List of usage examples for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE
int VALIDATE_ON_KEY_STROKE
To view the source code for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE.
Click Source Link
0
) indicating that the editor should perform validation after every key stroke. From source file:org.ganoro.phing.ui.internal.preferences.AntPreferencePage.java
License:Open Source License
protected void createFieldEditors() { storeAppliedValues();/*ww w . j a v a 2 s . c o m*/ Font font = getFieldEditorParent().getFont(); Label label = new Label(getFieldEditorParent(), SWT.WRAP); label.setText(AntPreferencesMessages.AntPreferencePage_Enter); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.widthHint = convertWidthInCharsToPixels(60); label.setLayoutData(gd); label.setLayoutData(gd); label.setFont(font); StringFieldEditor editor = new StringFieldEditor(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, AntPreferencesMessages.AntPreferencePage__Names__3, getFieldEditorParent()); addField(editor); timeout = new AntIntegerFieldEditor(PhingLaunching.getUniqueIdentifier(), "ANT_COMMUNICATION_TIMEOUT", AntPreferencesMessages.AntPreferencePage_13, getFieldEditorParent(), 2000); int minValue = 20000; int maxValue = 1200000; timeout.setValidRange(minValue, maxValue); timeout.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] { new Integer(minValue), new Integer(maxValue) })); addField(timeout); editor = new URLFieldEditor(IAntUIPreferenceConstants.DOCUMENTATION_URL, AntPreferencesMessages.AntPreferencePage_2, getFieldEditorParent()); addField(editor); workspacejre = new BooleanFieldEditor(IAntUIPreferenceConstants.USE_WORKSPACE_JRE, AntPreferencesMessages.always_run_in_workspace_jre, getFieldEditorParent()); workspacejre.fillIntoGrid(getFieldEditorParent(), 3); addField(workspacejre); createSpace(); if (!PhingUi.isMacOS()) { //the mac does not have a tools.jar Bug 40778 label = new Label(getFieldEditorParent(), SWT.WRAP); label.setText(AntPreferencesMessages.AntPreferencePage_0); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.widthHint = convertWidthInCharsToPixels(60); label.setLayoutData(gd); label.setFont(font); fToolsWarningEditor = new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING, AntPreferencesMessages.AntPreferencePage_1, getFieldEditorParent()); addField(fToolsWarningEditor); createSpace(); } addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_ERROR_DIALOG, AntPreferencesMessages.AntPreferencePage_12, getFieldEditorParent())); createSpace(); addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_CREATE_MARKERS, AntPreferencesMessages.AntPreferencePage_15, getFieldEditorParent())); label = new Label(getFieldEditorParent(), SWT.WRAP); label.setText(AntPreferencesMessages.AntPreferencePage_16); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.widthHint = convertWidthInCharsToPixels(60); label.setLayoutData(gd); label.setFont(font); createSpace(); createColorComposite(); getPreferenceStore().addPropertyChangeListener(this); }
From source file:org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage.java
License:Mozilla Public 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 a 2 s . c om*/ @Override public void createFieldEditors() { generatSkeleton = new BooleanFieldEditor(PreferenceConstants.P_GENERATE_SKELETON, "Generate skeleton code", getFieldEditorParent()); addField(generatSkeleton); license = new MultiLineStringFieldEditor(PreferenceConstants.P_LICENSE, "The license header to be inserted in all generated files", 30, getFieldEditorParent()); license.setLabelText(""); // need to set this parameter (seems to be a bug) addField(license); // output directory definitions commonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_COMMON, "Output directory for the common code", 30, getFieldEditorParent()); addField(commonOutput); proxyOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_PROXIES, "Output directory for proxy code", 30, getFieldEditorParent()); addField(proxyOutput); stubOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_STUBS, "Output directory for stub code", 30, getFieldEditorParent()); addField(stubOutput); skeletonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_SKELETON, "Output directory for the skeleton code", 30, getFieldEditorParent()); addField(skeletonOutput); postFix = new StringFieldEditor(PreferenceConstants.P_SKELETONPOSTFIX, "Postfix for skeleton filenames", 30, getFieldEditorParent()); addField(postFix); postFix.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); enumPrefix = new StringFieldEditor(PreferenceConstants.P_ENUMPREFIX, "Prefix for enumeration literals", 30, getFieldEditorParent()); addField(enumPrefix); }
From source file:org.gradle.eclipse.preferences.GradleRuntimePreferencePage.java
License:Apache License
protected void createFieldEditors() { storeAppliedValues();/*from ww w . ja va 2s. c om*/ if (!isPropertyPage()) { Font font = getFieldEditorParent().getFont(); Label label = new Label(getFieldEditorParent(), SWT.WRAP); label.setText(GradlePreferencesMessages.GradleRuntimePreferencePage_Enter); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.widthHint = convertWidthInCharsToPixels(60); label.setLayoutData(gd); label.setLayoutData(gd); label.setFont(font); FieldEditor editor = new StringFieldEditor(IGradlePreferenceConstants.GRADLE_FIND_BUILD_FILE_NAMES, GradlePreferencesMessages.GradleRuntimePreferencePage_BuildFileName, getFieldEditorParent()); addField(editor); } useCustomCacheFieldEditor = new BooleanFieldEditor(IGradlePreferenceConstants.USE_SPECIFIC_GRADLE_CACHE, GradlePreferencesMessages.GradleRuntimePreferencePage_USE_MANUEL_GRADLE_CACHE, getFieldEditorParent()); useCustomCacheFieldEditor.setPropertyChangeListener(this); addField(useCustomCacheFieldEditor); gradleCacheDirEditor = new DirectoryFieldEditor(IGradlePreferenceConstants.GRADLE_CACHE, GradlePreferencesMessages.GradleRuntimePreferencePage_GRADLE_CACHE_DIR, getFieldEditorParent()); gradleCacheDirEditor.setEmptyStringAllowed(isPropertyPage()); gradleCacheDirEditor.setPropertyChangeListener(this); addField(gradleCacheDirEditor); useCustomGradleHomeFieldEditor = new BooleanFieldEditor(IGradlePreferenceConstants.USE_SPECIFIC_GRADLE_HOME, GradlePreferencesMessages.GradleRuntimePreferencePage_USE_MANUEL_GRADLE_HOME, getFieldEditorParent()); useCustomGradleHomeFieldEditor.setPropertyChangeListener(this); addField(useCustomGradleHomeFieldEditor); gradleHomeDirectoryFieldEditor = new DirectoryFieldEditor(IGradlePreferenceConstants.MANUELL_GRADLE_HOME, GradlePreferencesMessages.GradleRuntimePreferencePage_GradleHome_Label, getFieldEditorParent()); gradleHomeDirectoryFieldEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); gradleHomeDirectoryFieldEditor.setErrorMessage("GRADLE_HOME must not be empty!"); gradleHomeDirectoryFieldEditor.setPropertyChangeListener(this); addField(gradleHomeDirectoryFieldEditor); boolean useCustomHome = getPreferenceStore() .getBoolean(IGradlePreferenceConstants.USE_SPECIFIC_GRADLE_HOME); if (useCustomHome) { gradleHomeDirectoryFieldEditor.setEmptyStringAllowed(false); gradleHomeDirectoryFieldEditor.setEnabled(true, getFieldEditorParent()); } else { gradleHomeDirectoryFieldEditor.setEmptyStringAllowed(true); gradleHomeDirectoryFieldEditor.setEnabled(false, getFieldEditorParent()); } boolean useCustomCache = getPreferenceStore() .getBoolean(IGradlePreferenceConstants.USE_SPECIFIC_GRADLE_CACHE); if (useCustomCache) { gradleCacheDirEditor.setEmptyStringAllowed(false); gradleCacheDirEditor.setEnabled(true, getFieldEditorParent()); } else { gradleCacheDirEditor.setEmptyStringAllowed(true); gradleCacheDirEditor.setEnabled(false, getFieldEditorParent()); } gradleCmdParamsEditor = new StringFieldEditor(IGradlePreferenceConstants.ADDITIONAL_COMMANDLINE_PARAMS, GradlePreferencesMessages.GradleRuntimePreferencePage_ADDITIONAL_COMMANDLINE_PARAMS, getFieldEditorParent()); addField(gradleCmdParamsEditor); createSpace(); getPreferenceStore().addPropertyChangeListener(this); if (!isPropertyPage()) { createColorComposite(); } checkState(); }
From source file:org.jboss.tools.windup.ui.internal.launch.OptionsTab.java
License:Open Source License
private void createJREGroup(Composite parent) { // parent = new Composite(parent, SWT.NONE); // GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(8, LayoutConstants.getSpacing().y).applyTo(parent); parent = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(parent); jreEditor = new FileFieldEditor(IPreferenceConstants.WINDUP_JRE_HOME, Messages.WindupPreferenceJRE, true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, parent) { private boolean isDefaultJrePresented = false; public Label getLabelControl(Composite parent) { CLabel label = new CLabel(parent, SWT.LEFT); Image jreImage = PDEPluginImages.DESC_JAVA_LIB_OBJ.createImage(); label.setImage(jreImage);// www .j av a2s. com label.setFont(parent.getFont()); String text = getLabelText(); if (text != null) { label.setText(text); } label.addDisposeListener(event -> { jreImage.dispose(); }); return null; } @Override protected void doStore() { configuration.setJreHome(getTextControl().getText().trim()); } @Override public void store() { if (isDefaultJrePresented) { configuration.setJreHome(WindupRuntimePlugin.computeJRELocation()); } else { doStore(); } } protected void valueChanged() { setPresentsDefaultValue(false); boolean oldState = super.isValid(); refreshValidState(); if (isValid() != oldState) { fireStateChanged(IS_VALID, oldState, isValid()); } String newValue = super.getTextControl().getText(); if (!newValue.equals(oldValue)) { fireValueChanged(VALUE, oldValue, newValue); oldValue = newValue; store(); } } @Override public void load() { isDefaultJrePresented = false; Text textControl = super.getTextControl(); if (textControl != null) { String value = configuration.getJreHome(); textControl.setText(value != null ? value : ""); oldValue = value; } refreshValidState(); } @Override public void loadDefault() { isDefaultJrePresented = true; Text textControl = super.getTextControl(); if (textControl != null) { String value = WindupRuntimePlugin.computeJRELocation(); textControl.setText(value); } refreshValidState(); valueChanged(); } @Override protected boolean checkState() { String msg = null; String path = getTextControl().getText(); clearErrorMessage(); if (path != null) { path = path.trim(); } else { path = "";//$NON-NLS-1$ } if (path.length() == 0) { return true; } else { File file = new File(path); if (file.isDirectory()) { if (!file.isAbsolute()) { msg = Messages.JRENotAbsolute; } } else { msg = Messages.InvalidJRELocation; } } if (msg != null) { // error showErrorMessage(msg); return false; } return true; } @Override protected String changePressed() { File f = new File(getTextControl().getText()); if (!f.exists()) { f = null; } File d = promptJRE(); if (d == null) { return null; } return d.getAbsolutePath(); } }; jreEditor.setEmptyStringAllowed(true); }
From source file:org.jboss.tools.windup.ui.preferences.WindupPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { homeEditor = new DirectoryFieldEditor(IPreferenceConstants.WINDUP_HOME, Messages.WindupPreferenceHome, getFieldEditorParent());// ww w . jav a 2 s. c o m homeEditor.setEmptyStringAllowed(false); addField(homeEditor); portEditor = new IntegerFieldEditor(IPreferenceConstants.RMI_PORT, Messages.WindupPreferenceRmiPort, getFieldEditorParent()); portEditor.setEmptyStringAllowed(false); addField(portEditor); startTimeoutDurationEditor = new IntegerFieldEditor(IPreferenceConstants.START_TIMEOUT, Messages.WindupPreferenceStartTimeoutDuration, getFieldEditorParent()); startTimeoutDurationEditor.setEmptyStringAllowed(false); addField(startTimeoutDurationEditor); stopTimeoutDurationEditor = new IntegerFieldEditor(IPreferenceConstants.STOP_TIMEOUT, Messages.WindupPreferenceStopTimeoutDuration, getFieldEditorParent()); stopTimeoutDurationEditor.setEmptyStringAllowed(false); addField(stopTimeoutDurationEditor); jreEditor = new FileFieldEditor(IPreferenceConstants.WINDUP_JRE_HOME, Messages.WindupPreferenceJRE, true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent()) { @Override protected boolean checkState() { String msg = null; String path = getTextControl().getText(); clearErrorMessage(); if (path != null) { path = path.trim(); } else { path = "";//$NON-NLS-1$ } if (path.length() == 0) { return true; } else { File file = new File(path); if (file.isDirectory()) { if (!file.isAbsolute()) { msg = Messages.JRENotAbsolute; } } else { msg = Messages.InvalidJRELocation; } } if (msg != null) { // error showErrorMessage(msg); return false; } return true; } @Override protected String changePressed() { File f = new File(getTextControl().getText()); if (!f.exists()) { f = null; } File d = handleAdd(); if (d == null) { return null; } return d.getAbsolutePath(); } }; jreEditor.setEmptyStringAllowed(false); addField(jreEditor); if (windupClient.isWindupServerRunning()) { Composite parent = new Composite(getFieldEditorParent(), SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent); GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(parent); new Label(parent, SWT.LEFT).setText(Messages.currentJavaHome); Text text = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(text); text.setEnabled(false); text.setText(windupClient.getJavaHome()); } }
From source file:org.rdkit.knime.extensions.aggregration.RDKitMcsAggregationPreferencePage.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from www . ja va2s. c o m*/ protected void createFieldEditors() { m_editorThreshold = new StringFieldEditor(PREF_KEY_THRESHOLD, "Threshold (0.0 < t <= 1.0): ", StringFieldEditor.UNLIMITED, StringFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent()); addField(m_editorThreshold); m_editorRingMatchesRingOnlyOption = new BooleanFieldEditor(PREF_KEY_RING_MATCHES_RING_ONLY_OPTION, "Ring matches ring only", getFieldEditorParent()); addField(m_editorRingMatchesRingOnlyOption); m_editorCompleteRingsOnlyOption = new BooleanFieldEditor(PREF_KEY_COMPLETE_RINGS_ONLY_OPTION, "Complete rings only", getFieldEditorParent()); addField(m_editorCompleteRingsOnlyOption); m_editorMatchValencesOption = new BooleanFieldEditor(PREF_KEY_MATCH_VALENCES_OPTION, "Match valences", getFieldEditorParent()); addField(m_editorMatchValencesOption); final String[][] arrAtomComparisons = new String[AtomComparison.values().length][2]; int i = 0; for (final AtomComparison comp : AtomComparison.values()) { arrAtomComparisons[i][0] = comp.toString(); arrAtomComparisons[i][1] = comp.name(); i++; } m_editorAtomComparison = new ComboFieldEditor(PREF_KEY_ATOM_COMPARISON, "Atom comparison: ", arrAtomComparisons, getFieldEditorParent()); addField(m_editorAtomComparison); final String[][] arrBondComparisons = new String[BondComparison.values().length][2]; i = 0; for (final BondComparison comp : BondComparison.values()) { arrBondComparisons[i][0] = comp.toString(); arrBondComparisons[i][1] = comp.name(); i++; } m_editorBondComparison = new ComboFieldEditor(PREF_KEY_BOND_COMPARISON, "Bond comparison: ", arrBondComparisons, getFieldEditorParent()); addField(m_editorBondComparison); m_editorTimeout = new IntegerFieldEditor(PREF_KEY_TIMEOUT, "Timeout (in seconds): ", getFieldEditorParent()); m_editorTimeout.setValidRange(1, Integer.MAX_VALUE); ; addField(m_editorTimeout); }
From source file:org.robotframework.ide.eclipse.main.plugin.preferences.DefaultLaunchConfigurationPreferencePage.java
License:Apache License
private void createExecutorLaunchConfigurationPreferences(final Composite parent) { final Group group = new Group(parent, SWT.NONE); group.setText("Executor tab"); GridLayoutFactory.fillDefaults().applyTo(group); GridDataFactory.fillDefaults().grab(true, false).indent(0, 10).span(2, 1).applyTo(group); final StringFieldEditor additionalInterpreterArguments = new StringFieldEditor( RedPreferences.LAUNCH_ADDITIONAL_INTERPRETER_ARGUMENTS, "Additional interpreter arguments:", group); additionalInterpreterArguments.load(); addField(additionalInterpreterArguments); final FileFieldEditor scriptPathEditor = new FileFieldEditor(RedPreferences.LAUNCH_EXECUTABLE_FILE_PATH, "Executable file:", true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, group); scriptPathEditor.setFileExtensions(RobotLaunchConfiguration.getSystemDependentExecutableFileExtensions()); scriptPathEditor.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile()); scriptPathEditor.load();// w w w . j a v a 2 s . co m addField(scriptPathEditor); final StringFieldEditor additionalScriptArguments = new StringFieldEditor( RedPreferences.LAUNCH_ADDITIONAL_EXECUTABLE_FILE_ARGUMENTS, "Additional executable file arguments:", group); additionalScriptArguments.load(); addField(additionalScriptArguments); GridDataFactory.fillDefaults().span(2, 1).applyTo(scriptPathEditor.getLabelControl(group)); }
From source file:org.soyatec.tooling.gef.properties.ViewPropertyTab.java
License:Open Source License
private FieldEditor createFieldEditor(final Composite parent, final EStructuralFeature feature) { final String name = feature.getName(); final String label = getFeatureLabel(feature); if (ES_BACKGROUND == feature || ES_FOREGROUND == feature || ES_GRADIENT_COLOR == feature || ES_LINE_COLOR == feature) { return new ColorFieldEditor(name, label, parent); } else if (ES_GRADIENT_VERTICAL == feature) { return new ComboFieldEditor(name, label, new String[][] { { ResourcesFactory.getString("properties_vertical"), "true" }, //$NON-NLS-1$//$NON-NLS-2$ { ResourcesFactory.getString("properties_horizontal"), "false" } }, //$NON-NLS-1$//$NON-NLS-2$ parent);//w w w . ja v a 2s. c o m } else { final Class<?> instanceClass = feature.getEType().getInstanceClass(); if (boolean.class == instanceClass) { return new BooleanFieldEditor(name, label, parent); } else if (int.class == instanceClass) { return new SpinnerFieldEditor(name, label, parent, 1, 10, 1, 1); } } return new StringFieldEditor(name, label, StringFieldEditor.UNLIMITED, StringFieldEditor.VALIDATE_ON_KEY_STROKE, parent); }
From source file:org.symbian.tools.tmw.debug.ui.DebugPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { DirectoryFieldEditor editor = new DirectoryFieldEditor(IConstants.PREF_NAME_CHROME_LOCATION, "Chrome Install Location:", getFieldEditorParent()) { @Override/* w w w. jav a 2 s . c o m*/ protected boolean doCheckState() { if (super.doCheckState()) { String message = validate(getStringValue()); setErrorMessage(message); return message == null; } else { return false; } } }; editor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); editor.setEmptyStringAllowed(false); addField(editor); check = new Button(getFieldEditorParent(), SWT.CHECK); check.setText("Show warning dialog when resources in the debugged project were changed"); check.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false, 3, 1)); check.setSelection(!MessageDialogWithToggle.ALWAYS .equals(getPreferenceStore().getString(IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR))); }
From source file:org.vclipse.vcml.ui.preferences.SapDefaultSettingsPreferencePage.java
License:Open Source License
private StringFieldEditor createStringFieldEditor(String prefName, String label, Composite parent) { return new StringFieldEditor(prefName, label, 10, StringFieldEditor.VALIDATE_ON_KEY_STROKE, parent) { @Override/*from ww w . j a va2 s .co m*/ protected void createControl(Composite parent) { GridLayout layout = new GridLayout(); layout.numColumns = getNumberOfControls(); layout.marginWidth = 10; layout.marginHeight = 5; layout.horizontalSpacing = HORIZONTAL_GAP; parent.setLayout(layout); doFillIntoGrid(parent, layout.numColumns); } }; }