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

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

Introduction

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

Prototype

public void setPreferenceStore(IPreferenceStore store) 

Source Link

Document

Sets the preference store for this preference page.

Usage

From source file:at.nucle.e4.plugin.preferences.core.internal.registry.PreferenceRegistry.java

License:Open Source License

private void setPreferenceStore(PreferencePage page, String bundleId) {
    PreferenceScopeContext store = preferenceScopeRegistry.findPreferenceStore(bundleId);
    page.setPreferenceStore(store);

}

From source file:com.nsn.squirrel.preferences.internal.E4PreferenceRegistry.java

License:Open Source License

private void setPreferenceStore(String bundleId, PreferencePage page) {

    // Affect preference store to this page if this is a
    // PreferencePage, else, must manage it internally
    // Set the issue#1 on github :
    // https://github.com/opcoach/e4Preferences/issues/1
    // And manage the extensions of IP
    initialisePreferenceStoreProviders();
    IPreferenceStore store = null;//  ww  w  .  j a  va2s  . c  o m
    // Get the preference store according to policy.
    Object data = psProviders.get(bundleId);
    if (data != null) {
        if (data instanceof IPreferenceStore)
            store = (IPreferenceStore) data;
        else if (data instanceof IPreferenceStoreProvider)
            store = ((IPreferenceStoreProvider) data).getPreferenceStore();
        else if (data instanceof String)
            store = (IPreferenceStore) context.get((String) data);
    } else {
        // Default behavior : create a preference store for this bundle and
        // remember of it
        store = new ScopedPreferenceStore(InstanceScope.INSTANCE, bundleId);
        psProviders.put(bundleId, store);
    }
    if (store != null)
        page.setPreferenceStore(store);
    else {
        logger.warn("Unable to set the preferenceStore for page " + page.getTitle() + " defined in bundle "
                + bundleId);
    }
}

From source file:com.opcoach.e4.preferences.internal.E4PreferenceRegistry.java

License:Open Source License

private void setPreferenceStore(String bundleId, PreferencePage page) {
    // Affect preference store to this page if this is a
    // PreferencePage, else, must manage it internally
    // Set the issue#1 on github :
    // https://github.com/opcoach/e4Preferences/issues/1
    // And manage the extensions of IP
    initialisePreferenceStoreProviders();

    IPreferenceStore store = null;//from w  w  w  . j  a  v  a  2s.  c  om

    // Get the preference store according to policy.
    Object data = psProviders.get(bundleId);
    if (data != null) {
        if (data instanceof IPreferenceStore)
            store = (IPreferenceStore) data;
        else if (data instanceof IPreferenceStoreProvider)
            store = ((IPreferenceStoreProvider) data).getPreferenceStore();
        else if (data instanceof String)
            store = (IPreferenceStore) context.get((String) data);

    } else {
        // Default behavior : create a preference store for this bundle and remember of it
        store = new ScopedPreferenceStore(InstanceScope.INSTANCE, bundleId);
        psProviders.put(bundleId, store);
    }

    if (store != null)
        page.setPreferenceStore(store);
    else {
        logger.warn("Unable to set the preferenceStore for page " + page.getTitle() + " defined in bundle "
                + bundleId);
    }

}

From source file:net.mldonkey.g2gui.view.pref.Preferences.java

License:Open Source License

/**
 * @param preferenceStore where to store the values at
 *//*  ww  w . ja va2 s . c o m*/
