List of usage examples for org.eclipse.jface.viewers DecorationContext putProperty
public void putProperty(String property, Object value)
From source file:ext.org.eclipse.jdt.internal.ui.packageview.HierarchicalDecorationContext.java
License:Open Source License
public static IDecorationContext getContext() { if (fgContext == null) { DecorationContext context = new DecorationContext(); context.putProperty(SynchronizationStateTester.PROP_TESTER, new HierarchicalSynchronizationStateTester()); fgContext = context;/*from w w w. j av a 2 s . c om*/ } return fgContext; }
From source file:org.eclipse.m2e.core.ui.internal.wizards.MavenPomSelectionComponent.java
License:Open Source License
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);/*ww w .j ava2 s .c om*/ } if (artifacts != null) { for (ArtifactKey a : artifacts) { artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId()); //$NON-NLS-1$ artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$ } } if (managed != null) { for (ArtifactKey a : managed) { managedKeys.add(a.getGroupId() + ":" + a.getArtifactId()); //$NON-NLS-1$ managedKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$ } } 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(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent 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 = (ArtifactKey) file.getAdapter(ArtifactKey.class); IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key); if (!status.isOK()) { setStatus(IStatus.ERROR, status.getMessage()); return; // TODO not nice to exit method like this } } 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(); setStatus(IStatus.ERROR, ""); //$NON-NLS-1$ scheduleSearch(queryText, false); }
From source file:org.eclipse.team.internal.ui.mapping.CommonViewerAdvisor.java
License:Open Source License
/** * Create the advisor using the given configuration * @param parent the parent/*w ww . ja v a 2 s.c o m*/ * @param configuration the configuration */ public CommonViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) { super(configuration); final CommonViewer viewer = CommonViewerAdvisor.createViewer(parent, configuration, this); TeamUI.getTeamContentProviderManager().addPropertyChangeListener(this); configuration.addPropertyChangeListener(this); GridData data = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(data); viewer.getNavigatorContentService().addListener(this); initializeViewer(viewer); IBaseLabelProvider provider = viewer.getLabelProvider(); if (provider instanceof DecoratingLabelProvider) { DecoratingLabelProvider dlp = (DecoratingLabelProvider) provider; ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator(); if (decorator != null) { ILabelProvider lp = dlp.getLabelProvider(); dlp = new DecoratingLabelProvider(new DecoratingLabelProvider(lp, decorator), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); viewer.setLabelProvider(dlp); } DecorationContext decorationContext = new DecorationContext(); decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() { public boolean isStateDecorationEnabled() { return false; } }); dlp.setDecorationContext(decorationContext); } else if (provider instanceof DecoratingStyledCellLabelProvider) { DecoratingStyledCellLabelProvider dsclp = (DecoratingStyledCellLabelProvider) provider; ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator(); if (decorator != null) { IStyledLabelProvider slp = dsclp.getStyledStringProvider(); dsclp = new DecoratingStyledCellLabelProvider( new MyDecoratingStyledCellLabelProvider(slp, decorator), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null); viewer.setLabelProvider(dsclp); } DecorationContext decorationContext = new DecorationContext(); decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() { public boolean isStateDecorationEnabled() { return false; } }); dsclp.setDecorationContext(decorationContext); } }
From source file:org.polymap.core.project.ui.layer.LayerStatusDecorator.java
License:Open Source License
public void decorate(Object elm, IDecoration decoration) { if (elm instanceof ILayer) { ILayer layer = (ILayer) elm;//www. j a v a 2 s . c o m try { layer.id(); } catch (NoSuchEntityException e) { // handled by EntityModificationDecorator return; } // visible if (layer.isVisible()) { ImageDescriptor image = ProjectPlugin.getDefault().imageDescriptor(visible); decoration.setFont(bold); DecorationContext context = (DecorationContext) decoration.getDecorationContext(); context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); decoration.addOverlay(image, IDecoration.REPLACE); ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(visible_ovr); decoration.addOverlay(ovr, TOP_LEFT); } // inactive == not visible if (!layer.isVisible()) { decoration.setForegroundColor(INACTIVE_COLOR); } LayerStatus layerStatus = layer.getLayerStatus(); if (layerStatus.getCode() == LayerStatus.MISSING) { decoration.setForegroundColor(MISSING_COLOR); decoration.addSuffix(Messages.get("LayerStatusDecorator_missing")); } else if (layerStatus.getCode() == LayerStatus.WAITING) { ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(waiting); decoration.setFont(italic); decoration.addOverlay(ovr, TOP_RIGHT); decoration.addSuffix(Messages.get("LayerStatusDecorator_checking")); } else if (layerStatus.getSeverity() == LayerStatus.OK) { // } // register listener decorated.put(layer.id(), layer); } }
From source file:org.polymap.core.project.ui.project.MapStatusDecorator.java
License:Open Source License
public void decorate(Object elm, IDecoration decoration) { if (elm instanceof IMap) { IMap map = (IMap) elm;//from w w w. j a va2s . com // visible if (map.isVisible() /*activeMaps.containsKey( map.id() )*/) { DecorationContext context = (DecorationContext) decoration.getDecorationContext(); context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); decoration.addOverlay(visible, IDecoration.REPLACE); decoration.addOverlay(visibleOvr, IDecoration.TOP_LEFT); } // empty if (map.getLayers().isEmpty()) { DecorationContext context = (DecorationContext) decoration.getDecorationContext(); context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); decoration.addOverlay(empty, IDecoration.REPLACE); } decorated.put(map.id(), map); } }