Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / MFC

A Java Language IDE

Rate me:
Please Sign up or sign in to vote.
4.33/5 (26 votes)
13 May 2004CPOL3 min read 80.6K   3.4K   41  
This is a partially implemented IDE for the Java platform.
//#include "CCrystalTextBuffer.h"

/*
#define GETWORKSPACE      CVisualJavaApp::GetApp()->GetMainFrame()->GetViewDlg()
#define GETACTIVEFRAME    CVisualJavaApp::GetApp()->GetMainFrame()->GetActiveFrame()
#define GETMAINFRAME      CVisualJavaApp::GetApp()->GetMainFrame()
*/
#define error(szpErro)        MessageBox(0,szpErro,"JavaJam",MB_OK|MB_ICONERROR);

#define ID_NEWFILE_OPTIONS      0x12349137
#define ID_NEWPROJECT_OPTIONS   0x71289364
#define ID_MULTVIEW             0x74658213
#define ID_CLASSVIEW            0x00122243
#define ID_RESVIEW              0x11342216
#define ID_FILEVIEW             0x34556971
#define IDC_BUTTON_EXPAND       0x00003642
#define IDC_BUTTON_COLAPS       0x11111142
#define IDC_BUTTON_CLOSE        0x77777777

#define ID_COMBO_BROWSER        0x10202330

#define COOKIE_COMMENT			0x0001
#define COOKIE_PREPROCESSOR		0x0002
#define COOKIE_EXT_COMMENT		0x0004
#define COOKIE_STRING			0x0008
#define COOKIE_CHAR				0x0010

#define ID_TABSHEET     0x2317945
#define ID_BUILDOUTPUT  0x7461340
#define ID_FINDINFILE   0x4761327
#define ID_FINDINFILE1  0x8543719
#define ID_DEBUG        0x99

#define expand        0x1
#define colapse       0x2
#define select        0x1
#define unselect      0x2

#define INSERT_CONTEXT          0x11
#define DELETE_CONTEXT          0x12

//project type
#define  PRO_AWT                0x24
#define  PRO_SWING              0x25
#define  PRO_CONSOLE            0x26
//frame app type
#define  FRM_EDITOR             0x27
#define  FRM_TOOLBAR            0x28
#define  FRM_MENUBAR            0x29
#define  FRM_NONE               0x33

//app type
#define  APP_DIALOG             0x30
#define  APP_FRAME              0x31
#define  APP_APPLET             0x32
//file types
#define F_JAVA                  0x13
#define F_ASP                   0x14
#define F_CPP                   0x15
#define F_H                     0x16
#define F_HTML                  0x17
#define F_BIN                   0x18
#define F_TXT                   0x19
#define F_BMP                   0x20

//workspace item types
#define W_WORKSPACE             0x34
#define W_PROJECT               0x35
#define W_FILE                  0x36
#define W_FILE_FOLDER           0x37

//output window tab looks
#define STANDARD_3D    0x20
#define CUSTOM_3D      0x21
#define PLAIN_VC       0x22
#define BORDERS_3D     0x18
#define FLAT_BORDERS   0x17


//views



