Creating Java Integrated Development Environment (IDE) In C#


 

 
Introduction

I have created a project named Silver-J in Visual Studio and used a text editor,  ICSharpCode.TextEditor.dll. You can use any other text editor that you want. In this document, we will focus only on creating Project file, reading Project file, and starting processes for compiling Java source code file. I have defined all the functions in the same project without creating other library (dll). There may be some extra unneeded memory-consuming code in it.

To understand this source code, read the Creating Advanced Notepad In C# article.

You can read the following articles to create or customize your IDE.

I have used C# programming language to create this IDE but it is possible to create IDE in Java. The benefits of using Java are that you can access all the features of it. It also supports many syntax highlighting libraries. C# & Java are syntactically same.

The following article may help you to learn how to create Tabbed Notepad Editor in Java.

Requirements
  • Visual Studio 2013 Professional
  • .NET framework 4.5
  • ICSharpCode.TextEditor.dll library

I have used these in this project because they are free. But, you can use any other library for syntax highlighting. I have also used some features of this library.

You can download it from the following sites.

Files 

For this application, we need many files where we can store the data. These files are stored in the "Files" folder at application location.

  1. appletcode.slvjapplet file
  2. config.slvj file
  3. defaultprojloc.slvj file
  4. files.slvj file
  5. jkeywords.slvj file
  6. jpackages.slvj file
  7. mainhtmlsource.slvj main HTML file
  8. themesfile.slvj theme file
  9. <project_name>.slvjproj

Download the source code.

appletcode.slvjapplet 

This file contains HTML source code with <applet></applet> tag.

config.slvj

This file contains the data about everything in our application like JDK path or browser path to show ToolStrip, StatusStrip, or not, SplitContainer values. e.g:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <!--    
  3.             Silver-J  
  4.     Free light weight IDE for Java     
  5.      Copyright(c) 2016. All rights reserved  
  6. -->  
  7. <SilverJConfiguration>  
  8.     <!--JDK Path-->  
  9.     <JDKPath>C:\Program Files\Java\jdk1.8.0_25\bin</JDKPath>  
  10.     <!-- web browser -->  
  11.     <WebBrowser>C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</WebBrowser>  
  12.      <!--text editor font & font size-->  
  13.     <Font>Microsoft YaHei UI</Font>  
  14.     <FontSize>10</FontSize>  
  15.     <!--views-->  
  16.     <!--Appearance-->  
  17.      <Appearance>Default</Appearance>  
  18.     <!--text editor views-->  
  19.     <ShowLineNumbers>true</ShowLineNumbers>  
  20.     <ShowLineHighlighter>true</ShowLineHighlighter>  
  21.     <ShowInvalidLines>false</ShowInvalidLines>  
  22.     <ShowEndOfLineMarker>false</ShowEndOfLineMarker>  
  23.     <ShowVisibleSpaces>false</ShowVisibleSpaces>  
  24.     <BracesMatching>true</BracesMatching>  
  25.     <AutoCompleteBraces>true</AutoCompleteBraces>  
  26.     <!--split containers-->  
  27.     <SplitContainer1>1132</SplitContainer1>  
  28.     <SplitContainer2>559</SplitContainer2>  
  29.     <SplitContainer3>280</SplitContainer3>  
  30.     <SplitContainer4>315</SplitContainer4>  
  31.      <!--tabs,documents etc views-->  
  32.     <TabsAlignment>Top</TabsAlignment>  
  33.     <ShowStatusStrip>true</ShowStatusStrip>  
  34.      <ShowToolStrip>true</ShowToolStrip>  
  35.     <ShowProjectExplorer>true</ShowProjectExplorer>  
  36.     <ShowClassesView>true</ShowClassesView>  
  37.     <ShowMethodsView>true</ShowMethodsView>  
  38.     <ShowErrorList>true</ShowErrorList>  
  39.     <ShowErrorDialog>false</ShowErrorDialog>  
  40.     <ShowStartPageOnStartUp>true</ShowStartPageOnStartUp>  
  41.     <!--Auto Compile Java-->  
  42.     <AutoCompileJava>false</AutoCompileJava>  
  43.     <!--Auto Completion Mode-->  
  44.     <AutoCompletion>true</AutoCompletion>  
  45. </SilverJConfiguration>  

defaultprojloc.slvj file

This file contains the current created or opened project name, project folder path, project folder file (.slvjproj) and project type.

  1.  <?xml version="1.0" encoding="utf-8"?>  
  2. <SilverJ>  
  3.      <DefaultProjectLocation>C:\My Java Projects</DefaultProjectLocation>  
  4.     <CurrentProjectName>LookAndFeelDemo</CurrentProjectName>  
  5.  <CurrentProjectFileName>C:\My Java Projects\LookAndFeelDemo\LookAndFeelDemo.slvjproj</CurrentProjectFileName>  
  6.      <CurrentProjectType>ApplicationType</CurrentProjectType>  
  7. </SilverJ>  

files.slvj file

This file contains the file names that are read from <VisualFile></VisualFile> tag from opened project file name.

jkeywords.slvj file

This file contains the Java keywords which will be used for code completion (see MyTabPage.cs file).

jpackages.slvj file

This file contains the Java packages which will be used to insert packages option Edit->Insert->Packages.

mainhtmlsource.slvj main html file

Contains the HTML source code when New->HTML file is added or created.

themesfile.slvjtheme file

This file contains the Java code when we create Java Class with Java Themes.

<project_name>.slvjproj

This file is stored in the users project folder. This file contains ProjectName, ProjectLocationFolder, ProjectType, MainClassFile, JavaClassFile, VisualFile, OtherFile. e.g of LookAndFeelDemo.slvjproj

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <SilverJProject>  
  3. <!--Silver-J (1.0) Java Application Project-->  
  4. <ProjectName>LookAndFeelDemo</ProjectName>  
  5. <ProjectLocationFolder>C:\My Java Projects\LookAndFeelDemo</ProjectLocationFolder>  
  6. <ProjectLocationFile>C:\My Java Projects\LookAndFeelDemo\LookAndFeelDemo.slvjproj</ProjectLocationFile>  
  7. <ProjectType>ApplicationType</ProjectType>  
  8. <MainClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\LookAndFeelDemo.java</MainClassFile>  
  9. <JavaClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\JavaBlueTheme.java</JavaClassFile>  
  10. <JavaClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\JavaGreenTheme.java</JavaClassFile>  
  11. <JavaClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\JavaRedTheme.java</JavaClassFile>  
  12. <JavaClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\LookAndFeelDemo.java</JavaClassFile>  
  13. <JavaClassFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\TestFrame.java</JavaClassFile>  
  14. <VisualFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\LookAndFeelDemo.java</VisualFile>  
  15. <VisualFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\JavaGreenTheme.java</VisualFile>  
  16. <VisualFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\JavaRedTheme.java</VisualFile>  
  17. <VisualFile>C:\My Java Projects\LookAndFeelDemo\srcclasses\TestFrame.java</VisualFile>  
  18. </SilverJProject>  
