/** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. * * @return <code>true</code> if there are still proposals left, <code>false</code> if the popup has been closed * @since 3.7 */ public boolean doFilterProposals() { fInvocationProcessedCounter= fInvocationCounter; int offset= fViewer.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); return true; } else { hide(); return false; } }
/** * Takes the selected proposal and applies it. * * @param stateMask the state mask * @return <code>true</code> iff a proposal has been inserted * @since 2.1 */ private boolean selectProposalWithMask(int stateMask) { if (fInvocationCounter != fInvocationProcessedCounter) if (!doFilterProposals()) return false; ICompletionProposal p= getSelectedProposal(); hide(); if (p != null) { insertProposal(p, (char) 0, stateMask, fViewer.getSelectedRange().x); return true; } return false; }
private void resizeProposalSelector(boolean adjustWidth) { int width= adjustWidth ? SWT.DEFAULT : ((GridData)fProposalTable.getLayoutData()).widthHint; Point size= fProposalTable.computeSize(width, SWT.DEFAULT, true); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= adjustWidth ? Math.min(size.x, 300) : width; data.heightHint= Math.min(getTableHeightHint(fProposalTable, fProposalTable.getItemCount()), getTableHeightHint(fProposalTable, 10)); fProposalTable.setLayoutData(data); fProposalShell.layout(true); fProposalShell.pack(); if (adjustWidth) { fProposalShell.setLocation(getLocation()); } }
fComputedProposals= computeProposals(fInvocationOffset); insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset); fLineDelimiter= styledText.getLineDelimiter(); createProposalSelector(); setProposals(fComputedProposals); resizeProposalSelector(true); displayProposals(); return getErrorMessage();
filterProposals(); return true; hide(); return true; selectProposal(newSelection, (e.stateMask & SWT.CTRL) != 0); case 0x1B: // Esc e.doit= false; hide(); break; case '\r': // Enter if ((e.stateMask & SWT.CTRL) == 0) { e.doit= !selectProposalWithMask(e.stateMask); ICompletionProposal p= getSelectedProposal(); if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension t= (ICompletionProposalExtension) p; char[] triggers= t.getTriggerCharacters(); if (contains(triggers, key)) { hide(); e.doit= false; insertProposal(p, key, e.stateMask, fViewer.getSelectedRange().x);
Point newLocation= getLocation(); if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y) fProposalShell.setLocation(newLocation); fProposalShell.addDisposeListener(e -> unregister());
@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); }
fComputedProposals= computeProposals(fInvocationOffset); return fComputedProposals;
Point newLocation= getLocation(); if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y) fProposalShell.setLocation(newLocation);
fComputedProposals= computeProposals(fInvocationOffset); insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset); fLineDelimiter= styledText.getLineDelimiter(); createProposalSelector(); setProposals(fComputedProposals); resizeProposalSelector(true); displayProposals(); return getErrorMessage();
filterProposals(); return true; hide(); return true; selectProposal(newSelection, (e.stateMask & SWT.CTRL) != 0); case 0x1B: // Esc e.doit= false; hide(); break; case '\r': // Enter if ((e.stateMask & SWT.CTRL) == 0) { e.doit= !selectProposalWithMask(e.stateMask); ICompletionProposal p= getSelectedProposal(); if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension t= (ICompletionProposalExtension) p; char[] triggers= t.getTriggerCharacters(); if (contains(triggers, key)) { hide(); e.doit= false; insertProposal(p, key, e.stateMask, fViewer.getSelectedRange().x);
@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); }
fComputedProposals= computeProposals(fInvocationOffset); return fComputedProposals;
/** * Takes the selected proposal and applies it. * * @param stateMask the state mask * @return <code>true</code> iff a proposal has been inserted * @since 2.1 */ private boolean selectProposalWithMask(int stateMask) { if (fInvocationCounter != fInvocationProcessedCounter) if (!doFilterProposals()) return false; ICompletionProposal p= getSelectedProposal(); hide(); if (p != null) { insertProposal(p, (char) 0, stateMask, fViewer.getSelectedRange().x); return true; } return false; }
/** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. * * @return <code>true</code> if there are still proposals left, <code>false</code> if the popup has been closed * @since 3.7 */ public boolean doFilterProposals() { fInvocationProcessedCounter= fInvocationCounter; int offset= fViewer.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); return true; } else { hide(); return false; } }
private void resizeProposalSelector(boolean adjustWidth) { int width= adjustWidth ? SWT.DEFAULT : ((GridData)fProposalTable.getLayoutData()).widthHint; Point size= fProposalTable.computeSize(width, SWT.DEFAULT, true); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= adjustWidth ? Math.min(size.x, 300) : width; data.heightHint= Math.min(getTableHeightHint(fProposalTable, fProposalTable.getItemCount()), getTableHeightHint(fProposalTable, 10)); fProposalTable.setLayoutData(data); fProposalShell.layout(true); fProposalShell.pack(); if (adjustWidth) { fProposalShell.setLocation(getLocation()); } }