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 an Action", ((Action) obj).getValue(Action.NAME)); |
617 |
assertEquals("This is a Popup Action", item.getText()); |
618 |
} |
619 |
|
620 |
public void testMenuText() throws Exception { |
621 |
FileObject fo = FileUtil.getConfigFile("Actions/menutext/namedaction.instance"); |
622 |
assertNotNull("Instance found", fo); |
623 |
Object obj = fo.getAttribute("instanceCreate"); |
624 |
assertNotNull("Action created", obj); |
625 |
|
626 |
JMenuItem item = new JMenuItem(); |
627 |
Actions.connect(item, (Action) obj, false ); |
628 |
assertEquals("This is an Action", ((Action) obj).getValue(Action.NAME)); |
629 |
assertEquals("This is a Menu Action", item.getText()); |
630 |
} |
631 |
|
597 |
public void testDirectInstanceIfImplementsMenuPresenter() throws Exception { |
632 |
public void testDirectInstanceIfImplementsMenuPresenter() throws Exception { |
598 |
FileObject fo = FileUtil.getConfigFile("Actions/eager/direct-one.instance"); |
633 |
FileObject fo = FileUtil.getConfigFile("Actions/eager/direct-one.instance"); |
599 |
assertNotNull("Instance found", fo); |
634 |
assertNotNull("Instance found", fo); |