Visual file is the Java Class file which is only used to open this file in tab or not, when the project is opened. 
 
Coding

Create Java Project

Add new Windows Form to your project. Here, I used New_JavaApplicationProject_Form (New_JavaApplicationProject_Form.cs file) and designed it with Project Name textbox, Project Location textbox, Create Java Class checkbox with Browse, Finish, and Cancel buttons.

   

In the file New_JavaApplicationProject_Form.cs, we will just read a file \\files\\defaultprojloc.slvjfile .

We will also take input from the above form as Project name, project location etc.

I have used the following variable to store it.

  1. String projloc = ProjectLocationTextBox.Text;  
  2. String projfolder = projectfolderlabel.Text;  
  3. String projectname = ProjectNameTextBox.Text;  
  4. String projectfile;  

Now, we need to create a folder (directory) same as project name in the read project location folder (projfolder).Once the directory is created, we will create classes, src, srcclasses directories in it.

Once the project directory is created, we need to create project file with file extension as .slvjproj (file name is same as created project name). In that file, we will save our project data as defined in above File section. We will save the data in XML format.

Following is the function that performs actions.

  1. public void CreateJavaProject()  
  2. {  
  3.     String projloc = ProjectLocationTextBox.Text;  
  4.     String projfolder = projectfolderlabel.Text;  
  5.     String projectname = ProjectNameTextBox.Text;  
  6.     String projectfile;  
  7.   
  8.     if (projloc != "" && projectname != "")  
  9.     {  
  10.         projectfile = projectname + ".slvjproj";  
  11.         if (checkBox1.Checked == false)  
  12.         {  
  13.             if (Directory.Exists(projloc + "\\" + projfolder))  
  14.             {  
  15.                 MessageBox.Show("Entered project name folder is already exists in current location","Error............");  
  16.             }  
  17.             else  
  18.             {  
  19.                 //create project directory & project file  
  20.                 Directory.CreateDirectory(projloc + "\\" + projfolder);  
  21.   
  22.                 //create classes directory  
  23.                 Directory.CreateDirectory(projloc + "\\" + projfolder + "\\classes");  
  24.   
  25.                 //creating & writing slvjproj file  
  26.                 using (XmlWriter xmlwriter = XmlWriter.Create(projloc + "\\" + projfolder + "\\" + projectfile))  
  27.                 {  
  28.                     xmlwriter.WriteStartDocument();  
  29.                     xmlwriter.WriteStartElement("SilverJProject");  
  30.                     xmlwriter.WriteString("\n");  
  31.                     xmlwriter.WriteComment("Silver-J (1.0) Java Application Project");  
  32.                     xmlwriter.WriteString("\n");  
  33.                     xmlwriter.WriteElementString("ProjectName", projectname);  
  34.                     xmlwriter.WriteString("\n");  
  35.                     xmlwriter.WriteElementString("ProjectLocationFolder", projloc + "\\" + projfolder);  
  36.                     xmlwriter.WriteString("\n");  
  37.                     xmlwriter.WriteElementString("ProjectLocationFile", projloc + "\\" + projfolder + "\\" + projectfile);  
  38.                     xmlwriter.WriteString("\n");  
  39.                     xmlwriter.WriteElementString("ProjectType""ApplicationType");  
  40.                     xmlwriter.WriteEndElement();  
  41.                     xmlwriter.WriteEndDocument();  
  42.                     xmlwriter.Close();  
  43.                 }  
  44.   
  45.                 String defaultprojfilepath = Application.StartupPath + "\\files\\defaultprojloc.slvjfile";  
  46.   
  47.                 projectfilename = projloc + "\\" + projfolder + "\\" + projectfile;  
  48.   
  49.                 XmlDocument doc = new XmlDocument();  
  50.                 doc.Load(defaultprojfilepath);  
  51.                 doc.SelectSingleNode("SilverJ/DefaultProjectLocation").InnerText = ProjectLocationTextBox.Text;  
  52.                 doc.SelectSingleNode("SilverJ/CurrentProjectName").InnerText = ProjectNameTextBox.Text;  
  53.                 doc.SelectSingleNode("SilverJ/CurrentProjectFileName").InnerText = projectfilename;  
  54.                 doc.SelectSingleNode("SilverJ/CurrentProjectType").InnerText = "ApplicationType";  
  55.                 doc.Save(defaultprojfilepath);  
  56.   
  57.                 a = 1;  
  58.   
  59.                 this.Close();  
  60.                 isfinished = true;  
  61.             }  
  62.         }  
  63.   
  64.   
  65.         else if (checkBox1.Checked == true)  
  66.         {  
  67.             if (JavaClassTextBox.Text != "")  
  68.             {  
  69.                 String classname = JavaClassTextBox.Text;  
  70.                 if (classname.Contains(".java"))  
  71.                 {  
  72.                 }  
  73.                 else  
  74.                 {  
  75.                     classname = classname + ".java";  
  76.                 }  
  77.   
  78.                 String javafilename = classname;  
  79.   
  80.                 if (Directory.Exists(projloc + "\\" + projfolder))  
  81.                 {  
  82.                     MessageBox.Show("Entered project name folder is already exists in current location""Error............");  
  83.                 }  
  84.                 else  
  85.                 {  
  86.                     //create project directory & project file  
  87.                     Directory.CreateDirectory(projloc + "\\" + projfolder);  
  88.                     //create srcclasses directory  
  89.                     Directory.CreateDirectory(projloc + "\\" + projfolder + "\\srcclasses");  
  90.                     //create classes directory  
  91.                     Directory.CreateDirectory(projloc + "\\" + projfolder + "\\classes");  
  92.   
  93.                     String fname = projloc + "\\" + projfolder + "\\srcclasses\\" + javafilename;  
  94.                     createdfilename = fname;  
  95.                     String filename = fname.Substring(fname.LastIndexOf("\\") + 1);  
  96.   
  97.                     //creating & writing slvjproj file  
  98.                     using (XmlWriter xmlwriter = XmlWriter.Create(projloc + "\\" + projfolder + "\\" + projectfile))  
  99.                     {  
  100.                         xmlwriter.WriteStartDocument();  
  101.                         xmlwriter.WriteStartElement("SilverJProject");  
  102.                         xmlwriter.WriteString("\n");  
  103.                         xmlwriter.WriteComment("Silver-J (1.0) Java Application Project");  
  104.                         xmlwriter.WriteString("\n");  
  105.                         xmlwriter.WriteElementString("ProjectName", projectname);  
  106.                         xmlwriter.WriteString("\n");  
  107.                         xmlwriter.WriteElementString("ProjectLocationFolder", projloc + "\\" + projfolder);  
  108.                         xmlwriter.WriteString("\n");  
  109.                         xmlwriter.WriteElementString("ProjectLocationFile", projloc + "\\" + projfolder + "\\" + projectfile);  
  110.                         xmlwriter.WriteString("\n");  
  111.                         xmlwriter.WriteElementString("ProjectType""ApplicationType");  
  112.                         xmlwriter.WriteString("\n");  
  113.                         xmlwriter.WriteElementString("MainClassFile", fname);  
  114.                         xmlwriter.WriteString("\n");  
  115.                         xmlwriter.WriteElementString("JavaClassFile", fname);  
  116.                         xmlwriter.WriteString("\n");  
  117.                         xmlwriter.WriteElementString("VisualFile", fname);  
  118.                         xmlwriter.WriteEndElement();  
  119.                         xmlwriter.WriteEndDocument();  
  120.                         xmlwriter.Close();  
  121.                     }  
  122.   
  123.                     isSaved = true;  
  124.   
  125.                     String defaultprojfilepath = Application.StartupPath + "\\files\\defaultprojloc.slvjfile";  
  126.   
  127.   
  128.                     projectfilename = projloc + "\\" + projfolder + "\\" + projectfile;  
  129.   
  130.                     XmlDocument doc = new XmlDocument();  
  131.                     doc.Load(defaultprojfilepath);  
  132.                     doc.SelectSingleNode("SilverJ/DefaultProjectLocation").InnerText = ProjectLocationTextBox.Text;  
  133.                     doc.SelectSingleNode("SilverJ/CurrentProjectName").InnerText = ProjectNameTextBox.Text;  
  134.                     doc.SelectSingleNode("SilverJ/CurrentProjectFileName").InnerText = projectfilename;  
  135.                     doc.SelectSingleNode("SilverJ/CurrentProjectType").InnerText = "ApplicationType";  
  136.                     doc.Save(defaultprojfilepath);  
  137.   
  138.                     a = 2;  
  139.   
  140.                     this.Close();  
  141.                     isfinished = true;  
  142.                 }  
  143.             }  
  144.         }  
  145.     }  
  146. }  

