private void createBacklogField(Composite composite) { backlogEditor = new IntegerFieldEditor(ILogViewerConstants.PREF_BACKLOG,LogViewerPlugin.getResourceString("preferences.backlog.label.text"),composite); //$NON-NLS-1$ backlogEditor.setPreferenceStore(doGetPreferenceStore()); backlogEditor.setPage(this); backlogEditor.setTextLimit(Integer.toString(ILogViewerConstants.MAX_BACKLOG).length()); backlogEditor.setErrorMessage(LogViewerPlugin.getResourceString("preferences.backlog.label.errortext",new Object[]{new Integer(ILogViewerConstants.MAX_BACKLOG)})); //$NON-NLS-1$ backlogEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); backlogEditor.setValidRange(0,ILogViewerConstants.MAX_BACKLOG); backlogEditor.load(); backlogEditor.setPropertyChangeListener(validityChangeListener); }
@Override protected boolean checkState() { Text text = getTextControl(); if (text == null) { return false; } String numberString = text.getText(); try { int number = Integer.valueOf(numberString).intValue(); if (number >= minValidValue && number <= maxValidValue) { clearErrorMessage(); return true; } showErrorMessage(); return false; } catch (NumberFormatException e1) { showErrorMessage(); } return false; }
/** * Returns this field editor's current value as an integer. * * @return the value * @exception NumberFormatException if the <code>String</code> does not * contain a parsable integer */ public int getIntValue() throws NumberFormatException { return new Integer(getStringValue()).intValue(); } }
private IntegerFieldEditor createIntegerField(final Composite parent, final String name, final String text, final int min, final int max) { final IntegerFieldEditor editor = new IntegerFieldEditor(name, text, parent); editor.setPreferenceStore(getPreferenceStore()); editor.setPage(this); editor.setValidRange(min, max); editor.setPropertyChangeListener(this); editor.load(); return editor; }
private FieldEditor createSlowTestWarningCutoffEditor() { IntegerFieldEditor editor = new IntegerFieldEditor(SLOW_TEST_WARNING, "Slow Test Warning (milliseconds)", getFieldEditorParent()); editor.setEmptyStringAllowed(false); editor.setValidRange(1, MAX_VALUE); return editor; }
@Override protected void doLoadDefault() { Text text = getTextControl(); if (text != null) { int value = getPreferenceStore().getDefaultInt(getPreferenceName()); text.setText("" + value);//$NON-NLS-1$ } valueChanged(); }
maxNumberOfElementPassed = new IntegerFieldEditor( USER_MAX_NUM_OF_ELEMENT_PASSED, "", columnMappingPageGroup ); Label lab = maxNumberOfElementPassed.getLabelControl( columnMappingPageGroup ); lab.setText(Messages.getString("designer.preview.preference.numberOfElementPassedToGetSchema" )); maxNumberOfElementPassed.setPage(this); maxNumberOfElementPassed.setTextLimit( Integer.toString( MAX_INTEGER ).length( ) ); maxNumberOfElementPassed.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE ); maxNumberOfElementPassed.setValidRange(0, MAX_INTEGER); maxNumberOfElementPassed.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) maxNumberOfElementPassed.setErrorMessage( Messages.getFormattedString( "designer.preview.preference.numberOfElementPassedToGetSchema.errormessage", new Object[]{new Integer( MAX_INTEGER ) } ) ); maxNumberOfElementPassed.setStringValue( defaultMaxSchema );
IntegerFieldEditor editor = new IntegerFieldEditor(IDebugUIConstants.PREF_MAX_HISTORY_SIZE, DebugPreferencesMessages.DebugPreferencePage_10, spacer); editor.fillIntoGrid(spacer, 2); addField(editor); int historyMax = IDebugPreferenceConstants.MAX_LAUNCH_HISTORY_SIZE; editor.setTextLimit(Integer.toString(historyMax).length()); editor.setErrorMessage(MessageFormat.format(DebugPreferencesMessages.DebugPreferencePage_11, new Object[] { Integer.valueOf(1), Integer.valueOf(historyMax)})); editor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); editor.setValidRange(1, historyMax); editor.setEmptyStringAllowed(false);
/** * Creates an integer field editor. * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param parent the parent of the field editor's control * @param textLimit the maximum number of characters in the text. */ public IntegerFieldEditor(String name, String labelText, Composite parent, int textLimit) { init(name, labelText); setTextLimit(textLimit); setEmptyStringAllowed(false); setErrorMessage(JFaceResources .getString("IntegerFieldEditor.errorMessage"));//$NON-NLS-1$ createControl(parent); }
private Group createPanelSettings(final Composite parent) { final Group group = new Group(parent, SWT.NONE); group.setText("Panel"); group.setLayout(new GridLayout(1, false)); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Composite composite = new Composite(group, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createCurrentWindowOption(composite); addField(new BooleanFieldEditor(PANEL_STARTUP, "Show at startup", composite)); addField(new BooleanFieldEditor(PANEL_STATUS_LINE, "Show panel in status line when possible", composite)); addField(new BooleanFieldEditor(PANEL_DIRECTIONS, "Show direction buttons", composite)); addField(new BooleanFieldEditor(PANEL_CLOSE, "Show close button", composite)); addField(new BooleanFieldEditor(PANEL_AUTO_INDEXING, "Enable auto indexing", composite)); addField(new BooleanFieldEditor(SEARCH_INCREMENTAL, "Enable incremental search", composite)); final IntegerFieldEditor maxIndexingDepthEditor = new IntegerFieldEditor(PANEL_MAX_INDEXING_DEPTH, "Max indexing depth for trees:", composite); maxIndexingDepthEditor.setValidRange(1, Integer.MAX_VALUE); addField(maxIndexingDepthEditor); addField(new IntegerFieldEditor(PANEL_TEXT_SIZE, "Default box width in chars:", composite)); return group; }
@Override protected void createFieldEditors() { // editor line length hint mEditorLineLengthHint = new IntegerFieldEditor( AnnotationEditorPreferenceConstants.EDITOR_LINE_LENGTH_HINT, "Line Length Hint", getFieldEditorParent()); addField(mEditorLineLengthHint); // editor text size mEditorTextSize = new IntegerFieldEditor( AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE, "Editor Text Size", getFieldEditorParent()); addField(mEditorTextSize); // load CAS with partial type system mEditorPartialTypeystem = new BooleanFieldEditor( AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM, "Load CAS leniently (WARNING: only for experienced users)", getFieldEditorParent()); addField(mEditorPartialTypeystem); }
groupData.horizontalSpan = 2; fGroup.setLayoutData(groupData); fPreBufferSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE, DebugUIMessages.TableRenderingPreferencePage_6, fGroup); fPreBufferSize.setPreferenceStore(getPreferenceStore()); fPreBufferSize.load(); fPostBufferSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE, DebugUIMessages.TableRenderingPreferencePage_7, fGroup); fPostBufferSize.setPreferenceStore(getPreferenceStore()); fPostBufferSize.load(); fManual.setLayoutData(hspanData); fPageSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, DebugUIMessages.TableRenderingPreferencePage_2, fComposite); fPageSize.setPreferenceStore(getPreferenceStore()); fPageSize.load(); fPreBufferSize.setPropertyChangeListener(this); fPostBufferSize.setPropertyChangeListener(this); fPageSize.setPropertyChangeListener(this);
int minValue = DefaultScope.INSTANCE.getNode(AntLaunching.getUniqueIdentifier()).getInt(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, 20000); int maxValue = 1200000; timeout.setValidRange(minValue, maxValue); timeout.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] { Integer.valueOf(minValue), Integer.valueOf(maxValue) })); addField(timeout);
@Override protected void doLoad() { Text text = getTextControl(); if (text != null) { int value = getPreferenceStore().getInt(getPreferenceName()); text.setText("" + value);//$NON-NLS-1$ oldValue = "" + value; //$NON-NLS-1$ } }
.setText(UIText.GitPreferenceRoot_RemoteConnectionsGroupHeader); IntegerFieldEditor timeoutEditor = new IntegerFieldEditor( UIPreferences.REMOTE_CONNECTION_TIMEOUT, UIText.RemoteConnectionPreferencePage_TimeoutLabel, remoteConnectionsGroup); timeoutEditor.getLabelControl(remoteConnectionsGroup).setToolTipText( UIText.RemoteConnectionPreferencePage_ZeroValueTooltip); addField(timeoutEditor);
@Override protected void performDefaults() { IPreferenceStore store = getPreferenceStore(); showMultipleEditorTabs .setSelection(getAPIPreferenceStore() .getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS)); allowInplaceEditor .setSelection(!getAPIPreferenceStore() .getDefaultBoolean(IWorkbenchPreferenceConstants.DISABLE_OPEN_EDITOR_IN_PLACE)); useIPersistableEditor .setSelection(store .getDefaultBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS)); promptWhenStillOpenEditor .setSelection(getAPIPreferenceStore() .getDefaultBoolean(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN)); reuseEditors.setSelection(store .getDefaultBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)); reuseEditorsThreshold.loadDefault(); reuseEditorsThreshold.getLabelControl(editorReuseThresholdGroup) .setEnabled(reuseEditors.getSelection()); reuseEditorsThreshold.getTextControl(editorReuseThresholdGroup) .setEnabled(reuseEditors.getSelection()); recentFilesEditor.loadDefault(); }
/** * Sets the range of valid values for this field. * * @param min the minimum allowed value (inclusive) * @param max the maximum allowed value (inclusive) */ public void setValidRange(int min, int max) { minValidValue = min; maxValidValue = max; setErrorMessage(JFaceResources.format("IntegerFieldEditor.errorMessageRange", //$NON-NLS-1$ Integer.valueOf(min), Integer.valueOf(max))); }
/** * For tests purpose only. Get auto-save interval text field value * programmatically. A call of this method when the auto-save preference * page is closed will return 0. * * @return the value contained in the interval text field, 0 otherwise. */ protected int getAutoSaveIntervalTextValue() { final int interval; if (intervalField != null && intervalComposite != null && !intervalField.getTextControl(intervalComposite).isDisposed()) { interval = intervalField.getIntValue(); } else { interval = 0; } return interval; }
private void updateEnablement() { boolean autoSave = autoSaveButton.getSelection(); final Display display = autoSaveButton.getDisplay(); noteMessage.setEnabled(autoSave); noteLabel.setEnabled(autoSave); resetMessage.setEnabled(autoSave); intervalField.getTextControl(intervalComposite).setEnabled(autoSave); intervalField.getLabelControl(intervalComposite).setEnabled(autoSave); intervalComposite.setEnabled(autoSave); autoSaveGroup.setEnabled(autoSave); if (autoSave) { noteMessage.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); noteLabel.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); resetMessage.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); intervalField.getLabelControl(intervalComposite) .setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); } else { noteMessage.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); noteLabel.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); resetMessage.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); intervalField.getLabelControl(intervalComposite) .setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); } }
/** * For tests purpose only.Set auto-save interval text field value * programmatically. A call of this method when the auto-save preference * page is closed won't do anything. * * @param interval * the value to set (between 0 and Integer.MAX_VALUE). */ protected void setAutoSaveIntervalTextValue(int interval) { if (intervalField != null && intervalComposite != null && !intervalField.getTextControl(intervalComposite).isDisposed() && autoSaveButton != null && !autoSaveButton.isDisposed() && autoSaveButton.getSelection()) { intervalField.setStringValue(String.valueOf(interval)); } }