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 129313
Collapse All | Expand All

(-)a/openide.awt/apichanges.xml (+14 lines)
Lines 47-52 made subject to such option by the copyr Link Here
47
<apidef name="awt">AWT API</apidef>
47
<apidef name="awt">AWT API</apidef>
48
</apidefs>
48
</apidefs>
49
<changes>
49
<changes>
50
    <change id="Actions.MenuText">
51
        <api name="awt"/>
52
        <summary>Actions can have "menuText" and "popupText" properties</summary>
53
        <version major="7" minor="1"/>
54
        <date day="12" month="3" year="2008"/>
55
        <author login="jtulach"/>
56
        <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="yes" deletion="no" modification="no"/>
57
        <description>
58
        In order to allow dynamic names of actions, the <a href="@TOP@/org/openide/awt/Actions.html#connect(javax.swing.JMenuItem,%20javax.swing.Action,%20boolean)">Actions.connect</a>
59
        method now understands additional properties that influence the text 
60
        of menu items or popup menu items build for this action.
61
        </description>
62
        <class package="org.openide.awt" name="Actions"/>
63
    </change>
50
    <change id="SpinButton.RepeatThread">
64
    <change id="SpinButton.RepeatThread">
51
        <api name="awt"/>
65
        <api name="awt"/>
52
        <summary>Hidden field SpinButton.rt made accessible</summary>
66
        <summary>Hidden field SpinButton.rt made accessible</summary>
(-)a/openide.awt/arch.xml (-3 / +8 lines)
Lines 458-466 made subject to such option by the copyr Link Here
458
        </question>
458
        </question>
459
-->
459
-->
460
 <answer id="exec-component">
460
 <answer id="exec-component">
461
  <p>
461
  <ul>
462
   XXX no answer for exec-component
462
   <li>
463
  </p>
463
    <api name="menuText" category="stable" type="export" group="property" url="@TOP@/org/openide/awt/Actions.html#connect(javax.swing.JMenuItem,%20javax.swing.Action,%20boolean)"/>
464
   </li>
465
   <li>
466
    <api name="popupText" category="stable" type="export" group="property" url="@TOP@/org/openide/awt/Actions.html#connect(javax.swing.JMenuItem,%20javax.swing.Action,%20boolean)"/>
467
   </li>
468
  </ul>
464
 </answer>
469
 </answer>
