use of org.eclipse.jface.viewers.DecorationContext in project eclipse.jdt.ui by eclipse-jdt.
the class HierarchicalDecorationContext method getContext.
public static IDecorationContext getContext() {
if (fgContext == null) {
DecorationContext context = new DecorationContext();
context.putProperty(SynchronizationStateTester.PROP_TESTER, new HierarchicalSynchronizationStateTester());
fgContext = context;
}
return fgContext;
}
use of org.eclipse.jface.viewers.DecorationContext in project m2e-core by eclipse-m2e.
the class MavenPomSelectionComponent method init.
public void init(String queryText, String queryType, IProject project, Set<ArtifactKey> artifacts, Set<ArtifactKey> managed) {
this.queryType = queryType;
this.project = project;
if (queryText != null) {
searchText.setText(queryText);
}
if (artifacts != null) {
for (ArtifactKey a : artifacts) {
// $NON-NLS-1$
artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId());
// $NON-NLS-1$ //$NON-NLS-2$
artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion());
}
}
if (managed != null) {
for (ArtifactKey a : managed) {
// $NON-NLS-1$
managedKeys.add(a.getGroupId() + ":" + a.getArtifactId());
// $NON-NLS-1$ //$NON-NLS-2$
managedKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion());
}
}
searchResultViewer.setContentProvider(new SearchResultContentProvider());
SearchResultLabelProvider labelProvider = new SearchResultLabelProvider(artifactKeys, managedKeys);
DecoratingStyledCellLabelProvider decoratingLabelProvider = new DecoratingStyledCellLabelProvider(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
DecorationContext decorationContext = new DecorationContext();
if (project != null) {
decorationContext.putProperty(PROP_DECORATION_CONTEXT_PROJECT, project);
}
decoratingLabelProvider.setDecorationContext(decorationContext);
searchResultViewer.setLabelProvider(decoratingLabelProvider);
searchResultViewer.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (!selection.isEmpty()) {
List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles(selection);
ArtifactFilterManager filterManager = MavenPluginActivator.getDefault().getArifactFilterManager();
for (IndexedArtifactFile file : files) {
ArtifactKey key = file.getAdapter(ArtifactKey.class);
IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
if (!status.isOK()) {
setStatus(IStatus.ERROR, status.getMessage());
// TODO not nice to exit method like this
return;
}
}
if (files.size() == 1) {
IndexedArtifactFile f = files.get(0);
// int severity = artifactKeys.contains(f.group + ":" + f.artifact) ? IStatus.ERROR : IStatus.OK;
int severity = IStatus.OK;
String date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(f.date);
setStatus(severity, NLS.bind(Messages.MavenPomSelectionComponent_detail1, f.fname, (f.size != -1 ? NLS.bind(Messages.MavenPomSelectionComponent_details2, date, f.size) : date)));
} else {
setStatus(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_selected, selection.size()));
}
} else {
setStatus(IStatus.ERROR, Messages.MavenPomSelectionComponent_nosel);
}
});
setupClassifiers();
// $NON-NLS-1$
setStatus(IStatus.ERROR, "");
scheduleSearch(queryText, false);
}
Aggregations