/** * Creates a new additional information controller. * * @param creator the information control creator to be used by this controller * @param delay time in milliseconds after which additional info should be displayed */ AdditionalInfoController(IInformationControlCreator creator, int delay) { super(creator); fDelay= delay; setAnchor(ANCHOR_RIGHT); setFallbackAnchors(new Anchor[] { ANCHOR_RIGHT, ANCHOR_LEFT, ANCHOR_BOTTOM }); /* * Adjust the location by one pixel towards the proposal popup, so that the single pixel * border of the additional info popup overlays with the border of the popup. This avoids * having a double black line. */ int spacing= -1; setMargins(spacing, spacing); // see also adjustment in #computeLocation InformationControlReplacer replacer= new InformationControlReplacer(new DefaultPresenterControlCreator()); getInternalAccessor().setInformationControlReplacer(replacer); }
@Override public void controlResized(ControlEvent e) { if (fAdditionalInfoController != null) { // reset the cached resize constraints fAdditionalInfoController.setSizeConstraints(50, 10, true, false); fAdditionalInfoController.hideInformationControl(); fAdditionalInfoController.handleTableSelectionChanged(); } fSize= fProposalShell.getSize(); } });
@Override protected void computeInformation() { if (fProposal instanceof ICompletionProposalExtension3) setCustomInformationControlCreator(((ICompletionProposalExtension3) fProposal).getInformationControlCreator()); else setCustomInformationControlCreator(null); // compute subject area Point size= fProposalTable.getShell().getSize(); // set information & subject area setInformation(fInformation, new Rectangle(0, 0, size.x, size.y)); }
@Override protected void showInformation(ICompletionProposal proposal, Object info) { InformationControlReplacer replacer= getInternalAccessor().getInformationControlReplacer(); if (replacer != null) replacer.hideInformationControl(); AdditionalInfoController.this.showInformation(proposal, info); } };
if (fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer() == null) fAdditionalInfoController.hideInformationControl(); else if (!fAdditionalInfoController.getInternalAccessor().isReplaceInProgress()) { IInformationControl infoControl= fAdditionalInfoController.getCurrentInformationControl2(); IInformationControlExtension5 iControl5= (IInformationControlExtension5) infoControl; if (!(iControl5.containsControl(control))) fAdditionalInfoController.hideInformationControl(); else if (event.type == SWT.MouseVerticalWheel) fAdditionalInfoController.getInternalAccessor().replaceInformationControl(false); } else if (infoControl != null && infoControl.isFocusControl()) { fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true); if (fAdditionalInfoController == null || fAdditionalInfoController.getInternalAccessor().isReplaceInProgress()) break; if (event.widget instanceof Control) { Control control= (Control) event.widget; IInformationControl infoControl= fAdditionalInfoController.getCurrentInformationControl2(); if (infoControl instanceof IInformationControlExtension5) { final IInformationControlExtension5 iControl5= (IInformationControlExtension5) infoControl; if (infoControl instanceof IDelayedInputChangeProvider) { final IDelayedInputChangeProvider delayedICP= (IDelayedInputChangeProvider) infoControl; final IInputChangedListener inputChangeListener= new DelayedInputChangeListener(delayedICP, fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer()); delayedICP.setDelayedInputChangeListener(inputChangeListener); if (fAdditionalInfoController == null) break; InformationControlReplacer replacer= fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer();
/** * Returns whether this popup has the focus. * * @return <code>true</code> if the popup has the focus */ public boolean hasFocus() { if (Helper.okToUse(fProposalShell)) { if ((fProposalShell.getDisplay().getActiveShell() == fProposalShell)) return true; /* * We have to delegate this query to the additional info controller * as well, since the content assistant is the widget token owner * and its closer does not know that the additional info control can * now also take focus. */ if (fAdditionalInfoController != null) { IInformationControl informationControl= fAdditionalInfoController.getCurrentInformationControl2(); if (informationControl != null && informationControl.isFocusControl()) return true; InformationControlReplacer replacer= fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer(); if (replacer != null) { informationControl= replacer.getCurrentInformationControl2(); if (informationControl != null && informationControl.isFocusControl()) return true; } } } return false; }
fAdditionalInfoController.install(fProposalTable); fAdditionalInfoController.handleTableSelectionChanged();
/** * @return the current information control, or <code>null</code> if none available */ public IInformationControl getCurrentInformationControl2() { return getInternalAccessor().getCurrentInformationControl(); } }
@Override public void widgetSelected(SelectionEvent e) { handleTableSelectionChanged(); }
/** * Informs the popup that it is being placed above the caret line instead of below. * * @param above <code>true</code> if the location of the popup is above the caret line, <code>false</code> if it is below * @since 3.3 */ void switchedPositionToAbove(boolean above) { if (fAdditionalInfoController != null) { fAdditionalInfoController.setFallbackAnchors(new Anchor[] { AbstractInformationControlManager.ANCHOR_RIGHT, AbstractInformationControlManager.ANCHOR_LEFT, above ? AbstractInformationControlManager.ANCHOR_TOP : AbstractInformationControlManager.ANCHOR_BOTTOM }); } }
protected void install() { fLayoutManager= new LayoutManager(); fInternalListener= new InternalListener(); AdditionalInfoController controller= null; if (fInformationControlCreator != null) controller= new AdditionalInfoController(fInformationControlCreator, OpenStrategy.getPostSelectionDelay()); fContextInfoPopup= fContentAssistSubjectControlAdapter.createContextInfoPopup(this); fProposalPopup= fContentAssistSubjectControlAdapter.createCompletionProposalPopup(this, controller, fAsynchronous); fProposalPopup.setSorter(fSorter); registerHandler(SELECT_NEXT_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_NEXT)); registerHandler(SELECT_PREVIOUS_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_PREVIOUS)); if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) { fContentAssistSubjectControlShell= fContentAssistSubjectControlAdapter.getControl().getShell(); fCASCSTraverseListener= e -> { if (e.detail == SWT.TRAVERSE_ESCAPE && isProposalPopupActive()) e.doit= false; }; fContentAssistSubjectControlShell.addTraverseListener(fCASCSTraverseListener); } manageAutoActivation(fIsAutoActivated); }
if (fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer() == null) fAdditionalInfoController.hideInformationControl(); else if (!fAdditionalInfoController.getInternalAccessor().isReplaceInProgress()) { IInformationControl infoControl= fAdditionalInfoController.getCurrentInformationControl2(); IInformationControlExtension5 iControl5= (IInformationControlExtension5) infoControl; if (!(iControl5.containsControl(control))) fAdditionalInfoController.hideInformationControl(); else if (event.type == SWT.MouseVerticalWheel) fAdditionalInfoController.getInternalAccessor().replaceInformationControl(false); } else if (infoControl != null && infoControl.isFocusControl()) { fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true); if (fAdditionalInfoController == null || fAdditionalInfoController.getInternalAccessor().isReplaceInProgress()) break; if (event.widget instanceof Control) { Control control= (Control) event.widget; IInformationControl infoControl= fAdditionalInfoController.getCurrentInformationControl2(); if (infoControl instanceof IInformationControlExtension5) { final IInformationControlExtension5 iControl5= (IInformationControlExtension5) infoControl; if (infoControl instanceof IDelayedInputChangeProvider) { final IDelayedInputChangeProvider delayedICP= (IDelayedInputChangeProvider) infoControl; final IInputChangedListener inputChangeListener= new DelayedInputChangeListener(delayedICP, fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer()); delayedICP.setDelayedInputChangeListener(inputChangeListener); control.getShell().getDisplay().asyncExec(() -> fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true)); if (fAdditionalInfoController == null)
@Override protected void showInformation(ICompletionProposal proposal, Object info) { InformationControlReplacer replacer= getInternalAccessor().getInformationControlReplacer(); if (replacer != null) replacer.hideInformationControl(); AdditionalInfoController.this.showInformation(proposal, info); } };
/** * Returns whether this popup has the focus. * * @return <code>true</code> if the popup has the focus */ public boolean hasFocus() { if (Helper.okToUse(fProposalShell)) { if ((fProposalShell.getDisplay().getActiveShell() == fProposalShell)) return true; /* * We have to delegate this query to the additional info controller * as well, since the content assistant is the widget token owner * and its closer does not know that the additional info control can * now also take focus. */ if (fAdditionalInfoController != null) { IInformationControl informationControl= fAdditionalInfoController.getCurrentInformationControl2(); if (informationControl != null && informationControl.isFocusControl()) return true; InformationControlReplacer replacer= fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer(); if (replacer != null) { informationControl= replacer.getCurrentInformationControl2(); if (informationControl != null && informationControl.isFocusControl()) return true; } } } return false; }
fAdditionalInfoController.install(fProposalTable); fAdditionalInfoController.handleTableSelectionChanged();
@Override public void run() { fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true); } });
@Override public void widgetSelected(SelectionEvent e) { handleTableSelectionChanged(); }
/** * Informs the popup that it is being placed above the caret line instead of below. * * @param above <code>true</code> if the location of the popup is above the caret line, <code>false</code> if it is below * @since 3.3 */ void switchedPositionToAbove(boolean above) { if (fAdditionalInfoController != null) { fAdditionalInfoController.setFallbackAnchors(new Anchor[] { AbstractInformationControlManager.ANCHOR_RIGHT, AbstractInformationControlManager.ANCHOR_LEFT, above ? AbstractInformationControlManager.ANCHOR_TOP : AbstractInformationControlManager.ANCHOR_BOTTOM }); } }
protected void install() { fLayoutManager= new LayoutManager(); fInternalListener= new InternalListener(); AdditionalInfoController controller= null; if (fInformationControlCreator != null) controller= new AdditionalInfoController(fInformationControlCreator, OpenStrategy.getPostSelectionDelay()); fContextInfoPopup= fContentAssistSubjectControlAdapter.createContextInfoPopup(this); fProposalPopup= fContentAssistSubjectControlAdapter.createCompletionProposalPopup(this, controller); fProposalPopup.setSorter(fSorter); registerHandler(SELECT_NEXT_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_NEXT)); registerHandler(SELECT_PREVIOUS_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_PREVIOUS)); if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) { fContentAssistSubjectControlShell= fContentAssistSubjectControlAdapter.getControl().getShell(); fCASCSTraverseListener= new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_ESCAPE && isProposalPopupActive()) e.doit= false; } }; fContentAssistSubjectControlShell.addTraverseListener(fCASCSTraverseListener); } manageAutoActivation(fIsAutoActivated); }
/** * Creates a new additional information controller. * * @param creator the information control creator to be used by this controller * @param delay time in milliseconds after which additional info should be displayed */ AdditionalInfoController(IInformationControlCreator creator, int delay) { super(creator); fDelay= delay; setAnchor(ANCHOR_RIGHT); setFallbackAnchors(new Anchor[] { ANCHOR_RIGHT, ANCHOR_LEFT, ANCHOR_BOTTOM }); /* * Adjust the location by one pixel towards the proposal popup, so that the single pixel * border of the additional info popup overlays with the border of the popup. This avoids * having a double black line. */ int spacing= -1; setMargins(spacing, spacing); // see also adjustment in #computeLocation InformationControlReplacer replacer= new InformationControlReplacer(new DefaultPresenterControlCreator()); getInternalAccessor().setInformationControlReplacer(replacer); }