Eclipse 4 Plugins - Guide

Basic Concept of Eclipse Installation and about Eclipse 4:

1. Like Java, other JVM based language is: Groovy, Scala.
2. For Linux, to install Eclipse, GTK2 is also required along with JRE.
3. To provide the spcific Java version to Eclipse, need to provide -vm argument in eclipse.ini file.
4. "eclipsec.exe" => This Eclipse executables (for Windows OS) allows Log message printed to the console to be seen also.
5. Eclipse Workspace: It has two purposes. First, it hold default project location. Second, in eclipse workspace it has another folder called .metadata directory which contains Eclipse settings, preferences, other runtime information. Log information is stored in .metadata/.log file.
6. Selecting Eclipse Workspace location can be optionally override or set it by -data argument.
7. To convert Java Project to Plug-ins project: R-click on Java Project in Eclipse -> Configure -> Convert to Plug-in Projects...
8. Java classes are not loaded or executed initially when eclipse start. It can scale by showing what's needed at the time, and then load the class on demand, when user invokes the action.
9. On "Run" mode (Run as Plug-ins Project) Java code changes are not reflected on new instance of second Eclipse. Where as in "Debug" mode, upto certain level of code changes in java (Dependes on JVM type) will reflect on new instance of the Eclipse.
10. During Debug the code, we can filter out inner class (less important class like: inside java.lang package classes) during "Step Into". To do this, goto Preferences -> Java -> Debug -> Step Filtering.
11. Conditional Breakpoint => To apply conditional breakpoint at any exiting breakpoint, simple Ctrl + D-Click (in Winsows OS) to the Breakpoint and it will open the breakpoint properties windows where it can be configured.


What are the important files in Plug-in Project:

1. MANIFEST.MF => In Plug-in project, it is OSGi manifest which describes the plug-in's Dependency, Version, Name.
Bundle-Symbolic Name: <plug-in ID> ; singleton:=true
- This means, it is an OSGi directive which means, the only one version of this plug-in can be installed in Eclipse at a time. Singleton plug-in only can add dependency in the UI which are singleton only. Due to this reason, after install new plug-in Eclipse requires 'restart'.
2. plugin.xml => It declares what extension this plug-in provides to the Eclipse runtime. Also in this file define, what are the extension points are configure for this plug-in. This file is optional, headless plug-in (non UI plug-in) often don't nedd to have it.
3. build.properties => It is used be PDE (Plug-in Development Environment) at development time and build time. Generally it can be ignored, but if resources are added that need to be made available to plug-in (like: images, properties file, HTML content etc.) then entry must be added here else it won't found.



  • Sample Code for below description will be found here in GitHub. 
(Note: To run this project, it's required minimum Java 1.7 target environment, else it's may throw "Plug-in * was unable to load class *" Exception at runtime. To solve this issue, you may need to change the target platform version in "org.eclipse.jdt.core.prefs" file which is located under <plugin-project>/.settings folder)



SWT:

   SWT (Standard Widget Toolkit) which eclipse uses, it gives performant (performs well) access to the platform's native tools in a portable manner.
org.ecl;ipse.ui => This bundle give access to the SWT and other key part of the eclipse framework.
   There are 32 different type of Style flag in SWT class. Like: SWT.NONE, SWT.CHECKBOX etc.
   The goal of SWT was to offload as much of the processing onto native component (like AWT) and let the OS do the heavy work instead of Java. By doing this, JVM require less time and OS render the graphics in most appropriate way.

org.eclipse.swt.SWTException: Invalid thread access - What is this mean ?
    Many windowing system have a User Interface thread ((UI thread) which is responsible for coordinating the UI updates with the program code. If long running operations executed in UI thread, the program can appear to hang and become unresponsive. SWT also done same thing. SWT provides a UI thread for interacting with UI and ensure that updates to SWT components are done on same UI thread. Technically, SWT is capable of supportig multiple OS UI threads.
   To resolved this thread access error, do the following :

composite.getDisplay().asynExec(new Runnable() {
   public void run() {
   // Code here
   }
});

1. asynExec() => Using this, code run asynchronously i.e. caller thread continued while the code is run in background.
2. syncExec() => Using this, code run synchronously i.e. the caller thread blocks until the code has been run.

Each SWT widget is non-disposed when it is initially created, and then subsequently disposed with a
call to dispose(). Once a widget is disposed, any native operating system resources are returned and any further operations will throw an Exception.


No comments:

Post a Comment