|
XXX no answer for arch-overall
Question (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer: First see the API description. Here is just a list of frequently asked or interesting questions slowly expanding as people ask them:In order for the action to show up in Keyboards Shortcut dialog you need the action defined in the layer file under "Actions" folder and have the shortcut defined there under "Keymaps/<Profile Name>" linking to your action.
<folder name="Actions" > <folder name="Window"> <file name="org-netbeans-core-actions-PreviousViewCallbackAction.instance"/> </folder> </folder> <folder name="Keymaps"> <folder name="NetBeans"> <file name="S-A-Left.shadow"> <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-core-actions-PreviousViewCallbackAction.instance"/> </file> </folder> </folder>
The mentioned Action has to be a subclass of org.openide.util.actions.CallbackSystemAction
. It does not necessarily has to
perform the action, it's just a placeholder for linking the shortcut. You might want to override it's getActionMapKey()
and give it a
reasonable key.
The actual action that does the work in your component (preferably a simple Swing javax.swing.Action
)
is to be put into your TopComponent
's ActionMap
. The key for the ActionMap
has to match the key defined in the global action's getActionMapKey()
method.
getActionMap().put("PreviousViewAction", new MyPreviousTabAction());
This way even actions from multiple TopComponent
s with the same gesture (eg. "switch to next tab") can share the same configurable shortcut.
Note: Don't define your action's shortcut and don't put it into any of the TopComponent
's
javax.swing.InputMap
. Otherwise the component would not pick up the changed shortcut from the
global context.
XXX no answer for arch-time
Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer:XXX no answer for arch-quality
Question (arch-where): Where one can find sources for your module? Answer:
The sources for the module are in NetBeans CVS in openide/actions directory.
NodeAction
.
NodeAction
uses TopComponent.Registry
.
PasteAction
uses ExplorerManager
.
FileSystemAction
uses FileSystem
.
FileSystemAction
uses DataObject
.
Default answer to this question is:
These modules are required in project.xml file:
openide.jar
.
Question (deploy-nbm):
Can you deploy an NBM via the Update Center?
Answer:
Whole openide can be deployed via AU center.
Question (deploy-shared):
Do you need to be installed in the shared location only, or in the user directory only,
or can your module be installed anywhere?
Answer:
openide.jar
needs to be in the system directory.
Question (deploy-packages):
Are packages of your module made inaccessible by not declaring them
public?
Answer:
No, ther are ActionsAPI.
Question (deploy-dependencies):
What do other modules need to do to declare a dependency on this one?
Answer:
XXX no answer for deploy-dependencies
org.openide.util.actions.SystemAction
, this
was recently changed that Actions supports javax.swing.Action
which
is java API standard, and Actions will be improving towards this more and more.
Question (compat-version):
Can your module coexist with earlier and future
versions of itself? Can you correctly read all old settings? Will future
versions be able to read your current settings? Can you read
or politely ignore settings stored by a future version?
Answer:
Yes up to now it is supposed to be compatible with older versions.
java.io.File
directly?
Answer:
No.
Question (resources-layer):
Does your module provide own layer? Does it create any files or
folders in it? What it is trying to communicate by that and with which
components?
Answer:
No in fact. Just concrete action implementation provided by this module
are typically used in xml layers.
Question (resources-read):
Does your module read any resources from layers? For what purpose?
Answer:
There are special folders containing actions in xml layers.
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
It uses Lookup
as a representation of context in which are certain action
types ContextAwareAction
s used. Current implementations
lookup in the context for javax.swing.ActionMap
or org.openide.nodes.Node
or org.openide.Node.Cookie
instances.
Question (lookup-register):
Do you register anything into lookup for other code to find?
Answer:
No. Actions are just clients of some lookups.
Question (lookup-remove):
Do you remove entries of other modules from lookup?
Answer:
No.
System.getProperty
) property?
Answer:
true
, changes default value of the
asynchronous()
method. Useful for unit tests
which would prefer to run all tested actions synchronously.
Action.getValue()
).
PasteAction
delegate action
which serves to pass an array of PasteType
or Action
to global instance (it is the only one
which actually performs paste operation).Boolean.TRUE
.
Influences the display of the action in the main menu, the item will have no icon there. Works for Actions that don't define custom MenuPresenter.
actionPeformed
method is passed ActionEvent
with command waitFinishedthe action shall be executed synchronously. The code:
action.actionPerformed (new ActionEvent (this, 0, "waitFinished"))shall be executed synchronously, even if the action by default runs asynchronously. All asynchronous actions are asked to obey this contract,
CallableSystemAction
does it by default. However this contract is defined as friend one
and may be abandoned in future.
CallableSystemAction
uses its getActionMapKey()
method
(usually overriden by subclasses) to get a key which is then searched in the
ActionMap
obtained from the action's context. Other modules can
register their own action then:
topComponent.getActionMap ().put (theKey, new YourOwnSwingAction ());Here is the list of special keys:
"cloneWindow"
- an action to be executed when a top component is to be cloned"closeWindow"
- an action when a view is about to be closedDefaultEditorKit.copyAction
- copy action handlerDefaultEditorKit.cutAction
- cut action handler"delete"
- delete action handlerDefaultEditorKit.pasteAction
- paste action handler"jumpNext"
- when a next element shall be selected"jumpPrev"
- when a previous element shall be selectedXXX no answer for exec-ant-tasks
Question (exec-classloader): Does your code create its own class loader(s)? Answer: No. Question (exec-reflection): Does your code use Java Reflection to execute other code? Answer: A bit indirectly.SystemAction.get (...)
calls to SharedClassObject.findObject
which calls constructor by reflection.
Question (exec-privateaccess):
Are you aware of any other parts of the system calling some of
your methods by reflection?
Answer:
No.
Question (exec-process):
Do you execute an external process from your module? How do you ensure
that the result is the same on different platforms? Do you parse output?
Do you depend on result code?
Answer:
XXX no answer for exec-process
Question (exec-introspection): Does your module use any kind of runtime type information (instanceof
,
work with java.lang.Class
, etc.)?
Answer:
XXX no answer for exec-introspection
Question (exec-threading): What threading models, if any, does your module adhere to? Answer:XXX no answer for exec-threading
Question (security-policy): Does your functionality require modifications to the standard policy file? Answer:XXX no answer for security-policy
Question (security-grant): Does your code grant additional rights to some other code? Answer:XXX no answer for security-grant
java.awt.datatransfer.Transferable
?
Answer:
Implementations of cut, copy and paste (CutAction
, CopyAction
and PasteAction
) reads/writes from/into clipboard. It uses standard
java datatransfer mechanism
and Netbeans extension to the mechanism.
SystemAction
.
Those kind of actions are singletons.
That older approach is getting away. There are already newer implementation
which creates short living action instances (context sensitive actions)
when invoking popup menu.
org.netbeans.core.ShortcutsEditor
.
Question (perf-menus):
Does your module use dynamically updated context menus, or
context-sensitive actions with complicated and slow enablement logic?
Answer:
Actions doesn't use menus, it is vice versa.
Question (perf-spi):
How the performance of the plugged in code will be enforced?
Answer:
XXX no answer for perf-spi
Built on March 26 2007. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.