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

The following examples show how to use org.openide.nodes.Node#getDisplayName() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   File: ViewTest.java    License: Apache License 2.0 6 votes vote down vote up
private static String expand(Node n) {
    Node[] kids = n.getChildren().getNodes(true);
    String nm = n.getDisplayName();
    if (kids.length == 0) {
        return nm;
    } else {
        SortedSet<String> under = new TreeSet<String>();
        for (Node kid : kids) {
            under.add(expand(kid));
        }
        StringBuilder b = new StringBuilder(nm).append('{');
        boolean first = true;
        for (String s : under) {
            if (first) {
                first = false;
            } else {
                b.append(' ');
            }
            b.append(s);
        }
        return b.append('}').toString();
    }
}
 
Example 2
Source Project: netbeans   File: FileTreeView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getDisplayName (Object o) {
    Node n = Visualizer.findNode(o);
    String value = n.getDisplayName();
    T leafNode = convertNode(n);
    if (leafNode != null) {
        // do not set selected flag, outline view handles color in its own way
        // instead return fg color in getForeground
        String htmlDisplayName = DiffUtils.getHtmlDisplayName(leafNode, isModified(leafNode), false);
        htmlDisplayName = annotateName(leafNode, htmlDisplayName);
        if (htmlDisplayName != null) {
            value = "<html>" + htmlDisplayName; //NOI18N
        }
    }
    return value;
}
 
Example 3
Source Project: netbeans   File: BasicTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkNode (Node n, String name, RequestProcessor rp) {
    // init
    //assertEquals (null, n.getShortDescription ());
    Node[] ns = n.getChildren ().getNodes ();
    waitFinished (rp);
    
    ns = n.getChildren ().getNodes ();
    if (name.length () < 4) {
        assertEquals (name, 3, ns.length);
        checkNode (ns [0], name + "a", rp);
        checkNode (ns [1], name + "b", rp);
        checkNode (ns [2], name + "c", rp);
    } else
        assertEquals (ns.length, 0);
    
    if (name.length () > 0) {
        //assertEquals (name, n.getName ());
        n.getDisplayName ();
        String sd = n.getShortDescription ();
        n.getActions (false);
        waitFinished (rp);
        assertEquals (name, n.getDisplayName ());
        assertEquals (name + "WWW", sd);
        assertEquals (1, n.getActions (false).length);
    }
}
 
Example 4
Source Project: netbeans   File: PropertiesOpen.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Builds a HTML display name for this component.
 *
 * @return  the created display name
 * @see  #displayName()
 */
private String htmlDisplayName() {
    if (bundleStructure.getNthEntry(0)==null) {
        bundleStructure.updateEntries();
    }
    final Node node = bundleStructure.getNthEntry(0).getDataObject().getNodeDelegate();
    String displayName = node.getHtmlDisplayName();
    if (displayName != null) {
        if (!displayName.startsWith("<html>")) {                //NOI18N
            displayName = "<html>" + displayName;               //NOI18N
        }
    } else {
        displayName = node.getDisplayName();
    }
    return DataEditorSupport.annotateName(displayName, true, isModified(), false);
}
 
Example 5
Source Project: netbeans   File: PackageViewTest.java    License: Apache License 2.0 5 votes vote down vote up
private static String printTree(Node n) {
    String name = n.getDisplayName();
    if (n.isLeaf()) {
        return name;
    } else {
        List<String> kidNames = new ArrayList<String>();
        for (Node kid : n.getChildren().getNodes(true)) {
            kidNames.add(printTree(kid));
        }
        return name + kidNames;
    }
}
 
Example 6
Source Project: netbeans   File: FormEditorSupport.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns display name of the multiview top component.
 * The first item of the array is normal display name,
 * the second item of the array is HTML display name.
 *
 * @param formDataObject form data object representing the multiview tc.
 * @return display names of the MVTC. The second item can be <code>null</code>.
 */
private static String[] getMVTCDisplayName(FormDataObject formDataObject) {
    Node node = formDataObject.getNodeDelegate();
    String title = node.getDisplayName();
    String htmlTitle = node.getHtmlDisplayName();
    if (htmlTitle == null) {
        try {
            htmlTitle = XMLUtil.toElementContent(title);
        } catch (CharConversionException x) {
            htmlTitle = "???";
        }
    }
    FormEditorSupport fes = (FormEditorSupport)formDataObject.getFormEditorSupport();
    if (fes != null) {
        FormDesignerTC designerTC = fes.getFormDesignerTC();
        if (designerTC != null && designerTC.isShowing()) {
            FormModel fm = fes.getFormModel();
            if (fm != null) {
                FormDesigner fd = FormEditor.getFormDesigner(fes.getFormModel());
                if (fd != null && fd.getFormModel() != null
                        && !fd.isTopRADComponent() && fd.getTopDesignComponent() != null) {
                    title = FormUtils.getFormattedBundleString(
                            "FMT_FormTitleWithContainerName", // NOI18N
                            new Object[] {title, fd.getTopDesignComponent().getName()});
                    htmlTitle = FormUtils.getFormattedBundleString(
                            "FMT_FormTitleWithContainerName", // NOI18N
                            new Object[] {htmlTitle, fd.getTopDesignComponent().getName()});
                }
            }
        }
    }
    boolean modified = formDataObject.isModified();
    boolean readOnly = readOnly(formDataObject);
    return new String[] {
        DataEditorSupport.annotateName(title, false, modified, readOnly),
        DataEditorSupport.annotateName(htmlTitle, true, modified, readOnly)
    };
}
 
