Easy Extension of a NetBeans Data Object's Functionality

In Playing with File Types in NetBeans IDE 4.1 and elsewhere, I specified the popup menus for a data object by defining them like this in the node class:

public Action[] getActions(boolean context) {
    Action[] result = new Action[] {
    SystemAction.get(EditAction.class),
    SystemAction.get(CutAction.class),
    SystemAction.get(CopyAction.class),
    SystemAction.get(RenameAction.class),
    SystemAction.get(DeleteAction.class),
    };
    return result;
}

However, what happens if someone wants to add additional popup menus to the ones that I provided? How would they do that? They won't because they can't (not easily, anyway). Instead, if I'd known that Actions for DataLoader can be specified in a layer, I'd have specified them in the layer.xml file and simply created a reference to them in the DataLoader class:

protected String actionsContext() {
    return "Loaders/text/x-tag/Actions/"; // NOI18N
}

Instead of x-tag above, I could specify x-java or x-jsp or whatever the MIME-TYPE is of the data object I want to extend.

Once the popup menus are defined in my layer.xml file, anyone else can add to them by adding them in the same place in their own module's layer.xml file. These layer.xml files can be seen as a big stack of pages in a book, that are read together as one story, providing one coherent whole -- hopefully! -- if all contributors are also good writers... However, note that this extensibility is only possible for existing loaders once they are migrated to this new style...

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today