Search in sources :

Example 6 with SVGResource

use of org.vectomatic.dom.svg.ui.SVGResource 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)

Example 7 with SVGResource

use of org.vectomatic.dom.svg.ui.SVGResource in project che by eclipse.

the class FieldNode method updatePresentation.

/** {@inheritDoc} */
@Override
public void updatePresentation(@NotNull NodePresentation presentation) {
    StringBuilder presentableName = new StringBuilder(field.getElementName());
    if (isShowInheritedMembers) {
        String path = field.getRootPath();
        String className = field.isBinary() ? path.substring(path.lastIndexOf('.') + 1) : path.substring(path.lastIndexOf('/') + 1, path.indexOf('.'));
        presentableName.append(" -> ").append(className);
    }
    updatePresentationField(isFromSuper, presentation, presentableName.toString(), resources);
    int flag = field.getFlags();
    SVGResource icon;
    if (Flags.isPublic(flag)) {
        icon = resources.publicMethod();
    } else if (Flags.isPrivate(flag)) {
        icon = resources.privateMethod();
    } else if (Flags.isProtected(flag)) {
        icon = resources.protectedMethod();
    } else {
        icon = resources.publicMethod();
    }
    presentation.setPresentableIcon(icon);
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource)

Example 8 with SVGResource

use of org.vectomatic.dom.svg.ui.SVGResource in project che by eclipse.

the class InitializerNode method updatePresentation.

/** {@inheritDoc} */
@Override
public void updatePresentation(@NotNull NodePresentation presentation) {
    updatePresentationField(isFromSuper, presentation, initializer.getLabel(), resources);
    SVGResource icon;
    int flag = initializer.getFlags();
    if (Flags.isPublic(flag)) {
        icon = resources.publicMethod();
    } else if (Flags.isPrivate(flag)) {
        icon = resources.privateMethod();
    } else if (Flags.isProtected(flag)) {
        icon = resources.protectedMethod();
    } else {
        icon = resources.publicMethod();
    }
    presentation.setPresentableIcon(icon);
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource)

Example 9 with SVGResource

use of org.vectomatic.dom.svg.ui.SVGResource in project che by eclipse.

the class TypeNode method updatePresentation.

/** {@inheritDoc} */
@Override
public void updatePresentation(@NotNull NodePresentation presentation) {
    StringBuilder presentableName = new StringBuilder(type.getLabel());
    if (isShowInheritedMembers && !type.isPrimary()) {
        String path = type.getRootPath();
        String className = type.isBinary() ? path.substring(path.lastIndexOf('.') + 1) : path.substring(path.lastIndexOf('/') + 1, path.indexOf('.'));
        presentableName.append(" -> ").append(className);
    }
    updatePresentationField(isFromSuper, presentation, presentableName.toString(), resources);
    int flags = type.getFlags();
    SVGResource icon;
    if (Flags.isInterface(flags)) {
        icon = resources.interfaceItem();
    } else if (Flags.isEnum(flags)) {
        icon = resources.enumItem();
    } else if (Flags.isAnnotation(flags)) {
        icon = resources.annotationItem();
    } else {
        icon = resources.javaFile();
    }
    presentation.setPresentableIcon(icon);
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource)

Example 10 with SVGResource

use of org.vectomatic.dom.svg.ui.SVGResource in project che by eclipse.

the class NotificationContainerItem method getIconBaseOnStatus.

/**
     * Return an icon based on {@link org.eclipse.che.ide.api.notification.StatusNotification.Status}.
     *
     * @return SVG image that represents icon status
     */
private SVGImage getIconBaseOnStatus() {
    final SVGResource icon;
    final String status;
    switch(((StatusNotification) notification).getStatus()) {
        case PROGRESS:
            icon = resources.progress();
            status = "progress";
            break;
        case SUCCESS:
            icon = resources.success();
            status = "success";
            break;
        case FAIL:
            icon = resources.fail();
            status = "fail";
            break;
        case WARNING:
            icon = resources.warning();
            status = "warning";
            break;
        default:
            throw new IllegalArgumentException("Can't determine notification icon");
    }
    SVGImage image = new SVGImage(icon);
    image.getElement().setAttribute("name", status);
    return image;
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Aggregations

SVGResource (org.vectomatic.dom.svg.ui.SVGResource)13 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)4 Element (elemental.dom.Element)2 DivElement (elemental.html.DivElement)2 SpanElement (elemental.html.SpanElement)2 TreeNodeElement (org.eclipse.che.ide.ui.tree.TreeNodeElement)2 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)1 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 Test (org.junit.Test)1