/** * 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; }
/** * 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); } }
/** * 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); } }
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 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 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 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); } } } } } }
@Override 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() { @Override public void menuHidden(MenuEvent e) { dispose(); } @Override public void menuShown(MenuEvent e) { } }); menu.setVisible(true); } } } } } }
@Override 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() { @Override public void menuHidden(MenuEvent e) { dispose(); } @Override public void menuShown(MenuEvent e) { } }); menu.setVisible(true); } } } } } }
/** * Determines graphical area covered by the given line. * * @param line the number of the line in the viewer whose graphical extend in the vertical ruler must be computed * @return the graphical extend of the given line */ private Rectangle computeArea(int line) { try { StyledText text= fSourceViewer.getTextWidget(); int widgetLine= getWidgetLineNumber(line); int y= JFaceTextUtil.computeLineHeight(text, 0, widgetLine, widgetLine) - text.getTopPixel(); Point size= fVerticalRulerInfo.getControl().getSize(); return new Rectangle(0, y, size.x, text.getLineHeight(text.getOffsetAtLine(widgetLine))); } catch (IllegalArgumentException ex) { } catch (BadLocationException ex) { } return null; }
/** * Determines graphical area covered by the given line. * * @param line the number of the line in the viewer whose graphical extend in the vertical ruler must be computed * @return the graphical extend of the given line */ private Rectangle computeArea(int line) { try { StyledText text= fSourceViewer.getTextWidget(); int widgetLine= getWidgetLineNumber(line); int y= JFaceTextUtil.computeLineHeight(text, 0, widgetLine, widgetLine) - text.getTopPixel(); Point size= fVerticalRulerInfo.getControl().getSize(); return new Rectangle(0, y, size.x, text.getLineHeight(text.getOffsetAtLine(widgetLine))); } catch (IllegalArgumentException ex) { } catch (BadLocationException ex) { } return null; }
/** * Returns the visible area of the vertical ruler covered by the given line * range. * * @param lineRange the line range * @return the visible area */ private Rectangle computeArea(ILineRange lineRange) { try { StyledText text= fSourceViewer.getTextWidget(); final int startLine= getWidgetLineNumber(lineRange.getStartLine()); int y= JFaceTextUtil.computeLineHeight(text, 0, startLine, startLine) - text.getTopPixel(); int height= JFaceTextUtil.computeLineHeight(text, startLine, startLine + lineRange.getNumberOfLines(), lineRange.getNumberOfLines()); Point size= fVerticalRulerInfo.getControl().getSize(); return new Rectangle(0, y, size.x, height); } catch (BadLocationException x) { } return null; }
/** * Returns the visible area of the vertical ruler covered by the given line * range. * * @param lineRange the line range * @return the visible area */ private Rectangle computeArea(ILineRange lineRange) { try { StyledText text= fSourceViewer.getTextWidget(); final int startLine= getWidgetLineNumber(lineRange.getStartLine()); int y= JFaceTextUtil.computeLineHeight(text, 0, startLine, startLine) - text.getTopPixel(); int height= JFaceTextUtil.computeLineHeight(text, startLine, startLine + lineRange.getNumberOfLines(), lineRange.getNumberOfLines()); Point size= fVerticalRulerInfo.getControl().getSize(); return new Rectangle(0, y, size.x, height); } catch (BadLocationException x) { } return null; }