extern UINT WM_WORKSPACE_OPENED; //=::RegisterWindowMessage("WorkSpacedOpen");   
extern UINT WM_WORKSPACE_CLOSED;//=::RegisterWindowMessage("WorkSpacedClose"); 
//ASSERT(WM_WORKSPACE_LOADED);
//ASSERT(WM_WORKSPACE_UNLOADED);


    //options
    static LPCTSTR m_szpalias         =  _T("-alias");
	static LPCTSTR m_szpkeyalg        =  _T("-keyalg");
	static LPCTSTR m_szpkeyszie       =  _T("-keysize");
	static LPCTSTR m_szpsigalg        =  _T("-sigalg");
	static LPCTSTR m_szpdname         =  _T("-dname");
    static LPCTSTR m_szpkeypass       =  _T("-keypass");
	static LPCTSTR m_szpvalidity      =  _T("-validity");
	static LPCTSTR m_szpstoretype     =  _T("-storetype");
	static LPCTSTR m_szpkeystore      =  _T("-keystore");
	static LPCTSTR m_szpstorepass     =  _T("-storepass");
	static LPCTSTR m_szpprovider      =  _T("-provider");
	static LPCTSTR m_szpv             =  _T("-v");
	static LPCTSTR m_szpj             =  _T("-J");
	static LPCTSTR m_szpnoprompt      =  _T("-noprompt");
	static LPCTSTR m_szptrustcacerts  =  _T("-trustcacerts");
	static LPCSTR  m_szpfile          =  _T("-file");
	static LPCTSTR m_szpdest          =  _T("-dest");
	static LPCTSTR m_szpnew           =  _T("-new");
	static LPCTSTR m_szprfc           =  _T("-rfc");
	static LPCTSTR m_szpsigfile       =  _T("-sigfile");
	static LPCTSTR m_szpsignedjar     =  _T("-signedjar");
	static LPCTSTR m_szpverify        =  _T("-verify");
	static LPCTSTR m_szpcerts         =  _T("-certs");
	static LPCTSTR m_szpverbose       =  _T("-verbose");
	static LPCTSTR m_szpinternalsf    =  _T("-internalsf");
	static LPCTSTR m_szpsectionsonly  =  _T("-sectionsonly");
    static LPCTSTR m_szpo             =  _T("-o");
	static LPCTSTR m_szpd             =  _T("-d");
    static LPCTSTR m_szpversion       =  _T("-version");
	static LPCTSTR m_szpjni           =  _T("-jni");
	static LPCTSTR m_szpclasspath     =  _T("-classpath");
	static LPCTSTR m_szpbootclasspath =  _T("-bootclasspath");
	static LPCTSTR m_szpold           =  _T("-old");
	static LPCTSTR m_szpforce         =  _T("-force");
    static LPCTSTR m_szpstubs         =  _T("-stubs");
    static LPCTSTR m_szpl             =  _T("-l");
    static LPCTSTR m_szpb             =  _T("-b");
	static LPCTSTR m_szppublic        =  _T("-public");
	static LPCTSTR m_szpprotected     =  _T("-protected");
    static LPCTSTR m_szppackage       =  _T("-package");
	static LPCTSTR m_szpprivate       =  _T("-private");
	static LPCTSTR m_szps             =  _T("-s");
    static LPCTSTR m_szpc             =  _T("-c");
	static LPCTSTR m_szpextdirs       =  _T("-extdirs");
   
  
	//commands
	static LPCTSTR m_szpgenkey        =  _T("-genkey");
	static LPCTSTR m_szpimport        =  _T("-import");
	static LPCTSTR m_szpselfcert      =  _T("-selfcert");
	static LPCTSTR m_szpidentitydb    =  _T("-identitydb");
	static LPCTSTR m_szpcertreq       =  _T("-certreq");
	static LPCTSTR m_szpexport        =  _T("-export");
	static LPCTSTR m_szplist          =  _T("-list");
	static LPCTSTR m_szpprintcert     =  _T("-printcert");
	static LPCTSTR m_szpkeyclone      =  _T("-keyclone");
	static LPCTSTR m_szpstorepasswd   =  _T("-storepasswd");
	static LPCTSTR m_szpkeypasswd     =  _T("-keypasswd");
	static LPCTSTR m_szpdelete        =  _T("-delete");
	static LPCTSTR m_szphelp          =  _T("-help");


    static LPCTSTR m_szpText          =  _T("Text");
    static LPCTSTR m_szpTextSel       =	 _T("Text Selection");
    static LPCTSTR m_szpCurErrTag     =	 _T("Current Error/Tag");
    static LPCTSTR m_szpBkMrk         =	 _T("Bookmark");
    static LPCTSTR m_szpBrkPt         =	 _T("Break Point");
    static LPCTSTR m_szpCurSt         =	 _T("Current Statement");
    static LPCTSTR m_szpSelMar        =	 _T("Selection Margin");
    static LPCTSTR m_szpKeyWd         =	 _T("Keyword");
    static LPCTSTR m_szpCom	          =  _T("Comment");
    static LPCTSTR m_szpNum           =	 _T("Number");
    static LPCTSTR m_szpStr           =	 _T("String");
    static LPCTSTR m_szpOp            =	 _T("Operator");
    static LPCTSTR m_szpHtmlEleName   =	 _T("HTML Element Name");
    static LPCTSTR m_szpHtmlAttrName  =	 _T("HTML Attribute Name");
    static LPCTSTR m_szpHtmlAttrVal   =  _T("HTML Attribute Value");
    static LPCTSTR m_szpHtmlCom       =	 _T("HTML Comment");
    static LPCTSTR m_szpHtmlEnt       =	 _T("HTML Entity");
    static LPCTSTR m_szpHtmlTagDel    =	 _T("HTML Tag Delimiter");
    static LPCTSTR m_szpHtmlStr       =	 _T("HTML String");
    static LPCTSTR m_szpHtmlTagTxt    =	 _T("HTML Tag Text");
    static LPCTSTR m_szpHtmlOp        =	 _T("HTML Operator");
    static LPCTSTR m_szpHtmlSsS       =	 _T("HTML Server-Side Script");
    static LPCTSTR m_szpWzCode        =	 _T("Wizard Code");
    static LPCTSTR m_szpUserDefKeywd  =	 _T("User Defined Keywords");
    static LPCTSTR m_szpValHglt       =	 _T("Value Highlight");
    static LPCTSTR m_szpMemHglht      =	 _T("Memory Highlight");
    static LPCTSTR m_szpCallHglht     =	 _T("Calls Highlight");
    static LPCTSTR m_szpSupCd         =	 _T("Superceded Code");
    static LPCTSTR m_szpVarHglht      =	 _T("Variables Highlight");
    static LPCTSTR m_szpWatchHglht    =	 _T("Watch Highlight");
    static LPCTSTR m_szpAssemCode     =	 _T("Assembly Code");

    static LPCTSTR m_lszpAllWindow    =   _T("All Windows");
    static LPCTSTR m_lszpSrcWindow    =   _T("Source Windows");
    static LPCTSTR m_lszpDebugWnd     =   _T("Debugger Windows");
    static LPCTSTR m_lszpSrcBrowser   =   _T("Source Browser");
    static LPCTSTR m_lszpWorkspcWnd   =   _T("Workspace Window");
    static LPCTSTR m_lszpRegWindow    =   _T("Registers Window");
    static LPCTSTR m_lszpMemWindow    =   _T("Memory Window");
    static LPCTSTR m_lszpCallWindow   =   _T("Calls Window");
    static LPCTSTR m_lszpVarWindow    =   _T("Variables Window");
    static LPCTSTR m_lszpWatchWindow  =   _T("Watch Window");
    static LPCTSTR m_lszpDisAssemWnd  =   _T("Disassembly Window");

  //the key here is uniqueness not sequential correctness
 typedef enum
 {
   CT_FOR_LOOP = 0x1,
   CT_WHILE_LOOP = 0x2,
   CT_SWITCH = 0x3,
   CT_TRY_CATCH = 0x4,
   CT_CLASS = 0x5,
   CT_INTERFACE = 0x6,
   CT_FRAME_APP_EDITOR_SWING = 0x7,
   CT_FRAME_APP_TOOLBAR_SWING = 0x8,
   CT_FRAME_APP_MENUBAR_SWING = 0x9,
   CT_FRAME_APP_NONE_SWING = 0x10,
   CT_FRAME_APP_EDITOR_AWT = 0x11,
   CT_FRAME_APP_TOOLBAR_AWT = 0x12,
   CT_FRAME_APP_MENUBAR_AWT = 0x13,
   CT_FRAME_APP_NONE_AWT = 0x14,
   CT_DIALOG_APP_AWT = 0x15,
   CT_DIALOG_APP_SWING = 0x16,
   CT_CONSOLE_APP = 0x17,
   CT_APPLET_APP = 0x18
 }__CodeTemplate;


