List of usage examples for org.eclipse.jface.preference PreferenceStore PreferenceStore
public PreferenceStore()
From source file:ccw.preferences.OverlayPreferenceStore.java
License:Open Source License
public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { fParent = parent; fOverlayKeys = overlayKeys; fStore = new PreferenceStore(); }
From source file:com.android.ide.eclipse.adt.internal.editors.formatting.EclipseXmlPrettyPrinterTest.java
License:Open Source License
@Override protected void setUp() throws Exception { super.setUp(); PreferenceStore store = new PreferenceStore(); AdtPrefs.init(store);//from w w w .j a va2 s.c om AdtPrefs prefs = AdtPrefs.getPrefs(); prefs.initializeStoreWithDefaults(store); prefs.loadValues(null); EclipseXmlFormatPreferences formatPrefs = EclipseXmlFormatPreferences.create(); assertTrue(formatPrefs.oneAttributeOnFirstLine); }
From source file:com.android.ide.eclipse.adt.internal.editors.formatting.XmlPrettyPrinterTest.java
License:Open Source License
@Override protected void setUp() throws Exception { super.setUp(); PreferenceStore store = new PreferenceStore(); AdtPrefs.init(store);/*w w w. j a v a2 s . co m*/ AdtPrefs prefs = AdtPrefs.getPrefs(); prefs.initializeStoreWithDefaults(store); prefs.loadValues(null); XmlFormatPreferences formatPrefs = XmlFormatPreferences.create(); assertTrue(formatPrefs.oneAttributeOnFirstLine); }
From source file:com.android.sdkstats.DdmsPreferenceStore.java
License:Apache License
/** * Returns the DDMS {@link PreferenceStore}. * This keeps a static reference on the store, so consequent calls will * return always the same store.// w ww .jav a2 s . c om */ public PreferenceStore getPreferenceStore() { synchronized (DdmsPreferenceStore.class) { if (sPrefStore == null) { // get the location of the preferences String homeDir = null; try { homeDir = AndroidLocation.getFolder(); } catch (AndroidLocationException e1) { // pass, we'll do a dummy store since homeDir is null } if (homeDir == null) { sPrefStore = new PreferenceStore(); return sPrefStore; } assert homeDir != null; String rcFileName = homeDir + "ddms.cfg"; //$NON-NLS-1$ // also look for an old pref file in the previous location String oldPrefPath = System.getProperty("user.home") //$NON-NLS-1$ + File.separator + ".ddmsrc"; //$NON-NLS-1$ File oldPrefFile = new File(oldPrefPath); if (oldPrefFile.isFile()) { FileOutputStream fileOutputStream = null; try { PreferenceStore oldStore = new PreferenceStore(oldPrefPath); oldStore.load(); fileOutputStream = new FileOutputStream(rcFileName); oldStore.save(fileOutputStream, ""); //$NON-NLS-1$ oldPrefFile.delete(); PreferenceStore newStore = new PreferenceStore(rcFileName); newStore.load(); sPrefStore = newStore; } catch (IOException e) { // create a new empty store. sPrefStore = new PreferenceStore(rcFileName); } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { // pass } } } } else { sPrefStore = new PreferenceStore(rcFileName); try { sPrefStore.load(); } catch (IOException e) { System.err.println("Error Loading DDMS Preferences"); } } } assert sPrefStore != null; return sPrefStore; } }
From source file:com.aptana.internal.ui.text.spelling.SpellingConfigurationBlock.java
License:Open Source License
/** * Creates the encoding field editor.//from ww w . j a v a 2 s. c o m * * @param composite * the parent composite * @param allControls * list with all controls * @since 3.3 */ private void createEncodingFieldEditor(Composite composite, List allControls) { final Label filler = new Label(composite, SWT.NONE); final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 4; filler.setLayoutData(gd); // Label label = new Label(composite, SWT.NONE); // label // .setText(PreferencesMessages.SpellingPreferencePage_encoding_label); // label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); // allControls.add(label); // fEncodingEditorParent = new Composite(composite, SWT.NONE); // GridLayout layout = new GridLayout(2, false); // layout.marginWidth = 0; // layout.marginHeight = 0; // fEncodingEditorParent.setLayout(layout); // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); // gd.horizontalSpan = 3; // fEncodingEditorParent.setLayoutData(gd); //fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); //$NON-NLS-1$ final PreferenceStore store = new PreferenceStore(); // String defaultEncoding= ResourcesPlugin.getEncoding(); store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), Charset.defaultCharset().name()); final String encoding = this.getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING); if ((encoding != null) && (encoding.length() > 0)) { store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding); } // fEncodingEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change // listener final DialogPage fakePage = new DialogPage() { public void createControl(Composite c) { } public void setErrorMessage(String newMessage) { final StatusInfo status = new StatusInfo(); if (newMessage != null) { status.setError(newMessage); } SpellingConfigurationBlock.this.fEncodingFieldEditorStatus = status; SpellingConfigurationBlock.this.fContext.statusChanged( StatusUtil.getMostSevere(new IStatus[] { SpellingConfigurationBlock.this.fThresholdStatus, SpellingConfigurationBlock.this.fFileStatus, SpellingConfigurationBlock.this.fEncodingFieldEditorStatus })); } }; // fEncodingEditor.setPage(fakePage); // // fEncodingEditor.load(); // // if (encoding == null || encoding.equals(defaultEncoding) || // encoding.length() == 0) // fEncodingEditor.loadDefault(); }
From source file:com.diffplug.gradle.spotless.groovy.eclipse.GrEclipseFormatterStepImpl.java
License:Apache License
private static PreferenceStore createPreferences(final Properties properties) throws IOException { final PreferenceStore preferences = new PreferenceStore(); ByteArrayOutputStream output = new ByteArrayOutputStream(); properties.store(output, null);/* w w w.j ava2s. c o m*/ ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); preferences.load(input); return preferences; }
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//from ww w . j a va2 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) { 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//from ww w . jav a 2s . 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 != 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/*from w w w . ja v a 2s .com*/ 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 ww w . j av 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; }