When a GEF application implements most of the required business functions, we should consider the ease of use in order to make it easier for users. Starting with the 3.0 release, GEF has added new features in this area that developers can easily use to improve their application interface. This post will introduce some of the main features, some of which appear in GEF 2.1, but are all about ease of use and have not been mentioned before, so put it all together.
Collapsible palette
In the previous example, our editors were inherited from Graphicaleditorwithpalette. GEF 3.0 provides a richer editor parent: Graphicaleditorwithflyoutpalette, the editor that inherits it has a collapsible toolbar and can take advantage of Eclipse's own palette view, when the palette view is displayed, The sidebar is automatically transferred to this view.
Figure 1 A collapsible and configured palette
The editor that inherits Graphicaleditorwithflyoutpalette needs to do more work than the previous graphicaleditorwithpalette. The first step is to implement the Getpalettepreferences () method, which returns a flyoutpreferences instance that preserves several state information (position, size, and expansion) of the palette so that the settings are automatically applied the next time you open the editor. You can use preferences to save and load these states, as well as other methods, such as the. Properties file:
protected FlyoutPreferences getPalettePreferences() {
return new FlyoutPreferences() {
public int getDockLocation() {
return SubjectEditorPlugin.getDefault().getPreferenceStore().getInt (IConstants.PREF_PALETTE_DOCK_LOCATION);
}
public void setDockLocation(int location) {
SubjectEditorPlugin.getDefault().getPreferenceStore().setValue (IConstants.PREF_PALETTE_DOCK_LOCATION,location);
}
…
};
}
You then override the default Createpaletteviewerprovider () implementation, where you can add drag-and-drop support for the palette, which means that the palette is a drag-and-drop source (in this way, because there is no way to get its corresponding palette instance in the editor), In the past this work was usually done in the Initializepaletteviewer () method, and now this method is no longer needed:
protected PaletteViewerProvider createPaletteViewerProvider() {
return new PaletteViewerProvider(getEditDomain()) {
protected void configurePaletteViewer(PaletteViewer viewer) {
super.configurePaletteViewer(viewer);
viewer.addDragSourceListener(new TemplateTransferDragSourceListener (viewer));
}
};
}
GEF 3.0 also allows users to customize the various tools in the palette, such as hiding a tool, or modifying the description of the tool, and so on, by defining a Palettecustomizer instance for Paletteviewer, but because of time, this is not a detailed description of , if you need this feature you can refer to the implementation method in the logic example.