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;
}
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();
}
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);
}
}
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;
}
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);
}
Aggregations