Search in sources :

Example 6 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.

the class EditorsPlugin method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    if (PlatformUI.isWorkbenchRunning()) {
        fThemeListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty()))
                    EditorsPluginPreferenceInitializer.setThemeBasedPreferences(getPreferenceStore(), true);
            }
        };
        PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener);
    }
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent)

Example 7 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.

the class ChainedPreferenceStoreTest method testChainedStore1.

/**
 * Assertion failed in ChainedPreferenceStore.handlePropertyChangeEvent(..)
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827
 */
@Test
public void testChainedStore1() {
    IPreferenceStore store1 = new PreferenceStore();
    IPreferenceStore store2 = new PreferenceStore();
    IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
    chainedStore.addPropertyChangeListener(fPropertyChangeListener);
    // simulated removal with newValue != null
    store1.firePropertyChangeEvent(PROPERTY, VALUE, DEFAULT_DEFAULT_VALUE);
    chainedStore.removePropertyChangeListener(fPropertyChangeListener);
    assertEquals(1, fEvents.size());
    PropertyChangeEvent event = fEvents.get(0);
    assertEquals(store1, event.getSource());
    assertEquals(PROPERTY, event.getProperty());
    assertEquals(VALUE, event.getOldValue());
    assertEquals(DEFAULT_DEFAULT_VALUE, event.getNewValue());
}
Also used : PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) PreferenceStore(org.eclipse.jface.preference.PreferenceStore) Test(org.junit.Test)

Example 8 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.

the class ChainedPreferenceStoreTest method testChainedStore0.

/**
 * [implementation] ChainedPreferenceStore
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=69419
 */
@Test
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);
    // simulated removal with newValue != null
    store1.firePropertyChangeEvent(PROPERTY, VALUE, DEFAULT_DEFAULT_VALUE);
    chainedStore.removePropertyChangeListener(fPropertyChangeListener);
    assertEquals(1, fEvents.size());
    PropertyChangeEvent event = fEvents.get(0);
    assertEquals(chainedStore, event.getSource());
    assertEquals(PROPERTY, event.getProperty());
    assertEquals(VALUE, event.getOldValue());
    assertEquals(DEFAULT_VALUE, event.getNewValue());
}
Also used : PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) PreferenceStore(org.eclipse.jface.preference.PreferenceStore) Test(org.junit.Test)

Example 9 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.

the class TemplateStore method startListeningForPreferenceChanges.

/**
 * Starts listening for property changes on the preference store. If the configured preference
 * key changes, the template store is {@link #load() reloaded}. Call
 * {@link #stopListeningForPreferenceChanges()} to remove any listener and stop the
 * auto-updating behavior.
 *
 * @since 3.2
 */
public final void startListeningForPreferenceChanges() {
    if (fPropertyListener == null) {
        fPropertyListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                /*
					 * Don't load if we are in the process of saving ourselves. We are in sync anyway after the
					 * save operation, and clients may trigger reloading by listening to preference store
					 * updates.
					 */
                if (!fIgnorePreferenceStoreChanges && fKey.equals(event.getProperty()))
                    try {
                        load();
                    } catch (IOException x) {
                        handleException(x);
                    }
            }
        };
        fPreferenceStore.addPropertyChangeListener(fPropertyListener);
    }
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOException(java.io.IOException)

Example 10 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method install.

/**
 * Installs this decoration support on the given preference store. It assumes
 * that this support has completely been configured.
 *
 * @param store the preference store
 */
public void install(IPreferenceStore store) {
    fPreferenceStore = store;
    if (fPreferenceStore != null) {
        fPropertyChangeListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                handlePreferenceStoreChanged(event);
            }
        };
        fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
    }
    updateTextDecorations();
    updateOverviewDecorations();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent)

Aggregations

PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)31 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)27 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)8 GridData (org.eclipse.swt.layout.GridData)8 Composite (org.eclipse.swt.widgets.Composite)7 GridLayout (org.eclipse.swt.layout.GridLayout)6 ColorSelector (org.eclipse.jface.preference.ColorSelector)5 Label (org.eclipse.swt.widgets.Label)5 PreferenceStore (org.eclipse.jface.preference.PreferenceStore)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 ChainedPreferenceStore (org.eclipse.ui.texteditor.ChainedPreferenceStore)4 Test (org.junit.Test)4 ISelection (org.eclipse.jface.viewers.ISelection)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Text (org.eclipse.swt.widgets.Text)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 MissingResourceException (java.util.MissingResourceException)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2