Java 类org.eclipse.jface.text.source.IAnnotationAccessExtension 实例源码

项目:Pydev    文件:CopiedOverviewRuler.java   
/**
 * Returns the color for the given annotation type
 *
 * @param annotationType the annotation type
 * @return the color
 * @since 3.0
 */
private Color findColor(Object annotationType) {
    Color color = (Color) fAnnotationTypes2Colors.get(annotationType);
    if (color != null) {
        return color;
    }

    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        IAnnotationAccessExtension extension = (IAnnotationAccessExtension) fAnnotationAccess;
        Object[] superTypes = extension.getSupertypes(annotationType);
        if (superTypes != null) {
            for (int i = 0; i < superTypes.length; i++) {
                color = (Color) fAnnotationTypes2Colors.get(superTypes[i]);
                if (color != null) {
                    return color;
                }
            }
        }
    }

    return null;
}
项目:bts    文件:XtextAnnotation.java   
public XtextAnnotation(String type, boolean isPersistent, IXtextDocument document, Issue issue, boolean isQuickfixable) {
    super(type, isPersistent, issue.getMessage());

    AnnotationPreference preference= lookup.getAnnotationPreference(this);
    if (preference != null)
        this.layer = preference.getPresentationLayer() + 1;
    else
        this.layer = IAnnotationAccessExtension.DEFAULT_LAYER + 1;

    this.document = document;
    this.issue = issue;
    this.isQuickfixable = isQuickfixable;
}
项目:bts    文件:XtextEditor.java   
@Override
protected IAnnotationAccess createAnnotationAccess() {
    return new DefaultMarkerAnnotationAccess() {
        @Override
        public int getLayer(Annotation annotation) {
            if (annotation.isMarkedDeleted()) {
                return IAnnotationAccessExtension.DEFAULT_LAYER;
            }
            return super.getLayer(annotation);
        }
    };
}
项目:APICloud-Studio    文件:ProblemAnnotation.java   
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup)
{
    Annotation annotation = new Annotation(annotationType, false, null);
    AnnotationPreference preference = lookup.getAnnotationPreference(annotation);
    if (preference != null)
    {
        return preference.getPresentationLayer() + 1;
    }
    else
    {
        return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitDocumentProvider.java   
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
    Annotation annotation= new Annotation(annotationType, false, null);
    AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
    if (preference != null)
        return preference.getPresentationLayer() + 1;
    else
        return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
项目:Eclipse-Postfix-Code-Completion    文件:AnnotationExpandHover.java   
protected int getOrder(Annotation annotation) {
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
        return extension.getLayer(annotation);
    }
    return IAnnotationAccessExtension.DEFAULT_LAYER;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompilationUnitDocumentProvider.java   
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
    Annotation annotation= new Annotation(annotationType, false, null);
    AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
    if (preference != null)
        return preference.getPresentationLayer() + 1;
    else
        return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AnnotationExpandHover.java   
protected int getOrder(Annotation annotation) {
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
        return extension.getLayer(annotation);
    }
    return IAnnotationAccessExtension.DEFAULT_LAYER;
}
项目:Pydev    文件:CopiedOverviewRuler.java   
private boolean isSubtype(Object annotationType) {
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        IAnnotationAccessExtension extension = (IAnnotationAccessExtension) fAnnotationAccess;
        return extension.isSubtype(annotationType, fType);
    }
    return fType.equals(annotationType);
}
项目:Pydev    文件:CopiedOverviewRuler.java   
/**
 * Computes whether the annotations of the given type are covered by the given <code>configured</code>
 * set. This is the case if either the type of the annotation or any of its
 * super types is contained in the <code>configured</code> set.
 *
 * @param annotationType the annotation type
 * @param configured the set with configured annotation types
 * @return <code>true</code> if annotation is covered, <code>false</code>
 *         otherwise
 * @since 3.0
 */
private boolean isCovered(Object annotationType, Set configured) {
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        IAnnotationAccessExtension extension = (IAnnotationAccessExtension) fAnnotationAccess;
        Iterator e = configured.iterator();
        while (e.hasNext()) {
            if (extension.isSubtype(annotationType, e.next())) {
                return true;
            }
        }
        return false;
    }
    return configured.contains(annotationType);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSelectAnnotationRulerAction.java   
private void findJavaAnnotation() {
    fPosition= null;
    fAnnotation= null;
    fHasCorrection= false;

    AbstractMarkerAnnotationModel model= getAnnotationModel();
    IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();

    IDocument document= getDocument();
    if (model == null)
        return ;

    boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);

    Iterator<Annotation> iter= model.getAnnotationIterator();
    int layer= Integer.MIN_VALUE;

    while (iter.hasNext()) {
        Annotation annotation= iter.next();
        if (annotation.isMarkedDeleted())
            continue;

        int annotationLayer= layer;
        if (annotationAccess != null) {
            annotationLayer= annotationAccess.getLayer(annotation);
            if (annotationLayer < layer)
                continue;
        }

        Position position= model.getPosition(annotation);
        if (!includesRulerLine(position, document))
            continue;

        AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
        if (preference == null)
            continue;

        String key= preference.getVerticalRulerPreferenceKey();
        if (key == null)
            continue;

        if (!fStore.getBoolean(key))
            continue;

        boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
        if (!isReadOnly
                && (
                    ((hasAssistLightbulb && annotation instanceof AssistAnnotation)
                    || JavaCorrectionProcessor.hasCorrections(annotation)))) {
            fPosition= position;
            fAnnotation= annotation;
            fHasCorrection= true;
            layer= annotationLayer;
            continue;
        } else if (!fHasCorrection) {
                fPosition= position;
                fAnnotation= annotation;
                layer= annotationLayer;
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AnnotationExpansionControl.java   
/**
     * Creates a new control.
     *
     * @param parent parent shell
     * @param shellStyle additional style flags
     * @param access the annotation access
     */
    public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) {
        fPaintListener= new MyPaintListener();
        fMouseTrackListener= new MyMouseTrackListener();
        fMouseListener= new MyMouseListener();
        fMenuDetectListener= new MyMenuDetectListener();
        fDisposeListener= new MyDisposeListener();
        fViewportListener= new IViewportListener() {

            public void viewportChanged(int verticalOffset) {
                dispose();
            }

        };
        fLayouter= new LinearLayouter();

        if (access instanceof IAnnotationAccessExtension)
            fAnnotationAccessExtension= (IAnnotationAccessExtension) access;

        fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
        Display display= fShell.getDisplay();
        fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
//      fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);

        GridLayout layout= new GridLayout(1, true);
        layout.marginHeight= 0;
        layout.marginWidth= 0;
        fShell.setLayout(layout);

        GridData data= new GridData(GridData.FILL_BOTH);
        data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
        fComposite.setLayoutData(data);
        fComposite.addMouseTrackListener(new MouseTrackAdapter() {

            @Override
            public void mouseExit(MouseEvent e) {
                if (fComposite == null)
                        return;
                Control[] children= fComposite.getChildren();
                Rectangle bounds= null;
                for (int i= 0; i < children.length; i++) {
                    if (bounds == null)
                        bounds= children[i].getBounds();
                    else
                        bounds.add(children[i].getBounds());
                    if (bounds.contains(e.x, e.y))
                        return;
                }

                // if none of the children contains the event, we leave the popup
                dispose();
            }

        });

//      fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
//
//          public void handleEvent(Event event) {
//              Rectangle bounds= fShell.getBounds();
//              int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
//              int y= bounds.y;
//              fShell.setBounds(x, y, bounds.width, bounds.height);
//          }
//
//      });

        Cursor handCursor= getHandCursor(display);
        fShell.setCursor(handCursor);
        fComposite.setCursor(handCursor);

        setInfoSystemColor();
    }
项目:Eclipse-Postfix-Code-Completion    文件:JavaExpandHover.java   
@Override
protected Object getHoverInfoForLine(final ISourceViewer viewer, final int line) {
    final boolean showTemporaryProblems= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
    IAnnotationModel model= viewer.getAnnotationModel();
    IDocument document= viewer.getDocument();

    if (model == null)
        return null;

    List<Annotation> exact= new ArrayList<Annotation>();
    HashMap<Position, Object> messagesAtPosition= new HashMap<Position, Object>();

    Iterator<Annotation> e= model.getAnnotationIterator();
    while (e.hasNext()) {
        Annotation annotation= e.next();

        if (fAnnotationAccess instanceof IAnnotationAccessExtension)
            if (!((IAnnotationAccessExtension)fAnnotationAccess).isPaintable(annotation))
                continue;

        if (annotation instanceof IJavaAnnotation && !isIncluded((IJavaAnnotation)annotation, showTemporaryProblems))
            continue;

        AnnotationPreference pref= fLookup.getAnnotationPreference(annotation);
        if (pref != null) {
            String key= pref.getVerticalRulerPreferenceKey();
            if (key != null && !fStore.getBoolean(key))
                continue;
        }

        Position position= model.getPosition(annotation);
        if (position == null)
            continue;

        if (compareRulerLine(position, document, line) == 1) {

            if (isDuplicateMessage(messagesAtPosition, position, annotation.getText()))
                continue;

            exact.add(annotation);
        }
    }

    sort(exact, model);

    if (exact.size() > 0)
        setLastRulerMouseLocation(viewer, line);

    if (exact.size() > 0) {
        Annotation first= exact.get(0);
        if (!isBreakpointAnnotation(first))
            exact.add(0, new NoBreakpointAnnotation());
    }

    if (exact.size() <= 1)
        return null;

    AnnotationHoverInput input= new AnnotationHoverInput();
    input.fAnnotations= exact.toArray(new Annotation[0]);
    input.fViewer= viewer;
    input.fRulerInfo= fCompositeRuler;
    input.fAnnotationListener= fgListener;
    input.fDoubleClickListener= fDblClickListener;
    input.redoAction= new AnnotationExpansionControl.ICallback() {

        public void run(IInformationControlExtension2 control) {
            control.setInput(getHoverInfoForLine(viewer, line));
        }

    };
    input.model= model;

    return input;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSelectAnnotationRulerAction.java   
private void findJavaAnnotation() {
    fPosition= null;
    fAnnotation= null;
    fHasCorrection= false;

    AbstractMarkerAnnotationModel model= getAnnotationModel();
    IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();

    IDocument document= getDocument();
    if (model == null)
        return ;

    boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);

    Iterator<Annotation> iter= model.getAnnotationIterator();
    int layer= Integer.MIN_VALUE;

    while (iter.hasNext()) {
        Annotation annotation= iter.next();
        if (annotation.isMarkedDeleted())
            continue;

        int annotationLayer= layer;
        if (annotationAccess != null) {
            annotationLayer= annotationAccess.getLayer(annotation);
            if (annotationLayer < layer)
                continue;
        }

        Position position= model.getPosition(annotation);
        if (!includesRulerLine(position, document))
            continue;

        boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
        if (!isReadOnly
                && (
                    ((hasAssistLightbulb && annotation instanceof AssistAnnotation)
                    || JavaCorrectionProcessor.hasCorrections(annotation)))) {
            fPosition= position;
            fAnnotation= annotation;
            fHasCorrection= true;
            layer= annotationLayer;
            continue;
        } else if (!fHasCorrection) {
            AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
            if (preference == null)
                continue;

            String key= preference.getVerticalRulerPreferenceKey();
            if (key == null)
                continue;

            if (fStore.getBoolean(key)) {
                fPosition= position;
                fAnnotation= annotation;
                layer= annotationLayer;
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AnnotationExpansionControl.java   
/**
     * Creates a new control.
     *
     * @param parent parent shell
     * @param shellStyle additional style flags
     * @param access the annotation access
     */
    public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) {
        fPaintListener= new MyPaintListener();
        fMouseTrackListener= new MyMouseTrackListener();
        fMouseListener= new MyMouseListener();
        fMenuDetectListener= new MyMenuDetectListener();
        fDisposeListener= new MyDisposeListener();
        fViewportListener= new IViewportListener() {

            public void viewportChanged(int verticalOffset) {
                dispose();
            }

        };
        fLayouter= new LinearLayouter();

        if (access instanceof IAnnotationAccessExtension)
            fAnnotationAccessExtension= (IAnnotationAccessExtension) access;

        fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
        Display display= fShell.getDisplay();
        fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
//      fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);

        GridLayout layout= new GridLayout(1, true);
        layout.marginHeight= 0;
        layout.marginWidth= 0;
        fShell.setLayout(layout);

        GridData data= new GridData(GridData.FILL_BOTH);
        data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
        fComposite.setLayoutData(data);
        fComposite.addMouseTrackListener(new MouseTrackAdapter() {

            @Override
            public void mouseExit(MouseEvent e) {
                if (fComposite == null)
                        return;
                Control[] children= fComposite.getChildren();
                Rectangle bounds= null;
                for (int i= 0; i < children.length; i++) {
                    if (bounds == null)
                        bounds= children[i].getBounds();
                    else
                        bounds.add(children[i].getBounds());
                    if (bounds.contains(e.x, e.y))
                        return;
                }

                // if none of the children contains the event, we leave the popup
                dispose();
            }

        });

//      fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
//
//          public void handleEvent(Event event) {
//              Rectangle bounds= fShell.getBounds();
//              int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
//              int y= bounds.y;
//              fShell.setBounds(x, y, bounds.width, bounds.height);
//          }
//
//      });

        Cursor handCursor= getHandCursor(display);
        fShell.setCursor(handCursor);
        fComposite.setCursor(handCursor);

        setInfoSystemColor();
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaExpandHover.java   
@Override
protected Object getHoverInfoForLine(final ISourceViewer viewer, final int line) {
    final boolean showTemporaryProblems= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
    IAnnotationModel model= viewer.getAnnotationModel();
    IDocument document= viewer.getDocument();

    if (model == null)
        return null;

    List<Annotation> exact= new ArrayList<Annotation>();
    HashMap<Position, Object> messagesAtPosition= new HashMap<Position, Object>();

    Iterator<Annotation> e= model.getAnnotationIterator();
    while (e.hasNext()) {
        Annotation annotation= e.next();

        if (fAnnotationAccess instanceof IAnnotationAccessExtension)
            if (!((IAnnotationAccessExtension)fAnnotationAccess).isPaintable(annotation))
                continue;

        if (annotation instanceof IJavaAnnotation && !isIncluded((IJavaAnnotation)annotation, showTemporaryProblems))
            continue;

        AnnotationPreference pref= fLookup.getAnnotationPreference(annotation);
        if (pref != null) {
            String key= pref.getVerticalRulerPreferenceKey();
            if (key != null && !fStore.getBoolean(key))
                continue;
        }

        Position position= model.getPosition(annotation);
        if (position == null)
            continue;

        if (compareRulerLine(position, document, line) == 1) {

            if (isDuplicateMessage(messagesAtPosition, position, annotation.getText()))
                continue;

            exact.add(annotation);
        }
    }

    sort(exact, model);

    if (exact.size() > 0)
        setLastRulerMouseLocation(viewer, line);

    if (exact.size() > 0) {
        Annotation first= exact.get(0);
        if (!isBreakpointAnnotation(first))
            exact.add(0, new NoBreakpointAnnotation());
    }

    if (exact.size() <= 1)
        return null;

    AnnotationHoverInput input= new AnnotationHoverInput();
    input.fAnnotations= exact.toArray(new Annotation[0]);
    input.fViewer= viewer;
    input.fRulerInfo= fCompositeRuler;
    input.fAnnotationListener= fgListener;
    input.fDoubleClickListener= fDblClickListener;
    input.redoAction= new AnnotationExpansionControl.ICallback() {

        public void run(IInformationControlExtension2 control) {
            control.setInput(getHoverInfoForLine(viewer, line));
        }

    };
    input.model= model;

    return input;
}
项目:Pydev    文件:CopiedOverviewRuler.java   
/**
 * Updates the header tool tip text of this ruler.
 */
private void updateHeaderToolTipText() {
    if (fHeader == null || fHeader.isDisposed()) {
        return;
    }

    if (fHeader.getToolTipText() != null) {
        return;
    }

    String overview = ""; //$NON-NLS-1$

    for (int i = fAnnotationsSortedByLayer.size() - 1; i >= 0; i--) {

        Object annotationType = fAnnotationsSortedByLayer.get(i);

        if (skipInHeader(annotationType) || skip(annotationType)) {
            continue;
        }

        int count = 0;
        String annotationTypeLabel = null;

        Iterator e = new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY
                | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
        while (e.hasNext()) {
            Annotation annotation = (Annotation) e.next();
            if (annotation != null) {
                if (annotationTypeLabel == null) {
                    annotationTypeLabel = ((IAnnotationAccessExtension) fAnnotationAccess).getTypeLabel(annotation);
                }
                count++;
            }
        }

        if (annotationTypeLabel != null) {
            if (overview.length() > 0)
            {
                overview += "\n"; //$NON-NLS-1$
            }
            overview += annotationTypeLabel + ":" + count; //$NON-NLS-1$ fabioz change; not user internal formatter
        }
    }

    if (overview.length() > 0) {
        fHeader.setToolTipText(overview);
    }
}