List of usage examples for org.eclipse.jface.preference PreferenceDialog setSelectedNode
public void setSelectedNode(String pageId)
From source file:com.microsoft.azuretools.core.utils.PluginUtil.java
License:Open Source License
/** * Method opens property dialog with only desired property page. * * @param nodeId//from w w w. j ava2 s . co m * : Node ID of property page * @param nodeLbl * : Property page name * @param classObj * : Class object of property page * @return */ public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) { int retVal = Window.CANCEL; // value corresponding to cancel // Node creation try { PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString()); nodePropPg.setPage((IPreferencePage) classObj); nodePropPg.getPage().setTitle(nodeLbl); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodePropPg); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(nodeLbl); dialog.create(); /* * If showing storage accounts preference page, don't show * properties for title as its common repository. */ String dlgTitle = ""; if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) { dlgTitle = nodeLbl; } else { dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName()); } dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(PluginUtil.getParentShell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e); } return retVal; }
From source file:com.microsoftopentechnologies.wacommon.utils.PluginUtil.java
License:Open Source License
/** * Method opens property dialog with only desired property page. * //from w ww . ja va2s . c o m * @param nodeId * : Node ID of property page * @param nodeLbl * : Property page name * @param classObj * : Class object of property page * @return */ public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) { int retVal = Window.CANCEL; // value corresponding to cancel // Node creation try { PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString()); nodePropPg.setPage((IPreferencePage) classObj); nodePropPg.getPage().setTitle(nodeLbl); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodePropPg); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(nodeLbl); dialog.create(); /* * If showing storage accounts preference page, don't show * properties for title as its common repository. */ String dlgTitle = ""; if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) { dlgTitle = nodeLbl; } else { dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName()); } dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e); } return retVal; }
From source file:com.motorola.studio.android.common.utilities.ui.WidgetsUtil.java
License:Apache License
/** * Opens the Eclipse preferences dialog and selects the page of the given * id.//www. j a va2 s . co m * * @param shell The shell. * @param selectedNode The preferences page to selec. * @return <code>true</code> if the Wizard dialog has constant OK, * <code>false</code> otherwise . */ public static boolean runPreferencePage(Shell shell, String selectedNode) { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); PreferenceDialog dialog = new PreferenceDialog(shell, manager); dialog.setSelectedNode(selectedNode); WidgetsUtil.centerDialog(shell); return dialog.open() == PreferenceDialog.OK; }
From source file:com.persistent.util.WAEclipseHelper.java
License:Open Source License
/** * Method creates tree structure of azure property pages. and opens property * dialog with desired property page selected & active. * /*from w ww . j ava 2 s .com*/ * @param windowsAzureRole * : worker role * @param pageToDisplay * : property page Id which should be active after opening dialog * @param tabToSelect : In case pageToDisplay is Server Configuration page then * provide tab which should be selected. * @return integer */ public static int openRolePropertyDialog(WindowsAzureRole windowsAzureRole, String pageToDisplay, String tabToSelect) { int retVal = Window.CANCEL; // value corresponding to cancel try { // Node creation PreferenceNode nodeGeneral = new PreferenceNode(Messages.cmhIdGeneral, Messages.cmhLblGeneral, null, WARGeneral.class.toString()); nodeGeneral.setPage(new WARGeneral()); nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral); PreferenceNode nodeCache = new PreferenceNode(Messages.cmhIdCach, Messages.cmhLblCach, null, WARCaching.class.toString()); nodeCache.setPage(new WARCaching()); nodeCache.getPage().setTitle(Messages.cmhLblCach); PreferenceNode nodeCert = new PreferenceNode(Messages.cmhIdCert, Messages.cmhLblCert, null, WARCertificates.class.toString()); nodeCert.setPage(new WARCertificates()); nodeCert.getPage().setTitle(Messages.cmhLblCert); PreferenceNode nodeCmpnts = new PreferenceNode(Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null, WARComponents.class.toString()); nodeCmpnts.setPage(new WARComponents()); nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts); PreferenceNode nodeDebugging = new PreferenceNode(Messages.cmhIdDbg, Messages.cmhLblDbg, null, WARDebugging.class.toString()); nodeDebugging.setPage(new WARDebugging()); nodeDebugging.getPage().setTitle(Messages.cmhLblDbg); PreferenceNode nodeEndPts = new PreferenceNode(Messages.cmhIdEndPts, Messages.cmhLblEndPts, null, WAREndpoints.class.toString()); nodeEndPts.setPage(new WAREndpoints()); nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts); PreferenceNode nodeEnvVars = new PreferenceNode(Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null, WAREnvVars.class.toString()); nodeEnvVars.setPage(new WAREnvVars()); nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars); PreferenceNode nodeLdBlnc = new PreferenceNode(Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null, WARLoadBalance.class.toString()); nodeLdBlnc.setPage(new WARLoadBalance()); nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc); PreferenceNode nodeLclStg = new PreferenceNode(Messages.cmhIdLclStg, Messages.cmhLblLclStg, null, WARLocalStorage.class.toString()); nodeLclStg.setPage(new WARLocalStorage()); nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg); PreferenceNode nodeSrvCnfg = new PreferenceNode(Messages.cmhIdSrvCnfg, Messages.cmhLblSrvCnfg, null, WAServerConfiguration.class.toString()); nodeSrvCnfg.setPage(new WAServerConfiguration(tabToSelect)); nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg); PreferenceNode nodeSslOff = new PreferenceNode(Messages.cmhIdSsl, Messages.cmhLblSsl, null, WASSLOffloading.class.toString()); nodeSslOff.setPage(new WASSLOffloading()); nodeSslOff.getPage().setTitle(Messages.cmhLblSsl); /* * Tree structure creation. Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeGeneral.add(nodeCache); nodeGeneral.add(nodeCert); nodeGeneral.add(nodeCmpnts); nodeGeneral.add(nodeDebugging); nodeGeneral.add(nodeEndPts); nodeGeneral.add(nodeEnvVars); nodeGeneral.add(nodeLdBlnc); nodeGeneral.add(nodeLclStg); nodeGeneral.add(nodeSrvCnfg); nodeGeneral.add(nodeSslOff); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeGeneral); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, windowsAzureRole.getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception ex) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex); } return retVal; }
From source file:com.persistent.util.WAEclipseHelper.java
License:Open Source License
/** * Method creates tree structure of azure deployment project property pages. * and opens property dialog with desired property page selected & active. * /*from ww w. ja v a2s. c om*/ * @param pageToDisplay * : property page Id which should be active after opening dialog * @return integer */ public static int openWAProjectPropertyDialog(String pageToDisplay) { int retVal = Window.CANCEL; // value corresponding to cancel // Node creation try { PreferenceNode nodeWindowsAzure = new PreferenceNode(Messages.cmhIdWinAz, Messages.cmhLblWinAz, null, WAWinAzurePropertyPage.class.toString()); nodeWindowsAzure.setPage(new WAWinAzurePropertyPage()); nodeWindowsAzure.getPage().setTitle(Messages.cmhLblWinAz); PreferenceNode nodeRemoteAcess = new PreferenceNode(Messages.cmhIdRmtAces, Messages.cmhLblRmtAces, null, WARemoteAccessPropertyPage.class.toString()); nodeRemoteAcess.setPage(new WARemoteAccessPropertyPage()); nodeRemoteAcess.getPage().setTitle(Messages.cmhLblRmtAces); PreferenceNode nodeRoles = new PreferenceNode(Messages.cmhIdRoles, Messages.cmhLblRoles, null, WARolesPropertyPage.class.toString()); nodeRoles.setPage(new WARolesPropertyPage()); nodeRoles.getPage().setTitle(Messages.cmhLblRoles); PreferenceNode nodeSubscriptions = new PreferenceNode(Messages.cmhIdCrdntls, Messages.cmhLblSubscrpt, null, SubscriptionPropertyPage.class.toString()); nodeSubscriptions.setPage(new SubscriptionPropertyPage()); nodeSubscriptions.getPage().setTitle(Messages.cmhLblSubscrpt); /* * Tree structure creation. Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeWindowsAzure.add(nodeRemoteAcess); nodeWindowsAzure.add(nodeRoles); nodeWindowsAzure.add(nodeSubscriptions); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeWindowsAzure); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e); } return retVal; }
From source file:org.eclipse.andmore.android.common.utilities.ui.WidgetsUtil.java
License:Apache License
/** * Opens the Eclipse preferences dialog and selects the page of the given * id.//from w w w . j a v a2 s .c o m * * @param shell * The shell. * @param selectedNode * The preferences page to selec. * @return <code>true</code> if the Wizard dialog has constant OK, * <code>false</code> otherwise . */ public static boolean runPreferencePage(Shell shell, String selectedNode) { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); PreferenceDialog dialog = new PreferenceDialog(shell, manager); dialog.setSelectedNode(selectedNode); WidgetsUtil.centerDialog(shell); return dialog.open() == Window.OK; }
From source file:org.eclipse.pde.internal.ui.correction.ConfigureTargetPlatformResolution.java
License:Open Source License
@Override public void run(IMarker marker) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); PreferenceDialog preferenceDialog = new PreferenceDialog(shell, PlatformUI.getWorkbench().getPreferenceManager()); preferenceDialog.setSelectedNode(TargetPlatformPreferencePage.PAGE_ID); preferenceDialog.open();//from ww w .j ava2 s. c o m }
From source file:org.eclipse.ui.tests.preferences.ZoomAndPreferencesFontTest.java
License:Open Source License
@After public void restoreAndCheckDefaults() { PreferenceDialog dialog = new PreferenceDialog(Display.getCurrent().getActiveShell(), PlatformUI.getWorkbench().getPreferenceManager()); dialog.setSelectedNode("org.eclipse.ui.preferencePages.ColorsAndFonts"); dialog.setBlockOnOpen(false);//from www . ja v a 2 s .co m dialog.open(); ColorsAndFontsPreferencePage page = (ColorsAndFontsPreferencePage) dialog.getSelectedPage(); page.performDefaults(); page.performOk(); dialog.close(); // make sure we land on a clean state Assert.assertEquals(initialFontHeight, text.getFont().getFontData()[0].getHeight()); editor.close(false); }
From source file:org.jboss.ide.eclipse.as.wtp.ui.composites.AbstractJREComposite.java
License:Open Source License
protected boolean showPreferencePage(String pageId) { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode node = manager.find(pageId); PreferenceManager manager2 = new PreferenceManager(); manager2.addToRoot(node);//from ww w . ja va2 s . com PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2); dialog.setSelectedNode(pageId); dialog.create(); dialog.setMessage(node.getLabelText()); return (dialog.open() == Window.OK); }
From source file:org.jcryptool.crypto.xml.ui.dialogs.MissingPreferenceDialog.java
License:Open Source License
/** * Opens the preferences with the node selected given by the target parameter. If the preferences * are closed by clicking on the OK button this dialog will disappear and the needed preference * values will be verified again.//from w w w .j ava 2 s . co m */ private void openPreferencePage() { IWorkbench workbench = PlatformUI.getWorkbench(); PreferenceManager pm = workbench.getPreferenceManager(); if (pm != null) { PreferenceDialog d = new PreferenceDialog(workbench.getActiveWorkbenchWindow().getShell(), pm); d.setSelectedNode(target); d.create(); if (d.open() == Window.OK) { close(); } } }