本文整理匯總了Java中org.openide.nodes.Node.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.setName方法的具體用法?Java Node.setName怎麽用?Java Node.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.nodes.Node
的用法示例。
在下文中一共展示了Node.setName方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performAction
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
protected void performAction(Node[] nodes) {
if (nodes != null && nodes.length == 1) {
SaasGroup group = nodes[0].getLookup().lookup(SaasGroup.class);
if (group == null) {
return;
}
Node n = nodes[0];
NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine(
NbBundle.getMessage(RenameAction.class, "CTL_RenameLabel"), // NOI18N
NbBundle.getMessage(RenameAction.class, "CTL_RenameTitle")); // NOI18N
dlg.setInputText(n.getName());
if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) {
String name = dlg.getInputText().trim();
if (group.getParent().getChildGroup(name) != null) {
String msg = NbBundle.getMessage(RenameGroupAction.class, "MSG_DuplicateGroupName"); // NOI18N
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE));
return;
}
SaasServicesModel.getInstance().renameGroup(group, name);
n.setName(name);
}
}
}
示例2: testChangeOfNodeDoesNotFireChangeInActionMap
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testChangeOfNodeDoesNotFireChangeInActionMap() {
ActionMap am = (ActionMap)tc.getLookup().lookup(ActionMap.class);
assertNotNull(am);
Node m1 = new AbstractNode(Children.LEAF);
m1.setName("old m1");
Node m2 = new AbstractNode(Children.LEAF);
m2.setName("new m2");
tc.setActivatedNodes(new Node[] { m1 });
assertEquals("No change in ActionMap 1", 0, cnt);
tc.setActivatedNodes(new Node[] { m2 });
assertEquals("No change in ActionMap 2", 0, cnt);
tc.setActivatedNodes(new Node[0]);
assertEquals("No change in ActionMap 3", 0, cnt);
tc.setActivatedNodes(null);
assertEquals("No change in ActionMap 4", 0, cnt);
ActionMap am2 = (ActionMap)tc.getLookup().lookup(ActionMap.class);
assertEquals("Still the same action map", am, am2);
}
示例3: testCreateCompositeChildren
import org.openide.nodes.Node; //導入方法依賴的package包/類
/**
* Test of createCompositeChildren method, of class org.netbeans.spi.project.ui.support.NodeFactorySupport.
*/
public void testCreateCompositeChildren() throws InterruptedException, InvocationTargetException {
InstanceContent ic = new InstanceContent();
final Children dels = new TestDelegates(new AbstractLookup(ic));
final Node node1 = new AbstractNode(Children.LEAF);
final Node node2 = new AbstractNode(Children.LEAF);
final Node node3 = new AbstractNode(Children.LEAF);
final Node node4 = new AbstractNode(Children.LEAF);
node1.setName("node1");
node2.setName("node2");
node3.setName("node3");
node4.setName("node4");
NodeFactory fact1 = new TestNodeFactory(node1);
NodeFactory fact2 = new TestNodeFactory(node2);
NodeFactory fact3 = new TestNodeFactory(node3);
NodeFactory fact4 = new TestNodeFactory(node4);
List<NodeFactory> col = new ArrayList<NodeFactory>();
col.add(fact1);
col.add(fact2);
ic.set(col, null);
assertEquals(Arrays.asList(node1, node2), Arrays.asList(dels.getNodes(true)));
col.add(0, fact4);
col.add(fact3);
col.remove(fact2);
ic.set(col, null);
//#115995, caused by fix for #115128
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Node[] nds = dels.getNodes();
assertEquals(nds[0], node4);
assertEquals(nds[1], node1);
assertEquals(nds[2], node3);
}
});
}
示例4: nodeRename
import org.openide.nodes.Node; //導入方法依賴的package包/類
static void nodeRename(final Node n, final String newStr) {
// bugfix #21589 don't update name if there is not any change
if (n.getName().equals(newStr)) {
return;
}
if (EventQueue.isDispatchThread() && Boolean.TRUE.equals(n.getValue("slowRename"))) { // NOI18N
RP.post(new Runnable() {
@Override
public void run() {
nodeRename(n, newStr);
}
});
return;
}
try {
n.setName(newStr);
} catch (IllegalArgumentException exc) {
boolean needToAnnotate = Exceptions.findLocalizedMessage(exc) == null;
// annotate new localized message only if there is no localized message yet
if (needToAnnotate) {
String msg = NbBundle.getMessage(
TreeViewCellEditor.class, "RenameFailed", n.getName(), newStr
);
Exceptions.attachLocalizedMessage(exc, msg);
}
Exceptions.printStackTrace(exc);
}
}
示例5: testLeafNodeReallyNotDisplayed
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testLeafNodeReallyNotDisplayed() throws Throwable {
final AbstractNode root = new AbstractNode(new Children.Array());
root.setName("test root");
root.getChildren().add(new Node[] {
createLeaf("kuk"),
createLeaf("huk"),
});
class AWTTst implements Runnable {
public void run() {
Panel p = new Panel();
p.getExplorerManager().setRootContext(root);
ContextTreeView ctv = new ContextTreeView();
p.add(BorderLayout.CENTER, ctv);
JFrame f = new JFrame();
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
f.getContentPane().add(BorderLayout.CENTER, p);
f.setVisible(true);
final JTree tree = ctv.tree;
// wait a while till the frame is realized and ctv.addNotify called
Object r = tree.getModel().getRoot();
assertEquals("There is root", Visualizer.findVisualizer(root), r);
int cnt = tree.getModel().getChildCount(r);
if (cnt != 0) {
fail("Should be zero " + cnt + " but there was: " +
tree.getModel().getChild(r, 0) + " and " +
tree.getModel().getChild(r, 1)
);
}
assertEquals("No children as they are leaves", 0, cnt);
Node n = Visualizer.findNode(r);
n.setName("Try Rename!");
}
}
AWTTst awt = new AWTTst();
try {
SwingUtilities.invokeAndWait(awt);
} catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}
示例6: testRenameNormalNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testRenameNormalNode() {
Node n = new AbstractNode(Children.LEAF) {
@Override
public void setName(String s) {
assertTrue("In AWT", EventQueue.isDispatchThread());
super.setName(s);
}
};
n.setName("newName");
assertEquals("newName", n.getName());
}
示例7: testNameAndRenameWithADot
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testNameAndRenameWithADot() throws IOException {
FileObject fo = FileUtil.createMemoryFileSystem().getRoot().createFolder("name-with.dot");
DataFolder folder = DataFolder.findFolder(fo);
Node n = folder.getNodeDelegate();
assertEquals("Full name provided", "name-with.dot", n.getName());
n.setName("new-name.other");
assertEquals("New name set", "new-name.other", n.getName());
assertEquals("New name of dobj too", "new-name.other", folder.getName());
assertEquals("New name of fo too", "new-name.other", fo.getNameExt());
}
示例8: testDisplayName
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testDisplayName() throws Exception {
String res = "Settings/org-netbeans-modules-settings-convertors-testDisplayName.settings";
FileObject fo = FileUtil.getConfigFile(res);
assertNotNull(res, fo);
assertNull("name", fo.getAttribute("name"));
DataObject dobj = DataObject.find (fo);
Node n = dobj.getNodeDelegate();
assertNotNull(n);
assertEquals("I18N", n.getDisplayName());
// property sets have to be initialized otherwise the change name would be
// propagated to the node after some delay (~2s)
Object garbage = n.getPropertySets();
InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
assertNotNull (dobj + " does not contain instance cookie", ic);
FooSetting foo = (FooSetting) ic.instanceCreate();
String newName = "newName";
foo.setName(newName);
assertEquals(n.toString(), newName, n.getDisplayName());
newName = "newNameViaNode";
n.setName(newName);
assertEquals(n.toString(), newName, n.getDisplayName());
assertEquals(n.toString(), newName, foo.getName());
}
示例9: testStructureFullOfFormFiles
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testStructureFullOfFormFiles() throws Exception {
if ((
Utilities.getOperatingSystem() &
(Utilities.OS_SOLARIS | Utilities.OS_SUNOS)
) != 0) {
LOG.log(Level.CONFIG, "Giving up, this test fails too randomly on Solaris");
return;
}
Children ch = new Children.Array();
Node root = new AbstractNode(ch);
root.setName(getName());
ch.add(nodeWith("A", "-A", "-B", "B"));
ch.add(nodeWith("X", "Y", "Z"));
final Node first = ch.getNodes()[0];
LOG.log(Level.INFO, "Nodes are ready: {0}", root);
final ExplorerManager em = testWindow.getExplorerManager();
em.setRootContext(root);
LOG.info("setRootContext done");
em.setSelectedNodes(new Node[] { first });
LOG.log(Level.INFO, "setSelectedNodes to {0}", first);
LOG.log(Level.INFO, "Verify setSelectedNodes: {0}", Arrays.asList(em.getSelectedNodes()));
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
TreePath path = treeView.tree.getSelectionPath();
LOG.log(Level.INFO, "getSelectionPath {0}", path);
LOG.log(Level.INFO, "getSelectedNodes {0}", Arrays.toString(em.getSelectedNodes()));
assertNotNull("Something is selected", path);
Node node = Visualizer.findNode(path.getLastPathComponent());
assertEquals("It is the first node", first, node);
}
});
sendAction("expand");
sendAction("selectNext");
assertEquals("Explored context is N0", first, em.getExploredContext());
assertEquals("Selected node is A", 1, em.getSelectedNodes().length);
assertEquals("Selected node is A", "A", em.getSelectedNodes()[0].getName());
sendAction(enter);
Keys keys = (Keys)first.getChildren();
assertEquals("One invocation", 1, keys.actionPerformed);
assertFalse("No write access", keys.writeAccess);
assertFalse("No read access", keys.readAccess);
}
示例10: setUp
import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Create tree and a selection of nodes for test.
*/
@SuppressWarnings("deprecation")
@Override
protected void setUp () {
System.setProperty ("org.openide.util.Lookup", Lkp.class.getName());
// create tree:
// root +--- parent_one +--- one1
// |--- one2
// |--- parent_two +--- two1
// |--- leaf
final Children parents = new Children.Array ();
Node root = new AbstractNode (parents);
root.setName ("root");
tree = new BeanTreeView ();
//tree = new ContextTreeView ();
final org.openide.explorer.ExplorerPanel p = new org.openide.explorer.ExplorerPanel();
p.setName ("SelectionModeTest");
p.add (tree, BorderLayout.CENTER);
p.getExplorerManager ().setRootContext (root);
p.open ();
final Children ones = new Children.Array ();
Node parent_one = new AbstractNode (ones);
parent_one.setName ("parent_one");
final Children twos = new Children.Array ();
Node parent_two = new AbstractNode (twos);
parent_two.setName ("parent_two");
final Node one1 = new AbstractNode (Children.LEAF);
one1.setName("one1");
final Node one2 = new AbstractNode (Children.LEAF);
one2.setName("one2");
ones.add(new Node[] { one1, one2 });
final Node two1 = new AbstractNode (Children.LEAF);
two1.setName("two1");
twos.add (new Node[] { two1 });
parents.add (new Node[] { parent_one, parent_two });
// the test selections
singleSelection = new Node[] {parent_two};
contiguousSelection = new Node[] {one1, one2};
discontiguousSelection = new Node[] {one2, two1};
mgr = p.getExplorerManager();
}
示例11: testNodeAddingAndRemoving
import org.openide.nodes.Node; //導入方法依賴的package包/類
/**
* Creates two nodes. Selects one and tries to remove it
* and replace with the other one (several times).
*/
public void testNodeAddingAndRemoving() {
final Children c = new Array();
Node n = new AbstractNode (c);
final PListView lv = new PListView();
final ExplorerPanel p = new ExplorerPanel();
p.add(lv, BorderLayout.CENTER);
p.getExplorerManager().setRootContext(n);
p.open();
final Node c1 = new AbstractNode(Children.LEAF);
c1.setDisplayName("First");
c1.setName("First");
c.add(new Node[] { c1 });
Node c2 = new AbstractNode(Children.LEAF);
c2.setDisplayName("Second");
c2.setName("Second");
//Thread.sleep(500);
for (int i = 0; i < 5; i++) {
c.remove(new Node[] { c1 });
c.add(new Node[] { c2 });
// Waiting for until the view is updated.
// This should not be necessary
try {
SwingUtilities.invokeAndWait( new EmptyRunnable() );
} catch (InterruptedException ie) {
fail ("Caught InterruptedException:" + ie.getMessage ());
} catch (InvocationTargetException ite) {
fail ("Caught InvocationTargetException: " + ite.getMessage ());
}
try {
p.getExplorerManager().setSelectedNodes(new Node[] {c2} );
} catch (PropertyVetoException pve) {
fail ("Caught the PropertyVetoException when set selected node " + c2.getName ()+ ".");
}
c.remove(new Node[] { c2 });
c.add(new Node[] { c1 });
//Thread.sleep(350);
}
}
示例12: performAction
import org.openide.nodes.Node; //導入方法依賴的package包/類
protected void performAction(final Node[] activatedNodes) {
if (activatedNodes == null || activatedNodes.length == 0) {
return;
}
Node n = activatedNodes[0]; // we supposed that one node is activated
// for slow FS perform rename out of EDT
if (EventQueue.isDispatchThread() && Boolean.TRUE.equals(n.getValue("slowRename"))) { // NOI18N
RP.post(new Runnable() {
@Override
public void run() {
performAction(activatedNodes);
}
});
return;
}
NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine(
NbBundle.getMessage(RenameAction.class, "CTL_RenameLabel"),
NbBundle.getMessage(RenameAction.class, "CTL_RenameTitle")
);
dlg.setInputText(n.getName());
if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) {
String newname = null;
try {
newname = dlg.getInputText();
if (!newname.equals("")) {
n.setName(dlg.getInputText()); // NOI18N
}
} catch (IllegalArgumentException e) {
// determine if "printStackTrace" and "new annotation" of this exception is needed
boolean needToAnnotate = Exceptions.findLocalizedMessage(e) == null;
// annotate new localized message only if there is no localized message yet
if (needToAnnotate) {
Exceptions.attachLocalizedMessage(e,
NbBundle.getMessage(RenameAction.class,
"MSG_BadFormat",
n.getName(),
newname));
}
Exceptions.printStackTrace(e);
}
}
}