Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.MarkerAnnotation


      }

      public boolean canFix(Annotation annotation) {
        boolean canFix = false;
        if (annotation instanceof MarkerAnnotation) {
          MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
          try {
            if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_TML_REFERENCES)) {
              String refType = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_REFERENCE_TYPE, "");
              canFix = refType.equals(ReferenceValidator.REFERENCE_TYPE_TML) || refType.equals(ReferenceValidator.REFERENCE_TYPE_SCRIPT);
            } else if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_TML_LABEL)) {
              return true;
            } else if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_INVALID_CHARACTER)) {
              return InvalidCharacterCompletionProposal.canCorrect(markerAnnotation);
            }
          } catch (CoreException e) {;
          }
        }       
        return canFix;
      }

      public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {

        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

        MarkerAnnotation markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_TML_REFERENCES, invocationContext.getOffset(), invocationContext.getSourceViewer());
        if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
          String refType = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_REFERENCE_TYPE, "");
          boolean isPortletReference = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_IS_PORTLET_REFERENCE, false);
          if (refType.equals(ReferenceValidator.REFERENCE_TYPE_TML)) {
            proposals.add(new CreateTMLFileReferenceCompletionProposal(markerAnnotation));
            if (isPortletReference) {
              // check if we can handle this missing portlet reference with our wizzard
              String ref = markerAnnotation.getMarker().getAttribute(ReferenceValidator.ATTRIBUTE_MISSING_REFERENCE_PATH, null);
              if (ref != null && ref.endsWith("/portlet.tml")) {
                String[] parts = ref.split("/");
                if (parts.length > 1) {
                  String portletNameToCreate = parts[parts.length - 2];
                  proposals.add(new CreateTMLPortletReferenceCompletionProposal(markerAnnotation, portletNameToCreate));                 
                }
              }
               
            }
          } else if (refType.equals(ReferenceValidator.REFERENCE_TYPE_SCRIPT)) {
            proposals.add(new CreateScriptFileReferenceCompletionProposal(markerAnnotation));
          }
        }
       
        markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_TML_LABEL, invocationContext.getOffset(), invocationContext.getSourceViewer());
        if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {               
          proposals.add(new CreateTMLLabelCompletionProposal(markerAnnotation));         
        }
       
        markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_INVALID_CHARACTER, invocationContext.getOffset(), invocationContext.getSourceViewer());
        if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
          InvalidCharacterCompletionProposal proposal = new InvalidCharacterCompletionProposal(markerAnnotation);         
          proposals.add(proposal);                   
        }
       
        return proposals.toArray(new ICompletionProposal[0]);
