當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.addNodeListener方法代碼示例

本文整理匯總了Java中org.openide.nodes.Node.addNodeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.addNodeListener方法的具體用法?Java Node.addNodeListener怎麽用?Java Node.addNodeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.nodes.Node的用法示例。


在下文中一共展示了Node.addNodeListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MatchingObjectNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
private MatchingObjectNode(Node original,
        org.openide.nodes.Children children,
        final MatchingObject matchingObject,
        ReplaceCheckableNode checkableNode) {
    super(children, createLookup(matchingObject, checkableNode));
    replacing = checkableNode.isCheckable();
    Parameters.notNull("original", original);                       //NOI18N
    this.matchingObject = matchingObject;
    if (matchingObject.isObjectValid()) {
        this.original = original;
        setValidOriginal();
        origNodeListener = new OrigNodeListener();
        original.addNodeListener(origNodeListener);
    } else {
        setInvalidOriginal();
    }
    validityListener = new ValidityListener(matchingObject);
    matchingObject.addPropertyChangeListener(
            MatchingObject.PROP_INVALIDITY_STATUS,
            validityListener);
    selectionListener = new SelectionListener();
    matchingObject.addPropertyChangeListener(selectionListener);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:MatchingObjectNode.java

示例2: testNameAndDisplayName

import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testNameAndDisplayName() throws Exception {
    SuiteProject p = generateSuite("Sweet Stuff");
    Node n = p.getLookup().lookup(LogicalViewProvider.class).createLogicalView();
    assertEquals("Sweet Stuff", n.getName());
    assertEquals("Sweet Stuff", n.getDisplayName());
    NL nl = new NL();
    n.addNodeListener(nl);
    EditableProperties ep = p.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    ep.setProperty("app.name", "sweetness");
    ep.setProperty("app.title", "Sweetness is Now!");
    p.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
    TestBase.waitForNodesUpdate();
    assertEquals(new HashSet<String>(Arrays.asList(Node.PROP_NAME, Node.PROP_DISPLAY_NAME)), nl.changed);
    assertEquals("Sweetness is Now!", n.getName());
    assertEquals("Sweetness is Now!", n.getDisplayName());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:SuiteLogicalViewTest.java

示例3: getValueFor

import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Object getValueFor(Object node, int column) {
    Node n = Visualizer.findNode(node);
    if (n == null) {
        throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + node + " of class " + node.getClass().getName());
    }
    PropertyChangeListener cacheEntry = nodesListenersCache.get (n);
    if (cacheEntry == null) {
        PropertyChangeListener p = WeakListeners.propertyChange(pcl, n);
        nodesListenersCache.put(n, p);
        n.addPropertyChangeListener(p);
        NodeListener l = WeakListeners.create(NodeListener.class, nl, n);
        n.addNodeListener(l);
    }
    Node.Property theRealProperty = getPropertyFor(n, prop[column]);
    return theRealProperty;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:PropertiesRowModel.java

示例4: attach

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Attach to a node, detaching from the last one if non-null.  */
public void attach(Node n) {
    if (currNode != n) {
        if (currNode != null) {
            detach();
        }

        if (n != null) {
            n.addPropertyChangeListener(inner);
            n.addNodeListener(this);

            if (PropUtils.isLoggable(PropertySheet.class)) {
                PropUtils.log(PropertySheet.class, "Now listening for changes on " + n);
            }
        }

        currNode = n;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:PropertySheet.java

示例5: ShortcutAction

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Create a new presenter.
 * @param obj XML file describing it
 */
public ShortcutAction(DataObject obj, String helpID, boolean showmaster) {
    this.obj = obj;
    this.helpID = helpID;
    this.showmaster = showmaster;
    putValue("noIconInMenu", true); // NOI18N
    Installer.log.log(Level.FINE, "new ShortcutAction: {0} {1} showmaster={2}", new Object[] {obj, helpID, showmaster});
    updateText();
    updateIcon();
    updateEnabled();
    if (obj.isValid()) {
        Node n = obj.getNodeDelegate();
        n.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (this, n));
    }
    Help h = findHelp();
    if (h != null) {
        h.addChangeListener(WeakListeners.change(this, h));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:HelpCtxProcessor.java

示例6: registerNodeListener

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void registerNodeListener() {
    if (formDataObject.isValid()) {
        Node node = formDataObject.getNodeDelegate();
        multiviewTC.setIcon(node.getIcon(BeanInfo.ICON_COLOR_16x16));
        if (nodeListener == null) {
            NodeListener listener = new NodeAdapter() {
                @Override
                public void propertyChange(final PropertyChangeEvent ev) {
                    Mutex.EVENT.writeAccess(new Runnable() {
                        @Override
                        public void run() {
                            if (Node.PROP_ICON.equals(ev.getPropertyName())) {
                                if (formDataObject.isValid() && (multiviewTC != null)) {
                                    multiviewTC.setIcon(formDataObject.getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16));
                                }
                            }
                        }
                    });
                }
            };
            node.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener(listener, node));
            nodeListener = listener;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:FormEditorSupport.java

示例7: addChildAdditionListener

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void addChildAdditionListener(Node addedNode) {
    for (Node n : addedNode.getChildren().getNodes(true)) {
        addChildAdditionListener(n);
    }
    addedNode.addNodeListener(resultsNodeAdditionListener);

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:BasicAbstractResultsPanel.java

示例8: testBehaviourOfProjectsLogicNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testBehaviourOfProjectsLogicNode() throws Exception {
    
    Node logicalView = new ProjectsRootNode(ProjectsRootNode.LOGICAL_VIEW);
    L listener = new L();
    logicalView.addNodeListener(listener);
    
    assertEquals("2 children", 2, logicalView.getChildren().getNodesCount());
    listener.assertEvents("None", 0);
    assertEquals("No project opened yet", 0, TestProjectOpenedHookImpl.opened);
    
    for (Node n : logicalView.getChildren().getNodes()) {
        TestSupport.TestProject p = n.getLookup().lookup(TestSupport.TestProject.class);
        assertNull("No project of this type, yet", p);
    }
    
    // let project open code run
    down.countDown();
    TestProjectOpenedHookImpl.toOpen.await();
    
    assertEquals("All projects opened", 2, TestProjectOpenedHookImpl.opened);
    
    OpenProjectList.waitProjectsFullyOpen();

    Node[] nodes = logicalView.getChildren().getNodes();
    assertEquals("No projects open", 0, nodes.length);
    
    listener.assertEvents("Goal is to receive no events at all", 1);
    assertTrue("Finished", OpenProjects.getDefault().openProjects().isDone());
    assertFalse("Not cancelled, Finished", OpenProjects.getDefault().openProjects().isCancelled());
    Project[] arr = OpenProjects.getDefault().openProjects().get();
    assertEquals("zero projects to be opened", 0, arr.length);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:OpenProjectHookThrowsExceptionTest.java

示例9: testClose

import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testClose() throws Exception {
    Node logicalView = new ProjectsRootNode(ProjectsRootNode.LOGICAL_VIEW);
    L listener = new L();
    logicalView.addNodeListener(listener);
    
    assertEquals("30 children", 30, logicalView.getChildren().getNodesCount());
    listener.assertEvents("None", 0);
    assertEquals("No project opened yet", 0, TestProjectOpenedHookImpl.opened);
    
    Node[] nodeArray = logicalView.getChildren().getNodes();
    Project[] arr = new Project[nodeArray.length];
    int i = 0;
    for (Node n : nodeArray) {
        Project p = n.getLookup().lookup(TestSupport.TestProject.class);
        assertNull("No project of this type, yet", p);
        
        arr[i] = n.getLookup().lookup(Project.class);
        assertNotNull("but some project is there", arr[i]);
        
        if (i >= 15) {
            OpenProjects.getDefault().close(new Project[] { arr[i] });
        }
        i++;
    }
    ProjectsRootNode.ProjectChildren.RP.post(new Runnable() {public @Override void run() {}}).waitFinished();
    assertEquals("Just fifteen left nodes", 15, logicalView.getChildren().getNodesCount());

    // let the project open hook run
    down.countDown();
    
    OpenProjects.getDefault().close(arr);
    
    ProjectsRootNode.ProjectChildren.RP.post(new Runnable() {public @Override void run() {}}).waitFinished();
    assertEquals("View is empty", 0, logicalView.getChildren().getNodesCount());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:CloseProjectsTest.java

示例10: initChildren

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void initChildren() {
    Node node = getOriginal();
    node.addNodeListener(WeakListeners.create(NodeListener.class, this, node));
    final boolean leaf = node.isLeaf();
    if (!leaf) {
        setChildren(children);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ActionFilterNode.java

示例11: LazyMenu

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Constructor. */
public LazyMenu(final DataFolder df, boolean icon) {
    this.master = df;
    this.icon = icon;
    this.dynaModel = new DynaMenuModel();
    this.slave = new MenuFolder();
    
    setName(df.getName());
    final FileObject pf = df.getPrimaryFile();
    Object prefix = pf.getAttribute("property-prefix"); // NOI18N
    if (prefix instanceof String) {
        Enumeration<String> en = pf.getAttributes();
        while (en.hasMoreElements()) {
            String attrName = en.nextElement();
            if (attrName.startsWith((String)prefix)) {
                putClientProperty(
                    attrName.substring(((String)prefix).length()), 
                    pf.getAttribute(attrName)
                );
            }
        }
    }

    // Listen for changes in Node's DisplayName/Icon
    Node n = master.getNodeDelegate ();
    n.addNodeListener (org.openide.nodes.NodeOp.weakNodeListener (this, n));
    Mutex.EVENT.readAccess(this);
    getModel().addChangeListener(this);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:MenuBar.java

示例12: initializeCloneableEditor

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Annotates the editor with icon from the data object and also sets 
 * appropriate selected node. But only in the case the data object is valid.
 * This implementation also listen to display name and icon changes of the
 * node and keeps editor top component up-to-date. If you override this
 * method and not call super, please note that you will have to keep things
 * synchronized yourself. 
 *
 * @param editor the editor that has been created and should be annotated
 */
@Override
protected void initializeCloneableEditor (CloneableEditor editor) {
    // Prevention to bug similar to #17134. Don't call getNodeDelegate
    // on invalid data object. Top component should be discarded later.
    if(obj.isValid()) {
        Node ourNode = obj.getNodeDelegate();
        editor.setActivatedNodes (new Node[] { ourNode });
        editor.setIcon(ourNode.getIcon (java.beans.BeanInfo.ICON_COLOR_16x16));
        NodeListener nl = new DataNodeListener(editor);
        ourNode.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (nl, ourNode));
        nodeL = nl;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:DataEditorSupport.java

示例13: attach

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Attaches itself to a given node.
*/
private void attach(Node n) {
    synchronized (top) {
        node = new WeakReference<Node>(n);
        nodeL = WeakListeners.create(NodeListener.class, this, n);
        n.addNodeListener(nodeL);
        top.attachNodeName(this);
        top.setActivatedNodes(new Node[] { n });
        top.setName(n.getDisplayName());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:TopComponent.java

示例14: attachListeners

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Attach itself as a listener to the given nodes */
void attachListeners(List<Reference<Node>> nodes) {
    Iterator<Reference<Node>> it = nodes.iterator();

    while (it.hasNext()) {
        Node node = it.next().get();

        if (node != null) {
            node.addNodeListener(listener);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:CookieAction.java

示例15: testViewItemChanges

import org.openide.nodes.Node; //導入方法依賴的package包/類
@RandomlyFails // NB-Core-Build #1012
public void testViewItemChanges() throws Exception {
    FileObject top = FileUtil.toFileObject(copyFolder(FileUtil.toFile(egdirFO.getFileObject("extsrcroot"))));
    FreeformProject extsrcroot_ = (FreeformProject) ProjectManager.getDefault().findProject(top.getFileObject("proj"));
    Node root = extsrcroot_.getLookup().lookup(LogicalViewProvider.class).createLogicalView();
    Children ch = root.getChildren();
    Node[] kids = ch.getNodes(true);
    assertEquals("two child nodes", 2, kids.length);
    assertEquals("correct code name #1", "../src", kids[0].getName());
    assertEquals("correct code name #2", "nbproject/project.xml", kids[1].getName());
    TestNL l = new TestNL();
    root.addNodeListener(l);
    Element data = extsrcroot_.getPrimaryConfigurationData();
    Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <view>", view);
    Element items = XMLUtil.findElement(view, "items", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <items>", items);
    Element sourceFolder = XMLUtil.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <source-folder>", sourceFolder);
    Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <location>", location);
    NodeList nl = location.getChildNodes();
    assertEquals("one child", 1, nl.getLength());
    location.removeChild(nl.item(0));
    location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
    Element sourceFile =  XMLUtil.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <source-file>", sourceFile);
    items.removeChild(sourceFile);
    extsrcroot_.putPrimaryConfigurationData(data);
    // children keys are updated asynchronously. give them a time
    Thread.sleep(500);
    assertFalse("got some changes in children", l.probeChanges().isEmpty());
    kids = ch.getNodes(true);
    assertEquals("one child node", 1, kids.length);
    assertEquals("correct code name #1", "../src2", kids[0].getName());
    assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName());
    assertEquals("correct cookie #1",
            DataObject.find(top.getFileObject("src2")),
            kids[0].getLookup().lookup(DataObject.class));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:ViewTest.java


注:本文中的org.openide.nodes.Node.addNodeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。