# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /data/work/src/netbeans-annotations
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: openide.awt/apichanges.xml
--- openide.awt/apichanges.xml Base (BASE)
+++ openide.awt/apichanges.xml Locally Modified (Based On LOCAL)
@@ -50,6 +50,21 @@
AWT API
+
New @ActionReference annotations
Index: openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java
--- openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java Base (BASE)
+++ openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java Locally Modified (Based On LOCAL)
@@ -191,6 +191,16 @@
File f = layer(e).file("Actions/" + aid.category() + "/" + id + ".instance");
f.bundlevalue("displayName", ar.displayName());
+ String menuText = ar.menuText();
+ if(!menuText.isEmpty()) {
+ f.bundlevalue("menuText", menuText);
+ }
+
+ String popupText = ar.popupText();
+ if (!popupText.isEmpty()) {
+ f.bundlevalue("popupText", popupText);
+ }
+
String key;
boolean createDelegate = true;
if (e.getKind() == ElementKind.FIELD) {
Index: openide.awt/src/org/openide/awt/ActionRegistration.java
--- openide.awt/src/org/openide/awt/ActionRegistration.java Base (BASE)
+++ openide.awt/src/org/openide/awt/ActionRegistration.java Locally Modified (Based On LOCAL)
@@ -65,6 +65,30 @@
* @return display name for the action
*/
String displayName();
+
+ /**
+ * Provides the text if one wants to use other text in a JMenuItem than
+ * the name of the action taken from Action.NAME. Takes precedence
+ * over standard Action.NAME.
+ *
+ * @return display name for the action
+ *
+ * @see Actions#connect(javax.swing.JMenuItem, javax.swing.Action, boolean)
+ * @since 7.29
+ */
+ String menuText() default "";
+
+ /**
+ * Provides the text if one wants to use other text in a JMenuItem popup
+ * than the name of the action taken from Action.NAME.
+ *
+ * @return display name for the action in a popup menu
+ *
+ * @see Actions#connect(javax.swing.JMenuItem, javax.swing.Action, boolean)
+ * @since 7.29
+ */
+ String popupText() default "";
+
/** Path to image representing the action's icon.
* @return "org/myproject/mypkg/Icon.png"
*/
Index: openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java
--- openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java Base (BASE)
+++ openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java Locally Modified (Based On LOCAL)
@@ -58,11 +58,13 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
+import javax.swing.JButton;
import javax.swing.JSeparator;
import org.netbeans.junit.NbTestCase;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
+import org.openide.awt.Actions;
import org.openide.awt.DynamicMenuContent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -594,6 +596,37 @@
return null;
}
}
+
+ @ActionID(category="menutext", id="namedaction")
+ @ActionRegistration(displayName="This is an Action", menuText="This is a Menu Action", popupText="This is a Popup Action")
+ public static class NamedAction extends AbstractAction {
+ public NamedAction() { }
+ @Override
+ public void actionPerformed(ActionEvent e) { }
+ }
+
+ public void testPopupText() throws Exception {
+ FileObject fo = FileUtil.getConfigFile("Actions/menutext/namedaction.instance");
+ assertNotNull("Instance found", fo);
+ Object obj = fo.getAttribute("instanceCreate");
+ assertNotNull("Action created", obj);
+
+ JMenuItem item = new JMenuItem();
+ Actions.connect(item, (Action) obj, true );
+ assertEquals( "This is a Popup Action", item.getText() );
+ }
+
+ public void testMenuText() throws Exception {
+ FileObject fo = FileUtil.getConfigFile("Actions/menutext/namedaction.instance");
+ assertNotNull("Instance found", fo);
+ Object obj = fo.getAttribute("instanceCreate");
+ assertNotNull("Action created", obj);
+
+ JMenuItem item = new JMenuItem();
+ Actions.connect(item, (Action) obj, false );
+ assertEquals( "This is a Menu Action", item.getText() );
+ }
+
public void testDirectInstanceIfImplementsMenuPresenter() throws Exception {
FileObject fo = FileUtil.getConfigFile("Actions/eager/direct-one.instance");
assertNotNull("Instance found", fo);