use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class ResolutionTreeLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
StyledString label = new StyledString();
Image icon = null;
if (element instanceof ResolutionTreeItem) {
ResolutionTreeItem item = (ResolutionTreeItem) element;
R5LabelFormatter.appendCapability(label, item.getCapability(), shortenNamespaces);
// Get the icon from the capability namespace
icon = getImage(R5LabelFormatter.getNamespaceImagePath(item.getCapability().getNamespace()), true);
} else if (element instanceof Requirement) {
Requirement requirement = (Requirement) element;
if (Namespace.RESOLUTION_OPTIONAL.equals(requirement.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE)))
label.append(" OPTIONALLY", StyledString.QUALIFIER_STYLER);
label.append(" REQUIRED BY ", StyledString.QUALIFIER_STYLER);
Resource resource = requirement.getResource();
if (resource != null)
R5LabelFormatter.appendResourceLabel(label, resource);
else
label.append(" INITIAL");
label.append(" [", StyledString.QUALIFIER_STYLER);
boolean first = true;
for (Entry<String, String> entry : requirement.getDirectives().entrySet()) {
String key = entry.getKey();
if (!key.equals(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE)) {
if (!first)
label.append(",", StyledString.QUALIFIER_STYLER);
first = false;
label.append(key + ":=" + entry.getValue(), StyledString.QUALIFIER_STYLER);
}
}
label.append("]", StyledString.QUALIFIER_STYLER);
}
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(icon);
}
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);
}
Aggregations