X

Geertjan's Blog

  • July 15, 2005

Easy Extension of a NetBeans Data Object's Functionality

Geertjan Wielenga
Product Manager
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...

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.