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

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

Introduction

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

Prototype

protected PreferencePage() 

Source Link

Document

Creates a new preference page with an empty title and no image.

Usage

From source file:net.sourceforge.eclipsetrader.trading.wizards.systems.TradingSystemSettingsDialog.java

License:Open Source License

public TradingSystemSettingsDialog(TradingSystem system, Shell parentShell) {
    super(parentShell, new PreferenceManager());
    this.system = system;

    baseParameters = new BaseParametersPage() {
        public void createControl(Composite parent) {
            super.createControl(parent);
            setAccount(TradingSystemSettingsDialog.this.system.getAccount());
            setSecurity(TradingSystemSettingsDialog.this.system.getSecurity());
            setMaxExposure(TradingSystemSettingsDialog.this.system.getMaxExposure());
            setMaxAmount(TradingSystemSettingsDialog.this.system.getMaxAmount());
            setMinAmount(TradingSystemSettingsDialog.this.system.getMinAmount());
        }// w w  w. jav a 2  s .  c om

        public void performFinish() {
            TradingSystemSettingsDialog.this.system.setAccount(baseParameters.getAccount());
            TradingSystemSettingsDialog.this.system.setSecurity(baseParameters.getSecurity());
            TradingSystemSettingsDialog.this.system.setMaxExposure(baseParameters.getMaxExposure());
            TradingSystemSettingsDialog.this.system.setMaxAmount(baseParameters.getMaxAmount());
            TradingSystemSettingsDialog.this.system.setMinAmount(baseParameters.getMinAmount());
        }
    };
    baseParameters.setPageComplete(true);

    getPreferenceManager().addToRoot(new PreferenceNode("base", new CommonDialogPage(baseParameters) {
        protected Control createContents(Composite parent) {
            Control control = super.createContents(parent);
            return control;
        }
    }));

    IConfigurationElement[] members = TradingPlugin.getTradingSystemPluginPreferencePages(system.getPluginId());
    try {
        for (int i = 0; i < members.length; i++) {
            final TradingSystemPluginPreferencePage preferencePage = (TradingSystemPluginPreferencePage) members[i]
                    .createExecutableExtension("class");
            preferencePage.init(system.getSecurity(), system.getParameters());
            PreferencePage page = new PreferencePage() {
                protected Control createContents(Composite parent) {
                    noDefaultAndApplyButton();

                    Control control = preferencePage.createContents(parent);
                    return control;
                }

                public boolean performOk() {
                    preferencePage.performOk();
                    TradingSystemSettingsDialog.this.system.getParameters()
                            .putAll(preferencePage.getParameters());
                    return super.performOk();
                }
            };
            page.setTitle(members[i].getAttribute("name"));
            getPreferenceManager().addToRoot(new PreferenceNode("plugin" + String.valueOf(i), page));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}