Java Code Examples for org.openide.nodes.Node#setDisplayName()

The following examples show how to use org.openide.nodes.Node#setDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSSStylesSelectionPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets dummy roots to tree views to release the currently displayed nodes.
 */
private void setDummyRoots() {
    Node rulePaneRoot = new AbstractNode(Children.LEAF);
    Node propertyPaneRoot = new AbstractNode(Children.LEAF);
    // Workaround for a bug in TreeTableView
    rulePaneRoot.setDisplayName(NbBundle.getMessage(CSSStylesSelectionPanel.class, "MatchedRulesNode.displayName")); // NOI18N
    propertyPaneRoot.setDisplayName(NbBundle.getMessage(CSSStylesSelectionPanel.class, "MatchedPropertiesNode.displayName")); // NOI18N
    rulePaneManager.setRootContext(rulePaneRoot);
    propertyPaneManager.setRootContext(propertyPaneRoot);
}
 
Example 2
Source File: ListViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: ListViewTopComponentTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: BuildScriptsNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Messages({
    "LBL_ProjectSuffixt=project",
    "LBL_RootSuffix=root",
    "LBL_UserSuffix=user"
})
@Override
protected Node createNodeForKey(Pair<FileObject, GradleFiles.Kind> key) {
    // Do not show root script and property nodes on root project.
    boolean isRoot = project.getGradleProject().getBaseProject().isRoot();
    if (isRoot
            && ((key.second() == GradleFiles.Kind.ROOT_SCRIPT)
            || (key.second() == GradleFiles.Kind.ROOT_PROPERTIES))) {
        return null;
    }
    try {
        Node node = DataObject.find(key.first()).getNodeDelegate().cloneNode();
        String nameSuffix = null;
        if (key.second() != null) {
            if (key.second() == GradleFiles.Kind.USER_PROPERTIES) {
                nameSuffix = Bundle.LBL_UserSuffix();
            }
            if (!isRoot) {
                switch (key.second()) {
                    case BUILD_SCRIPT:
                    case PROJECT_PROPERTIES: {
                        nameSuffix = Bundle.LBL_ProjectSuffixt();
                        break;
                    }
                    case ROOT_SCRIPT:
                    case ROOT_PROPERTIES: {
                        nameSuffix = Bundle.LBL_RootSuffix();
                        break;
                    }
                }
            }
        }
        if (nameSuffix != null) {
            node.setDisplayName(key.first().getNameExt() + " [" + nameSuffix + "]");
        }
        return node;
    } catch (DataObjectNotFoundException e) {
        return null;
    }
}
 
Example 5
Source File: CallEjbDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public boolean open(final FileObject referencingFO, final String referencingClassName, String title) throws IOException {
    Project enterpriseProject = FileOwnerQuery.getOwner(referencingFO);
    
    Project[] allProjects = Utils.getCallableEjbProjects(enterpriseProject);
    List<Node> ejbProjectNodes = new LinkedList<Node>();
    
    for (int i = 0; i < allProjects.length; i++) {
        Node projectView = new EjbsNode(allProjects[i]);
        ejbProjectNodes.add(new FilterNode(projectView, new EjbChildren(projectView)) {
            @Override
            public Action[] getActions(boolean context) {
                return new Action[0];
            }
        });
    }
    
    Children.Array children = new Children.Array();
    children.add(ejbProjectNodes.toArray(new Node[ejbProjectNodes.size()]));
    Node root = new AbstractNode(children);
    root.setDisplayName(NbBundle.getMessage(CallEjbDialog.class, "LBL_EJBModules"));
    EnterpriseReferenceContainer erc = enterpriseProject.getLookup().lookup(EnterpriseReferenceContainer.class);
    boolean isJavaEE5orHigher = ProjectUtil.isJavaEE5orHigher(enterpriseProject);
    final CallEjbPanel panel = new CallEjbPanel(referencingFO, root, isJavaEE5orHigher ? null : erc.getServiceLocatorName(), referencingClassName);
    if (isJavaEE5orHigher) {
        panel.disableServiceLocator();
    }
    
    final DialogDescriptor dialogDescriptor = new DialogDescriptor(
            panel,
            title,
            true,
            DialogDescriptor.OK_CANCEL_OPTION,
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx(CallEjbPanel.class),
            null
            );
    NotificationLineSupport statusLine = dialogDescriptor.createNotificationLineSupport();
    panel.setNotificationLine(statusLine);
    
    panel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(CallEjbPanel.IS_VALID)) {
                Object newvalue = evt.getNewValue();
                if ((newvalue != null) && (newvalue instanceof Boolean)) {
                    dialogDescriptor.setValid(((Boolean)newvalue).booleanValue());
                }
            }
        }
    });
    
    panel.validateReferences();
    
    Object button = DialogDisplayer.getDefault().notify(dialogDescriptor);
    if (button != NotifyDescriptor.OK_OPTION) {
        return false;
    }
    Node ejbNode = panel.getEjb();
    final boolean throwExceptions = !panel.convertToRuntime();
    EjbReference ref = ejbNode.getLookup().lookup(EjbReference.class);
    String referenceNameFromPanel = panel.getReferenceName();
    if (referenceNameFromPanel != null && referenceNameFromPanel.trim().equals("")) {
        referenceNameFromPanel = null;
    }
    final FileObject fileObject = ejbNode.getLookup().lookup(FileObject.class);
    final Project nodeProject = FileOwnerQuery.getOwner(fileObject);
    
    boolean isDefaultRefName = panel.isDefaultRefName();
    final String referencedClassName = _RetoucheUtil.getJavaClassFromNode(ejbNode).getQualifiedName();

    final CallEjbGenerator generator = CallEjbGenerator.create(ref, referenceNameFromPanel, isDefaultRefName);
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            try {
                final ElementHandle<? extends Element> elementHandle = generator.addReference(
                        referencingFO,
                        referencingClassName,
                        fileObject,
                        referencedClassName,
                        panel.getServiceLocator(),
                        panel.getSelectedInterface(),
                        throwExceptions,
                        nodeProject
                        );
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        ElementOpen.open(referencingFO, elementHandle);
                    }
                });
            } catch (IOException ioe) {
                Exceptions.printStackTrace(ioe);
            }
        }
    });

    
    return true;
}