<!-- <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>
Navigator API is good for clients (module writers) that want to show some
structure or outline of their document in dedicated window, allowing end user
fast navigation and control over the document.</p>
<p>
API allows its clients to plug in their Swing based views easily, which
then will be automatically shown in specialized Navigator UI.</p>
<!-- <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>
Unit tests will be written ensuring that implementation loads, instantiates
and calls client's SPI correctly. Usual manual testing will be performed as
well. As whole API is rather small, it will be easily covered by unit tests
as a whole.
</p>
</answer>
<!-- <questionid="arch-time"when="init"> Whatarethetimeestimatesofthework? <hint> Pleaseexpressyourestimatesofhowlongthedesign,implementation, stabilizationarelikelytolast.Howmanypeoplewillbeneededto implementthisandwhatistheexpectedmilestonebywhichtheworkshouldbe ready? </hint> </question>
-->
<answer id="arch-time">
<p>
(June 8, 2005) Basic design and implementation are somehow written and
compilable, but not tested so far.
Estimated time for work left is three-four weeks of one-man work.
Important milestone is merge into main trunk, which should happen in
early August.
</p>
</answer>
<usecase id="basicUsage" name="Basic Usage Steps" >
In order to plug in a view into Navigator UI for certain document (data) type,
module writers need to write a <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
implementation marked with <code>@Registration</code>.
<h4>Writing NavigatorPanel implementation</h4>
<p>Implementing <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
interface is easy, you can copy from template basic implementation
<a href="@TOP@/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl_java">BasicNavPanelImpl.java</a>.</p>
Advices on important part of panel implementation:
<ul>
<li><b>Instantiation:</b> Your implementation of NavigatorPanel
is instantied automatically by the system if you register it using <code>@Registration</code>.</li>
<li><b>getComponent</b> method: Simply create and return your UI
representation of your data in Swing's JComponent envelope. Just be sure
that you don't create new JComponent subclass per every call, as
performance will suffer then.<p></p></li>
<li><b>panelActivated and panelDeactivated</b> methods wraps an 'active' life of your panel implementation. In panelActivated, grab
your data from given <a href="@org-openide-util-lookup@/org/openide/util/Lookup.html">Lookup</a>,
usually by looking up its asociated
<a href="@org-openide-loaders@/org/openide/loaders/DataObject.html">DataObject</a>
or
<a href="@org-openide-filesystems@/org/openide/filesystems/FileObject.html">FileObject</a>
to take data from. Also remember to attach listeners to lookup result,
perhaps also to data itself and trigger UI update with new data.
Code will typically look like this:<br></br>
<pre>
/** JavaDataObject used as example, replace with your own data source */
private static final Lookup.Template MY_DATA = new Lookup.Template(JavaDataObject.class);
public void panelActivated (Lookup context) {
// lookup context and listen to result to get notified about context changes
curResult = context.lookup(MY_DATA);
curResult.addLookupListener(/** your LookupListener impl here*/);
Collection data = curResult.allInstances();
// ... compute view from data and trigger repaint
}
</pre>
Do *not* perform any long computation in panelActivated directly, see below.<br></br>
In panelDeactivated, be sure to remove all listeners to context given
to you in panelActivated.<p></p></li>
<li><b>Long computation of content:</b> What if rendering your
Navigator view takes long time, more than several milliseconds?
Right approach is to create and run new task using
<a href="@org-openide-util@/org/openide/util/RequestProcessor.html">RequestProcessor techniques</a>,
each time when panelActivated call arrived or your listeners on
data context got called.<br></br>
While computing, UI of Navigator view
should show some please wait message.<p></p></li>
</ul>
<h4>Registering NavigatorPanel impl</h4>
<p>Declarative registration of your NavigatorPanel impl connects this
implementation with specific content type, which is type of
the document, expressed in mime-type syntax, for example 'text/x-java'
for java sources. Infrastructure will automatically load and show
your NavigatorPanel impl in UI, when <b>currently activated Node
is backed by primary FileObject whose
<a href="@org-openide-filesystems@/org/openide/filesystems/FileObject.html#getMIMEType()">FileObject.getMimeType()</a>
equals to content type specified in your registering annotation</b> (see more options below).</p>
</usecase>
<usecase id="lookupHint" name="Advanced Content Registration - Linking to Node's Lookup" >
<p>There may be situations where linking between your Navigator view and
activated Node's primary FileObject is not enough or not possible at all.
This simply happens when the data you want to represent in Navigator are
not accessible through primary FileObject or DataObject. Usual example is
Multiview environment, where more views of one document exists.</p>
<p>The solution is to bind content of your Navigator view directly to your
TopComponent. Then, whenever your TopComponent gets activated in the system, Navigator UI
will show th content you connected to it.</p>
<b>Steps to do:</b>
<ul>
<li>Choose your content type, could be either well known or arbitrary,
say <b>'text/my-amazing-type'</b> and
do all basic steps described in above use case.<p></p></li>
<li>Implement <a href="@TOP@/org/netbeans/spi/navigator/NavigatorLookupHint.html">NavigatorLookupHint</a>
interface like this:
<pre>
class AmazingTypeLookupHint implements NavigatorLookupHint { public String getContentType () {
return "text/my-amazing-type";
}
}
</pre>
<p></p></li>
<li>Alter your <a href="@org-openide-windows@/org/openide/windows/TopComponent.html">TopComponent</a>
to contain your NavigatorLookupHint implementation (AmazingTypeLookupHint in this case)
in its lookup, returned from
<a href="@org-openide-windows@/org/openide/windows/TopComponent.html#getLookup()">TopComponent.getLookup()</a>
method.<p></p></li>
<li>
Another option you have is to alter lookup of your <code>Node</code> subclass
instead of directly altering lookup of your <code>TopComponent</code>.
See <a href="@org-openide-nodes@/org/openide/nodes/Node.html#getLookup()">Node.getLookup()</a> method.
Then Navigator will show your desired content whenever your <code>Node</code>
subclass will be active in the system.<br></br>
However, keep in mind that this option is less preferred, because it
only uses implementation detail knowledge that default implementation
of <code>TopComponent.getLookup()</code> includes also results from
lookup of asociated <code>Node</code>. So this approach will stop
working if you change default behaviour of <code>TopComponent.getLookup()</code> method.
<p></p>
</li>
</ul>
</usecase>
<usecase id="activatePanel" name="Programmatic activation of NavigatorPanel" >
<p>Programmatic activation of specific navigator panel activates and shows
navigator panel in navigation area, as if user had selected the panel
manually. API clients are expected to use programmatic activation to
activate/select preferred panel from a set of available panels.</p>
<b>Example:</b>
Several <code>TopComponents</code> in multiview arrangement,
<code>TopComponentA</code> and <code>TopComponentB</code>.
Both components provide the same
<code>NavigatorLookupHint</code> impl, which is recognized by two
providers <code>NavigatorPanelA</code> and <code>NavigatorPanelB</code>.
Now when <code>TopComponentA</code> becomes activated (has a focus),
it's desirable to select/show <code>NavigatorPanelA</code> from
navigator panels. On the other side, when <code>TopComponentB</code>
is activated, <code>NavigatorPanelB</code> should be activated automatically.
<p></p>
<b>Steps to do to activate panel programmatically:</b>
<ul>
<li>Get the instance of <code>NavigatorPanel</code> implementation that
you want to activate/show in navigator area.<br></br>
See <a href="@org-openide-util@/org/openide/util/doc-files/api.html#instances">Instantiation rules</a>.<p></p>
</li>
<usecase id="activatedNode" name="Setting activated node of Navigator window" >
<p>Sometimes clients need to alter activated Nodes of Navigator window,
to better represent Navigator area content within the whole application.
See <a href="@org-openide-windows@/org/openide/windows/TopComponent.html#getActivatedNodes()">TopComponent.getActivatedNodes()</a>
and <a href="@org-openide-windows@/org/openide/windows/TopComponent.Registry.html#getActivatedNodes()">TopComponent.Registry.html#getActivatedNodes()</a>
to find out what activated nodes of TopComponent and whole system mean.
</p>
<b>Use Case Example:</b>
NavigatorPanel implementation shows list or tree of some <code>Node</code>s
in Navigator area. When user selects a Node in the list or tree,
it is desirable to show selected Node's properties in Properties
window and enable proper actions in main menu. Exactly this can be done
by presenting Node selected in the list/tree as activated Node of
Navigator window.
<p></p>
<b>Steps to specify activated Nodes of Navigator window:</b>
<ul>
<li>In your implementation of <code>NavigatorPanel</code>, implement
method <code>getLookup()</code> to return Lookup instance filled
with Node(s) that you want to set as activated Nodes of Navigator window.
<p></p>
</li>
<li>Be sure to update Lookup content properly, for example using
<a href="@org-openide-util-lookup@/org/openide/util/lookup/InstanceContent.html">InstanceContent</a> as follows:
<pre>
class MyNavigatorPanel implements NavigatorPanel {
/** Dynamic Lookup content */
private final InstanceContent ic;
/** Lookup instance */
private final Lookup lookup;
public MyNavigatorPanel () {
this.ic = new InstanceContent();
this.lookup = new AbstractLookup(ic);
}
public Lookup getLookup () {
return lookup;
}
/** Call this method when activated Nodes change is needed,
* for example when selection changes in your NavigatorPanel's Component
*/
private void selectionChanged (Node oldSel, Node newSel) {
ic.remove(oldSel);
ic.add(newSel);
}
... impl of rest of your NavigatorPanel
}
</pre>
</li>
</ul>
</usecase>
<usecase id="undoRedo" name="Adding UndoRedo support to the navigation view" >
<p>Some complex navigation views need support for undoing and redoing
edit changes done either directly in the view or in document which
the view is representing.
</p>
<b>Steps to support undo and redo in navigation view:</b>
<ul>
<li>Implement your navigation view as <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanelWithUndo.html">NavigatorPanelWithUndo</a>,
which is <code>NavigatorPanel</code> interface with extra method
<a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanelWithUndo.html#getUndoRedo()">getUndoRedo()</a>.
<p></p>
</li>
<li>All other things remain the same as with basic <code>NavigatorPanel</code> usage.
<code>UndoRedo</code> support returned from <code>NavigatorPanelWithUndo.getUndoRedo()</code>
is propagated to the Navigator TopComponent and returned as its
<code>UndoRedo</code> support. For details see
<a href="@org-openide-windows@/org/openide/windows/TopComponent.html#getUndoRedo()">TopComponent.getUndoRedo()</a>
and <a href="@org-openide-awt@/org/openide/awt/UndoRedo.html">UndoRedo interface</a>.
<p></p>
</li>
<li>Example of <code>NavigatorPanelWithUndo</code> implementation:
<pre>
class MyNavigatorPanelWithUndo implements NavigatorPanelWithUndo {
/** UndoRedo support, substitute with your impl */
private final UndoRedo undo = new UndoRedo.Manager();
public UndoRedo getUndoRedo () {
return undo;
}
... rest of the NavigatorPanelWithUndo impl ...
}
</pre>
</li>
</ul>
</usecase>
<usecase id="panelsPolicy" name="Removing active Node/DataObject related NavigatorPanels from Navigator window" >
<p>In certain situations it's not desired to show NavigatorPanel implementations
related to DataObject of active Node in Navigator window. Typically
you need to have active Node of some type, so that actions in the system
works properly. But you don't want to show NavigatorPanels that "come"
with such active Node.
</p>
<b>Steps to remove such NavigatorPanels:</b>
<ul>
<li>Implement interface <a href="@TOP@/org/netbeans/spi/navigator/NavigatorLookupPanelsPolicy.html">NavigatorLookupPanelsPolicy</a>,
return kind of policy that suits you from <code>getPanelsPolicy()</code> method.
<p></p>
</li>
<li>Put implementation instance into your TopComponent's subclass lookup,
see <a href="@org-openide-windows@/org/openide/windows/TopComponent.html#getLookup()">TopComponent.getLookup()</a>
for details.
<p></p>
</li>
<li>Now when your TopComponent becomes active in the system, found
panels policy is used to limit/affect set of available
<a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
implementations.
<p></p>
</li>
</ul>
</usecase>
<usecase id="explorerView" name="Integration of Explorer view into Navigator" >
<p>Explorer views comes handy when showing Nodes in varienty of situations
and it is just natural to be able to integrate them into Navigator window.
Working with explorer views is described at
<a href="@org-openide-explorer@/org/openide/explorer/ExplorerUtils.html">ExplorerUtils javadoc</a>.
Integration with Navigator is easy and there are only subtle differencies
from integration into TopComponent.
</p>
<b>Steps to integrate some kind of Explorer View into Navigator:</b>
<ul>
<li>Implement <code>NavigatorPanel</code> interface and return created explorer
view from <code>getComponent()</code> method. Creating explorer view
is described in <a href="@org-openide-explorer@/org/openide/explorer/ExplorerUtils.html">ExplorerUtils</a>.
<p></p>
</li>
<li>Return lookup created using
<a href="@org-openide-explorer@/org/openide/explorer/ExplorerUtils.html#createLookup(org.openide.explorer.ExplorerManager,javax.swing.ActionMap)">
ExplorerUtils.createLookup(ExplorerManager, ActionMap)</a>
from <code>getLookup()</code> method of <code>NavigatorPanel</code>.
<p></p>
</li>
<li>Use <a href="@org-openide-explorer@/org/openide/explorer/ExplorerUtils.html#activateActions(org.openide.explorer.ExplorerManager,boolean)">
ExplorerUtils.activateActions(ExplorerManager, boolean)</a> for actions activation and
deactivation in <code>panelActivated</code> and <code>panelDeactivated</code>.
<p></p>
</li>
<li>Take inspiration from following example code which integrates
ListView with Navigator:
<pre> public class ListViewNavigatorPanel extends JPanel implements NavigatorPanel, ExplorerManager.Provider {
<!-- <questionid="arch-what"when="init"> Whatisthisprojectgoodfor? <hint> Pleaseprovidehereafewlinesdescribingtheproject, whatproblemitshouldsolve,providelinkstodocumentation, specifications,etc. </hint> </question>
-->
<answer id="arch-what">
Navigator module is a base API module which provides:
<ul>
<li> A place for modules to show structure/outline of their documents</li>
<li> Ability for modules to show their view only when special document(node)
is active in the system</li>
<li> UI for switching between multiple views available for currently active document(node)</li>
<li> Coalescing of fast coming selected node changes to show content for</li>
</ul>
</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, there is not much I18N.
</p>
</answer>
<!-- <questionid="compat-standards"when="init"> Doesthemoduleimplementordefineanystandards?Isthe implementationexactordoesitdeviatesomehow? </question>
-->
<answer id="compat-standards">
<p>
No new unusual standard, just layer-based xml registration and SPI
interface NavigatorPanel that clients has to implement.
</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>
Yes it will. However this is open issue now - whether to store settings
(like filter values) for Navigator API clients and how.
</p>
</answer>
<!-- <questionid="dep-nb"when="init"> WhatotherNetBeansprojectsandmodulesdoesthisonedependon? <hint> Ifyouwant,describesuchprojectsasimportedAPIsusing the<code><apiname="identification"type="importorexport"category="stable"url="whereisthedescription"/></code> </hint> </question>
-->
<answer id="dep-nb">
<p>
Navigator module depends on:
<api group="java" name="OpenAPIs"type="import" category="official">
<p>
For acces to winsys TopComponent, Nodes, lookup,
general utilities like icon obtaining, bundles.
</p>
</api>
<api group="java" name="Loaders"type="import" category="official">
<p>
API implementation has to access data objects for obtaining mime types.
</p>
</api>
<!-- <questionid="exec-reflection"when="impl"> DoesyourcodeuseJavaReflectiontoexecuteothercode? <hint> ThisusuallyindicatesamissingorinsufficientAPIintheother partofthesystem.Iftheothersideisnotawareofyourdependency thiscontractcanbeeasilybroken. </hint> </question>
-->
<answer id="exec-reflection">
<p>
No, just instatiating registered providers.
</p>
</answer>
<!-- <questionid="exec-threading"when="impl"> Whatthreadingmodels,ifany,doesyourmoduleadhereto? <hint> IfyourmodulecallsforeignAPIswhichhaveaspecificthreadingmodel, indicatehowyoucomplywiththerequirementsformultithreadedaccess (synchronization,mutexes,etc.)applicabletothoseAPIs. IfyourmoduledefinesanyAPIs,orhascomplexinternalstructures thatmightbeusedfrommultiplethreads,declarehowyouprotect dataagainstconcurrentaccess,raceconditions,deadlocks,etc., andwhethersuchrulesareenforcedbyruntimewarnings,errors,assertions,etc. Examples:aclassmightbenon-thread-safe(likeJavaCollections);might befullythread-safe(internallocking);mightrequireaccessthroughamutex (andmayormaynotautomaticallyacquirethatmutexonbehalfofaclientmethod); mightbeabletorunonlyintheeventqueue;etc. Alsodescribewhenanyeventsarefired:synchronously,asynchronously,etc. Ideas:<ahref="http://core.netbeans.org/proposals/threading/index.html#recommendations">ThreadingRecommendations</a>(inprogress) </hint> </question>
-->
<answer id="exec-threading">
<h3>Navigator and Threading</h3>
<p>
Navigator API itself doesn't define any specific threading model, it's
up to clients to handle threading. API just instructs clients which SPI
methods should execute fast and tell them to use Request Processor for
long runnign computation of Navigator view content.
</p>
<!-- <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="devel">
<p>
Navigator listen to system activated node changes and sets activated
node for Navigator top component accordingly. Local activated node is
set from system activated node if any provider agrees to display content
for data object behind the node. Navigator relies on default lookup
mechanism of TopComponent to populate its activated node.
Currently it means that if node backed by JavaDataObject is activated node
in the system, it is also activated node for Navigator's top component.
So main menu actions like Compile File, Move Class etc. work as usual
when Navigator window is active.
Also, lookup of currently selected Node is searched for NavigatorPanel
SPI instances.
</p>
</api>
</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>
No, but clients will face this.
</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>
Nothing, API itself is out of this, but client's performance is affected by a type of document behind selected node - so the size and complexness of java, xml documents will affect performance of related Navigator clients.
</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.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.