@Override public boolean canReplace(IInformationControl control) { return AbstractInformationControlManager.this.canReplace(control); }
/** * Computes information to be displayed as well as the subject area * and initiates that this information is presented in the information control. */ protected void doShowInformation() { fSubjectArea= null; fInformation= null; computeInformation(); }
/** * Computes the size constraints of the information control in points. * * @param subjectControl the subject control * @param subjectArea the subject area * @param informationControl the information control whose size constraints are computed * @return the computed size constraints in points * @since 3.0 */ protected Point computeSizeConstraints(Control subjectControl, Rectangle subjectArea, IInformationControl informationControl) { return computeSizeConstraints(subjectControl, informationControl); }
IInformationControl informationControl= getInformationControl(); if (informationControl != null) { Point sizeConstraints= computeSizeConstraints(fSubjectControl, fSubjectArea, informationControl); if (informationControl instanceof IInformationControlExtension3) { IInformationControlExtension3 iControl3= (IInformationControlExtension3) informationControl; Rectangle bounds= restoreInformationControlBounds(); location= computeInformationControlLocation(subjectArea, size); cropToClosestMonitor(controlBounds); location= Geometry.getLocation(controlBounds); size= Geometry.getSize(controlBounds); informationControl.setSize(size.x, size.y); showInformationControl(subjectArea);
do { upperLeft= computeLocation(subjectArea, controlSize, testAnchor); Monitor monitor= getClosestMonitor(subjectAreaDisplayRelative, testAnchor); if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor)) return upperLeft; Rectangle available= computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(), testAnchor); Rectangle proposed= new Rectangle(upperLeft.x, upperLeft.y, controlSize.x, controlSize.y); available.intersect(proposed); testAnchor= getNextFallbackAnchor(testAnchor);
/** * Handles the disposal of the subject control. By default, the information control * is disposed by calling <code>disposeInformationControl</code>. Subclasses may extend * this method. */ protected void handleSubjectControlDisposed() { disposeInformationControl(); }
/** * Hides the information control and stops the information control closer. */ protected void hideInformationControl() { if (fInformationControl != null) { storeInformationControlBounds(); fInformationControl.setVisible(false); if (fInformationControlCloser != null) fInformationControlCloser.stop(); } if (canClearDataOnHide()) { fSubjectArea= null; fInformation= null; // allow garbage collection of potentially large object } }
/** * Replaces this manager's information control as defined by * the information control replacer. * <strong>Must only be called when {@link #fInformationControl} instanceof {@link IInformationControlExtension3}!</strong> * * @param takeFocus <code>true</code> iff the replacing information control should take focus * * @since 3.4 */ void replaceInformationControl(boolean takeFocus) { if (fInformationControlReplacer != null && canReplace(fInformationControl)) { IInformationControlExtension3 iControl3= (IInformationControlExtension3) fInformationControl; Rectangle b= iControl3.getBounds(); Rectangle t= iControl3.computeTrim(); Rectangle contentBounds= new Rectangle(b.x - t.x, b.y - t.y, b.width - t.width, b.height - t.height); IInformationControlCreator informationPresenterControlCreator= ((IInformationControlExtension5) fInformationControl).getInformationPresenterControlCreator(); fInformationControlReplacer.replaceInformationControl(informationPresenterControlCreator, contentBounds, fInformation, fSubjectArea, takeFocus); } hideInformationControl(); }
/** * Disposes this manager and if necessary all dependent parts such as * the information control. For symmetry it first disables this manager. */ public void dispose() { if (!fDisposed) { fDisposed= true; setEnabled(false); disposeInformationControl(); if (fInformationControlReplacer != null) { fInformationControlReplacer.dispose(); fInformationControlReplacer= null; } if (fSubjectControl != null && !fSubjectControl.isDisposed() && fSubjectControlDisposeListener != null) fSubjectControl.removeDisposeListener(fSubjectControlDisposeListener); fSubjectControl= null; fSubjectControlDisposeListener= null; fIsCustomInformationControl= false; fCustomInformationControlCreator= null; fInformationControlCreator= null; fInformationControlCloser= null; } }
@Override protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) { Point result= super.computeInformationControlLocation(subjectArea, controlSize); Point cursorLocation= fTextViewer.getTextWidget().getDisplay().getCursorLocation(); if (isTakingFocusWhenVisible() || cursorLocation.x <= result.x + controlSize.x) return result; result.x= cursorLocation.x + 20 - controlSize.x; return result; }
@Override public void cropToClosestMonitor(Rectangle bounds) { AbstractInformationControlManager.this.cropToClosestMonitor(bounds); }
@Override protected Point computeLocation(Rectangle subjectArea, Point controlSize, Anchor anchor) { Point location= super.computeLocation(subjectArea, controlSize, anchor); /* * The location is computed using subjectControl.toDisplay(), which does not include the * trim of the subject control. As we want the additional info popup aligned with the outer * coordinates of the proposal popup, adjust this here */ Rectangle trim= fProposalTable.getShell().computeTrim(0, 0, 0, 0); location.x += trim.x; location.y += trim.y; return location; }
/** * Disposes this manager's information control. */ @Override public void dispose() { if (fMouseTracker != null) { fMouseTracker.stop(); fMouseTracker.fSubjectControl= null; fMouseTracker.fSubjectArea= null; fMouseTracker= null; } super.dispose(); }
IInformationControl informationControl= getInformationControl(); if (informationControl != null) { Point sizeConstraints= computeSizeConstraints(fSubjectControl, fSubjectArea, informationControl); if (informationControl instanceof IInformationControlExtension3) { IInformationControlExtension3 iControl3= (IInformationControlExtension3) informationControl; Rectangle bounds= restoreInformationControlBounds(); location= computeInformationControlLocation(subjectArea, size); cropToClosestMonitor(controlBounds); location= Geometry.getLocation(controlBounds); size= Geometry.getSize(controlBounds); informationControl.setSize(size.x, size.y); showInformationControl(subjectArea);
do { upperLeft= computeLocation(subjectArea, controlSize, testAnchor); Monitor monitor= getClosestMonitor(subjectAreaDisplayRelative, testAnchor); if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor)) return upperLeft; Rectangle available= computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(), testAnchor); Rectangle proposed= new Rectangle(upperLeft.x, upperLeft.y, controlSize.x, controlSize.y); available.intersect(proposed); testAnchor= getNextFallbackAnchor(testAnchor);
/** * Handles the disposal of the subject control. By default, the information control * is disposed by calling <code>disposeInformationControl</code>. Subclasses may extend * this method. */ protected void handleSubjectControlDisposed() { disposeInformationControl(); }
/** * Hides the information control and stops the information control closer. */ protected void hideInformationControl() { if (fInformationControl != null) { storeInformationControlBounds(); fInformationControl.setVisible(false); if (fInformationControlCloser != null) fInformationControlCloser.stop(); } if (canClearDataOnHide()) { fSubjectArea= null; fInformation= null; // allow garbage collection of potentially large object } }
/** * Replaces this manager's information control as defined by * the information control replacer. * <strong>Must only be called when {@link #fInformationControl} instanceof {@link IInformationControlExtension3}!</strong> * * @param takeFocus <code>true</code> iff the replacing information control should take focus * * @since 3.4 */ void replaceInformationControl(boolean takeFocus) { if (fInformationControlReplacer != null && canReplace(fInformationControl)) { IInformationControlExtension3 iControl3= (IInformationControlExtension3) fInformationControl; Rectangle b= iControl3.getBounds(); Rectangle t= iControl3.computeTrim(); Rectangle contentBounds= new Rectangle(b.x - t.x, b.y - t.y, b.width - t.width, b.height - t.height); IInformationControlCreator informationPresenterControlCreator= ((IInformationControlExtension5) fInformationControl).getInformationPresenterControlCreator(); fInformationControlReplacer.replaceInformationControl(informationPresenterControlCreator, contentBounds, fInformation, fSubjectArea, takeFocus); } hideInformationControl(); }
/** * Disposes this manager and if necessary all dependent parts such as * the information control. For symmetry it first disables this manager. */ public void dispose() { if (!fDisposed) { fDisposed= true; setEnabled(false); disposeInformationControl(); if (fInformationControlReplacer != null) { fInformationControlReplacer.dispose(); fInformationControlReplacer= null; } if (fSubjectControl != null && !fSubjectControl.isDisposed() && fSubjectControlDisposeListener != null) fSubjectControl.removeDisposeListener(fSubjectControlDisposeListener); fSubjectControl= null; fSubjectControlDisposeListener= null; fIsCustomInformationControl= false; fCustomInformationControlCreator= null; fInformationControlCreator= null; fInformationControlCloser= null; } }
@Override protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) { Point result= super.computeInformationControlLocation(subjectArea, controlSize); Point cursorLocation= fTextViewer.getTextWidget().getDisplay().getCursorLocation(); if (isTakingFocusWhenVisible() || cursorLocation.x <= result.x + controlSize.x) return result; result.x= cursorLocation.x + 20 - controlSize.x; return result; }