@Override public boolean verifyKey(VerifyEvent e) { if (Helper2.okToUse(fContextSelectorShell)) return contextSelectorKeyPressed(e); if (Helper2.okToUse(fContextInfoPopup)) return contextInfoPopupKeyPressed(e); return true; }
@Override public void processEvent(VerifyEvent event) { if (Helper2.okToUse(fContextSelectorShell)) contextSelectorProcessEvent(event); if (Helper2.okToUse(fContextInfoPopup)) contextInfoPopupProcessEvent(event); }
/** * Returns whether any popups controlled by the receiver have the input focus. * * @return <code>true</code> if any of the managed popups have the focus, <code>false</code> otherwise */ public boolean hasFocus() { return (fProposalPopup != null && fProposalPopup.hasFocus()) || (fContextInfoPopup != null && fContextInfoPopup.hasFocus()); }
/** * Hides context selector and context information popup. */ public void hide() { hideContextSelector(); hideContextInfoPopup(); }
/** * Processes a key stroke while the info popup is up. * * @param e the verify event describing the key stroke * @return <code>true</code> if processing can be stopped */ private boolean contextInfoPopupKeyPressed(KeyEvent e) { char key= e.character; if (key == 0) { switch (e.keyCode) { case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.ARROW_UP: case SWT.ARROW_DOWN: validateContextInformation(); break; default: if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) hideContextInfoPopup(); break; } } else if (key == SWT.ESC) { e.doit= false; hideContextInfoPopup(); } else { validateContextInformation(); } return true; }
/** * Shows all possible contexts for the given cursor position of the viewer. * * @param autoActivated <code>true</code> if auto activated * @return a potential error message or <code>null</code> in case of no error */ public String showContextProposals(final boolean autoActivated) { final StyledText styledText= fViewer.getTextWidget(); BusyIndicator.showWhile(styledText.getDisplay(), () -> { int position= fViewer.getSelectedRange().x; IContextInformation[] contexts= computeContextInformation(position); int count= (contexts == null ? 0 : contexts.length); if (count == 1) { // Show context information directly internalShowContextInfo(contexts[0], position); } else if (count > 0) { // Precise context must be selected if (fLineDelimiter == null) fLineDelimiter= styledText.getLineDelimiter(); createContextSelector(); setContexts(contexts); displayContextSelector(); hideContextInfoPopup(); } }); return getErrorMessage(); }
/** * Shows the given context frame. * * @param frame the frane to display * @param initial <code>true</code> if this is the first frame to be displayed * @since 2.0 */ private void internalShowContextFrame(ContextFrame frame, boolean initial) { frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset); if (frame.fPresenter != null) { if (fTextPresentation == null) fTextPresentation= new TextPresentation(); frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset); frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation); } createContextInfoPopup(); fContextInfoText.setText(frame.fInformation.getInformationDisplayString()); if (fTextPresentation != null) TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText); resize(); if (initial) { if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.CONTEXT_INFO_POPUP)) { fContentAssistant.addToLayout(this, fContextInfoPopup, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset); fContextInfoPopup.setVisible(true); } } else { fContentAssistant.layout(ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset); } }
/** * Hides any open pop-ups. */ protected void hide() { if (fProposalPopup != null) fProposalPopup.hide(); if (fContextInfoPopup != null) fContextInfoPopup.hide(); }
@Override public void install(ITextViewer textViewer) { Assert.isNotNull(textViewer); fViewer= textViewer; fLayoutManager= new LayoutManager(); fInternalListener= new InternalListener(); AdditionalInfoController2 controller= null; if (fInformationControlCreator != null) controller= new AdditionalInfoController2(fInformationControlCreator, OpenStrategy.getPostSelectionDelay()); fContextInfoPopup= new ContextInformationPopup2(this, fViewer); fProposalPopup= new CompletionProposalPopup2(this, fViewer, controller); manageAutoActivation(fIsAutoActivated); }
/** * Shows all possible contexts for the given cursor position of the viewer. * * @param autoActivated <code>true</code> if auto activated * @return a potential error message or <code>null</code> in case of no error */ public String showContextProposals(final boolean autoActivated) { final StyledText styledText= fViewer.getTextWidget(); BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() { @Override public void run() { int position= fViewer.getSelectedRange().x; IContextInformation[] contexts= computeContextInformation(position); int count = (contexts == null ? 0 : contexts.length); if (count == 1) { // Show context information directly internalShowContextInfo(contexts[0], position); } else if (count > 0) { // Precise context must be selected if (fLineDelimiter == null) fLineDelimiter= styledText.getLineDelimiter(); createContextSelector(); setContexts(contexts); displayContextSelector(); hideContextInfoPopup(); } } }); return getErrorMessage(); }
/** * Hides context selector and context information popup. */ public void hide() { hideContextSelector(); hideContextInfoPopup(); }
/** * Processes a key stroke while the info popup is up. * * @param e the verify event describing the key stroke * @return <code>true</code> if processing can be stopped */ private boolean contextInfoPopupKeyPressed(KeyEvent e) { char key= e.character; if (key == 0) { switch (e.keyCode) { case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.ARROW_UP: case SWT.ARROW_DOWN: validateContextInformation(); break; default: if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) hideContextInfoPopup(); break; } } else if (key == SWT.ESC) { e.doit= false; hideContextInfoPopup(); } else { validateContextInformation(); } return true; }
/** * Shows the given context frame. * * @param frame the frane to display * @param initial <code>true</code> if this is the first frame to be displayed * @since 2.0 */ private void internalShowContextFrame(ContextFrame frame, boolean initial) { frame.fValidator.install(frame.fInformation, fViewer, frame.fOffset); if (frame.fPresenter != null) { if (fTextPresentation == null) fTextPresentation= new TextPresentation(); frame.fPresenter.install(frame.fInformation, fViewer, frame.fBeginOffset); frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation); } createContextInfoPopup(); fContextInfoText.setText(frame.fInformation.getInformationDisplayString()); if (fTextPresentation != null) TextPresentation.applyTextPresentation(fTextPresentation, fContextInfoText); resize(); if (initial) { if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.CONTEXT_INFO_POPUP)) { fContentAssistant.addToLayout(this, fContextInfoPopup, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset); fContextInfoPopup.setVisible(true); } } else { fContentAssistant.layout(ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_INFO_POPUP, frame.fVisibleOffset); } }
/** * Hides any open pop-ups. */ protected void hide() { if (fProposalPopup != null) fProposalPopup.hide(); if (fContextInfoPopup != null) fContextInfoPopup.hide(); }
@Override public void install(ITextViewer textViewer) { Assert.isNotNull(textViewer); fViewer= textViewer; fLayoutManager= new LayoutManager(); fInternalListener= new InternalListener(); AdditionalInfoController2 controller= null; if (fInformationControlCreator != null) controller= new AdditionalInfoController2(fInformationControlCreator, OpenStrategy.getPostSelectionDelay()); fContextInfoPopup= new ContextInformationPopup2(this, fViewer); fProposalPopup= new CompletionProposalPopup2(this, fViewer, controller); manageAutoActivation(fIsAutoActivated); }
@Override public boolean verifyKey(VerifyEvent e) { if (Helper2.okToUse(fContextSelectorShell)) return contextSelectorKeyPressed(e); if (Helper2.okToUse(fContextInfoPopup)) return contextInfoPopupKeyPressed(e); return true; }
@Override public void processEvent(VerifyEvent event) { if (Helper2.okToUse(fContextSelectorShell)) contextSelectorProcessEvent(event); if (Helper2.okToUse(fContextInfoPopup)) contextInfoPopupProcessEvent(event); }
@Override public void uninstall() { if (fProposalPopup != null) fProposalPopup.hide(); if (fContextInfoPopup != null) fContextInfoPopup.hide(); manageAutoActivation(false); if (fCloser != null) { fCloser.uninstall(); fCloser= null; } fViewer= null; }
/** * Returns whether any popups controlled by the receiver have the input focus. * * @return <code>true</code> if any of the managed popups have the focus, <code>false</code> otherwise */ public boolean hasFocus() { return (fProposalPopup != null && fProposalPopup.hasFocus()) || (fContextInfoPopup != null && fContextInfoPopup.hasFocus()); }
@Override public void uninstall() { if (fProposalPopup != null) fProposalPopup.hide(); if (fContextInfoPopup != null) fContextInfoPopup.hide(); manageAutoActivation(false); if (fCloser != null) { fCloser.uninstall(); fCloser= null; } fViewer= null; }