Bug 92962 - Allow the user to create new palette items at runtime
Allow the user to create new palette items at runtime
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Palette
6.x
All All
: P1 (vote)
: 6.x
Assigned To: Stanislav Aubrecht
issues@platform
: API_REVIEW_FAST
Depends on:
Blocks: 90212 93002
  Show dependency treegraph
 
Reported: 2007-01-22 14:58 UTC by Stanislav Aubrecht
Modified: 2008-12-22 11:29 UTC (History)
3 users (show)

See Also:
Issue Type: TASK
:


Attachments
proposed implementation (12.75 KB, patch)
2007-01-22 15:00 UTC, Stanislav Aubrecht
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Aubrecht 2007-01-22 14:58:44 UTC
the current api for palette items for text-based editors enforces the usage of
resource bundles for item display name. therefore it isn't possible to create
new palette items at runtime upon user's request (e.g. new code snippets)

the change is a simple enhancement of palette item's DTD to allow inlined
description without the need for resource bundle.

the current format is:
<description
localizing-bundle="org.netbeans.modules.html.palette.items.resources.Bundle"
           display-name-key="NAME_html-TABLE"
           tooltip-key="HINT_html-TABLE" />

the new format for items created by the user at runtime will be:
<inline-description>
           <display-name>my code snippet</display-name>
           <tooltip> long description for my code snippet </tooltip>
</inline-description>

the two formats above are mutually exclusive, see the attachment.
Comment 1 Stanislav Aubrecht 2007-01-22 15:00:06 UTC
Created attachment 37569 [details]
proposed implementation
Comment 2 _ ludo 2007-01-23 15:03:58 UTC
For jMaki plugin this is critical.
We did an ugly workaround to *call*, (yes) private method on the module class
loader to add a set of classes (byte code generated on the fly) and bundles...
This is what it takes to provide value to the customers.

Another way to fix that would be to open a little bit more the very very private
class loading implementation in Nb.

This is related (a little) to plugins to define dependant jars/dir that are not
under the modules/ext area for example, but somewhere on disk...
Comment 3 _ ludo 2007-01-23 15:45:46 UTC
The class name element could also be parametrizable, so that I can pass a String
parameter to the object repesenting the palette.
This way the class would be known at compile time, but based on this parameter,
we could dbd and drop what we want.
Fro jMaki we cannot use static snippet since we need validation and add more
than the snippet code when DnD. We need a class.
Having a class per palette entry is a bit too heavy and not extensible dynamically.
Comment 4 Jaroslav Tulach 2007-01-24 06:20:36 UTC
New DTD is good solution. 
The patch contains System.err.println
There is no test, please write one - e.g. create a file on SystemFileSystem conforming to new 
DTD and make sure it is recognized.
Comment 5 Stanislav Aubrecht 2007-01-29 09:19:13 UTC
if there are no more comments, i'll integrate tomorrow
Comment 6 _ ludo 2007-01-29 15:15:36 UTC
what about adding some parameters to the class name so that we can use the same
class but with different args?
Comment 7 _ ludo 2007-01-29 15:15:48 UTC
what about adding some parameters to the class name so that we can use the same
class but with different args?
Comment 8 Stanislav Aubrecht 2007-01-29 15:38:42 UTC
> what about adding some parameters to the class name so that we can use the same
> class but with different args?

i've created a separate issue for that: #93451
Comment 9 Jaroslav Tulach 2007-01-29 18:45:33 UTC
What do you want to integrate? The proposed patch or some other patch? I guess the 
proposed patch is not integratable. It contains system.err and there is no test. Imho it should 
not be integrated as it is. 
Comment 10 Stanislav Aubrecht 2007-01-30 08:30:52 UTC
i'll remove the sysstem.err and add a test.
the dtd will remain the same as in the attached patch.
Comment 11 Libor Kotouc 2007-01-30 08:48:23 UTC
What about inline-description tag example, which is a part of the DTD?
Comment 12 Stanislav Aubrecht 2007-01-30 08:51:58 UTC
> What about inline-description tag example, which is a part of the DTD?
i'll fix that as well:)
Comment 13 Stanislav Aubrecht 2007-01-30 10:38:05 UTC
integrated to trunk:

Checking in src/org/netbeans/modules/palette/resources/editor-palette-item-1_1.dtd;
/cvs/core/palette/src/org/netbeans/modules/palette/resources/editor-palette-item-1_1.dtd,v
 <--  editor-palette-item-1_1.dtd
initial revision: 1.1
done
Checking in src/org/netbeans/modules/palette/resources/layer.xml;
/cvs/core/palette/src/org/netbeans/modules/palette/resources/layer.xml,v  <-- 
layer.xml
new revision: 1.11; previous revision: 1.10
done
Checking in api/doc/changes/apichanges.xml;
/cvs/core/palette/api/doc/changes/apichanges.xml,v  <--  apichanges.xml
new revision: 1.14; previous revision: 1.13
done
Checking in src/org/netbeans/modules/palette/PaletteEnvironmentProvider.java;
/cvs/core/palette/src/org/netbeans/modules/palette/PaletteEnvironmentProvider.java,v
 <--  PaletteEnvironmentProvider.java
new revision: 1.10; previous revision: 1.9
done
Checking in src/org/netbeans/modules/palette/PaletteItemNode.java;
/cvs/core/palette/src/org/netbeans/modules/palette/PaletteItemNode.java,v  <-- 
PaletteItemNode.java
new revision: 1.10; previous revision: 1.9
done
Checking in src/org/netbeans/modules/palette/PaletteItemHandler.java;
/cvs/core/palette/src/org/netbeans/modules/palette/PaletteItemHandler.java,v 
<--  PaletteItemHandler.java
new revision: 1.6; previous revision: 1.5
done
Checking in test/unit/src/org/netbeans/spi/palette/PaletteItemTest.java;
/cvs/core/palette/test/unit/src/org/netbeans/spi/palette/PaletteItemTest.java,v
 <--  PaletteItemTest.java
new revision: 1.7; previous revision: 1.6
done

Checking in editor-palette-item-1_1.dtd;
/cvs/www/www/dtds/editor-palette-item-1_1.dtd,v  <--  editor-palette-item-1_1.dtd
initial revision: 1.1
done


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo