use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class CapabilityLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Capability cap = (Capability) cell.getElement();
StyledString label = new StyledString();
R5LabelFormatter.appendCapability(label, cap, shortenNamespaces);
cell.setText(label.toString());
cell.setStyleRanges(label.getStyleRanges());
// Get the icon from the capability namespace
Image icon = getImage(R5LabelFormatter.getNamespaceImagePath(cap.getNamespace()), true);
if (icon != null)
cell.setImage(icon);
}
use of org.eclipse.jface.viewers.StyledString in project bndtools by bndtools.
the class VersionedClauseLabelProvider method update.
@Override
public void update(ViewerCell cell) {
aQute.bnd.build.model.clauses.VersionedClause clause = (aQute.bnd.build.model.clauses.VersionedClause) cell.getElement();
StyledString label = new StyledString(clause.getName());
String version = clause.getVersionRange();
if (version != null) {
label.append(" " + version, StyledString.COUNTER_STYLER);
}
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
use of org.eclipse.jface.viewers.StyledString in project AutoRefactor by JnRouvignac.
the class ChooseRefactoringWizardPage method createRefactoringsTable.
private void createRefactoringsTable(Composite parent) {
tableViewer = newCheckList(parent, BORDER | H_SCROLL | CHECK | NO_FOCUS | HIDE_SELECTION);
createColumns(tableViewer);
tableViewer.setContentProvider(new ArrayContentProvider());
final List<RefactoringRule> refactorings = AllRefactoringRules.getAllRefactoringRules();
tableViewer.setInput(refactorings);
tableViewer.setCheckStateProvider(new CheckStateProvider(refactorings));
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
return ((RefactoringRule) o1).getName().compareTo(((RefactoringRule) o2).getName());
}
});
tableViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object refactoring) {
final String filter = filterText.getText().toLowerCase();
final RefactoringRule rule = (RefactoringRule) refactoring;
final String description = rule.getDescription().toLowerCase();
final String name = rule.getName().toLowerCase();
return description.contains(filter) || name.contains(filter);
}
});
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
tableViewer.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
final String filter = filterText.getText().toLowerCase();
final String name = ((RefactoringRule) cell.getElement()).getName();
cell.setText(name);
cell.setStyleRanges(getStyleRanges(name, filter));
}
private StyleRange[] getStyleRanges(String text, String filter) {
final int matchIndex = text.toLowerCase().indexOf(filter);
final int matchLength = filter.length();
if (matchIndex != -1 && matchLength != 0) {
final StyledString styledString = new StyledString(text, defaultStyler);
styledString.setStyle(matchIndex, matchLength, underlineStyler);
return styledString.getStyleRanges();
}
return null;
}
@Override
public String getToolTipText(Object refactoring) {
return ((RefactoringRule) refactoring).getDescription();
}
@Override
public Point getToolTipShift(Object object) {
return new Point(10, 20);
}
});
final Table table = tableViewer.getTable();
table.setLinesVisible(false);
tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
packColumns(table);
table.setFocus();
}
use of org.eclipse.jface.viewers.StyledString in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup2 method setProposals.
/**
* Initializes the proposal selector with these given proposals.
*
* @param proposals the proposals
*/
private void setProposals(ICompletionProposal[] proposals) {
if (Helper2.okToUse(fProposalTable)) {
ICompletionProposal oldProposal = getSelectedProposal();
if (oldProposal instanceof ICompletionProposalExtension2)
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
fFilteredProposals = proposals;
int selectionIndex = 0;
fProposalTable.setRedraw(false);
try {
fProposalTable.removeAll();
Point selection = fViewer.getSelectedRange();
int endOffset;
endOffset = selection.x + selection.y;
IDocument document = fViewer.getDocument();
boolean validate = false;
if (selection.y != 0 && document != null)
validate = true;
TableItem item;
ICompletionProposal p;
for (int i = 0; i < proposals.length; i++) {
p = proposals[i];
item = new TableItem(fProposalTable, SWT.NULL);
if (p.getImage() != null)
item.setImage(p.getImage());
String displayString;
StyleRange[] styleRanges = null;
if (fIsColoredLabelsSupportEnabled && p instanceof ICompletionProposalExtension6) {
StyledString styledString = ((ICompletionProposalExtension6) p).getStyledDisplayString();
displayString = styledString.getString();
styleRanges = styledString.getStyleRanges();
} else
displayString = p.getDisplayString();
item.setText(displayString);
if (fIsColoredLabelsSupportEnabled)
TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
item.setData(p);
if (validate && validateProposal(document, p, endOffset, null)) {
selectionIndex = i;
validate = false;
}
}
} finally {
fProposalTable.setRedraw(true);
}
resizeProposalSelector(false);
selectProposal(selectionIndex, false);
}
}
use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.
the class JvmOutlineTests method testActiveAnnotation.
@Test
public void testActiveAnnotation() throws Exception {
InputStream inputStream = JvmOutlineTests.class.getResourceAsStream("TestAA.txt");
String model = Files.readStreamIntoString(inputStream);
XtendFile aaXtendFile = getWorkbenchTestHelper().xtendFile("aatest/TestAA.xtend", model);
WorkbenchTestHelper.addExportedPackages(getWorkbenchTestHelper().getProject(), "aatest");
AssertBuilder aaFile = newAssertBuilder(aaXtendFile).numChildren(4);
aaFile.child(0, "aatest");
aaFile.child(1, "import declarations");
aaFile.child(2, "TestAAnnotation");
aaFile.child(3, "TestAAProcessor");
List<String> deps = newArrayList(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES);
deps.add(WorkbenchTestHelper.TESTPROJECT_NAME);
final IProject clientProj = WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME + "-client", Iterables.toArray(deps, String.class));
IResourcesSetupUtil.waitForBuild();
XtendFile xtendFile = getWorkbenchTestHelper().xtendFile(clientProj, "clienttest/TestAAClient.xtend", "package clienttest @aatest.TestAAnnotation class AAOutlineTest { override void myPublicMethod() {}}");
AssertBuilder clientAAFile = newAssertBuilder(xtendFile).numChildren(3);
clientAAFile.leaf(0, "clienttest");
clientAAFile.child(1, "AAOutlineTest").leaf(0, "myPublicMethod() : void");
StyledString styledString = new StyledString("AAOutlineTestInterface - clienttest.test", StyledString.QUALIFIER_STYLER);
AssertBuilder createdtype = clientAAFile.child(2, styledString).numChildren(1);
createdtype.child(0, new StyledString("myPublicMethod()", StyledString.QUALIFIER_STYLER).append(" : void", StyledString.DECORATIONS_STYLER));
WorkbenchTestHelper.deleteProject(clientProj);
}
Aggregations