List of usage examples for org.eclipse.jface.preference PreferenceManager addToRoot
public void addToRoot(IPreferenceNode node)
From source file:org.eclipse.ui.tests.preferences.PreferencesDialogTest.java
License:Open Source License
/** * To test sorting elements we need to access internal class * FilteredPreferenceDialog. It is available from the IWorkbench#getPreferenceManager(), * but using it would bring all workbench pages into this test which could * impact sorting./*from w ww.j a va 2s. c om*/ */ public void testWithSorting() { PreferenceManager manager = new PreferenceManager(); IPreferencePage page1 = new SamplePreferencePage("Zzz", "First Sample"); IPreferenceNode node1 = new PreferenceNode("abc", page1); manager.addToRoot(node1); IPreferencePage page2 = new SamplePreferencePage("Aaa", "Second Sample"); IPreferenceNode node2 = new PreferenceNode("www", page2); manager.addToRoot(node2); FilteredPreferenceDialog dialog = null; try { dialog = new FilteredPreferenceDialog(shell, manager) { }; dialog.setBlockOnOpen(false); // check that we can create a dialog with custom preference manager dialog.open(); // The page with title "Aaa" should be the first one despite being // added second assertEquals(page2, dialog.getCurrentPage()); // Also, "Aaa" should be the first tree item TreeItem item = dialog.getTreeViewer().getTree().getItem(0); assertEquals("Aaa", item.getText()); } finally { if (dialog != null) dialog.close(); } }
From source file:org.eclipse.virgo.ide.runtime.internal.ui.ServerRuntimeComposite.java
License:Open Source License
protected boolean showPreferencePage() { String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage") .findSubNode(id);/*from w ww.j ava 2s .c o m*/ PreferenceManager manager2 = new PreferenceManager(); manager2.addToRoot(node); PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2); dialog.create(); return dialog.open() == Window.OK; }
From source file:org.eclipse.wst.ide.remote.ui.internal.view.MonitorView.java
License:Open Source License
protected boolean showPreferencePage() { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode node = manager.find("org.eclipse.debug.ui.DebugPreferencePage") .findSubNode("org.eclipse.wst.ide.remote.preferencePage"); PreferenceManager manager2 = new PreferenceManager(); manager2.addToRoot(node); final PreferenceDialog dialog = new PreferenceDialog(getSite().getShell(), manager2); final boolean[] result = new boolean[] { false }; BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { public void run() { dialog.create();/*from ww w .j av a 2 s .c om*/ if (dialog.open() == Window.OK) result[0] = true; } }); return result[0]; }
From source file:org.eclipse.wst.internet.monitor.ui.internal.view.MonitorView.java
License:Open Source License
protected boolean showPreferencePage() { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode node = manager.find("org.eclipse.debug.ui.DebugPreferencePage") .findSubNode("org.eclipse.wst.internet.monitor.preferencePage"); PreferenceManager manager2 = new PreferenceManager(); manager2.addToRoot(node); final PreferenceDialog dialog = new PreferenceDialog(getSite().getShell(), manager2); final boolean[] result = new boolean[] { false }; BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { public void run() { dialog.create();/*from w w w. j a v a 2 s . c o m*/ if (dialog.open() == Window.OK) result[0] = true; } }); return result[0]; }
From source file:org.eclipse.wst.xsl.internal.debug.ui.XSLDebugUIPlugin.java
License:Open Source License
/** * Convenience method for opening a given preference page. * //from w w w . j av a 2 s . c o m * @param id * the id of the preference page * @param page * the preference page to show */ public static void showPreferencePage(String id, IPreferencePage page) { final IPreferenceNode targetNode = new PreferenceNode(id, page); PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); final PreferenceDialog dialog = new PreferenceDialog(XSLDebugUIPlugin.getActiveWorkbenchShell(), manager); final boolean[] result = new boolean[] { false }; BusyIndicator.showWhile(XSLDebugUIPlugin.getStandardDisplay(), new Runnable() { public void run() { dialog.create(); dialog.setMessage(targetNode.getLabelText()); result[0] = (dialog.open() == Window.OK); } }); }
From source file:org.eclipsetrader.repository.hibernate.internal.ui.RepositoryPropertiesHandler.java
License:Open Source License
protected void openPropertiesDialog(final Shell shell, final IAdaptable adaptableElement) { PreferenceManager pageManager = new PreferenceManager(); pageManager.addToRoot(new PreferenceNode("general", new RepositoryProperties())); for (Object nodeObj : pageManager.getElements(PreferenceManager.PRE_ORDER)) { IPreferenceNode node = (IPreferenceNode) nodeObj; if (node.getPage() instanceof PropertyPage) { ((PropertyPage) node.getPage()).setElement(adaptableElement); }/*from w w w. j a va2 s . com*/ } FilteredPreferenceDialog dlg = new FilteredPreferenceDialog(shell, pageManager) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); RepositoryDefinition repository = (RepositoryDefinition) adaptableElement .getAdapter(RepositoryDefinition.class); newShell.setText("Properties for " + repository.getLabel()); } }; dlg.setHelpAvailable(false); if (dlg.open() == Window.OK && !shell.isDisposed()) { Activator.saveRepositoryDefinitions(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (MessageDialog.openQuestion(shell, "EclipseTrader", "The workbench must be restarted for the changes to take effect.\r\nRestart the workbench now ?")) { PlatformUI.getWorkbench().restart(); } } }); } }
From source file:org.eclipsetrader.ui.internal.ats.monitor.SettingsAction.java
License:Open Source License
@Override @SuppressWarnings("restriction") public void run() { final IAdaptable adaptableElement = getWrappedElement(view); PreferenceManager pageManager = new PreferenceManager(); pageManager.addToRoot(new PreferenceNode("columns", new ColumnsProperties())); //$NON-NLS-1$ for (Object nodeObj : pageManager.getElements(PreferenceManager.PRE_ORDER)) { IPreferenceNode node = (IPreferenceNode) nodeObj; if (node.getPage() instanceof PropertyPage) { ((PropertyPage) node.getPage()).setElement(adaptableElement); }/*from www . j a v a 2s.co m*/ } FilteredPreferenceDialog dlg = new FilteredPreferenceDialog(shell, pageManager) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.SettingsAction_SettingsFor + view.getPartName()); } }; dlg.setHelpAvailable(false); dlg.open(); }
From source file:org.eclipsetrader.ui.internal.views.SettingsAction.java
License:Open Source License
@Override @SuppressWarnings("restriction") public void run() { final IAdaptable adaptableElement = getWrappedElement(view); PreferenceManager pageManager = new PreferenceManager(); pageManager.addToRoot(new PriorityPreferenceNode("general", new GeneralProperties(), -1)); pageManager.addToRoot(new PreferenceNode("columns", new ColumnsProperties())); for (Object nodeObj : pageManager.getElements(PreferenceManager.PRE_ORDER)) { IPreferenceNode node = (IPreferenceNode) nodeObj; if (node.getPage() instanceof PropertyPage) { ((PropertyPage) node.getPage()).setElement(adaptableElement); }/*from w ww. j a v a 2s.co m*/ } FilteredPreferenceDialog dlg = new FilteredPreferenceDialog(shell, pageManager) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Settings for " + view.getPartName()); } }; dlg.setHelpAvailable(false); dlg.open(); }
From source file:org.eclipsetrader.ui.internal.views.TickersSettingsAction.java
License:Open Source License
@Override @SuppressWarnings("restriction") public void run() { final IAdaptable adaptableElement = getWrappedElement(view); PreferenceManager pageManager = new PreferenceManager(); pageManager.addToRoot(new PreferenceNode("securities", new SecurityProperties())); for (Object nodeObj : pageManager.getElements(PreferenceManager.PRE_ORDER)) { IPreferenceNode node = (IPreferenceNode) nodeObj; if (node.getPage() instanceof PropertyPage) { ((PropertyPage) node.getPage()).setElement(adaptableElement); }/* w w w . j ava2 s. c om*/ } FilteredPreferenceDialog dlg = new FilteredPreferenceDialog(shell, pageManager) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Settings for " + view.getPartName()); } }; dlg.setHelpAvailable(false); dlg.open(); }
From source file:org.entirej.framework.plugin.preferences.EntirejConnectionPreferencePage.java
License:Apache License
public static void openPage(IProject project) { EntirejConnectionPreferencePage page = new EntirejConnectionPreferencePage(); final IPreferenceNode targetNode = new PreferenceNode(page.getPageId(), page); PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); page.setElement(project);/*from w w w. ja v a 2s .c o m*/ page.setTitle("Connection Settings"); final PreferenceDialog dialog = new PreferenceDialog(Display.getCurrent().getActiveShell(), manager); BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { public void run() { dialog.create(); dialog.setMessage(targetNode.getLabelText()); dialog.open(); } }); }