public Preferences(PreferenceStore preferenceStore) {
    this.preferenceStore = preferenceStore;

    /* main page */
    PreferencePage g2gui = new G2GuiPref("G2Gui", FieldEditorPreferencePage.GRID);
    g2gui.setPreferenceStore(preferenceStore);

    PreferenceNode g2GuiRootNode = new PreferenceNode("G2gui", g2gui);

    /* display page */
    if (PreferenceLoader.loadBoolean("advancedMode")) {
        PreferencePage preferencePage = new G2GuiDisplay("Display", FieldEditorPreferencePage.GRID);
        preferencePage.setPreferenceStore(preferenceStore);

        PreferenceNode g2guiDisplayNode = new PreferenceNode("Display", preferencePage);

        preferencePage = new G2GuiDisplayConsole("Console", FieldEditorPreferencePage.GRID);
        preferencePage.setPreferenceStore(preferenceStore);
        g2guiDisplayNode.add(new PreferenceNode("Console", preferencePage));

        preferencePage = new G2GuiDisplayDownloads("Downloads", FieldEditorPreferencePage.GRID);
        preferencePage.setPreferenceStore(preferenceStore);
        g2guiDisplayNode.add(new PreferenceNode("Downloads", preferencePage));

        preferencePage = new G2GuiDisplayGraphs("Graphs", FieldEditorPreferencePage.GRID);
        preferencePage.setPreferenceStore(preferenceStore);
        g2guiDisplayNode.add(new PreferenceNode("Graphs", preferencePage));

        g2GuiRootNode.add(g2guiDisplayNode);
    }

    /* advanced page */
    PreferencePage preferencePage = new G2GuiAdvanced("Advanced", FieldEditorPreferencePage.GRID);
    preferencePage.setPreferenceStore(preferenceStore);
    g2GuiRootNode.add(new PreferenceNode("Advanced", preferencePage));

    /* windows registry page */
    String g2guiexe = System.getProperty("user.dir") + System.getProperty("file.separator") + "g2gui.exe";

    if (VersionCheck.isWin32() && new File(g2guiexe).exists()) {
        preferencePage = new G2GuiWinReg("Windows Registry", FieldEditorPreferencePage.NONE);
        preferencePage.setPreferenceStore(preferenceStore);
        g2GuiRootNode.add(new PreferenceNode("Windows Registry", preferencePage));
    }

    /* add all of this to the root node */
    addToRoot(g2GuiRootNode);
}

From source file:net.sourceforge.eclipsetrader.trading.wizards.accounts.AccountSettingsDialog.java

License:Open Source License

public AccountSettingsDialog(Account account, Shell parentShell) {
    super(parentShell, new PreferenceManager());
    this.account = account;

    generalPage = new GeneralPage(account);
    getPreferenceManager().addToRoot(new PreferenceNode("general", generalPage));

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(CorePlugin.ACCOUNT_PROVIDERS_EXTENSION_POINT);
    if (extensionPoint != null) {
        IConfigurationElement[] members = extensionPoint.getConfigurationElements();
        for (int i = 0; i < members.length; i++) {
            if (members[i].getAttribute("id").equals(account.getPluginId())) //$NON-NLS-1$
            {//w w  w  . j  a v a 2  s.c o m
                members = members[i].getChildren("preferencePage");
                for (int ii = 0; ii < members.length; ii++) {
                    try {
                        PreferencePage preferencePage = (PreferencePage) members[ii]
                                .createExecutableExtension("class");
                        if (members[ii].getAttribute("name") != null)
                            preferencePage.setTitle(members[ii].getAttribute("name"));
                        preferencePage.setPreferenceStore(account.getPreferenceStore());
                        getPreferenceManager()
                                .addToRoot(new PreferenceNode("page" + String.valueOf(ii), preferencePage));
                    } catch (Exception e) {
                        CorePlugin.logException(e);
                    }
                }
                break;
            }
        }
    }
}

From source file:net.sourceforge.eclipsetrader.trading.wizards.accounts.PluginSelectionPage.java

License:Open Source License

private void setPages() {
    NewAccountWizard wizard = (NewAccountWizard) getWizard();
    String pluginId = getPluginId();

    java.util.List pages = wizard.getAdditionalPages();
    for (Iterator iter = pages.iterator(); iter.hasNext();)
        ((IWizardPage) iter.next()).dispose();
    pages.clear();//from w w  w.j  av  a 2s .co m

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(CorePlugin.ACCOUNT_PROVIDERS_EXTENSION_POINT);
    if (extensionPoint != null) {
        IConfigurationElement[] members = extensionPoint.getConfigurationElements();
        for (int i = 0; i < members.length; i++) {
            if (members[i].getAttribute("id").equals(pluginId)) //$NON-NLS-1$
            {
                members = members[i].getChildren("preferencePage");
                for (int ii = 0; ii < members.length; ii++) {
                    try {
                        PreferencePage preferencePage = (PreferencePage) members[ii]
                                .createExecutableExtension("class");
                        WizardPageAdapter page = new WizardPageAdapter(preferencePage);
                        if (members[ii].getAttribute("name") != null)
                            page.setTitle(members[ii].getAttribute("name"));
                        if (members[ii].getAttribute("description") != null)
                            page.setDescription(members[ii].getAttribute("description"));
                        preferencePage.setPreferenceStore(wizard.getPreferenceStore());
                        wizard.getAdditionalPages().add(page);
                    } catch (Exception e) {
                        CorePlugin.logException(e);
                    }
                }
                break;
            }
        }
    }
}