Example usage for org.eclipse.jface.preference JFacePreferences setPreferenceStore

List of usage examples for org.eclipse.jface.preference JFacePreferences setPreferenceStore

Introduction

In this page you can find the example usage for org.eclipse.jface.preference JFacePreferences setPreferenceStore.

Prototype

public static void setPreferenceStore(IPreferenceStore store) 

Source Link

Document

Set the preference store for the receiver.

Usage

From source file:org.eclipse.ui.internal.JFaceUtil.java

License:Open Source License

/**
 * Adds a preference listener so that the JFace preference store is initialized
 * as soon as the workbench preference store becomes available.
 *///from  ww  w  .  j  a v a2  s . c  om
public static void initializeJFacePreferences() {
    IEclipsePreferences rootNode = (IEclipsePreferences) Platform.getPreferencesService().getRootNode()
            .node(InstanceScope.SCOPE);
    final String workbenchName = WorkbenchPlugin.getDefault().getBundle().getSymbolicName();

    rootNode.addNodeChangeListener(new IEclipsePreferences.INodeChangeListener() {
        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
         */
        public void added(NodeChangeEvent event) {
            if (!event.getChild().name().equals(workbenchName)) {
                return;
            }
            ((IEclipsePreferences) event.getChild())
                    .addPreferenceChangeListener(PlatformUIPreferenceListener.getSingleton());

        }

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
         */
        public void removed(NodeChangeEvent event) {
            // Nothing to do here

        }
    });

    JFacePreferences.setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore());
}

From source file:org.jlibrary.client.JLibraryWorkbenchWindowAdvisor.java

License:Open Source License

private void initPreferences() {

    IPreferenceStore store = PlatformUI.getPreferenceStore();
    JFacePreferences.setPreferenceStore(store);
    JLibraryPreferences.newInstance();
}

From source file:org.pwsafe.passwordsafeswt.util.UserPreferences.java

License:Open Source License

/**
 * Loads preferences from a properties file.
 * // w  w  w  . j  a  va 2 s.  c o m
 * @throws IOException if there are problems loading the preferences file
 */
private void loadPreferences() throws IOException {
    // props = new Properties();
    String userFile = getPreferencesFilename();
    if (log.isDebugEnabled())
        log.debug("Loading from [" + userFile + "]");
    File prefsFile = new File(userFile);
    if (!prefsFile.exists()) {
        File prefsDir = new File(System.getProperty("user.home") + File.separator + PROPS_DIR);
        if (!prefsDir.exists()) {
            prefsDir.mkdir();
        }
    }

    prefStore = new PreferenceStore(getPreferencesFilename());
    JFacePreferences.setPreferenceStore(prefStore);
    new JpwPreferenceInitializer().initializeDefaultPreferences();

    if (prefsFile.exists()) {
        prefStore.load();
    }
    // TODO: Check what happens if no file exists?

    if (log.isDebugEnabled())
        log.debug("Loaded " + prefStore + " preference settings from file");
}