First, check if project location and project name are not empty strings. Then, check whether "Create Java Class" checkbox is checked or not. If it is not checked, then just create project without .java source file.

First, create your Java project file (projectfile = projectname + ".slvjproj";). Then, we create this file and start to write that file by using XmlWriter class. 

We will write Project Name, Project Location Folder, Project type tags with its read values. Once we are done with this, we need to change the contents of file defaultprojloc.slvjfile 

In this file, we will save current created/opened project name, location folder, project location file, project type.

If Create Java Class check box is checked then we will perform all action as above just adding following tags and info to it.where fname is entered java class file name

  1. xmlwriter.WriteElementString("MainClassFile", fname);  
  2. xmlwriter.WriteString("\n");  
  3. xmlwriter.WriteElementString("JavaClassFile", fname);  
  4. xmlwriter.WriteString("\n");  
  5. xmlwriter.WriteElementString("VisualFile", fname);  

I am keeping track of created project, which means if Project is created without creating a java class (which means Create Java Class checkbox is unchecked) then CheckProjectType() function return 1 otherwise it returns 2(variable a is used for this). This is  for creating file, adding tabs to tabcontrol, adding projectname & filename to treeview etc. in MainForm.cs file.

Consider you have already designed you main IDE.

Now event for clicking on File->New->New Java Application Project

First show the New java application dialog form.

Download the source code.

ReadCurrentProjectFileName() function returns the string as project file name by reading file \files\defaultprojloc.slvjfile by reading tag CurrentProjectFileName.

If CheckProjectType() is 2 then we will create create a file by reading JavaClassFile tag text from current project, add tab to tabcontrol with control of texteditor,changing text of MainForm, add projectname & file names to ProjectExplorerTreeView and then we will save that file.

  1. private void File_New_JavaApplicationProjectMenuItem_Click(object sender, EventArgs e)  
  2.     {  
  3.         New_JavaApplicationProject_Form njap = new New_JavaApplicationProject_Form(this, ProjectExplorerTreeView, myTabControl);  
  4.         njap.ShowDialog();  
  5.   
  6.         String projectname = "";  
  7.         String javaclassfilename = "";  
  8.   
  9.             //create project with class  
  10.             if (njap.CheckProjectType() == 2)  
  11.             {  
  12.                 if (ReadCurrentProjectFileName() != "" && File.Exists(ReadCurrentProjectFileName()))  
  13.                 {  
  14.                     //first reading project name & java class file when project type = 2  
  15.                     String projectfilename = ReadCurrentProjectFileName();  
  16.                     if (File.Exists(projectfilename))  
  17.                     {  
  18.                         using (XmlReader xmlreader = XmlReader.Create(projectfilename))  
  19.                         {  
  20.                             while (xmlreader.Read())  
  21.                             {  
  22.                                 if (xmlreader.IsStartElement())  
  23.                                 {  
  24.                                     switch (xmlreader.Name.ToString())  
  25.                                     {  
  26.                                         case "ProjectName": projectname = xmlreader.ReadString();  
  27.                                             break;  
  28.   
  29.                                         case "JavaClassFile": javaclassfilename = xmlreader.ReadString();  
  30.                                             break;  
  31.                                     }  
  32.                                 }  
  33.                             }  
  34.                         }  
  35.   
  36.                         if (projectfilename != "" && javaclassfilename != "" && njap.getCreatedFileName() != "")  
  37.                         {  
  38.                             //adding nodes to tree view  
  39.                             //changing main form name to project name  
  40.                             //adding file name to filenametoolstriplabel  
  41.                             ProjectExplorerTreeView.Nodes.Clear();  
  42.                             myTabControl.TabPages.Clear();  
  43.   
  44.                             String prjname = projectfilename.Substring(projectfilename.LastIndexOf("\\") + 1);  
  45.                             prjname = prjname.Remove(prjname.Length - 9);  
  46.                             this.Text = "Silver-J - [ " + prjname + " ]";  
  47.   
  48.                             String jclassfilename = javaclassfilename.Substring(javaclassfilename.LastIndexOf("\\") + 1);  
  49.                             String jclassnamewithoutjava = jclassfilename.Remove(jclassfilename.Length - 5);  
  50.   
  51.                             MyTabPage mytabpage = new MyTabPage(this);  
  52.                             mytabpage.Text = jclassfilename;  
  53.                             mytabpage.textEditor.Text = "/*******************************\n                    "+prjname+"     \n*********************************/"  
  54.                                  + "\npublic class " + jclassnamewithoutjava + "  {" + "\n                                                                " + "\n}";  
  55.                             mytabpage.textEditor.ContextMenuStrip = textEditorContextMenuStrip;  
  56.   
  57.                             myTabControl.TabPages.Add(mytabpage);  
  58.                             myTabControl.SelectedTab = mytabpage;  
  59.   
  60.                             TreeNode projecttreenode = new TreeNode();  
  61.                             projecttreenode.Text = prjname;  
  62.                             projecttreenode.ImageIndex = 6;  
  63.                             projecttreenode.SelectedImageIndex = 6;  
  64.                             ProjectExplorerTreeView.Nodes.Add(projecttreenode);  
  65.                             ProjectExplorerTreeView.SelectedNode = projecttreenode;  
  66.   
  67.                             TreeNode trnode = ProjectExplorerTreeView.Nodes[0];  
  68.                             TreeNode jclassnode = new TreeNode();  
  69.                             jclassnode.Text = jclassfilename;  
  70.                             jclassnode.ImageIndex = 2;  
  71.                             jclassnode.SelectedImageIndex = 2;  
  72.                             trnode.Nodes.Add(jclassnode);  
  73.                             ProjectExplorerTreeView.ExpandAll();  
  74.   
  75.                             if (njap.getCreatedFileName() != "")  
  76.                             {  
  77.                                 try  
  78.                                 {  
  79.                                     StreamWriter strw = new StreamWriter(njap.getCreatedFileName());  
  80.                                     strw.Write(mytabpage.textEditor.Text);  
  81.                                     strw.Close();  
  82.                                     strw.Dispose();  
  83.                                 }  
  84.                                 catch  
  85.                                 { }  
  86.                             }  
  87.                         }  
  88.                     }  
  89.                 }  
  90.             }  
  91.   
  92.              //create project without class  
  93.             else if (njap.CheckProjectType() == 1)  
  94.             {  
  95.                 if (ReadCurrentProjectFileName() != "" && File.Exists(ReadCurrentProjectFileName()))  
  96.                 {  
  97.                     String projectfilename2 = ReadCurrentProjectFileName();  
  98.                     if (File.Exists(projectfilename2))  
  99.                     {  
  100.                         using (XmlReader xmlreader = XmlReader.Create(projectfilename2))  
  101.                         {  
  102.                             while (xmlreader.Read())  
  103.                             {  
  104.                                 if (xmlreader.IsStartElement())  
  105.                                 {  
  106.                                     switch (xmlreader.Name.ToString())  
  107.                                     {  
  108.                                         case "ProjectName": projectname = xmlreader.ReadString();  
  109.                                             break;  
  110.                                     }  
  111.                                 }  
  112.                             }  
  113.                         }  
  114.   
  115.                         if (projectfilename2 != "")  
  116.                         {  
  117.                             ProjectExplorerTreeView.Nodes.Clear();  
  118.                             myTabControl.TabPages.Clear();  
  119.   
  120.                             String prjname = projectfilename2.Substring(projectfilename2.LastIndexOf("\\") + 1);  
  121.                             prjname = prjname.Remove(prjname.Length - 9);  
  122.                             this.Text = "Silver-J - [ " + prjname + " ]";  
  123.   
  124.   
  125.                             TreeNode projecttreenode = new TreeNode();  
  126.                             projecttreenode.Text = prjname;  
  127.                             projecttreenode.ImageIndex = 6;  
  128.                             projecttreenode.SelectedImageIndex = 6;  
  129.                             ProjectExplorerTreeView.Nodes.Add(projecttreenode);  
  130.                             ProjectExplorerTreeView.SelectedNode = projecttreenode;  
  131.                         }  
  132.                     }  
  133.                 }  
  134.             }  
  135.   
  136.   
  137.         if (njap.IsFinished() == true)  
  138.         {  
  139.             FilenameToolStripLabel.Text = "Silver-J";  
  140.             AddFilesToProjectExplorerTreeView();  
  141.             WriteCurrentFileNames();  
  142.             CopyAllSourceFilesToSRCFolder();  
  143.             UpdateWindowsList_WindowMenu();  
  144.             SetVisibilityOfToolStripButtons();  
  145.             myTabControl_SelectedIndexChanged(sender, e);  
  146.         }  
  147.     }  

