List of usage examples for org.eclipse.jface.preference IPreferenceStore firePropertyChangeEvent
void firePropertyChangeEvent(String name, Object oldValue, Object newValue);
From source file:mmrnmhrm.ui.preferences.pages.DeeAppearancePreferencePage.java
License:Open Source License
/** Triggers a refresh on all viewers with model element label providers. * (Uses a workaround to trigger refresh in {@link AppearanceAwareLabelProvider} ) */ protected void refreshIDEViewers() { IPreferenceStore prefStore = DeeUIPlugin.getInstance().getPreferenceStore(); String value = prefStore.getString(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE); prefStore.firePropertyChangeEvent(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, value, value); }
From source file:net.sf.solareclipse.ui.preferences.ChainedPreferenceStore.java
License:Open Source License
public static void startPropagating(final IPreferenceStore source, final IPreferenceStore target, final Set keys) { for (Iterator i = keys.iterator(); i.hasNext();) { String key = (String) i.next(); target.setDefault(key, source.getString(key)); }// ww w. j a v a 2 s . c o m source.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String key = event.getProperty(); if (keys.contains(key)) { target.setDefault(key, source.getString(key)); if (target.isDefault(key)) { target.firePropertyChangeEvent(key, event.getOldValue(), event.getNewValue()); } } } }); }
From source file:net.sourceforge.javahexeditor.plugin.editors.HexEditorPreferencesPage.java
License:Open Source License
@Override public boolean performOk() { IPreferenceStore store = HexEditorPlugin.getDefault().getPreferenceStore(); FontData fontData = preferences.getFontData(); store.setValue(Preferences.FONT_NAME, fontData.getName()); store.setValue(Preferences.FONT_STYLE, fontData.getStyle()); store.setValue(Preferences.FONT_SIZE, fontData.getHeight()); store.firePropertyChangeEvent(Preferences.FONT_DATA, null, fontData); try {/*from w ww. ja va 2 s. c o m*/ InstanceScope.INSTANCE.getNode(HexEditorPlugin.ID).flush(); } catch (BackingStoreException ex) { throw new RuntimeException("Cannot store preferences for plugin '" + HexEditorPlugin.ID + "'", ex); } return true; }
From source file:org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.java
License:Open Source License
/** * Sets the default value and fires a property * change event if necessary./*from www. ja v a2 s . c o m*/ * * @param store the preference store * @param key the preference key * @param newValue the new value * @param fireEvent <code>false</code> if no event should be fired * @since 3.4 */ private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) { if (!fireEvent) { PreferenceConverter.setDefault(store, key, newValue); } else { RGB oldValue = null; if (store.isDefault(key)) oldValue = PreferenceConverter.getDefaultColor(store, key); PreferenceConverter.setDefault(store, key, newValue); if (oldValue != null && !oldValue.equals(newValue)) store.firePropertyChangeEvent(key, oldValue, newValue); } }
From source file:org.eclipse.editorconfig.ui.internal.preferences.EditorConfigUIPreferenceInitializer.java
License:Open Source License
/** * Sets the default value and fires a property change event if necessary. * * @param store/* w ww . jav a 2 s. c o m*/ * the preference store * @param key * the preference key * @param newValue * the new value * @param fireEvent * <code>false</code> if no event should be fired */ private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) { if (!fireEvent) { PreferenceConverter.setDefault(store, key, newValue); return; } RGB oldValue = null; if (store.isDefault(key)) { oldValue = PreferenceConverter.getDefaultColor(store, key); } PreferenceConverter.setDefault(store, key, newValue); if (oldValue != null && !oldValue.equals(newValue)) { store.firePropertyChangeEvent(key, oldValue, newValue); } }
From source file:org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior.java
License:Open Source License
/** * Initializes the used GEF palette viewer to display the palette as * defined. The default implementation initializes the preference store with * the GEF {@link DefaultPaletteViewerPreferences} and triggers a refresh of * the palette.// w w w. j av a2 s . c om */ public void initializeViewer() { // Set preference-store for palette PaletteViewer paletteViewer = diagramBehavior.getEditDomain().getPaletteViewer(); if (paletteViewer != null) { IPreferenceStore store = GraphitiUIPlugin.getDefault().getPreferenceStore(); paletteViewer.setPaletteViewerPreferences(new DefaultPaletteViewerPreferences(store)); // Refresh the PaletteViewer // This can be achieved by firing a font-change-event from the // IPreferenceStore. It would be nicer, if the PaletteViewer would // have some kind of refresh()-method directly. store.firePropertyChangeEvent(PaletteViewerPreferences.PREFERENCE_FONT, null, null); } }
From source file:org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.java
License:Open Source License
/** * Called to initialize the editor with its content. Here everything is * done, which is dependent of the IConfigurationProvider. *//* w ww .j a v a 2 s . c om*/ @Override protected void initializeGraphicalViewer() { super.initializeGraphicalViewer(); // register Actions IFeatureProvider featureProvider = getConfigurationProvider().getDiagramTypeProvider().getFeatureProvider(); if (featureProvider != null) { IPrintFeature pf = featureProvider.getPrintFeature(); if (pf != null) { registerAction(new PrintGraphicalViewerAction(getConfigurationProvider(), getConfigurationProvider().getWorkbenchPart(), pf)); } } buildNewObjectActions(); // this will cause the ActionBarContributor to refresh with the // new actions (there is no specific refresh-action). if (getEditorSite().getActionBarContributor() != null) getEditorSite().getActionBarContributor().setActiveEditor(this); // setting ContextMenuProvider ContextMenuProvider contextMenuProvider = createContextMenuProvider(); if (contextMenuProvider != null) { getGraphicalViewer().setContextMenu(contextMenuProvider); // the registration allows an extension of the context-menu by other // plugins if (shouldRegisterContextMenu()) { getSite().registerContextMenu(contextMenuProvider, getGraphicalViewer()); } } // set contents getGraphicalViewer().setEditPartFactory(getConfigurationProvider().getEditPartFactory()); getGraphicalViewer().setContents(getConfigurationProvider().getDiagram()); // set preference-store for palette PaletteViewer paletteViewer = getEditDomain().getPaletteViewer(); if (paletteViewer != null) { IPreferenceStore store = GraphitiUIPlugin.getDefault().getPreferenceStore(); paletteViewer.setPaletteViewerPreferences(new DefaultPaletteViewerPreferences(store)); // Refresh the PaletteViewer // This can be achieved by firing a font-change-event from the // IPreferenceStore. // It would be nicer, if the PaletteViewer would have some kind of // refresh()-method directly. store.firePropertyChangeEvent(PaletteViewerPreferences.PREFERENCE_FONT, null, null); } getGraphicalViewer().getControl().addMouseMoveListener(new MouseMoveListener() { @Override public void mouseMove(MouseEvent e) { setMouseLocation(e.x, e.y); } }); getGraphicalViewer().addDropTargetListener( (TransferDropTargetListener) new ObjectsTransferDropTargetListener(getGraphicalViewer())); getGraphicalViewer() .addDropTargetListener(new GFTemplateTransferDropTargetListener(getGraphicalViewer(), this)); }
From source file:org.eclipse.rap.ui.interactiondesign.layout.LayoutRegistry.java
License:Open Source License
/** * Saves the new <code>Layout</code> id in a * <code>ScopedPreferenceStore</code>. * /*from ww w .j a v a 2 s . co m*/ * @param id the new <code>Layout</code> id to save. */ public void saveLayoutId(final String id) { IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); preferenceStore.putValue(SAVED_LAYOUT_KEY, id); preferenceStore.firePropertyChangeEvent(SAVED_LAYOUT_KEY, "", id); }
From source file:org.eclipse.ui.editors.tests.ChainedPreferenceStoreTest.java
License:Open Source License
/** * [implementation] ChainedPreferenceStore * https://bugs.eclipse.org/bugs/show_bug.cgi?id=69419 *//*from ww w . j av a 2 s . com*/ public void testChainedStore0() { 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, VALUE, DEFAULT_DEFAULT_VALUE); // simulated removal with newValue != null chainedStore.removePropertyChangeListener(fPropertyChangeListener); assertEquals(1, fEvents.size()); PropertyChangeEvent event = (PropertyChangeEvent) fEvents.get(0); assertEquals(chainedStore, event.getSource()); assertEquals(PROPERTY, event.getProperty()); assertEquals(VALUE, event.getOldValue()); assertEquals(DEFAULT_VALUE, event.getNewValue()); }
From source file:org.eclipse.ui.editors.tests.ChainedPreferenceStoreTest.java
License:Open Source License
/** * Assertion failed in ChainedPreferenceStore.handlePropertyChangeEvent(..) * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827 */// w w w . j ava 2 s . c om public void testChainedStore1() { IPreferenceStore store1 = new PreferenceStore(); IPreferenceStore store2 = new PreferenceStore(); IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 }); chainedStore.addPropertyChangeListener(fPropertyChangeListener); store1.firePropertyChangeEvent(PROPERTY, VALUE, DEFAULT_DEFAULT_VALUE); // simulated removal 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(VALUE, event.getOldValue()); assertEquals(DEFAULT_DEFAULT_VALUE, event.getNewValue()); }