List of usage examples for org.eclipse.jface.preference PreferenceManager PreferenceManager
public PreferenceManager()
From source file:kieker.develop.rl.ui.preferences.AbstractFieldEditorOverlayPage.java
License:Apache License
/** * Show a single preference pages./*from ww w .j a va2 s. c o m*/ * * @param id * - the preference page identification * @param page * - the preference page */ protected void showPreferencePage(final String id, final IPreferencePage page) { final IPreferenceNode targetNode = new PreferenceNode(id, page); final PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); final PreferenceDialog dialog = new PreferenceDialog(this.getControl().getShell(), manager); BusyIndicator.showWhile(this.getControl().getDisplay(), new Runnable() { @Override public void run() { dialog.create(); dialog.setMessage(targetNode.getLabelText()); dialog.open(); } }); }
From source file:net.heartsome.license.LicenseManageDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { if (isShowBack) { Button backBtn = createButton(parent, IDialogConstants.BACK_ID, Messages.getString("license.OfflineActiveDialog.backBtn"), false); backBtn.addSelectionListener(new SelectionAdapter() { @Override/*www . j a v a 2 s .com*/ public void widgetSelected(SelectionEvent e) { setReturnCode(OK); Point p = getShell().getLocation(); close(); ActiveMethodDialog dialog = new ActiveMethodDialog(getShell(), p); dialog.open(); } }); } Button button = createButton(parent, 11, Messages.getString("license.LicenseManageDialog.netconnection"), false); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); PreferenceManager mgr = window.getWorkbench().getPreferenceManager(); IPreferenceNode node = null; @SuppressWarnings("unchecked") List<IPreferenceNode> lstNodes = mgr.getElements(PreferenceManager.PRE_ORDER); for (IPreferenceNode n : lstNodes) { if (n.getId().equals("org.eclipse.ui.net.proxy_preference_page_context")) { node = n; } } if (node == null) { return; } mgr = new PreferenceManager(); mgr.addToRoot(node); HsPreferenceDialog dlg = new HsPreferenceDialog(window.getShell(), mgr); dlg.create(); final List<Image> imageList = new ArrayList<Image>(); dlg.getTreeViewer().setLabelProvider(new PreferenceLabelProvider() { Image image = null; public Image getImage(Object element) { String id = ((IPreferenceNode) element).getId(); if ("org.eclipse.ui.net.proxy_preference_page_context".equals(id)) { // image = Activator.getImageDescriptor("icons/network.png").createImage(); imageList.add(image); return image; } else { return null; } } }); dlg.open(); for (Image img : imageList) { if (img != null && !img.isDisposed()) { img.dispose(); } } imageList.clear(); } }); boolean isDefault = false; if (type == Constants.STATE_NOT_ACTIVATED || type == Constants.STATE_INVALID || type == Constants.STATE_EXPIRED || type == Constants.EXCEPTION_INT14 || type == Constants.EXCEPTION_INT15 || type == Constants.EXCEPTION_INT1 || type == Constants.EXCEPTION_INT2 || type == Constants.EXCEPTION_INT3 || type == Constants.EXCEPTION_INT4) { createButton(parent, IDialogConstants.OK_ID, Messages.getString("license.LicenseManageDialog.activeBtn"), true); isDefault = true; } createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("license.LicenseManageDialog.exitBtn"), !isDefault).setFocus(); }
From source file:net.openchrom.xxd.processor.supplier.tracecompare.ui.swt.EnhancedTraceCompareEditor.java
License:Open Source License
private Button createSettingsButton(Composite parent, GridData gridData) { Button button = new Button(parent, SWT.PUSH); button.setText("Settings"); button.setImage(ApplicationImageFactory.getInstance().getImage(IApplicationImage.IMAGE_CONFIGURE, IApplicationImage.SIZE_16x16)); button.setLayoutData(gridData);// w ww . ja v a 2 s . c o m button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPreferencePage preferencePage = new PreferencePage(); preferencePage.setTitle("TraceCompare Preferences"); PreferenceManager preferenceManager = new PreferenceManager(); preferenceManager.addToRoot(new PreferenceNode("1", preferencePage)); // PreferenceDialog preferenceDialog = new PreferenceDialog(Display.getDefault().getActiveShell(), preferenceManager); preferenceDialog.create(); preferenceDialog.setMessage("Settings"); if (preferenceDialog.open() == PreferenceDialog.OK) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Settings", "The settings have been updated."); } } }); return button; }
From source file:net.sourceforge.eclipsetrader.ats.ui.tradingsystem.properties.TradingSystemPropertiesDialog.java
License:Open Source License
public TradingSystemPropertiesDialog(Shell parentShell, TradingSystem tradingSystem) { super(parentShell, new PreferenceManager()); getPreferenceManager().addToRoot(new PreferenceNode("general", new GeneralPage(tradingSystem))); }
From source file:net.sourceforge.eclipsetrader.charts.dialogs.ChartSettingsDialog.java
License:Open Source License
public ChartSettingsDialog(Chart chart, Shell parentShell) { super(parentShell, new PreferenceManager()); this.chart = chart; generalPage = new GeneralPage(chart); PreferenceNode generalNode = new PreferenceNode("general", generalPage); //$NON-NLS-1$ getPreferenceManager().addToRoot(generalNode); for (int r = 0; r < chart.getRows().size(); r++) { ChartRow row = (ChartRow) chart.getRows().get(r); for (int t = 0; t < row.getTabs().size(); t++) { ChartTab tab = (ChartTab) row.getTabs().get(t); PreferenceNode tabNode = new PreferenceNode("tab" + t, new TabsPage(tab)); //$NON-NLS-1$ getPreferenceManager().addToRoot(tabNode); for (int i = 0; i < tab.getIndicators().size(); i++) { ChartIndicator indicator = (ChartIndicator) tab.getIndicators().get(i); Settings settings = new Settings(); for (Iterator iter = indicator.getParameters().keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); settings.set(key, (String) indicator.getParameters().get(key)); }/*from ww w. j ava 2 s. c om*/ IConfigurationElement plugin = getIndicatorPlugin(indicator.getPluginId()); IConfigurationElement[] members = plugin.getChildren("preferencePage"); //$NON-NLS-1$ if (members.length != 0) { PreferenceNode indicatorNode = null; IConfigurationElement item = members[0]; try { Object obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ indicatorNode = new PreferenceNode("indicator", page); //$NON-NLS-1$ tabNode.add(indicatorNode); } for (int p = 1; p < members.length; p++) { obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ PreferenceNode node = new PreferenceNode("prefs" + p, page); //$NON-NLS-1$ indicatorNode.add(node); } } } catch (Exception e) { e.printStackTrace(); } } } } } }
From source file:net.sourceforge.eclipsetrader.charts.dialogs.IndicatorSettingsDialog.java
License:Open Source License
public IndicatorSettingsDialog(ChartIndicator indicator, Shell parentShell) { super(parentShell, new PreferenceManager()); Settings settings = new Settings(); for (Iterator iter = indicator.getParameters().keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); settings.set(key, (String) indicator.getParameters().get(key)); }/*w ww .j a v a2 s . co m*/ IConfigurationElement plugin = ChartsPlugin.getIndicatorPlugin(indicator.getPluginId()); IConfigurationElement[] members = plugin.getChildren("preferencePage"); //$NON-NLS-1$ if (members.length != 0) { IConfigurationElement item = members[0]; try { Object obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("indicator", page)); //$NON-NLS-1$ } for (int p = 1; p < members.length; p++) { obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("prefs" + p, page)); //$NON-NLS-1$ } } } catch (Exception e) { e.printStackTrace(); } } }
From source file:net.sourceforge.eclipsetrader.charts.dialogs.ObjectSettingsDialog.java
License:Open Source License
public ObjectSettingsDialog(ChartObject indicator, Shell parentShell) { super(parentShell, new PreferenceManager()); this.object = indicator; Settings settings = new Settings(); for (Iterator iter = indicator.getParameters().keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); settings.set(key, (String) indicator.getParameters().get(key)); }/*from www . ja v a 2 s. c o m*/ IConfigurationElement plugin = ChartsPlugin.getObjectPlugin(indicator.getPluginId()); IConfigurationElement[] members = plugin.getChildren("preferencePage"); //$NON-NLS-1$ if (members.length != 0) { IConfigurationElement item = members[0]; try { Object obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof ObjectPluginPreferencePage) { ((ObjectPluginPreferencePage) obj).setSettings(settings); ObjectPage page = new ObjectPage(indicator, (ObjectPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("indicator", page)); //$NON-NLS-1$ } for (int p = 1; p < members.length; p++) { obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof ObjectPluginPreferencePage) { ((ObjectPluginPreferencePage) obj).setSettings(settings); ObjectPage page = new ObjectPage(indicator, (ObjectPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("prefs" + p, page)); //$NON-NLS-1$ } } } catch (Exception e) { e.printStackTrace(); } } }
From source file:net.sourceforge.eclipsetrader.core.ui.preferences.SecurityPropertiesDialog.java
License:Open Source License
public SecurityPropertiesDialog(Security security, Shell parentShell) { super(parentShell, new PreferenceManager()); this.security = security; getPreferenceManager().addToRoot(new PreferenceNode("general", new GeneralPage())); //$NON-NLS-1$ PreferenceNode node = new PreferenceNode("feed", new PreferencePage("Feeds") { //$NON-NLS-1$ //$NON-NLS-2$ protected Control createContents(Composite parent) { noDefaultAndApplyButton();/* w w w .j a v a 2 s .co m*/ return new Composite(parent, SWT.NONE); } }); getPreferenceManager().addToRoot(node); node.add(new PreferenceNode("quote", new QuoteFeedPage())); //$NON-NLS-1$ node.add(new PreferenceNode("level2", new Level2FeedPage())); //$NON-NLS-1$ node.add(new PreferenceNode("history", new HistoryFeedPage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("trading", new TradeSourcePage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("intraday", new DataCollectorPage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("dividends", new DividendsPage(security))); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("splits", new SplitsPage(security))); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("notes", new CommentsPage())); //$NON-NLS-1$ }
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$ {// ww w.j a v a 2 s. co 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.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()); }// www . j av a 2 s.co m 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(); } }