Example 7
Source Project: netbeans   File: NodeRenderDataProvider.java    License: Apache License 2.0 5 votes vote down vote up
public String getDisplayName(Object o) {
    Node n = Visualizer.findNode(o);
    if (n == null) {
        throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName());
    }
    String text = n.getHtmlDisplayName();
    if( null == text )
        text = n.getDisplayName();
    return text;
}
 
Example 8
Source Project: netbeans   File: InstanceNodeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Test of getDisplayName method, of class org.openide.loaders.InstanceNode.
 */
public void testGetDisplayName () throws Exception {
    Node instance = node;
    
    String expResult = "Ahoj";
    // node's name is calculated later, let's wait
    SwingUtilities.invokeAndWait (new Runnable () {
        public void run () {
            
        }
        
    });
    String result = instance.getDisplayName();
    assertEquals(expResult, result);
}
 
Example 9
Source Project: netbeans   File: SettingChildren.java    License: Apache License 2.0 5 votes vote down vote up
public String getDisplayName() {
    String retVal = null;
    DataObject dobj= (DataObject) getCookie (DataObject.class);
    if (dobj != null && dobj instanceof DataShadow) {
        DataShadow dsh = (DataShadow)dobj;
        Node origNode = dsh.getOriginal().getNodeDelegate();
        if (origNode != null) {
            retVal = origNode.getDisplayName();
        }
    }                        
    return (retVal != null) ? retVal : super.getDisplayName();
}
 
Example 10
Source Project: netbeans   File: LayerUtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void assertDisplayName(FileSystem fs, String message, String path, String label) throws Exception {
    FileObject file = fs.findResource(path);
    assertNotNull("found " + path, file);
    Node n = DataObject.find(file).getNodeDelegate();
    n.getDisplayName();
    BadgingSupport.RP.post(new Runnable() {public void run() {}}).waitFinished();
    assertEquals(message, label, n.getDisplayName());
}
 
Example 11
public KeyNode(Node orig, String bundlepath, String codenamebase, InstanceContent content) {
    super(orig, null, new AbstractLookup(content));
    content.add(this);

    disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME
            | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION
            | DELEGATE_GET_ACTIONS);

    this.key = orig.getDisplayName();
    this.bundlepath = bundlepath;
    this.codenamebase = codenamebase;

    cachedDisplayName = null;
    cachedHtmlDisplayName = null;
}
 
Example 12
public KeyNode(Node orig, String bundlepath, String codenamebase, InstanceContent content) {
    super(orig, null, new AbstractLookup(content));
    content.add(this);

    disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME
            | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION
            | DELEGATE_GET_ACTIONS);

    this.key = orig.getDisplayName();
    this.bundlepath = bundlepath;
    this.codenamebase = codenamebase;

    cachedDisplayName = null;
    cachedHtmlDisplayName = null;
}
 
Example 13
Source Project: netbeans   File: RESTResourcesPanel.java    License: Apache License 2.0 5 votes vote down vote up
public static String getSaasResourceName(Node node) {
    WadlSaasResource saasResource = node.getLookup().lookup(WadlSaasResource.class);

    String resourceName = saasResource.getResource().getPath();
    if (resourceName.startsWith("/")) { //NOI18N
        resourceName = resourceName.substring(1);
    }

    Node saasNode = node.getParentNode();
    while (saasNode != null && saasNode.getLookup().lookup(WadlSaas.class) == null) {
        saasResource = saasNode.getLookup().lookup(WadlSaasResource.class);
        if (saasResource != null) {
            String path = saasResource.getResource().getPath();
            if (path.startsWith("/")) {
                path = path.substring(1);
            }
            if (path.endsWith("/")) {
                path = path.substring(0, path.length()-1);
            }
            if (path.length() > 0) {
                resourceName = path+"/"+resourceName;
            }
        } else {
            resourceName = saasNode.getDisplayName()+"/"+resourceName;
        }
        saasNode = saasNode.getParentNode();
    }
    if (saasNode != null) {
        resourceName = saasNode.getDisplayName()+" ["+resourceName+"]"; //NOI18N
    }
    return resourceName;
}
 
Example 14
Source Project: netbeans   File: CategoryNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName() {

    String retValue = null;
    DataFolder folder = (DataFolder)getCookie( DataFolder.class );
    if( null != folder ) {
        FileObject fob = folder.getPrimaryFile();
        Object catName = fob.getAttribute( CAT_NAME );
        if (catName instanceof String)
            retValue = catName.toString();
    } 
    if( null == retValue ) {
        retValue = super.getDisplayName();
    }
    // XXX poor impl; should not depend on org.openide.loaders.Bundle#FMT_shadowName:
    if( null != retValue && retValue.indexOf("\u2192") > 0 ) {
        DataShadow shadow = (DataShadow)getCookie( DataShadow.class );
        if( null != shadow ) {
            DataObject dobj = shadow.getOriginal();
            if( null != dobj ) {
                Node origNode = dobj.getNodeDelegate();
                if( null != origNode && null != origNode.getDisplayName() ) {
                    retValue = origNode.getDisplayName();
                }
            }
        }
    }
    return retValue;
}
 
