DevFaqActionsFolder

(Difference between revisions)
(What is the Actions folder in the system filesystem, and why should I use it?)
 
(3 intermediate revisions not shown)
Line 1: Line 1:
-
__NOTOC__
 
__NOTOC__
__NOTOC__
===What is the Actions folder in the system filesystem, and why should I use it?===
===What is the Actions folder in the system filesystem, and why should I use it?===
-
You may have noticed that the examples of adding actions typically look like this:
+
When you use @ActionRegistration the META-INF/generated-layer.xml may contain:
-
<pre>
+
<source lang="xml">
<folder name="Actions">
<folder name="Actions">
   <folder name="Build">
   <folder name="Build">
Line 18: Line 17:
   </folder>
   </folder>
</folder>
</folder>
-
</pre>
+
</source>
And you may have noticed that actions are usually put, not directly into the <tt>Menu/</tt> folders, but into subfolders of this <tt>Actions/</tt> folder.  Then we create [[DevFaqDotShadowFiles| .shadow files ]] that act like symbolic links, pointing to the real [[DevFaqInstanceDataObject| .instance file ]].  Why all this indirection?
And you may have noticed that actions are usually put, not directly into the <tt>Menu/</tt> folders, but into subfolders of this <tt>Actions/</tt> folder.  Then we create [[DevFaqDotShadowFiles| .shadow files ]] that act like symbolic links, pointing to the real [[DevFaqInstanceDataObject| .instance file ]].  Why all this indirection?
Line 36: Line 35:
----
----
-
Applies to: NetBeans 6.7
+
Applies to: NetBeans 6.7 and above

Current revision as of 00:09, 14 December 2011

What is the Actions folder in the system filesystem, and why should I use it?

When you use @ActionRegistration the META-INF/generated-layer.xml may contain:

<folder name="Actions">
   <folder name="Build">
     <file name="com-foo-SomeAction.instance"/>
   </folder>
</folder>
<folder name="Menu">
   <folder name="Build">
     <file name="pointerToComFooSomeAction.shadow">
        <attr name="originalFile" stringvalue="Actions/Build/com-foo-SomeAction.instance"/>
     </file>
   </folder>
</folder>

And you may have noticed that actions are usually put, not directly into the Menu/ folders, but into subfolders of this Actions/ folder. Then we create .shadow files that act like symbolic links, pointing to the real .instance file . Why all this indirection?

Older versions of the NetBeans UI included the ability to rearrange, and even delete, whole menus or individual menu items, and future ones may again. (Many applications built on NetBeans will not want to expose such customizability, but some do.) The current UI does include a key binding editor; the Actions/ folder can be used from this editor to list available actions, even those which are not currently bound to any keystroke.

Additionally, for actions which are javax.swing.Action but not SystemAction, creating the action instance in only a single place ensures that it acts as a singleton. (While the action class likely has no declared instance fields, it does have some state, notably information about keyboard accelerators which should be displayed in menu presenters.)


Applies to: NetBeans 6.7 and above

Not logged in. Log in, Register

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