List of usage examples for org.eclipse.jface.viewers IDecoration addOverlay
void addOverlay(ImageDescriptor overlay);
From source file:nexcore.tool.uml.ui.project.explorer.ExplorerDecorator.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, * org.eclipse.jface.viewers.IDecoration) *//* w ww . j a v a 2s .co m*/ public void decorate(Object element, IDecoration decoration) { if (element instanceof IProject) { IProject project = (IProject) element; if (UMLNature.hasUMLNature(project)) { decoration.addOverlay( UiCorePlugin.getImageDescriptor(IConstantImageRegistry.LOCATION_OVER_DECORATOR)); } return; } ITreeNode treeNode = null; if (!(element instanceof ITreeNode)) { return; } else { treeNode = (ITreeNode) element; } EObject eobject = treeNode.getEObject(); Resource resource = null; if (eobject == null) { return; } if (element instanceof ITreeNode) { // TODO pns ?? ? . // createValidationDecorator(eobject, decoration); } // if (ALMPreference.useCollaboration() && ProjectUtil.useCollaboration(eobject)) { // if (MetaContentUtil.hasMetaContent(eobject)) { // decoration.addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_NCP_DECORATOR), // IDecoration.BOTTOM_RIGHT); // } // } if (eobject instanceof Model) { resource = eobject.eResource(); // 2011-10-26 nspark // ?? ? ?? ? ? Model model = (Model) eobject; for (ProfileApplication profileApplication : model.getProfileApplications()) { if (profileApplication.getAppliedProfile() != null) { Profile newProfile = profileApplication.getAppliedProfile(); if (newProfile.eIsProxy()) { decoration.addOverlay( UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_ERROR_OVER)); break; } } } boolean active = treeNode.isActive(); if (!active) { decoration.addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_CLOSE_MODEL)); } } else if (element instanceof UMLFileTreeNode) { resource = eobject.eResource(); // 2011-08-03 nspark // project explorer ? ??? ? ? boolean validationCheck = UiCorePlugin.getDefault().getPreferenceStore() .getBoolean("MODEL_VALIDATION_CHECK"); if (validationCheck) { if (element instanceof UMLFileTreeNode) { treeNode = (UMLFileTreeNode) element; boolean isValid = treeNode.isValid(); if (!isValid) { decoration.addOverlay( UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_WARNING_OVER)); } } } } else if (eobject instanceof Diagram) { // 2011-08-09 ? // diagram? (dangling) ? ? Diagram diagram = (Diagram) eobject; boolean isValid = true; for (Iterator<AbstractNode> iter = diagram.getNodeList().iterator(); iter.hasNext();) { AbstractNode abstractNode = iter.next(); if (NodeType.NOTE.equals(abstractNode.getNodeType())) { return; } EObject umlModel = abstractNode.getUmlModel(); if (umlModel == null) { isValid = false; } else if (DomainUtil.isProxy(umlModel)) { isValid = false; } } if (!isValid) { decoration .addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_WARNING_OVER)); } } else { return; } if (resource == null) { return; } if (resource.isModified()) { decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__BLANK + UICoreConstant.PROJECT_CONSTANTS__STAR); } else { // crossReference ?? dirty ? ? if (resource.getContents() != null && resource.getContents().size() > 0) { EObject contents = resource.getContents().get(0); boolean dirtyOfCrossReference = ResourceManager.getInstance().isDirtyOfCrossReference(contents); if (dirtyOfCrossReference) { decoration.addSuffix( UICoreConstant.PROJECT_CONSTANTS__BLANK + UICoreConstant.PROJECT_CONSTANTS__STAR); } else { decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING); } } else { decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING); } } }
From source file:nexcore.tool.uml.ui.project.explorer.ExplorerDecorator.java
License:Open Source License
/** * 'Validate'? ? ? Marker Decoration ?. * //from w w w. jav a 2s. co m * @param eobject * @param decoration * void */ private void createValidationDecorator(EObject eobject, IDecoration decoration) { EObject rootContainer = EcoreUtil.getRootContainer(eobject); if (rootContainer == null) return; Resource containerResource = rootContainer.eResource(); if (containerResource == null) return; Set<Resource> resourceList = ProjectUtil.getFragmentedFileList(containerResource); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (Resource resource : resourceList) { IPath path = new Path(resource.getURI().toString()); IFile file = root.getFile(path); if (file != null && file.exists()) { try { IMarker[] markers = file.findMarkers(UICoreConstant.VALIDATION_MARKER_TYPE, true, IResource.DEPTH_INFINITE); for (int i = 0; i < markers.length; i++) { String location = (String) markers[i].getAttribute(IMarker.LOCATION); if (null == location) { return; } int severity = markers[i].getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO); // QualifiedName? ? ??? ? ??? . if (eobject instanceof NamedElement) { String qualifiedName = ((NamedElement) eobject).getQualifiedName(); if (null == qualifiedName) { return; } else if (location.startsWith(qualifiedName)) { switch (severity) { case IMarker.SEVERITY_ERROR: decoration.addOverlay(UiCorePlugin .getImageDescriptor(IConstantImageRegistry.ICONNAME_ERROR_OVER)); break; case IMarker.SEVERITY_WARNING: decoration.addOverlay(UiCorePlugin .getImageDescriptor(IConstantImageRegistry.ICONNAME_WARNING_OVER)); break; } } } } } catch (CoreException e) { e.printStackTrace(); } } } }
From source file:org.absmodels.abs.plugin.decorators.FolderDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFolder) { if (hasABSFiles((IFolder) element)) { decoration.addOverlay(MARKER_DESCRIPTOR); }/*from ww w. j a v a 2 s . c o m*/ } else if (element instanceof IFile) { if (UtilityFunctions.isABSPackage((IFile) element)) { //if (checkFile((IResource)element)){ decoration.addOverlay(MARKER_DESCRIPTOR); //} } } }
From source file:org.apache.derby.ui.decorate.DerbyIsRunningDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { IProject proj = null;/* w w w.java 2 s .co m*/ if (element instanceof IJavaProject) { proj = ((IJavaProject) element).getProject(); } else { proj = (IProject) element; } try { if (DerbyServerUtils.getDefault().getRunning(proj)) { decoration.addOverlay(derbyRunningImageDesc); } } catch (CoreException ce) { Logger.log(SelectionUtil.getStatusMessages(ce), IStatus.ERROR); } }
From source file:org.apache.hadoop.eclipse.ui.internal.hdfs.HDFSLightweightLabelDecorator.java
License:Apache License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IResource) { IResource r = (IResource) element; URI locationURI = r.getLocationURI(); if (locationURI != null && HDFSURI.SCHEME.equals(locationURI.getScheme())) { try { if (r instanceof IProject) { final HDFSManager hdfsManager = HDFSManager.INSTANCE; HDFSServer server = hdfsManager.getServer(locationURI.toString()); if (server != null) { String serverUrl = server.getUri(); String userId = server.getUserId(); if (userId == null) { try { userId = hdfsManager.getClient(serverUrl).getDefaultUserAndGroupIds().get(0); } catch (Throwable e) { userId = null; }//from www . j a v a2s.c om } if (userId == null) userId = ""; else userId = userId + "@"; if (serverUrl != null) { try { URI uri = new URI(serverUrl); serverUrl = serverUrl.substring(uri.getScheme().length() + 3); } catch (Throwable e) { } } if (serverUrl.endsWith("/")) serverUrl = serverUrl.substring(0, serverUrl.length() - 1); decoration.addSuffix(" " + userId + serverUrl); if (server.getStatusCode() == ServerStatus.DISCONNECTED_VALUE) decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_OFFLINE_OVR); else decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_ONLINE_OVR); } else decoration.addSuffix(" [Unknown server]"); } else decorate((HDFSFileStore) EFS.getStore(locationURI), decoration); } catch (CoreException e) { logger.debug(e.getMessage(), e); } } } }
From source file:org.apache.openjpa.eclipse.ui.ProjectDecorator.java
License:Apache License
/** * Decorate the project root if it has the OpenJPA nature. *///ww w .j a va 2 s. c om public void decorate(Object element, IDecoration decoration) { if (!(element instanceof IProject)) { return; } try { if (((IProject) element).hasNature(OpenJPANature.NATURE_ID)) { decoration.addOverlay(decor); } else { decoration.addOverlay(null); } } catch (CoreException e) { } }
From source file:org.codecover.eclipse.views.UseForCoverageMeasurementDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { CodeCoverPlugin codeCoverPlugin = CodeCoverPlugin.getDefault(); if (codeCoverPlugin == null) { return;/*from w w w . ja va2s . c o m*/ } InstrumentableItemsManager instrumentableItemsManager = codeCoverPlugin.getInstrumentableItemsManager(); if (instrumentableItemsManager == null) { return; } if (element instanceof IPackageFragment) { IPackageFragment packageFragment = (IPackageFragment) element; if (instrumentableItemsManager.hasIPackageFragmentSubEntries(packageFragment)) { decoration.addOverlay(ImageProvider.getDecorator()); } } else if (element instanceof ICompilationUnit) { ICompilationUnit compilationUnit = (ICompilationUnit) element; if (instrumentableItemsManager.containsICompilationUnit(compilationUnit)) { decoration.addOverlay(ImageProvider.getDecorator()); } } }
From source file:org.cs3.pdt.navigator.internal.decorators.EntryPointDecoratorContributor.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (!(element instanceof IFile)) { return;// w w w . j a va 2s. com } PDTCommonPlugin.getDefault().addDecorator(this); IFile file = (IFile) element; try { if (file.exists()) { String isEntryPoint = file.getPersistentProperty(PDTCommonPlugin.ENTRY_POINT_KEY); if (isEntryPoint != null && isEntryPoint.equalsIgnoreCase("true")) { decoration.addOverlay(ImageRepository.getImageDescriptor(ImageRepository.PROLOG_ENTRY_POINT)); decoration.addSuffix(ENTRY_POINT_SUFFIX); } } } catch (CoreException e) { e.printStackTrace(); } }
From source file:org.eclipse.bpel.common.ui.ResourceMarkerDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { try {/* ww w.j av a2 s .c o m*/ int severity = ((IResource) element).findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_ONE); switch (severity) { case IMarker.SEVERITY_ERROR: if (img_error == null) img_error = CommonUIPlugin.getDefault().getImageRegistry() .getDescriptor(ICommonUIConstants.ICON_ERROR); decoration.addOverlay(img_error); break; case IMarker.SEVERITY_WARNING: if (img_warning == null) img_warning = CommonUIPlugin.getDefault().getImageRegistry() .getDescriptor(ICommonUIConstants.ICON_WARNING); decoration.addOverlay(img_warning); break; case IMarker.SEVERITY_INFO: if (img_info == null) img_info = CommonUIPlugin.getDefault().getImageRegistry() .getDescriptor(ICommonUIConstants.ICON_INFO); decoration.addOverlay(img_info); break; } } catch (Exception e) { } }
From source file:org.eclipse.cdt.internal.ui.viewsupport.CustomBuildSettingsDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile || element instanceof IFolder) { IResource rc = (IResource) element; ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault() .getProjectDescriptionManager(); ICProjectDescription prjDescription = projectDescriptionManager.getProjectDescription(rc.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED); if (prjDescription != null) { ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); if (cfgDescription != null) { if (isCustomizedResource(cfgDescription, rc)) decoration.addOverlay(CPluginImages.DESC_OVR_SETTING); }/*from ww w . ja v a 2 s.co m*/ } } }