List of usage examples for org.eclipse.jface.preference FieldEditor load
public void load()
From source file:net.sourceforge.eclipseccase.ui.preferences.UcmPreferencePage.java
License:Open Source License
private void addFieldEditor(FieldEditor fieldEditor) { fieldEditor.setPreferencePage(this); fieldEditor.setPreferenceStore(getPreferenceStore()); fieldEditor.load(); }
From source file:org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizardPage.java
License:Apache License
public void createControl(Composite parent) { Composite control = new Composite(parent, SWT.NONE); setControl(control);/* w w w. j a va2s . c o m*/ if (getModel().getType().isDynamic()) { nameEditor = new StringFieldEditor("name", "Name:", control); nameEditor.setEmptyStringAllowed(false); addField(nameEditor); } createFieldEditors(); int cols = 0; for (FieldEditor e : editors) { cols = Math.max(cols, e.getNumberOfControls()); } control.setLayout(new GridLayout(cols, false)); for (FieldEditor e : editors) { if (e instanceof StringFieldEditor) { StringFieldEditor sfe = (StringFieldEditor) e; sfe.getTextControl(getFieldEditorParent()).addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { checkPageComplete(); } }); } e.fillIntoGrid(getFieldEditorParent(), cols); e.setPreferenceStore(getStore()); e.load(); } checkPageComplete(); }
From source file:org.bc.eclipse.hadoop.debug.JavaRetryConnectTab.java
License:Open Source License
/** * Updates the connection argument field editors from the specified configuration * @param config the config to load from *///from ww w .j av a 2 s .c o m private void updateConnectionFromConfig(ILaunchConfiguration config) { String id = null; try { id = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, JavaRuntime.getDefaultVMConnector().getIdentifier()); fConnectorCombo.setText(JavaRuntime.getVMConnector(id).getName()); handleConnectorComboModified(); Map<String, String> attrMap = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, (Map<String, String>) null); if (attrMap == null) { return; } Iterator<String> keys = attrMap.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); Connector.Argument arg = fArgumentMap.get(key); FieldEditor editor = fFieldEditorMap.get(key); if (arg != null && editor != null) { String value = attrMap.get(key); if (arg instanceof Connector.StringArgument || arg instanceof Connector.SelectedArgument) { editor.getPreferenceStore().setValue(key, value); } else if (arg instanceof Connector.BooleanArgument) { editor.getPreferenceStore().setValue(key, Boolean.valueOf(value).booleanValue()); } else if (arg instanceof Connector.IntegerArgument) { editor.getPreferenceStore().setValue(key, new Integer(value).intValue()); } editor.load(); } } } catch (CoreException ce) { JDIDebugUIPlugin.log(ce); } }
From source file:org.bonitasoft.studio.preferences.pages.BonitaAppearancePreferencePage.java
License:Open Source License
@Override protected void initialize() { if (fieldEditors != null) { Iterator<FieldEditor> e = fieldEditors.iterator(); while (e.hasNext()) { FieldEditor pe = e.next(); pe.setPage(this); pe.setPropertyChangeListener(this); if (pe.getPreferenceStore() == null) { pe.setPreferenceStore(getPreferenceStore()); }//from w ww . j a v a 2 s. c o m pe.load(); } } }
From source file:org.cs3.pdt.graphicalviews.preferences.PreferencePageBase.java
License:Open Source License
@Override public void preferencesUpdated() { for (FieldEditor e : editors) { if (e != null) { e.load(); }/*from w w w .j a va 2 s . c o m*/ } }
From source file:org.cs3.prolog.connector.internal.preferences.PreferencePage.java
License:Open Source License
private void changePreferenceStore(PreferenceStore store) { setPreferenceStore(store);/* w w w .j a v a2 s. c o m*/ for (FieldEditor editor : editors) { editor.setPreferenceStore(store); editor.load(); } updateExecuteablePreviewLabelText(); }
From source file:org.csstudio.diirt.util.preferences.BasePreferencePage.java
License:Open Source License
/** * Add the given {@code editor} field to this page. The editor's * caption foreground will be updated when the editor's value changes. * * @param fieldEditor The {@link FieldEditor} to be added and updated. * @param parent The {@link Composite} owning the given {@code editor}. * @param canBeDefaulted {@code true} if the given {@code editor} can be * restored to its default value. * @param defaultGetter The {@link Supplier} of the editor's default value. * Can be {@code null} if the editor's caption foreground * should not be updated when the editor's value changes. * @param storedGetter The {@link Supplier} of the editor's stored value. * Can be {@code null} if the editor's caption foreground * should not be initially updated. * @param listener Called when a field editor fires a value property change. *//*from w ww. ja v a2s .c om*/ protected void addField(FieldEditor fieldEditor, Composite parent, boolean canBeDefaulted, Supplier<Object> defaultGetter, Supplier<Object> storedGetter, IPropertyChangeListener listener) { final IPreferenceStore store = getPreferenceStore(); final Editor editor = new Editor(fieldEditor, parent, canBeDefaulted, defaultGetter, storedGetter); fieldEditor.getLabelControl(parent).setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); fieldEditor.setPage(this); fieldEditor.setPreferenceStore(store); fieldEditor.load(); fieldEditor.setPropertyChangeListener(e -> { if (FieldEditor.VALUE.equals(e.getProperty())) { if (storedGetter != null) { editor.setRestartRequired(!Objects.equals(e.getNewValue(), storedGetter.get())); } editor.updateCaptionColor(e.getNewValue()); if (listener != null) { listener.propertyChange(e); } } }); editor.updateCaptionColor(); editors.put(fieldEditor, editor); if (PREF_CONFIGURATION_DIRECTORY.equals(fieldEditor.getPreferenceName())) { directoryEditor = editor; } }
From source file:org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsUI.java
License:Open Source License
/** * Update field editors in this page when the page is loaded. */// w w w. j a va2 s. c om @Override public void updateFields() { Object[][] options = category.getOptions(fInfo, optionHolder); // some option has changed on this page... update enabled/disabled state for all options for (int index = 0; index < options.length; ++index) { // Get the option IHoldsOptions holder = (IHoldsOptions) options[index][0]; if (holder == null) break; // The array may not be full IOption opt = (IOption) options[index][1]; String prefName = getToolSettingsPrefStore().getOptionId(opt); // is the option on this page? if (fieldsMap.containsKey(prefName)) { FieldEditor fieldEditor = fieldsMap.get(prefName); try { if (opt.getValueType() == IOption.ENUMERATED) { updateEnumList(fieldEditor, opt, holder, fInfo); } } catch (BuildException be) { } // check to see if the option has an applicability calculator IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); if (applicabilityCalculator != null) { Composite parent = fieldEditorsToParentMap.get(fieldEditor); setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, parent); } } } Collection<FieldEditor> fieldsList = fieldsMap.values(); for (FieldEditor editor : fieldsList) { if (editor instanceof TriStateBooleanFieldEditor) ((TriStateBooleanFieldEditor) editor).set3(true); editor.load(); } }
From source file:org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsUI.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent event) { // allow superclass to handle as well super.propertyChange(event); Object source = event.getSource(); IOption changedOption = null;// w w w . jav a 2s. c om IHoldsOptions changedHolder = null; String id = null; if (source instanceof FieldEditor) { FieldEditor fe = (FieldEditor) source; if (fe instanceof TriStateBooleanFieldEditor) ((TriStateBooleanFieldEditor) fe).set3(false); id = fe.getPreferenceName(); Object[] option = this.getToolSettingsPrefStore().getOption(id); if (option == null) { int n = id.lastIndexOf('.'); if (n > 0) { id = id.substring(0, n); option = getToolSettingsPrefStore().getOption(id); } } if (option != null) { changedOption = (IOption) option[1]; changedHolder = (IHoldsOptions) option[0]; try { switch (changedOption.getValueType()) { case IOption.STRING: if (fe instanceof StringFieldEditor) { String val = ((StringFieldEditor) fe).getStringValue(); ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, val); } break; case IOption.BOOLEAN: if (fe instanceof BooleanFieldEditor) { boolean val = ((BooleanFieldEditor) fe).getBooleanValue(); ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, val); } break; case IOption.ENUMERATED: if (fe instanceof BuildOptionComboFieldEditor) { String name = ((BuildOptionComboFieldEditor) fe).getSelection(); String enumId = changedOption.getEnumeratedId(name); ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, (enumId != null && enumId.length() > 0) ? enumId : name); } break; case IOption.TREE: if (fe instanceof TreeBrowseFieldEditor) { String name = ((TreeBrowseFieldEditor) fe).getStringValue(); String treeId = changedOption.getId(name); ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, (treeId != null && treeId.length() > 0) ? treeId : name); } break; case IOption.INCLUDE_PATH: case IOption.STRING_LIST: case IOption.PREPROCESSOR_SYMBOLS: case IOption.LIBRARIES: case IOption.OBJECTS: case IOption.INCLUDE_FILES: case IOption.LIBRARY_PATHS: case IOption.LIBRARY_FILES: case IOption.MACRO_FILES: case IOption.UNDEF_INCLUDE_PATH: case IOption.UNDEF_PREPROCESSOR_SYMBOLS: case IOption.UNDEF_INCLUDE_FILES: case IOption.UNDEF_LIBRARY_PATHS: case IOption.UNDEF_LIBRARY_FILES: case IOption.UNDEF_MACRO_FILES: if (fe instanceof FileListControlFieldEditor) { String val[] = ((FileListControlFieldEditor) fe).getStringListValue(); ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, val); } break; default: break; } } catch (BuildException e) { } } } Object[][] options = category.getOptions(fInfo, optionHolder); // some option has changed on this page... update enabled/disabled state for all options for (int index = 0; index < options.length; ++index) { // Get the option IHoldsOptions holder = (IHoldsOptions) options[index][0]; if (holder == null) break; // The array may not be full IOption opt = (IOption) options[index][1]; String optId = getToolSettingsPrefStore().getOptionId(opt); // is the option on this page? if (fieldsMap.containsKey(optId)) { // check to see if the option has an applicability calculator IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); FieldEditor fieldEditor = fieldsMap.get(optId); try { if (opt.getValueType() == IOption.ENUMERATED) { // the item list of this enumerated option may have changed, update it updateEnumList(fieldEditor, opt, holder, fInfo); } } catch (BuildException be) { } if (applicabilityCalculator != null) { Composite parent = fieldEditorsToParentMap.get(fieldEditor); setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, parent); } } } Collection<FieldEditor> xxx = fieldsMap.values(); for (FieldEditor editor : xxx) { if (id == null || !id.equals(editor.getPreferenceName())) editor.load(); } }
From source file:org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsUI.java
License:Open Source License
/** * The items shown in an enumerated option may depend on other option values. * Whenever an option changes, check and update the valid enum values in * the combo fieldeditor./*from www . jav a 2s .co m*/ * * See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=154053 * * @param fieldEditor enumerated combo fieldeditor * @param opt enumerated option type to update * @param holder the option holder * @param config project or resource info * @throws BuildException */ protected void updateEnumList(FieldEditor fieldEditor, IOption opt, IHoldsOptions holder, IResourceInfo config) throws BuildException { // Get all applicable values for this enumerated Option, and filter out // the disable values String[] enumNames = opt.getApplicableValues(); // get the currently selected enum value, the updated enum list may not contain // it, in that case a new value has to be selected String selectedEnum = opt.getSelectedEnum(); String selectedEnumName = opt.getEnumName(selectedEnum); // get the default value for this enumerated option String defaultEnumId = (String) opt.getDefaultValue(); String defaultEnumName = opt.getEnumName(defaultEnumId); boolean selectNewEnum = true; boolean selectDefault = false; Vector<String> enumValidList = new Vector<String>(); for (int i = 0; i < enumNames.length; ++i) { if (opt.getValueHandler().isEnumValueAppropriate(config, opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) { if (selectedEnumName.equals(enumNames[i])) { // the currently selected enum is part of the new item list, no need to select a new value. selectNewEnum = false; } if (defaultEnumName.equals(enumNames[i])) { // the default enum value is part of new item list selectDefault = true; } enumValidList.add(enumNames[i]); } } String[] enumValidNames = new String[enumValidList.size()]; enumValidList.copyInto(enumValidNames); if (selectNewEnum) { // apparently the currently selected enum value is not part anymore of the enum list // select a new value. String selection = null; if (selectDefault) { // the default enum value is part of the item list, use it selection = (String) opt.getDefaultValue(); } else if (enumValidNames.length > 0) { // select the first item in the item list selection = opt.getEnumeratedId(enumValidNames[0]); } ManagedBuildManager.setOption(config, holder, opt, selection); } ((BuildOptionComboFieldEditor) fieldEditor).setOptions(enumValidNames); fieldEditor.load(); }