[Eclipse] GEF Getting Started series (ix, increased ease of use)

Source: Internet
Author: User
Tags new features

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.