static LPTSTR s_apszFileTypeList[] =
{
  _T("java"),
  _T("cpp"),
  _T("h"),
  _T("asp"),
  _T("bin"),
  _T("txt"),
  NULL

};


static BOOL GetName(CString& szpPath,CString& szpName)
{
  szpPath.TrimLeft();szpPath.TrimRight();
  
  int nLength = szpPath.GetLength();
  int I       = szpPath.Find('.');
  if(I != -1)
  {
    
    CString ext = szpPath.Right(szpPath.GetLength()-I);
	--I;
    for(I; I>=0; I--)//retrive name
	{
      if(szpPath[I] == '\\'||I==0)
	  {
         if(szpPath[I] != '\\')
		   szpName.Insert(0,szpPath[I]);
         szpName += ext;
         //szpPath += szpPath.Left(I);
		 return TRUE;
	  }
	  else
	  szpName.Insert(0,szpPath[I]);
	}
  }
  return FALSE;
}

static void GenPath(int nDepth,CString& szpPath)
{
  /*for(int i=0; i<nDepth; i++)
  {
    if(int npos = szpPath.Find("\\") != -1&&!szpPath.IsEmpty())
	{
                 
   
	}
	else
	break;
  }*/
}

static BOOL GetExt(CString szpName,CString& szpExt)
{
  int i = szpName.Find('.');
  if(i != -1)
  {
     szpExt = szpName.Right(szpName.GetLength()-i);
	 szpExt.TrimLeft('.');
     return TRUE;
  }
  return FALSE;
}

