Java Code Examples for org.eclipse.jface.fieldassist.ContentProposalAdapter#setProposalAcceptanceStyle()
The following examples show how to use
org.eclipse.jface.fieldassist.ContentProposalAdapter#setProposalAcceptanceStyle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoCompleteTextCellEditor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void setProposalProvider(IContentProposalProvider proposalProvider) { final TextContentAdapter controlContentAdapter = new TextContentAdapter(); proposalAdapter = new ContentProposalAdapter(getControl(), controlContentAdapter, proposalProvider, contentAssistKeyStroke, null); proposalAdapter.setPropagateKeys(true); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); proposalAdapter.setAutoActivationDelay(0); proposalAdapter.getControl().addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { AutoCompleteTextCellEditor.this.focusLost(); } }); proposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { fireApplyEditorValue(); } }); }
Example 2
Source File: AutoCompleteTextUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static <T> void addAutoCompleteSupport(Text text, IContentProposalProvider cpProvider, T defaultObject){ setValue(text, defaultObject); ContentProposalAdapter cpAdapter = new ContentProposalAdapter(text, new TextContentAdapter(), cpProvider, null, null); cpAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); cpAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal){ text.setText(proposal.getLabel()); text.setData(PROPOSAL_RET_OBJ, getProposalObject(proposal)); text.setSelection(text.getText().length()); } }); text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e){ // resets the contents after manual change text.setData(PROPOSAL_RET_OBJ, null); } }); }
Example 3
Source File: SearchDialog.java From JDeodorant with MIT License | 5 votes |
@Override protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(1, false); container.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); container.setLayout(layout); Label enterClassNameLabel = new Label(container, SWT.NONE); enterClassNameLabel.setText("Enter Class Name: "); GridData dataClassName = new GridData(); dataClassName.grabExcessHorizontalSpace = true; dataClassName.horizontalAlignment = GridData.FILL; inputText = new Text(container, SWT.BORDER); inputText.setLayoutData(dataClassName); ArrayList<PMClassFigure> classes = (ArrayList<PMClassFigure>) PackageMapDiagram.allClassFigures; String[] classNames= new String[classes.size()]; for(int i=0; i< classes.size(); i++){ PMClassFigure figure = classes.get(i); classNames[i] = figure.getName(); } //new AutoCompleteField(inputText, new TextContentAdapter(),classNames); MyContentProposalProvider provider = new MyContentProposalProvider(classNames); ContentProposalAdapter adapter = new ContentProposalAdapter(inputText, new TextContentAdapter(), provider, null, null); adapter.setPropagateKeys(true); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); return area; }
Example 4
Source File: FieldAssistHelper.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @param control * @param contentAdapter * @param values */ public void installContentProposalAdapter( Control control, IControlContentAdapter contentAdapter, String[] values ) { IPreferenceStore store = getPreferenceStore( ); boolean propagate = store.getBoolean( PreferenceConstants.PREF_CONTENTASSISTKEY_PROPAGATE ); KeyStroke keyStroke = null; char[] autoActivationCharacters = null; int autoActivationDelay = store.getInt( PreferenceConstants.PREF_CONTENTASSISTDELAY ); String triggerKey = getTriggerKey( ); if ( triggerKey == null ) { keyStroke = null; } else { keyStroke = getKeyStroke( triggerKey ); } ContentProposalAdapter adapter = new ContentProposalAdapter( control, contentAdapter, getContentProposalProvider( values ), keyStroke, autoActivationCharacters ); adapter.setAutoActivationDelay( autoActivationDelay ); adapter.setPropagateKeys( propagate ); adapter.setFilterStyle( getContentAssistFilterStyle( ) ); adapter.setProposalAcceptanceStyle( getContentAssistAcceptance( ) ); }
Example 5
Source File: WorkspaceWizardPage.java From n4js with Eclipse Public License 1.0 | 4 votes |
private void setupContentProposal(WorkspaceWizardPageForm wizardForm) { // Get the active binding's content assist key strokes KeyStroke keyInitiator = getActiveContentAssistBinding(); // If unbound don't configure the content proposal if (null == keyInitiator) { return; } // Setup project content proposal ContentProposalAdapter projectAdapter = new ContentProposalAdapter(wizardForm.getProjectText(), new TextContentAdapter(), projectContentProposalProvider, keyInitiator, null); projectAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); ImageDescriptor projectSymbol = PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); projectAdapter.setLabelProvider( new SimpleImageContentProposalLabelProvider(projectSymbol)); createContentProposalDecoration(wizardForm.getProjectText()); sourceFolderContentProposalAdapter = new ContentProposalAdapter( wizardForm.getSourceFolderText(), new TextContentAdapter(), null, keyInitiator, null); sourceFolderContentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); sourceFolderContentProposalAdapter.setLabelProvider( new SimpleImageContentProposalLabelProvider( ImageDescriptorCache.ImageRef.SRC_FOLDER.asImageDescriptor().orNull())); createContentProposalDecoration(wizardForm.getSourceFolderText()); moduleSpecifierContentProposalAdapter = new ContentProposalAdapter( wizardForm.getModuleSpecifierText().getInternalText(), new TextContentAdapter(), null, keyInitiator, null); wizardForm.getModuleSpecifierText().createDecoration(contentProposalDecorationImage); // Update proposal context whenever the model changes model.addPropertyChangeListener(evt -> { if (evt.getPropertyName() == WorkspaceWizardModel.PROJECT_PROPERTY || evt.getPropertyName() == WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY) { updateProposalContext(); } }); updateProposalContext(); moduleSpecifierContentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); moduleSpecifierContentProposalAdapter .setLabelProvider(new ModuleSpecifierProposalLabelProvider()); }