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

The following examples show how to use org.openide.nodes.Node#getDisplayName() . 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: PropertiesOpen.java    From netbeans with 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 2
Source File: BasicTest.java    From netbeans with 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 3
Source File: ViewTest.java    From netbeans with 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 4
Source File: FileTreeView.java    From netbeans with 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 5
Source File: ResourceBundleBrandingPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 6
Source File: AsynchronousTest.java    From netbeans with 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 7
Source File: CategoryNode.java    From netbeans with 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 8
Source File: RESTResourcesPanel.java    From netbeans with 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 9
Source File: InternationalizationResourceBundleBrandingPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 10
Source File: PackageViewTest.java    From netbeans with 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 11
Source File: LayerUtilsTest.java    From netbeans with 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 12
Source File: SettingChildren.java    From netbeans with 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 13
Source File: InstanceNodeTest.java    From netbeans with 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 14
Source File: NodeRenderDataProvider.java    From netbeans with 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 15
Source File: FormEditorSupport.java    From netbeans with 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 16
Source File: ProjectTab.java    From netbeans with 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 17
Source File: CheckRenderer.java    From netbeans with 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 18
Source File: BeanInfoOperator.java    From netbeans with 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 19
Source File: HierarchyTopComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public String displayName(Node obj) {
    return obj.getDisplayName();
}
 
Example 20
Source File: SectionPanel.java    From netbeans with 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);
}