public static Image getResolutionImage(int kind) {
   switch (kind) {
     case IAccessRule.K_ACCESSIBLE:
       return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_TRANSLATE);
     case IAccessRule.K_DISCOURAGED:
       return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING);
     case IAccessRule.K_NON_ACCESSIBLE:
       return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_ERROR);
   }
   return null;
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker)
   */
  public IMarkerResolution[] getResolutions(IMarker marker) {
    final Shell shell = JavaPlugin.getActiveWorkbenchShell();
    if (!hasResolutions(marker) || shell == null) {
      return NO_RESOLUTION;
    }

    ArrayList<IMarkerResolution2> resolutions = new ArrayList<IMarkerResolution2>();

    final IJavaProject project = getJavaProject(marker);

    int id = marker.getAttribute(IJavaModelMarker.ID, -1);
    if (id == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND) {
      String[] arguments = CorrectionEngine.getProblemArguments(marker);
      final IPath path = new Path(arguments[0]);

      if (path.segment(0).equals(JavaCore.USER_LIBRARY_CONTAINER_ID)) {
        String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetouserlib_label;
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        resolutions.add(
            new UserLibraryMarkerResolution(label, image) {
              public void run(IMarker m) {
                changeToExistingLibrary(shell, path, false, project);
              }
            });
        if (path.segmentCount() == 2) {
          String label2 =
              Messages.format(
                  NewWizardMessages.UserLibraryMarkerResolutionGenerator_createuserlib_label,
                  path.segment(1));
          Image image2 = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_LIBRARY);
          resolutions.add(
              new UserLibraryMarkerResolution(label2, image2) {
                public void run(IMarker m) {
                  createUserLibrary(shell, path);
                }
              });
        }
      }
      String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetoother;
      Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
      resolutions.add(
          new UserLibraryMarkerResolution(label, image) {
            public void run(IMarker m) {
              changeToExistingLibrary(shell, path, true, project);
            }
          });
    }

    if (project != null) {
      resolutions.add(new OpenBuildPathMarkerResolution(project));
    }

    return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
  }
  public static void getInvalidQualificationProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    if (!(node instanceof Name)) {
      return;
    }
    Name name = (Name) node;
    IBinding binding = name.resolveBinding();
    if (!(binding instanceof ITypeBinding)) {
      return;
    }
    ITypeBinding typeBinding = (ITypeBinding) binding;

    AST ast = node.getAST();
    ASTRewrite rewrite = ASTRewrite.create(ast);
    rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null);

    String label = CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    ASTRewriteCorrectionProposal proposal =
        new ASTRewriteCorrectionProposal(
            label,
            context.getCompilationUnit(),
            rewrite,
            IProposalRelevance.QUALIFY_INNER_TYPE_NAME,
            image);

    proposals.add(proposal);
  }
  private Image getImage(IJavaAnnotation annotation, int imageType) {
    if ((imageType == QUICKFIX_WARNING_IMAGE
            || imageType == QUICKFIX_ERROR_IMAGE
            || imageType == QUICKFIX_INFO_IMAGE)
        && fCachedImageType == imageType) return fCachedImage;

    Image image = null;
    switch (imageType) {
      case OVERLAY_IMAGE:
        IJavaAnnotation overlay = annotation.getOverlay();
        image = getManagedImage((Annotation) overlay);
        fCachedImageType = -1;
        break;
      case QUICKFIX_WARNING_IMAGE:
        image = getQuickFixWarningImage();
        fCachedImageType = imageType;
        fCachedImage = image;
        break;
      case QUICKFIX_ERROR_IMAGE:
        image = getQuickFixErrorImage();
        fCachedImageType = imageType;
        fCachedImage = image;
        break;
      case QUICKFIX_INFO_IMAGE:
        image = getQuickFixInfoImage();
        fCachedImageType = imageType;
        fCachedImage = image;
        break;
      case GRAY_IMAGE:
        {
          String annotationType = annotation.getType();
          if (JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotationType)) {
            image = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ERROR_ALT);
          } else if (JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(annotationType)) {
            image = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_WARNING_ALT);
          } else if (JavaMarkerAnnotation.INFO_ANNOTATION_TYPE.equals(annotationType)) {
            image = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INFO_ALT);
          }
          fCachedImageType = -1;
          break;
        }
    }

    return image;
  }
 public AddMissingJavadocTagProposal(
     String label,
     ICompilationUnit cu,
     BodyDeclaration bodyDecl,
     ASTNode missingNode,
     int relevance) {
   super(label, cu, null, relevance, JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVADOCTAG));
   fBodyDecl = bodyDecl;
   fMissingNode = missingNode;
 }
  public CancelSearchAction(CallHierarchyViewPart view) {
    super(CallHierarchyMessages.CancelSearchAction_label);
    fView = view;
    setToolTipText(CallHierarchyMessages.CancelSearchAction_tooltip);
    JavaPluginImages.setLocalImageDescriptors(this, "ch_cancel.gif"); // $NON-NLS-1$

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_CANCEL_SEARCH_ACTION);
  }
 public MissingReturnTypeCorrectionProposal(
     ICompilationUnit cu, MethodDeclaration decl, ReturnStatement existingReturn, int relevance) {
   super(
       "",
       cu,
       null,
       relevance,
       JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)); // $NON-NLS-1$
   fMethodDecl = decl;
   fExistingReturn = existingReturn;
 }
 /** Constructs a new action. */
 @SuppressWarnings("restriction")
 public RefreshAction(GradleTasksView owner) {
   super("Refresh");
   setDescription("Refresh Tasks");
   setToolTipText("Request a rebuild of the gradle model and refresh the list of tasks");
   JavaPluginImages.setLocalImageDescriptors(this, "refresh.gif"); // $NON-NLS-1$
   //		PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
   // IJavaHelpContextIds.LINK_EDITOR_ACTION);
   //		setChecked(owner.isLinkingEnabled());
   this.owner = owner;
   setToolTipText("Refresh task list");
 }
  public ToggleViewAction(IJobHierarchyViewPart v, int viewerIndex) {
    super("", AS_RADIO_BUTTON); // $NON-NLS-1$
    if (viewerIndex == IJobHierarchyViewPart.HIERARCHY_MODE_SUPERTYPES) {
      setText(TypeHierarchyMessages.ToggleViewAction_supertypes_label);
      setDescription(TypeHierarchyMessages.ToggleViewAction_supertypes_description);
      setToolTipText(TypeHierarchyMessages.ToggleViewAction_supertypes_tooltip);
      JavaPluginImages.setLocalImageDescriptors(this, "super_co.gif"); // $NON-NLS-1$
    } else if (viewerIndex == IJobHierarchyViewPart.HIERARCHY_MODE_SUBTYPES) {
      setText(TypeHierarchyMessages.ToggleViewAction_subtypes_label);
      setDescription(TypeHierarchyMessages.ToggleViewAction_subtypes_description);
      setToolTipText(TypeHierarchyMessages.ToggleViewAction_subtypes_tooltip);
      JavaPluginImages.setLocalImageDescriptors(this, "sub_co.gif"); // $NON-NLS-1$
    } else if (viewerIndex == IJobHierarchyViewPart.HIERARCHY_MODE_CLASSIC) {
      setText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_label);
      setDescription(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_description);
      setToolTipText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_tooltip);
      JavaPluginImages.setLocalImageDescriptors(this, "hierarchy_co.gif"); // $NON-NLS-1$
    } else {
      Assert.isTrue(false);
    }

    fViewPart = v;
    fViewerIndex = viewerIndex;
  }
    private LexicalSortingAction(TreeViewer outlineViewer) {
      super(
          TextMessages.getString("JavaOutlineInformationControl.LexicalSortingAction.label"),
          IAction.AS_CHECK_BOX); // $NON-NLS-1$
      setToolTipText(
          TextMessages.getString(
              "JavaOutlineInformationControl.LexicalSortingAction.tooltip")); //$NON-NLS-1$
      setDescription(
          TextMessages.getString(
              "JavaOutlineInformationControl.LexicalSortingAction.description")); //$NON-NLS-1$

      JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); // $NON-NLS-1$

      fOutlineViewer = outlineViewer;

      boolean checked = getDialogSettings().getBoolean(STORE_LEXICAL_SORTING_CHECKED);
      setChecked(checked);
      AspectJUIPlugin.getDefault()
          .getWorkbench()
          .getHelpSystem()
          .setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_BROWSING_ACTION);
    }
    private ShowOnlyMainTypeAction(TreeViewer outlineViewer) {
      super(
          TextMessages.getString("JavaOutlineInformationControl.GoIntoTopLevelType.label"),
          IAction.AS_CHECK_BOX); // $NON-NLS-1$
      setToolTipText(
          TextMessages.getString(
              "JavaOutlineInformationControl.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$
      setDescription(
          TextMessages.getString(
              "JavaOutlineInformationControl.GoIntoTopLevelType.description")); //$NON-NLS-1$

      JavaPluginImages.setLocalImageDescriptors(this, "gointo_toplevel_type.gif"); // $NON-NLS-1$

      AspectJUIPlugin.getDefault()
          .getWorkbench()
          .getHelpSystem()
          .setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);

      fOutlineViewer = outlineViewer;

      boolean showclass = getDialogSettings().getBoolean(STORE_GO_INTO_TOP_LEVEL_TYPE_CHECKED);
      setTopLevelTypeOnly(showclass);
    }
    /**
     * Creates the action.
     *
     * @param outlineViewer the outline viewer
     */
    private SortByDefiningTypeAction(TreeViewer outlineViewer) {
      super(
          TextMessages.getString(
              "JavaOutlineInformationControl.SortByDefiningTypeAction.label")); //$NON-NLS-1$
      setDescription(
          TextMessages.getString(
              "JavaOutlineInformationControl.SortByDefiningTypeAction.description")); //$NON-NLS-1$
      setToolTipText(
          TextMessages.getString(
              "JavaOutlineInformationControl.SortByDefiningTypeAction.tooltip")); //$NON-NLS-1$

      JavaPluginImages.setLocalImageDescriptors(this, "definingtype_sort_co.gif"); // $NON-NLS-1$

      fOutlineViewer = outlineViewer;

      AspectJUIPlugin.getDefault()
          .getWorkbench()
          .getHelpSystem()
          .setHelp(this, IJavaHelpContextIds.SORT_BY_DEFINING_TYPE_ACTION);

      boolean state = getDialogSettings().getBoolean(STORE_SORT_BY_DEFINING_TYPE_CHECKED);
      setChecked(state);
      fInnerLabelProvider.setShowDefiningType(state);
    }
 private Image getQuickFixErrorImage() {
   if (fgQuickFixErrorImage == null)
     fgQuickFixErrorImage = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_ERROR);
   return fgQuickFixErrorImage;
 }
 private AddJavadocCommentProposal(
     String name, ICompilationUnit cu, int relevance, int insertPosition, String comment) {
   super(name, cu, relevance, JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVADOCTAG));
   fInsertPosition = insertPosition;
   fComment = comment;
 }
 private Image getQuickFixWarningImage() {
   if (fgQuickFixWarningImage == null)
     fgQuickFixWarningImage = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_WARNING);
   return fgQuickFixWarningImage;
 }
 public OpenDeclarationAction(BrowserInformationControl infoControl) {
   fInfoControl = infoControl;
   setText("Open Declaration");
   JavaPluginImages.setLocalImageDescriptors(this, "goto_input.gif"); // $NON-NLS-1$
 }
 private Image getQuickFixInfoImage() {
   if (fgQuickFixInfoImage == null)
     fgQuickFixInfoImage = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_INFO);
   return fgQuickFixInfoImage;
 }
