List of usage examples for org.eclipse.jface.fieldassist SimpleContentProposalProvider SimpleContentProposalProvider
public SimpleContentProposalProvider(String... proposals)
From source file:com.amalto.workbench.utils.WidgetUtils.java
License:Open Source License
public static ContentProposalAdapterExtended addContentProposal(Control control, String[] proposals, char[] autoActivationCharacters) { // add content proposal ContentProposalAdapterExtended adapter = ProposalUtils.getCommonProposal(control, new SimpleContentProposalProvider(proposals), autoActivationCharacters); // ContentProposalAdapter adapter = new ContentProposalAdapter(control,new TextContentAdapter(), new // SimpleContentProposalProvider(proposals), keyStroke, // autoActivationCharacters); return adapter; }
From source file:com.android.traceview.ProblemView.java
License:Apache License
public ProblemView(Composite parent, TraceReader reader, ContextLogReader logReader, SelectionController selectController, Shell shell) { super(parent, SWT.NONE); parentShell = shell;//ww w .j av a 2 s .com setLayout(new GridLayout(2, true)); this.mSelectionController = selectController; mCombinedReader = new CombinedReader(reader, logReader); mReaders.add(mCombinedReader); Display display = getDisplay(); mLogMap = logReader.getLogMap(); mTraceRecords = reader.getThreadTimeRecords(); // Add container holding the problem definition form Composite formComposite = new Composite(this, SWT.NONE); formComposite.setLayout(new FillLayout(SWT.VERTICAL)); formComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Add a label for the problem definer Label problemLabel = new Label(formComposite, SWT.NONE); problemLabel.setText("Problem:"); // Add radio button for BRB option BRBButton = new Button(formComposite, SWT.RADIO); BRBButton.setText("BigRedButton"); // Add radio button for own problem definition option problemDefButton = new Button(formComposite, SWT.RADIO); problemDefButton.setText("Function call + constraint"); Composite composite = new Composite(formComposite, SWT.NONE); composite.setLayout(new GridLayout(2, false)); // composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Add a text box for searching for method names Label callLabel = new Label(composite, SWT.NONE); callLabel.setText("Function:"); // Add a text box for searching for method names mProblemBox = new Text(composite, SWT.BORDER); mProblemBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mProblemBox.setEnabled(false); mColorNoMatch = new Color(display, 255, 200, 200); mColorMatch = mProblemBox.getBackground(); ContentProposalAdapter adapter = null; mScp = new SimpleContentProposalProvider(new String[0]); adapter = new ContentProposalAdapter(mProblemBox, new TextContentAdapter(), mScp, null, null); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); final Composite constraintHolderComposite = new Composite(formComposite, SWT.NONE); constraintHolderComposite.setLayout(new FormLayout()); // composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite mConstraintComposite = new Composite(constraintHolderComposite, SWT.NONE); RowLayout constraintLayout = new RowLayout(); constraintLayout.pack = true; constraintLayout.type = SWT.HORIZONTAL; mConstraintComposite.setLayout(constraintLayout); Label constraintLabel = new Label(mConstraintComposite, SWT.NONE); constraintLabel.setText("Constraint:"); logTypeCombo = new Combo(mConstraintComposite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); for (Entry<Integer, ContextLogData> ld : mLogMap.entrySet()) { logTypeCombo.add(ld.getValue().getName(), ld.getKey()); //System.out.println(ld.getValue().getName() + " " + ld.getKey()); } logTypeCombo.setEnabled(false); final FormData hide = new FormData(); hide.top = new FormAttachment(0); hide.bottom = new FormAttachment(0); hide.left = new FormAttachment(0); hide.right = new FormAttachment(0); final FormData show = new FormData(); show.top = new FormAttachment(0); show.bottom = new FormAttachment(100, -4); show.left = new FormAttachment(mConstraintComposite, 0, 4); show.right = new FormAttachment(100); // Composite holding controls for int type logs final Composite mIntComposite = new Composite(constraintHolderComposite, SWT.NONE); mIntComposite.setLayout(new FillLayout()); intRelationCombo = new Combo(mIntComposite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); intRelationCombo.add("<"); intRelationCombo.add("<="); intRelationCombo.add("="); intRelationCombo.add(">="); intRelationCombo.add(">"); mIntValueBox = new Text(mIntComposite, SWT.BORDER); // Composite holding controls for float type logs final Composite mFloatComposite = new Composite(constraintHolderComposite, SWT.NONE); mFloatComposite.setLayout(new FillLayout()); floatRelationCombo = new Combo(mFloatComposite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); floatRelationCombo.add("<"); floatRelationCombo.add(">"); mFloatValueBox = new Text(mFloatComposite, SWT.BORDER); // Composite holding controls for float type logs final Composite mStringComposite = new Composite(constraintHolderComposite, SWT.NONE); mStringComposite.setLayout(new FillLayout()); stringRelationCombo = new Combo(mStringComposite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); stringRelationCombo.add("="); stringRelationCombo.add("<>"); stringValueCombo = new Combo(mStringComposite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); mIntComposite.setLayoutData(hide); mFloatComposite.setLayoutData(hide); mStringComposite.setLayoutData(hide); // Add result text field to the right side mResultBox = new Text(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); mResultBox.setLayoutData(new GridData(GridData.FILL_BOTH)); mResultBox.setEditable(false); final Button addProblems = new Button(formComposite, SWT.PUSH); addProblems.setText("Add more input"); addProblems.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { System.out.println("OK"); FileDialog fd = new FileDialog(parentShell, SWT.OPEN); fd.setText("Open context log files"); // fd.setFilterPath("./"); fd.setFilterExtensions(new String[] { "*.clog" }); String selected = fd.open(); if (selected != null) { addReaders(fd.getFilterPath(), fd.getFileNames()); } } @Override public void widgetDefaultSelected(SelectionEvent arg0) { System.out.println("KO"); } }); openedReadersList = new org.eclipse.swt.widgets.List(this, SWT.SINGLE); openedReadersList.add("main"); logTypeCombo.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { int index = logTypeCombo.getSelectionIndex(); System.out.println(index); mSelectedLog1 = mLogMap.get(index); if (mSelectedLog1 == null) { mLogname = null; System.out.println("null"); return; } mLogname = mSelectedLog1.getName(); switch (mSelectedLog1.getType()) { case INT: case LONG: System.out.println("i"); mIntComposite.setLayoutData(show); mFloatComposite.setLayoutData(hide); mStringComposite.setLayoutData(hide); mIntValueBox.setText(""); break; case FLOAT: case DOUBLE: System.out.println("f"); mIntComposite.setLayoutData(hide); mFloatComposite.setLayoutData(show); mStringComposite.setLayoutData(hide); mFloatValueBox.setText(""); break; case STRING: System.out.println("s"); stringValueCombo.removeAll(); for (String s : mSelectedLog1.getStringDataMap().values()) { stringValueCombo.add(s); } mIntComposite.setLayoutData(hide); mFloatComposite.setLayoutData(hide); mStringComposite.setLayoutData(show); break; } updateProblems(); constraintHolderComposite.pack(); updateStatistics(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { } }); intRelationCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { } @Override public void widgetSelected(SelectionEvent arg0) { try { String relationStr = intRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.LONG, Long.valueOf(mIntValueBox.getText())); updateProblems(); // updateIntervals(rel, Long.valueOf(mIntValueBox.getText())); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo1"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo1"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); mIntValueBox.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { try { String relationStr = intRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.LONG, Long.valueOf(mIntValueBox.getText())); updateProblems(); // updateIntervals(rel, Long.valueOf(mIntValueBox.getText())); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo2"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo2"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); floatRelationCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } @Override public void widgetSelected(SelectionEvent arg0) { try { String relationStr = floatRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.FLOAT, Double.valueOf(mFloatValueBox.getText())); updateProblems(); // updateIntervals(rel, // Double.valueOf(mFloatValueBox.getText())); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo3"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo3"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); mFloatValueBox.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { try { String relationStr = floatRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.FLOAT, Double.valueOf(mFloatValueBox.getText())); updateProblems(); // updateIntervals(rel, // Double.valueOf(mFloatValueBox.getText())); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo4"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo4"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); stringRelationCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } @Override public void widgetSelected(SelectionEvent arg0) { try { String relationStr = stringRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.STRING, stringValueCombo.getText()); updateProblems(); // updateIntervals(rel, stringValueCombo.getText()); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo5"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo5"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); stringValueCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } @Override public void widgetSelected(SelectionEvent arg0) { try { String relationStr = stringRelationCombo.getText(); Relation rel = Relation.value(relationStr); mProblemConstraint = new ProblemConstraint(rel, LogType.STRING, stringValueCombo.getText()); updateProblems(); // updateIntervals(rel, stringValueCombo.getText()); updateStatistics(); } catch (NumberFormatException e) { // boo System.out.println("boo6"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } catch (IllegalArgumentException e) { // foo System.out.println("foo6"); mProblemConstraint = null; updateProblems(); // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); } } }); problemDefButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } @Override public void widgetSelected(SelectionEvent arg0) { if (problemDefButton.getSelection()) { mProblemConstraint = null; mFunctionName = null; mProblemBox.setEnabled(true); logTypeCombo.setEnabled(true); mIntValueBox.setEnabled(true); mFloatValueBox.setEnabled(true); stringValueCombo.setEnabled(true); intRelationCombo.setEnabled(true); floatRelationCombo.setEnabled(true); stringRelationCombo.setEnabled(true); mProblemBox.setText(""); updateProblems(); // mIntervals.clear(); // updateTimeStamps(null); updateStatistics(); } } }); BRBButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub } @Override public void widgetSelected(SelectionEvent arg0) { if (BRBButton.getSelection()) { mFunctionName = ProblemDefinition.BRB_FUNCTION_NAME; // mProblemBox.setText(""); mProblemBox.setEnabled(false); logTypeCombo.setEnabled(false); mIntValueBox.setEnabled(false); mFloatValueBox.setEnabled(false); stringValueCombo.setEnabled(false); intRelationCombo.setEnabled(false); floatRelationCombo.setEnabled(false); stringRelationCombo.setEnabled(false); mProblemConstraint = null; // mIntervals.clear(); // mSelectionController.changeIntervals(mIntervals, // "ProblemView"); // updateTimeStamps(BRBMethodData); updateProblems(); updateStatistics(); } } }); mProblemBox.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent ev) { String query = mProblemBox.getText(); if (query.length() < 4) { mScp.setProposals(new String[0]); mProblemBox.setBackground(mColorMatch); //TODO: make empty problem mFunctionName = null; updateProblems(); // updateTimeStamps(null); return; } MethodData[] matchingMD = mCombinedReader.findAllMethodDataByName(query); if (matchingMD.length == 0) { mProblemBox.setBackground(mColorNoMatch); } else { mProblemBox.setBackground(mColorMatch); } List<String> proposals = new ArrayList<String>(); for (MethodData md : matchingMD) { StringBuilder proposal = new StringBuilder(md.getName()); proposals.add(proposal.toString()); } // TODO: get matching call names mScp.setProposals(proposals.toArray(new String[0])); if (matchingMD.length == 1) { mFunctionName = matchingMD[0].getName(); updateProblems(); // updateTimeStamps(matchingMD[0]); updateStatistics(); } } }); }
From source file:com.aptana.git.ui.dialogs.CreateBranchDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // Add an advanced section so users can specify a start point ref (so they can create a branch that // tracks a remote branch!) Composite composite = (Composite) super.createDialogArea(parent); // TODO Add a minimize/maximize button for the advanced section Group group = new Group(composite, SWT.DEFAULT); group.setText(Messages.CreateBranchDialog_AdvancedOptions_label); group.setLayout(new GridLayout(1, false)); group.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); Label label = new Label(group, SWT.NONE); label.setText(Messages.CreateBranchDialog_StartPoint_label); startPointText = new Text(group, getInputTextStyle()); startPointText.setText(repo.headRef().simpleRef().shortName()); startPointText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); startPointText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { startPoint = startPointText.getText(); // TODO Validate the start point. Must be branch name, commit id or tag ref if (startPoint.indexOf('/') != -1 && autoTrack) { // If name is a remote branch, turn on track by default? for (String remoteName : repo.remotes()) { if (startPoint.startsWith(remoteName + '/')) { trackButton.setSelection(true); track = true;/*from w w w . ja v a 2 s . c o m*/ break; } } } } }); Set<String> simpleRefs = repo.allSimpleRefs(); String[] proposals = simpleRefs.toArray(new String[simpleRefs.size()]); new AutoCompleteField(startPointText, new TextContentAdapter(), proposals); // Have CTRL+SPACE also trigger content assist SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(proposals); proposalProvider.setFiltering(true); ContentProposalAdapter adapter = new ContentProposalAdapter(startPointText, new TextContentAdapter(), proposalProvider, KeyStroke.getInstance(SWT.CONTROL, ' '), null); adapter.setPropagateKeys(true); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); ControlDecoration decoration = new ControlDecoration(startPointText, SWT.LEFT); decoration.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage()); trackButton = new Button(group, SWT.CHECK); trackButton.setText(Messages.CreateBranchDialog_Track_label); trackButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { track = trackButton.getSelection(); autoTrack = false; // don't change the value since user modified it here. } }); return composite; }
From source file:com.astra.ses.spell.gui.views.controls.input.PromptField.java
License:Open Source License
/*************************************************************************** * Create decoration for the input field **************************************************************************/ private void createDecoration() { // Field decoration ControlDecoration deco = new ControlDecoration(m_contents, SWT.LEFT); deco.setDescriptionText("Use CTRL+Space to see the possible commands"); deco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); deco.setShowOnlyOnFocus(false);//from w ww. j ava 2s .c o m deco.setShowHover(true); KeyStroke keyStroke; ArrayList<String> possibleCommandsList = new ArrayList<String>(); for (GuiExecutorCommand cmd : GuiExecutorCommand.values()) { possibleCommandsList.add(cmd.label.toLowerCase()); } String[] possibleCommands = possibleCommandsList.toArray(new String[0]); char[] autoActivationCharacters = new char[0]; IContentProposalProvider provider = new SimpleContentProposalProvider(possibleCommands); try { keyStroke = KeyStroke.getInstance("Ctrl+Space"); new ContentProposalAdapter(m_contents, new TextContentAdapter(), provider, keyStroke, autoActivationCharacters); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.rcpcompany.uibindings.decorators.BaseUIBindingDecorator.java
License:Open Source License
/** * Decorates the binding with all relevant field assist. *///from w ww. j ava 2 s . co m public void decorateAssist() { /* * Must be called before the binding to insure the internals of the decorator is properly * setup... */ final IObservableList decoratorUIList = getValidUIList(); if (decoratorUIList == null) return; /* * Bind field assist */ final SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(new String[0]) { @Override public IContentProposal[] getProposals(String contents, int position) { final IObservableList list = getValidUIList(); setProposals((String[]) list.toArray(new String[list.size()])); return super.getProposals(contents, position); } }; proposalProvider.setFiltering(true); setupValueContentProposalProvider(proposalProvider); }
From source file:com.safi.workshop.audio.utils.MyAutoCompleteField.java
License:Open Source License
/** * Construct an AutoComplete field on the specified control, whose completions are * characterized by the specified array of Strings. * // w ww . ja v a2 s . c o m * @param control * the control for which autocomplete is desired. May not be <code>null</code>. * @param controlContentAdapter * the <code>IControlContentAdapter</code> used to obtain and update the * control's contents. May not be <code>null</code>. * @param proposals * the array of Strings representing valid content proposals for the field. */ public MyAutoCompleteField(Control control, IControlContentAdapter controlContentAdapter, String[] proposals) { proposalProvider = new SimpleContentProposalProvider(proposals); proposalProvider.setFiltering(true); KeyStroke stroke = KeyStroke.getInstance(SWT.CTRL, ' '); adapter = new ContentProposalAdapter(control, controlContentAdapter, proposalProvider, null, null); adapter.setPropagateKeys(true); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); adapter.setAutoActivationDelay(2000); }
From source file:com.vogella.jface.fieldassists.parts.SamplePart.java
License:Open Source License
@PostConstruct public void createComposite(Composite parent) { GridLayout layout = new GridLayout(2, false); // parent is a Composite parent.setLayout(layout);// w ww. j a v a2 s . c om Label lblPleaseEnterA = new Label(parent, SWT.NONE); lblPleaseEnterA.setText("Please enter a value:"); Text text = new Text(parent, SWT.BORDER); GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false); gd_text.horizontalIndent = 8; text.setLayoutData(gd_text); GridData data = new GridData(SWT.FILL, SWT.TOP, true, false); text.setData(data); // create the decoration for the text component final ControlDecoration deco = new ControlDecoration(text, SWT.TOP | SWT.LEFT); // use an existing image Image image = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage(); // set description and image deco.setDescriptionText("Use CNTL + SPACE to see possible values"); deco.setImage(image); // always show decoration deco.setShowOnlyOnFocus(false); // hide the decoration if the text componet has content text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { Text text = (Text) e.getSource(); if (text.getText().length() > 0) { deco.hide(); } else { deco.show(); } } }); // help the user with the possible inputs // "." and "#" activate the content proposals char[] autoActivationCharacters = new char[] { '.', '#' }; KeyStroke keyStroke; // try { keyStroke = KeyStroke.getInstance("Ctrl+Space"); ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), new SimpleContentProposalProvider( new String[] { "ProposalOne", "ProposalTwo", "ProposalThree" }), keyStroke, autoActivationCharacters); } catch (ParseException e1) { e1.printStackTrace(); } }
From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandDataDialog.java
License:Open Source License
private ContentProposalAdapter addContentAssistSimple(Text textControl) { char[] autoActivationCharacters = new char[] { '$', '{' }; KeyStroke keyStroke = null;//from w w w . ja v a 2 s.c om 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; }
From source file:de.unistuttgart.ipvs.pmp.editor.ui.editors.internals.localetable.AutocompleteTextCellEditor.java
License:Apache License
public AutocompleteTextCellEditor(Composite parent, String[] proposals) { this(parent, new SimpleContentProposalProvider(proposals), null, null); }
From source file:dynamicrefactoring.interfaz.wizard.RefactoringWizardUtils.java
License:Open Source License
/** * Aade un gestor de sugerencias al campo de texto * que ofrece como sugerencias las pasadas en el parametro * proposals.//from w w w . j a v a 2s .c o m * * @param textField campo de texto * @param proposals sugerencias a realizar */ public static void addContentProposalToTextField(Text textField, java.util.List<String> proposals) { SimpleContentProposalProvider proposalsProvider = new SimpleContentProposalProvider( proposals.toArray(new String[proposals.size()])); proposalsProvider.setFiltering(true); ContentProposalAdapter adapter; try { adapter = new ContentProposalAdapter(textField, new TextContentAdapter(), proposalsProvider, KeyStroke.getInstance("Ctrl+Space"), null); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); adapter.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { return RefactoringImages.getEclipseClassIcon(); } @Override public String getText(Object element) { return ((IContentProposal) element).getContent(); } }); } catch (org.eclipse.jface.bindings.keys.ParseException e2) { throw Throwables.propagate(e2); } }