A First Look at Eclipse Plug-In Programming, Page 2
1.4. First impression
The first thing that you will notice is its user interface. The user interface looks neither like a Windows application nor a Java application. Eclipse itself is written in Java, but the user interface framework (SWT, JFace) of Eclipse is written in native Language. This significant property of Eclipse seems to bring extensive use of Java desktop applications into scenes.
On the other hand, code that is written in a native language is no longer platform independent. For that reason, a proper platform-specific version of Eclipse should be downloaded to run on different platforms.
1.5. The SWT Architecture
The Java AWT library uses Java and C libraries to provide platform independence. The user interface is written by Sun. There is no direct call to the windowing sub-system of the host operating system. This provides a level of platform independence. The AWT library was not very flexible and some components were missing. For that reason, Swing is developed on the top of AWT library. It provides more flexibility then AWT.
Figure 3. Swing and SWT architectures
On the other hand, the performance and look & feel of the existing Java GUI API have not convinced IBM and they have started to write a new GUI library, called SWT. The SWT is simpler and faster then the Swing library. The look & feel is the same as the host platform. It uses JNI, with the help of small native SWT code, to call the existing windowing sub-system on the host platform.
Advantages of the SWT library:
- Look & Feel does not differ from other native-written applications on the host platform
- Simple API
- Emulates unavailable widget under the host platform
Disadvantages of the SWT library:
- Requires SWT native libraries on the target platform
- Not as flexible as Swing
- The AWT base APIs cannot be used under SWT, such as Java2D, Java3D, and Java Advanced Imaging APIs
1.5.1 SWT and system resources
Swing simulates the GUI components and GUI resources are disposed of by the Java garbage collection mechanism.
In contrast to Swing, system resources must be disposed of after using them in SWT. Basically, keeping in mind the following two rules will help in efficiently managing GUI resources:
- If you create a GUI component with SWT, such as Button, Text, List, or Combo, you have to dispose of it.
- Disposing of a parent Composite disposes of the children. Because the fonts and colors are not part of a composite, they must be disposed of manually.
In the Eclipse workbench, disposing of the workbench window disposes of child composites. The Fonts and Colors are not a part of a composite; therefore, in the Eclipse workbench, they must be disposed of.
1.6. Eclipse Architecture
A simplified variant of the Eclipse architecture can be seen below. The Eclipse platform has a small micro kernel. Except for this small micro kernel, everything is written as a plug-in. Each plug-in is loaded by this small micro kernel.
Figure 4. Eclipse plug-in Architecture
Eclipse has plug-in architecture. Developers can extend Eclipse by writing extensions to the predefined extension points.
The Eclipse core is responsible for:
- Booting and running the platform
- Plug-in declaration and management
- Resource management
The core module is generic. It behaves equally to all plug-ins. It does not know any domain-specific information. It can run equally well with or without a GUI.
The Eclipse user interface defines the building blocks of the user interface. It can be divided into three groups—workbench, JFace, and SWT. From the user's point of view, a workbench is the main window of Eclipse. It consists of views, toolbars, menu bars, and editors. The purpose of the workbench is to facilitate the integration of the tools. These tools use extension points to contribute to the workbench. JFace is a smaller set of UI frameworks for handling common user interface programming tasks. JFace is designed to work with SWT without hiding it. SWT defines a set of widgets that form the basis of integrated tools build with Eclipse.
Page 2 of 5