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