Search in sources :

Example 1 with NodeIconProvider

use of org.eclipse.che.ide.project.node.icon.NodeIconProvider in project che by eclipse.

the class ResourceNode method updatePresentation.

@Override
public void updatePresentation(@NotNull NodePresentation presentation) {
    final StringBuilder cssBuilder = new StringBuilder();
    final Optional<Marker> presentableTextMarker = getData().getMarker(PresentableTextMarker.ID);
    if (presentableTextMarker.isPresent() && getData() instanceof Container) {
        presentation.setPresentableText(((PresentableTextMarker) presentableTextMarker.get()).getPresentableText());
    } else {
        presentation.setPresentableText(getData().getName());
    }
    if (resourceIsCut) {
        cssBuilder.append("opacity:0.5;");
    } else {
        cssBuilder.append("opacity:1;");
    }
    SVGResource icon = null;
    for (NodeIconProvider iconProvider : nodeIconProviders) {
        icon = iconProvider.getIcon(getData());
        if (icon != null) {
            break;
        }
    }
    if (icon != null) {
        presentation.setPresentableIcon(icon);
    } else {
        if (getData().getResourceType() == FOLDER) {
            presentation.setPresentableIcon(getData().getName().startsWith(".") ? nodesResources.hiddenSimpleFolder() : nodesResources.simpleFolder());
        } else if (getData().getResourceType() == PROJECT) {
            presentation.setPresentableIcon(((Project) getData()).isProblem() ? nodesResources.notValidProjectFolder() : nodesResources.projectFolder());
            cssBuilder.append("font-weight:bold;");
        } else if (getData().getResourceType() == FILE) {
            presentation.setPresentableIcon(nodesResources.file());
        }
    }
    presentation.setPresentableTextCss(cssBuilder.toString());
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource) Container(org.eclipse.che.ide.api.resources.Container) CutResourceMarker(org.eclipse.che.ide.api.resources.modification.CutResourceMarker) PresentableTextMarker(org.eclipse.che.ide.api.resources.marker.PresentableTextMarker) Marker(org.eclipse.che.ide.api.resources.marker.Marker) NodeIconProvider(org.eclipse.che.ide.project.node.icon.NodeIconProvider)

Aggregations

Container (org.eclipse.che.ide.api.resources.Container)1 Marker (org.eclipse.che.ide.api.resources.marker.Marker)1 PresentableTextMarker (org.eclipse.che.ide.api.resources.marker.PresentableTextMarker)1 CutResourceMarker (org.eclipse.che.ide.api.resources.modification.CutResourceMarker)1 NodeIconProvider (org.eclipse.che.ide.project.node.icon.NodeIconProvider)1 SVGResource (org.vectomatic.dom.svg.ui.SVGResource)1