View Full Code Here


  public static MarkerAnnotation findMarkerAnnotationByTypeAndOffset(String type, int offset, ISourceViewer sourceViewer) {
    Iterator<Annotation> annotations = sourceViewer.getAnnotationModel().getAnnotationIterator();
    while (annotations.hasNext()) {
      Annotation tmpAnnotation = annotations.next();
      if (tmpAnnotation instanceof MarkerAnnotation) {
        MarkerAnnotation markerAnnotation = (MarkerAnnotation) tmpAnnotation;
        try {
          if (markerAnnotation.getMarker().getType().equals(type)) {
            Integer charStart = markerAnnotation.getMarker().getAttribute(IMarker.CHAR_START, -1);
            Integer charEnd = markerAnnotation.getMarker().getAttribute(IMarker.CHAR_END, -1);
            if (offset >= charStart && offset <= charEnd) {
               return markerAnnotation;
            }
          }
        } catch (CoreException e) {
View Full Code Here

      }

      public boolean canFix(Annotation annotation) {
        boolean canFix = false;
        if (annotation instanceof MarkerAnnotation) {
          MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
          try {
            if (markerAnnotation.getMarker().getType().equals(ResourceIDs.MARKER_INVALID_CHARACTER)) {
              canFix =  InvalidCharacterCompletionProposal.canCorrect(markerAnnotation);
            }
          } catch (CoreException e) {;
          }
        }       
        return canFix;
      }

      public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {

        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

        MarkerAnnotation markerAnnotation = MarkerFactory.findMarkerAnnotationByTypeAndOffset(ResourceIDs.MARKER_INVALID_CHARACTER, invocationContext.getOffset(), invocationContext.getSourceViewer());
        if (markerAnnotation != null && markerAnnotation.isQuickFixable()) {
          InvalidCharacterCompletionProposal proposal = new InvalidCharacterCompletionProposal(markerAnnotation);         
          proposals.add(proposal);                   
        }
       
        return proposals.toArray(new ICompletionProposal[0]);
View Full Code Here

        super(resource);
    }

    @Override
    protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
        MarkerAnnotation annotation = super.createMarkerAnnotation(marker);

        boolean fixable = marker.getAttribute(BuildErrorDetailsHandler.PROP_HAS_RESOLUTIONS, false);
        annotation.setQuickFixable(fixable);

        return annotation;
    }
View Full Code Here

                .getAnnotationIterator();
        final List<ICompletionProposal> result = Lists.newArrayList();
        while (iter.hasNext()) {
            final Annotation annotation = iter.next();
            if (annotation instanceof MarkerAnnotation) {
                final MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
                final IMarker marker = markerAnnotation.getMarker();
                try {
                    if (!marker.getType().equals(MarkerUtils.PROBLEM_MARKER)) {
                        continue;
                    }
                    final int invocationLine = sourceViewer.getDocument()
View Full Code Here

        continue;
     
      if (!annotations.containsKey(current))
        {
        //new annotaiton
        MarkerAnnotation toAdd = (MarkerAnnotation)current;
        if (toAdd.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
          {
          XCDEBookmarkDetails details = buildBookmarkDetails(toAdd);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          annotations.put(current,a);
          makeChange(new XCDEDocumentAnnotationStimulusAdd(parentRegister.getUsername(),a));
          }
        else if (toAdd.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
          {
          XCDETaskDetails details = buildTaskDetails(toAdd);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          annotations.put(current,a);
          makeChange(new XCDEDocumentAnnotationStimulusAdd(parentRegister.getUsername(),a));
         
        }
      else
        {
        //changed
        MarkerAnnotation toChange = (MarkerAnnotation)current;
        if (toChange.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
          {
          XCDEBookmarkDetails details = buildBookmarkDetails(toChange);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          if (!((XCDEDocumentAnnotation)annotations.get(current)).details.equals(details))
            {
            makeChange(new XCDEDocumentAnnotationStimulusChange(parentRegister.getUsername(),
                  (XCDEDocumentAnnotation)annotations.get(current),a));
            }
          annotations.put(current,a);
          }
        else if (toChange.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
          {
          XCDETaskDetails details = buildTaskDetails(toChange);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          if (!((XCDEDocumentAnnotation)annotations.get(current)).details.equals(details))
            {
            makeChange(new XCDEDocumentAnnotationStimulusChange(parentRegister.getUsername(),
                  (XCDEDocumentAnnotation)annotations.get(current),a));
            }
          annotations.put(current,a);
          }
        found.remove(current);
        }
      }
   
    for (Iterator i = found.iterator(); i.hasNext(); )
      {
      Annotation current = (Annotation)i.next();
      // This check should be unnecessary, because we only store MarkerAnnotations in the annotations map.
      //if (!(current instanceof MarkerAnnotation))
      //  continue;
      MarkerAnnotation toDelete = (MarkerAnnotation)current;
      if (toDelete.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
        {
        makeChange(new XCDEDocumentAnnotationStimulusDelete(parentRegister.getUsername(),
                (XCDEDocumentAnnotation)annotations.get(current)));
        }
      else if (toDelete.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
        {
        makeChange(new XCDEDocumentAnnotationStimulusDelete(parentRegister.getUsername(),
                (XCDEDocumentAnnotation)annotations.get(current)));
        }
      annotations.remove(current);
View Full Code Here

      }
      catch (CoreException e)
        {
        throw new RuntimeException("CoreException creating IMarker", e);
        }
    MarkerAnnotation annotation = new MarkerAnnotation(marker);
    annotation.setType(getAnnotationType(a.details));
    Position position = new Position(a.selection.pos, a.selection.length);
    annotModel.addAnnotation(annotation, position);
    annotations.put(annotation,a);
    }
View Full Code Here

    }
 
  private static final boolean annotationSupported(Annotation a)
    {
    if (!(a instanceof MarkerAnnotation)) return false;
    MarkerAnnotation m = (MarkerAnnotation)a;
    try
      {
      return
        ((m.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark") &&
            m.getMarker().getAttribute(IMarker.MESSAGE) != null )
          ||
         (m.getType().equals("org.eclipse.ui.workbench.texteditor.task") &&
            m.getMarker().getAttribute(IMarker.DONE) != null &&
            m.getMarker().getAttribute(IMarker.PRIORITY) != null &&
            m.getMarker().getAttribute(IMarker.MESSAGE) != null)
          );
      }
    catch (CoreException e)
      {
      throw new RuntimeException(e);
View Full Code Here

    List proposals = null;
    for (int i = 0; i < annotations.length; i++) {
      final Annotation annotation = annotations[i];
      ICompletionProposal proposal = null;
      if (annotation instanceof MarkerAnnotation) {
        MarkerAnnotation mAnnot = (MarkerAnnotation) annotation;
        IMarker marker = mAnnot.getMarker();
        if (isFixable(marker)) {
          final String pkgName = CorrectionEngine.getProblemArguments(marker)[0];
          proposal = new MarkerResolutionProposal(new RutaRequirePackageMarkerResolution(pkgName,
                  scriptProject), marker);
        }
View Full Code Here

    return false;
  }

  public static boolean hasCorrections(Annotation annotation) {
    if (annotation instanceof MarkerAnnotation) {
      MarkerAnnotation mAnnot = (MarkerAnnotation) annotation;
      IMarker marker = mAnnot.getMarker();
      return isFixable(marker);
    } else if (annotation instanceof IScriptAnnotation) {
      return isFixable((IScriptAnnotation) annotation);
    }
    return false;
View Full Code Here

TOP

Related Classes of org.eclipse.ui.texteditor.MarkerAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.