If njap.isFinished()==true it will call all functions that we need to change or modify the IDE such as adding files to project explorer tree view,set visibility of toolstrip buttons,changing text of FilenameToolStripLabel to current opened file name.

  • WriteCurrentFileNames() this function reads all files from current opened project file name & write those file name to \files\files.slvjfile for save operation.
  • CopyAllSourceFilesToSRCFolder() this function copies the all files from srcclasses to src folder without including .class file.
  • UpdateWindowsList_WindowMenu() this function checks tabs in tabcontrol and add those tab texts to Window menu by creating new menu items for selecting each tab by clicking on that menu item.

What we are doing here is:

In New_JavaApplicationProject_Form.cs file,we are creating project file(<project_name>.slvjproj),writing project data to this file, creating directories (Project named directory in that classes,src,srcclasses directories).

In MainForm.cs file,we are reading created project file(<project_name>.slvjproj),

Adding tabs to tabcontrol with text of created filename,creating that file & writing that file,also adding contents to ProjectExplorerTreeview.

Where tab is MyTabPage which is going to add to tabcontrol.(see MyTabPage.cs)

See following article for a better understanding of adding tabs,

Same actions to create New Java Applet Project, only one extra content to create it, which means index.html file. 

New Java Class

Now we need a class form that creates a java class.To create class a java project it must be created or opened in IDE. Following is the form that creates or adds java class to current opened project in the application.
 
 

In file New_Class_Form.cs, we are reading Class Name, also reading Modifiers,Super Class etc. Once Finish button is clicked, the tab is added to tabcontrol with same as class name by just adding .java to the end of it, and returning this filename with full path(getCreatedFileName() function).

In MainForm.cs file, In File_New_ClassMenuItem_Click() event, we will get this file name (getCreatedFileName()) , read contents from texteditor which is added to tabcontrol by New_Class_Form.cs file, create this file and write these contents to file using StreamWriter class.

Finally adding tag <JavaClassFile> & <VisualFile> with text as created filename.

Also adding <MainClassFile> tag, this tag text is read when we want to compile a file.

Download the source code to view complete code of ide.

