本文整理匯總了Java中org.openide.nodes.Node.getActions方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getActions方法的具體用法?Java Node.getActions怎麽用?Java Node.getActions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.nodes.Node
的用法示例。
在下文中一共展示了Node.getActions方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testActions
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testActions() throws Exception{
assertNotNull("have the Libraries node", libsNode);
//test removedep action
addTestDependency(p);
String depName = p.getModuleList().getEntry(DEP_CNB).getCodeNameBase();
forceChildrenUpdate(libsNode);
Node depNode = libsNode.getChildren().findChild(depName);
assertNotNull("have a node with dependency", depNode);
Action[] act = depNode.getActions(false);
assertEquals("have three actions", 3, act.length);
RemoveDependencyAction removeAct = (RemoveDependencyAction) act[2];
assertEquals("nc+1 nodes now", nc+1, libsNode.getChildren().getNodes().length);
removeAct.performAction(new Node[] {depNode});
forceChildrenUpdate(libsNode);
assertEquals("nc nodes now, dep removed", nc, libsNode.getChildren().getNodes().length);
}
示例2: testOpenActionIsAlwaysFirst
import org.openide.nodes.Node; //導入方法依賴的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]
);
}
示例3: checkNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
private void checkNode (Node n, String name, RequestProcessor rp) {
// init
//assertEquals (null, n.getShortDescription ());
Node[] ns = n.getChildren ().getNodes ();
waitFinished (rp);
ns = n.getChildren ().getNodes ();
if (name.length () < 4) {
assertEquals (name, 3, ns.length);
checkNode (ns [0], name + "a", rp);
checkNode (ns [1], name + "b", rp);
checkNode (ns [2], name + "c", rp);
} else
assertEquals (ns.length, 0);
if (name.length () > 0) {
//assertEquals (name, n.getName ());
n.getDisplayName ();
String sd = n.getShortDescription ();
n.getActions (false);
waitFinished (rp);
assertEquals (name, n.getDisplayName ());
assertEquals (name + "WWW", sd);
assertEquals (1, n.getActions (false).length);
}
}
示例4: testAddingSeparators
import org.openide.nodes.Node; //導入方法依賴的package包/類
/**
* This test checks whether the JSeparator added from the configuration
* file is reflected in the resulting popup.
* The tests performs following steps:
* <OL><LI> Create an instance of ExtensibleNode with folder set to "test"
* <LI> No actions should be returned by getActions since the "test" folder
* is not there
* <LI> Create two actions in the testing folder separated by JSeparator
* <LI> getActions should return 3 elements - null element for the separator
* <LI> Popup is created from the actions array - the null element
* should be replaced by a JSeparator again
* </OL>
*/
public void testAddingSeparators() throws Exception {
Node en1 = node;
assertEquals("No actions at the start", 0, en1.getActions(false).length);
FileObject test = root;
FileObject a1 = test.createData("1[org-openide-actions-PropertiesAction].instance");
FileObject sep = test.createData("2[javax-swing-JSeparator].instance");
FileObject a2 = test.createData("3[org-openide-actions-CutAction].instance");
Action[] actions = en1.getActions(false);
assertEquals("Actions array should contain 3 elements: "+Arrays.asList(actions), 3, actions.length);
assertNull("separator should create null element in the array", actions[1]);
javax.swing.JPopupMenu jp = Utilities.actionsToPopup(actions, Lookups.singleton(en1));
assertEquals("Popup should contain 3 components", 3, jp.getComponentCount());
assertTrue("Separator should be second", jp.getComponent(1) instanceof JSeparator);
}
示例5: inspectNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
private void inspectNode(Node n) {
n.getDisplayName();
n.getHtmlDisplayName();
n.getShortDescription();
n.getIcon(BeanInfo.ICON_COLOR_16x16);
n.canCopy();
n.canCut();
n.canRename();
n.getNewTypes();
n.getActions(true);
n.getPreferredAction();
inspectProperties(n);
}
示例6: testFactoryInstanceRegistrationWorksAsWell
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testFactoryInstanceRegistrationWorksAsWell() throws Exception {
URL u = DataLoaderInLayerTest.class.getResource("/org/openide/loaders/saveAll.gif");
Image img = Toolkit.getDefaultToolkit().createImage(u);
DataObject.Factory f = DataLoaderPool.factory(SimpleDataObject.class, "text/simplefactory", img);
addRemove("text/plain", f, true);
try {
FileSystem lfs = createFS("folderFKK/file.simple");
FileObject fo = lfs.findResource("folderFKK");
DataFolder df = DataFolder.findFolder(fo);
DataObject[] arr = df.getChildren();
assertEquals("One object: " + Arrays.toString(arr), 1, arr.length);
DataObject dob = arr[0];
assertEquals(SimpleDataObject.class, dob.getClass());
FileObject root = FileUtil.getConfigRoot();
FileObject edit = FileUtil.createData(root, "/Loaders/text/simplefactory/Actions/org-openide-actions-EditAction.instance");
Node node = dob.getNodeDelegate();
Action[] actions = node.getActions(true);
assertEquals("One action is present: " + Arrays.asList(actions), 1, actions.length);
assertEquals("It is the edit one", EditAction.class, actions[0].getClass());
assertSame("Icon is propagated for open", img, node.getOpenedIcon(0));
assertSame("Icon is propagated", img, node.getIcon(0));
Reference<DataFolder> ref = new WeakReference<DataFolder>(df);
df = null;
assertGC("Folder can go away", ref);
df = DataFolder.findFolder(fo);
arr = df.getChildren();
assertEquals("One object", 1, arr.length);
assertEquals("Object is the same", dob, arr[0]);
DataObject copied = dob.copy(df);
assertEquals(SimpleDataObject.class, copied.getClass());
DataObject templ = dob.createFromTemplate(df, "ahoj");
assertEquals(SimpleDataObject.class, templ.getClass());
assertEquals("ahoj", templ.getName());
DataObject ren = dob.copyRename(df, "kuk", "simple");
assertEquals(SimpleDataObject.class, ren.getClass());
assertEquals("kuk", ren.getName());
} finally {
addRemove("text/plain", f, false);
}
}
示例7: testFactoryInstanceRegistrationWorksAsWellNowFromLayer
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testFactoryInstanceRegistrationWorksAsWellNowFromLayer() throws Exception {
URL u = DataLoaderInLayerTest.class.getResource("/org/openide/loaders/saveAll.gif");
FileObject root = FileUtil.getConfigRoot();
FileObject instance = FileUtil.createData(root, "TestLoaders/text/L.instance");
instance.setAttribute("dataObjectClass", SimpleDataObject.class.getName());
instance.setAttribute("mimeType", "text/simplefactory");
instance.setAttribute("SystemFileSystem.icon", u);
Image img = ImageUtilities.loadImage("org/openide/loaders/saveAll.gif");
DataObject.Factory f = DataLoaderPool.factory(instance);
addRemove("text/plain", f, true);
try {
FileSystem lfs = createFS("folderQ/file.simple");
FileObject fo = lfs.findResource("folderQ");
DataFolder df = DataFolder.findFolder(fo);
DataObject[] arr = df.getChildren();
assertEquals("One object", 1, arr.length);
DataObject dob = arr[0];
assertEquals(SimpleDataObject.class, dob.getClass());
FileObject edit = FileUtil.createData(root, "/Loaders/text/simplefactory/Actions/org-openide-actions-EditAction.instance");
Node node = dob.getNodeDelegate();
Action[] actions = node.getActions(true);
assertEquals("One action is present: " + Arrays.asList(actions), 1, actions.length);
assertEquals("It is the edit one", EditAction.class, actions[0].getClass());
assertImage("Icon is propagated for open", img, node.getOpenedIcon(0));
assertImage("Icon is propagated", img, node.getIcon(0));
Reference<DataFolder> ref = new WeakReference<DataFolder>(df);
df = null;
assertGC("Folder can go away", ref);
df = DataFolder.findFolder(fo);
arr = df.getChildren();
assertEquals("One object", 1, arr.length);
assertEquals("Object is the same", dob, arr[0]);
} finally {
addRemove("text/plain", f, false);
}
}