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

The following are Jave code examples for showing how to use getDisplayName() of the org.openide.nodes.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: FileTreeView.java   Source Code and License Vote up 6 votes
@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 2
Project: incubator-netbeans   File: BasicTest.java   Source Code and License Vote up 6 votes
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 3
Project: incubator-netbeans   File: PropertiesOpen.java   Source Code and License Vote up 6 votes
/**
 * 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 4
Project: incubator-netbeans   File: ViewTest.java   Source Code and License Vote up 6 votes
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 5
Project: incubator-netbeans   File: PackageViewTest.java   Source Code and License Vote up 5 votes
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
Project: incubator-netbeans   File: LayerUtilsTest.java   Source Code and License Vote up 5 votes
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 7
Project: incubator-netbeans   File: ResourceBundleBrandingPanel.java   Source Code and License Vote up 5 votes
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 8
Project: incubator-netbeans   File: InternationalizationResourceBundleBrandingPanel.java   Source Code and License Vote up 5 votes
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 9
Project: incubator-netbeans   File: NodeRenderDataProvider.java   Source Code and License Vote up 5 votes
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 10
Project: incubator-netbeans   File: CategoryNode.java   Source Code and License Vote up 5 votes
@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 11
Project: incubator-netbeans   File: TemplateWizard1.java   Source Code and License Vote up 5 votes
/** Creates nodes for nodes.
 */
@Override
protected Node[] createNodes(Node key) {
    Node n = key;
    String nodeName = n.getDisplayName();
    
    DataObject obj = null;
    DataShadow shadow = n.getCookie(DataShadow.class);
    if (shadow != null) {
        // I need DataNode here to get localized name of the
        // shadow, but without the ugly "(->)" at the end
        DataNode dn = new DataNode(shadow, Children.LEAF);
        nodeName = dn.getDisplayName();
        obj = shadow.getOriginal();
        n = obj.getNodeDelegate();
    }
    
    if (obj == null)
        obj = n.getCookie(DataObject.class);
    
    if (obj != null) {
        if (obj.isTemplate ()) {
            // on normal nodes stop recursion
            return new Node[] { new DataShadowFilterNode (n, Children.LEAF, nodeName) };
        }
    
        if (acceptDataObject (obj)) {
            // on folders use normal filtering
            return new Node[] { new DataShadowFilterNode (n, new DataShadowFilterChildren (n), nodeName) };
        }
    }
    return new Node[] {};
}
 
Example 12
Project: incubator-netbeans   File: InstanceNodeTest.java   Source Code and License Vote up 5 votes
/**
 * 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 13
Project: incubator-netbeans   File: AsynchronousTest.java   Source Code and License Vote up 5 votes
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 14
Project: incubator-netbeans   File: SettingChildren.java   Source Code and License Vote up 5 votes
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 15
Project: incubator-netbeans   File: FormEditorSupport.java   Source Code and License Vote up 5 votes
/**
 * 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 16
Project: incubator-netbeans   File: ProjectTab.java   Source Code and License Vote up 4 votes
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 17
Project: incubator-netbeans   File: HierarchyTopComponent.java   Source Code and License Vote up 4 votes
@Override
public String displayName(Node obj) {
    return obj.getDisplayName();
}
 
Example 18
Project: incubator-netbeans   File: BeanInfoOperator.java   Source Code and License Vote up 4 votes
@Override
public String getDisplayName(TreeNode node) {
    Node n = Visualizer.findNode(node);
    return n.getDisplayName();
}
 
Example 19
Project: incubator-netbeans   File: CheckRenderer.java   Source Code and License Vote up 4 votes
/** 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 20
Project: incubator-netbeans   File: SectionPanel.java   Source Code and License Vote up 2 votes
/**
 * 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);
}