public class AddListenerWizardPage extends DataModelWizardPage {

  private static final Image IMG_INTERFACE =
      JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INTERFACE);

  protected ServletDataModelSyncHelper synchHelper2;

  public AddListenerWizardPage(IDataModel model, String pageName) {
    super(model, pageName);
    setDescription(ADD_LISTENER_WIZARD_PAGE_DESC);
    setTitle(ADD_LISTENER_WIZARD_PAGE_TITLE);
    synchHelper2 = initializeSynchHelper(model);
  }

  @Override
  public ServletDataModelSyncHelper initializeSynchHelper(IDataModel dm) {
    return new ServletDataModelSyncHelper(dm);
  }

  @Override
  protected Composite createTopLevelComposite(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 300;
    composite.setLayoutData(data);

    createServletContextEvents(composite);
    createHttpSessionEvents(composite);
    createServletRequestEvents(composite);
    createSelectAllGroup(composite);

    Dialog.applyDialogFont(composite);

    return composite;
  }

  @Override
  protected String[] getValidationPropertyNames() {
    return new String[] {INTERFACES};
  }

  @Override
  protected void enter() {
    super.enter();
    synchHelper2.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG);
  }

  private void createServletContextEvents(Composite parent) {
    Group group = createGroup(parent, ADD_LISTENER_WIZARD_SERVLET_CONTEXT_EVENTS);

    createEventListenerRow(
        group, ADD_LISTENER_WIZARD_LIFECYCLE_L, QUALIFIED_SERVLET_CONTEXT_LISTENER, INTERFACES);

    createEventListenerRow(
        group,
        ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_C,
        QUALIFIED_SERVLET_CONTEXT_ATTRIBUTE_LISTENER,
        INTERFACES);
  }

  private void createHttpSessionEvents(Composite parent) {
    Group group = createGroup(parent, ADD_LISTENER_WIZARD_HTTP_SESSION_EVENTS);

    createEventListenerRow(
        group, ADD_LISTENER_WIZARD_LIFECYCLE_I, QUALIFIED_HTTP_SESSION_LISTENER, INTERFACES);

    createEventListenerRow(
        group,
        ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H,
        QUALIFIED_HTTP_SESSION_ATTRIBUTE_LISTENER,
        INTERFACES);

    createEventListenerRow(
        group,
        ADD_LISTENER_WIZARD_SESSION_MIGRATION,
        QUALIFIED_HTTP_SESSION_ACTIVATION_LISTENER,
        INTERFACES);

    createEventListenerRow(
        group,
        ADD_LISTENER_WIZARD_OBJECT_BINDING,
        QUALIFIED_HTTP_SESSION_BINDING_LISTENER,
        INTERFACES);
  }

  private void createServletRequestEvents(Composite parent) {
    Group group = createGroup(parent, ADD_LISTENER_WIZARD_SERVLET_REQUEST_EVENTS);

    createEventListenerRow(
        group, ADD_LISTENER_WIZARD_LIFECYCLE_Y, QUALIFIED_SERVLET_REQUEST_LISTENER, INTERFACES);

    createEventListenerRow(
        group,
        ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G,
        QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER,
        INTERFACES);
  }

  private Group createGroup(Composite parent, String text) {
    Group group = new Group(parent, SWT.NONE);

    group.setLayout(new GridLayout(3, false));
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    group.setText(text);

    return group;
  }

  private void createEventListenerRow(
      Composite parent, String event, String listener, String property) {
    createCheckbox(parent, event, listener, property);
    createInterfaceIcon(parent);
    createInterfaceLabel(parent, listener);
  }

  private Button createCheckbox(Composite parent, String text, String value, String property) {
    Button button = new Button(parent, SWT.CHECK);

    button.setText(text);
    button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    synchHelper2.synchCheckbox(button, value, property, null);

    return button;
  }

  private Label createInterfaceIcon(Composite parent) {
    GridData data = new GridData();
    data.horizontalIndent = 50;

    Label label = new Label(parent, SWT.RIGHT);
    label.setImage(IMG_INTERFACE);
    label.setLayoutData(data);

    return label;
  }

  private Label createInterfaceLabel(Composite parent, String text) {
    Label label = new Label(parent, SWT.LEFT);

    label.setText(text);

    return label;
  }

  private void createSelectAllGroup(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Button selectAll = new Button(composite, SWT.PUSH);
    selectAll.setText(SELECT_ALL_BUTTON);
    selectAll.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleSelectAll();
          }
        });

    Button clear = new Button(composite, SWT.PUSH);
    clear.setText(CLEAR_BUTTON);
    clear.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleSelectNone();
          }
        });
  }

  private void handleSelectAll() {
    List interfaces = (List) model.getProperty(INTERFACES);
    if (interfaces == null) {
      interfaces = new ArrayList();
      model.setProperty(INTERFACES, interfaces);
    }

    for (String iface : LISTENER_INTERFACES) {
      if (!interfaces.contains(iface)) {
        interfaces.add(iface);
      }
    }

    synchHelper2.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG);
    model.notifyPropertyChange(INTERFACES, DataModelEvent.VALUE_CHG);
  }

  private void handleSelectNone() {
    List interfaces = (List) model.getProperty(INTERFACES);
    if (interfaces == null) {
      interfaces = new ArrayList();
      model.setProperty(INTERFACES, interfaces);
    }

    interfaces.removeAll(Arrays.asList(LISTENER_INTERFACES));

    synchHelper2.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG);
    model.notifyPropertyChange(INTERFACES, DataModelEvent.VALUE_CHG);
  }
}
 /*
  * @see org.eclipse.jface.text.source.IAnnotationPresentation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
  */
 public void paint(GC gc, Canvas canvas, Rectangle bounds) {
   // draw affordance so the user know she can click here to get a breakpoint
   Image fImage = JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
   ImageUtilities.drawImage(fImage, gc, canvas, bounds, SWT.CENTER);
 }
 public Image getImage() {
   return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
 }
 public Image getImage() {
   return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ACCESSRULES_ATTRIB);
 }