List of usage examples for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_FOCUS_LOST
int VALIDATE_ON_FOCUS_LOST
To view the source code for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_FOCUS_LOST.
Click Source Link
1
) indicating that the editor should perform validation only when the text widget loses focus. From source file:com.mind_era.knime_rapidminer.knime.nodes.preferences.SubPreferencePage.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 av a 2s. c o m @Override public void createFieldEditors() { for (final String parameterKey : ParameterService.getParameterKeys()) { final ParameterType type = ParameterService.getParameterType(parameterKey); final String value = ParameterService.getParameterValue(parameterKey); final String key = PreferenceInitializer.getRapidminerPreferenceKey(parameterKey); if (type instanceof ParameterTypeInt) { final ParameterTypeInt intType = (ParameterTypeInt) type; final IntegerFieldEditor integerFieldEditor = new IntegerFieldEditor(key, intType.getDescription(), getFieldEditorParent()); integerFieldEditor.setValidRange(intType.getMinValueInt(), intType.getMaxValueInt()); integerFieldEditor.setStringValue(value); addField(integerFieldEditor); } else if (type instanceof ParameterTypeDouble) { final ParameterTypeDouble doubleType = (ParameterTypeDouble) type; final StringFieldEditor stringFieldEditor = new StringFieldEditor(key, doubleType.getDescription(), getFieldEditorParent()); addField(stringFieldEditor); } else if (type instanceof ParameterTypeStringCategory) { final ParameterTypeStringCategory catType = (ParameterTypeStringCategory) type; final String[] vals = catType.getValues(); final String[][] labelAndValues = new String[vals.length][2]; for (int i = labelAndValues.length; i-- > 0;) { labelAndValues[i][0] = vals[i]; labelAndValues[i][1] = Integer.toString(i); } final RadioGroupFieldEditor stringFieldEditor = new RadioGroupFieldEditor(key, catType.getDescription(), 2, labelAndValues, getFieldEditorParent(), true); addField(stringFieldEditor); } else if (type instanceof ParameterTypeFile) { final ParameterTypeFile fileType = (ParameterTypeFile) type; final FileFieldEditor fileFieldEditor = new FileFieldEditor(key, fileType.getDescription(), getFieldEditorParent()); addField(fileFieldEditor); } else if (type instanceof ParameterTypeDirectory) { final ParameterTypeDirectory dirType = (ParameterTypeDirectory) type; final DirectoryFieldEditor directoryFieldEditor = new DirectoryFieldEditor(key, dirType.getDescription(), getFieldEditorParent()); addField(directoryFieldEditor); } else if (type instanceof ParameterTypeBoolean) { final ParameterTypeBoolean boolType = (ParameterTypeBoolean) type; final BooleanFieldEditor booleanFieldEditor = new BooleanFieldEditor(key, boolType.getDescription(), getFieldEditorParent()); addField(booleanFieldEditor); } else if (type instanceof ParameterTypeColor) { final ParameterTypeColor colorType = (ParameterTypeColor) type; final ColorFieldEditor colorFieldEditor = new ColorFieldEditor(key, colorType.getDescription(), getFieldEditorParent()); addField(colorFieldEditor); } else if (type instanceof ParameterTypeChar) { final ParameterTypeChar charType = (ParameterTypeChar) type; final StringFieldEditor charFieldEditor = new StringFieldEditor(key, charType.getDescription(), 1, getFieldEditorParent()); addField(charFieldEditor); } else if (type != null)/* if (type instanceof ParameterTypeString) */ { // final ParameterTypeString stringType = (ParameterTypeString) // type; final StringFieldEditor stringFieldEditor = new StringFieldEditor(key, type.getDescription(), StringFieldEditor.UNLIMITED, StringFieldEditor.VALIDATE_ON_FOCUS_LOST, getFieldEditorParent()); addField(stringFieldEditor); } // else Password should be important } // addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH, // "&Directory preference:", getFieldEditorParent())); // addField(new BooleanFieldEditor(PreferenceConstants.P_BOOLEAN, // "&An example of a boolean preference", getFieldEditorParent())); // // addField(new RadioGroupFieldEditor(PreferenceConstants.P_CHOICE, // "An example of a multiple-choice preference", 1, // new String[][] { { "&Choice 1", "choice1" }, // { "C&hoice 2", "choice2" } }, getFieldEditorParent())); // addField(new StringFieldEditor(PreferenceConstants.P_STRING, // "A &text preference:", getFieldEditorParent())); }
From source file:eu.hydrologis.jgrass.beegisutils.project.newprojectwizard.NewBeegisProjectWizardPage.java
License:Open Source License
/** * Set up this page for use./*from w w w. j a v a 2 s .c o m*/ * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) * @param parent */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); // PROJECT NAME projectNameEditor = new StringFieldEditor("newproject.name", "Name of the new project", composite) { protected boolean doCheckState() { return validate(); } }; projectNameEditor.setPage(this); projectNameEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); projectNameEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST); Text textControl = projectNameEditor.getTextControl(composite); GridData gd = new GridData(SWT.LEFT, SWT.NONE, false, false); gd.widthHint = 100; gd.horizontalSpan = 2; textControl.setLayoutData(gd); // PROJECT PARENT FOLDER projectDirectoryEditor = new DirectoryFieldEditor("newproject.directory", "Base folder for the new project", //$NON-NLS-1$ composite) { protected boolean doCheckState() { updatePathsAndLabels(); return validate(); } }; projectDirectoryEditor.setPage(this); projectDirectoryEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); projectDirectoryEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST); projectDirectoryEditor.fillIntoGrid(composite, 3); Label dummyLabel = new Label(composite, SWT.NONE); GridData dummyGD = new GridData(SWT.BEGINNING, SWT.FILL, false, true); dummyGD.horizontalSpan = 3; dummyLabel.setLayoutData(dummyGD); dummyLabel.setText(""); Group resultGroup = new Group(composite, SWT.NONE); GridData resultGroupGD = new GridData(SWT.FILL, SWT.FILL, true, false); resultGroupGD.horizontalSpan = 3; resultGroup.setLayoutData(resultGroupGD); resultGroup.setLayout(new GridLayout(1, false)); resultGroup.setText("Resulting folders summary"); overallProjectFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN); overallProjectFolderGroup.setLayout(new GridLayout(1, false)); overallProjectFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); overallProjectFolderLabel = new Label(overallProjectFolderGroup, SWT.NONE); overallProjectFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); overallProjectFolderLabel.setText(""); udigProjectFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN); udigProjectFolderGroup.setLayout(new GridLayout(1, false)); udigProjectFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); udigProjectFolderLabel = new Label(udigProjectFolderGroup, SWT.NONE); udigProjectFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); udigProjectFolderLabel.setText(""); projectDatabaseFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN); projectDatabaseFolderGroup.setLayout(new GridLayout(1, false)); projectDatabaseFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); projectDatabaseFolderLabel = new Label(projectDatabaseFolderGroup, SWT.NONE); projectDatabaseFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); projectDatabaseFolderLabel.setText(""); String defaultProjectName = Messages.NewProjectWizardPage_default_name; String projectPath = BeegisUtilsPlugin.getDefault().getLastFolderChosen(); projectNameEditor.setStringValue(defaultProjectName); projectDirectoryEditor.setStringValue(projectPath); updatePathsAndLabels(); composite.pack(); setControl(composite); setPageComplete(true); }
From source file:org.eclipse.cdt.dsf.debug.internal.ui.preferences.DsfDebugPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { final Composite parent = getFieldEditorParent(); final GridLayout layout = new GridLayout(); layout.marginWidth = 0;//w ww. j a va2 s . c o m parent.setLayout(layout); Group performanceGroup = new Group(parent, SWT.NONE); performanceGroup.setText(MessagesForPreferences.DsfDebugPreferencePage_performanceGroup_label); GridLayout groupLayout = new GridLayout(3, false); performanceGroup.setLayout(groupLayout); performanceGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // stack frame limit IntegerFieldEditor limitEditor = new IntegerWithBooleanFieldEditor( IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT_ENABLE, IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT, MessagesForPreferences.DsfDebugPreferencePage_limitStackFrames_label, performanceGroup); limitEditor.setValidRange(1, Integer.MAX_VALUE); limitEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST); limitEditor.fillIntoGrid(performanceGroup, 3); addField(limitEditor); // sync stepping speed BooleanFieldEditor syncSteppingEditor = new BooleanFieldEditor( IDsfDebugUIConstants.PREF_WAIT_FOR_VIEW_UPDATE_AFTER_STEP_ENABLE, MessagesForPreferences.DsfDebugPreferencePage_waitForViewUpdate_label, performanceGroup); syncSteppingEditor.fillIntoGrid(performanceGroup, 3); addField(syncSteppingEditor); // minimum step interval IntegerFieldEditor minIntervalEditor = new DecoratingIntegerFieldEditor( IDsfDebugUIConstants.PREF_MIN_STEP_INTERVAL, MessagesForPreferences.DsfDebugPreferencePage_minStepInterval_label, performanceGroup); minIntervalEditor.setValidRange(0, 10000); minIntervalEditor.fillIntoGrid(performanceGroup, 3); addField(minIntervalEditor); // need to set layout again performanceGroup.setLayout(groupLayout); }
From source file:org.jboss.tools.feedhenry.ui.cordova.internal.preferences.FeedHenryPreferencesPage.java
License:Open Source License
@Override protected void createFieldEditors() { final Composite parent = getFieldEditorParent(); parent.setFont(getControl().getFont()); // FH target URL final URLFieldEditor targetUrlField = new URLFieldEditor(PREF_TARGET_URL, LABEL_TARGET_URL, parent); targetUrlField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST); targetUrlField.setPreferenceStore(getPreferenceStore()); targetUrlField.setPage(this); targetUrlField.load();//w w w .ja va 2 s . com targetUrlField.setPropertyChangeListener(this); targetUrlField.getTextControl(parent).setMessage(MESSAGE_TARGET_URL); addField(targetUrlField); // API key final StringFieldEditor apikeyField = new StringFieldEditor(PREF_API_KEY, LABEL_API_KEY, parent); apikeyField.setPreferenceStore(getPreferenceStore()); apikeyField.setPage(this); apikeyField.load(); addField(apikeyField); }
From source file:org.objectstyle.wolips.ui.preferences.WOLipsPropertiesPreferencesPage.java
License:Open Source License
public void createFieldEditors() { int widthInChars = 50; // MS: WOLips Properties is set in a different preferences store, so we want to hijack this one field editor to use the primary preferences store _wolipsPropertiesFieldEditor = new StringFieldEditor(Preferences.PREF_WOLIPS_PROPERTIES_FILE, "WOLips Properties File", widthInChars, StringFieldEditor.VALIDATE_ON_FOCUS_LOST, getFieldEditorParent()) {// www . j a va 2 s. co m @Override public void setPreferenceStore(IPreferenceStore store) { super.setPreferenceStore(store == null ? null : Preferences.getPreferenceStore()); } public void loadDefault() { super.loadDefault(); // MS: I have no idea why this isn't resetting ... getTextControl().setText(getPreferenceStore().getDefaultString(getPreferenceName())); } }; addField(_wolipsPropertiesFieldEditor); addField(new WOLipsDirectoryFieldEditor(WOVariables.NETWORK_FRAMEWORKS, "Network Frameworks", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.SYSTEM_FRAMEWORKS, "System Frameworks", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.LOCAL_FRAMEWORKS, "Local Frameworks", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.USER_FRAMEWORKS, "User Frameworks", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.NETWORK_ROOT, "Network Root", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.SYSTEM_ROOT, "System Root", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.LOCAL_ROOT, "Local Root", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.USER_ROOT, "User Root", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.WEBOBJECTS_EXTENSIONS, "WebObjects Extensions", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.APPS_ROOT, "Installed Applications", widthInChars, getFieldEditorParent())); addField(new WOLipsDirectoryFieldEditor(WOVariables.API_ROOT_KEY, "WebObjects Javadoc", widthInChars, getFieldEditorParent())); }