Following is the code when File->New->Class option selected

  1. private void File_New_ClassMenuItem_Click(object sender, EventArgs e)  
  2. {  
  3.     MyTabPage tb = new MyTabPage(this);  
  4.     New_Class_Form ncf = new New_Class_Form(tb, myTabControl);  
  5.     ncf.ShowDialog();  
  6.     String filename = ncf.getCreatedFileName();  
  7.     int sel = myTabControl.SelectedIndex;  
  8.   
  9.     if (sel != -1)  
  10.     {  
  11.         var mytexteditor = myTabControl.TabPages[sel].Controls[0];  
  12.         mytexteditor.ContextMenuStrip = textEditorContextMenuStrip;  
  13.   
  14.         if (filename != "")  
  15.         {  
  16.             //check file name is already exists  
  17.             //if not then create that file  
  18.             if (File.Exists(filename))  
  19.             {  
  20.                 MessageBox.Show("The file name you entered is already exists in the folder or already added to your project""Error......");  
  21.             }  
  22.             else  
  23.             {  
  24.                 try  
  25.                 {  
  26.                     StreamWriter strw = new StreamWriter(File.Create(filename));  
  27.                     strw.Write(mytexteditor.Text);  
  28.                     strw.Close();  
  29.                     strw.Dispose();  
  30.                 }  
  31.                 catch  
  32.                 { }  
  33.   
  34.                 //adding entry to current opened project file  
  35.                 //JavaClassFile & VisualFile  
  36.                 if (ReadCurrentProjectFileName() != "")  
  37.                 {  
  38.                     String projectfilename = ReadCurrentProjectFileName();  
  39.                     XmlDocument xmldoc = new XmlDocument();  
  40.                     xmldoc.Load(projectfilename);  
  41.                     XmlNode node = xmldoc.CreateNode(XmlNodeType.Element, "JavaClassFile"null);  
  42.                     node.InnerText = filename;  
  43.                     xmldoc.DocumentElement.AppendChild(node);  
  44.                     xmldoc.Save(projectfilename);  
  45.   
  46.                     XmlDocument xmldoc2 = new XmlDocument();  
  47.                     xmldoc2.Load(projectfilename);  
  48.                     XmlNode node2 = xmldoc2.CreateNode(XmlNodeType.Element, "VisualFile"null);  
  49.                     node2.InnerText = filename;  
  50.                     xmldoc2.DocumentElement.AppendChild(node2);  
  51.                     xmldoc2.Save(projectfilename);  
  52.                 }  
  53.             }  
  54.         }  
  55.     }  
  56.   
  57.   
  58.     if (ncf.IsFinished() == true)  
  59.     {  
  60.         AddFilesToProjectExplorerTreeView();  
  61.         WriteCurrentFileNames();  
  62.         CopyAllSourceFilesToSRCFolder();  
  63.         UpdateWindowsList_WindowMenu();  
  64.         myTabControl_SelectedIndexChanged(sender, e);  
  65.   
  66.         //check srcclasses directory exists or not  
  67.         if (Directory.Exists(getCurrentProjectLocationFolder() + "\\srcclasses"))  
  68.         {  
  69.             String mainclassfile = "";  
  70.             using (XmlReader reader = XmlReader.Create(ReadCurrentProjectFileName()))  
  71.             {  
  72.                 while (reader.Read())  
  73.                 {  
  74.                     if (reader.IsStartElement())  
  75.                     {  
  76.                         switch (reader.Name.ToString())  
  77.                         {  
  78.                             case "MainClassFile":  
  79.                                 mainclassfile = reader.ReadString();  
  80.                                 break;  
  81.                         }  
  82.                     }  
  83.                 }  
  84.             }  
  85.             if (mainclassfile == "")  
  86.             {  
  87.                 if (ReadCurrentProjectFileName() != "")  
  88.                 {  
  89.                     String projectfilename = ReadCurrentProjectFileName();  
  90.                     XmlDocument xmldoc = new XmlDocument();  
  91.                     xmldoc.Load(projectfilename);  
  92.                     XmlNode node = xmldoc.CreateNode(XmlNodeType.Element, "MainClassFile"null);  
  93.                     node.InnerText = filename;  
  94.                     xmldoc.DocumentElement.AppendChild(node);  
  95.                     xmldoc.Save(projectfilename);  
  96.                 }  
  97.             }  
  98.         }  
  99.     }  
  100. }   
New Package

Here we will create a folder in the project folder.when aaa.bbb.ccc package name is entered then we will replace . to \,(aaa\bbb\ccc) and will create these directories in current opened project location folder and also will create java class in aaa\bbb\ccc folder.

For other options like,

  • File->New->Interface, File->New->Enums
  • File->New->HTML File, File->New->CSS File
  • File->New->Text File, File->New->JavaScript File
  • File->New->SQL File, File->New->XML File
  • File->New->New File

This is the same code as creating New Java Class, just create files with their own extensions.

Open Project

(File->Open Project) This is nothing but the read file(.slvjproj) from OpenFileDialog, read contents from it, and perform actions about it such as adding application form text to project name text, adds tabs to tabcontrol by getting files by tags

<JavaClassFile>,<HTMLFile> etc. Once project is opened add Project Type, ProjectName, Project Location Folder to \files\defaultprojloc.slvjfile. 

OpenFiles

(File->Open Files) This is same as above(Open Project) only to read files, add their names to ProjectExplorerTreeView, opening those files on tabs and add all file names with their full path to \files\files.slvjfile.
 
Save

(File->Save) For saving an opened file on tab, I am using FilenameToolStripLabel to show/store current opened file name full path on tab.

I am checking if FilenameToolStripLabel contains ‘\’ or not, if it contains it then read texteditor contents from current selected tab & write it to file from FilenameToolStripLabel.Text or here you can read files\files.slvjfile where contains all current opened project files with their full path.

Save All

(File->Save All) For this, I am reading a file \files\files.slvjfile, comparing each tab with each file name read from files.slvjfile, if it matches then setting that tab to selected, save that file by reading current set tab texteditor with filename 

Load Sample Project

As every IDE provides some sample projects, here we will provide following sample projects.
 
    

First design your sample project form for selecting what kind of project want to create.

Creating sample project involves nothing but to create a Project file(.slvjproj), Project directory, creating sub directories in it(src,classes,srcclasses), creating project files(.java) in those directories, adding this created project information to \files\defaultprojloc.slvjfile & just call OpenProject function with created project file name.

These project files are located at Samples folder.

First let's define variables to store what files need to be read from Samples folder.

Here I defined notepad_files(notepad source file), notepad_2(source file name we want to create in/as project)

  1. String[] notepad_files = {  
  2.                            Application.StartupPath+"\\Samples\\Notepad\\Notepad.slvjfile"  
  3.                          };  
  4.   
  5.     String[] notepad_2 ={  
  6.                          "Notepad.java"  
  7.                         };  
  8.   
  9.     String defaultprojfilepath = Application.StartupPath + "\\files\\defaultprojloc.slvjfile";  
  10.   
  11.   
  12.     public String ProjectLocaionFoder()  
  13.     {  
  14.         String projectfolder = "";  
  15.         using (XmlReader reader = XmlReader.Create(defaultprojfilepath))  
  16.         {  
  17.             while (reader.Read())  
  18.             {  
  19.                 if (reader.IsStartElement())  
  20.                 {  
  21.                     switch (reader.Name.ToString())  
  22.                     {  
  23.                         case "DefaultProjectLocation":  
  24.                             projectfolder = reader.ReadString();  
  25.                             break;  
  26.                     }  
  27.                 }  
  28.             }  
  29.         }  
  30.   
  31.         return projectfolder;  
  32.     }  
  33.   
  34.   
  35.             String selected_item = listBox1.SelectedItem.ToString();  
  36.             String projectfolder = ProjectLocaionFoder();  

