Design
This article will show you how to add eclipse forms to your rich client program. Eclipse forms can achieve web effects without embedding a browser in your program. in this way, you not only have full control over components, but also ensure all the portability of eclipse. This article will guide you step by step from the basic features of eclipse forms to advanced features.
History
The basic features of an eclipse platform are: All Program interfaces developed based on the eclipse platform can be the same as local programs. because SWT, menu, window, tree, table, button and other components are consistent with the system style in any operating system. as the earliest member of the eclipse team, I remember the happy days when I developed the eclipse prototype code. the menu is true, the toolbar is true, and the check menu, text box, button, check box, and single choice button are all true. they are not drawn out. They are all called local components of the operating system.
For a long time, if you have written Eclipse plug-ins, they basically fall within the following scope:
1. Editors (editor)
2. Views)
3. Wizards (wizard)
4. Dialog (window)
There are clear rules for this scope to define how to compile plug-ins. we have read the tree, table, and editors documents in views, as well as simple buttons and text boxes in the wizard and window.
Eclipse 3. RCP in X extends a series of new features in the system, which brings about effective solutions to many problems. Now you can build RCP programs that are completely different from the IDE on Eclipse.
Although common workbench components such as views and editors work well, components (trees, tables, text editors, etc.) that constitute these components may not be the best solution in RCP. since eclipse 3.0, eclipse forms has been designed to provide alternative solutions.
The eclipse forms we developed solves a problem that exists in the eclipse SDK For A Long Time earlier than RCP. use Special Editor plug-in. in XML with syntax analysis, the color-displayed text editor's pdpd developers are not happy. there is no problem with Eclipse's Java editor. It is very powerful and ideal for this task. However, it is used to edit Java code. In the plug-in manifests, XML is used to abstract and describe the data structure at a higher level. You can edit XML manually. Most users may find it inappropriate to use an editor with syntax analysis and color display. In the plug-in manifests, the syntax is not the focus. The specific data and its meaning are the focus.
A good example is to use HTML recognition tools to view tags. from the code perspective, we can clearly see the elements that contain relevant attributes. although we can see the syntax, it is hard to see what it will do. a WYSIWYG view can display tables, colors, and text content containing tables and images. HTML files are more efficient in this aspect.
Because the syntax and tag are hidden in the background.
It is very easy to understand the WYSIWYG concept of HTML documents, because HTML labels are used to display a text document structure that represents attributes, hyperlinks, and images for the browser, WYSIWYG means editing the document in its final form-probably in the same form as it does in a browser. It is pointed out that the appearance of the manifest Editor, an editing plug-in with different methods, is difficult. The final team made the following decision:
1. Use the most appropriate method to display every part of manifest. For example, important information such as the plug-in name and provider can be edited in a text box. A hierarchical data structure such as the extension point definition is displayed in a tree.
2. Each part of the manifest is displayed on a separate editing page. The order is in the order of its original code.
3. Each page of the editor should maintain the Document Style and accommodate different components, hyperlink, images, text, and provide a scroll bar when there are too many page size content.
Figure 1: plug-in manifest editor in eclipse sdk1.0. it supports SWT components, hyperlinks, and images, and can scroll when the size is not enough (just like a web browser ). note that all components are flat in order to seem more integrated with the text content ).
The third point effectively promotes the creation of the plug-in named eclipse forms. After the release of MySQL 1.0, other developers hope to copy the rich client interface of the Multi-page editor of The pdpd.
It was finally released as a plug-in with public APIs in eclipse3.0.
In the following article, we will show you what is eclipse forms (and what is not eclipse forms) and how to use them to create beautiful interfaces.
Eclipse forms mission
Eclipse forms is an optional rich client plug-in that runs through all eclipse UIS Based on SWT and jface to provide web-friendly user interfaces.
Eclipse forms breaks the pattern that can only be used in a specific eclipse UI (Editor, view, wizard, window. To meet developers' needs, an eclipse form can appear in any UI. Ui developers can select the most appropriate concept for their tasks.
Eclipse is not designed to completely replace SWT or jface. This plug-in only has some well-selected proprietary custom components, layout, and support classes to achieve the expected results using SWT and jface.
Obviously, an eclipse form usually looks like a webpage. the fact is that all aspects of form's program feasibility make forms powerful and attractive. to achieve this elasticity through browsers, dom-based support is required, and it is often almost a coupling. eclipse forms are portable and written on SWT and jface.
Eclipse forms has been rewritten in 3.0 release to rely only on the platform UI plug-in, rather than on the partial interface plug-in. although they are not the smallest part of RCP, you can add eclipse forms to any RCP program.
Points cannot be underestimated. when building eclipse forms, you are using SWT. there are no eclipse forms buttons or eclipse forms tree components. you only use eclipse forms to make existing components provide a rich customer experience.
Eclipse forms is achieved through the following elements:
"Form" Concepts, views, and editors are hierarchical concepts.
A toolkit is used to manage colors. hyperlink groups also have other aspects and act as factory classes for many SWT components.
A new layout manager is used to manage the layout, which is similar to an HTML table.
A set of custom components are used in combination with form. (hyperlinks, image hyperlinks, and scrolling combinations <scrollable composite>, segments <section>)
Each page is a forms multi-page editor (e.g. pdmanifest editor)
Although the eclipse forms design does not prevent you from creating a form in a window. however, most of the time, forms are used in views and editors, rather than Windows or wizard. indeed, adding form to a common window or wizard seems a bit strange. After all, other parts are common SWT components. in any case, in the future, this is a direction of exploration.
Baby Steps
It is very easy to use eclipse forms in your user interfaces. Before you start, add the org. Eclipse. UI. Forms plug-in to the plug-in dependency section. We will create
Eclipse view, and then fill in the content. Note that all the code of the plug-in this article is downloaded in the ZIP file format.
Hello, eclipse forms
We will add a blank form to the view to start the game:
Public class formview extends viewpart {
Private formtoolkit toolkit;
Private scrolledform form;
/**
* The constructor.
*/
Public formview (){}
/**
* This is a callback that will allow us to create the viewer and
* Initialize it.
*/
Public void createpartcontrol (composite parent ){
Toolkit = new formtoolkit (parent. getdisplay ());
Form = toolkit. createscrolledform (parent );
Form. settext ("Hello, eclipse forms ");
}
/**
* Passing the focus request to the form.
*/
Public void setfocus (){
Form. setfocus ();
}
/**
* Disposes the Toolkit
*/
Public void dispose (){
Toolkit. Dispose ();
Super. Dispose ();
}
}
Just as you can see in this code, you can create a form without too much. we started by creating a toolkit instance (). we use toolkit to create a scrolling form with the provided composite as the parent. we have set the Form title. in addition, we are sure to pass the focus to the form when necessary, and the toolkit is also dispose when the view dispose.
This view should look like this:
Image 2
A blank form in the view encapsulates the Form title by narrowing the view. the scroll bar is displayed once there is no space to hold the entire form.
Note that we use a scrollable form, because we put it in a view that can change the size. in a more complex environment, for example, a form must be a part of a layout. A form without the ability to scroll can also be used. in this case, formtoolkit is called. createform (), let the outer parent solve the problem that requires the scroll bar.