List of usage examples for org.eclipse.jface.viewers IDecoration addOverlay
void addOverlay(ImageDescriptor overlay);
From source file:com.iw.plugins.spindle.ui.decorators.ProjectDecorator.java
License:Mozilla Public License
public void decorate(Object element, IDecoration decoration) { if (isTapestryProject(element)) { decoration.addOverlay(Images.getImageDescriptor("project_ovr.gif")); }//from w ww . j av a 2 s .c o m }
From source file:com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof WorkflowDefinitionEntry) { WorkflowDefinitionEntry definition = (WorkflowDefinitionEntry) element; if (!definition.isLoadingNode()) { int version = definition.getVersion(); int draftVersion = definition.getDraftVersion(); decoration.addSuffix(combine(version, draftVersion)); }//ww w . ja v a 2s . c o m } else if (element instanceof WorkflowDefinitionsFolder) { WorkflowDefinitionsFolder folder = (WorkflowDefinitionsFolder) element; IStatus status = folder.getStatus(); if (status != null) { if (status.getException() instanceof KaleoAPIException) { decoration.addSuffix(" [Error API unavailable. Ensure kaleo-designer-portlet is deployed.]"); decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR)); } else { decoration.addSuffix(" [" + status.getMessage() + "]"); } } else { decoration.addSuffix(""); } } }
From source file:com.liferay.ide.server.ui.navigator.BundlesDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof BundleDTO) { BundleDTO bundle = (BundleDTO) element; if (!(bundle instanceof BundleDTOLoading)) { String id = bundle.id + ""; String state = bundle.state + ""; String version = bundle.version; decoration.addSuffix(combine(id, state, version)); }//from w w w. j av a2s. co m } else if (element instanceof BundlesFolder) { BundlesFolder folder = (BundlesFolder) element; IStatus status = folder.getStatus(); if (status != null) { if (status.getException() instanceof BundleAPIException) { decoration.addSuffix(" [Error Bundle API unavailable.]"); decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR)); } else { decoration.addSuffix(" [" + status.getMessage() + "]"); } } else { decoration.addSuffix(""); } } else if (element instanceof IServerModule) { final IServerModule module = (IServerModule) element; final IServer server = module.getServer(); if (server.getServerState() == IServer.STATE_STARTED) { final BundleDeployer deployer = getDeployer(server); //TODO this chould be cached somehow? for (BundleDTO bundle : deployer.listBundles()) { if (module.getModule()[0].getName().equals(bundle.symbolicName)) { String id = bundle.id + ""; String state = bundle.state + ""; String version = bundle.version; decoration.addSuffix(combine(id, state, version)); } } } } }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * This allows us to decorate either the label or the icon used for an * IResource.// w w w.j a v a 2 s . com * * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, * org.eclipse.jface.viewers.IDecoration) */ @Override public void decorate(final Object element, final IDecoration decoration) { tryHookListeners(); // should never happen if (element == null || !(element instanceof IResource)) { return; } final IResource resource = (IResource) element; // if the resource is not in an open project, we don't decorate if (resource.getProject() == null || resource.getProject().isOpen() == false) { return; } // make sure that TFS is the repository provider for this resource if (!TeamUtils.isConfiguredWith(resource, TFSRepositoryProvider.PROVIDER_ID)) { return; } // ignore linked, private, team ignored resources if (eclipseIgnoreFilter.filter(resource).isReject()) { // add ignored suffix if enabled if (TFSCommonUIClientPlugin.getDefault().getPreferenceStore() .getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_IGNORED_STATUS)) { decoration.addSuffix(Messages.getString("TFSLabelDecorator.IgnoredDecorationSuffix")); //$NON-NLS-1$ } return; } // try to get the repository for this resource final TFSRepositoryProvider repositoryProvider = (TFSRepositoryProvider) TeamUtils .getRepositoryProvider(resource); final TFSRepository repository = repositoryProvider.getRepository(); // hook up any listeners, etc, if necessary if (repository != null) { addRepositoryListener(repository); } // try to get the full path for this resource final String resourcePath = Resources.getLocation(resource, LocationUnavailablePolicy.IGNORE_RESOURCE); final ResourceDataManager resourceDataManager = TFSEclipseClientPlugin.getDefault() .getResourceDataManager(); final ResourceData resourceData = resourceDataManager.getResourceData(resource); // decorate ignored resources with the ignored iconography if (PluginResourceFilters.TPIGNORE_FILTER.filter(resource).isReject() || PluginResourceFilters.TFS_IGNORE_FILTER.filter(resource).isReject()) { // add ignored suffix if enabled if (TFSCommonUIClientPlugin.getDefault().getPreferenceStore() .getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_IGNORED_STATUS)) { decoration.addSuffix(Messages.getString("TFSLabelDecorator.IgnoredDecorationSuffix")); //$NON-NLS-1$ } // if this is in TFS, paint this as in-tfs but ignored if (resourceData != null) { decoration.addOverlay(imageHelper.getImageDescriptor(IGNORED_ICON)); } // not in tfs, draw no iconography return; } // repository is offline if (repository == null) { decorateFromFilesystem(resource, decoration, repository); return; } // there are two passes here: first we update any information in the // pending changes cache, then we try to update information from the // itemcache. (if that fails, we use the readonly/writable hackery // from 2.0.) we draw high-priority overlays first, since the first // one wins.) /* * Add conflicts once conflict cache is considered reliable. */ // decorateFromConflicts(resource, decoration, repository, // resourcePath); // add decorations from pending changes decorateFromPendingChanges(resource, decoration, repository, resourcePath); resource.getProject().getLocation().toOSString(); if (resourceData != null) { decorateFromResourceData(resource, decoration, resourceData); } else if (!resourceDataManager.hasCompletedRefresh(resource.getProject())) { decorateFromFilesystem(resource, decoration, repository); } else if (resource instanceof IProject) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * This decorator allows us to paint based on the pending changes cache. (it * will decorate adds, checkouts, locks, etc.) * * @param resource/* ww w. jav a2 s. co m*/ * The IResource to decorate * @param decoration * The IDecoration which will be decorated * @param repository * The TFSRepository for this item * @param resourcePath * The local path to the resource for querying the pending changes * cache */ private void decorateFromFilePendingChanges(final IResource resource, final IDecoration decoration, final TFSRepository repository, final String resourcePath) { final PendingChange pendingChange = repository.getPendingChangeCache() .getPendingChangeByLocalPath(resourcePath); // no pending changes, don't alter any decorations if (pendingChange == null || pendingChange.getChangeType() == null) { return; } final ChangeType pendingChangeType = pendingChange.getChangeType(); // handle adds if (pendingChangeType.contains(ChangeType.ADD)) { decoration.addOverlay(imageHelper.getImageDescriptor(ADD_ICON)); decoration.addPrefix("+"); //$NON-NLS-1$ } // edits else if (pendingChangeType.contains(ChangeType.EDIT)) { decoration.addOverlay(imageHelper.getImageDescriptor(EDIT_ICON)); decoration.addPrefix(">"); //$NON-NLS-1$ } // non-edit locks else if (pendingChangeType.contains(ChangeType.LOCK)) { decoration.addOverlay(imageHelper.getImageDescriptor(LOCK_ICON)); } // arbitrary pending changes just get a something else if (!pendingChangeType.isEmpty()) { decoration.addOverlay(imageHelper.getImageDescriptor(CHANGE_ICON)); } }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * This decorator allows us to paint based on the pending changes cache. (it * will decorate adds, checkouts, locks, etc.) * * @param resource/*w ww . jav a 2 s . c o m*/ * The IResource to decorate * @param decoration * The IDecoration which will be decorated * @param repository * The TFSRepository for this item * @param resourcePath * The local path to the resource for querying the pending changes * cache */ private void decorateFromFolderPendingChanges(final IResource resource, final IDecoration decoration, final TFSRepository repository, final String resourcePath) { if (repository.getPendingChangeCache().hasPendingChangesByLocalPathRecursive(resourcePath) == false) { return; } decoration.addOverlay(imageHelper.getImageDescriptor(CHANGE_ICON)); }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * Decorate a resource based on data in the ResourceDataManager. (This * includes knowledge of whether the resource is actually in TFS, local * version, changeset date, etc.)/*from ww w . ja v a 2 s . com*/ * * @param resource * The IResource to decorate * @param decoration * The IDecoration which will be decorated * @param resourceData * The {@link ResourceData} for this local resource */ private void decorateFromResourceData(final IResource resource, final IDecoration decoration, final ResourceData resourceData) { final List<String> suffixList = new ArrayList<String>(); // there's no item cache data (but the item cache was updated, above) // so there's nothing to decorate if (resourceData == null) { return; } // indicate that this file is in tfs decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); // These preferences affect the decoration string final IPreferenceStore preferenceStore = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); // only show enhanced decorations for files, unless otherwise configured if (resource.getType() == IResource.FILE || preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_DECORATE_FOLDERS)) { // optionally show local changeset if (preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_CHANGESET) && resourceData.getChangesetID() != 0) { suffixList.add(Integer.toString(resourceData.getChangesetID())); } if (preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_SERVER_ITEM)) { suffixList.add(resourceData.getServerItem()); } // pretty up any suffix decorations if (suffixList.size() > 0) { final StringBuffer suffix = new StringBuffer(); suffix.append(" ["); //$NON-NLS-1$ for (int i = 0; i < suffixList.size(); i++) { if (i > 0) { suffix.append(", "); //$NON-NLS-1$ } suffix.append(suffixList.get(i)); } suffix.append("]"); //$NON-NLS-1$ decoration.addSuffix(suffix.toString()); } } }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * This is a fallback decorator for when the ItemCache is not available * (hasn't yet completed refreshing.) This is very similar to the 2.x * LabelDecorator.//from w w w. j a va 2 s .c om * * @param resource * The IResource to decorate * @param decoration * The IDecoration which will be deecorated */ private void decorateFromFilesystem(final IResource resource, final IDecoration decoration, final TFSRepository repository) { // repository does not exist, we are offline if (repository == null) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_OFFLINE_ICON)); } else if (resource.getType() == IResource.FILE && resource.isReadOnly()) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } else if (resource.getType() == IResource.FILE) { decoration.addOverlay(imageHelper.getImageDescriptor(UNKNOWN_ICON)); } else { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } }
From source file:com.nokia.tools.vct.navigator.confml.ConfMLMarkerDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { lasyInit();//from w w w . j av a 2 s . co m if (element instanceof IResource) { int severity = -1; try { severity = ((IResource) element).findMaxProblemSeverity( "com.nokia.tools.variant.validation.core.validationmarker", true, IResource.DEPTH_INFINITE); } catch (CoreException e) { // ignore } boolean hasError = severity == IMarker.SEVERITY_ERROR; boolean hasWarning = severity == IMarker.SEVERITY_WARNING; if (hasError) { decoration.addOverlay(errorDescriptor); } else if (hasWarning) { decoration.addOverlay(warningDescriptor); } } else if (element instanceof EObject) { EObject obj = (EObject) element; if (obj.eClass() == null) { return; } EPackage pack = obj.eClass().getEPackage(); if (pack == null) { return; } if (pack.equals(EConfML1Package.eINSTANCE)) { // OK - ConfML v 1 } else if (pack.equals(EConfML2Package.eINSTANCE)) { // OK - ConfML v 2 } else if (pack.equals(EConfMLIncludePackage.eINSTANCE)) { // OK - XInclude elements } else if (pack.equals(EXSDFacetPackage.eINSTANCE)) { // OK - XML schema elements } else { return; } Resource resource = obj.eResource(); URI uri = resource.getURI(); IPath path = new Path(uri.toPlatformString(true)); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (!file.exists()) { return; } IMarker[] markers = {}; try { markers = file.findMarkers("com.nokia.tools.variant.validation.core.validationmarker", true, IResource.DEPTH_ZERO); } catch (CoreException e) { // ignore } if (hasErrorMarkers(obj, markers)) { decoration.addOverlay(errorDescriptor); } else if (hasWarningMarkers(obj, markers)) { decoration.addOverlay(warningDescriptor); } } }
From source file:com.nokia.tools.vct.navigator.layer.RootFileDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { lazyInit();/*from ww w.ja va 2s .c o m*/ if (!(element instanceof IFile)) { return; } IFile file = (IFile) element; EConfigurationProject cp = ConfMLCore.getProjectModel(file.getProject()); if (cp == null) { return; } URI rootConfmlURI = cp.getRootConfml(); URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); if (rootConfmlURI.equals(fileURI)) { decoration.addOverlay(rootDescriptor); } }