List of usage examples for org.eclipse.jface.preference FieldEditor getPreferenceName
public String getPreferenceName()
From source file:com.chookapp.org.bracketeer.preferences.ChangingFieldsPrefPage.java
License:Open Source License
@Override protected void addField(FieldEditor editor) { super.addField(editor); _prefNames.add(editor.getPreferenceName()); }
From source file:com.dnw.depmap.preferences.RootPreferenePage.java
License:Open Source License
/** * 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. * //from w w w . j a v a 2s.co m * @author manbaum * @since Oct 23, 2014 * @param event the property change event object describing which property changed and how. * @see org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); FieldEditor f = (FieldEditor) event.getSource(); Composite p = getFieldEditorParent(); if (event.getProperty() == FieldEditor.VALUE) { if (f.getPreferenceName().equals(PrefKeys.P_USESTANDALONE)) { boolean value = (Boolean) event.getNewValue(); dburl.setEnabled(value, gf1.getGroupControl(p)); } else if (f.getPreferenceName().equals(PrefKeys.P_USEEMBEDDED)) { boolean value = (Boolean) event.getNewValue(); dbdir.setEnabled(value, gf1.getGroupControl(p)); } else if (f.getPreferenceName().equals(PrefKeys.P_USEPREEXEC)) { boolean value = (Boolean) event.getNewValue(); statements.setEnabled(value, gf3.getGroupControl(p)); } } }
From source file:com.ge.research.sadl.ui.preferences.ReasonerConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override// w w w. j a v a2 s.co m public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; if (config != null) { for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug(key + " class = " + optionValue.getClass().getName()); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } else { logger.info("No configuration options available"); } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(reasonerCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.ge.research.sadl.ui.preferences.TranslatorConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override/* w ww .j a v a 2 s . c om*/ public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; if (config == null) { messageArea.updateText("No options available", IMessageProvider.NONE); return; } for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug( key + " class = " + (optionValue != null ? optionValue.getClass().getName() : "null")); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue == null) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(translatorCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.ge.research.sadl.ui.properties.ReasonerConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override/* w w w .j a v a 2 s . co m*/ public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug(key + " class = " + optionValue.getClass().getName()); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(reasonerCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.ge.research.sadl.ui.properties.TranslatorConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); editors = new ArrayList<FieldEditor>(); messageArea = new DialogMessageArea(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override//from w w w .j a v a 2 s . c o m public void createControl(Composite parentComposite) { noDefaultAndApplyButton(); super.createControl(parentComposite); } @SuppressWarnings("synthetic-access") @Override protected void createFieldEditors() { rcps = this.doGetPreferenceStore(); if (rcps == null) { rcps = new PreferenceStore(); } FieldEditor editor; if (config == null) { messageArea.updateText("No options available", IMessageProvider.NONE); return; } for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) { String key = entry.getKey(); ConfigurationOption option = entry.getValue(); if (key.equalsIgnoreCase("builtin")) { continue; } String optionDescription = option.getDescription(); Object currentValue = currentConfig.get(key); Object optionValue = option.getValue(); if (currentValue != null) { optionValue = currentValue; } logger.debug(key + " class = " + optionValue.getClass().getName()); Object[] optionPossibleValues = option.getPossibleValues(); if (optionPossibleValues != null && optionPossibleValues.length > 0) { // Option has a list of values so create a dropdown box String[][] nv = new String[optionPossibleValues.length][2]; for (int i = 0; i < optionPossibleValues.length; i++) { nv[i][0] = optionPossibleValues[i].toString(); nv[i][1] = optionPossibleValues[i].toString(); } editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) { editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) { editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) { editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.setPage(page); editor.load(); editors.add(editor); } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) { editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent()); rcps.setValue(editor.getPreferenceName(), optionValue.toString()); editor.setPreferenceStore(rcps); addField(editor); editor.load(); editors.add(editor); } } } @SuppressWarnings("synthetic-access") @Override protected void updateApplyButton() { updateButtons(isValid()); super.updateApplyButton(); } }; messageArea.createContents(composite); messageArea.showTitle(translatorCategory + " Configuration Options", null); messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH)); page.createControl(composite); for (FieldEditor editor : editors) { editor.setPreferenceStore(rcps); } Control pageControl = page.getControl(); pageControl.setLayoutData(new GridData(GridData.FILL_BOTH)); return pageControl; }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.editors.AbstractPreferencePage.java
License:Open Source License
/** * Saves the 'use project settings' as a preference in the store using * the {@link #getUseProjectSettingsName()} as the key. * If not project specific, all affected keys are removed from the project preferences. *//*w ww . j a v a 2 s. com*/ private void saveUseProjectSettings(boolean isProjectSpecific) throws Exception { final ProjectAwareScopedPreferenceStore store = (ProjectAwareScopedPreferenceStore) 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(getUseProjectSettingsName()); } else { store.setValue(getUseProjectSettingsName(), Boolean.toString(isProjectSpecific)); } store.save(); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.editors.AbstractPreferencePage.java
License:Open Source License
/** * Copies all the project specific values (except master key) to the values of the instance preference * store.//from w ww .j a v a 2s.c o m */ private void setProjectSpecificValues() { ProjectAwareScopedPreferenceStore store = (ProjectAwareScopedPreferenceStore) getPreferenceStore(); IEclipsePreferences storePreferences = store.getStorePreferences(); for (FieldEditor field : editors) { String key = field.getPreferenceName(); storePreferences.put(key, store.getString(key)); } }
From source file:com.technophobia.substeps.editor.preferences.page.SubstepsPropertyPage.java
License:Open Source License
private void addField(final FieldEditor field, final Composite parent) { fieldEditorsByKey.put(field.getPreferenceName(), field); fieldToParentMap.put(field, parent); }
From source file:de.fu_berlin.inf.dpp.videosharing.preferences.VideoPlayerPreferencePage.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof FieldEditor) { FieldEditor field = (FieldEditor) event.getSource(); if (field.getPreferenceName().equals(PreferenceConstants.PLAYER_RESAMPLE)) { if (event.getNewValue() instanceof Boolean) { Boolean newValue = (Boolean) event.getNewValue(); keepAspectRatioField.setEnabled(newValue, parent); }// ww w. j av a2 s. c o m } } }