List of usage examples for org.eclipse.jface.preference PreferenceDialog PreferenceDialog
public PreferenceDialog(Shell parentShell, PreferenceManager manager)
From source file:org.pwsafe.passwordsafeswt.action.OptionsAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.Action#run() *//*from w w w . j ava2 s. c om*/ @Override public void run() { final PasswordSafeJFace app = PasswordSafeJFace.getApp(); // Create the preference manager PreferenceManager mgr = new PreferenceManager(); // Create the nodes PreferenceNode displayPrefs = new PreferenceNode("display", Messages.getString("OptionsAction.DisplayNode"), //$NON-NLS-1$//$NON-NLS-2$ null, DisplayPreferences.class.getName()); PreferenceNode securityPrefs = new PreferenceNode("security", //$NON-NLS-1$ Messages.getString("OptionsAction.SecurityNode"), null, SecurityPreferences.class //$NON-NLS-1$ .getName()); PreferenceNode passwordPolicyPrefs = new PreferenceNode("policy", //$NON-NLS-1$ Messages.getString("OptionsAction.PolicyNode"), null, //$NON-NLS-1$ PasswordPolicyPreferences.class.getName()); PreferenceNode usernamePrefs = new PreferenceNode("username", //$NON-NLS-1$ Messages.getString("OptionsAction.UserNameNode"), null, UsernamePreferences.class //$NON-NLS-1$ .getName()); PreferenceNode miscPrefs = new PreferenceNode("misc", Messages.getString("OptionsAction.MiscNode"), null, //$NON-NLS-1$//$NON-NLS-2$ MiscPreferences.class.getName()); // Add the nodes mgr.addToRoot(displayPrefs); mgr.addToRoot(securityPrefs); mgr.addToRoot(passwordPolicyPrefs); mgr.addToRoot(usernamePrefs); mgr.addToRoot(miscPrefs); // Create the preferences dialog PreferenceDialog dlg = new PreferenceDialog(app.getShell(), mgr); Window.setDefaultImage( IOUtils.getImage(PasswordSafeJFace.class, "/org/pwsafe/passwordsafeswt/images/clogo.gif")); //$NON-NLS-1$ // Set the preference store dlg.setPreferenceStore(JFacePreferences.getPreferenceStore()); // Open the dialog dlg.open(); try { if (JFacePreferences.getPreferenceStore().needsSaving()) { // Be Paranoid - Save the preferences now UserPreferences.getInstance().savePreferences(); } } catch (IOException e) { e.printStackTrace(); } }
From source file:org.reap.internal.core.persistence.PersistenceManager.java
License:Open Source License
private void showConfigDialog(final PersistenceConfig config) { final Display display = Activator.getDefault().getWorkbench().getDisplay(); display.syncExec(new Runnable() { public void run() { final PreferenceManager manager = new PreferenceManager(); final PreferenceDialog dialog = new PreferenceDialog(new Shell(display), manager); final PreferencePage page = new PersistenceConfigPage(config); final IPreferenceNode node = new PreferenceNode("Datenbank", page); manager.addToRoot(node);//from w ww. j a va 2 s . co m configDialogState = dialog.open(); } }); }
From source file:org.rubypeople.rdt.internal.ui.preferences.PreferencePageSupport.java
License:Open Source License
/** * Open the given preference page in a preference dialog. * @param shell The shell to open on/*from w w w . ja v a 2 s .c om*/ * @param id The id of the preference page as in the plugin.xml * @param page An instance of the page. Note that such a page should also set its own * title to correctly show up. * @return Returns <code>true</code> if the user ended the page by pressing OK. */ public static boolean showPreferencePage(Shell shell, String id, IPreferencePage page) { final IPreferenceNode targetNode = new PreferenceNode(id, page); PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); final PreferenceDialog dialog = new PreferenceDialog(shell, manager); final boolean[] result = new boolean[] { false }; BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { public void run() { dialog.create(); dialog.setMessage(targetNode.getLabelText()); result[0] = (dialog.open() == Window.OK); } }); return result[0]; }
From source file:org.springsource.ide.eclipse.gradle.ui.JavaHomeSection.java
License:Open Source License
public void createContents(Composite page) { GridDataFactory grabHorizontal = GridDataFactory.fillDefaults().grab(true, false); Label label = new Label(page, SWT.NONE); label.setText("Java Home (requires Gradle 1.0.RC1 or later)"); //Alternative 1 Composite composite = new Composite(page, SWT.NONE); GridLayout layout = new GridLayout(3, false); composite.setLayout(layout);/*from w ww . j a va 2 s . com*/ grabHorizontal.applyTo(composite); defaultButton = new Button(composite, SWT.RADIO); defaultButton.setText("Use Gradle wrapper's default"); GridDataFactory span = GridDataFactory.fillDefaults().span(3, 1); span.applyTo(defaultButton); //Alternative 2: choose a workspace JRE customHomeButton = new Button(composite, SWT.RADIO); customHomeButton.setText("Workspace JRE: "); customHomeButton.setToolTipText("Use a specific Java installation configured in this workspace"); customJRECombo = new Combo(composite, SWT.DROP_DOWN + SWT.READ_ONLY); refreshJREs(); browseHomeButton = new Button(composite, SWT.PUSH); browseHomeButton.setText("Configure JREs"); customHomeButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { enableDisableWidgets(); } public void widgetDefaultSelected(SelectionEvent e) { } }); browseHomeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @SuppressWarnings("restriction") IPreferencePage page = new org.eclipse.jdt.internal.debug.ui.jres.JREsPreferencePage(); PreferenceManager mgr = new PreferenceManager(); IPreferenceNode node = new PreferenceNode("1", page); mgr.addToRoot(node); PreferenceDialog dialog = new PreferenceDialog(owner.getShell(), mgr); dialog.create(); dialog.setMessage(page.getTitle()); dialog.open(); refreshJREs(); // System.out.println("kdvolder"); // PreferenceDialog w = PreferencesUtil.createPreferenceDialogOn(owner.getShell(), JRE_PREF_PAGE_ID, new String[] {JRE_PREF_PAGE_ID, GradlePreferencesPage.ID}, null); // w.setBlockOnOpen(true); // w.open(); // //Eclipse only allows one preferences dialog to be open at the same time // //We only get here after user closed dialog, so we must reopen it on the Gradle preferences page. // PreferencesUtil.createPreferenceDialogOn(null, GradlePreferencesPage.ID, new String[] {JRE_PREF_PAGE_ID, GradlePreferencesPage.ID}, null).open(); } }); customJRECombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validator.refresh(); } }); grabHorizontal.applyTo(customJRECombo); setJavaHomeInPage(getJavaHome()); enableDisableWidgets(); }
From source file:org.springsource.ide.eclipse.gradle.ui.JavaHomeSectionImpl.java
License:Open Source License
/** * This does more or less what a PageSection implementation of createContents should do (i.e. * create the widgets on the page)./*from www. j ava2 s . c o m*/ * <p> * However, it does not fill the widget contents with the contents of the preferences because * this implementation may not yet be connected to a preferences store yet when the widgets * are being created. It is up to the caller/client to make sure a to call copyFrom method * to (re)initialise the widget contents at an appropriate time. * * @param page */ public void createWidgets(Composite page) { GridDataFactory grabHor = GridDataFactory.fillDefaults().grab(true, false); Group group = null; if (!border) { Label label = new Label(page, SWT.NONE); label.setText(TITLE); } else { group = new Group(page, SWT.BORDER); group.setText(TITLE); } //Alternative 1 Composite composite = border ? group : new Composite(page, SWT.NONE); GridLayout layout = new GridLayout(3, false); composite.setLayout(layout); grabHor.applyTo(composite); defaultButton = new Button(composite, SWT.RADIO); defaultButton.setText("Use Gradle wrapper's default"); GridDataFactory span = GridDataFactory.fillDefaults().span(3, 1); span.applyTo(defaultButton); //Alternative 2: choose a workspace JRE customHomeButton = new Button(composite, SWT.RADIO); customHomeButton.setText("Workspace JRE: "); customHomeButton.setToolTipText("Use a specific Java installation configured in this workspace"); customJRECombo = new Combo(composite, SWT.DROP_DOWN + SWT.READ_ONLY); configureJREsButton = new Button(composite, SWT.PUSH); configureJREsButton.setText("Configure JREs"); grabHor.applyTo(configureJREsButton); grabHor.applyTo(customJRECombo); //Alternative 3: choose an execution environment customExecutionEnvButton = new Button(composite, SWT.RADIO); customExecutionEnvButton.setText("Execution Environment"); customExecutionEnvButton.setToolTipText("Specify a JRE indirectly via an execution environment"); customExecutionEnvCombo = new Combo(composite, SWT.DROP_DOWN + SWT.READ_ONLY); configureExecEnvsButton = new Button(composite, SWT.PUSH); configureExecEnvsButton.setText("Configure EEs"); grabHor.applyTo(configureExecEnvsButton); grabHor.applyTo(customExecutionEnvCombo); refreshJREs(); customHomeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { enableDisableWidgets(customHomeButton, customJRECombo, configureJREsButton); doRefresh(); } }); customExecutionEnvButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { enableDisableWidgets(customExecutionEnvButton, customExecutionEnvCombo, configureExecEnvsButton); doRefresh(); } }); configureJREsButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @SuppressWarnings("restriction") IPreferencePage page = new org.eclipse.jdt.internal.debug.ui.jres.JREsPreferencePage(); PreferenceManager mgr = new PreferenceManager(); IPreferenceNode node = new PreferenceNode("1", page); mgr.addToRoot(node); PreferenceDialog dialog = new PreferenceDialog(owner.getShell(), mgr); dialog.create(); dialog.setMessage(page.getTitle()); dialog.open(); refreshJREs(); } }); configureExecEnvsButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @SuppressWarnings("restriction") IPreferencePage page = new org.eclipse.jdt.internal.debug.ui.jres.ExecutionEnvironmentsPreferencePage(); PreferenceManager mgr = new PreferenceManager(); IPreferenceNode node = new PreferenceNode("1", page); mgr.addToRoot(node); PreferenceDialog dialog = new PreferenceDialog(owner.getShell(), mgr); dialog.create(); dialog.setMessage(page.getTitle()); dialog.open(); refreshJREs(); } }); customJRECombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { doRefresh(); } }); customExecutionEnvCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { doRefresh(); } }); grabHor.applyTo(customJRECombo); }
From source file:org.swtchart.ext.InteractiveChart.java
License:Apache License
/** * Opens the properties dialog./*from w w w.j a v a 2 s . c o m*/ */ private void openPropertiesDialog() { PreferenceManager manager = new PreferenceManager(); final String chartTitle = "Chart"; PreferenceNode chartNode = new PreferenceNode(chartTitle); chartNode.setPage(new ChartPage(this, resources, chartTitle)); manager.addToRoot(chartNode); final String legendTitle = "Legend"; PreferenceNode legendNode = new PreferenceNode(legendTitle); legendNode.setPage(new LegendPage(this, resources, legendTitle)); manager.addTo(chartTitle, legendNode); final String xAxisTitle = "X Axis"; PreferenceNode xAxisNode = new PreferenceNode(xAxisTitle); xAxisNode.setPage(new AxisPage(this, resources, Direction.X, xAxisTitle)); manager.addTo(chartTitle, xAxisNode); final String gridTitle = "Grid"; PreferenceNode xGridNode = new PreferenceNode(gridTitle); xGridNode.setPage(new GridPage(this, resources, Direction.X, gridTitle)); manager.addTo(chartTitle + "." + xAxisTitle, xGridNode); final String tickTitle = "Tick"; PreferenceNode xTickNode = new PreferenceNode(tickTitle); xTickNode.setPage(new AxisTickPage(this, resources, Direction.X, tickTitle)); manager.addTo(chartTitle + "." + xAxisTitle, xTickNode); final String yAxisTitle = "Y Axis"; PreferenceNode yAxisNode = new PreferenceNode(yAxisTitle); yAxisNode.setPage(new AxisPage(this, resources, Direction.Y, yAxisTitle)); manager.addTo(chartTitle, yAxisNode); PreferenceNode yGridNode = new PreferenceNode(gridTitle); yGridNode.setPage(new GridPage(this, resources, Direction.Y, gridTitle)); manager.addTo(chartTitle + "." + yAxisTitle, yGridNode); PreferenceNode yTickNode = new PreferenceNode(tickTitle); yTickNode.setPage(new AxisTickPage(this, resources, Direction.Y, tickTitle)); manager.addTo(chartTitle + "." + yAxisTitle, yTickNode); final String seriesTitle = "Series"; PreferenceNode plotNode = new PreferenceNode(seriesTitle); plotNode.setPage(new SeriesPage(this, resources, seriesTitle)); manager.addTo(chartTitle, plotNode); final String labelTitle = "Label"; PreferenceNode labelNode = new PreferenceNode(labelTitle); labelNode.setPage(new SeriesLabelPage(this, resources, labelTitle)); manager.addTo(chartTitle + "." + seriesTitle, labelNode); PreferenceDialog dialog = new PreferenceDialog(getShell(), manager); dialog.create(); dialog.getShell().setText("Properties"); dialog.getTreeViewer().expandAll(); dialog.open(); }
From source file:org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService.java
License:Open Source License
@Override public void addRuntimeServer(TargetExecComposite targetExecComposite, JobJvmComposite jobComposite) { Combo targetCombo = null;//from w w w . j a v a 2 s .c o m IPreferenceStore store = ESBRunContainerPlugin.getDefault().getPreferenceStore(); String url = store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_HOST); String port = store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_PORT); String rt = ESB_RUNTIME_ITEM + " (" + url + ":" + port + ")"; if (JobJvmComposite.class == jobComposite.getClass()) { // Update Tab SE try { Control control = ((Composite) jobComposite.getChildren()[0]).getChildren()[0]; if (control instanceof StyledText) { StyledText styled = (StyledText) control; styled.setText("Please select target execution environment"); targetCombo = new Combo((Composite) jobComposite.getChildren()[0], SWT.BORDER | SWT.READ_ONLY); GridData data = new GridData(GridData.FILL_BOTH); data.horizontalIndent = 5; targetCombo.setLayoutData(data); targetCombo.add("Default", 0); targetCombo.add(rt, 1); this.index = targetCombo.getSelectionIndex(); targetCombo.select(index == -1 ? 0 : index); } } catch (Exception ex) { } } else { // Update EE tab try { Control control = ((Composite) jobComposite.getChildren()[0]).getChildren()[0]; if (control instanceof Combo) { targetCombo = (Combo) control; targetCombo.add(rt); this.index = targetCombo.getSelectionIndex(); } } catch (Exception ex) { } } if (targetCombo != null) { if (RunProcessPlugin.getDefault() .getRunProcessContextManager() instanceof RunContainerProcessContextManager) { targetCombo.select(targetCombo.indexOf(rt)); } else { targetCombo.select(index); } targetCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (((Combo) e.getSource()).getText().startsWith(ESB_RUNTIME_ITEM)) { // check if server setting is validated. IPreferenceStore store = ESBRunContainerPlugin.getDefault().getPreferenceStore(); String host = store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_HOST); File containerDir = new File( store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_LOCATION)); if (containerDir.exists() || !(host.equals("localhost") || host.equals("127.0.0.1"))) { defaultContextManager = RunProcessPlugin.getDefault().getRunProcessContextManager(); esbProcessContext = defaultContextManager.getActiveContext(); if (runtimeContextManager == null) { runtimeContextManager = new RunContainerProcessContextManager(); } // reset context manager and active process RunProcessPlugin.getDefault().setRunProcessContextManager(runtimeContextManager); RunProcessPlugin.getDefault().getRunProcessContextManager() .setActiveProcess(esbProcessContext.getProcess()); ProcessManager.getInstance() .setProcessContext(runtimeContextManager.getActiveContext()); } else { boolean openPrefs = MessageDialog.openConfirm(jobComposite.getShell(), "Runtime Server Setting", "Runtime Server setting is not complete, please update runtime server informations before running."); if (openPrefs) { PreferenceDialog d = new PreferenceDialog(jobComposite.getShell(), PlatformUI.getWorkbench().getPreferenceManager()); d.setSelectedNode(RunContainerPreferencePage.ID); d.open(); } // ((Combo) e.getSource()).select(index); } } else if (defaultContextManager != null) { RunProcessPlugin.getDefault().setRunProcessContextManager(defaultContextManager); } } }); } }
From source file:org.talend.designer.esb.runcontainer.ui.actions.OpenRuntimePrefsAction.java
License:Open Source License
@Override public void run() { PreferenceDialog dlg = new PreferenceDialog(Display.getDefault().getActiveShell(), PlatformUI.getWorkbench().getPreferenceManager()); dlg.setSelectedNode(RunContainerPreferencePage.ID); dlg.open();/*from w w w. j a v a 2 s. c om*/ }
From source file:org.xwalk.ide.eclipse.xdt.wizards.export.ExportProjectWizard.java
License:Apache License
private void showQuickPreferenceDialog() { IPreferencePage page = new settingPage(); PreferenceManager mgr = new PreferenceManager('/'); IPreferenceNode node = new PreferenceNode("1", page); mgr.addToRoot(node);/*from w ww . j a v a2s .c om*/ PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr); dialog.create(); dialog.setMessage(page.getTitle()); dialog.open(); }
From source file:org2.eclipse.php.internal.debug.ui.preferences.phps.ShowPHPsPreferences.java
License:Open Source License
protected void showPreferencePage(String id, IPreferencePage page) { final IPreferenceNode targetNode = new PreferenceNode(id, page); PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode);//from w w w .ja v a 2 s . c o m final PreferenceDialog dialog = new PreferenceDialog(PHPDebugEPLPlugin.getActiveWorkbenchShell(), manager); final boolean[] result = new boolean[] { false }; BusyIndicator.showWhile(PHPDebugEPLPlugin.getStandardDisplay(), new Runnable() { public void run() { dialog.create(); dialog.setMessage(targetNode.getLabelText()); result[0] = (dialog.open() == Window.OK); } }); }