/** * Displays the context selector. */ private void displayContextSelector() { if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR)) fContextSelectorShell.setVisible(true); }
/** * Returns the completion proposal available at the given offset of the * viewer's document. Delegates the work to the content assistant. * * @param offset the offset * @return the completion proposals available at this offset */ private ICompletionProposal[] computeProposals(int offset) { return fContentAssistant.computeCompletionProposals(fViewer, offset); }
/** * Computes all possible context information for the given offset. * * @param position the offset * @return all possible context information for the given offset * @since 2.0 */ private IContextInformation[] computeContextInformation(int position) { return fContentAssistant.computeContextInformation(fViewer, position); }
Color c= fContentAssistant.getContextSelectorBackground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); fContextSelectorTable.setBackground(c); c= fContentAssistant.getContextSelectorForeground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
/** * 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); } }
/** * Registers a content assist listener. * The following are valid listener types: * <ul> * <li>AUTO_ASSIST * <li>CONTEXT_SELECTOR * <li>PROPOSAL_SELECTOR * <li>CONTEXT_INFO_POPUP * <ul> * Returns whether the listener could be added successfully. A listener * can not be added if the widget token could not be acquired. * * @param listener the listener to register * @param type the type of listener * @return <code>true</code> if the listener could be added */ boolean addContentAssistListener(IContentAssistListener2 listener, int type) { if (acquireWidgetToken(type)) { fListeners[type]= listener; if (getNumberOfListeners() == 1) { fCloser= new Closer(); fCloser.install(); fViewer.setEventConsumer(fInternalListener); installKeyListener(); } return true; } return false; }
fIsColoredLabelsSupportEnabled= fContentAssistant.isColoredLabelsSupportEnabled(); if (fIsColoredLabelsSupportEnabled) TableOwnerDrawSupport.install(fProposalTable); fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
/** * Hodes the context selector. */ private void hideContextSelector() { if (Helper2.okToUse(fContextSelectorShell)) { fContentAssistant.removeContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR); fPopupCloser.uninstall(); fContextSelectorShell.setVisible(false); fContextSelectorShell.dispose(); fContextSelectorShell= null; } if (!Helper2.okToUse(fContextInfoPopup)) fContentAssistant.contextInformationClosed(); }
/** * This does the actual constructor work. * * @param model the linked mode model * @param targets the non-empty array of targets upon which the linked mode UI * should act */ private void constructor(LinkedModeModel model, LinkedModeUITarget[] targets) { Assert.isNotNull(model); Assert.isNotNull(targets); Assert.isTrue(targets.length > 0); Assert.isTrue(model.getTabStopSequence().size() > 0); fModel= model; fTargets= targets; fCurrentTarget= targets[0]; fIterator= new TabStopIterator(fModel.getTabStopSequence()); fIterator.setCycling(!fModel.isNested()); fModel.addLinkingListener(fLinkedListener); fAssistant= new ContentAssistant2(); fAssistant.addProposalListener(fProposalListener); // TODO find a way to set up content assistant. // fAssistant.setDocumentPartitioning(IJavaPartitions.JAVA_PARTITIONING); fCaretPosition.delete(); }
Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { if (fProposalPopupOrientation == PROPOSAL_STACKED) layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset()); addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW) layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
fContentAssistant.showContextInformation(info, position); fContentAssistant.fireProposalChosen(p);
/** * Enables the support for colored labels in the proposal popup. * <p>Completion proposals can implement {@link ICompletionProposalExtension6} * to provide colored proposal labels.</p> * * @param isEnabled if <code>true</code> the support for colored labels is enabled in the proposal popup * @since 3.4 */ public void enableColoredLabels(boolean isEnabled) { fAssistant.enableColoredLabels(isEnabled); }
Color c= fContentAssistant.getContextSelectorBackground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); fContextSelectorTable.setBackground(c); c= fContentAssistant.getContextSelectorForeground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant2.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
/** * 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); } }
/** * Registers a content assist listener. * The following are valid listener types: * <ul> * <li>AUTO_ASSIST * <li>CONTEXT_SELECTOR * <li>PROPOSAL_SELECTOR * <li>CONTEXT_INFO_POPUP * <ul> * Returns whether the listener could be added successfully. A listener * can not be added if the widget token could not be acquired. * * @param listener the listener to register * @param type the type of listener * @return <code>true</code> if the listener could be added */ boolean addContentAssistListener(IContentAssistListener2 listener, int type) { if (acquireWidgetToken(type)) { fListeners[type]= listener; if (getNumberOfListeners() == 1) { fCloser= new Closer(); fCloser.install(); fViewer.setEventConsumer(fInternalListener); installKeyListener(); } return true; } return false; }
fIsColoredLabelsSupportEnabled= fContentAssistant.isColoredLabelsSupportEnabled(); if (fIsColoredLabelsSupportEnabled) TableOwnerDrawSupport.install(fProposalTable); fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
/** * Hodes the context selector. */ private void hideContextSelector() { if (Helper2.okToUse(fContextSelectorShell)) { fContentAssistant.removeContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR); fPopupCloser.uninstall(); fContextSelectorShell.setVisible(false); fContextSelectorShell.dispose(); fContextSelectorShell= null; } if (!Helper2.okToUse(fContextInfoPopup)) fContentAssistant.contextInformationClosed(); }
/** * This does the actual constructor work. * * @param model the linked mode model * @param targets the non-empty array of targets upon which the linked mode UI * should act */ private void constructor(LinkedModeModel model, LinkedModeUITarget[] targets) { Assert.isNotNull(model); Assert.isNotNull(targets); Assert.isTrue(targets.length > 0); Assert.isTrue(model.getTabStopSequence().size() > 0); fModel= model; fTargets= targets; fCurrentTarget= targets[0]; fIterator= new TabStopIterator(fModel.getTabStopSequence()); fIterator.setCycling(!fModel.isNested()); fModel.addLinkingListener(fLinkedListener); fAssistant= new ContentAssistant2(); fAssistant.addProposalListener(fProposalListener); // TODO find a way to set up content assistant. // fAssistant.setDocumentPartitioning(IJavaPartitions.JAVA_PARTITIONING); fCaretPosition.delete(); }
Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { if (fProposalPopupOrientation == PROPOSAL_STACKED) layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset()); addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW) layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
fContentAssistant.showContextInformation(info, position); fContentAssistant.fireProposalChosen(p);