org.eclipse.jface.fieldassist.ContentProposalAdapter Java Examples
The following examples show how to use
org.eclipse.jface.fieldassist.ContentProposalAdapter.
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: 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 #2
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void proposalAccepted(final IContentProposal proposal) { final int proposalAcceptanceStyle = autoCompletion.getContentProposalAdapter().getProposalAcceptanceStyle(); if (proposalAcceptanceStyle == ContentProposalAdapter.PROPOSAL_REPLACE) { final Expression selectedExpression = getSelectedExpression(); final CompoundCommand cc = new CompoundCommand("Update Expression (and potential side components)"); final ExpressionProposal prop = (ExpressionProposal) proposal; final Expression copy = EcoreUtil.copy((Expression) prop.getExpression()); copy.setReturnTypeFixed(selectedExpression.isReturnTypeFixed()); sideModificationOnProposalAccepted(cc, copy); updateSelection(cc, copy); fireSelectionChanged(new SelectionChangedEvent(ExpressionViewer.this, new StructuredSelection(selectedExpression))); validate(); } }
Example #3
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void manageNatureProviderAndAutocompletionProposal(final Object input) { if (input instanceof EObject && context == null) { setContext((EObject) input); } final Expression selectedExpression = getSelectedExpression(); if (selectedExpression != null && ExpressionConstants.CONDITION_TYPE.equals(selectedExpression.getType())) { setProposalsFiltering(false); autoCompletion.getContentProposalAdapter().setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT); } else { autoCompletion.getContentProposalAdapter().setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); } autoCompletion.setContext(context); final Set<Expression> filteredExpressions = getFilteredExpressions(); autoCompletion.setProposals(filteredExpressions.toArray(new Expression[filteredExpressions.size()])); final ArrayList<String> filteredExpressionType = getFilteredExpressionType(); autoCompletion.setFilteredExpressionType(filteredExpressionType); if (filteredExpressionType.contains(ExpressionConstants.VARIABLE_TYPE) && filteredExpressionType.contains(ExpressionConstants.PARAMETER_TYPE) && filteredExpressionType.contains(ExpressionConstants.FORM_REFERENCE_TYPE) && filteredExpressions.isEmpty()) { contentAssistText.setProposalEnabled(false); } else { contentAssistText.setProposalEnabled(true); } }
Example #4
Source File: CommandDataDialog.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
private ContentProposalAdapter addContentAssistSimple(Text textControl) { char[] autoActivationCharacters = new char[] { '$', '{' }; KeyStroke keyStroke = null; try { keyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // assume that myTextControl has already been created in some way List<Variable> variables = Variable.getVisibleVariables(); String[] proposals = new String [variables.size()]; for(int i=0;i<variables.size();i++) { proposals[i] = variables.get(i).getFullVariableName(); } ContentProposalAdapter adapter = new ContentProposalAdapter( textControl , new TextContentAdapter(), new SimpleContentProposalProvider(proposals), keyStroke, autoActivationCharacters); adapter.setPropagateKeys(false); adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE); //adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); return adapter; }
Example #5
Source File: AutoCompletionField.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public AutoCompletionField(final Control control, final IControlContentAdapter controlContentAdapter, final IExpressionProposalLabelProvider proposalLabelProvider) { contentProposalProvider = new ExpressionProposalProvider(proposalLabelProvider); contentProposalProvider.setFiltering(true); contentProposalAdapter = new BonitaContentProposalAdapter(control, controlContentAdapter, contentProposalProvider, null, null); contentProposalAdapter.setLabelProvider(new ExpressionLabelProvider() { @Override public String getText(final Object expression) { return ((ExpressionProposal) expression).getLabel(); } }); contentProposalAdapter.setPropagateKeys(true); contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); }
Example #6
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 #7
Source File: FieldAssistHelper.java From birt with Eclipse Public License 1.0 | 5 votes |
private int getContentAssistAcceptance( ) { IPreferenceStore store = getPreferenceStore( ); String acceptanceStyle = store.getString( PreferenceConstants.PREF_CONTENTASSISTRESULT ); if ( acceptanceStyle.equals( PreferenceConstants.PREF_CONTENTASSISTRESULT_INSERT ) ) return ContentProposalAdapter.PROPOSAL_INSERT; if ( acceptanceStyle.equals( PreferenceConstants.PREF_CONTENTASSISTRESULT_REPLACE ) ) return ContentProposalAdapter.PROPOSAL_REPLACE; return ContentProposalAdapter.PROPOSAL_IGNORE; }
Example #8
Source File: ParameterProposals.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public static ContentProposalAdapter on(Text text, Supplier<List<Parameter>> locals) { ContentProposalAdapter adapter = new ContentProposalAdapter( text, new TextContentAdapter(), new ParameterProposals(locals), null, null); return adapter; }
Example #9
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void updateAutoCompletionContentProposalAdapter() { if (ExpressionConstants.CONDITION_TYPE.equals(getSelectedExpression().getType())) { autoCompletion.getContentProposalAdapter().setEnabled(false); autoCompletion.getContentProposalAdapter().setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_INSERT); } else { autoCompletion.getContentProposalAdapter().setEnabled(true); autoCompletion.getContentProposalAdapter().setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE); } }
Example #10
Source File: FieldAssistHelper.java From birt with Eclipse Public License 1.0 | 5 votes |
private int getContentAssistFilterStyle( ) { IPreferenceStore store = getPreferenceStore( ); String acceptanceStyle = store.getString( PreferenceConstants.PREF_CONTENTASSISTFILTER ); if ( acceptanceStyle.equals( PreferenceConstants.PREF_CONTENTASSISTFILTER_CHAR ) ) return ContentProposalAdapter.FILTER_CHARACTER; if ( acceptanceStyle.equals( PreferenceConstants.PREF_CONTENTASSISTFILTER_CUMULATIVE ) ) return ContentProposalAdapter.FILTER_CUMULATIVE; return ContentProposalAdapter.FILTER_NONE; }
Example #11
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 #12
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 #13
Source File: MenuDataDialog.java From EasyShell with Eclipse Public License 2.0 | 5 votes |
private ContentProposalAdapter addContentAssistExtended(Text textControl) { char[] autoActivationCharacters = new char[] { '$', '{' }; Map<String, String> proposals = new LinkedHashMap<String, String>(); // add internal variables proposals.putAll(Variable.getInternalVariableInfoMap()); ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl, new CommandVariableContentAdapter(), new CommandVariableContentProposalProvider(proposals), null, autoActivationCharacters, true); adapter.setPropagateKeys(false); adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE); return adapter; }
Example #14
Source File: CommandDataDialog.java From EasyShell with Eclipse Public License 2.0 | 5 votes |
private ContentProposalAdapter addContentAssist(Text textControl) { // add content assist to command text editor field if (useExtendedContentAssists) { return addContentAssistExtended(textControl); } else { return addContentAssistSimple(textControl); } }
Example #15
Source File: CommandDataDialog.java From EasyShell with Eclipse Public License 2.0 | 5 votes |
private ContentProposalAdapter addContentAssistExtended(Text textControl) { char[] autoActivationCharacters = new char[] { '$', '{' }; Map<String, String> proposals = new LinkedHashMap<String, String>(); // add own variables proposals.putAll(Variable.getVariableInfoMap()); // add eclipse variables proposals.putAll(Variable.getEclipseVariableInfoMap()); ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl, new CommandVariableContentAdapter(), new CommandVariableContentProposalProvider(proposals), null, autoActivationCharacters, true); adapter.setPropagateKeys(false); adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE); return adapter; }
Example #16
Source File: DynamicWorkingSetPage.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
private void installPatternContentAssist() { ContentProposalAdapter contentAssist = new ContentAssistCommandAdapter( patternText, new TextContentAdapter(), new FindReplaceDocumentAdapterContentProposalProvider( true ), CONTENT_ASSIST_PROPOSALS, new char[]{ '\\', '[', '(' }, true ); contentAssist.setEnabled( true ); }
Example #17
Source File: ContentProposalViewerKeyHandler.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void createContentAdpater() { // SemanticContentControlAdapter controlAdapter = new SemanticContentControlAdapter(proposalProvider, getViewer()); adapter = new ContentProposalAdapter((Composite) getViewer().getControl(), proposalHandler.getProposalControlAdapter(), proposalHandler, keyStroke, null); adapter.setLabelProvider(proposalHandler.getProposalLabelProvider()); adapter.setPropagateKeys(true); // TODO: If not set, the adapter uses the full width of the // GraphicalViewer as initial bounds adapter.setPopupSize(new Point(400, 150)); }
Example #18
Source File: NpmInstallWidget.java From typescript.java with MIT License | 5 votes |
private void addContentProposal(Text text) { char[] autoActivationCharacters = null;// new char[] { '.' }; KeyStroke keyStroke = null; try { keyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException e) { e.printStackTrace(); } adapter = new VersionContentProposalAdapter(text, new TextContentAdapter(), new VersionContentProposalProvider(), keyStroke, autoActivationCharacters); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); adapter.setPropagateKeys(true); adapter.setLabelProvider(VersionLabelProvider.getInstance()); }
Example #19
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()); }
Example #20
Source File: MtesterAutoCompleteField.java From AndroidRobot with Apache License 2.0 | 4 votes |
public ContentProposalAdapter getContentProposalAdapter() { return contentProposalAdapter; }
Example #21
Source File: CodingSelectionComposite.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public CodingSelectionComposite(Composite parent, int style){ super(parent, style); GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; setLayout(gridLayout); systemCombo = new ComboViewer(this); systemCombo.setContentProvider(new ArrayContentProvider()); systemCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element){ return super.getText(element); } }); systemCombo.setInput(CodingServiceComponent.getService().getAvailableCodeSystems().stream() .filter(system -> !system.equals(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem())) .collect(Collectors.toList())); systemCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event){ if (proposalProvider != null) { ISelection selection = event.getSelection(); if (selection instanceof StructuredSelection && !selection.isEmpty()) { proposalProvider .setSelectedSystem(Optional .of((String) ((StructuredSelection) selection).getFirstElement())); } else { proposalProvider.setSelectedSystem(Optional.empty()); } } } }); selectionTxt = new Text(this, SWT.BORDER); selectionTxt.setMessage("Coding selektieren"); selectionTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); proposalProvider = new CodingContentProposalProvider(); ContentProposalAdapter toAddressProposalAdapter = new ContentProposalAdapter(selectionTxt, new TextContentAdapter(), proposalProvider, null, null); toAddressProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal){ selectionTxt.setText(proposal.getContent()); proposalProvider.getCodingForProposal(proposal) .ifPresent(iCoding -> selectedCode = Optional.of(iCoding)); selectionTxt.setSelection(selectionTxt.getText().length()); Object[] listeners = selectionListeners.getListeners(); for (Object object : listeners) { SelectionChangedEvent selectionEvent = new SelectionChangedEvent(CodingSelectionComposite.this, getSelection()); ((ISelectionChangedListener) object).selectionChanged(selectionEvent); } } }); MenuManager menuManager = new MenuManager(); menuManager.add(new Action("Lokalen Code anlegen") { @Override public void run(){ TransientCoding transientCoding = new TransientCoding( CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem(), selectionTxt.getSelectionText(), ""); CodingEditDialog editDialog = new CodingEditDialog(transientCoding, getShell()); if (editDialog.open() == CodingEditDialog.OK) { CodingServiceComponent.getService().addLocalCoding(transientCoding); // trigger reload of code system setCodeSystem(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem()); } } @Override public boolean isEnabled(){ ISelection systemSelection = systemCombo.getSelection(); if (systemSelection instanceof StructuredSelection) { Object codeSystem = ((StructuredSelection) systemSelection).getFirstElement(); if(codeSystem instanceof String && codeSystem.equals(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem()) ) { String text = selectionTxt.getSelectionText(); return text != null && !text.isEmpty(); } } return false; } }); menuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager){ IContributionItem[] items = manager.getItems(); for (IContributionItem iContributionItem : items) { iContributionItem.update(); } } }); selectionTxt.setMenu(menuManager.createContextMenu(selectionTxt)); }
Example #22
Source File: ParameterProposals.java From olca-app with Mozilla Public License 2.0 | 4 votes |
public static ContentProposalAdapter on(Text text) { return on(text, null); }