org.eclipse.jface.preference.FieldEditor Java Examples
The following examples show how to use
org.eclipse.jface.preference.FieldEditor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkbenchPreferencePage.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * @return a new field editor for the user name */ private FieldEditor createUserFieldEditor() { return new CheckedStringFieldEditor(USER_ID, // Messages.WorkbenchPreferencePage_UserId, // getFieldEditorParent(), // Messages.WorkbenchPreferencePage_Validate_InvalidUserId) { /** * {@inheritDoc} */ @Override protected boolean check() { return StringUtils.isNotEmpty(getTextControl().getText()); } }; }
Example #2
Source File: GenericFieldEditorPropertyPage.java From tlaplus with MIT License | 6 votes |
/** * The field editor preference page implementation of a <code>PreferencePage</code> * method loads all the field editors with their default values. */ protected void performDefaults() { if (fields != null) { Iterator e = fields.iterator(); while (e.hasNext()) { FieldEditor pe = (FieldEditor) e.next(); pe.loadDefault(); } } // Force a recalculation of my error state. checkState(); super.performDefaults(); }
Example #3
Source File: GenericFieldEditorPropertyPage.java From tlaplus with MIT License | 6 votes |
/** * The field editor preference page implementation of this <code>IPreferencePage</code> * (and <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code> * events but passes other events on to its superclass. */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { boolean newValue = ((Boolean) event.getNewValue()).booleanValue(); // If the new value is true then we must check all field editors. // If it is false, then the page is invalid in any case. if (newValue) { checkState(); } else { setInvalidFieldEditor((FieldEditor) event.getSource()); setValid(newValue); } } }
Example #4
Source File: ProfileView.java From Pydev with Eclipse Public License 1.0 | 6 votes |
protected void addField(final FieldEditor editor, Composite parent, IPreferenceStore preferenceStore) { fields.add(editor); editor.setPreferenceStore(preferenceStore); editor.load(); editor.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // Apply on any change! editor.store(); } }); if (editor instanceof BooleanFieldEditorCustom) { editor.fillIntoGrid(parent, 2); } else { editor.fillIntoGrid(parent, 1); } }
Example #5
Source File: GenericFieldEditorPropertyPage.java From tlaplus with MIT License | 6 votes |
/** * Recomputes the page's error state by calling <code>isValid</code> for * every field editor. */ protected void checkState() { boolean valid = true; setInvalidFieldEditor(null); // The state can only be set to true if all // field editors contain a valid value. So we must check them all if (fields != null) { int size = fields.size(); for (int i = 0; i < size; i++) { FieldEditor editor = (FieldEditor) fields.get(i); valid = valid && editor.isValid(); if (!valid) { setInvalidFieldEditor(editor); break; } } } setValid(valid); }
Example #6
Source File: AbstractPreferencePage.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Saves the 'use project settings' as a preference in the store using the * {@link #useProjectSettingsPreferenceName()} as the key. If not project specific, all affected keys are removed * from the project preferences. */ private void saveUseProjectSettings(boolean isProjectSpecific) throws IOException { final FixedScopedPreferenceStore store = (FixedScopedPreferenceStore) getPreferenceStore(); if (!isProjectSpecific) { // remove all the keys (written by various field editors) IEclipsePreferences storePreferences = store.getStorePreferences(); for (FieldEditor field : editors) { storePreferences.remove(field.getPreferenceName()); } // Also remove the master key (i.e. use default/default == false when later reading). storePreferences.remove(useProjectSettingsPreferenceName()); } else { store.setValue(useProjectSettingsPreferenceName(), Boolean.toString(isProjectSpecific)); } store.save(); }
Example #7
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 6 votes |
/** * Recomputes the page's error state by calling <code>isValid</code> for every field editor. */ protected void checkState() { boolean valid = true; m_invalidFieldEditor = null; // The state can only be set to true if all // field editors contain a valid value. So we must check them all if (m_fields != null) { int size = m_fields.size(); for (int i = 0; i < size; i++) { FieldEditor editor = m_fields.get(i); valid = valid && editor.isValid(); if (!valid) { m_invalidFieldEditor = editor; break; } } } setValid(true); }
Example #8
Source File: JenerateBasePreferencePage.java From jenerate with Eclipse Public License 1.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getProperty().equals(FieldEditor.VALUE)) { if (event.getSource() == getCacheHashCodeField()) { getHashCodeCachingField().setEnabled(getCacheHashCodeField().getBooleanValue(), getFieldEditorParent()); } else if (event.getSource() == getCacheToStringField()) { getToStringCachingField().setEnabled(getCacheToStringField().getBooleanValue(), getFieldEditorParent()); } else if (event.getSource() == getHashCodeCachingField() || event.getSource() == getToStringCachingField()) { checkState(); } } }
Example #9
Source File: TimeZonePreferencePage.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override protected void createFieldEditors () { final List<String> tzs = Arrays.asList ( TimeZone.getAvailableIDs () ); Collections.sort ( tzs ); final String[][] entries = new String[tzs.size ()][2]; int i = 0; for ( final String id : tzs ) { entries[i][0] = id; entries[i][1] = id; i += 1; } final FieldEditor field = new ComboFieldEditor ( "timeZone", Messages.TimeZonePreferencePage_TimeZone_Label, entries, getFieldEditorParent () ); //$NON-NLS-1$ addField ( field ); }
Example #10
Source File: WorkbenchPreferencePage.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * @return a new field editor for the window size */ private FieldEditor createWindowSizeFieldEditor() { return new CheckedStringFieldEditor(WINDOW_SIZE, // Messages.WorkbenchPreferencePage_WindowSize, // getFieldEditorParent(), // Messages.WorkbenchPreferencePage_Validate_WindowLocationSizeWrongFormat) { /** * Checks the format defines coordinates, e.g. 120,160 or 200,350. * * {@inheritDoc} */ @Override protected boolean check() { return getTextControl().getText().matches("^-?\\d+,-?\\d+$"); //$NON-NLS-1$ } }; }
Example #11
Source File: WorkbenchPreferencePage.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * @return a new field editor for the window location */ private FieldEditor createWindowLocationFieldEditor() { return new CheckedStringFieldEditor(WINDOW_LOCATION, // Messages.WorkbenchPreferencePage_WindowLocation, // getFieldEditorParent(), // Messages.WorkbenchPreferencePage_Validate_WindowLocationSizeWrongFormat) { /** * Checks the format defines coordinates, e.g. 120,160 or 200,350. * * {@inheritDoc} */ @Override protected boolean check() { return getTextControl().getText().matches("^-?\\d+,-?\\d+$"); //$NON-NLS-1$ } }; }
Example #12
Source File: FieldEditorWrapper.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override public Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fieldEditor = createFieldEditor(container); fieldEditor.setPage(messages); fieldEditor.setPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (FieldEditor.IS_VALID.equals(event.getProperty())) { fireValueChanged(IS_VALID, event.getOldValue(), event.getNewValue()); } else if (FieldEditor.VALUE.equals(event.getProperty())) { fireValueChanged(VALUE, event.getOldValue(), event.getNewValue()); } } }); fieldEditor.setPreferenceStore(getPreferenceStore()); fieldEditor.load(); fieldEditor.fillIntoGrid(container, fieldEditor.getNumberOfControls()); return container; }
Example #13
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * The field editor preference page implementation of this <code>PreferencePage</code> method saves all field * editors by calling <code>FieldEditor.store</code>. Note that this method does not save the preference store * itself; it just stores the values back into the preference store. * * @see FieldEditor#store() */ @Override public boolean performOk() { if (m_fields != null) { Iterator<FieldEditor> I = m_fields.iterator(); while (I.hasNext()) { FieldEditor editor = I.next(); editor.store(); } } return true; }
Example #14
Source File: BaseStylePreferencePage.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean hasLocaleProperties( ) { if ( !firstCheck ) { firstCheck = true; String[] fields = getPreferenceNames( ); if ( fields != null ) { for ( int i = 0; i < fields.length; i++ ) { if ( getPreferenceStore( ) instanceof StylePreferenceStore ) { StylePreferenceStore store = (StylePreferenceStore) getPreferenceStore( ); if ( store.hasLocalValue( fields[i] ) ) { hasLocaleProperty = true; return true; } } } } } else { if ( fields != null ) { for ( int i = 0; i < fields.size( ); i++ ) { FieldEditor editor = (FieldEditor) fields.get( i ); if ( editor instanceof AbstractFieldEditor ) { if ( ( (AbstractFieldEditor) editor ).hasLocaleValue( ) ) return true; } } return false; } } return hasLocaleProperty; }
Example #15
Source File: AbstractBonitaPreferencePage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void createPreferenceEditorContributions(final String contributorId) { final List<IPreferenceFieldEditorContribution> prefEditorContributions = getFieldEditorContibutions(); for (final IPreferenceFieldEditorContribution prefEditorContrib : prefEditorContributions) { if (prefEditorContrib.appliesTo(contributorId)) { addContribution(prefEditorContrib); for (final FieldEditor fe : prefEditorContrib.createFieldEditors(getFieldEditorParent())) { addField(fe); contributedEditors.put(fe, fe.getPreferenceStore()); } } } }
Example #16
Source File: AbstractBonitaPreferencePage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void initialize() { super.initialize(); for (final Entry<FieldEditor, IPreferenceStore> pe : getContributedEditors().entrySet()) { if (pe.getValue() != null) { pe.getKey().setPreferenceStore(pe.getValue()); pe.getKey().load(); } } }
Example #17
Source File: AbstractBonitaPreferencePageTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_initialize_load_editor_preference_store() throws Exception { final Map<FieldEditor, IPreferenceStore> contributedEditor = mapOfContributedEditors(aFieldEditor); when(preferencePage.getContributedEditors()).thenReturn(contributedEditor); doCallRealMethod().when(preferencePage).initialize(); preferencePage.initialize(); verify(contributedEditor.keySet().iterator().next()).setPreferenceStore(contributedEditor.values().iterator().next()); verify(contributedEditor.keySet().iterator().next()).load(); }
Example #18
Source File: AbstractBonitaPreferencePageTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private Map<FieldEditor, IPreferenceStore> mapOfContributedEditors(final FieldEditor... editors) { final Map<FieldEditor, IPreferenceStore> contribuedEditors = new HashMap<FieldEditor, IPreferenceStore>(); for (final FieldEditor editor : editors) { contribuedEditors.put(editor, mock(IPreferenceStore.class)); } return contribuedEditors; }
Example #19
Source File: ShowDiagramGridField.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public List<FieldEditor> createFieldEditors(Composite parent) { editors = new ArrayList<FieldEditor>(); //addRulerFields( parent ); addGridFields( parent ); return editors; }
Example #20
Source File: GitRepositoriesPreferencePage.java From MergeProcessor with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void createFieldEditors() { /* * The following field may be required if GIT repositories should not be created * automatically, as they are provided by a central shared directory, where many * developers use these repositories for GIT merge. */ final Path gitRepositories = Paths .get(Activator.getDefault().getPreferenceStore().getString(GIT_REPOSITORIES_FOLDER)); if (!gitRepositories.toFile().exists()) { try { Files.createDirectories(gitRepositories); } catch (IOException e) { Logger.getLogger(GitRepositoriesPreferencePage.class.getName()).log(Level.SEVERE, e.getMessage(), e); } } final DirectoryFieldEditor repositoryFolderEditor = new DirectoryFieldEditor(GIT_REPOSITORIES_FOLDER, Messages.GitRepositoriesPreferencePage_title, getFieldEditorParent()) { /** * {@inheritDoc} */ @Override protected void fireValueChanged(String property, Object oldValue, Object newValue) { super.fireValueChanged(property, oldValue, newValue); if (FieldEditor.VALUE.equals(property) && !Objects.equals(oldValue, newValue)) { tableViewer.setInput(getGitRepositoryPaths(newValue.toString())); } } }; addField(repositoryFolderEditor); }
Example #21
Source File: DropBusinessDataDBFieldEditorContribution.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public List<FieldEditor> createFieldEditors(final Composite parent) { final List<FieldEditor> editors = new ArrayList<FieldEditor>(); final BooleanFieldEditor dropOnExitFieldEditor = new BooleanFieldEditor(EnginePreferenceConstants.DROP_BUSINESS_DATA_DB_ON_EXIT_PREF, Messages.dropBusinessDataDBOnExit, BooleanFieldEditor.DEFAULT, parent); dropOnExitFieldEditor.setPreferenceStore(EnginePlugin.getDefault().getPreferenceStore()); editors.add(dropOnExitFieldEditor); return editors; }
Example #22
Source File: UpdateCheckerPreferencePage.java From developer-studio with Apache License 2.0 | 5 votes |
@Override public void propertyChange(PropertyChangeEvent event) { FieldEditor fe = (FieldEditor) event.getSource(); if (PreferenceConstants.ENABLE_AUTOMATIC_UPDATES.equals(fe.getPreferenceName())) { boolean isAutomaticUpdateEnabled = (boolean) event.getNewValue(); updateSiteURL.setEnabled(isAutomaticUpdateEnabled, enableDisableSet); releaseSiteURL.setEnabled(isAutomaticUpdateEnabled, enableDisableSet); updateInstallationRadioBttn.setEnabled(isAutomaticUpdateEnabled, enableDisableSet); updateSchedulingRadioBttn.setEnabled(isAutomaticUpdateEnabled, enableDisableSet); if (preferenceStore.getString(PreferenceConstants.UPDATE_RUNNING_CONFIGURATION) .equals(PreferenceConstants.SCHEDULE)) { intervalDayEditor.setEnabled(true, enableDisableSet); intervalTimeEditor.setEnabled(true, enableDisableSet); } } else if (PreferenceConstants.UPDATE_RUNNING_CONFIGURATION.equals(fe.getPreferenceName())) { String newPref = null; boolean isScheduler = false; if (event.getNewValue() != null && !((String) event.getNewValue()).isEmpty()) { newPref = (String) event.getNewValue(); } if (PreferenceConstants.SCHEDULE.equals(newPref)) { isScheduler = true; } intervalDayEditor.setEnabled(isScheduler, enableDisableSet); intervalTimeEditor.setEnabled(isScheduler, enableDisableSet); } super.propertyChange(event); }
Example #23
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * The field editor preference page implementation of this <code>IPreferencePage</code> (and * <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code> events but passes other events on * to its superclass. */ @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { boolean newValue = ((Boolean) event.getNewValue()).booleanValue(); // If the new value is true then we must check all field editors. // If it is false, then the page is invalid in any case. if (newValue) { checkState(); } else { m_invalidFieldEditor = (FieldEditor) event.getSource(); setValid(newValue); } } }
Example #24
Source File: SwaggerValidationPreferences.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 5 votes |
@Override protected void createFieldEditors() { Composite composite = new Composite(getFieldEditorParent(), SWT.NONE); GridLayoutFactory.fillDefaults() // .numColumns(2) // .margins(5, 8) // .spacing(5, 20) // .applyTo(composite); Group group = new Group(composite, SWT.SHADOW_ETCHED_IN); GridDataFactory.fillDefaults().span(2, 1).applyTo(group); group.setText("Allow JSON references in additional contexts"); addField(new BooleanFieldEditor(VALIDATION_REF_SECURITY_DEFINITIONS_OBJECT, "Security Definitions Object", group)); addField(new BooleanFieldEditor(VALIDATION_REF_SECURITY_SCHEME_OBJECT, "Security Scheme Object", group)); addField(new BooleanFieldEditor(VALIDATION_REF_SECURITY_REQUIREMENTS_ARRAY, "Security Requirements Array", group)); addField(new BooleanFieldEditor(VALIDATION_REF_SECURITY_REQUIREMENT_OBJECT, "Security Requirement Object", group)); // FieldEditor set parent layout to GridLayout with margin = 0 ((GridLayout) group.getLayout()).marginTop = 8; ((GridLayout) group.getLayout()).marginBottom = 8; ((GridLayout) group.getLayout()).marginLeft = 8; ((GridLayout) group.getLayout()).marginRight = 8; // Validation Set<PreferenceProvider> providers = ExtensionUtils.getPreferenceProviders(VALIDATION_PREFERENCE_PAGE); providers.forEach(provider -> { for (FieldEditor field : provider.createFields(Version.SWAGGER, composite)) { addField(field); } }); }
Example #25
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * The field editor preference page implementation of a <code>PreferencePage</code> method loads all the field * editors with their default values. */ @Override protected void performDefaults() { if (m_fields != null) { Iterator<FieldEditor> I = m_fields.iterator(); while (I.hasNext()) { FieldEditor editor = I.next(); editor.loadDefault(); } } // Force a recalculation of my error state. checkState(); super.performDefaults(); }
Example #26
Source File: LabSettings.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void propertyChange(PropertyChangeEvent event){ super.propertyChange(event); if (event.getSource() instanceof FieldEditor) { FieldEditor fe = ((FieldEditor) event.getSource()); if (Preferences.LABSETTINGS_CFG_LOCAL_REFVALUES.equals(fe.getPreferenceName())) { if (event.getNewValue().equals(Boolean.TRUE)) { MessageDialog.openInformation(UiDesk.getTopShell(), Messages.LabSettings_enableUseLocalLabRefValues_title, Messages.LabSettings_enableUseLocalLabRefValues_text); } } } }
Example #27
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * Initializes all field editors. */ protected void initialize() { if (m_fields != null) { Iterator<FieldEditor> I = m_fields.iterator(); while (I.hasNext()) { FieldEditor editor = I.next(); editor.setPage(null); editor.setPropertyChangeListener(this); editor.setPreferenceStore(getPreferenceStore()); editor.load(); } } }
Example #28
Source File: FieldLayoutPreferencePage.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * The field editor preference page implementation of an <code>IDialogPage</code> method disposes of this page's * controls and images. Subclasses may override to release their own allocated SWT resources, but must call * <code>super.dispose</code>. */ @Override public void dispose() { super.dispose(); if (m_fields != null) { Iterator<FieldEditor> I = m_fields.iterator(); while (I.hasNext()) { FieldEditor editor = I.next(); editor.setPage(null); editor.setPropertyChangeListener(null); editor.setPreferenceStore(null); } } }
Example #29
Source File: JenerateBasePreferencePage.java From jenerate with Eclipse Public License 1.0 | 5 votes |
@Override protected void createFieldEditors() { for (PluginPreference<?> pluginPreference : JeneratePreferences.getAllPreferences()) { FieldEditor fieldEditor = pluginPreference.createFieldEditor(getFieldEditorParent()); fieldEditors.put(pluginPreference, fieldEditor); addField(fieldEditor); } }
Example #30
Source File: StrategyIdentifierPluginPreference.java From jenerate with Eclipse Public License 1.0 | 5 votes |
@Override public FieldEditor createFieldEditor(Composite parent) { MethodContentStrategyIdentifier[] values = MethodContentStrategyIdentifier.values(); String[][] comboValues = new String[values.length][2]; for (int i = 0; i < values.length; i++) { comboValues[i] = new String[] { values[i].name(), values[i].name() }; } return new ComboFieldEditor(this.getKey(), this.getDescription(), comboValues, parent); }