listBox1 is the control added to form (see above image).selected_item contain selected sample project name and projectfolder contains users project folder.

  1. if (selected_item == "Notepad")  
  2. {  
  3.     project_name = "Notepad";  
  4.   
  5.     String directory = projectfolder + "\\Notepad";  
  6.     String projectfile = "Notepad.slvjproj";  
  7.   
  8.     if (Directory.Exists(directory))  
  9.     {  
  10.         MessageBox.Show("The selected project is already exists in current location""Error............");  
  11.     }  
  12.   
  13.     else  
  14.     {  
  15.   
  16.         Directory.CreateDirectory(directory);  
  17.   
  18.         if (Directory.Exists(directory))  
  19.         {  
  20.             project_folder = directory;  
  21.   
  22.             project_file = directory + "\\" + projectfile;  
  23.         }  
  24.   
  25.         if (File.Exists(notepad_files[0]))  
  26.         {  
  27.             String filename = notepad_files[0];  
  28.             String fname = filename.Substring(filename.LastIndexOf("\\") + 1);  
  29.             fname = fname.Remove(fname.Length - 9);  
  30.             fname = fname + ".java";  
  31.   
  32.             if (Directory.Exists(directory))  
  33.             {  
  34.                 String src = directory + "\\src";  
  35.                 String srcclasses = directory + "\\srcclasses";  
  36.                 String classes = directory + "\\classes";  
  37.   
  38.                 Directory.CreateDirectory(src);  
  39.                 Directory.CreateDirectory(srcclasses);  
  40.                 Directory.CreateDirectory(classes);  
  41.   
  42.                 String content = "";  
  43.   
  44.                 content = File.ReadAllText(notepad_files[0]);  
  45.   
  46.                 if (Directory.Exists(srcclasses))  
  47.                 {  
  48.                     StreamWriter strw = new StreamWriter(File.Create(srcclasses + "\\" + fname));  
  49.                     strw.Write(content);  
  50.                     strw.Close();  
  51.                     strw.Dispose();  
  52.                 }  
  53.   
  54.                 //creating & writing slvjproj file  
  55.                 using (XmlWriter xmlwriter = XmlWriter.Create(directory + "\\" + projectfile))  
  56.                 {  
  57.                     xmlwriter.WriteStartDocument();  
  58.                     xmlwriter.WriteStartElement("SilverJProject");  
  59.                     xmlwriter.WriteString("\n");  
  60.                     xmlwriter.WriteComment("Silver-J (1.0) Java Application Project");  
  61.                     xmlwriter.WriteString("\n");  
  62.                     xmlwriter.WriteElementString("ProjectName""Notepad");  
  63.                     xmlwriter.WriteString("\n");  
  64.                     xmlwriter.WriteElementString("ProjectLocationFolder", directory);  
  65.                     xmlwriter.WriteString("\n");  
  66.                     xmlwriter.WriteElementString("ProjectLocationFile", directory + "\\" + projectfile);  
  67.                     xmlwriter.WriteString("\n");  
  68.                     xmlwriter.WriteElementString("ProjectType""ApplicationType");  
  69.                     xmlwriter.WriteString("\n");  
  70.                     xmlwriter.WriteElementString("MainClassFile", directory + "\\srcclasses" + "\\" + notepad_2[0]);  
  71.                     xmlwriter.WriteString("\n");  
  72.                     xmlwriter.WriteElementString("JavaClassFile", directory + "\\srcclasses" + "\\" + notepad_2[0]);  
  73.                     xmlwriter.WriteString("\n");  
  74.                     xmlwriter.WriteElementString("VisualFile", directory + "\\srcclasses" + "\\" + notepad_2[0]);  
  75.                     xmlwriter.WriteEndElement();  
  76.                     xmlwriter.WriteEndDocument();  
  77.                     xmlwriter.Close();  
  78.                 }  
  79.   
  80.             }  
  81.         }  
  82.   
  83.         is_project_created = true;  
  84.     }  
  85. }  

Here we are just performing actions the same way as we create new Java application projects with Create Java Class checkbox checked.

Compile & Run 

Compiling using IDE means runnnimg commands through processes. But here to compile a java source file we don't need any window to show, we just need output of compilation such as errors & warnings. It is easy to create process. We need boolean value for whether processes are started or not for compilation.

Consider you are compiling your java programs using cmd, same as we are doing here.

e.g

cd C:\MyJava\Hello
javac.exe HelloWorld.java

Download the source code.

See following code;

Where EXE is application javac.exe with full path

WorkingDirectory is our source file directory(srcclasses)(above e.g C:\MyJava\Hello)

FileName is our main java source file which we want to compile (HelloWorld.java)

We need only one java source file to compile, you can provide more files.

The main source file is saved in the project file(.slvjproj) with tag <MainClassFile>. This file can be changed by going to Run->Main Class

  1. public bool Compile(String EXE, String WorkingDirectory, String FileName)  
  2.     {  
  3.         bool processStarted = false;  
  4.   
  5.         if (File.Exists(EXE))  
  6.         {  
  7.             process.StartInfo.FileName = EXE;  
  8.             process.StartInfo.Arguments = FileName;  
  9.             process.StartInfo.WorkingDirectory = WorkingDirectory;  
  10.             process.StartInfo.CreateNoWindow = true;  
  11.             process.StartInfo.ErrorDialog = false;  
  12.             process.StartInfo.UseShellExecute = false;  
  13.             process.StartInfo.RedirectStandardOutput = true;  
  14.             process.StartInfo.RedirectStandardError = true;  
  15.             processStarted = process.Start();  
  16.         }  
  17.         else  
  18.         {  
  19.             MessageBox.Show("Unable to compile java file. Check your Java Path settings: Current Java Path : ");  
  20.         }  
  21.         return processStarted;  
  22.     }  
  23.   
  24.   
  25.    public void CompileJava(String file, String jdkpath)  
  26.     {  
  27.         String mystr = file;  
  28.         if (mystr.Contains(".java"))  
  29.         {  
  30.             mystr = mystr.Remove(mystr.Length - 5);  
  31.         }  
  32.         if (this.Compile(jdkpath + "\\javac.exe", Path.GetDirectoryName(file), Path.GetFileName(file)))  
  33.         {  
  34.             ErrorReader = process.StandardError;  
  35.             string response = ErrorReader.ReadToEnd();  
  36.   
  37.             if (response != "")  
  38.             {  
  39.                 ErrorTextBox.Text = response;  
  40.                 if (showErrorDialog == true)  
  41.                 {  
  42.                     MessageBox.Show("" + response, "Errors");  
  43.                 }  
  44.             }  
  45.             else if (response == "")  
  46.             {  
  47.                 ErrorTextBox.Text = "Program Compiled Successfully.................!";  
  48.             }  
  49.             else if (response.Contains("uses or overrides a deprecated API."))  
  50.             {  
  51.                 ErrorTextBox.Text = "Program Compiled Successfully.................!";  
  52.             }  
  53.             else  
  54.             {  
  55.                 ErrorTextBox.Text = "Program Compiled Successfully.................!";  
  56.             }  
  57.         }  
  58.         else if (File.Exists("" + mystr + ".class"))  
  59.         {  
  60.             ErrorTextBox.Text = "Program Compiled Successfully.................!";  
  61.         }  
  62.   
  63.         //set caret position to error line number  
  64.         if(myTabControl.TabCount>0)  
  65.         {  
  66.             if(myTabControl.SelectedTab.Text.Contains(".java"))  
  67.             {  
  68.                 String compilejavafilename = myTabControl.SelectedTab.Text;  
  69.                 if (ErrorTextBox.Text.Contains(compilejavafilename))  
  70.                 {  
  71.                     int select_index = myTabControl.SelectedIndex;  
  72.                     var texteditor = (TextEditorControl)myTabControl.TabPages[select_index].Controls[0];  
  73.                     RichTextBox rtb = new RichTextBox();  
  74.                     rtb.Text = texteditor.Text;  
  75.   
  76.                     for(int i=0;i<rtb.Lines.Length;i++)  
  77.                     {  
  78.                         if(ErrorTextBox.Lines[0].Contains(i.ToString()))  
  79.                         {  
  80.                             texteditor.ActiveTextAreaControl.TextArea.Caret.Line = i-1;  
  81.                         }  
  82.                     }  
  83.                 }  
  84.             }  
  85.         }  
  86.     }  