static int FILE_TYPE(LPCTSTR szpF)
{
  int npos = CString(szpF).Find('.');
  ++npos;
  szpF = CString(szpF).Right(CString(szpF).GetLength()-npos);

  if(CString(szpF).Compare("java") == 0)
	  return F_JAVA;
  else
  if(CString(szpF).Compare("asp") == 0)
	  return F_ASP;
  else
  if(CString(szpF).Compare("cpp") == 0)
	  return F_CPP;
  else
  if(CString(szpF).Compare("h") == 0)
	  return F_H;
  else
  if(CString(szpF).Compare("html") == 0)
	  return F_HTML;
  else
  if(CString(szpF).Compare("bin") == 0)
	  return F_BIN;
  else
  if(CString(szpF).Compare("txt") == 0)
	  return F_TXT;
  return 0;
}

static int FILE_TYPE_EX(LPCTSTR szpF)
{
  if(CString(szpF).Compare("Java Source Files") == 0)
	  return F_JAVA;
  else
  if(CString(szpF).Compare("ASP Files") == 0)
	  return F_ASP;
  else
  if(CString(szpF).Compare("Cpp Source Files") == 0)
	  return F_CPP;
  else
  if(CString(szpF).Compare("C header Files") == 0)
	  return F_H;
  else
  if(CString(szpF).Compare("Html Files") == 0)
	  return F_HTML;
  else
  if(CString(szpF).Compare("Binary Files") == 0)
	  return F_BIN;
  else
  if(CString(szpF).Compare("Text Files") == 0)
	  return F_TXT;
  else
  if(CString(szpF).Compare("Bitmap Files") == 0)
	  return F_BMP;
  return 0;
}


static LPCTSTR FILE_TYPE_NUM_TO_STR(UINT nType)
{
  if(nType == F_JAVA)
   return _T("Java Source Files");
  else
  if(nType == F_ASP)
   return _T("ASP Files");
  else
  if(nType == F_CPP)
   return _T("Cpp Source Files");
  else
  if(nType == F_H)
   return _T("C header Files");
  else
  if(nType == F_HTML)
   return _T("Html Files");
  else
  if(nType == F_BIN)
   return _T("Binary Files");
  else
  if(nType == F_TXT)
   return _T("Text Files");
  else
  if(nType == F_BMP)
   return _T("Bitmap Files");
  return 0;
}



#define ID_VIEWTAB              0x55
#define ID_OUTPUT               0x56
#define ID_WORKSPACE            0x57

#define IS_PUBLIC               0x62
#define IS_PRIVATE              0x63
#define IS_PROTECTED            0x64

#define IS_CLASS                0x58
#define IS_FUNC                 0x59
#define IS_VAR                  0x60
#define IS_LOCAL                0x61
#define IS_BLOCK                0x17

#define IS_INTERFACE            0x65
#define IS_IMPORT               0x66
#define IS_PACKAGE              0x67

#define PARAM                   0x88
#define ASSIGN                  0x17



static UINT ACCESS(LPCTSTR ac)
{
  if(strcmp(ac,"public") == 0)
		return IS_PUBLIC;
  else
  if(strcmp(ac,"protected") == 0)
		return IS_PROTECTED;
  else
  return IS_PRIVATE;
}

