@Override public Image getImage(Object element) { if (element instanceof CPElement) { CPElement cpentry = (CPElement) element; ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry); if (imageDescriptor != null) { switch (cpentry.getStatus().getSeverity()) { case IStatus.WARNING: imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE); break; case IStatus.ERROR: imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE); break; } if (cpentry.getInherited() != null) { imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE); } return fRegistry.get(imageDescriptor); } } else if (element instanceof CPElementAttribute) { String key = ((CPElementAttribute) element).getKey(); if (key.equals(CPElement.SOURCEATTACHMENT)) { return fRegistry.get( CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ATTACH_ATTRIB)); } else if (key.equals(CPElement.EXCLUSION)) { return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB); } } else if (element instanceof IPathEntry) { return getImage(CPElement.createFromExisting((IPathEntry) element, null)); } else if (element instanceof CPElementGroup) { switch (((CPElementGroup) element).getEntryKind()) { case IPathEntry.CDT_INCLUDE: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER); case IPathEntry.CDT_MACRO: return fRegistry.get(fMacroIcon); case IPathEntry.CDT_INCLUDE_FILE: case IPathEntry.CDT_MACRO_FILE: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE); case IPathEntry.CDT_LIBRARY: return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY); case -1: IResource res = ((CPElementGroup) element).getResource(); IWorkbenchAdapter adapter = (IWorkbenchAdapter) res.getAdapter(IWorkbenchAdapter.class); ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res); if (!res.exists()) { imageDescriptor = new CPListImageDescriptor( imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE); } return fRegistry.get(imageDescriptor); } } return null; }
@Override public final String getText(Object element) { IWorkbenchAdapter adapter = getAdapter(element); if (adapter == null) { return ""; } return adapter.getLabel(element); }
/* (non-Javadoc) * Method declared on ILabelProvider */ public String getText(Object element) { // query the element for its label IWorkbenchAdapter adapter = getAdapter(element); if (adapter == null) { return ""; //$NON-NLS-1$ } String label = adapter.getLabel(element); // return the decorated label return decorateText(label, element); }
@Override public final Image getImage(Object element) { IWorkbenchAdapter adapter = getAdapter(element); if (adapter == null) { return null; } ImageDescriptor descriptor = adapter.getImageDescriptor(element); if (descriptor == null) { return null; } Image image = (Image) imageTable.get(descriptor); if (image == null) { image = descriptor.createImage(); imageTable.put(descriptor, image); } return image; }
@Override public final Image getImage(Object element) { // obtain the base image by querying the element IWorkbenchAdapter adapter = getAdapter(element); if (adapter == null) { return null; } ImageDescriptor descriptor = adapter.getImageDescriptor(element); if (descriptor == null) { return null; } // add any annotations to the image descriptor descriptor = decorateImage(descriptor, element); return descriptor.createImage(); }
/** * Verifies if the given element matches one of the selection requirements. Element must at least * pass the type test, and optionally wildcard name match. */ private boolean verifyElement(IAdaptable element) { if (classes.isEmpty()) { return true; } for (int i = 0; i < classes.size(); i++) { SelectionClass sc = (SelectionClass) classes.get(i); if (verifyClass(element, sc.className) == false) { continue; } if (sc.nameFilter == null) { return true; } IWorkbenchAdapter de = (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class); if ((de != null) && verifyNameMatch(de.getLabel(element), sc.nameFilter)) { return true; } } return false; }
/* (non-Javadoc) * Method declared on ILabelProvider */ public Image getImage(Object element) { // obtain the base image by querying the element IWorkbenchAdapter adapter = getAdapter(element); if (adapter == null) { return null; } ImageDescriptor descriptor = adapter.getImageDescriptor(element); if (descriptor == null) { return null; } // add any annotations to the image descriptor descriptor = decorateImage(descriptor, element); try { return resourceManager.createImage(descriptor); } catch (Exception e) { Log.log(e); return null; } }
/* (non-Javadoc) * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; Iterator it = ssel.iterator(); final HashSet projects = new HashSet(); while (it.hasNext()) { Object element = it.next(); IProject proj = null; if (element instanceof IFile) proj = ((IFile) element).getProject(); if ((proj == null) && (element instanceof IProject)) proj = (IProject) element; if ((proj == null) && (element instanceof IAdaptable)) { IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); if (resource != null) { proj = resource.getProject(); } if (proj == null) { IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class); if (workbenchAdapter != null) { Object o = workbenchAdapter.getParent(element); if (o instanceof IAdaptable) { resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class); if (resource != null) { proj = resource.getProject(); } } } } } if (proj != null && WorkspaceModelManager.isPluginProject(proj)) projects.add(proj); } if (projects.size() > 0) { BusyIndicator.showWhile( PDEPlugin.getActiveWorkbenchShell().getDisplay(), new Runnable() { public void run() { Iterator it = projects.iterator(); while (it.hasNext()) { IProject project = (IProject) it.next(); IFile file = PDEProject.getManifest(project); if (file == null || !file.exists()) file = PDEProject.getPluginXml(project); if (file == null || !file.exists()) file = PDEProject.getFragmentXml(project); if (file == null || !file.exists()) MessageDialog.openError( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, NLS.bind(PDEUIMessages.OpenManifestsAction_cannotFind, project.getName())); else try { IDE.openEditor( PDEPlugin.getActivePage(), file, IPDEUIConstants.MANIFEST_EDITOR_ID); } catch (PartInitException e) { MessageDialog.openError( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, NLS.bind( PDEUIMessages.OpenManifestsAction_cannotOpen, project.getName())); } } } }); } else MessageDialog.openInformation( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, PDEUIMessages.OpenManifestAction_noManifest); } return null; }