Search in sources :

Example 1 with PresentableTextMarker

use of org.eclipse.che.ide.api.resources.marker.PresentableTextMarker in project che by eclipse.

the class PomInterceptor method intercept.

/** {@inheritDoc} */
@Override
public void intercept(Resource resource) {
    if (resource.isFile() && POM_XML.equals(resource.getName())) {
        final Optional<Project> project = resource.getRelatedProject();
        if (!project.isPresent() || !project.get().isTypeOf(MAVEN_ID)) {
            return;
        }
        final String artifact = project.get().getAttribute(ARTIFACT_ID);
        if (!isNullOrEmpty(artifact)) {
            resource.addMarker(new PresentableTextMarker(artifact));
        }
    }
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PresentableTextMarker(org.eclipse.che.ide.api.resources.marker.PresentableTextMarker)

Example 2 with PresentableTextMarker

use of org.eclipse.che.ide.api.resources.marker.PresentableTextMarker 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

PresentableTextMarker (org.eclipse.che.ide.api.resources.marker.PresentableTextMarker)2 Container (org.eclipse.che.ide.api.resources.Container)1 Project (org.eclipse.che.ide.api.resources.Project)1 Marker (org.eclipse.che.ide.api.resources.marker.Marker)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