Download NetBeans!

20070326 Monday March 26, 2007

Palette API and 6.0, Testing the Waters... (Part 3)

Revision 1.12 of PaletteItemNode.java, performed in response to issue 97812, allows icons in palette items to come from external files. This may seem a less than exciting fix, however look at the following scenario, which is precisely what I had in mind when creating issue 97812 (by the way, in today's build, I couldn't get the text/x-java content type to work, probably a temporary glitch):

You can now, for the first time, make use of the palette item DTD to let the user select the small icon and large icon of their new snippet. (As explained in the two previous installments of this mini series, here and here, one can now, since recent 6.0 development builds, create a palette for existing editors and let users add to them at runtime.)

Prior to this fix, the icons had to be provided by the module, which meant that the user of the palette was not able to select the icons (except if you were to provide 100s of icons yourself in the module, but even then the user wouldn't be able to select their own icon).

Therefore, if you pass the file's URL to the code that creates the palette item XML file, the result of the XML creation process is now allowed to be as follows (note the two lines in bold below):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE editor_palette_item PUBLIC 
"-//NetBeans//Editor Palette Item 1.1//EN" 
"http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd">
<editor_palette_item version="1.1">
  <body>
     <![CDATA[
       blablabla ]]>
  </body>
  <icon16 urlvalue="file:/C:/Datasource.GIF"/>
  <icon32 urlvalue="file:/C:/DatasourceBig.GIF"/>
  <inline-description>
     <display-name>How to Use a JFileChooser</display-name>
     <tooltip>JFileChooser Code</tooltip>
  </inline-description>
</editor_palette_item>

That's a pretty cool change, which means that the users of your palette functionality have absolute freedom when defining new palette items, assuming you provide functionality for them to do so. However, if the user accidentally deletes the icons on their disk, they're destroying their palette items. But, that's the side effect of this. Just make sure that your users know that when they select icons from their filesystem for one or more of their palette items, the icons aren't copied anywhere. So, if they delete them or move them (or even just rename them), they're impacting their palette.

Mar 26 2007, 11:24:10 AM PDT Permalink