|PREV NEXT||FRAMES NO FRAMES|
The API provides access to the Common Component Palette. The palette clients can use this API to define content to be displayed in the common palette TopComponent when their editors are active. The module will autoload. Palette
The API includes support for the clients writing palette content insertable into the text editor.
This support covers the DTD definition of the palette item definition file format and the content of the Lookup holding object(s) representing the selected item. editor-palette-item-1_0.dtd
Now it's possible to add helpId attribute to palette's root, categories and items that will be used to create appropriate HelpCtx. The attribute can be specified in XML layer as a folder (palette's root and categories) or file attribute (palette items) or it can be provided directly by appropriate Nodes.
When F1 key is pressed in palette's window then first the selected item is asked for HelpCtx id. If no item is selected or it does not provide specific help id then selected category is checked for help id. If the category does not provide any help id either then palette's root is asked for help id. If the root does not define any then the default help id CommonPalette will be used.
To indicate that this is now considered a stable API, the major release version was incremented to 1 from 0.
The abstract class DragAndDropHandler now provides default implementation
for all drag and drop operations. The only method that needs to be overridden
void customize( ExTransferable t, Lookup item ) to provide
custom data flavors for items dragged from the palette to editor.
There are also new methods (and their default implementations) in this class that handle reordering of categories and reordering of items (i.e. drag and drop operations withing the palette window).
The first release of the Palette client support. It involves namely DTD describing item definition file format
and some implementation addons regarding definition file parsing and custom implementation class loading.
The palette item implementor can either directly provide the item body
or her own item class implementing
Lookup that holds object(s) representing the selected item then associates
custom item class instance with the
org.openide.text.ActiveEditorDrop.class key and
the body with
There's a new attribute "itemWidth" that can be set for palette's root node (or for palette's root folder in the layer). This attribute defines the width in pixels for all items in the palette thus forcing the same number of columns for all categories. If the attribute is omitted or its value is "-1" then the item widths will be calculated dynamically. The attribute is read-only.
The following steps must be taken if an editor module wants to display a palette of items that can be dropped to editor window:
When an item is selected in the palette and user clicks into the editor window then the module can ask for selected item by calling PaletteController.getSelectedItem(). This method returns a Lookup that holds object(s) representing the selected item. After the item is inserted into the editor window the module may clear palette's selection (ProgressController.clearSelection()) or leave the item selected to implement 'multi drop' insertion scenario.
It is possible to filter palette content and hide some categories and/or items from the user by implementing PaletteFilter interface. Calling PaletteController.setPaletteFilter() updates palette content and repaints the palette window.
The initial state of the palette can be overridden by setting appropriate attributes to palette model. The list of supported attributes is defined in PaletteController class. If the palette model is create from Nodes then the attributes are extracted by calling Node.getValue() method on the root Node and category and item nodes. If the palette model is defined as folders and files in the layer then the attributes are extracted by calling FileObject.getAttribute().
The following steps must be taken when writing the item using the support provided by this module:
OpenIDE-Module-Module-Dependencies org.netbeans.spi.palette/0 > 1.0
Read more about the implementation in the answers to architecture questions.
|PREV NEXT||FRAMES NO FRAMES|