Search in sources :

Example 41 with StyledString

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

the class LabelProviderUtils method getStyledText.

/**
 * @param dockerContainer
 *            the {@link IDockerContainer} to process
 * @return the {@link StyledString} to be displayed.
 */
public static StyledString getStyledText(final IDockerContainer dockerContainer) {
    final StyledString styledString = new StyledString();
    styledString.append(dockerContainer.name());
    if (dockerContainer.image() != null && !dockerContainer.image().isEmpty()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        styledString.append(// $NON-NLS-1$ //$NON-NLS-2$
        " (" + dockerContainer.image() + ")", StyledString.QUALIFIER_STYLER);
    }
    return styledString;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

Example 42 with StyledString

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

the class StyledConsoleLogsTest method getData.

// don't use name = "{0}" to display the unit test name, as it
@Parameters()
public static Object[][] getData() {
    final ParametersBuilder parametersBuilder = new ParametersBuilder();
    parametersBuilder.add(ESC + "[33mcontainerid|" + ESC + "[0mstandard_content", new StyledString().append("containerid|", StylerBuilder.styler(33)).append("standard_content", StylerBuilder.defaultStyler()));
    parametersBuilder.add("prefix_content" + ESC + "[33mcontainerid|" + ESC + "[0mstandard_content", new StyledString().append("prefix_content", StylerBuilder.defaultStyler()).append("containerid|", StylerBuilder.styler(33)).append("standard_content", StylerBuilder.defaultStyler()));
    parametersBuilder.add(ESC + "[33merror_content", new StyledString().append("error_content", StylerBuilder.styler(33)));
    parametersBuilder.add(ESC + "[33mcontainerid|" + ESC + "[0mstandard_content1" + ESC + "[34mcolorized_content" + ESC + "[0mstandard_content2", new StyledString().append("containerid|", StylerBuilder.styler(33)).append("standard_content1", StylerBuilder.defaultStyler()).append("colorized_content", StylerBuilder.styler(34)).append("standard_content2", StylerBuilder.defaultStyler()));
    parametersBuilder.add(ESC + "[33mcontainerid|" + ESC + "[0mstandard_content1" + ESC + "[34mcolorized_content" + ESC + "[0mstandard_content2" + ESC + "[35mcolorized_content2", new StyledString().append("containerid|", StylerBuilder.styler(33)).append("standard_content1", StylerBuilder.defaultStyler()).append("colorized_content", StylerBuilder.styler(34)).append("standard_content2", StylerBuilder.defaultStyler()).append("colorized_content2", StylerBuilder.styler(35)));
    parametersBuilder.add(ESC + "[0m" + ESC + "[33merror_content", new StyledString().append("", StylerBuilder.defaultStyler()).append("error_content", StylerBuilder.styler(33)));
    parametersBuilder.add(ESC + "[0m", new StyledString().append("", StylerBuilder.defaultStyler()));
    return parametersBuilder.build();
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) Parameters(org.junit.runners.Parameterized.Parameters)

Example 43 with StyledString

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

the class RepoTemplateLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    if (element instanceof Category) {
        Category cat = (Category) element;
        cell.setText(cat.getName());
        cell.setImage(IMG_FOLDER);
    } else if (element instanceof Template) {
        Template template = (Template) element;
        // Name
        StyledString label = new StyledString(template.getName(), BoldStyler.INSTANCE_DEFAULT);
        // Version, with all segments except qualifier in bold
        Version version = template.getVersion();
        if (version != null) {
            label.append(" ");
            label.append(String.format("%d.%d.%d", version.getMajor(), version.getMinor(), version.getMicro()), BoldStyler.INSTANCE_COUNTER);
            String q = version.getQualifier();
            if (q != null && !q.isEmpty())
                label.append("." + q, StyledString.COUNTER_STYLER);
        }
        String description = template.getShortDescription();
        if (description != null) {
            label.append(" — [", StyledString.QUALIFIER_STYLER).append(template.getShortDescription(), StyledString.QUALIFIER_STYLER).append("]", StyledString.QUALIFIER_STYLER);
        }
        cell.setText(label.toString());
        cell.setStyleRanges(label.getStyleRanges());
        Image image = loadedImages.get(template);
        if (image == null)
            cell.setImage(defaultIcon);
        else
            cell.setImage(image);
    }
}
Also used : Category(org.bndtools.templating.Category) Version(org.osgi.framework.Version) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) Template(org.bndtools.templating.Template)

Example 44 with StyledString

use of org.eclipse.jface.viewers.StyledString in project yamcs-studio by yamcs.

the class StackedCommand method toStyledString.

public StyledString toStyledString(CommandStackView styleProvider) {
    Styler identifierStyler = styleProvider != null ? styleProvider.getIdentifierStyler(this) : null;
    Styler bracketStyler = styleProvider != null ? styleProvider.getBracketStyler(this) : null;
    Styler argNameSyler = styleProvider != null ? styleProvider.getArgNameStyler(this) : null;
    Styler errorStyler = styleProvider != null ? styleProvider.getErrorStyler(this) : null;
    Styler numberStyler = styleProvider != null ? styleProvider.getNumberStyler(this) : null;
    StyledString str = new StyledString();
    str.append(getSelectedAlias(), identifierStyler);
    str.append("(", bracketStyler);
    boolean first = true;
    for (ArgumentInfo arg : meta.getArgumentList()) {
        String value = getAssignedStringValue(arg);
        if (value == null && arg.hasInitialValue())
            continue;
        if (!first)
            str.append("\n, ", bracketStyler);
        first = false;
        str.append(arg.getName() + ": ", argNameSyler);
        if (value == null) {
            str.append("  ", errorStyler);
        } else {
            boolean needQuotationMark = ArgumentTableBuilder.STRING.equals(arg.getType().getEngType()) || ArgumentTableBuilder.ENUM.equals(arg.getType().getEngType());
            if (needQuotationMark)
                str.append("\"", isValid(arg) ? numberStyler : errorStyler);
            str.append(value, isValid(arg) ? numberStyler : errorStyler);
            if (needQuotationMark)
                str.append("\"", isValid(arg) ? numberStyler : errorStyler);
        }
    }
    str.append(")", bracketStyler);
    return str;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Styler(org.eclipse.jface.viewers.StyledString.Styler) ArgumentInfo(org.yamcs.protobuf.Mdb.ArgumentInfo)

Example 45 with StyledString

use of org.eclipse.jface.viewers.StyledString in project yamcs-studio by yamcs.

the class CommandSourceColumnLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    StackedCommand cmd = (StackedCommand) cell.getElement();
    StyledString str = cmd.toStyledString(styleProvider);
    cell.setText(str.toString());
    cell.setImage(cmd.isValid() ? null : errorImage);
    cell.setStyleRanges(str.getStyleRanges());
    super.update(cell);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

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