当前位置: 首页>>代码示例>>Java>>正文


Java NodeOp类代码示例

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


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

示例1: testReducedTreePathFinder

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public void testReducedTreePathFinder() throws Exception {
    SourceGroup g = sampleGroup();
    final Node r = new TreeRootNode(g, true);
    final FileObject rootFolder = g.getRootFolder();
    final TreeRootNode.PathFinder pf = new TreeRootNode.PathFinder(g, true);
    class A {
        void assertPath(String expected, String resource) {
            FileObject f = rootFolder.getFileObject(resource);
            assertNotNull(resource, f);
            Node n = pf.findPath(r, f);
            if (expected == null) {
                assertNull(resource, n);
            } else {
                assertNotNull(resource, n);
                assertEquals(expected, Arrays.toString(NodeOp.createPath(n, r)));
            }
        }
    }
    new A().assertPath("[org.netbeans, api.stuff, Stuff]", "org/netbeans/api/stuff/Stuff.java");
    new A().assertPath("[org.netbeans, api.stuff]", "org/netbeans/api/stuff");
    new A().assertPath(null, "org/netbeans/api"); // displayed only in Files
    new A().assertPath("[org.netbeans, spi.stuff, StuffImplementation]", "org/netbeans/spi/stuff/StuffImplementation.java");
    new A().assertPath("[org.netbeans, spi.stuff, support]", "org/netbeans/spi/stuff/support");
    new A().assertPath("[org.netbeans, spi.stuff, support, AbstractStuffImplementation]", "org/netbeans/spi/stuff/support/AbstractStuffImplementation.java");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:PackageViewTest.java

示例2: createPopup

import org.openide.nodes.NodeOp; //导入依赖的package包/类
void createPopup(int xpos, int ypos) {
    // bugfix #23932, don't create if it's disabled
    if (isPopupAllowed()) {
        Node[] selNodes = manager.getSelectedNodes();

        if (selNodes.length > 0) {
            Action[] actions = NodeOp.findActions(selNodes);
            if (actions.length > 0) {
                createPopup(xpos, ypos, Utilities.actionsToPopup(actions, this));
            }                
        } else if (manager.getRootContext() != null) {
            JPopupMenu popup = manager.getRootContext().getContextMenu();
            if (popup != null) {
                createPopup(xpos, ypos, popup);
            }
        }                
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TreeView.java

示例3: createExtendedPopup

import org.openide.nodes.NodeOp; //导入依赖的package包/类
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
    Node[] ns = manager.getSelectedNodes();
    JPopupMenu popup = null;

    if (ns.length > 0) {
        // if any nodes are selected --> find theirs actions
        Action[] actions = NodeOp.findActions(ns);
        popup = Utilities.actionsToPopup(actions, this);
    } else {
        // if none node is selected --> get context actions from view's root
        if (manager.getRootContext() != null) {
            popup = manager.getRootContext().getContextMenu();
        }
    }

    int cnt = 0;

    if (popup == null) {
        popup = SystemAction.createPopupMenu(new SystemAction[] {  });
    }

    popup.add(newMenu);

    createPopup(xpos, ypos, popup);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TreeView.java

示例4: createPopupMenu

import org.openide.nodes.NodeOp; //导入依赖的package包/类
/**
 * Creates a popup menu with entries from the selected nodes
 * related to the given component (usually a ETable subclass). The popup
 * is created for the table element in given column and row (column
 *  and row are in the view's coordinates (not the model's)).
 */
public JPopupMenu createPopupMenu(int row, int column, Node[] selectedNodes,
        Component component) {
    
    Action[] actions = NodeOp.findActions (selectedNodes);
    JPopupMenu res = Utilities.actionsToPopup(actions, component);
    if (showQuickFilter) {
        if ((component instanceof ETable) && (column >= 0)) {
            ETable et = (ETable)component;
            if (row >= 0) {
                Object val = et.getValueAt(row, column);
                val = et.transformValue(val);
                String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
                res.add(et.getQuickFilterPopup(column, val, s));
            } else if (et.getQuickFilterColumn() == column) {
                addNoFilterItem(et, res);
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NodePopupFactory.java

示例5: setSelectedNode

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public void setSelectedNode (String path) {
    if (path == null) {
        return;
    }
    StringTokenizer tk = new StringTokenizer (path,"/");    //NOI18N
    final String[] names = new String[tk.countTokens()];
    for (int i=0;tk.hasMoreTokens();i++) {
        names[i] = tk.nextToken();
    }
    RP.post(new Runnable() {
        @Override public void run() {
            try {
                Node node = NodeOp.findPath(manager.getRootContext(), names);
                if (node != null) {
                    setSelectedNodes(new Node[] {node});
                }
            } catch (PropertyVetoException e) {
                //Skip it, not important
            } catch (NodeNotFoundException x) {
                // OK, never mind
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TemplatesPanelGUI.java

示例6: stringPath2TreePath

import org.openide.nodes.NodeOp; //导入依赖的package包/类
/** Converts path of strings to TreePath if exists null otherwise
 */
private TreePath stringPath2TreePath (String[] sp) {
    ExplorerManager em = ExplorerManager.find (this);
    try {
        Node n = NodeOp.findPath (em.getRootContext (), sp); 
        
        // Create the tree path
        TreeNode tns[] = new TreeNode [sp.length + 1];
        
        for (int i = sp.length; i >= 0; i--) {
            tns[i] = Visualizer.findVisualizer (n);
            n = n.getParentNode ();
        }                
        return new TreePath (tns);
    } catch (NodeNotFoundException e) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:OutlineTable.java

示例7: writeExternal

import org.openide.nodes.NodeOp; //导入依赖的package包/类
/** Serialize this property sheet */
@Override
public void writeExternal (ObjectOutput out)
throws IOException {
    super.writeExternal(out);

    if (global) {
        // write dummy array
        out.writeObject (null);
    } else {
        Node.Handle[] arr = NodeOp.toHandles (nodes);
        out.writeObject(arr);
    }

    out.writeBoolean(global);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbSheet.java

示例8: testPackageUnregistering

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public void testPackageUnregistering() {
    MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test1.pkg"));
    NodeOp.registerPropertyEditors();
    MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test2.pkg"));
    
    String[] editorSearchPath = PropertyEditorManager.getEditorSearchPath();
    int count = 0;
    for (int i = 0; i < editorSearchPath.length; i++) {
        assertNotSame("test1.pkg", editorSearchPath[i]);
        if ("test2.pkg".equals(editorSearchPath[i])) {
            count++;
        }
    }
    assertEquals(1, count);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PELookupTest.java

示例9: initializeWithRootContext

import org.openide.nodes.NodeOp; //导入依赖的package包/类
/** Initialize this top component properly with information
* obtained from specified root context node */
private void initializeWithRootContext (Node rc) {
    // update TC's attributes
    setToolTipText(rc.getDisplayName());
    setName(rc.getDisplayName());
    updateTitle();
    // attach listener
    if (weakRcL == null) {
        weakRcL = WeakListeners.propertyChange(
            rcListener(), rc
        );
    }
    rc.addPropertyChangeListener(weakRcL);

    if (weakNRcL == null) {
        weakNRcL = NodeOp.weakNodeListener (
            rcListener(), rc
        );
    }
    rc.addNodeListener(weakNRcL);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Tab.java

示例10: getExpandedPaths

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public List<String[]> getExpandedPaths() {
    List<String[]> result = new ArrayList<String[]>();
    if (getRootNode() != null) {
        TreeNode rtn = Visualizer.findVisualizer(getRootNode());
        TreePath tp = new TreePath(rtn); // Get the root
        Enumeration exPaths = tree.getExpandedDescendants(tp);
        while (exPaths != null && exPaths.hasMoreElements()) {
            TreePath ep = (TreePath) exPaths.nextElement();
            Node en = Visualizer.findNode(ep.getLastPathComponent());
            String[] path = NodeOp.createPath(en, getRootNode());
            result.add(path);
            if (logger.isTraceEnabled()) logger.trace("Expanded path: " + LoggingUtils.printArray(path));
        }
    }
    return result;

}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:18,代码来源:StatefulView.java

示例11: getExpandedPaths

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public List<String[]> getExpandedPaths() {

        List<String[]> result = new ArrayList<String[]>();

        TreeNode rtn = Visualizer.findVisualizer(getRootContext());
        TreePath tp = new TreePath(rtn); // Get the root

        Enumeration<TreePath> paths = tree.getExpandedDescendants(tp);
        if (null != paths) {
            while (paths.hasMoreElements()) {
                TreePath ep = paths.nextElement();
                Node en = Visualizer.findNode(ep.getLastPathComponent());
                String[] path = NodeOp.createPath(en, getRootContext());  
                result.add(path);
            }
        }

        return result;

    }
 
开发者ID:tusharvjoshi,项目名称:nbtaskfocus,代码行数:21,代码来源:CustomTreeView.java

示例12: stringPath2TreePath

import org.openide.nodes.NodeOp; //导入依赖的package包/类
/** Converts path of strings to TreePath if exists null otherwise
     */
private TreePath stringPath2TreePath(String[] sp) {

    try {
        Node n = NodeOp.findPath(getRootContext(), sp);

        // Create the tree path
        TreeNode tns[] = new TreeNode[sp.length + 1];

        for (int i = sp.length; i >= 0; i--) {
            tns[i] = Visualizer.findVisualizer(n);
            n = n.getParentNode();
        }
        return new TreePath(tns);
    } catch (NodeNotFoundException e) {
        return null;
    }
}
 
开发者ID:tusharvjoshi,项目名称:nbtaskfocus,代码行数:20,代码来源:CustomTreeView.java

示例13: findPathPlain

import org.openide.nodes.NodeOp; //导入依赖的package包/类
private Node findPathPlain(FileObject fo, FileObject groupRoot, Node rootNode) {
    FileObject folder = fo.isFolder() ? fo : fo.getParent();
    String relPath = FileUtil.getRelativePath(groupRoot, folder);
    List<String> path = new ArrayList<String>();
    StringTokenizer strtok = new StringTokenizer(relPath, "/"); // NOI18N
    while (strtok.hasMoreTokens()) {
        String token = strtok.nextToken();
       path.add(token);
    }
    try {
        Node folderNode =  folder.equals(groupRoot) ? rootNode : NodeOp.findPath(rootNode, Collections.enumeration(path));
        if (fo.isFolder()) {
            return folderNode;
        } else {
            Node[] childs = folderNode.getChildren().getNodes(true);
            for (int i = 0; i < childs.length; i++) {
               DataObject dobj = childs[i].getLookup().lookup(DataObject.class);
               if (dobj != null && dobj.getPrimaryFile().getNameExt().equals(fo.getNameExt())) {
                   return childs[i];
               }
            }
        }
    } catch (NodeNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:TreeRootNode.java

示例14: testReducedTreeDelete

import org.openide.nodes.NodeOp; //导入依赖的package包/类
@RandomlyFails // NB-Core-Build #8123
public void testReducedTreeDelete() throws Exception {
    SourceGroup g = sampleGroup();
    Node r = new TreeRootNode(g, true);
    assertTree("TestGroup{org.netbeans{api.stuff{Stuff.java}, modules.stuff{resources{stuff.png}, Bundle.properties, StuffUtils.java}, spi.stuff{support{AbstractStuffImplementation.java}, StuffImplementation.java}}}", r);
    Node n = NodeOp.findPath(r, new String[] {"org.netbeans", "modules.stuff"});
    n.destroy();
    assertTree("TestGroup{org.netbeans{api.stuff{Stuff.java}, spi.stuff{support{AbstractStuffImplementation.java}, StuffImplementation.java}}}", r);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:PackageViewTest.java

示例15: testReducedTreeCut

import org.openide.nodes.NodeOp; //导入依赖的package包/类
public void testReducedTreeCut() throws Exception { // #210314
    SourceGroup g = sampleGroup();
    Node r = new TreeRootNode(g, true);
    Node n = NodeOp.findPath(r, new String[] {"org.netbeans", "modules.stuff"});
    Transferable t = n.clipboardCut();
    DataObject moving = LoaderTransfer.getDataObject(t, LoaderTransfer.MOVE);
    assertEquals(g.getRootFolder().getFileObject("org/netbeans/modules"), moving.getPrimaryFile());
    n = NodeOp.findPath(r, new String[] {"org.netbeans", "spi.stuff", "support"});
    t = n.clipboardCut();
    moving = LoaderTransfer.getDataObject(t, LoaderTransfer.MOVE);
    assertEquals(g.getRootFolder().getFileObject("org/netbeans/spi/stuff/support"), moving.getPrimaryFile());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PackageViewTest.java


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