List of usage examples for org.eclipse.jface.preference ListEditor ListEditor
protected ListEditor(String name, String labelText, Composite parent)
From source file:com.codenvy.eclipse.ui.preferences.CodenvyPreferencesPage.java
License:Open Source License
@Override protected void createFieldEditors() { final Composite parent = getFieldEditorParent(); final ListEditor locations = new ListEditor(REMOTE_REPOSITORIES_LOCATION_KEY_NAME, "Remote repositories locations:", parent) { @Override// www .ja v a 2 s . co m protected String getNewInputObject() { // Give the user an input dialog to enter its new location final InputDialog dialog = new InputDialog(getShell(), "Add a remote Codenvy repository location", "Enter the URL of the repository", null, new CodenvyRepositoryValidator()); if (dialog.open() != Window.OK) { return null; } final String newRepositoryLocation = dialog.getValue(); if (StringHelper.isNullOrEmpty(newRepositoryLocation)) { return null; } return newRepositoryLocation; } @Override protected String[] parseString(String stringList) { return CodenvyPreferencesInitializer.parseString(stringList); } @Override protected String createList(String[] items) { return CodenvyPreferencesInitializer.createList(items); } }; locations.loadDefault(); addField(locations); }
From source file:com.gorillalogic.monkeyconsole.preferences.ProxyServerSSLPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to * manipulate various types of preferences. Each field editor knows how to save and restore * itself./*from w w w .j a v a2s.co m*/ */ public void createFieldEditors() { addField(new BooleanFieldEditor(PreferenceConstants.P_ENABLE_SSL_PROXY, "Enable SSL Proxy", getFieldEditorParent())); addField(new ListEditor(PreferenceConstants.P_SSL_PROXY_LIST, "Locations:", getFieldEditorParent()) { @Override protected String[] parseString(String str) { // TODO Auto-generated method stub return str.split("\\,"); } @Override protected String getNewInputObject() { // TODO Auto-generated method stub InputDialog dlg = new InputDialog(getFieldEditorParent().getShell(), "New value", "New value", "", new IInputValidator() { @Override public String isValid(String val) { if (val != null && val.indexOf(":") > 0) { return null; } else { return "value should be host:port format!"; } } }); if (dlg.open() == Window.OK) { return dlg.getValue(); } else { return null; } } @Override protected String createList(String[] str) { // TODO Auto-generated method stub return String.join(",", str); } }); checkState(); }
From source file:com.python.pydev.codecompletion.ui.CodeCompletionPreferencesPage.java
License:Open Source License
@Override protected void createFieldEditors() { Composite p = getFieldEditorParent(); addField(new IntegerFieldEditor( CodeCompletionPreferencesInitializer.CHARS_FOR_CTX_INSENSITIVE_MODULES_COMPLETION, "Number of chars for showing modules in context-insensitive completions?", p)); addField(new IntegerFieldEditor( CodeCompletionPreferencesInitializer.CHARS_FOR_CTX_INSENSITIVE_TOKENS_COMPLETION, "Number of chars for showing global tokens in context-insensitive completions?", p)); addField(new BooleanFieldEditor(CodeCompletionPreferencesInitializer.USE_KEYWORDS_CODE_COMPLETION, "Use common tokens auto code completion?", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(new BooleanFieldEditor(CodeCompletionPreferencesInitializer.ADD_SPACE_WHEN_NEEDED, "Add <SPACE> for common cases (e.g.: \"and \", \"assert \", etc.)?", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(new BooleanFieldEditor(CodeCompletionPreferencesInitializer.ADD_SPACE_AND_COLON_WHEN_NEEDED, "Add <SPACE><COLON> for common cases (e.g.: \"class :\", \"if :\", etc.)?", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(new BooleanFieldEditor(CodeCompletionPreferencesInitializer.FORCE_PY3K_PRINT_ON_PY2, "Force print() function on Python 2.x projects?", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(//from w ww .j a v a 2s . c o m new ListEditor(CodeCompletionPreferencesInitializer.KEYWORDS_CODE_COMPLETION, "Tokens to use:", p) { @Override protected String createList(String[] items) { return KeywordsSimpleAssist.wordsAsString(items); } @Override protected String getNewInputObject() { InputDialog d = new InputDialog(getShell(), "New word", "Add the word you wish.", "", new IInputValidator() { public String isValid(String newText) { if (newText.indexOf(' ') != -1) { return "The input cannot have spaces"; } return null; } }); int retCode = d.open(); if (retCode == InputDialog.OK) { return d.getValue(); } return null; } @Override protected String[] parseString(String stringList) { return KeywordsSimpleAssist.stringAsWords(stringList); } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); List listControl = getListControl(parent); GridData layoutData = (GridData) listControl.getLayoutData(); layoutData.heightHint = 300; } }); }
From source file:net.sourceforge.metrics.ui.preferences.NORMPreferencePage.java
License:Open Source License
@Override public void createFieldEditors() { addField(new BooleanFieldEditor("NORM.Abstract", "Count abstract Inherited Methods", getFieldEditorParent()));/*from ww w.java 2 s .c o m*/ addField(new BooleanFieldEditor("NORM.Super", "Count methods invoking super", getFieldEditorParent())); addField(new ListEditor("NORM.ExludeList", "Exclude the following methods:", getFieldEditorParent()) { @Override protected String createList(String[] items) { StringBuffer b = new StringBuffer(); for (String item : items) { b.append(item).append(","); } return b.substring(0, b.length() - 1); } @Override protected String getNewInputObject() { InputDialog input = new InputDialog(getShell(), "New Excluded method", "Please type a method name", "", null); input.open(); if (input.getReturnCode() == Window.OK) { return input.getValue(); } /* else { */ return null; /* } */ } @Override protected String[] parseString(String stringList) { StringTokenizer t = new StringTokenizer(stringList, ","); int length = t.countTokens(); String[] items = new String[length]; for (int i = 0; i < length; i++) { items[i] = t.nextToken().trim(); } return items; } }); }
From source file:org.csstudio.auth.ui.internal.preferences.OnsiteSubnetPreferencePage.java
License:Open Source License
/** * {@inheritDoc}//www .j a v a 2 s . c o m */ @Override protected final void createFieldEditors() { addField(new ListEditor(OnsiteSubnetPreferences.PREFERENCE_KEY, "Subnets: ", getFieldEditorParent()) { public String[] parseString(String stringList) { return stringList.split(","); } public String getNewInputObject() { AddSubnetDialog dialog = new AddSubnetDialog(getShell()); if (dialog.open() == Window.OK) { Subnet s = dialog.getSubnet(); return s != null ? s.toString() : null; } return null; } public String createList(String[] items) { StringBuilder temp = new StringBuilder(); for (int i = 0; i < items.length; i++) { temp.append(items[i]); temp.append(","); } return temp.toString(); } }); }
From source file:org.eclipse.cdt.codan.internal.ui.widgets.ParametersComposite.java
License:Open Source License
/** * @param parent/*from w w w . j a v a 2s .c om*/ * @param problem * @param style */ public ParametersComposite(Composite parent, final IProblem problem) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); this.setLayout(new GridLayout(2, false)); this.problem = problem; this.prefStore = new PreferenceStore(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override protected void createFieldEditors() { noDefaultAndApplyButton(); ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; addField(new BooleanFieldEditor(PREF_ENABLED, CodanUIMessages.ParametersComposite_IsEnabled, getFieldEditorParent())); String[][] entries = { { CodanSeverity.Error.toTranslatableString(), CodanSeverity.Error.toString() }, // { CodanSeverity.Warning.toTranslatableString(), CodanSeverity.Warning.toString() }, // { CodanSeverity.Info.toTranslatableString(), CodanSeverity.Info.toString() }, // { NO_CHANGE, NO_CHANGE }, // }; addField(new ComboFieldEditor(PREF_SEVERITY, CodanUIMessages.ParametersComposite_Severity, entries, getFieldEditorParent())); StringFieldEditor messagePatternEditor = new StringFieldEditor(PREF_MESSAGE, CodanUIMessages.ParametersComposite_MessagePattern, getFieldEditorParent()); // We are using read-only text field for message pattern to allow copy to clipboard. makeUneditable(messagePatternEditor); addField(messagePatternEditor); IProblemPreference pref = problem.getPreference(); createFieldEditorsForParameters(pref); } private void makeUneditable(StringFieldEditor editor) { /* * Here we are doing 2 things to make a text control "uneditable": * 1. 'setUneditable(false)' the problem with with just doing this is that * the background of the text control doesn't change, and it looks like * an editable one. This is confusing to the user. * 2. Getting the background of a label control and applying it * to the "uneditable" text control. This way it is easier to figure out that * the contents of the text control cannot be changed. * Why not just setEnable(false)? Because it changes the text of the text control * to light gray, making it difficult to read. Also, users cannot select and copy * text from a disabled text field. */ Color background = editor.getLabelControl(getFieldEditorParent()).getBackground(); Text text = editor.getTextControl(getFieldEditorParent()); text.setBackground(background); text.setEditable(false); } @Override protected Control createContents(Composite parent) { return super.createContents(parent); } /** * @param info */ private void createFieldEditorsForParameters(final IProblemPreference info) { if (info == null) return; if (info.getKey() == FileScopeProblemPreference.KEY) return; // skip the scope if (info.getKey() == LaunchModeProblemPreference.KEY) return; // skip the launch switch (info.getType()) { case TYPE_STRING: { StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_BOOLEAN: { BooleanFieldEditor fe = new BooleanFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_LIST: ListEditor le = new ListEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()) { @Override protected String[] parseString(String stringList) { ListProblemPreference list = (ListProblemPreference) info; IProblemPreference[] childDescriptors = list.getChildDescriptors(); if (childDescriptors.length == 0) return new String[0]; String res[] = new String[childDescriptors.length]; for (int i = 0; i < childDescriptors.length; i++) { IProblemPreference item = childDescriptors[i]; res[i] = String.valueOf(item.getValue()); } return res; } @Override protected String getNewInputObject() { ListProblemPreference list = (ListProblemPreference) info; String label = list.getChildDescriptor().getLabel(); InputDialog dialog = new InputDialog(getShell(), CodanUIMessages.ParametersComposite_NewValue, label, "", null); //$NON-NLS-1$ if (dialog.open() == Window.OK) { return dialog.getValue(); } return null; } @Override protected String createList(String[] items) { ListProblemPreference list = (ListProblemPreference) info.clone(); list.clear(); for (int i = 0; i < items.length; i++) { String val = items[i]; list.addChildValue(val); } return list.exportValue(); } }; addField(le); break; case TYPE_MAP: IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info) .getChildDescriptors(); for (int i = 0; i < childrenDescriptor.length; i++) { IProblemPreference desc = childrenDescriptor[i]; createFieldEditorsForParameters(desc); } break; case TYPE_CUSTOM: { StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_FILE: { FileFieldEditor fe = new FileFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } default: throw new UnsupportedOperationException(info.getType().toString()); } } }; load(problem); page.setPreferenceStore(prefStore); page.createControl(parent); page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences.SmtpHostPreferencePage.java
License:Open Source License
/** * Create the Server host information GUI * // www . ja va2s.c o m * @param Composite * aPrefsContainer */ private void createServerHostInformation(Composite aPrefsContainer) { // Create a Group to hold SMTP user preferences final Group smtpHostPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID); final GridData smtpHostPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false); smtpHostPrefsGroupData.horizontalSpan = FGROUP_PREFS_SERVER_DATA_SPAN; smtpHostPrefsGroup.setText(PreferenceConstants.FP_SERVER_HOST_GROUP); smtpHostPrefsGroup.setLayoutData(smtpHostPrefsGroupData); smtpHostPrefsGroup.setLayout(new GridLayout(FGROUP_PREFS_SERVER_DATA_SPAN, false)); // dummy spacer label final Label smtpPrefsSpacer = new Label(smtpHostPrefsGroup, SWT.FILL); final GridData smtpPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false); smtpPrefsSpacerData.horizontalSpan = FGROUP_PREFS_SERVER_DATA_SPAN; smtpPrefsSpacer.setLayoutData(smtpPrefsSpacerData); fserverlListBox = new ListEditor(PreferenceConstants.FP_SMTP_SERVER_LIST_ID, PreferenceConstants.FP_SMTP_SERVER_LABEL, smtpHostPrefsGroup) { @Override protected String createList(String[] aItems) { StringBuilder sb = new StringBuilder(); int itemSize = aItems.length; for (int i = 0; i < itemSize; i++) { sb.append(aItems[i]); if (i + 1 < itemSize) { sb.append(fLIST_SEPARATOR); } } return sb.toString(); } @Override protected String getNewInputObject() { // New button selected InputDialog dialog = new InputDialog(getShell(), SMTPHostString.getString("smtp_pref_title"), SMTPHostString.getString("smtp_pref_dialog_msg"), "", SmtpInputValidator()); dialog.create(); dialog.open(); String text = dialog.getValue(); return text; } private IInputValidator SmtpInputValidator() { // No validation yet return null; } @Override protected String[] parseString(String aStringList) { String[] star = aStringList.split(fLIST_SEPARATOR); return star; } }; addField(fserverlListBox); }
From source file:org.infoglue.igide.preferences.InfogluePreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of * the common GUI blocks needed to manipulate various types * of preferences. Each field editor knows how to save and * restore itself.//from ww w . j a va 2 s. com */ public void createFieldEditors() { addField(new ListEditor(P_PROJECTS, "Connections and projects", getFieldEditorParent()) { @Override protected String[] parseString(String stringList) { return stringList.split(";"); } @Override protected String getNewInputObject() { ConnectionDialogNew dialog = new ConnectionDialogNew(getShell()); dialog.setBlockOnOpen(true); String value = null; int dialogCode = dialog.open(); if (dialogCode == InputDialog.OK) { value = dialog.getValue(); System.out.println(value); if (value != null) { value = value.trim(); if (value.length() == 0) return null; } } return value; } @Override protected String createList(String[] items) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < items.length; i++) { buf.append(items[i]).append(";"); } return buf.toString(); } }); addField(new ListEditor(P_ACC_TYPES, "Content Type Attribute Association", getFieldEditorParent()) { @Override protected String[] parseString(String stringList) { return stringList.split(";"); } @Override protected String getNewInputObject() { AttributeAssociationDialogNew dialog = new AttributeAssociationDialogNew(getShell()); dialog.setBlockOnOpen(true); String value = null; int dialogCode = dialog.open(); if (dialogCode == InputDialog.OK) { value = dialog.getValue(); System.out.println(value); if (value != null) { value = value.trim(); if (value.length() == 0) return null; } } return value; } @Override protected String createList(String[] items) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < items.length; i++) { buf.append(items[i]).append(";"); } return buf.toString(); } }); }
From source file:org.python.pydev.debug.newconsole.prefs.InteractiveConsoleUMDPrefs.java
License:Open Source License
@Override protected void createFieldEditors() { Composite p = getFieldEditorParent(); addField(new BooleanFieldEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_ENABLED, "Enable UMD", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(new BooleanFieldEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_VERBOSE, "Show reloaded modules list", p)); addField(new LabelFieldEditor("LabelFieldEditor", "", p)); addField(new ListEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_EXCLUDE_MODULE_LIST, "UMD Excluded Modules:", p) { @Override// ww w . j av a 2s. c o m protected String createList(String[] items) { return StringUtils.join(",", items); } @Override protected String[] parseString(String stringList) { return stringList.split(","); } @Override protected String getNewInputObject() { InputDialog d = new InputDialog(getShell(), "New Excluded Module", "Add the module you want to exclude.", "", new IInputValidator() { public String isValid(String newText) { if (newText.indexOf(',') != -1) { return "The input cannot have a comma"; } return null; } }); if (d.open() == InputDialog.OK) { return d.getValue(); } return null; } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); List listControl = getListControl(parent); GridData layoutData = (GridData) listControl.getLayoutData(); layoutData.heightHint = 300; } }); }
From source file:ptolemy.backtrack.eclipse.plugin.preferences.BacktrackingPreferencePage.java
License:Open Source License
/** Create the first section named "Sources for Batch Refactoring" in the * preference page./*from ww w . ja v a2 s. c om*/ */ private void _createSection1() { Composite composite = _createSection("Sources for Batch Refactoring", "Set the sources of refactoring. A source list file stores " + "the complete list of Java source files to be refactored. " + "A single Java source file name is written on each line of " + "the source list. The source file names may use paths " + "relative to the path where the source list file is in."); Composite currentComposite = _newComposite(composite); _sourceList = new FileFieldEditor(PreferenceConstants.BACKTRACK_SOURCE_LIST, "Source &list file:", currentComposite) { protected boolean checkState() { String currentValue = getStringValue(); boolean superResult = super.checkState(); if (!getTextControl(_getParent(this)).isEnabled()) { return superResult; } if (getStringValue().equals(_lastString)) { if (superResult) { return true; } } else { _lastString = currentValue; _sourcesModified = false; if (superResult || currentValue.equals("")) { return _updateSources(); } } List list = _sources.getListControl(_getParent(_sources)); list.removeAll(); return false; } private String _lastString = null; }; GridData gridData = new GridData(); gridData.widthHint = 0; gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; _sourceList.getTextControl(currentComposite).setLayoutData(gridData); _sourceList.setFileExtensions(new String[] { "*.lst", "*.*" }); _setParent(_sourceList, currentComposite); addField(_sourceList); currentComposite = _newComposite(composite); _sources = new ListEditor(PreferenceConstants.BACKTRACK_SOURCES, "&Sources", currentComposite) { protected String createList(String[] items) { return Strings.encodeFileNames(items); } protected void doStore() { if (_sourcesModified) { List list = getListControl(_getParent(this)); String[] items = list.getItems(); String fileName = _sourceList.getStringValue(); try { PrintWriter writer = new PrintWriter(new FileOutputStream(fileName)); for (int i = 0; i < items.length; i++) { writer.write(items[i] + "\n"); } writer.close(); } catch (Exception e) { MessageDialog.openError(getShell(), "Error writing file", e.getMessage()); } } } protected String getNewInputObject() { String sourceList = _sourceList.getStringValue(); String sourceListPath = new File(sourceList).getParent(); FileDialog dialog = new FileDialog(getShell()); dialog.setText("Please choose a file to be added to the source list"); dialog.setFilterPath(sourceListPath); dialog.setFilterExtensions(new String[] { "*.java" }); String file = dialog.open(); if (file != null) { file = file.trim(); if (file.length() == 0) { return null; } } return file; } protected String[] parseString(String stringList) { return Strings.decodeFileNames(stringList); } }; gridData = new GridData(); gridData.widthHint = 0; gridData.heightHint = _LIST_HEIGHT; gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; _sources.getListControl(currentComposite).setLayoutData(gridData); _setParent(_sources, currentComposite); addField(_sources); }