465
470
466
471
(-)a/openide.awt/nbproject/project.properties (-1 / +1 lines)
Lines 46-49 javadoc.arch=${basedir}/arch.xml Link Here
46
#javadoc.apichanges=${basedir}/api/apichanges.xml
46
#javadoc.apichanges=${basedir}/api/apichanges.xml
47
javadoc.apichanges=${basedir}/apichanges.xml
47
javadoc.apichanges=${basedir}/apichanges.xml
48
48
49
spec.version.base=7.0.0
49
spec.version.base=7.1
(-)a/openide.awt/src/org/openide/awt/Actions.java (-2 / +19 lines)
Lines 168-174 public class Actions extends Object { Link Here
168
     * for this method by implementing method
168
     * for this method by implementing method
169
     * {@link ButtonActionConnector#connect(JMenuItem, Action, boolean)} and
169
     * {@link ButtonActionConnector#connect(JMenuItem, Action, boolean)} and
170
     * registering an instance of {@link ButtonActionConnector} in the
170
     * registering an instance of {@link ButtonActionConnector} in the
171
     * default lookup.
171
     * default lookup. 
172
     * <p>
173
     * Since version 7.1 the action can also provide properties
174
     * "menuText" and "popupText" if one wants to use other text on the JMenuItem
175
     * than the name
176
     * of the action taken from Action.NAME. The popupText is checked only if the
177
     * popup parameter is true and takes the biggest precedence. The menuText is
178
     * tested everytime and takes precedence over standard <code>Action.NAME</code>
179
     * 
172
     * @param item menu item
180
     * @param item menu item
173
     * @param action action
181
     * @param action action
174
     * @param popup create popup or menu item
182
     * @param popup create popup or menu item
Lines 908-914 public class Actions extends Object { Link Here
908
            }
916
            }
909
917
910
            if ((changedProperty == null) || changedProperty.equals(Action.NAME)) {
918
            if ((changedProperty == null) || changedProperty.equals(Action.NAME)) {
911
                Object s = action.getValue(Action.NAME);
919
                Object s = null;
920
                if (popup) {
921
                    s = action.getValue("popupText"); // NOI18N
922
                }
923
                if (s == null) {
924
                    s = action.getValue("menuText"); // NOI18N
925
                }
926
                if (s == null) {
927
                    s = action.getValue(Action.NAME);
928
                }
912
929
913
                if (s instanceof String) {
930
                if (s instanceof String) {
914
                    setMenuText(((JMenuItem) comp), (String) s, true);
931
                    setMenuText(((JMenuItem) comp), (String) s, true);
(-)a/openide.awt/test/unit/src/org/openide/awt/ActionsTest.java (+63 lines)
Lines 55-60 import javax.swing.Icon; Link Here
55
import javax.swing.Icon;
55
import javax.swing.Icon;
56
import javax.swing.JButton;
56
import javax.swing.JButton;
57
import javax.swing.JFrame;
57
import javax.swing.JFrame;
58
import javax.swing.JMenu;
58
import javax.swing.JMenuItem;
59
import javax.swing.JMenuItem;
59
import javax.swing.KeyStroke;
60
import javax.swing.KeyStroke;
60
import javax.swing.text.Keymap;
61
import javax.swing.text.Keymap;
Lines 372-377 public class ActionsTest extends NbTestC Link Here
372
        assertEquals(3, tc.getConnectCalled());
373
        assertEquals(3, tc.getConnectCalled());
373
        tc.setActive(false);
374
        tc.setActive(false);
374
    }
375
    }
376
377
    @SuppressWarnings("deprecation")
378
    private static Object peer(Component menu) {
379
        return menu.getPeer();
380
    }
381
    
382
    public void testPopupTextIsTaken() throws Exception {
383
        Action action = new ActionsTest.TestAction();
384
        JMenuItem item = new JMenuItem();
385
        JMenu jmenu = new JMenu();
386
        jmenu.addNotify();
387
        assertNotNull("Peer created", peer(jmenu));
388
        jmenu.getPopupMenu().addNotify();
389
        assertNotNull("Peer for popup", peer(jmenu.getPopupMenu()));
390
391
        action.putValue("popupText", "&Ahoj");
392
        action.putValue("menuText", "&Ble");
393
        action.putValue(action.NAME, "&Mle");
394
        
395
        Actions.connect(item, action, true);
396
        
397
        assertEquals('A', item.getMnemonic());
398
        assertEquals("Ahoj", item.getText());
399
    }
400
401
    public void testMenuTextIsTaken() throws Exception {
402
        Action action = new ActionsTest.TestAction();
403
        JMenuItem item = new JMenuItem();
404
        JMenu jmenu = new JMenu();
405
        jmenu.addNotify();
406
        assertNotNull("Peer created", peer(jmenu));
407
        jmenu.getPopupMenu().addNotify();
408
        assertNotNull("Peer for popup", peer(jmenu.getPopupMenu()));
409
410
        //action.putValue("popupText", "&Ahoj");
411
        action.putValue("menuText", "&Ble");
412
        action.putValue(action.NAME, "&Mle");
413
        
414
        Actions.connect(item, action, true);
415
        
416
        assertEquals('B', item.getMnemonic());
417
        assertEquals("Ble", item.getText());
418
    }
419
    
420
    public void testActionNameIsTaken() throws Exception {
421
        Action action = new ActionsTest.TestAction();
422
        JMenuItem item = new JMenuItem();
423
        JMenu jmenu = new JMenu();
424
        jmenu.addNotify();
425
        assertNotNull("Peer created", peer(jmenu));
426
        jmenu.getPopupMenu().addNotify();
427
        assertNotNull("Peer for popup", peer(jmenu.getPopupMenu()));
428
429
        //action.putValue("popupText", "&Ahoj");
430
        //action.putValue("menuText", "&Ble");
431
        action.putValue(action.NAME, "&Mle");
432
        
433
        Actions.connect(item, action, true);
434
        
435
        assertEquals('M', item.getMnemonic());
436
        assertEquals("Mle", item.getText());
437
    }
375
    
438
    
376
    
439
    
377
    protected boolean runInEQ() {
440
    protected boolean runInEQ() {

Return to bug 129313