static BOOL is_opCode(char c)
{
  if(c == '+'||c == '-'||c == '*'
  ||c == '/'||c == '%'||c == '|'||c == '&'
  ||c == '^'||c == '>'||c == '<'||c == '!')
  return TRUE;
  return FALSE;
}



static LPTSTR s_apszJavaModifiers[]=
{
	_T("abstract"),
	_T("final"),
	_T("public"),
	_T("private"),
	_T("protected"),
	_T("static"),
	_T("transient"),
	_T("volatile"),
	_T("native"),
	_T("synchronized"),
	NULL
};


//	C++ keywords (MSVC5.0 + POET5.0)
static LPTSTR s_apszCppKeywordList[] =
{
	_T("__asm"),
	_T("abstract"),
	_T("public"),
	_T("private"),
	_T("protected"),
	_T("static"),
	_T("transient"),
	_T("volatile"),
	_T("native"),
	_T("synchronized"),
	_T("enum"),
	_T("__multiple_inheritance"),
	_T("template"),
	_T("auto"),
	_T("__except"),
	_T("__single_inheritance"),
	_T("this"),
	_T("__based"),
	_T("explicit"),
	_T("__virtual_inheritance"),
	_T("thread"),
	_T("bool"),
	_T("extern"),
	_T("mutable"),
	_T("throw"),
	_T("break"),
	_T("false"),
	_T("naked"),
	_T("true"),
	_T("case"),
	_T("__fastcall"),
	_T("namespace"),
	_T("try"),
	_T("catch"),
	_T("__finally"),
	_T("new"),
	_T("__try"),
	_T("__cdecl"),
	_T("float"),
	_T("operator"),
	_T("typedef"),
	_T("char"),
	_T("for"),
	_T("typeid"),
	_T("class"),
	_T("friend"),
	_T("typename"),
	_T("const"),
	_T("goto"),
	_T("public"),
	_T("union"),
	_T("const_cast"),
	_T("if"),
	_T("register"),
	_T("unsigned"),
	_T("continue"),
	_T("inline"),
	_T("reinterpret_cast"),
	_T("using"),
	_T("__declspec"),
	_T("__inline"),
	_T("return"),
	_T("uuid"),
	_T("default"),
	_T("int"),
	_T("short"),
	_T("__uuidof"),
	_T("delete"),
	_T("__int8"),
	_T("signed"),
	_T("virtual"),
	_T("dllexport"),
	_T("__int16"),
	_T("sizeof"),
	_T("void"),
	_T("dllimport"),
	_T("__int32"),
	_T("do"),
	_T("__int64"),
	_T("static_cast"),
	_T("wmain"),
	_T("double"),
	_T("__leave"),
	_T("__stdcall"),
	_T("while"),
	_T("dynamic_cast"),
	_T("long"),
	_T("struct"),
	_T("xalloc"),
	_T("else"),
//	_T("main"),
	_T("switch"),
	_T("interface"),
	//	Added by a.s.
	_T("persistent"),
	_T("_persistent"),
	_T("depend"),
	_T("ondemand"),
	_T("cset"),
	_T("useindex"),
	_T("indexdef"),
	_T("extends"),
	_T("implements"),
	_T("boolean"),
	_T("byte"),
	_T("import"),
	_T("final"),
	NULL
};






static CString jtypes[] = {"char","int","long","float",
	                "double","boolean","byte",
					"short","void"};

static LPTSTR s_apszJavaTypeList[] = 
{
 _T("char"),
 _T("int"),
 _T("long"),
 _T("float"),
 _T("double"),
 _T("boolean"),
 _T("byte"),
 _T("short"),
 _T("void"),
  NULL
};


static BOOL IsJavaType(LPCTSTR pszChars, int nLength)
{  
	for (int L = 0; s_apszJavaTypeList[L] != NULL; L ++)
	{
		if (strncmp(s_apszJavaTypeList[L], pszChars, nLength) == 0
				&& s_apszJavaTypeList[L][nLength] == 0) 
			   return TRUE;
			 
	}
	return FALSE;
}


