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

The following examples show how to use org.openide.nodes.Node#getHtmlDisplayName() . 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: BreadCrumbComponent.java    License: Apache License 2.0 6 votes vote down vote up
private void configureForNode(Node node) {
    renderer.reset();
    
    Image nodeIcon = node.getIcon(BeanInfo.ICON_COLOR_16x16);
    Icon icon = nodeIcon != null && nodeIcon != BreadcrumbsController.NO_ICON ? ImageUtilities.image2Icon(nodeIcon) : null;
    int width = icon != null ? icon.getIconWidth() : 0;
    if (width > 0) {
        renderer.setIcon(icon);
        renderer.setIconTextGap(ICON_TEXT_SEPARATOR);
    } else {
        renderer.setIcon(null);
        renderer.setIconTextGap(0);
    }
    String html = node.getHtmlDisplayName();
    if (html != null) {
        renderer.setHtml(true);
        renderer.setText(html);
    } else {
        renderer.setHtml(false);
        renderer.setText(node.getDisplayName());
    }
    renderer.setFont(getFont());
}
 
Example 2
Source Project: netbeans   File: DiffUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Makes an HTML display name for the given node, if the node should be
 * rendered with a non-default font and/or color. The returned string
 * (if non-{@code null}) does not contain the leading
 * {@code "<html>"} string that in many cases neccessary
 * if the HTML markup should be interpreted during rendering.
 *
 * @param  node  node to make a display name for
 * @param  fileModified  {@code true} if the file represented by the node
 *                       is modified (contains unsaved changes)
 * @param  selected  if the node is selected (in a table, in a tree, ...)
 * @return  string with HTML markups included,
 *          or {@code null} if no HTML markup is neccessary
 * @since 1.9.1
 */
public static String getHtmlDisplayName(Node node,
                                        boolean fileModified,
                                        boolean selected) {
    boolean bold = fileModified;
    boolean colored = !selected;

    if (!bold && !colored) {
        return null;            //no HTML markup necessary
    }

    String normal = colored ? node.getHtmlDisplayName()
                            : node.getName();
    return bold ? makeBold(normal)
                : normal;
}
 
Example 3
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 4
Source Project: netbeans   File: BookmarkNodeRenderer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    Icon icon = null;
    BookmarksTableModel model = (BookmarksTableModel) table.getModel();
    BookmarkNode bNode = model.getEntry(row);
    BookmarkInfo bookmark = bNode.getBookmarkInfo();
    Node fNode = bNode.getParentNode();
    if (fNode != null) {
        if (!isSelected) {
            String text = fNode.getHtmlDisplayName();
            if (text != null) {
                text = bookmark.getDescription(text, forHistoryPopup, forHistoryPopup, true);
                setText("<html>" + text + "</html>");
            } // else leave original text set by "super"
        }
        Image image = fNode.getIcon(BeanInfo.ICON_COLOR_16x16);
        if (image != null) {
            icon = ImageUtilities.image2Icon(image);
        }
    }
    setIcon(icon);
    return this;

}
 
Example 5
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 6
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 7
Source Project: netbeans   File: NodeRenderDataProvider.java    License: Apache License 2.0 5 votes vote down vote up
public boolean isHtmlDisplayName(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());
    }
    return null != n.getHtmlDisplayName();
}
 
Example 8
Source Project: netbeans   File: AsynchronousTest.java    License: Apache License 2.0 5 votes vote down vote up
public void run() {
    OutlineTable tt = (OutlineTable) Models.createView(mcm);
    Node root = tt.getExplorerManager ().getRootContext ();

    root.getChildren().getNodes();
    root.getHtmlDisplayName();
    root.getShortDescription();
    for (Node n : root.getChildren().getNodes()) {
        inspectNode(n);
        for (Node nn : n.getChildren().getNodes()) {
            inspectNode(nn);
        }
    }
}
 
Example 9
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 10
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;
        
    }