List of usage examples for org.eclipse.jface.preference PreferenceDialog getShell
@Override
public Shell getShell()
From source file:cc.warlock.rcp.util.RCPUtil.java
License:Open Source License
public static int openPreferences(String pageId) { GameView inFocus = GameView.getGameViewInFocus(); IWarlockClient client = inFocus == null ? null : inFocus.getClient(); WarlockClientAdaptable clientAdapter = new WarlockClientAdaptable(client); PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(Display.getDefault().getActiveShell(), clientAdapter, pageId, null, null); if (dialog == null) return 0; dialog.getShell().setText("Warlock Preferences"); dialog.getTreeViewer().expandToLevel(2); return dialog.open(); }
From source file:com.gigaspaces.azure.propertypage.SubscriptionPropertyPage.java
License:Open Source License
protected int openPropertyDialog(PublishData pd) { int retVal = Window.CANCEL; try {/*from ww w .ja va 2 s . c o m*/ // Create the nodes IPreferenceNode subscriptionGeneral = new PreferenceNode(Messages.credentialsPageId, Messages.credentialsNodeText, null, CredentialsPropertyPage.class.toString()); CredentialsPropertyPage.setPublishData(null); if (pd != null) { CredentialsPropertyPage.setPublishData(pd); } SelectionProvider selProvider = new SelectionProvider(); PropertyDialogAction action = new PropertyDialogAction(new IShellProvider() { @Override public Shell getShell() { return new Shell(); } }, selProvider); StructuredSelection selection = new StructuredSelection(subscriptionGeneral); selProvider.setSelection(selection); PreferenceDialog dlg = action.createDialog(); String dlgTitle = String.format(Messages.credentialsDlgTitle); dlg.getShell().setText(dlgTitle); retVal = dlg.open(); } catch (Exception ex) { } return retVal; }
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/*w w w . j av a2 s. com*/ * : 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 w w . ja v a 2 s . co 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.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 av a2 s . co m * @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 w ww.j a v a 2s. 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:com.siteview.mde.internal.runtime.spy.sections.ActiveHelpSection.java
License:Open Source License
public void build(ScrolledForm form, SpyFormToolkit toolkit, ExecutionEvent event) { this.toolkit = toolkit; final Shell shell = HandlerUtil.getActiveShell(event); Object object = shell.getData(); if (object == null) return;/* ww w. j a va 2 s . c o m*/ StringBuffer helpBuffer = new StringBuffer(); // process help // TODO we need to make this cleaner... help processing is complicated atm if (object instanceof PreferenceDialog) { PreferenceDialog dialog = (PreferenceDialog) object; IPreferencePage page = (IPreferencePage) dialog.getSelectedPage(); processHelp(page.getControl().getShell(), helpBuffer); processChildren(page.getControl(), helpBuffer); } else if (object instanceof Dialog) { Dialog dialog = (Dialog) object; processChildren(dialog.getShell(), helpBuffer); } else { helpBuffer.append(processControlHelp(event, toolkit)); } if (helpBuffer != null && helpBuffer.length() > 0) { Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); section.setText(MDERuntimeMessages.SpyDialog_activeHelpSection_title); section.clientVerticalSpacing = 9; FormText text = toolkit.createFormText(section, true); section.setClient(text); TableWrapData td = new TableWrapData(); td.align = TableWrapData.FILL; td.grabHorizontal = true; section.setLayoutData(td); Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_CONTEXTID_OBJ); text.setImage("contextid", image); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer(); buffer.append("<form>"); //$NON-NLS-1$ buffer.append("<p>"); //$NON-NLS-1$ buffer.append(MDERuntimeMessages.SpyDialog_activeHelpSection_desc); buffer.append("</p>"); //$NON-NLS-1$ buffer.append(helpBuffer.toString()); buffer.append("</form>"); //$NON-NLS-1$ String content = buffer.toString().replaceAll("&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ text.setText(content, true, false); } }
From source file:eu.geclipse.ui.problems.ShowPreferencePageSolver.java
License:Open Source License
public void solve() { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), this.preferencePageID, null, null);//from www . jav a 2 s .c o m Shell dialogShell = dialog.getShell(); Shell currentShell = dialogShell.getDisplay().getActiveShell(); Shell parentShell = currentShell; // Create the chain of shells to be closed for making the preference // dialog the top level component List<Shell> toClose = new ArrayList<Shell>(); while ((parentShell != null) && (parentShell != dialogShell)) { toClose.add(parentShell); Composite parent = parentShell.getParent(); if (parent instanceof Shell) { parentShell = (Shell) parent; } else { parentShell = null; } } // If the preference dialog is part of the chain close // all shells "above" the dialog if (parentShell == dialogShell) { for (Shell shell : toClose) { shell.close(); } } dialogShell.forceActive(); dialog.open(); }
From source file:org.apache.directory.studio.connection.ui.actions.PropertiesAction.java
License:Apache License
/** * {@inheritDoc}/*from w w w . ja v a 2s . com*/ */ public void run() { IAdaptable element = null; String pageId = null; String title = null; if (getSelectedConnections().length == 1) { element = getSelectedConnections()[0]; pageId = ConnectionUIPlugin.getDefault().getPluginProperties() .getString("Prop_ConnectionPropertyPage_id"); //$NON-NLS-1$ title = getSelectedConnections()[0].getName(); } if (element != null) { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), element, pageId, null, null); if (dialog != null) { title = Utils.shorten(title, 30); } dialog.getShell().setText(NLS.bind(Messages.getString("PropertiesAction.PropertiesFor"), new String[] //$NON-NLS-1$ { title })); dialog.open(); } }
From source file:org.apache.directory.studio.ldapbrowser.common.actions.OpenQuickSearchAction.java
License:Apache License
/** * {@inheritDoc}//from w w w . j av a2 s.co m */ public void run() { IBrowserConnection browserConnection = getBrowserConnection(); if (browserConnection != null) { // Getting the current quick search IQuickSearch quickSearch = widget.getQuickSearch(); // Creating a new quick search with the currently selected entry // if there's no current quick search or quick search isn't selected if ((quickSearch == null) || !isQuickSearchSelected()) { // Setting a default search base on Root DSE IEntry searchBase = browserConnection.getRootDSE(); // Getting the selected entry IEntry selectedEntry = getSelectedEntry(); if (selectedEntry != null) { // Setting the selected entry as search base searchBase = selectedEntry; } // Creating a new quick search quickSearch = new QuickSearch(searchBase, browserConnection); widget.setQuickSearch(quickSearch); } // Creating and opening the dialog PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), quickSearch, BrowserCommonConstants.PROP_SEARCH, null, null); dialog.getShell().setText(NLS.bind(Messages.getString("PropertiesAction.PropertiesForX"), //$NON-NLS-1$ Utils.shorten(quickSearch.getName(), 30))); if (dialog.open() == PreferenceDialog.OK) { // Performing the quick search if it has not been performed before // (ie. the quick search was not modified at in the dialog) if (quickSearch.getSearchResults() == null) { new StudioBrowserJob(new SearchRunnable(new ISearch[] { quickSearch })).execute(); } } } }