/* (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()]);
  }
Ejemplo n.º 2
0
 /*
  * @see IJavaAnnotation#getArguments()
  */
 public String[] getArguments() {
   IMarker marker = getMarker();
   if (marker != null && marker.exists() && isProblem())
     return CorrectionEngine.getProblemArguments(marker);
   return null;
 }