Search in sources :

Example 61 with StyledString

use of org.eclipse.jface.viewers.StyledString in project KaiZen-OpenAPI-Editor by RepreZen.

the class OutlineStyledLabelProvider method getStyledString.

public StyledString getStyledString(AbstractNode element) {
    StyledString styledString = new StyledString(element.getText(), getTextStyler());
    if (element.getParent() != null && (element.isObject() || element.isArray())) {
        TypeDefinition definition = element.getType();
        String label = null;
        if (definition != null && definition.asJson() != null) {
            if (definition.asJson().has("title")) {
                label = definition.asJson().get("title").asText();
            } else if (definition.getContainingProperty() != null) {
                label = definition.getContainingProperty();
            }
        }
        if (label != null) {
            styledString.append(" ");
            styledString.append(label, getTagStyler());
        }
    } else if (element.getParent() == null) {
        if (element.getModel().getPath() != null) {
            styledString.append(" ");
            styledString.append(element.getModel().getPath().toString(), getTagStyler());
        }
    }
    return styledString;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) TypeDefinition(com.reprezen.swagedit.core.schema.TypeDefinition)

Example 62 with StyledString

use of org.eclipse.jface.viewers.StyledString in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonContentAssistProcessor method getTemplateLabel.

protected StyledString getTemplateLabel(Template template) {
    Styler nameStyle = new StyledString.Styler() {

        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.foreground = new Color(Display.getCurrent(), new RGB(80, 80, 255));
        }
    };
    Styler descriptionStyle = new StyledString.Styler() {

        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.foreground = new Color(Display.getCurrent(), new RGB(120, 120, 120));
        }
    };
    return new StyledString(template.getName(), nameStyle).append(": ", descriptionStyle).append(template.getDescription(), descriptionStyle);
}
Also used : TextStyle(org.eclipse.swt.graphics.TextStyle) Color(org.eclipse.swt.graphics.Color) StyledString(org.eclipse.jface.viewers.StyledString) Styler(org.eclipse.jface.viewers.StyledString.Styler) RGB(org.eclipse.swt.graphics.RGB)

Example 63 with StyledString

use of org.eclipse.jface.viewers.StyledString in project cubrid-manager by CUBRID.

the class NavigatorTreeLabelProvider method getStyledText.

public StyledString getStyledText(Object element) {
    String text = getText(element);
    StyledString styledString = new StyledString(text);
    return styledString;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 64 with StyledString

use of org.eclipse.jface.viewers.StyledString in project tdi-studio-se by Talend.

the class JvmTreeLabelProvider method getStyledText.

/*
     * @see IStyledLabelProvider#getStyledText(Object)
     */
@Override
public StyledString getStyledText(Object element) {
    StyledString text = new StyledString();
    if (element instanceof IJvm) {
        //$NON-NLS-1$
        String prefix = "";
        String mainClass = ((IJvm) element).getMainClass();
        String suffix = getIdInicator((IJvm) element);
        if (element instanceof ITerminatedJvm) {
            //$NON-NLS-1$
            prefix = "<terminated>";
        }
        text.append(prefix).append(mainClass).append(suffix);
        text.setStyle(prefix.length() + mainClass.length(), suffix.length(), StyledString.DECORATIONS_STYLER);
    } else if (element instanceof ISnapshot) {
        String fileName = ((ISnapshot) element).getFileStore().getName();
        text.append(fileName);
        String date = ((ISnapshot) element).getTimeStamp();
        if (date != null) {
            //$NON-NLS-1$ //$NON-NLS-2$
            text.append(" (").append(date).append(")");
        }
    } else {
        text.append(element.toString());
    }
    return text;
}
Also used : ISnapshot(org.talend.designer.runtime.visualization.ISnapshot) IJvm(org.talend.designer.runtime.visualization.IJvm) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) ITerminatedJvm(org.talend.designer.runtime.visualization.ITerminatedJvm)

Example 65 with StyledString

use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.

the class URLLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    Image img;
    String text;
    Object element = cell.getElement();
    if (element instanceof OBRLink) {
        StyledString label = ((OBRLink) element).getLabel();
        cell.setStyleRanges(label.getStyleRanges());
        text = label.getString();
    } else {
        text = (element == null ? "null" : element.toString());
    }
    if (text.startsWith("file:"))
        img = fileImg;
    else
        img = linkImg;
    cell.setText(text);
    cell.setImage(img);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image)

Aggregations

StyledString (org.eclipse.jface.viewers.StyledString)95 Image (org.eclipse.swt.graphics.Image)17 JavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal)8 LazyJavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)8 ViewerCell (org.eclipse.jface.viewers.ViewerCell)5 GridData (org.eclipse.swt.layout.GridData)5 Table (org.eclipse.swt.widgets.Table)5 Entry (java.util.Map.Entry)4 StyledCellLabelProvider (org.eclipse.jface.viewers.StyledCellLabelProvider)4 Styler (org.eclipse.jface.viewers.StyledString.Styler)4 Capability (org.osgi.resource.Capability)4 EObject (org.eclipse.emf.ecore.EObject)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 Version (org.osgi.framework.Version)3 Resource (org.osgi.resource.Resource)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IStatus (org.eclipse.core.runtime.IStatus)2