/** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. */ void filterProposals() { if (!fIsFilterPending) { fIsFilterPending= true; Control control= fContentAssistSubjectControlAdapter.getControl(); control.getDisplay().asyncExec(fFilterRunnable); } }
/** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. */ private void filterProposals() { if (!fIsFilterPending) { fIsFilterPending= true; Control control= fContentAssistSubjectControlAdapter.getControl(); control.getDisplay().asyncExec(fFilterRunnable); } }
/** * Installs a key listener on the text viewer's widget. */ private void installKeyListener() { if (!fVerifyKeyListenerHooked) { if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) { fVerifyKeyListenerHooked= fContentAssistSubjectControlAdapter.prependVerifyKeyListener(fInternalListener); } } }
/** * Uninstall the key listener from the text viewer's widget. * * @since 3.0 */ private void uninstallVerifyKeyListener() { if (fVerifyKeyListenerHooked) { if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) fContentAssistSubjectControlAdapter.removeVerifyKeyListener(fInternalListener); fVerifyKeyListenerHooked= false; } }
/** * Installs a key listener on the text viewer's widget. */ private void installKeyListener() { if (!fVerifyKeyListenerHooked) { if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) { fVerifyKeyListenerHooked= fContentAssistSubjectControlAdapter.prependVerifyKeyListener(fInternalListener); } } }
/** * Uninstall the key listener from the text viewer's widget. * * @since 3.0 */ private void uninstallVerifyKeyListener() { if (fVerifyKeyListenerHooked) { if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) fContentAssistSubjectControlAdapter.removeVerifyKeyListener(fInternalListener); fVerifyKeyListenerHooked= false; } }
/** * Displays the given context information for the given offset. * * @param info the context information * @param offset the offset * @since 2.0 */ public void showContextInformation(final IContextInformation info, final int offset) { Control control= fContentAssistSubjectControlAdapter.getControl(); BusyIndicator.showWhile(control.getDisplay(), new Runnable() { @Override public void run() { if (info == null) validateContextInformation(); else { ContextFrame frame= createContextFrame(info, offset); if (isDuplicate(frame)) validateContextInformation(); else internalShowContextInfo(frame); hideContextSelector(); } } }); }
/** * Unregister this completion proposal popup. * * @since 3.0 */ private void unregister() { if (fDocumentListener != null) { IDocument document= fContentAssistSubjectControlAdapter.getDocument(); if (document != null) document.removeDocumentListener(fDocumentListener); fDocumentListener= null; } fDocumentEvents.clear(); if (fKeyListener != null && fContentAssistSubjectControlAdapter.getControl() != null && !fContentAssistSubjectControlAdapter.getControl().isDisposed()) { fContentAssistSubjectControlAdapter.removeKeyListener(fKeyListener); fKeyListener= null; } if (fLastProposal != null) { if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null) { ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal; extension.unselected(fViewer); } fLastProposal= null; } fFilteredProposals= null; fComputedProposals= null; fContentAssistant.possibleCompletionsClosed(); }
@Override public void run() { if (!fIsFilterPending) return; fIsFilterPending= false; if (!Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) return; int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x; ICompletionProposal[] proposals= null; try { if (offset > -1) { DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents); proposals= computeFilteredProposals(offset, event); } } catch (BadLocationException x) { } finally { fDocumentEvents.clear(); } fFilterOffset= offset; if (proposals != null && proposals.length > 0) setProposals(proposals, fIsFilteredSubset); else hide(); } };
private Rectangle getCaretRectangle(int offset) { Point location= fContentAssistSubjectControlAdapter.getLocationAtOffset(offset); Control subjectControl= fContentAssistSubjectControlAdapter.getControl(); Point controlSize= subjectControl.getSize(); constrainLocation(location, new Point(0, 0), new Rectangle(0, 0, controlSize.x, controlSize.y)); location= subjectControl.toDisplay(location); Rectangle subjectRectangle= new Rectangle(location.x, location.y, 1, fContentAssistSubjectControlAdapter.getLineHeight()); return subjectRectangle; }
private Rectangle getCaretRectangle(int offset) { Point location= fContentAssistSubjectControlAdapter.getLocationAtOffset(offset); Control subjectControl= fContentAssistSubjectControlAdapter.getControl(); Point controlSize= subjectControl.getSize(); constrainLocation(location, new Point(0, 0), new Rectangle(0, 0, controlSize.x, controlSize.y)); location= subjectControl.toDisplay(location); Rectangle subjectRectangle= new Rectangle(location.x, location.y, 1, fContentAssistSubjectControlAdapter.getLineHeight()); return subjectRectangle; }
/** * Hides the popup and returns <code>true</code> if the popup is configured * to never display an empty list. Returns <code>false</code> otherwise. * * @param autoActivated whether the invocation was auto-activated * @return <code>false</code> if an empty list should be displayed, <code>true</code> otherwise * @since 3.2 */ private boolean hideWhenNoProposals(boolean autoActivated) { if (autoActivated || !fContentAssistant.isShowEmptyList()) { if (!autoActivated) { Control control= fContentAssistSubjectControlAdapter.getControl(); if (control != null && !control.isDisposed()) control.getDisplay().beep(); } hide(); return true; } return false; }
/** * Hides the popup and returns <code>true</code> if the popup is configured * to never display an empty list. Returns <code>false</code> otherwise. * * @param autoActivated whether the invocation was auto-activated * @return <code>false</code> if an empty list should be displayed, <code>true</code> otherwise * @since 3.2 */ boolean hideWhenNoProposals(boolean autoActivated) { if (autoActivated || !fContentAssistant.isShowEmptyList()) { if (!autoActivated) { Control control= fContentAssistSubjectControlAdapter.getControl(); if (control != null && !control.isDisposed()) control.getDisplay().beep(); } hide(); return true; } return false; }
protected void showAssist(final int showStyle) { final Control control= fContentAssistSubjectControlAdapter.getControl(); if (control == null) return; final Display d= control.getDisplay(); if (d == null) return; try { d.syncExec(() -> { if (isProposalPopupActive()) return; if (control.isDisposed() || !control.isFocusControl()) return; if (showStyle == SHOW_PROPOSALS) { if (!prepareToShowCompletions(true)) return; fProposalPopup.showProposals(true); fLastAutoActivation= System.currentTimeMillis(); } else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null) { promoteKeyListener(); fContextInfoPopup.showContextProposals(true); } }); } catch (SWTError e) { } } }
/** * Installs this closer on it's viewer's text widget. */ protected void install() { Control control= fContentAssistSubjectControlAdapter.getControl(); fControl= control; if (Helper.okToUse(control)) { Shell shell= control.getShell(); fShell= shell; shell.addControlListener(this); control.addMouseListener(this); control.addFocusListener(this); /* * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of * Internal Errors */ control.addDisposeListener(this); } if (fViewer != null) fViewer.addViewportListener(this); }
/** * Installs this closer on it's viewer's text widget. */ protected void install() { Control control= fContentAssistSubjectControlAdapter.getControl(); fControl= control; if (Helper.okToUse(control)) { Shell shell= control.getShell(); fShell= shell; shell.addControlListener(this); control.addMouseListener(this); control.addFocusListener(this); /* * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of * Internal Errors */ control.addDisposeListener(this); } if (fViewer != null) fViewer.addViewportListener(this); }
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); }
/** * Displays the given context information for the given offset. * * @param info the context information * @param offset the offset * @since 2.0 */ public void showContextInformation(final IContextInformation info, final int offset) { Control control= fContentAssistSubjectControlAdapter.getControl(); BusyIndicator.showWhile(control.getDisplay(), () -> { if (info == null) validateContextInformation(); else { ContextFrame frame= createContextFrame(info, offset); if (isDuplicate(frame)) validateContextInformation(); else internalShowContextInfo(frame); hideContextSelector(); } }); }
/** * Creates the context information popup. This is the tool tip like overlay window. */ private void createContextInfoPopup() { if (Helper.okToUse(fContextInfoPopup)) return; Control control= fContentAssistSubjectControlAdapter.getControl(); Display display= control.getDisplay(); fContextInfoPopup= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP); fContextInfoPopup.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); fContextInfoText= new StyledText(fContextInfoPopup, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP); Color c= fContentAssistant.getContextInformationPopupBackground(); if (c == null) c= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fContextInfoText.setBackground(c); c= fContentAssistant.getContextInformationPopupForeground(); if (c == null) c= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); fContextInfoText.setForeground(c); }
/** * Creates the context information popup. This is the tool tip like overlay window. */ private void createContextInfoPopup() { if (Helper.okToUse(fContextInfoPopup)) return; Control control= fContentAssistSubjectControlAdapter.getControl(); Display display= control.getDisplay(); fContextInfoPopup= new Shell(control.getShell(), SWT.NO_TRIM | SWT.ON_TOP); fContextInfoPopup.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); fContextInfoText= new StyledText(fContextInfoPopup, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP); Color c= fContentAssistant.getContextInformationPopupBackground(); if (c == null) c= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fContextInfoText.setBackground(c); c= fContentAssistant.getContextInformationPopupForeground(); if (c == null) c= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); fContextInfoText.setForeground(c); }