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


Java Node類代碼示例

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


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

示例1: createNodes

import org.openide.nodes.Node; //導入依賴的package包/類
protected Node[] createNodes (final Object key) {
        if (key instanceof ColumnElement)
            return new Node[] {factory.createColumnNode((ColumnElement) key)};
            
        if (key instanceof ColumnPairElement)
            return new Node[] {factory.createColumnPairNode((ColumnPairElement) key)};

        if (element instanceof TableElement) {
            boolean viewSupport = isViewSupport((TableElement) element);
            if (((TableElement) element).isTableOrView() || viewSupport) {
//            if (((TableElement) element).isTableOrView()) {
                if (key instanceof IndexElement)
                    return new Node[] { factory.createIndexNode((IndexElement)key) };
                if (key instanceof ForeignKeyElement)
                    return new Node[] { factory.createForeignKeyNode((ForeignKeyElement)key) };
            }
        }
            
        // ?? unknown type
        return new Node[0];
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:TableChildren.java

示例2: getNodes

import org.openide.nodes.Node; //導入依賴的package包/類
private final Vector getNodes() {
    Vector<Node> result = new Vector(javaObjects.size());
    LinkedList<FileObject> q = new LinkedList<FileObject>(javaObjects);
    while (!q.isEmpty()) {
        FileObject f = q.removeFirst();
        if (!VisibilityQuery.getDefault().isVisible(f)) {
            continue;
        }
        DataObject d = null;
        try {
            d = DataObject.find(f);
        } catch (DataObjectNotFoundException ex) {
            ex.printStackTrace();
        }
        if (d instanceof DataFolder) {
            for (DataObject o:((DataFolder) d).getChildren()) {
                q.addLast(o.getPrimaryFile());
            }
        } else {
            result.add(d.getNodeDelegate());
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:MoveClassesUI.java

示例3: createProperty

import org.openide.nodes.Node; //導入依賴的package包/類
/**
 * Creates a node property of the given key (same as the column keys)
 * and specific getter/setter methods on the given object.
 *
 * @param  key     property name (same as matching column).
 * @param  type    Class of the property (e.g. String.class).
 * @param  inst    object on which to reflect.
 * @param  getter  name of getter method for property value.
 * @param  setter  name of setter method for property value (may be null).
 * @return  new property.
 */
private Node.Property createProperty(String key, Class type, Object inst,
        String getter, String setter) {
    Property prop = null;
    try {
        prop = new Reflection(inst, type, getter, setter);
        prop.setName(key);
        prop.setDisplayName(NbBundle.getMessage(
                ExternalReferenceDataNode.class,
                "CTL_SchemaPanel_Column_Name_" + key));
        prop.setShortDescription(NbBundle.getMessage(
                ExternalReferenceDataNode.class,
                "CTL_SchemaPanel_Column_Desc_" + key));
    }  catch (NoSuchMethodException nsme) {
        ErrorManager.getDefault().notify(nsme);
    }
    return prop;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:ExternalReferenceDataNode.java

示例4: computeEqualsCount

import org.openide.nodes.Node; //導入依賴的package包/類
private int computeEqualsCount(int size) throws Exception {
    Integer [] arr = new Integer[size];
    for (int i = 0; i<arr.length; i++) {
        arr[i] = i;
    }
    ExplorerManager myem = new ExplorerManager();
    IntKeys mykeys = new IntKeys();
    mykeys.keys(arr);
    Node myroot = new AbstractNode(mykeys);
    myem.setRootContext(myroot);
    
    Node[] ch = myroot.getChildren().getNodes(true);
    
    Node[] neuCh = new Node[ch.length-1];
    System.arraycopy(ch, 0, neuCh, 0, neuCh.length);
    myem.setSelectedNodes(neuCh);
    IntKeys.eqCounter = 0;
    myem.setSelectedNodes(ch);
    myem.setSelectedNodes(neuCh);

    return IntKeys.eqCounter;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ExplorerManagerTest.java

示例5: compare

import org.openide.nodes.Node; //導入依賴的package包/類
public int compare(Object o1, Object o2) {
    Node.Property p1 = (Node.Property) o1;
    Node.Property p2 = (Node.Property) o2;
    String sk1 = (String) p1.getValue("sortkey"); // NOI18N
    if (sk1 != null) {
        String sk2 = (String) p2.getValue("sortkey"); // NOI18N
        return sk1.compareToIgnoreCase(sk2);
    } else {
        try {
            String s1 = (String) p1.getValue();
            String s2 = (String) p2.getValue();
            return s1.compareToIgnoreCase(s2);
        } catch (Exception e) {
            Subversion.LOG.log(Level.SEVERE, null, e);
            return 0;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:UpdateResultsTable.java

示例6: obtainNodes

import org.openide.nodes.Node; //導入依賴的package包/類
/** Utility method. Returns either selected nodes in tree
* (if cursor hotspot is above some selected node) or the node
* the cursor points to.
* @return Node array or null if position of the cursor points
* to no node.
*/
Node[] obtainNodes(DragGestureEvent dge) {
    TreePath[] tps = tree.getSelectionPaths();

    if (tps == null) {
        return null;
    }

    Node[] result = new Node[tps.length];

    int cnt = 0;

    for (int i = 0; i < tps.length; i++) {
        Rectangle r = tree.getPathBounds(tps[i]);
        if (r != null && r.contains(dge.getDragOrigin())) {
            cnt++;
        }

        result[i] = DragDropUtilities.secureFindNode(tps[i].getLastPathComponent());
    }

    // #41954:
    // if the drag source is not at all in path location, do not return
    // any nodes
    return (cnt == 0) ? null : result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:TreeViewDragSupport.java

示例7: toggleView

import org.openide.nodes.Node; //導入依賴的package包/類
private void toggleView(boolean flat) {
    FindDialogMemory memory = FindDialogMemory.getDefault();
    if (flat) {
        resultsOutlineSupport.setFlatMode();
        memory.setResultsViewMode(MODE_FLAT);
    } else {
        resultsOutlineSupport.setFolderTreeMode();
        memory.setResultsViewMode(MODE_TREE);
    }
    btnTreeView.setSelected(!flat);
    btnFlatView.setSelected(flat);
    try {
        getExplorerManager().setSelectedNodes(new Node[]{
                    resultsOutlineSupport.getResultsNode()});
    } catch (PropertyVetoException ex) {
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:BasicAbstractResultsPanel.java

示例8: getSetups

import org.openide.nodes.Node; //導入依賴的package包/類
@Override
public Collection<Setup> getSetups() {
    Node [] nodes = TopComponent.getRegistry().getActivatedNodes();
    if (nodes.length == 0) {
        return parent.getSetups(results.toArray(new RepositoryRevision[results.size()]), new RepositoryRevision.Event[0]);
    }
    
    Set<RepositoryRevision.Event> events = new HashSet<RepositoryRevision.Event>();
    Set<RepositoryRevision> revisions = new HashSet<RepositoryRevision>();
    for (Node n : nodes) {
        RevisionNode node = (RevisionNode) n;
        if (node.getEvent() != null) {
            events.add(node.getEvent());
        } else {
            revisions.add(node.getContainer());
        }
    }
    return parent.getSetups(revisions.toArray(new RepositoryRevision[revisions.size()]), events.toArray(new RepositoryRevision.Event[events.size()]));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:DiffResultsView.java

示例9: testChildrenCanGC

import org.openide.nodes.Node; //導入依賴的package包/類
public void testChildrenCanGC () throws Exception {
    Filter filter = new Filter();
    holder = filter;

    String pref = getName() + '/';
    FileObject bb = FileUtil.createFolder(FileUtil.getConfigRoot(), pref + "/BB");
    bb.createData("Ahoj.txt");
    bb.createData("Hi.txt");
    DataFolder folder = DataFolder.findFolder(bb);

    Children ch = folder.createNodeChildren(filter);
    LOG.info("children created: " + ch);
    Node[] arr = ch.getNodes(true);
    LOG.info("nodes obtained" + arr);
    assertEquals("Accepts only Ahoj", 1, arr.length);
    LOG.info("The one node" + arr[0]);

    WeakReference<Children> ref = new WeakReference<Children>(ch);
    ch = null;
    arr = null;

    assertGC("Children can disappear even we hold the filter", ref);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:FolderChildrenTest.java

示例10: propertyChange

import org.openide.nodes.Node; //導入依賴的package包/類
@Override
public void propertyChange (PropertyChangeEvent evt) {
    if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) && !internalTraverse) {
        Node[] selectedNodes = em.getSelectedNodes();
        final TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, view);
        if (tc != null) {
            tc.setActivatedNodes(selectedNodes);
        }
        if (selectedNodes.length == 1) {
            // single selection
            T node = convertNode(selectedNodes[0]);
            if (node != null) {
                nodeSelected(node);
                return;
            }
        }
        nodeSelected(null);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:FileTreeView.java

示例11: testForToStrictAssertsInVisualizerChildren

import org.openide.nodes.Node; //導入依賴的package包/類
public void testForToStrictAssertsInVisualizerChildren() throws InterruptedException, InvocationTargetException {
    // block AWT thread
    Block b = new Block();
    b.block();
    Node n = lch.getNodeAt(0);
    final TreeNode tn = Visualizer.findVisualizer(n);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            try {
                int idx = ta.getIndex(tn);
            } catch (Throwable ex) {
                e = ex;
            }
        }
    });
    lch.keys("x", "y", "y");
    b.unblock();
    waitForAwtQueue();
    if (e != null) {
        fail();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:VisualizerNodeEventsOrderTest.java

示例12: getPropSet

import org.openide.nodes.Node; //導入依賴的package包/類
public Sheet.Set getPropSet() {
    Sheet.Set props = super.getPropSet();

    Node.Property p = new PropertySupport.ReadWrite("loglevel", Integer.class, "Log level", "") {

        public void setValue(Object val) {
            filter = replaceFilter(filter, new LogProxy.FilterLog(levels[(Integer) val]));
        }

        public Object getValue() {
            Integer i = levelToIndex.get(((LogProxy.FilterLog) filter).getLevel());
            return i;
        }
    };

    p.setValue("intValues", levelVals);
    p.setValue("stringKeys", levelNames);
    props.put(p);

    return props;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:22,代碼來源:LogProxy.java

示例13: getText

import org.openide.nodes.Node; //導入依賴的package包/類
private static String getText(org.w3c.dom.Element el) {
    NodeList nl = el.getChildNodes();
    if (nl.getLength() > 0) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < nl.getLength(); i++) {
            org.w3c.dom.Node nd = nl.item(i);
            if (nd instanceof org.w3c.dom.Text) {
                org.w3c.dom.Text txt = (org.w3c.dom.Text)nd;
                String s = txt.getNodeValue();
                if (s != null) {
                    sb.append(s);
                }
            }
        }
        return sb.toString();
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:POMModelPanel.java

示例14: testCreatePaletteFolder

import org.openide.nodes.Node; //導入依賴的package包/類
public void testCreatePaletteFolder() throws Exception {
    try {
        PaletteFactory.createPalette( "non_existent_folder", new DummyActions() );
        fail( "Palette factory accepts non-existent folders." );
    } catch( FileNotFoundException fnfE ) {
        //that's what we want
    } catch( Throwable e ) {
        fail( "Invalid exception thrown." );
    }
    
    PaletteActions actions = new DummyActions();
    PaletteController controller = PaletteFactory.createPalette( PALETTE_ROOT_FOLDER_NAME, actions );
    Node rootNode = (Node)controller.getRoot().lookup( Node.class );
    assertNotNull( rootNode );
    assertEquals( actions, controller.getRoot().lookup( PaletteActions.class ) );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:PaletteFactoryTest.java

示例15: createSubmenu

import org.openide.nodes.Node; //導入依賴的package包/類
private void createSubmenu(JMenu menu) {
    Node[] nodes = getActivatedNodes();
    if (nodes != null && nodes.length == 1) {
        RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
        RADComponent comp = (radCookie != null) ? radCookie.getRADComponent() : null;
        if (comp != null) {
            List<JMenuItem> list = new ArrayList<JMenuItem>();
            RADComponent topComp = comp.getFormModel().getTopRADComponent();
            boolean topCompIncluded = false;
            RADComponent parent = comp.getParentComponent();
            while (parent != null) {
                list.add(new DesignParentMenuItem(parent, parent == topComp, getMenuItemListener()));
                if (parent == topComp) {
                    topCompIncluded = true;
                }
                parent = parent.getParentComponent();
            }
            if (!topCompIncluded && topComp != null) {
                list.add(new DesignParentMenuItem(topComp, true, getMenuItemListener()));
            }
            for (ListIterator<JMenuItem> it=list.listIterator(list.size()); it.hasPrevious(); ) {
                menu.add(it.previous());
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:DesignParentAction.java


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