<!-- <questionid="arch-overall"when="init"> Describetheoverallarchitecture. <hint> WhatwillbeAPIfor <ahref="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi"> clientsandwhatsupportAPI</a>? Whatpartswillbepluggable? Howwillplug-insberegistered?Pleaseuse<code><apitype="export"/></code> todescribeyourgeneralAPIs. Ifpossiblepleaseprovide simplediagrams. </hint> </question>
-->
<answer id="arch-overall">
<p>
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.
<api name="Palette" group="java"type="export" category="stable"url="@TOP@/overview-summary.html"/>
</p>
<p>
The API includes support for the clients writing palette content insertable into the text editor.<br/>
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.
<api name="editor-palette-item-1_0.dtd" group="dtd"type="export" category="stable"url="http://www.netbeans.org/dtds/editor-palette-item-1_0.dtd" />
</p>
</answer>
<!-- <questionid="arch-quality"when="init"> Howwillthe<ahref="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a> ofyourcodebetestedand howarefutureregressionsgoingtobeprevented? <hint> Whatkindoftestingdo youwanttouse?Howmuchfunctionality,inwhichareas, shouldbecoveredbythetests? </hint> </question>
-->
<answer id="arch-quality">
<p>
There are unit tests for Palette's model implementation and assertions are used where appropriate.
</p>
</answer>
<!-- <questionid="arch-time"when="init"> Whatarethetimeestimatesofthework? <hint> Pleaseexpressyourestimatesofhowlongthedesign,implementation, stabilizationarelikelytolast.Howmanypeoplewillbeneededto implementthisandwhatistheexpectedmilestonebywhichtheworkshouldbe ready? </hint> </question>
-->
<answer id="arch-time">
<p>
The remaining work is about 1 man/weeks (July 20th 2005).
</p>
</answer>
<!-- <questionid="arch-usecases"when="init"> <hint> Contentofthisanswerwillbedisplayedaspartofpageat http://www.netbeans.org/download/dev/javadoc/usecases.html Youcanusetags<usecasename="name>regularhtmldescription</usecase> andifyouwanttouseanURLyoucanprefixifwith@TOP@tobegin attherootofyourjavadoc </hint> Describethemain<ahref="http://openide.netbeans.org/tutorial/api-design.html#usecase"> usecases</a>ofthenewAPI.Whowilluseitunder whatcircumstances?Whatkindofcodewouldtypicallyneedtobewritten tousethemodule? </question>
-->
<answer id="arch-usecases">
<usecase id="content" name="Palette Content" >
<p>The Common Palette content is a two-level hierarchy. The top-most level
are <b>Categories</b>, the Category children are <b>Items</b>. It's
possible to select (highlight) items in the palette panel using a mouse
or keyboard and then inserted/dropped into an editor that supports the palette.</p>
<p>The palette content can come from two different sources:</p>
<ul>
<li><b>Folders and files hierarchy defined in XML layer:</b> folders under
palette's root folder represent categories, files in category folders are palette
item. This way of creating of palette content is more convenient for module
developers as very little extra coding is required to setup a palette.</li>
<li><b>An arbitraty hierarchy of generic Nodes:</b> the children of palette's
root Node are categories and the children of a category Node are palette items.
This approach is more flexible when the palette content must change dynamically
(e.g. according to cursor position in editor window) however more coding
may be needed to setup the Node hierarchy. Please see Nodes API for more
details on Node management.</li>
</ul>
</usecase>
<usecase id="basic_xml" name="Basic usage" >
<p>The following steps must be taken if a module wants to define its own palette
content as a hierarchy of folders and files in its XML layer:</p>
<ul>
<li>Define palette's root folder in module's layer and also define subfolders for
categories and file objects for palette items.<br/>Example:<br/>
<pre>
<filesystem>
<folder name="MyModulePalette">
<folder name="Category1">
<file name="PaletteItem_1.myitem"url="palette/PaletteItem_1.xml" />
<file name="PaletteItem_2.myitem"url="palette/PaletteItem_2.xml" />
<file name="PaletteItem_3.myitem"url="palette/PaletteItem_3.xml" />
</folder>
<folder name="Category2">
<file name="PaletteItem_4.myitem"url="palette/PaletteItem_4.xml" />
<file name="PaletteItem_5.myitem"url="palette/PaletteItem_5.xml" />
<file name="PaletteItem_6.myitem"url="palette/PaletteItem_6.xml" />
</folder>
</folder>
</filesystem>
</pre>
<br/>Note: it's necessary to define some way of loading of the palette item
from e.g. XML files. There are several possible ways to achieve that,
please refer to DataLoaders API for more details.
</li>
<li>Extend <a href="@TOP@/org/netbeans/spi/palette/PaletteActions.html">PaletteActions</a>
class that provides custom Actions for palette's popup menus.
<br/>Example:<br/>
<pre>
class MyPaletteActions extends PaletteActions {
public Action[] getCustomItemActions(Lookup lookup) {
Node itemNode = (Node)lookup.lookup( Node.class );
if( null != itemNode ) {
return new Action[] { new CustomizeItemAction( itemNode ) };
}
return null;
}
public Action[] getCustomCategoryActions(Lookup lookup) {
Node categoryNode = (Node)lookup.lookup( Node.class );
if( null != categoryNode ) {
return new Action[] { new CustomizeCategoryAction( categoryNode ) };
}
return null;
}
public Action[] getImportActions() {
return new Action[] { new ImportItemsFromWebAction() };
}
public Action[] getCustomPaletteActions() {
return null; //no custom actions for palette's root
}
}
</pre>
</li>
<li>Use <a href="@TOP@/org/netbeans/spi/palette/PaletteFactory.html">PaletteFactory</a>
to create an instance of PaletteController. The editor module keeps
a reference to this object and registers a PropertyChangeListner to it to be notified
of palette's selection changes.<br/>Example:<br/>
<pre>
class MyClass {
PaletteController controller;
controller.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) {
if( PaletteController.PROP_SELECTED_ITEM.equals( evt.getPropertyName() ) ) {
Lookup selItem = controller.getSelectedItem();
if( null == selItem ) {
//nothing is selected in palette
} else {
Node selNode = (Node)selItem.lookup( Node.class );
if( null != selNode ) {
//change mouse cursor for editor window to indicate
//the type of palette item that can be dropped
changeCursorInEditorWindow( selNode );
}
}
}
}
});
return controller;
}
}
</pre>
</li>
<li>Add the instance of
<a href="@TOP@/org/netbeans/spi/palette/PaletteController.html">PaletteController</a>
to the lookup of editor's TopComponent.<br/>
<pre>
class MyEditorTopComponent extends TopComponent {
private MyEditorTopComponent() {
this( new InstanceContent() );
}
PaletteController controller;
private PaletteController initializePalette() {
if( null == controller ) {
controller = PaletteFactory.createPalette( "MyPalette", new MyPaletteActions() );
}
return controller;
}
}
</pre>
</li>
</ul>
<p>
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
<a href="@TOP@/org/netbeans/spi/palette/PaletteController.html#getSelectedItem()">PaletteController.getSelectedItem()</a>.
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
(<a href="@TOP@/org/netbeans/spi/palette/PaletteController.html#clearSelection()">PaletteController.clearSelection()</a>)
or leave the item selected to implement 'multi drop' insertion scenario.
</p>
</usecase>
<usecase id="filter" name="Filtering" >
<p>It is possible to filter palette content and hide some categories and/or
items from the user by extending <a href="@TOP@/org/netbeans/spi/palette/PaletteFilter.html">PaletteFilter</a> class.
</p>
<pre>
class MyPaletteFilter extends PaletteFilter {
private boolean isItemVisibleInCurrentEditorContext( Node item ) {
boolean res = true;
//check current cursor positions and/or item type and decide whether
//the item is valid, i.e. can be selected and dropped into editor
return res;
}
private boolean isCategoryVisibleInCurrentEditorContext( Node item ) {
boolean res = true;
//check current cursor positions and/or category type and decide whether
//the category is valid, i.e. its items can be selected and dropped into editor
return res;
}
</pre>
<p>Then initialize the palette using the following method:</p>
<pre>
MyPaletteFilter filter = new MyPaletteFilter();
PaletteController controller = PaletteFactory.createPalette( "MyPalette", new MyPaletteActions(), filter, null );
</pre>
<p>It is necessary to call
<a href="@TOP@/org/netbeans/spi/palette/PaletteController.html#refresh()">PaletteController.refresh()</a>
to refresh and repaint the palette window whenever the filtering condition has changed:</p>
<pre>
myPaletteFilter.setShowSomeSpecialCategories( false );
paletteController.refresh();
</pre>
</usecase>
<usecase id="settings" name="Default Settings" >
<p>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().</p>
<p>In the example below the palette will not show item names initially
(only icons are visible), the user can change this in palette's context menu.
Category1 is read-only therefore the user cannot remove it.
Category2 is not initially visible, the user can change this in
palette's customizer.
<br/></p>
<pre>
<filesystem>
<folder name="MyModulePalette">
<attr name="showItemNames" stringvalue="false"/>
<file name="PaletteItem_4.myitem"url="palette/PaletteItem_4.myitem" />
<file name="PaletteItem_5.myitem"url="palette/PaletteItem_5.myitem" />
<file name="PaletteItem_6.myitem"url="palette/PaletteItem_6.myitem" />
</folder>
</folder>
</filesystem>
</pre>
</usecase>
<usecase id="newcontentatruntime" name="Adding categories and items at runtime" >
<p>It is possible to add new palette categories and/or palette item at runtime
when the palette window is already visible.</p>
<p>Adding a <strong>new category</strong> is very straight-forward, it basically means creating
a new folder under palette's root folder in XML layer:</p>
<pre>
FileObject paletteRoot = FileUtil.getConfigFile( "MyModulePalette" );
paletteRoot.createFolder( "NewCategory" );
</pre>
<p>Adding a <strong>new item</strong> is a similar task:</p>
<pre>
FileObject paletteRoot = FileUtil.getConfigFile( "MyPalette" );
FileObject targetCategoryFO = paletteRoot.getFileObject( "CategoryName" );
DataFolder targetCategoryDF = DataFolder.findFolder( targetCategoryFO );
DataObject dobj = (DataObject)itemNode.getLookup().lookup( DataObject.class );
dobj.copy( targetCategoryFolder );
</pre>
<p>Please refer to Nodes API in case the palette content is defined as a
hierarchy of arbitrary Nodes.</p>
</usecase>
<usecase id="items" name="Palette content for text-based editors" >
<p>The following steps must be taken when writing the item using the support provided by this module:</p>
<ol>
<li>
Create XML file with item definition according to
the <a href="@TOP@architecture-summary.html#dtd-editor-palette-item-1_0.dtd">editor-palette-item-1_0.dtd</a>.
</li>
<li>
Register it in the editor's layer file (see Basic usage).
</li>
<li>
Provide custom item implementation of the ActiveEditorDrop interface if needed. I must be
referenced from the definition file.
</li>
</ol>
</usecase>
</answer>
<!-- <questionid="arch-what"when="init"> Whatisthisprojectgoodfor? <hint> Pleaseprovidehereafewlinesdescribingtheproject, whatproblemitshouldsolve,providelinkstodocumentation, specifications,etc. </hint> </question>
-->
<answer id="arch-what">
<p>
The project implements a new component palette that will be reused by other
projects. The new palette should provide a common look and feel for Form editor,
Mobility, J2EE and possible other modules as well.
UI draft specification is available at http://ui.netbeans.org/docs/ui/palette/index.html
</p>
</answer>
<!-- <questionid="compat-i18n"when="impl"> Isyourmodulecorrectlyinternationalized? <hint> Correctinternationalizationmeansthatitobeysinstructions at<ahref="http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/doc-files/i18n-branding.html"> NetBeansI18Npages</a>. </hint> </question>
-->
<answer id="compat-i18n">
<p>
Yes (any uninternationalized text will be fixed during implementation).
</p>
</answer>
<!-- <questionid="compat-standards"when="init"> Doesthemoduleimplementordefineanystandards?Isthe implementationexactordoesitdeviatesomehow? </question>
-->
<answer id="compat-standards">
<p>
The palette's user inteface should match the look and feel of comparable components
in competitive IDEs as defined in the UI specification document.
</p>
</answer>
<!-- <questionid="compat-version"when="impl"> Canyourmodulecoexistwithearlierandfuture versionsofitself?Canyoucorrectlyreadalloldsettings?Willfuture versionsbeabletoreadyourcurrentsettings?Canyouread orpolitelyignoresettingsstoredbyafutureversion? <hint> Veryhelpfulforreadingsettingsistostoreversionnumber there,sofutureversionscandecidewhetherhowtoread/convert thesettingsandolderversionscanignorethenewones. </hint> </question>
-->
<answer id="compat-version">
<p>
API should be backwards compatible, old settings can be ignored if needed.
All user settings are stored in an XML file that can be easily extended.
</p>
</answer>
<!-- <questionid="format-clipboard"when="impl"> Whichdataflavors(ifany)doesyourcodereadfromorinsertto theclipboard(byaccesstoclipboardonmeanscallingmethodson<code>java.awt.datatransfer.Transferable</code>? <hint> OftenNode'sdealwithclipboardbyusageof<code>Node.clipboardCopy,Node.clipboardCutandNode.pasteTypes</code>. Checkyourcodeforoverridingthesemethods. </hint> </question>
-->
<answer id="format-clipboard">
<p>
Palette extends the default clipboard implementation from Nodes. When a palette
item (Node) is copied/cut to clipboard it adds another data flavor to Transferable
created by the default Node implementation, see PaletteController.ITEM_DATA_FLAVOR.
The transfer data for this flavor is the Lookup of item's Node.
</p>
</answer>
<!-- <questionid="format-dnd"when="impl"> Whichprotocols(ifany)doesyourcodeunderstandduringDrag&Drop? <hint> OftenNode'sdealwithclipboardbyusageof<code>Node.drag,Node.getDropType</code>. Checkyourcodeforoverridingthesemethods.Btw.iftheyarenotoverridden,they bydefaultdelegateto<code>Node.clipboardCopy,Node.clipboardCutandNode.pasteTypes</code>. </hint> </question>
-->
<answer id="format-dnd">
<p>
Palette extends the default drag'n'drop implementation from Nodes. When an item
is being dragged from the palette to editor window the Transferable is provided
by the default Node.drag() method and a another data flavor is added
(see PaletteController.ITEM_DATA_FLAVOR) which contains the Lookup of dragged
item's Node.
<br/>
Palette clients can provide their own data flavors to items being dragged by
subclassing the DragAndDropHandler class. This class also provides methods
to implement the drop of new items from e.g. editor area to the palette window.
</p>
</answer>
<!-- <questionid="format-types"when="impl"> Whichprotocolsandfileformats(ifany)doesyourmodulereadorwriteondisk, ortransmitorreceiveoverthenetwork?Doyougenerateanantbuildscript? Canitbeeditedandmodified? <hint> <p> Filescanbereadandwrittenbyotherprograms,modulesandusers.Iftheyinfluence yourbehaviour,makesureyoueitherdocumenttheformatorclaimthatitisaprivate api(usingthe<api>tag). </p> <p> Ifyougenerateanantbuildfile,thisisverylikelygoingtobeseenbyendusersand theywillbeattemptedtoeditit.Youshouldbereadyforthatandprovideherealink todocumentationthatyouhaveforsuchpurposesandalsodescribehowyouaregoingto understandsuchfilesduringnextrelease,whenyou(verylikely)slightlychangethe format. </p> </hint> </question>
-->
<answer id="format-types">
<p>
<api group="layer" name="user_settings"type="export" category="private">
<p>
There's a private XML file for user settings for each palette model.
</p>
</api>
</p>
</answer>
<!-- <questionid="lookup-lookup"when="init"> Doesyourmoduleuse<code>org.openide.util.Lookup</code> oranysimilartechnologytofindanycomponentstocommunicatewith?Whichones? <hint> Pleasedescribetheinterfacesyouaresearchingfor,where aredefined,whetheryouaresearchingforjustoneormoreofthem, iftheorderisimportant,etc.Alsoclassifythestabilityofsuch APIcontract.Forthatuse<apigroup=&lookup&/>tag. </hint> </question>
-->
<answer id="lookup-lookup">
<p>
<api group="lookup" name="activated_node"type="export" category="stable">
<p>
Palette listens to system activated node changes. The palette TopComponent
opens when an editor TopComponent with a PaletteController instance in its Lookup
is opened or activated. Palette window closes when the editor window is closed
or deactivated and no other visible editor window supports the palette.<br/>
The palette window always shows the content from the last active editor
window regardless where the input focus is. The palette content is updated
when user activates a different editor window that supports the palette.
</p>
</api>
</p>
</answer>
<!-- <questionid="lookup-register"when="final"> Doyouregisteranythingintolookupforothercodetofind? <hint> Doyouregisterusinglayerfileorusing<code>META-INF/services</code>? Whoissupposedtofindyourcomponent? </hint> </question>
-->
<answer id="lookup-register">
<p>
<api name="node_represention" group="lookup"type="export" category="stable">
The palette item implementor can either directly provide the item body
or her own item class implementing <code>org.openide.text.ActiveEditorDrop</code> interface.
<br/>
Lookup that holds object(s) representing the selected item then associates
custom item class instance with the <code>org.openide.text.ActiveEditorDrop.class</code> key and
the body with <code>java.lang.String</code> key.
<br/>
Editor side implementor can use the Lookup content whenever the Lookup is given,
namely in the editor-provided implementations of the <code>PaletteActions</code>,
<code>DragAndDropHandler</code> and <code>PropertyChangeListener</code> (registered
on the <code>PaletteController</code>) interfaces.
</api>
</p>
</answer>
<!-- <questionid="perf-huge_dialogs"when="final"> Doesyourmodulecontainanydialogsorwizardswithalargenumberof GUIcontrolssuchascomboboxes,lists,trees,ortextareas? </question>
-->
<answer id="perf-huge_dialogs">
<p>
There's a 'Palette Customizer' dialog window that displays hierarchy of palette contents
(categories and their items) and contains some buttons to customize the palette contents.
The Palette Customizer window design depends on the final version of the UI specification.
</p>
</answer>
<!-- <questionid="perf-mem"when="final"> Howmuchmemorydoesyourcomponentconsume?Estimate witharelationtothenumberofwindows,etc. </question>
-->
<answer id="perf-mem">
<p>
Depends on the palette contents provided by palette clients. The Palette module
provides only user interface for the palette contents.
</p>
</answer>
<!-- <questionid="perf-progress"when="final"> Doesyourmoduleexecuteanylong-runningtasks? <hint>Longrunningtasksshouldneverblock AWTthreadasitbadlyhurtstheUI <ahref="http://performance.netbeans.org/responsiveness/issues.html"> responsiveness</a>. Taskslikeconnectingover network,computinghugeamountofdata,compilation bedoneasynchronously(forexample using<code>RequestProcessor</code>),definitivelyitshould notblockAWTthread. </hint> </question>
-->
<answer id="perf-progress">
<p>
Depends on the palette contents provided by palette clients. When the palette
contents is being switched (i.e. user activates a different editor) the palette UI
must display icons and/or names for items in expanded categories. This is being
done in AWT thread.
On the other hand the palette can show only a limited number of items according to screen
resolution so there will be only a limited number of of requests for item's name and icon
during this switch.
</p>
</answer>
<!-- <questionid="perf-scale"when="init"> Whichexternalcriteriainfluencetheperformanceofyour program(sizeoffileineditor,numberoffilesinmenu, insourcedirectory,etc.)andhowwellyourcodescales? <hint> Pleaseincludesomeestimates,thereareothermoredetailed questionstoanswerinlaterphasesofimplementation. </hint> </question>
-->
<answer id="perf-scale">
<p>
The default palette model implementation is based on Nodes, therefore
the performance criteria are the same as those for Nodes.
</p>
</answer>
<!-- <questionid="resources-layer"when="final"> Doesyourmoduleprovideownlayer?Doesitcreateanyfilesor foldersinit?Whatitistryingtocommunicatebythatandwithwhich components? <hint> NetBeansallowsautomaticanddeclarativeinstallationofresources bymodulelayers.Moduleregisterfilesintoappropriateplaces andothercomponentsusethatinformationtoperformtheirtask (buildmenu,toolbar,windowlayout,listoftemplates,setof options,etc.). </hint> </question>
-->
<answer id="resources-layer">
<p>
Yes, it creates folder PaletteSettings where a file is created for user settings
for each palette model.<br/>
There's also Window System definition of palette's TopComponent group and mode.
<br/>
Palette clients (editor modules) may define palette contents in their layers.
</p>
</answer>
<!-- <questionid="resources-read"when="final"> Doesyourmodulereadanyresourcesfromlayers?Forwhatpurpose? <hint> Asthisissomekindofintermoduledependency,itisakindofAPI. Pleasedescribeitandclassifyaccordingto <ahref="http://openide.netbeans.org/tutorial/api-design.html#categories"> commonstabilitycategories</a>. </hint> </question>
-->
<answer id="resources-read">
<p>
The default palette model is based on Nodes that may be defined in layer hierarchy.
</p>
</answer>
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.45Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.