showErrorDialog is whether to show dialog after clicking on compile menu item. If error is found then show it, and set caret to that error line number.

You know how to run java programs on cmd.

First you to compile java source file, it will create .class file by going to the location folder. And then you can run that class file using java.exe command.

e.g

cd C:\MyJava\Hello
java.exe HelloWorld.class

Instead of using only java.exe, I am using full path of java.exe file(jdk_path\bin\java.exe) as a string.

  1.  String projectlocationfolder = getCurrentProjectLocationFolder();  
  2. if (Directory.Exists(projectlocationfolder + "\\srcclasses"))  
  3. {  
  4.     if (filename.Contains(".java"))  
  5.     {  
  6.         String ffname = filename.Remove(filename.Length - 5);  
  7.         ffname = ffname + ".class";  
  8.   
  9.         if (File.Exists(ffname))  
  10.         {  
  11.             ProcessStartInfo ProcessInfo;  
  12.             //Process process;  
  13.             String javapath = "\"" + jdkpath + "\\java.exe" + "\"";  
  14.             String getfilename = filename.Substring(filename.LastIndexOf("\\") + 1);  
  15.             String fname = "";  
  16.             if (getfilename.Contains(".java"))  
  17.             {  
  18.                 fname = getfilename.Remove(getfilename.Length - 5);  
  19.             }  
  20.             ProcessInfo = new ProcessStartInfo("cmd.exe""/K" + "  cd/   &&  cd " + workingDirectory + "  &&  " + javapath + "  " + fname);  
  21.             ProcessInfo.CreateNoWindow = true;  
  22.             ProcessInfo.UseShellExecute = true;  
  23.             Process.Start(ProcessInfo);  
  24.         }  
  25.     }  
  26. }  

ProcessInfo = new ProcessStartInfo("cmd.exe", "/K" + " cd/ && cd " + workingDirectory + " && " + javapath + " " + fname);

This line runs the program.first it starts the cmd.exe with command cd/.

Then it goes to project directory(workingDirectory(srcclasses)) by using cd.

Then it calls java.exe filename full path with .class filename.

Same for Run with Parameter option; just add those parameters after fname.

Same for Run Applet option only just to use appletviewer.exe with HTML source file. 

Build Executable Jar 

To create executable jar file, we need a manifest file (manifest.mf). That file contains the following contents.

  1. Manifest-Version: 1.0  
  2. Ant-Version: Apache Ant 1.9.4  
  3. Created-By: 1.8.0_25-b18 (Oracle Corporation)  
  4. Class-Path:  
  5. X-COMMENT: Main-Class will be added automatically by build  
  6. Main-Class:  
  7. Main-Class:  

Where Main-Class: should contain mailclass filename(only filename without any file extension).

Created-By: is the JDK version.

To create jar file using cmd, first go to the working directory.

jar.exe cmf <manifest_file> <outputfile> <class_files>

e.g

jar.exe cmf manifest.mf Hello.jar HelloWorld.class

In Run_BuildMenuItem_Click(), I have used a textbox to paste all .class files in it and use textbox.Text as class files. It will not add .java source files.

It also adds directories to jar file by adding directory names to textbox. The process is the same as running Java programs, with just small changes in commands, inputs, & arguments.

Once the JAR file is created, we will create a build folder in project location folder & copy the created jar file there.

  1. private void Run_BuildMenuItem_Click(object sender, EventArgs e)  
  2.        {  
  3.            String projectfolderpath = getCurrentProjectLocationFolder();  
  4.            if (projectfolderpath != "")  
  5.            {  
  6.                if (Directory.Exists(projectfolderpath + "\\srcclasses"))  
  7.                {  
  8.                    String mainclass = getMainClassFileName();  
  9.                    String mnclass = mainclass.Substring(mainclass.LastIndexOf("\\") + 1);  
  10.                    mnclass = mnclass.Remove(mnclass.Length - 5);  
  11.                    //create mainclass manifest file  
  12.                    String maintexttomanifest = "Manifest-Version: 1.0"  
  13.                        + "\nAnt-Version: Apache Ant 1.9.4"  
  14.                        + "\nCreated-By: 1.8.0_25-b18 (Oracle Corporation)"  
  15.                        + "\nClass-Path: "  
  16.                        + "\nX-COMMENT: Main-Class will be added automatically by build"  
  17.                        + "\nMain-Class: " + mnclass  
  18.                        + "\nMain-Class: " + mnclass;  
  19.   
  20.                    String manifestfile = projectfolderpath + "\\srcclasses\\mainclass.mf";  
  21.                    StreamWriter strw = new StreamWriter(manifestfile);  
  22.                    strw.Write(maintexttomanifest);  
  23.                    strw.Close();  
  24.                    strw.Dispose();  
  25.   
  26.                    if (File.Exists(manifestfile))  
  27.                    {  
  28.                        String srcclassesfolderpath = projectfolderpath + "\\srcclasses";  
  29.                        List<string> packagenameslist = getPackageNamesList();  
  30.                        TextBox textbox = new TextBox();  
  31.                        string[] files = Directory.GetFiles(srcclassesfolderpath);  
  32.   
  33.                        foreach (string filePath in files)  
  34.                        {  
  35.                            if (Path.GetExtension(filePath) != ".java" && Path.GetExtension(filePath) != ".mf")  
  36.                            {  
  37.                                textbox.Paste(" " + Path.GetFileName(filePath));  
  38.                            }  
  39.                        }  
  40.   
  41.                        //check package folder exists or not  
  42.                        RichTextBox rtb = new RichTextBox();  
  43.                        String[] dirs = Directory.GetDirectories(srcclassesfolderpath);  
  44.                        foreach (String packagefolder in packagenameslist)  
  45.                        {  
  46.                            rtb.Text = rtb.Text.Insert(rtb.SelectionStart, "" + packagefolder + "  ");  
  47.                        }  
  48.   
  49.                        //get folder by leaving package folders  
  50.                        foreach (String dirsname in dirs)  
  51.                        {  
  52.                            String dirs2 = dirsname.Substring(dirsname.LastIndexOf("\\") + 1);  
  53.                            if (rtb.Text.Contains(dirs2)) { }  
  54.   
  55.                            else  
  56.                            {  
  57.                                textbox.Paste(" " + dirs2 + "* ");  
  58.                            }  
  59.                        }  
  60.   
  61.   
  62.                        //create jar file  
  63.                        if (File.Exists(manifestfile))  
  64.                        {  
  65.                            String jarfilepath = "\"" + getJDKPath() + "\\jar.exe" + "\"";  
  66.                            String prjfolder = getCurrentProjectLocationFolder() + "\\srcclasses";  
  67.                            String manifestfilename = manifestfile.Substring(manifestfile.LastIndexOf("\\") + 1);  
  68.                            String classes = textbox.Text;  
  69.                            String mainclassfile = mainclass.Substring(mainclass.LastIndexOf("\\") + 1);  
  70.                            mainclassfile = mainclassfile.Remove(mainclassfile.Length - 5);  
  71.                            String jarfilename = mainclassfile + ".jar";  
  72.   
  73.                            ProcessStartInfo ProcessInfo;  
  74.                            Process Process;  
  75.                            ProcessInfo = new ProcessStartInfo("cmd.exe""/K " + "cd/  &&  cd  " + prjfolder + " &&  " + jarfilepath + "  cmf   " + manifestfilename + "  " + jarfilename + "   " + classes);  
  76.                            ProcessInfo.CreateNoWindow = true;  
  77.                            ProcessInfo.UseShellExecute = true;  
  78.                            ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;  
  79.                            Process = Process.Start(ProcessInfo);  
  80.                        }  
  81.   
  82.                        //create build folder and moved created jar file to build folder  
  83.                        String createdjarfile = mainclass.Remove(mainclass.Length - 5) + ".jar";  
  84.                        if (File.Exists(createdjarfile))  
  85.                        {  
  86.                            String buildfolder = getCurrentProjectLocationFolder() + "\\build";  
  87.   
  88.                            if (Directory.Exists(buildfolder))  
  89.                            {  
  90.                                String createdjarfile2 = createdjarfile.Replace("srcclasses""build");  
  91.                                File.Delete(createdjarfile2);  
  92.                                File.Copy(createdjarfile, createdjarfile2);  
  93.   
  94.                                try  
  95.                                {  
  96.                                    File.Delete(createdjarfile);  
  97.                                }  
  98.                                catch { }  
  99.   
  100.                                ShowAboutToolStripLabel.Text = "Build Completed";  
  101.                                Run_BuildMenuItem_Click(sender, e);  
  102.                            }  
  103.                            else  
  104.                            {  
  105.                                Directory.CreateDirectory(buildfolder);  
  106.                                String createdjarfile2 = createdjarfile.Replace("srcclasses""build");  
  107.                                File.Copy(createdjarfile, createdjarfile2);  
  108.   
  109.                                ShowAboutToolStripLabel.Text = "Build Completed";  
  110.                                Run_BuildMenuItem_Click(sender, e);  
  111.                            }  
  112.                        }  
  113.                    }  
  114.                }  
  115.            }  
  116.        }   

Appearance

IDE has different themes also. Here, I am providing Default, System, Light, Dark & Night appearances. Here, Appearance means just changing colors of the components.

For MenuStrip & ToolStrip, we need to write the code for rendering their appearance by drawing. These render classes are defined in MyRenderer.cs file. I have created MyMenuStripZ, MyToolStripZ classes inheriting MenuStrip & ToolStrip & adding renderers to it from file MyRenderer.cs.

Here is the code that sets the Night theme to IDE.

  1. if(type=="Night")  
  2.   
  3.    MyMenuStripZ.Renderer = new NightMenuRenderer();  
  4.    textEditorContextMenuStrip.Renderer = new NightMenuRenderer();  
  5.    ProjectExplorerTreeViewContextMenuStrip.Renderer = new NightMenuRenderer();  
  6.    myTabControlContextMenuStrip.Renderer = new NightMenuRenderer();  
  7.    ErrorsListContextMenuStrip.Renderer = new NightMenuRenderer();  
  8.    MyToolStripZ.Renderer = new NightToolStripRenderer();  
  9.    myTabControl.DrawMode = TabDrawMode.OwnerDrawFixed;  
  10.   
  11.    myTabControl.Transparent1 = 255;  
  12.    myTabControl.Transparent2 = 255;  
  13.    toolstrippanel.Transparent1 = 255;  
  14.    toolstrippanel.Transparent2 = 255;  
  15.    projectexplorerpanel.Transparent1 = 255;  
  16.    projectexplorerpanel.Transparent2 = 255;  
  17.    classespanel.Transparent1 = 255;  
  18.    classespanel.Transparent2 = 255;  
  19.    methodspanel.Transparent1 = 255;  
  20.    methodspanel.Transparent2 = 255;  
  21.    errorslistpanel.Transparent1 = 255;  
  22.    errorslistpanel.Transparent2 = 255;  
  23.   
  24.    MyMenuStripZ.BackColor = Color.FromArgb(255, 30, 30, 30);  
  25.    toolstrippanel.StartColor = Color.FromArgb(30, 30, 30);  
  26.    toolstrippanel.EndColor = Color.FromArgb(30, 30, 30);  
  27.    MyToolStripZ.BackColor = Color.FromArgb(250, 30, 30, 30);  
  28.   
  29.    projectexplorerpanel.StartColor = Color.FromArgb(15, 15, 15);  
  30.    projectexplorerpanel.EndColor = Color.FromArgb(15, 15, 15);  
  31.    classespanel.StartColor = Color.FromArgb(15, 15, 15);  
  32.    classespanel.EndColor = Color.FromArgb(15, 15, 15);  
  33.    methodspanel.StartColor = Color.FromArgb(15, 15, 15);  
  34.    methodspanel.EndColor = Color.FromArgb(15, 15, 15);  
  35.    errorslistpanel.StartColor = Color.FromArgb(15, 15, 15);  
  36.    errorslistpanel.EndColor = Color.FromArgb(15, 15, 15);  
  37.   
  38.    projectexplorerlabel.ForeColor = Color.White;  
  39.    classeslabel.ForeColor = Color.White;  
  40.    methodslabel.ForeColor = Color.White;  
  41.    errorslabel.ForeColor = Color.White;  
  42.   
  43.    myTabControl.ActiveTabStartColor = Color.FromArgb(10, 10, 30);  
  44.    myTabControl.ActiveTabEndColor = Color.FromArgb(10, 10, 30);  
  45.    myTabControl.NonActiveTabStartColor = Color.FromArgb(60, 60, 60);  
  46.    myTabControl.NonActiveTabEndColor = Color.FromArgb(60, 60, 60);  
  47.   
  48.    myTabControl.TextColor = Color.White;  
  49.   
  50.    splitContainer1.BackColor = Color.FromArgb(255,10, 10, 10);  
  51.   
  52.    ProjectExplorerTreeView.BackColor = Color.FromArgb(255, 25, 25, 25);  
  53.    ClassesTreeView.BackColor = Color.FromArgb(255, 25, 25, 25);  
  54.    MethodsTreeView.BackColor = Color.FromArgb(255, 25, 25, 25);  
  55.    ErrorTextBox.BackColor = Color.FromArgb(255, 25, 25, 25);  
  56.   
  57.    ProjectExplorerTreeView.ForeColor = Color.White;  
  58.    ClassesTreeView.ForeColor = Color.White;  
  59.    MethodsTreeView.ForeColor = Color.White;  
  60.    ErrorTextBox.ForeColor = Color.FromArgb(255, 255, 220, 220);  
  61. }


Recommended Free Ebook
Similar Articles