use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class ResolutionChoiceSelectionDialog method createDialogArea.
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Multiple Provider Candidates");
setMessage("Use the candidate list to specify your preferences. Candidates at the top of the list will be preferred by the resolver.");
// Create controls
Composite outer = (Composite) super.createDialogArea(parent);
Composite contents = new Composite(outer, SWT.NONE);
Label lblRequirement = new Label(contents, SWT.NONE);
lblRequirement.setText("Requirement Info");
lblRequirement.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
StyledText txtRequirement = new StyledText(contents, SWT.WRAP | SWT.BORDER);
txtRequirement.setEditable(false);
txtRequirement.setCaret(null);
// txtRequirement.setBackground(contents.getBackground());
txtRequirement.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
new Label(contents, SWT.NONE);
Label lblCandidates = new Label(contents, SWT.NONE);
lblCandidates.setText("Candidates");
lblCandidates.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
Composite lowerPanel = new Composite(contents, SWT.NONE);
Table tbl = new Table(lowerPanel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
viewer = new CheckboxTableViewer(tbl);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new CapabilityLabelProvider());
btnUp = new Button(lowerPanel, SWT.PUSH);
btnUp.setText("Move Up");
btnUp.setEnabled(false);
btnDown = new Button(lowerPanel, SWT.PUSH);
btnDown.setText("Move Down");
btnDown.setEnabled(false);
Composite cmpPreferences = new Composite(contents, SWT.NONE);
btnSavePreference = new Button(cmpPreferences, SWT.CHECK | SWT.WRAP);
txtSavePreference = new StyledText(cmpPreferences, SWT.WRAP);
txtSavePreference.setEditable(false);
txtSavePreference.setCaret(null);
txtSavePreference.setBackground(contents.getBackground());
txtSavePreference.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
// Events
txtSavePreference.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
btnSavePreference.setSelection(!btnSavePreference.getSelection());
}
});
// Load data
StyledString label = createRequirementText();
txtRequirement.setText(label.getString());
txtRequirement.setStyleRanges(label.getStyleRanges());
viewer.setInput(candidates);
updateSavePreferenceText();
// Layout
GridLayout layout;
GridData gd;
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
contents.setLayoutData(gd);
layout = new GridLayout(1, false);
contents.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd.horizontalIndent = 5;
txtRequirement.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
lowerPanel.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
lowerPanel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.widthHint = 450;
gd.heightHint = 250;
tbl.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnUp.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnDown.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
cmpPreferences.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
cmpPreferences.setLayout(layout);
gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
btnSavePreference.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
txtSavePreference.setLayoutData(gd);
return contents;
}
use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class ResolutionChoiceSelectionDialog method createRequirementText.
protected StyledString createRequirementText() {
StyledString label = new StyledString();
label.append("Namespace: ");
label.append(requirement.getNamespace() + "\n", BoldStyler.INSTANCE_DEFAULT);
label.append("Filter: ");
R5LabelFormatter.appendRequirementLabel(label, requirement, false);
label.append("\n");
for (Entry<String, String> entry : requirement.getDirectives().entrySet()) {
String key = entry.getKey();
if (!Namespace.REQUIREMENT_FILTER_DIRECTIVE.equals(key) && !Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE.equals(key))
label.append(" " + key + ":=" + entry.getValue() + "\n");
}
if (Namespace.RESOLUTION_OPTIONAL.equals(requirement.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE)))
label.append("Optionally ", ItalicStyler.INSTANCE_DEFAULT);
label.append("Required by Resource: ");
R5LabelFormatter.appendResourceLabel(label, requirement.getResource());
return label;
}
use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class ResourceLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Resource resource = (Resource) cell.getElement();
StyledString label = new StyledString();
try {
Capability identityCap = ResourceUtils.getIdentityCapability(resource);
String name = ResourceUtils.getIdentity(identityCap);
label.append(name);
Version version = ResourceUtils.getVersion(identityCap);
label.append(" " + version, StyledString.COUNTER_STYLER);
} catch (IllegalArgumentException e) {
label.append("<unknown>");
}
try {
URI uri = ResourceUtils.getURI(ResourceUtils.getContentCapability(resource));
label.append(" [" + uri + "]", StyledString.QUALIFIER_STYLER);
} catch (IllegalArgumentException e) {
// ignore
}
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class PluginClauseLabelProvider method update.
@Override
public void update(ViewerCell cell) {
HeaderClause header = (HeaderClause) cell.getElement();
String className = header.getName();
StyledString label = new StyledString(className);
Map<String, String> attribs = header.getAttribs();
if (!attribs.isEmpty())
label.append(" ");
for (Iterator<Entry<String, String>> iter = attribs.entrySet().iterator(); iter.hasNext(); ) {
Entry<String, String> entry = iter.next();
label.append(entry.getKey(), StyledString.QUALIFIER_STYLER);
label.append("=", StyledString.QUALIFIER_STYLER);
label.append(entry.getValue(), StyledString.COUNTER_STYLER);
if (iter.hasNext())
label.append(", ");
}
cell.setText(label.toString());
cell.setStyleRanges(label.getStyleRanges());
Image image = images.get(className);
if (image == null) {
IConfigurationElement configElem = configElements.get(className);
if (configElem != null) {
String iconPath = configElem.getAttribute("icon");
if (iconPath != null) {
ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configElem.getContributor().getName(), iconPath);
if (descriptor != null) {
image = descriptor.createImage();
images.put(className, image);
}
}
}
}
if (image == null) {
image = images.get("__DEFAULT__");
if (image == null) {
image = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/plugin.png").createImage();
images.put("__DEFAULT__", image);
}
}
cell.setImage(image);
}
use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class PluginDeclarationLabelProvider method update.
@Override
public void update(ViewerCell cell) {
IConfigurationElement element = (IConfigurationElement) cell.getElement();
boolean deprecated = element.getAttribute("deprecated") != null;
Styler mainStyler = deprecated ? new StrikeoutStyler(null) : null;
StyledString label = new StyledString(element.getAttribute("name"), mainStyler);
Styler classStyle = deprecated ? new StrikeoutStyler(StyledString.QUALIFIER_STYLER) : StyledString.QUALIFIER_STYLER;
label.append(" [" + element.getAttribute("class") + "]", classStyle);
cell.setText(label.toString());
cell.setStyleRanges(label.getStyleRanges());
String iconPath = element.getAttribute("icon");
if (iconPath != null) {
ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), iconPath);
if (descriptor != null) {
Image image = descriptor.createImage();
images.add(image);
cell.setImage(image);
}
}
}
Aggregations