Example 15
Source Project: netbeans   File: AsynchronousTest.java    License: Apache License 2.0 5 votes vote down vote up
private void inspectNode(Node n) {
    n.getDisplayName();
    n.getHtmlDisplayName();
    n.getShortDescription();
    n.getIcon(BeanInfo.ICON_COLOR_16x16);
    n.canCopy();
    n.canCut();
    n.canRename();
    n.getNewTypes();
    n.getActions(true);
    n.getPreferredAction();
    inspectProperties(n);
}
 
Example 16
Source Project: netbeans   File: HierarchyTopComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String displayName(Node obj) {
    return obj.getDisplayName();
}
 
Example 17
Source Project: netbeans   File: BeanInfoOperator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getDisplayName(TreeNode node) {
    Node n = Visualizer.findNode(node);
    return n.getDisplayName();
}
 
Example 18
Source Project: netbeans   File: CheckRenderer.java    License: Apache License 2.0 4 votes vote down vote up
/** The component returned by HtmlRenderer.Renderer.getTreeCellRendererComponent() */
    
    
    public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        
        Node n = Visualizer.findNode(value);
        Collection<? extends FixDescription> descriptions = n.getLookup().lookupAll(FixDescription.class);
        
        if (!descriptions.isEmpty()) {
            check.setVisible( true );
//            if( description.isSelectable() ) {
                check.setState(getCheckState(descriptions));
//            } else {
//                check.setState( getCheckState( description.getSubs() ));
//            }
        } else {
            check.setVisible(false);
        }
            
        if ( isSelected ) {
            label.setForeground(LIST_FOR_COLORS.getSelectionForeground());
            setOpaque(true);
            setBackground(LIST_FOR_COLORS.getSelectionBackground());
        }
        else {
            label.setForeground(tree.getForeground());
            setOpaque(false);
            //setBackground(tree.getBackground());
        }
        
        String displayName = n.getHtmlDisplayName();
        
        if (displayName != null) {
            if (!displayName.startsWith("<html>"))
                displayName = "<html>" + displayName;
        } else {
            displayName = n.getDisplayName();
        }
        
        label.setText( displayName );
        label.setIcon( new ImageIcon( n.getIcon(BeanInfo.ICON_COLOR_16x16) ) ); // XXX Ask description directly
        
        return this;
        
    }
 
Example 19
Source Project: netbeans   File: ProjectTab.java    License: Apache License 2.0 4 votes vote down vote up
private void performChange(Node [] selectedNodes) {
    String text = "";
    Node projectNode = null;
    if( selectedNodes != null && selectedNodes.length > 0 ) {
        Node selectedNode = selectedNodes[0];
        Node originallySelectedNode = selectedNodes[0];
        Node rootNode = ProjectTab.this.manager.getRootContext();
        while ( selectedNode.getParentNode() != null && !selectedNode.getParentNode().equals(rootNode)) {
            selectedNode = selectedNode.getParentNode();
        }
        projectNode = selectedNode;
        //Tests whether other selected items have same project owner
        if( selectedNodes.length > 1 ) {
            for ( int i = 1; i < selectedNodes.length; i ++) {
                selectedNode = selectedNodes[i];                        
                while ( !selectedNode.getParentNode().equals(rootNode) ) {
                    selectedNode = selectedNode.getParentNode();
                }
                if ( !projectNode.equals(selectedNode) ) {
                    projectNode = null;
                    text = Bundle.MSG_nodes_from_more_projects();
                    break;
                }
            }
        }
        if ( projectNode != null ) {
            ProjectTab.this.btv.showOrHideNodeSelectionProjectPanel(projectNode, originallySelectedNode);
            text = projectNode.getDisplayName();
        }
    } else {
        text = Bundle.MSG_none_node_selected();
    }
    if ( this.actualProjectLabel != null ) {
        this.actualProjectLabel.setText(text);
        setSelectionLabelProperties(projectNode);
    } else {
        this.actualProjectLabel = new JLabel(text);
        setSelectionLabelProperties(projectNode);
        this.selectionsProjectPanel.add(actualProjectLabel);
    }
}
 
Example 20
Source Project: netbeans   File: SectionPanel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new section panel whose title will be set to display name
 * of the given <code>explorerNode</code>.
 * @param sectionView the section view for this panel
 * @param explorerNode the node for this panel
 * @param key the key that identifies the panel
 * @param autoExpand defines whether the section should be expanded by default
 */
public SectionPanel(SectionView sectionView, Node explorerNode, Object key, boolean autoExpand) {
    this(sectionView, explorerNode, explorerNode.getDisplayName(), key, autoExpand);
}