static BOOL IsCppKeyword(LPCTSTR pszChars, int nLength)
{

	for (int L = 0; s_apszCppKeywordList[L] != NULL; L ++)
	{
		if (strncmp(s_apszCppKeywordList[L], pszChars, nLength) == 0
				&& s_apszCppKeywordList[L][nLength] == 0) 
			   return TRUE;
			 
	}
	return FALSE;
}


static BOOL isModifier(LPCTSTR pszChars, int nLength)
{
	for (int L = 0; s_apszJavaModifiers[L] != NULL; L ++)
	{
		if (strncmp(s_apszJavaModifiers[L], pszChars, nLength) == 0
				&& s_apszJavaModifiers[L][nLength] == 0) 
			   return TRUE;
			 
	}
	return FALSE;
}


static BOOL IsCppNumber(LPCTSTR pszChars, int nLength)
{
	if (nLength > 2 && pszChars[0] == '0' && pszChars[1] == 'x')
	{
		for (int I = 2; I < nLength; I++)
		{
			if (isdigit(pszChars[I]) || (pszChars[I] >= 'A' && pszChars[I] <= 'F') ||
										(pszChars[I] >= 'a' && pszChars[I] <= 'f'))
				continue;
			return FALSE;
		}
		return TRUE;
	}
	if (! isdigit(pszChars[0]))
		return FALSE;
	for (int I = 1; I < nLength; I++)
	{
		if (! isdigit(pszChars[I]) && pszChars[I] != '+' &&
			pszChars[I] != '-' && pszChars[I] != '.' && pszChars[I] != 'e' &&
			pszChars[I] != 'E')
			return FALSE;
	}
	return TRUE;
}

static BOOL IsValidDir(LPCTSTR szpDir)
{
   int nLen = strlen(szpDir);
   CString szpBuff;
   BOOL bDrive = FALSE;
   BOOL bInit  = TRUE;
   for(int I=0; I<=nLen+1; I++)
   {
     char nChar = szpDir[I];
	 if(I==nLen+1)
	 {
       return TRUE;

	 }
	 else
	 if(nChar == '\\')
	 {
       bInit = FALSE;
	   if(szpBuff.Compare("\\")==0)
		   return FALSE;
	   szpBuff = '\\';
	 }
	 else
	 if(!bDrive&&bInit&&!szpBuff.IsEmpty()&&nChar == ':')
	 {
       bInit = FALSE;
	 }
	 else
	 if(nChar == '/'||nChar == '*'||nChar=='<'||nChar == '>'||nChar == '|')
		 return FALSE;
	 else
	 szpBuff += szpDir[I];
   }
   return FALSE;
}

#include "MsgOutPut.h"
#include "OutPutDlg.h"

#define OUTPUT_BUILD(szpText) COutPutDlg::m_pwndBuildOutPut->OutPut(szpText)
#define OUTPUT_DEBUG(szpText) COutPutDlg::m_pwndDebugOutPut->OutPut(szpText)
#define OUTPUT_FenF1(szpText) COutPutDlg::m_pwndFindInFiles_1->OutPut(szpText)
#define OUTPUT_FenF2(szpText) COutPutDlg::m_pwndFindInFiles_2->OutPut(szpText)


extern 	HTREEITEM AddFunc(CString pszItem,HTREEITEM hParent, UINT naccess,DWORD dwData = 0);
extern  HTREEITEM AddVar(CString pszItem,HTREEITEM hParent,UINT naccess,DWORD dwData = 0);
extern  void RemoveItem(HTREEITEM hItem,UINT nType = -1);
extern  HTREEITEM AddItem(CString pszItem,HTREEITEM hParent = 0,UINT ntype = 0,UINT naccess=0,DWORD dwData = 0);
extern  void PrintBound(int nStartIndex,int nStartLine,int nEndIndex,int nEndLine,CString strLabel = "");

extern HTREEITEM addProject(CString strProj);
extern HTREEITEM addSource(HTREEITEM,CString strSource);
extern HTREEITEM addImports(HTREEITEM,CString strImports);

extern HTREEITEM removeOnContainZero(HTREEITEM);


#include "XPButton_.h"
#define   CButton CXPButton

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
biography? I am not that old yet.

Comments and Discussions