本文整理汇总了Java中org.openide.awt.Actions.forID方法的典型用法代码示例。如果您正苦于以下问题:Java Actions.forID方法的具体用法?Java Actions.forID怎么用?Java Actions.forID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.awt.Actions
的用法示例。
在下文中一共展示了Actions.forID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActions
import org.openide.awt.Actions; //导入方法依赖的package包/类
@Override
public Action[] getActions(boolean context) {
if (!context) {
Action copyPath = Actions.forID("Edit", //NOI18N
"org.netbeans.modules.utilities.CopyPathToClipboard"); //NOI18N
return new Action[]{
SystemAction.get(OpenMatchingObjectsAction.class),
replacing && !matchingObject.isObjectValid()
? new RefreshAction(matchingObject) : null,
null,
copyPath == null ? new CopyPathAction() : copyPath,
SystemAction.get(HideResultAction.class),
null,
SystemAction.get(SelectInAction.class),
SystemAction.get(MoreAction.class)
};
} else {
return new Action[0];
}
}
示例2: getToolbarPresenter
import org.openide.awt.Actions; //导入方法依赖的package包/类
public Component getToolbarPresenter() {
if (toolbarPresenter == null) {
// gets the real action registered in the menu from layer
Action a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachMainProject"); // NOI18N
final Action attachProjectAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();
// gets the real action registered in the menu from layer
a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachAction"); // NOI18N
final Action attachProcessAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();
JPopupMenu dropdownPopup = new JPopupMenu();
dropdownPopup.add(createDropdownItem(defaultAction));
dropdownPopup.add(createDropdownItem(attachProjectAction));
dropdownPopup.addSeparator();
dropdownPopup.add(createDropdownItem(attachProcessAction));
JButton button = DropDownButtonFactory.createDropDownButton(new ImageIcon(
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), dropdownPopup);
Actions.connect(button, defaultAction);
toolbarPresenter = button;
}
return toolbarPresenter;
}
示例3: testMultiContextAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
public void testMultiContextAction() throws Exception {
ContextAwareAction a = (ContextAwareAction) Actions.forID("Tools", "on.numbers");
InstanceContent ic = new InstanceContent();
AbstractLookup lkp = new AbstractLookup(ic);
Action clone = a.createContextAwareInstance(lkp);
NumberLike ten = new NumberLike(10);
NumberLike three = new NumberLike(3);
ic.add(ten);
ic.add(three);
assertEquals("Number lover!", clone.getValue(Action.NAME));
clone.actionPerformed(new ActionEvent(this, 300, ""));
assertEquals("Global Action not called", 13, MultiContext.cnt);
ic.remove(ten);
clone.actionPerformed(new ActionEvent(this, 200, ""));
assertEquals("Adds 3", 16, MultiContext.cnt);
ic.remove(three);
assertFalse("It is disabled", clone.isEnabled());
clone.actionPerformed(new ActionEvent(this, 200, ""));
assertEquals("No change", 16, MultiContext.cnt);
}
示例4: testOpenActionIsAlwaysFirst
import org.openide.awt.Actions; //导入方法依赖的package包/类
public void testOpenActionIsAlwaysFirst() throws Exception {
Node n = obj.getNodeDelegate();
Action openAction = Actions.forID("System", "org.openide.actions.OpenAction");
assertEquals(
"Open action is the default one",
openAction,
n.getPreferredAction()
);
Action[] actions = n.getActions(false);
assertTrue("There are some actions", actions.length > 1);
assertEquals(
"First one is open",
openAction,
actions[0]
);
}
示例5: testCallbackAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
public void testCallbackAction() throws Exception {
Callback.cnt = 0;
ContextAwareAction a = (ContextAwareAction) Actions.forID("Tools", "my.action");
class MyAction extends AbstractAction {
int cnt;
@Override
public void actionPerformed(ActionEvent e) {
cnt += e.getID();
}
}
MyAction my = new MyAction();
ActionMap m = new ActionMap();
m.put("klic", my);
InstanceContent ic = new InstanceContent();
AbstractLookup lkp = new AbstractLookup(ic);
Action clone = a.createContextAwareInstance(lkp);
ic.add(m);
assertEquals("I am context", clone.getValue(Action.NAME));
clone.actionPerformed(new ActionEvent(this, 300, ""));
assertEquals("Local Action called", 300, my.cnt);
assertEquals("Global Action not called", 0, Callback.cnt);
ic.remove(m);
clone.actionPerformed(new ActionEvent(this, 200, ""));
assertEquals("Local Action stays", 300, my.cnt);
assertEquals("Global Action ncalled", 200, Callback.cnt);
}
示例6: testSurviveFocusChangeBehavior
import org.openide.awt.Actions; //导入方法依赖的package包/类
public void testSurviveFocusChangeBehavior() throws Exception {
class MyAction extends AbstractAction {
public int cntEnabled;
public int cntPerformed;
@Override
public boolean isEnabled() {
cntEnabled++;
return true;
}
@Override
public void actionPerformed(ActionEvent ev) {
cntPerformed++;
}
}
MyAction myAction = new MyAction();
ActionMap disable = new ActionMap();
ActionMap enable = new ActionMap();
InstanceContent ic = new InstanceContent();
AbstractLookup al = new AbstractLookup(ic);
ContextAwareAction temp = (ContextAwareAction) Actions.forID("Windows", "my.survival.action");
Action a = temp.createContextAwareInstance(al);
enable.put(SURVIVE_KEY, myAction);
ic.add(enable);
assertTrue("MyAction is enabled", a.isEnabled());
ic.set(Collections.singletonList(disable), null);
assertTrue("Remains enabled on other component", a.isEnabled());
ic.remove(disable);
}
示例7: setUp
import org.openide.awt.Actions; //导入方法依赖的package包/类
protected void setUp() throws Exception {
saveAction = (ContextAwareAction) Actions.forID("System", "org.openide.actions.SaveAction");
saveAllAction = Actions.forID("System", "org.openide.actions.SaveAllAction");
assertNotNull("Save action found", saveAction);
assertNotNull("Save All action found", saveAllAction);
assertEquals("Nothing in the registry", null, MySavable.REGISTRY.lookup(MySavable.class));
}
示例8: testAlwaysEnabledAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
@ActionReferences({
@ActionReference(
path="Loaders/text/x-my/Actions",
[email protected](category="System", id="org.openide.actions.OpenAction"),
position=100,
separatorAfter=200
)
})
public void testAlwaysEnabledAction() throws Exception {
assertEquals("Not created yet", 0, Always.created);
Action a = Actions.forID("Tools", "my.test.Always");
assertNotNull("action found", a);
assertEquals("Still not created", 0, Always.created);
assertEquals("I am always on!", a.getValue(Action.NAME));
assertEquals("Not even now created", 0, Always.created);
a.actionPerformed(new ActionEvent(this, 300, ""));
assertEquals("Created now!", 1, Always.created);
assertEquals("Action called", 300, Always.cnt);
FileObject shad = FileUtil.getConfigFile(
"My/Folder/D-F6.shadow"
);
assertNotNull("Shadow created", shad);
assertEquals("Right position", 333, shad.getAttribute("position"));
assertEquals("Proper link", "Actions/Tools/my-test-Always.instance", shad.getAttribute("originalFile"));
}
示例9: setUp
import org.openide.awt.Actions; //导入方法依赖的package包/类
@Override
protected void setUp () throws java.lang.Exception {
clearWorkDir ();
// initialize modules
Lookup.getDefault().lookup(ModuleInfo.class);
openAction = Actions.forID("System", "org.openide.actions.OpenAction");
}
示例10: performAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
private boolean performAction(String category, String id) {
Action a = Actions.forID(category, id);
if (a == null) {
return false;
}
ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "whatever"); // NOI18N
try {
a.actionPerformed(ae);
return true;
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
return false;
}
}
示例11: testMultipleUsageInEQ
import org.openide.awt.Actions; //导入方法依赖的package包/类
public void testMultipleUsageInEQ() throws Exception {
FileObject pukMuk = FileUtil.getConfigFile("Puk/Muk/multi-use.shadow");
assertNotNull("One reference found", pukMuk);
FileObject jukLuk = FileUtil.getConfigFile("Juk/Luk/multi-use.shadow");
assertNotNull("2nd reference found", jukLuk);
Action a = Actions.forID("Windows", "multi.use");
assertNotNull("Action created", a);
assertEquals("No call to withReferences factory yet", 0, TC.cnt2);
a.actionPerformed(new ActionEvent(this, 0, null));
assertEquals("One call to factory", 1, TC.cnt2);
}
示例12: setUp
import org.openide.awt.Actions; //导入方法依赖的package包/类
@Override
protected void setUp () throws java.lang.Exception {
clearWorkDir ();
Lookup.getDefault().lookup(ModuleInfo.class);
openAction = Actions.forID("System", "org.openide.actions.OpenAction");
}
示例13: getAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
/**
* Get action by id in "Window/SelectDocumentNode" category.
*/
private Action getAction(String name) {
return Actions.forID("Window/SelectDocumentNode", name); //NOI18N
}
示例14: getPatchAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
private Action getPatchAction () {
return Actions.forID("Tools", "org.netbeans.modules.diff.PatchAction"); //NOI18N
}
示例15: ProfilerToolbarDropdownAction
import org.openide.awt.Actions; //导入方法依赖的package包/类
public ProfilerToolbarDropdownAction() {
defaultAction = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.ProfileMainProject"); // NOI18N
}