List of usage examples for org.eclipse.jface.preference StringFieldEditor StringFieldEditor
public StringFieldEditor(String name, String labelText, Composite parent)
From source file:com.blackducksoftware.integration.eclipseplugin.preferences.BlackDuckPreferences.java
License:Apache License
private StringFieldEditor createStringField(String preferenceName, String label, Composite composite, boolean integerValidation) { StringFieldEditor editor;/*from ww w . ja va2 s .c om*/ if (integerValidation) { // String field editor w/ integer validation, we can make this a separate class if we need to. editor = new StringFieldEditor(preferenceName, label, composite) { @Override protected boolean checkState() { setErrorMessage(JFaceResources.getString(INTEGER_FIELD_EDITOR_ERROR_STRING)); Text text = getTextControl(); if (text == null) { return false; } String intString = text.getText(); if (intString.isEmpty()) { clearErrorMessage(); return true; } try { Integer.valueOf(intString).intValue(); } catch (NumberFormatException nfe) { showErrorMessage(); } return false; } }; } else { editor = new StringFieldEditor(preferenceName, label, composite); } editor.setPage(this); editor.setPreferenceStore(this.getPreferenceStore()); editor.fillIntoGrid(composite, NUM_COLUMNS); editor.load(); return editor; }
From source file:com.clustercontrol.preference.ClusterControlCorePreferencePage.java
License:Open Source License
/** * ????//from w w w. j av a 2 s. c om */ @Override public void createFieldEditors() { Composite parent = this.getFieldEditorParent(); GridData gridData = null; // Group group = new Group(parent, SWT.SHADOW_NONE); WidgetTestUtil.setTestId(this, "group", group); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 10; gridData.verticalSpan = 10; group.setLayoutData(gridData); group.setText(Messages.getString("connection.setting")); // managerPollingInterval = new IntegerFieldEditor(KEY_INTERVAL, Messages.getString("manager.polling.interval"), group); managerPollingInterval.setValidRange(VALUE_INTERVAL_MIN, VALUE_INTERVAL_MAX); String[] args1 = { Integer.toString(VALUE_INTERVAL_MIN), Integer.toString(VALUE_INTERVAL_MAX) }; managerPollingInterval.setErrorMessage(Messages.getString("message.hinemos.8", args1)); this.addField(managerPollingInterval); // HTTP String[] args2 = { Integer.toString(VALUE_HTTP_TIMEOUT_MIN), Integer.toString(VALUE_HTTP_TIMEOUT_MAX) }; httpRequestTimeout = new IntegerFieldEditor(KEY_HTTP_REQUEST_TIMEOUT, Messages.getString("connection.request.timeout"), group); httpRequestTimeout.setValidRange(VALUE_HTTP_TIMEOUT_MIN, VALUE_HTTP_TIMEOUT_MAX); httpRequestTimeout.setErrorMessage(Messages.getString("message.hinemos.8", args2)); this.addField(httpRequestTimeout); // Proxy Group proxyGroup = new Group(parent, SWT.SHADOW_NONE); WidgetTestUtil.setTestId(this, "proxygroup", proxyGroup); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 10; gridData.verticalSpan = 10; proxyGroup.setLayoutData(gridData); proxyGroup.setText(Messages.getString("proxy.connection.setting")); // Proxy/ proxyEnable = new BooleanFieldEditor(KEY_PROXY_ENABLE, Messages.getString("proxy.connection.enable"), proxyGroup); this.addField(proxyEnable); // Proxy proxyHost = new StringFieldEditor(KEY_PROXY_HOST, Messages.getString("proxy.connection.host"), proxyGroup); proxyHost.setTextLimit(DataRangeConstant.VARCHAR_256); this.addField(proxyHost); // Proxy? proxyPort = new IntegerFieldEditor(KEY_PROXY_PORT, Messages.getString("proxy.connection.port"), proxyGroup); proxyPort.setValidRange(VALUE_PROXY_PORT_MIN, VALUE_PROXY_PORT_MAX); String[] args3 = { Integer.toString(VALUE_PROXY_PORT_MIN), Integer.toString(VALUE_PROXY_PORT_MAX) }; proxyPort.setErrorMessage(Messages.getString("message.hinemos.8", args3)); this.addField(proxyPort); // Proxy proxyUser = new StringFieldEditor(KEY_PROXY_USER, Messages.getString("proxy.connection.user"), proxyGroup); proxyUser.setTextLimit(DataRangeConstant.VARCHAR_256); this.addField(proxyUser); // Proxy proxyPassword = new PasswordFieldEditor(KEY_PROXY_PASSWORD, Messages.getString("proxy.connection.password"), proxyGroup); proxyPassword.setTextLimit(DataRangeConstant.VARCHAR_256); this.addField(proxyPassword); }
From source file:com.clustercontrol.repository.preference.RepositoryPreferencePage.java
License:Open Source License
/** * ????/*from w w w. j ava 2s. c o m*/ */ @Override public void createFieldEditors() { Composite parent = this.getFieldEditorParent(); GridData gridData = null; // ?[] Group nodeGroup = new Group(parent, SWT.SHADOW_NONE); WidgetTestUtil.setTestId(this, null, nodeGroup); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 10; gridData.verticalSpan = 10; nodeGroup.setLayoutData(gridData); nodeGroup.setText(Messages.getString("view.repository.node")); // StringFieldEditor progExec = new StringFieldEditor(P_PROGRAM_EXECUTION, MSG_PROGRAM_EXECUTION, nodeGroup); progExec.setTextLimit(DataRangeConstant.VARCHAR_1024); String[] args = { Integer.toString(DataRangeConstant.VARCHAR_1024) }; progExec.setErrorMessage(Messages.getString("message.hinemos.7", args)); this.addField(progExec); // This setting is not available for Web Client. Disable and show message. // Note: RAP BUG? If there is no FieldEditor set, label will not be shown. if (ClusterControlPlugin.isRAP()) { progExec.getTextControl(nodeGroup).setEnabled(false); Label lblNotAvailable = new Label(parent, SWT.LEFT); lblNotAvailable.setText(Messages.getString("preferencepage.notavailable.message")); lblNotAvailable.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); WidgetTestUtil.setTestId(this, "notavailable", nodeGroup); } }
From source file:com.coldfire.debugger.ui.GDBPreferencePage.java
License:Open Source License
public void createFieldEditors() { addField(new StringFieldEditor(Constants.pref_GDB_COMMAND, "GDB Path:", getFieldEditorParent())); addField(new FileFieldEditor(Constants.pref_GDB_INIT_FILE, "GDB Init Script:", getFieldEditorParent())); }
From source file:com.coldfire.debugger.ui.MainPreferencePage.java
License:Open Source License
public void createFieldEditors() { addField(new BooleanFieldEditor(Constants.pref_IS_INTERNAL_PROGRAMMER, "Use Internal Coldfire Programmer (m68k GDB)", getFieldEditorParent())); addField(new StringFieldEditor(Constants.pref_EXTPROGRAMMER_PARAM, "External Programmer Command:", getFieldEditorParent()));/* w w w.j a v a2s .c o m*/ }
From source file:com.dnw.depmap.preferences.RootPreferenePage.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 .ja va2s .co m * * @author manbaum * @since Oct 20, 2014 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ public void createFieldEditors() { final Composite p = getFieldEditorParent(); gf1 = new GroupFieldEditor("Neo4j graph database", p); flagurl = new BooleanFieldEditor(PrefKeys.P_USESTANDALONE, "&Standalone database server (access thru Rest API)", gf1.getGroupControl(p)); dburl = new StringFieldEditor(PrefKeys.P_DBURL, "&Url:", gf1.getGroupControl(p)); flagdir = new BooleanFieldEditor(PrefKeys.P_USEEMBEDDED, "&Embedded database server (access thru Java API)", gf1.getGroupControl(p)); dbdir = new DirectoryFieldEditor(PrefKeys.P_DBDIR, "S&tore:", gf1.getGroupControl(p)); gf2 = new GroupFieldEditor( "Class/Method name filter (a regexp or a string prefix with '@', one item each line)", p); flagprefer = new BooleanFieldEditor(PrefKeys.P_PREFERWHITE, "P&refer white list", gf2.getGroupControl(p)); whitelist = new TextFieldEditor(PrefKeys.P_WHITELIST, "&Whitelist:", 50, 2, gf2.getGroupControl(p)); blacklist = new TextFieldEditor(PrefKeys.P_BLACKLIST, "&Blacklist:", 50, 2, gf2.getGroupControl(p)); gf3 = new GroupFieldEditor("Cypher statements executed before generating (one statement each line)", p); flagexec = new BooleanFieldEditor(PrefKeys.P_USEPREEXEC, "Enable e&xecuting statements", gf3.getGroupControl(p)); statements = new TextFieldEditor(PrefKeys.P_PREEXEC, "", 56, 6, gf3.getGroupControl(p)); gf1.addField(flagurl); gf1.addField(dburl); gf1.addField(flagdir); gf1.addField(dbdir); addField(gf1); gf2.addField(flagprefer); gf2.addField(whitelist); gf2.addField(blacklist); addField(gf2); gf3.addField(flagexec); gf3.addField(statements); addField(gf3); }
From source file:com.doapps.cakephp.preferences.CakePHPPreferencePage.java
License:MIT 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.ja v a2 s . co m*/ */ public void createFieldEditors() { //Setup a key value in format: {{"2.1","2.1"},{"1.3","1.3"}} String[][] tmpVersionsKeyValueList = new String[CakeVersion.getVersions().size()][2]; int i = 0; for (String s : CakeVersion.getVersions()) { tmpVersionsKeyValueList[i][0] = tmpVersionsKeyValueList[i][1] = s; i++; } CakeVersion.getVersions(); addField(new ComboFieldEditor(PreferenceConstants.P_CAKE_VER, "&CakePHP Version", tmpVersionsKeyValueList, getFieldEditorParent())); addField(new StringFieldEditor(PreferenceConstants.P_APP_DIR, "&App folder (relative to project):", getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.P_CREATE_FILES_AUTOMATICALLY, "&Automatically Create Files (if they don't exist):", getFieldEditorParent())); }
From source file:com.ge.research.sadl.ui.preferences.ReasonerConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override/* w w w . j a v a2 s .com*/ public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; if (config != null) { for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug(key + " class = " + optionValue.getClass().getName()); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } else { logger.info("No configuration options available"); } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(reasonerCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.ge.research.sadl.ui.preferences.TranslatorConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override//from w w w. ja v a 2 s . c o m public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; if (config == null) { messageArea.updateText("No options available", IMessageProvider.NONE); return; } for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug( key + " class = " + (optionValue != null ? optionValue.getClass().getName() : "null")); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue == null) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(translatorCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.ge.research.sadl.ui.properties.ReasonerConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override/*from ww w .j a v a 2 s . com*/ public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug(key + " class = " + optionValue.getClass().getName()); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(reasonerCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }