This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 197789
Collapse All | Expand All

(-)openide.awt/apichanges.xml (+15 lines)
Lines 50-55 Link Here
50
<apidef name="awt">AWT API</apidef>
50
<apidef name="awt">AWT API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
    <change id="ActionRegistration.menuOrPopupText">
54
        <api name="awt"/>
55
        <summary>New attributes (popupText, menuText) in @ActionRegistration annotation</summary>
56
        <version major="7" minor="29"/>
57
        <date day="7" month="4" year="2011"/>
58
        <author login="tstupka"/>
59
        <compatibility addition="yes" binary="compatible" deletion="no" semantic="compatible"/>
60
        <description>
61
            <p>
62
                New annotation to register references to actions from layer.
63
            </p>
64
        </description>
65
        <class package="org.openide.awt" name="ActionRegistration"/>
66
        <issue number="197789"/>
67
    </change>
53
    <change id="ActionReference">
68
    <change id="ActionReference">
54
        <api name="awt"/>
69
        <api name="awt"/>
55
        <summary>New @ActionReference annotations</summary>
70
        <summary>New @ActionReference annotations</summary>
(-)openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java (+10 lines)
Lines 191-196 Link Here
191
            File f = layer(e).file("Actions/" + aid.category() + "/" + id + ".instance");
191
            File f = layer(e).file("Actions/" + aid.category() + "/" + id + ".instance");
192
            f.bundlevalue("displayName", ar.displayName());
192
            f.bundlevalue("displayName", ar.displayName());
193
            
193
            
194
            String menuText = ar.menuText();
195
            if(!menuText.isEmpty()) {
196
                f.bundlevalue("menuText", menuText);
197
            }
198
199
            String popupText = ar.popupText();
200
            if (!popupText.isEmpty()) {
201
                f.bundlevalue("popupText", popupText);
202
            }
203
            
194
            String key;
204
            String key;
195
            boolean createDelegate = true;
205
            boolean createDelegate = true;
196
            if (e.getKind() == ElementKind.FIELD) {
206
            if (e.getKind() == ElementKind.FIELD) {
(-)openide.awt/src/org/openide/awt/ActionRegistration.java (+24 lines)
Lines 65-70 Link Here
65
     * @return display name for the action
65
     * @return display name for the action
66
     */
66
     */
67
    String displayName();
67
    String displayName();
68
    
69
    /** 
70
     * Provides the text if one wants to use other text in a JMenuItem than 
71
     * the name of the action taken from Action.NAME. Takes precedence 
72
     * over standard Action.NAME.
73
     * 
74
     * @return display name for the action
75
     * 
76
     * @see Actions#connect(javax.swing.JMenuItem, javax.swing.Action, boolean) 
77
     * @since 7.29
78
     */    
79
    String menuText() default "";
80
    
81
    /** 
82
     * Provides the text if one wants to use other text in a JMenuItem popup 
83
     * than the name of the action taken from Action.NAME. 
84
     * 
85
     * @return display name for the action in a popup menu
86
     * 
87
     * @see Actions#connect(javax.swing.JMenuItem, javax.swing.Action, boolean) 
88
     * @since 7.29
89
     */
90
    String popupText() default "";
91
    
68
    /** Path to image representing the action's icon.
92
    /** Path to image representing the action's icon.
69
     * @return "org/myproject/mypkg/Icon.png"
93
     * @return "org/myproject/mypkg/Icon.png"
70
     */
94
     */
(-)openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java (+33 lines)
Lines 58-68 Link Here
58
import javax.swing.AbstractAction;
58
import javax.swing.AbstractAction;
59
import javax.swing.Action;
59
import javax.swing.Action;
60
import javax.swing.ActionMap;
60
import javax.swing.ActionMap;
61
import javax.swing.JButton;
61
import javax.swing.JSeparator;
62
import javax.swing.JSeparator;
62
import org.netbeans.junit.NbTestCase;
63
import org.netbeans.junit.NbTestCase;
63
import org.openide.awt.ActionReference;
64
import org.openide.awt.ActionReference;
64
import org.openide.awt.ActionReferences;
65
import org.openide.awt.ActionReferences;
65
import org.openide.awt.ActionRegistration;
66
import org.openide.awt.ActionRegistration;
67
import org.openide.awt.Actions;
66
import org.openide.awt.DynamicMenuContent;
68
import org.openide.awt.DynamicMenuContent;
67
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileUtil;
70
import org.openide.filesystems.FileUtil;
Lines 594-599 Link Here
594
            return null;
596
            return null;
595
        }
597
        }
596
    }
598
    }
599
    
600
    @ActionID(category="menutext", id="namedaction")
601
    @ActionRegistration(displayName="This is an Action", menuText="This is a Menu Action", popupText="This is a Popup Action")
602
    public static class NamedAction extends AbstractAction {
603
        public NamedAction() { }
604
        @Override
605
        public void actionPerformed(ActionEvent e) { }
606
    }
607
608
    public void testPopupText() throws Exception {
609
        FileObject fo = FileUtil.getConfigFile("Actions/menutext/namedaction.instance");
610
        assertNotNull("Instance found", fo);
611
        Object obj = fo.getAttribute("instanceCreate");
612
        assertNotNull("Action created", obj);
613
        
614
        JMenuItem item = new JMenuItem();
615
        Actions.connect(item, (Action) obj, true );
616
        assertEquals( "This is a Popup Action", item.getText() );
617
    }
618
    
619
    public void testMenuText() throws Exception {
620
        FileObject fo = FileUtil.getConfigFile("Actions/menutext/namedaction.instance");
621
        assertNotNull("Instance found", fo);
622
        Object obj = fo.getAttribute("instanceCreate");
623
        assertNotNull("Action created", obj);
624
        
625
        JMenuItem item = new JMenuItem();
626
        Actions.connect(item, (Action) obj, false );
627
        assertEquals( "This is a Menu Action", item.getText() );
628
    }
629
    
597
    public void testDirectInstanceIfImplementsMenuPresenter() throws Exception {
630
    public void testDirectInstanceIfImplementsMenuPresenter() throws Exception {
598
        FileObject fo = FileUtil.getConfigFile("Actions/eager/direct-one.instance");
631
        FileObject fo = FileUtil.getConfigFile("Actions/eager/direct-one.instance");
599
        assertNotNull("Instance found", fo);
632
        assertNotNull("Instance found", fo);

Return to bug 197789