Java Code Examples for org.netbeans.api.project.SourceGroup#getDisplayName()

The following examples show how to use org.netbeans.api.project.SourceGroup#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: ClassPathFileChooser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Node createPackageRootNode(FileObject rootFO, Project project, Filter filter) {
    Node origNode;
    try {
        origNode = DataObject.find(rootFO).getNodeDelegate();
    }
    catch (DataObjectNotFoundException ex) {
        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
        return null;
    }

    String displayName;
    Project owner = FileOwnerQuery.getOwner(rootFO);
    if (owner != null) {
        SourceGroup g = getSourceGroup(rootFO, owner);
        displayName = g != null ? g.getDisplayName() : FileUtil.getFileDisplayName(rootFO);
        if (project != owner) {
            ProjectInformation pi = ProjectUtils.getInformation(owner);
            displayName += " [" + pi.getDisplayName() + "]"; // NOI18N
        }
    }
    else displayName = FileUtil.getFileDisplayName(rootFO);

    return new FilteredNode(origNode, displayName, filter);

}
 
Example 2
Source File: TestDataDirsNodeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Node node(final SourceGroup key) {
    try {
        Node nodeDelegate = DataObject.find(key.getRootFolder()).getNodeDelegate();
        return new FilterNode(nodeDelegate,
                null, new ProxyLookup(nodeDelegate.getLookup(), Lookups.singleton(new PathFinder(key)))) {
            @Override
            public String getName() {
                return key.getName();
            }
            @Override
            public String getDisplayName() {
                return key.getDisplayName();
            }
        };
    } catch (DataObjectNotFoundException ex) {
        throw new AssertionError(ex);
    }
}
 
Example 3
Source File: SimpleTestStepLocation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
private static String getSrcGrpDisp(SourceGroup srcGroup) {
    if (srcGroup == null) {
        return "";                                                  //NOI18N
    } else {
        String srcGroupName = srcGroup.getDisplayName();
        return new StringBuffer(srcGroupName.length() + 3)
               .append(' ')
               .append('(').append(srcGroupName).append(')')
               .toString();
    }
}
 
Example 4
Source File: SelectorUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String getDisplayName(FileObject fo, Project owner, boolean incPrjName) {
    if (owner != null) {
        SourceGroup grp = getSourceGroup(fo, owner);
        String n = (grp!=null)?grp.getDisplayName():FileUtil.getFileDisplayName(fo);
        if (incPrjName) {
            ProjectInformation pi = ProjectUtils.getInformation(owner);
            n  += " [" + pi.getDisplayName() + "]";
        }
        return n;
    } else 
        return FileUtil.getFileDisplayName(fo);
}
 
Example 5
Source File: CompositeComponentVisualPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (value instanceof SourceGroup) {
        SourceGroup group = (SourceGroup) value;
        String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
        String groupDisplayName = group.getDisplayName();
        if (projectDisplayName.equals(groupDisplayName)) {
            setText(groupDisplayName);
        } else {
            setText(MessageFormat.format("{1} - {0}", //NOI18N
                    new Object[]{groupDisplayName, projectDisplayName, group.getRootFolder().getName()}));
        }

        setIcon(group.getIcon(false));
    } else {
        setText(value.toString());
        setIcon(null);
    }
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());

    }
    return this;
}
 
Example 6
Source File: MultiTargetChooserPanelGUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    SourceGroup g = (SourceGroup) value;
    if (g != null) {
        super.getListCellRendererComponent(list, g.getDisplayName(), index, isSelected, cellHasFocus);
        setIcon(g.getIcon(false));
    }
    return this;
}
 
Example 7
Source File: SimpleTargetChooserPanelGUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (value instanceof SourceGroup) {
        SourceGroup group = (SourceGroup)value;
        String projectDisplayName = ProjectUtils.getInformation( project ).getDisplayName();
        String groupDisplayName = group.getDisplayName();
        if ( projectDisplayName.equals( groupDisplayName ) ) {
            setText( groupDisplayName );
        }
        else {
            setText(FMT_PhysicalView_GroupName(
                    groupDisplayName, projectDisplayName, group.getRootFolder().getName()));
        }
        
        setIcon( group.getIcon( false ) );
    } 
    else {
        setText( value.toString () );
        setIcon( null );
    }
    if ( isSelected ) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());             
    }
    else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
     
    }
    return this;        
}
 
Example 8
Source File: ResNodeFactoryProvider.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public Node createNode(Project p, SourceGroup sg) {
    try {
        DataObject dobj = DataObject.find(sg.getRootFolder());
        Node node = cache.get(dobj);
        if (node == null) {
            node = new AndroidResourceNode(dobj.getNodeDelegate(), p, sg.getDisplayName());
            cache.put(dobj, node);
        }
        return node;
    } catch (DataObjectNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }
    return null;
}
 
Example 9
Source File: GrailsTargetChooserPanelGUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    SourceGroup g = (SourceGroup) value;
    super.getListCellRendererComponent(list, g.getDisplayName(), index, isSelected, cellHasFocus);
    setIcon(g.getIcon(false));
    return this;
}