コード例 #1
0
 @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;
 }
コード例 #2
0
 @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();
  }
コード例 #4
0
  /* (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;
    }
  }