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.eclipse.linuxtools.internal.docker.ui.preferences.DockerPreferencePage.java
License:Open Source License
/** * Create a container for the refresh rate property * @param parent the parent container/* ww w .j a v a 2 s.com*/ */ private void createContainerRefreshContainer(Composite parent) { final Composite container = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, false).applyTo(container); GridLayoutFactory.fillDefaults().margins(0, 0).spacing(10, 2).applyTo(container); refreshTimeField = new IntegerFieldEditor(PreferenceConstants.REFRESH_TIME, Messages.getString(REFRESH_TIME_MSG), container); refreshTimeField.setPreferenceStore(getPreferenceStore()); refreshTimeField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); refreshTimeField.setValidRange(5, 200); refreshTimeField.setPage(this); refreshTimeField.setErrorMessage(Messages.getString(INVALID_REFRESH_TIME_MSG)); refreshTimeField.showErrorMessage(); refreshTimeField.load(); // If the preference changes, alert the Refresh Manager refreshTimeField.setPropertyChangeListener(event -> { if (event.getSource().equals(refreshTimeField)) { if (refreshTimeField.isValid()) { DockerContainerRefreshManager.getInstance().setRefreshTime(refreshTimeField.getIntValue()); setErrorMessage(null); } else { setErrorMessage(refreshTimeField.getErrorMessage()); } setValid(refreshTimeField.isValid()); } }); }
From source file:org.eclipse.ptp.debug.internal.ui.preferences.PDebugPreferencePage.java
License:Open Source License
/** * Create communication preference settings * /*w w w . j a v a 2 s . c om*/ * @param parent */ protected void createCommunicationPreferences(Composite parent) { Composite comp = createGroupComposite(parent, 1, false, Messages.PDebugPreferencePage_6); Composite spacingComposite = new Composite(comp, SWT.NONE); spacingComposite.setLayout(new GridLayout()); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; spacingComposite.setLayoutData(data); commandTimeoutField = new IntegerFieldEditor(IPDebugConstants.PREF_DEBUG_COMM_TIMEOUT, Messages.PDebugPreferencePage_7, spacingComposite); commandTimeoutField.setPreferenceStore(getPreferenceStore()); commandTimeoutField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); commandTimeoutField.setValidRange(IPDebugConstants.MIN_REQUEST_TIMEOUT, IPDebugConstants.MAX_REQUEST_TIMEOUT); String minValue = Integer.toString(IPDebugConstants.MIN_REQUEST_TIMEOUT); String maxValue = Integer.toString(IPDebugConstants.MAX_REQUEST_TIMEOUT); commandTimeoutField .setErrorMessage(NLS.bind(Messages.PDebugPreferencePage_8, new Object[] { minValue, maxValue })); commandTimeoutField.setEmptyStringAllowed(false); commandTimeoutField.setPropertyChangeListener(listener); commandTimeoutField.load(); }
From source file:org.eclipse.scada.ca.ui.importer.preferences.ImportPreferencePage.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 2 s . co m @Override public void createFieldEditors() { final IntegerFieldEditor fieldEditor = new IntegerFieldEditor(PreferenceConstants.P_DEFAULT_CHUNK_SIZE, "&Default chunk size:", getFieldEditorParent()); fieldEditor.setEmptyStringAllowed(false); fieldEditor.setValidRange(1, Integer.MAX_VALUE); fieldEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); addField(fieldEditor); }
From source file:org.eclipse.ui.internal.dialogs.EditorsPreferencePage.java
License:Open Source License
/** * Create a composite that contains entry fields specifying editor reuse preferences. *///from ww w . j av a 2s . c o m protected void createEditorReuseGroup(Composite composite) { editorReuseGroup = new Composite(composite, SWT.LEFT); GridLayout layout = new GridLayout(); // Line up with other entries in preference page layout.marginWidth = 0; layout.marginHeight = 0; editorReuseGroup.setLayout(layout); editorReuseGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); reuseEditors = new Button(editorReuseGroup, SWT.CHECK); reuseEditors.setText(WorkbenchMessages.WorkbenchPreference_reuseEditors); reuseEditors.setLayoutData(new GridData()); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); reuseEditors.setSelection(store.getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)); reuseEditors.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { reuseEditorsThreshold.getLabelControl(editorReuseThresholdGroup) .setEnabled(reuseEditors.getSelection()); reuseEditorsThreshold.getTextControl(editorReuseThresholdGroup) .setEnabled(reuseEditors.getSelection()); dirtyEditorReuseGroup.setEnabled(reuseEditors.getSelection()); openNewEditor.setEnabled(reuseEditors.getSelection()); promptToReuseEditor.setEnabled(reuseEditors.getSelection()); } }); editorReuseIndentGroup = new Composite(editorReuseGroup, SWT.LEFT); GridLayout indentLayout = new GridLayout(); indentLayout.marginLeft = REUSE_INDENT; indentLayout.marginWidth = 0; editorReuseIndentGroup.setLayout(indentLayout); editorReuseIndentGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); editorReuseThresholdGroup = new Composite(editorReuseIndentGroup, SWT.LEFT); layout = new GridLayout(); layout.marginWidth = 0; editorReuseThresholdGroup.setLayout(layout); editorReuseThresholdGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); reuseEditorsThreshold = new IntegerFieldEditor(IPreferenceConstants.REUSE_EDITORS, WorkbenchMessages.WorkbenchPreference_reuseEditorsThreshold, editorReuseThresholdGroup); reuseEditorsThreshold.setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore()); reuseEditorsThreshold.setPage(this); reuseEditorsThreshold.setTextLimit(2); reuseEditorsThreshold.setErrorMessage(WorkbenchMessages.WorkbenchPreference_reuseEditorsThresholdError); reuseEditorsThreshold.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); reuseEditorsThreshold.setValidRange(1, 99); reuseEditorsThreshold.load(); reuseEditorsThreshold.getLabelControl(editorReuseThresholdGroup).setEnabled(reuseEditors.getSelection()); reuseEditorsThreshold.getTextControl(editorReuseThresholdGroup).setEnabled(reuseEditors.getSelection()); reuseEditorsThreshold.setPropertyChangeListener(validityChangeListener); dirtyEditorReuseGroup = new Group(editorReuseIndentGroup, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; dirtyEditorReuseGroup.setLayout(layout); dirtyEditorReuseGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); dirtyEditorReuseGroup.setText(WorkbenchMessages.WorkbenchPreference_reuseDirtyEditorGroupTitle); dirtyEditorReuseGroup.setEnabled(reuseEditors.getSelection()); promptToReuseEditor = new Button(dirtyEditorReuseGroup, SWT.RADIO); promptToReuseEditor.setText(WorkbenchMessages.WorkbenchPreference_promptToReuseEditor); promptToReuseEditor.setSelection(store.getBoolean(IPreferenceConstants.REUSE_DIRTY_EDITORS)); promptToReuseEditor.setEnabled(reuseEditors.getSelection()); openNewEditor = new Button(dirtyEditorReuseGroup, SWT.RADIO); openNewEditor.setText(WorkbenchMessages.WorkbenchPreference_openNewEditor); openNewEditor.setSelection(!store.getBoolean(IPreferenceConstants.REUSE_DIRTY_EDITORS)); openNewEditor.setEnabled(reuseEditors.getSelection()); }
From source file:org.eclipse.ui.internal.dialogs.EditorsPreferencePage.java
License:Open Source License
/** * Create a composite that contains entry fields specifying editor history preferences. *//* w w w . jav a 2 s . co m*/ protected void createEditorHistoryGroup(Composite composite) { Composite groupComposite = new Composite(composite, SWT.LEFT); GridLayout layout = new GridLayout(); layout.numColumns = 2; groupComposite.setLayout(layout); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; groupComposite.setLayoutData(gd); recentFilesEditor = new IntegerFieldEditor(IPreferenceConstants.RECENT_FILES, WorkbenchMessages.WorkbenchPreference_recentFiles, groupComposite); recentFilesEditor.setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore()); recentFilesEditor.setPage(this); recentFilesEditor.setTextLimit(Integer.toString(EditorHistory.MAX_SIZE).length()); recentFilesEditor.setErrorMessage(NLS.bind(WorkbenchMessages.WorkbenchPreference_recentFilesError, new Integer(EditorHistory.MAX_SIZE))); recentFilesEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); recentFilesEditor.setValidRange(0, EditorHistory.MAX_SIZE); recentFilesEditor.load(); recentFilesEditor.setPropertyChangeListener(validityChangeListener); }
From source file:org.eclipse.ui.internal.dialogs.WorkbenchPreferencePage.java
License:Open Source License
/** * Create a composite that contains entry fields specifying save interval * preference.//from www. j a v a2 s . c o m * * @param composite * the Composite the group is created in. */ private void createSaveIntervalGroup(Composite composite) { Composite groupComposite = new Composite(composite, SWT.LEFT); GridLayout layout = new GridLayout(); layout.numColumns = 2; groupComposite.setLayout(layout); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; groupComposite.setLayoutData(gd); saveInterval = new IntegerFieldEditor(IPreferenceConstants.WORKBENCH_SAVE_INTERVAL, WorkbenchMessages.WorkbenchPreference_workbenchSaveInterval, groupComposite); // @issue we should drop our preference constant and let clients use // core's pref. ours is not up-to-date anyway if someone changes this // interval directly thru core api. saveInterval.setPreferenceStore(getPreferenceStore()); saveInterval.setPage(this); saveInterval.setTextLimit(Integer.toString(MAX_SAVE_INTERVAL).length()); saveInterval.setErrorMessage(NLS.bind(WorkbenchMessages.WorkbenchPreference_workbenchSaveIntervalError, new Integer(MAX_SAVE_INTERVAL))); saveInterval.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); saveInterval.setValidRange(0, MAX_SAVE_INTERVAL); saveInterval.load(); saveInterval.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { setValid(saveInterval.isValid()); } } }); }
From source file:org.eclipse.ui.internal.ide.dialogs.AutoSavePreferencePage.java
License:Open Source License
/** * Creates a widget with a text, a text field (to handle the interval) and a * text./*from www . java 2 s .c o m*/ */ private void createIntervalPart() { intervalComposite = new Composite(autoSaveGroup, SWT.NONE); final GridLayout intervalCompositeLayout = new GridLayout(); intervalCompositeLayout.numColumns = 2; intervalCompositeLayout.marginWidth = 0; intervalCompositeLayout.marginHeight = 10; intervalComposite.setLayout(intervalCompositeLayout); final GridData intervalCompositeLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false); intervalComposite.setLayoutData(intervalCompositeLayoutData); intervalComposite.setEnabled(autoSaveButton.getSelection()); intervalField = new IntegerFieldEditor(IPreferenceConstants.SAVE_AUTOMATICALLY_INTERVAL, "", //$NON-NLS-1$ intervalComposite); intervalField.setLabelText(IDEWorkbenchMessages.AutoSavePreferencPage_intervalMessage); intervalField.setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore()); intervalField.setPage(this); intervalField.setTextLimit(10); intervalField.setErrorMessage(IDEWorkbenchMessages.AutoSavePreferencPage_errorMessage); intervalField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); intervalField.setValidRange(1, Integer.MAX_VALUE); intervalField.load(); intervalField.getLabelControl(intervalComposite).setEnabled(autoSaveButton.getSelection()); intervalField.getTextControl(intervalComposite).setEnabled(autoSaveButton.getSelection()); intervalField.setPropertyChangeListener(validityChangeListener); }
From source file:org.eclipse.ui.internal.ide.dialogs.IDEWorkspacePreferencePage.java
License:Open Source License
/** * Create a composite that contains entry fields specifying save interval * preference./* w w w . j a va 2s. co m*/ * * @param composite the Composite the group is created in. */ private void createSaveIntervalGroup(Composite composite) { Composite groupComposite = new Composite(composite, SWT.LEFT); GridLayout layout = new GridLayout(); layout.numColumns = 2; groupComposite.setLayout(layout); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; groupComposite.setLayoutData(gd); saveInterval = new IntegerFieldEditor(IDEInternalPreferences.SAVE_INTERVAL, IDEWorkbenchMessages.WorkbenchPreference_saveInterval, groupComposite); // @issue we should drop our preference constant and let clients use // core's pref. ours is not up-to-date anyway if someone changes this // interval directly thru core api. saveInterval.setPreferenceStore(getIDEPreferenceStore()); saveInterval.setPage(this); saveInterval.setTextLimit(Integer.toString(IDEInternalPreferences.MAX_SAVE_INTERVAL).length()); saveInterval.setErrorMessage(NLS.bind(IDEWorkbenchMessages.WorkbenchPreference_saveIntervalError, new Integer(IDEInternalPreferences.MAX_SAVE_INTERVAL))); saveInterval.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); saveInterval.setValidRange(1, IDEInternalPreferences.MAX_SAVE_INTERVAL); IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); long interval = description.getSnapshotInterval() / 60000; saveInterval.setStringValue(Long.toString(interval)); saveInterval.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { setValid(saveInterval.isValid()); } } }); }
From source file:org.eclipse.wst.sse.ui.internal.preferences.ui.TranslucencyPreferenceTab.java
License:Open Source License
public Control createContents(Composite tabFolder) { Composite composite = new Composite(tabFolder, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from w ww. ja v a2 s .c o m*/ composite.setLayout(layout); String text = SSEUIMessages.TranslucencyPreferenceTab_1; //$NON-NLS-1$ fTranslucencyScale = new IntegerFieldEditor(EditorPreferenceNames.READ_ONLY_FOREGROUND_SCALE, text, composite); fTranslucencyScale.setErrorMessage(JFaceResources.getString("StringFieldEditor.errorMessage"));//$NON-NLS-1$ fTranslucencyScale.setPreferenceStore(getPreferenceStore()); fTranslucencyScale.setPreferencePage(getMainPreferencePage()); fTranslucencyScale.setTextLimit(Integer.toString(MAX_PERCENTAGE).length()); fTranslucencyScale.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); fTranslucencyScale.setValidRange(0, MAX_PERCENTAGE); fTranslucencyScale.load(); fTranslucencyScale.setPropertyChangeListener(validityChangeListener); // PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PREFWEBX_READONLY_HELPID); return composite; }
From source file:org.emftools.emf2gv.processor.ui.preferences.EMF2GvPreferencePage.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. */// w w w.j av a 2s .c o m public void createFieldEditors() { // Character set Set<String> charsetKeys = Charset.availableCharsets().keySet(); String[][] charsets = new String[charsetKeys.size()][2]; int i = 0; for (String charsetKey : charsetKeys) { charsets[i][0] = charsetKey; charsets[i][1] = charsetKey; i++; } ComboFieldEditor comboFieldEditor = new ComboFieldEditor(EMF2GvPreferenceConstants.P_GV_SOURCE_ENCODING, "&Graphviz source encoding :", charsets, getFieldEditorParent()); addField(comboFieldEditor); // Dot path addField(new FileFieldEditor(EMF2GvPreferenceConstants.P_DOT_UTILITY_PATH, "&Dot utility path :", true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent()) { @Override protected boolean checkState() { String executablePath = getTextControl().getText(); if (executablePath != null) { executablePath = executablePath.trim(); } boolean valid = true; try { Runtime.getRuntime().exec(new String[] { executablePath, "-V" }); clearErrorMessage(); } catch (IOException e) { File file = new File(executablePath); if (!file.exists()) { showErrorMessage("Specified executable file does not exist"); } else { showErrorMessage("Specified executable not seem to be runnable"); } valid = false; } return valid; } }); }