use of org.eclipse.jface.viewers.StyledString in project linuxtools by eclipse.
the class DockerImageHierarchyLabelProvider method getStyledText.
/**
* @param image
* the {@link IDockerImage} to process
* @return the {@link StyledString} to be displayed.
*/
public static StyledString getStyledText(final IDockerImage image) {
final Map<String, List<String>> imageTagsByRepo = DockerImage.extractTagsByRepo(image.repoTags());
final List<String> imageRepos = new ArrayList<>(imageTagsByRepo.keySet());
Collections.sort(imageRepos);
final StyledString result = new StyledString();
imageRepos.forEach(repo -> {
result.append(repo);
final List<String> tags = imageTagsByRepo.get(repo);
final String joinedTags = tags.stream().collect(// $NON-NLS-1$
Collectors.joining(", "));
result.append(':');
// $NON-NLS-1$
result.append(joinedTags, StyledString.COUNTER_STYLER);
result.append(' ');
});
// TODO: remove the cast to 'DockerImage' once the 'shortId()'
// method is in the public API
// $NON-NLS-1$
result.append('(', StyledString.QUALIFIER_STYLER).append(((DockerImage) image).shortId(), StyledString.QUALIFIER_STYLER).append(')', // $NON-NLS-1$
StyledString.QUALIFIER_STYLER);
return result;
}
use of org.eclipse.jface.viewers.StyledString in project linuxtools by eclipse.
the class LabelProviderUtils method getStyledText.
/**
* @param mapping
* the {@link IDockerPortMapping} to process
* @return the {@link StyledString} to be displayed.
*/
public static StyledString getStyledText(final IDockerPortMapping mapping) {
final StyledString styledString = new StyledString();
// $NON-NLS-1$
styledString.append(mapping.getIp() + ":" + mapping.getPublicPort()).append(// $NON-NLS-1$
" -> ").append(Integer.toString(mapping.getPrivatePort())).append(// $NON-NLS-1$ //$NON-NLS-2$
" (" + mapping.getType() + ")", StyledString.QUALIFIER_STYLER);
return styledString;
}
use of org.eclipse.jface.viewers.StyledString in project linuxtools by eclipse.
the class LabelProviderUtils method getStyledText.
/**
* @param connection
* the {@link IDockerConnection} to process
* @return the {@link StyledString} to be displayed.
*/
public static StyledString getStyledText(final IDockerConnection connection) {
final String connectionName = (connection.getName() != null && !connection.getName().isEmpty()) ? connection.getName() : // $NON-NLS-1$
DVMessages.getString("Connection.unnamed");
final StyledString styledString = new StyledString();
styledString.append(connectionName);
if (connection.getUri() != null && !connection.getUri().isEmpty()) {
styledString.append(// $NON-NLS-1$
" (" + connection.getUri() + ")", // $NON-NLS-1$
StyledString.QUALIFIER_STYLER);
}
return styledString;
}
use of org.eclipse.jface.viewers.StyledString in project knime-core by knime.
the class RepositoryStyledLabelProvider method update.
@Override
public void update(final ViewerCell cell) {
Object obj = cell.getElement();
if (obj instanceof IRepositoryObject) {
StyledString styledString = new StyledString(m_provider.getText(obj));
if (m_appendCategory) {
// receive the category string.
String categoryString = getCategoryString((IRepositoryObject) obj);
if (!categoryString.isEmpty()) {
styledString.append(String.format("\t - %s", categoryString), StyledString.DECORATIONS_STYLER);
}
}
if (m_appendAdditionalInfoKeys.length > 0) {
if (obj instanceof AbstractRepositoryObject) {
AbstractRepositoryObject aro = (AbstractRepositoryObject) obj;
for (String key : m_appendAdditionalInfoKeys) {
if (aro.getAdditionalInfo(key) != null) {
styledString.append(String.format("\t [%s]", ((AbstractRepositoryObject) obj).getAdditionalInfo(key)), StyledString.QUALIFIER_STYLER);
}
}
}
}
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
} else {
cell.setText(m_provider.getText(obj));
}
cell.setImage(m_provider.getImage(obj));
}
use of org.eclipse.jface.viewers.StyledString in project knime-core by knime.
the class LinkStyleLabelProvider method update.
@Override
public void update(final ViewerCell cell) {
Object element = cell.getElement();
if (element instanceof String) {
// Multi-font support only works in JFace 3.5 and above (specifically, 3.5 M4 and above).
// With JFace 3.4, the font information (bold in this example) will be ignored.
Styler style = linkStyler;
StyledString styledString = new StyledString((String) element, style);
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
} else {
// $NON-NLS-1$
cell.setText("Unknown element");
}
super.update(cell);
}
Aggregations