• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NodeListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openide.nodes.NodeListener的典型用法代码示例。如果您正苦于以下问题:Java NodeListener类的具体用法?Java NodeListener怎么用?Java NodeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NodeListener类属于org.openide.nodes包,在下文中一共展示了NodeListener类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getValueFor

import org.openide.nodes.NodeListener; //导入依赖的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


示例2: testNodeListenersDetachedAtFinalizeIssue58065

import org.openide.nodes.NodeListener; //导入依赖的package包/类
public void testNodeListenersDetachedAtFinalizeIssue58065() throws Exception {
    CookieNode node = new CookieNode();
    SimpleCookieAction2 sca = new SimpleCookieAction2();
    Action action = sca.createContextAwareInstance(node.getLookup());
    
    class NodeListenerMemoryFilter implements MemoryFilter {
        public int numofnodelisteners = 0;
        public boolean reject(Object obj) {
            numofnodelisteners += (obj instanceof NodeListener)?1:0;
            return !((obj instanceof EventListenerList) | (obj instanceof Object[]));
        }
    }
    NodeListenerMemoryFilter filter = new NodeListenerMemoryFilter();
    assertSize("",Arrays.asList( new Object[] {node} ),1000000,filter);
    assertTrue("Node is expected to have a NodeListener attached", filter.numofnodelisteners > 0);
    
    Reference actionref = new WeakReference(sca);
    sca = null;
    action = null;
    assertGC("CookieAction is supposed to be GCed", actionref);
    
    NodeListenerMemoryFilter filter2 = new NodeListenerMemoryFilter();
    assertSize("",Arrays.asList( new Object[] {node} ),1000000,filter2);
    assertEquals("Node is expected to have no NodeListener attached", 0, filter2.numofnodelisteners);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CookieAction2Test.java


示例3: registerNodeListener

import org.openide.nodes.NodeListener; //导入依赖的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


示例4: createNodeListener

import org.openide.nodes.NodeListener; //导入依赖的package包/类
@Override
protected NodeListener createNodeListener() {
    return new NodeAdapter(this) {
        @Override
        protected void propertyChange(FilterNode fn, PropertyChangeEvent ev) {
            super.propertyChange(fn, ev);
            if (Node.PROP_LEAF.equals(ev.getPropertyName())) {
                Node orig = getOriginal();
                setChildren(orig.isLeaf() ? Children.LEAF : new ProjectBadgingChildren(orig));
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:PhysicalView.java


示例5: initChildren

import org.openide.nodes.NodeListener; //导入依赖的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


示例6: initializeCloneableEditor

import org.openide.nodes.NodeListener; //导入依赖的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


示例7: attach

import org.openide.nodes.NodeListener; //导入依赖的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


示例8: createNodeListener

import org.openide.nodes.NodeListener; //导入依赖的package包/类
@Override
protected NodeListener createNodeListener() {
    return new NodeAdapter(this) {
        @Override
        protected void propertyChange(FilterNode fn, PropertyChangeEvent ev) {
            super.propertyChange(fn, ev);
            if (Node.PROP_LEAF.equals(ev.getPropertyName())) {
                RP.post(ProjectFilterNode.this);
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:FavoritesNode.java


示例9: initializeCloneableEditor

import org.openide.nodes.NodeListener; //导入依赖的package包/类
/** Overrides superclass method. Initializes editor component. */
protected void initializeCloneableEditor (CloneableEditor editor) {
    DataObject obj = getDataObject();
    if(obj.isValid()) {
        org.openide.nodes.Node ourNode = obj.getNodeDelegate();
        editor.setActivatedNodes(new org.openide.nodes.Node[] {ourNode});
        editor.setIcon(ourNode.getIcon (java.beans.BeanInfo.ICON_COLOR_16x16));
        NodeListener nl = new DataNodeListener(editor);
        ourNode.addNodeListener(WeakListener.node(nl, ourNode));
        nodeL = nl;
    }
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:13,代码来源:EditorSupport.java


示例10: initializeCloneableEditor

import org.openide.nodes.NodeListener; //导入依赖的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 chamges 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
 */
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(WeakListener.node(nl, ourNode));
        nodeL = nl;
    }
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:22,代码来源:DataEditorSupport.java


示例11: createNodeListener

import org.openide.nodes.NodeListener; //导入依赖的package包/类
@Override
protected NodeListener createNodeListener() {
    return new FilterNode.NodeAdapter(this) {
        @Override
        protected void propertyChange(FilterNode fn, PropertyChangeEvent ev) {
            super.propertyChange(fn, ev);
            if (ev.getPropertyName().equals(Node.PROP_LEAF)) {
                final org.openide.nodes.Children[] newChildren = new org.openide.nodes.Children[1];
                Children.MUTEX.readAccess(new Runnable() {

                    @Override
                    public void run() {
                        boolean origIsLeaf = getOriginal().isLeaf();
                        boolean thisIsLeaf = isLeaf();
                        if (origIsLeaf && !thisIsLeaf) {
                            newChildren[0] = Children.LEAF;
                        } else if (!origIsLeaf && thisIsLeaf) {
                            newChildren[0] = new SortedChildren(getOriginal());
                        }
                    }
                });

                if (newChildren[0] != null) {
                    Children.MUTEX.postWriteRequest(
                            new Runnable() {

                                @Override
                                public void run() {
                                    setChildren(newChildren[0]);
                                }
                            }
                    );
                }
            }
            if (ev.getPropertyName().equals(Node.PROP_PARENT_NODE)) {
                final Node node = (Node)ev.getSource();
                if (node.getParentNode() == null) {
                    original2filter.remove(node);
                }
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:TreeTableView.java


示例12: logicalViewForProject

import org.openide.nodes.NodeListener; //导入依赖的package包/类
@NonNull
final Node logicalViewForProject(
        @NonNull final Project project,
        final Union2<LogicalViewProvider,org.openide.util.Pair<Sources,SourceGroup[]>> data,
        final boolean[] projectInLookup) {
    Node node;            
    if (!data.hasFirst()) {
        LOG.log(
                Level.WARNING,
                "Warning - project of {0} in {1} failed to supply a LogicalViewProvider in its lookup",  // NOI18N
                new Object[]{
                    project.getClass(),
                    FileUtil.getFileDisplayName(project.getProjectDirectory())
                });
        final Sources sources = data.second().first();
        final SourceGroup[] groups = data.second().second();
        sources.removeChangeListener(this);
        sources.addChangeListener(this);
        if (groups.length > 0) {
            node = PhysicalView.createNodeForSourceGroup(groups[0], project);
        } else {
            node = Node.EMPTY;
        }
    } else {
        final LogicalViewProvider lvp = data.first();
        node = lvp.createLogicalView();
        if (!project.equals(node.getLookup().lookup(Project.class))) {
            // Various actions, badging, etc. are not going to work.
            LOG.log(
                    Level.WARNING,
                    "Warning - project {0} failed to supply itself in the lookup of the root node of its own logical view",  // NOI18N
                    ProjectUtils.getInformation(project).getName());
            //#114664
            if (projectInLookup != null) {
                projectInLookup[0] = false;
            }
        }
    }                        
    node.addNodeListener(WeakListeners.create(NodeListener.class, this, node));
    return node;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ProjectsRootNode.java


示例13: testLastModifiedOrderUpdatedAfterFileIsTouched

import org.openide.nodes.NodeListener; //导入依赖的package包/类
public void testLastModifiedOrderUpdatedAfterFileIsTouched() throws Exception {
    aa.setSortMode(DataFolder.SortMode.LAST_MODIFIED);

    Node n = aa.getNodeDelegate().cloneNode();
    Node[] nodes = n.getChildren().getNodes(true);
    assertEquals ("Two nodes", 2, nodes.length);

    waitEvents();
    assertEquals("Sort mode not changed and children not refreshed: " + events, 2, events.size());
    assertTrue(DataFolder.PROP_SORT_MODE + " change not fired", events.contains(DataFolder.PROP_SORT_MODE));
    assertTrue(DataFolder.PROP_CHILDREN + " change not fired", events.contains(DataFolder.PROP_CHILDREN));
    assertEquals("Y.txt", nodes[0].getName()); // Y is newer
    assertEquals("X.txt", nodes[1].getName()); // X is older
    events.clear();

    final FileObject orig = lfs.findResource("AA/Y.txt");
    final FileObject touch = lfs.findResource("AA/X.txt");

    // After touching, X.txt will be newer than Y.txt.
    TestFileUtils.touch(FileUtil.toFile(touch), FileUtil.toFile(orig));
    // It's not enough to wait only for DataFolder event
    // because of number of RP tasks run before node children are updated
    // must wait for reorder fired by node itself.
    final CountDownLatch barrier = new CountDownLatch(1);
    NodeListener nodeList = new NodeAdapter() {

        @Override
        public void childrenReordered (NodeReorderEvent ev) {
            barrier.countDown();
        }
      
    };
    n.addNodeListener(nodeList);
    try {
        touch.refresh();
        waitEvents();
        // wait for node reorder event
        barrier.await(10, TimeUnit.SECONDS);
    } finally {
        n.removeNodeListener(nodeList);
    }
    assertEquals(0, barrier.getCount());
    assertTrue(DataFolder.PROP_CHILDREN + " change not fired", events.contains(DataFolder.PROP_CHILDREN));

    Node[] newNodes = n.getChildren().getNodes(true);
    assertEquals("Node " + nodes[1].getName() + " expected first.", newNodes[0], nodes[1]);
    assertEquals("Node " + nodes[0].getName() + " expected second.", newNodes[1], nodes[0]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:DataFolderTimeOrderTest.java


示例14: rcListener

import org.openide.nodes.NodeListener; //导入依赖的package包/类
private NodeListener rcListener () {
    if (rcListener == null) {
        rcListener = new RootContextListener();
    }
    return rcListener;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:Tab.java



注:本文中的org.openide.nodes.NodeListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PemObjectGenerator类代码示例发布时间:2022-05-23
下一篇:
Java ApiCallback类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap