List of usage examples for org.eclipse.jface.preference IPreferenceStore firePropertyChangeEvent
void firePropertyChangeEvent(String name, Object oldValue, Object newValue);
From source file:org.eclipse.ui.editors.tests.ChainedPreferenceStoreTest.java
License:Open Source License
/** * Third case where the initial implementation used to have an assertion which would fail in this case *//* w ww . j a v a 2 s . com*/ public void testChainedStore2() { IPreferenceStore store1 = new PreferenceStore(); IPreferenceStore store2 = new PreferenceStore(); IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 }); store1.setValue(PROPERTY, VALUE); chainedStore.addPropertyChangeListener(fPropertyChangeListener); store1.firePropertyChangeEvent(PROPERTY, DEFAULT_VALUE, null); // simulated change with newValue == null chainedStore.removePropertyChangeListener(fPropertyChangeListener); assertEquals(1, fEvents.size()); PropertyChangeEvent event = (PropertyChangeEvent) fEvents.get(0); assertEquals(store1, event.getSource()); assertEquals(PROPERTY, event.getProperty()); assertEquals(DEFAULT_VALUE, event.getOldValue()); assertEquals(null, event.getNewValue()); }
From source file:org.eclipse.ui.editors.tests.ChainedPreferenceStoreTest.java
License:Open Source License
/** * Case where the initial implementation used to throw an IAE */// www . j a va 2 s . c o m public void testChainedStore3() { IPreferenceStore store1 = new PreferenceStore(); IPreferenceStore store2 = new PreferenceStore(); IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 }); store2.setDefault(PROPERTY, DEFAULT_VALUE); chainedStore.addPropertyChangeListener(fPropertyChangeListener); store1.firePropertyChangeEvent(PROPERTY, null, null); // simulated removal with oldValue == null chainedStore.removePropertyChangeListener(fPropertyChangeListener); assertEquals(1, fEvents.size()); PropertyChangeEvent event = (PropertyChangeEvent) fEvents.get(0); assertEquals(chainedStore, event.getSource()); assertEquals(PROPERTY, event.getProperty()); assertEquals(null, event.getOldValue()); assertEquals(DEFAULT_VALUE, event.getNewValue()); }
From source file:org.eclipse.ui.internal.ide.dialogs.IDEWorkspacePreferencePage.java
License:Open Source License
/** * The user has pressed Ok. Store/apply this page's values appropriately. *//*from w w w. j a va 2s.c om*/ public boolean performOk() { // set the workspace auto-build flag IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (autoBuildButton.getSelection() != ResourcesPlugin.getWorkspace().isAutoBuilding()) { try { description.setAutoBuilding(autoBuildButton.getSelection()); ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { IDEWorkbenchPlugin.log("Error changing auto build workspace setting.", e//$NON-NLS-1$ .getStatus()); } } IPreferenceStore store = getIDEPreferenceStore(); // store the save all prior to build setting store.setValue(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD, autoSaveAllButton.getSelection()); // store the workspace save interval // @issue we should drop our preference constant and let clients use // core's pref. ours is not up-to-date anyway if someone changes this // interval directly thru core api. long oldSaveInterval = description.getSnapshotInterval() / 60000; long newSaveInterval = new Long(saveInterval.getStringValue()).longValue(); if (oldSaveInterval != newSaveInterval) { try { description.setSnapshotInterval(newSaveInterval * 60000); ResourcesPlugin.getWorkspace().setDescription(description); store.firePropertyChangeEvent(IDEInternalPreferences.SAVE_INTERVAL, new Integer((int) oldSaveInterval), new Integer((int) newSaveInterval)); } catch (CoreException e) { IDEWorkbenchPlugin.log("Error changing save interval preference", e //$NON-NLS-1$ .getStatus()); } } workspaceName.store(); Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); boolean autoRefresh = autoRefreshButton.getSelection(); preferences.setValue(ResourcesPlugin.PREF_AUTO_REFRESH, autoRefresh); boolean lightweightRefresh = lightweightRefreshButton.getSelection(); preferences.setValue(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, lightweightRefresh); boolean closeUnrelatedProj = closeUnrelatedProjectButton.getSelection(); getIDEPreferenceStore().setValue(IDEInternalPreferences.CLOSE_UNRELATED_PROJECTS, closeUnrelatedProj); if (clearUserSettings) { IDEEncoding.clearUserEncodings(); } encodingEditor.store(); lineSeparatorEditor.store(); openReferencesEditor.store(); return super.performOk(); }
From source file:org.search.niem.uml.papyrus.preferences.NIEMPreferenceConverter.java
License:Open Source License
public static void setValue(final IPreferenceStore store, final String name, final AggregationKind value) { final AggregationKind oldValue = getAggregationKind(store, name); if (oldValue == null || !oldValue.equals(value)) { store.putValue(name, asString(value)); store.firePropertyChangeEvent(name, oldValue, value); }//from ww w.ja v a 2 s .c o m }