@Override public int getLineOfLastMouseButtonActivity() { if (fDelegate instanceof IVerticalRulerInfo) return ((IVerticalRulerInfo)fDelegate).getLineOfLastMouseButtonActivity(); return -1; }
/** * Returns the line of interest deduced from the mouse hover event. * * @param event a mouse hover event that triggered hovering * @return the document model line number on which the hover event occurred or <code>-1</code> if there is no event * @since 3.0 */ private int getHoverLine(MouseEvent event) { return event == null ? -1 : fVerticalRulerInfo.toDocumentLineNumber(event.y); }
/** * Determines the hover to be used to display information based on the source of the * mouse hover event. If <code>fVerticalRulerInfo</code> is not a composite ruler, the * standard hover is returned. * * @param event the source of the mouse hover event * @return the hover depending on <code>source</code>, or <code>fAnnotationHover</code> if none can be found. * @since 3.0 */ private IAnnotationHover getHover(MouseEvent event) { if (event == null || event.getSource() == null) return fAnnotationHover; if (fVerticalRulerInfo instanceof CompositeRuler) { CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo; for (Iterator<IVerticalRulerColumn> it= comp.getDecoratorIterator(); it.hasNext();) { Object o= it.next(); if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) { if (((IVerticalRulerInfo) o).getControl() == event.getSource()) { IAnnotationHover hover= ((IVerticalRulerInfoExtension) o).getHover(); if (hover != null) return hover; } } } } return fAnnotationHover; }
/** * Determines the hover to be used to display information based on the source of the * mouse hover event. If <code>fVerticalRulerInfo</code> is not a composite ruler, the * standard hover is returned. * * @param event the source of the mouse hover event * @return the hover depending on <code>source</code>, or <code>fAnnotationHover</code> if none can be found. * @since 3.0 */ private IAnnotationHover getHover(MouseEvent event) { if (event == null || event.getSource() == null) return fAnnotationHover; if (fVerticalRulerInfo instanceof CompositeRuler) { CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo; for (Iterator<IVerticalRulerColumn> it= comp.getDecoratorIterator(); it.hasNext();) { Object o= it.next(); if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) { if (((IVerticalRulerInfo) o).getControl() == event.getSource()) { IAnnotationHover hover= ((IVerticalRulerInfoExtension) o).getHover(); if (hover != null) return hover; } } } } return fAnnotationHover; }
@Override public int getLineOfLastMouseButtonActivity() { if (fDelegate instanceof IVerticalRulerInfo) return ((IVerticalRulerInfo)fDelegate).getLineOfLastMouseButtonActivity(); return -1; }
/** * Determines graphical area covered for which the hover is valid. * * @param y y-coordinate in the vertical ruler * @return the graphical extend where the hover is valid */ private Rectangle computeArea(int y) { // This is OK (see constructor) IOverviewRuler overviewRuler= (IOverviewRuler) getVerticalRulerInfo(); int hover_height= overviewRuler.getAnnotationHeight(); int hover_width= getVerticalRulerInfo().getControl().getSize().x; // Calculate y-coordinate for hover int hover_y= y; boolean hasAnnotation= true; while (hasAnnotation && hover_y > y - hover_height) { hover_y--; hasAnnotation= overviewRuler.hasAnnotation(hover_y); } hover_y++; return new Rectangle(0, hover_y, hover_width, hover_height); } }
/** * Returns the line of interest deduced from the mouse hover event. * * @param event a mouse hover event that triggered hovering * @return the document model line number on which the hover event occurred or <code>-1</code> if there is no event * @since 3.0 */ private int getHoverLine(MouseEvent event) { return event == null ? -1 : fVerticalRulerInfo.toDocumentLineNumber(event.y); }
public int getLineOfLastMouseButtonActivity() { if (fDelegate instanceof IVerticalRulerInfo) ((IVerticalRulerInfo) fDelegate).getLineOfLastMouseButtonActivity(); return -1; }
public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { if (fEditor != null) { IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.removeMouseListener(this); } if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).removeRulerContextMenuListener(this); } fEditor= (ITextEditor)(targetEditor == null ? null : targetEditor.getAdapter(ITextEditor.class)); fCallerAction= callerAction; fAction= null; if (fEditor != null) { if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).addRulerContextMenuListener(this); IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { fAction= createAction(fEditor, rulerInfo); update(); Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.addMouseListener(this); } } }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fDelegate instanceof IVerticalRulerInfo) return ((IVerticalRulerInfo)fDelegate).toDocumentLineNumber(y_coordinate); return -1; }
public int getLineOfLastMouseButtonActivity() { if (fDelegate instanceof IVerticalRulerInfo) ((IVerticalRulerInfo) fDelegate).getLineOfLastMouseButtonActivity(); return -1; }
@Override public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { if (fEditor != null) { IVerticalRulerInfo rulerInfo= fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.removeMouseListener(this); } if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).removeRulerContextMenuListener(this); } fEditor= targetEditor == null ? null : targetEditor.getAdapter(ITextEditor.class); fCallerAction= callerAction; fAction= null; if (fEditor != null) { if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).addRulerContextMenuListener(this); IVerticalRulerInfo rulerInfo= fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { fAction= createAction(fEditor, rulerInfo); update(); Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.addMouseListener(this); } } }
public int toDocumentLineNumber(int y_coordinate) { if (fDelegate instanceof IVerticalRulerInfo) ((IVerticalRulerInfo) fDelegate).toDocumentLineNumber(y_coordinate); return -1; }
/** * Checks whether a position includes the ruler's line of activity. * * @param position the position to be checked * @param document the document the position refers to * @return <code>true</code> if the line is included by the given position */ protected boolean includesRulerLine(Position position, IDocument document) { if (position != null) { try { int markerLine= document.getLineOfOffset(position.getOffset()); int line= fRuler.getLineOfLastMouseButtonActivity(); if (line == markerLine) return true; // commented because of "1GEUOZ9: ITPJUI:ALL - Confusing UI for multi-line Bookmarks and Tasks" // return (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength())); } catch (BadLocationException x) { } } return false; }
public void handleEvent(Event event) { if (event.type == SWT.MenuDetect) { // TODO: show per-item menu // for now: show ruler context menu if (fInput != null) { Control ruler= fInput.fRulerInfo.getControl(); if (ruler != null && !ruler.isDisposed()) { Menu menu= ruler.getMenu(); if (menu != null && !menu.isDisposed()) { menu.setLocation(event.x, event.y); menu.addMenuListener(new MenuListener() { public void menuHidden(MenuEvent e) { dispose(); } public void menuShown(MenuEvent e) { } }); menu.setVisible(true); } } } } } }
public int toDocumentLineNumber(int y_coordinate) { if (fDelegate instanceof IVerticalRulerInfo) ((IVerticalRulerInfo) fDelegate).toDocumentLineNumber(y_coordinate); return -1; } }
/** * Checks whether a position includes the ruler's line of activity. * * @param position the position to be checked * @param document the document the position refers to * @return <code>true</code> if the line is included by the given position */ protected final boolean includesRulerLine(Position position, IDocument document) { if (position != null) { try { int markerLine= document.getLineOfOffset(position.getOffset()); int line= fRuler.getLineOfLastMouseButtonActivity(); if (line == markerLine) return true; // commented because of "1GEUOZ9: ITPJUI:ALL - Confusing UI for multi-line Bookmarks and Tasks" // return (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength())); } catch (BadLocationException x) { } } return false; }
@Override public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { if (fEditor != null) { IVerticalRulerInfo rulerInfo= fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.removeMouseListener(this); } if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).removeRulerContextMenuListener(this); } fEditor= targetEditor == null ? null : targetEditor.getAdapter(ITextEditor.class); fCallerAction= callerAction; fAction= null; if (fEditor != null) { if (fEditor instanceof ITextEditorExtension) ((ITextEditorExtension) fEditor).addRulerContextMenuListener(this); IVerticalRulerInfo rulerInfo= fEditor.getAdapter(IVerticalRulerInfo.class); if (rulerInfo != null) { fAction= createAction(fEditor, rulerInfo); update(); Control control= rulerInfo.getControl(); if (control != null && !control.isDisposed()) control.addMouseListener(this); } } }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fDelegate instanceof IVerticalRulerInfo) return ((IVerticalRulerInfo)fDelegate).toDocumentLineNumber(y_coordinate); return -1; } }
/** * Checks whether a position includes the ruler's line of activity. * * @param position the position to be checked * @param document the document the position refers to * @return <code>true</code> if the line is included by the given position */ protected boolean includesRulerLine(Position position, IDocument document) { if (position != null) { try { int markerLine= document.getLineOfOffset(position.getOffset()); int line= fRuler.getLineOfLastMouseButtonActivity(); if (line == markerLine) return true; // commented because of "1GEUOZ9: ITPJUI:ALL - Confusing UI for multi-line Bookmarks and Tasks" // return (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength())); } catch (BadLocationException x) { } } return false; }