List of usage examples for org.eclipse.jface.preference PreferenceDialog open
public int open()
From source file:net.rim.ejde.internal.signing.CodeSignMarkerResolution.java
License:Open Source License
public void run(IMarker marker) { try {// w w w . j ava 2 s . c o m String msg = marker.getAttribute(IMarker.MESSAGE).toString(); String keyLabel = VMUtils.convertCodeSignErrorMsgToPreferenceLabel(msg); PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault().getActiveShell(), WarningsPrefsPage.ID, null, null); WarningsPrefsPage page = (WarningsPrefsPage) dialog.getSelectedPage(); page.setSelection(keyLabel, true); dialog.open(); } catch (CoreException e) { e.printStackTrace(); } }
From source file:net.sf.jmoney.actions.PreferencesAction.java
License:Open Source License
/** * The action has been activated. The argument of the * method represents the 'real' action sitting * in the workbench UI./*w ww .j av a 2s. c om*/ * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { PreferenceManager manager = workbenchWindow.getWorkbench().getPreferenceManager(); PreferenceDialog preferenceDialog = new PreferenceDialog(workbenchWindow.getShell(), manager); preferenceDialog.open(); }
From source file:net.sf.smbt.ui.lemur.ui.views.LemurView.java
License:LGPL
private void makeActions() { jzmlOpenAction = new Action() { public void run() { FileDialog fileSelectionDialog = new FileDialog(Display.getDefault().getActiveShell()); String jzmlFilePath = fileSelectionDialog.open(); if (jzmlFilePath != null && !jzmlFilePath.equals("")) { LemurLiveApp lemurLiveApp = JzmlUtils.INSTANCE.loadLemurLiveAppFromXML(jzmlFilePath); if (lemurLiveApp != null && lemurLiveApp.getElements().size() > 0) { JZJazzInterface jzJazzInterface = (JZJazzInterface) lemurLiveApp.getElements().get(0); JzmuiControllerUtils.INSTANCE.initConnections(lemurLiveApp); JzmuiControllerUtils.INSTANCE.hookAdapters(lemurLiveApp); lemurWidget.setContents(jzJazzInterface); }/*from ww w. j a v a 2 s. c om*/ } } }; jzmlOpenAction.setEnabled(true); jzmlOpenAction.setText("Open Lemur Legacy Control UI"); jzmlOpenAction.setToolTipText("Open Lemur Legacy Control UI"); jzmlOpenAction.setImageDescriptor( Activator.imageDescriptorFromPlugin("net.sf.smbt.ui", "icons/new/world_of_motion_disc.png")); jzmuiOpenAction = new Action() { public void run() { FileDialog fileSelectionDialog = new FileDialog(Display.getDefault().getActiveShell()); String jzmuiFilePath = fileSelectionDialog.open(); if (jzmuiFilePath != null && !jzmuiFilePath.equals("")) { LemurLiveApp lemurLiveApp = JzmlUtils.INSTANCE.loadLemurLiveAppFromJzmuiXML(jzmuiFilePath); if (lemurLiveApp != null && lemurLiveApp.getElements().size() > 0) { JZJazzInterface jzJazzInterface = (JZJazzInterface) lemurLiveApp.getElements().get(0); JzmuiControllerUtils.INSTANCE.initConnections(lemurLiveApp); JzmuiControllerUtils.INSTANCE.hookAdapters(lemurLiveApp); lemurWidget.setContents(jzJazzInterface); } } } }; jzmuiOpenAction.setEnabled(true); jzmuiOpenAction.setText("Open Ubqt Control UI"); jzmuiOpenAction.setToolTipText("Open Ubqt Control UI"); jzmuiOpenAction.setImageDescriptor( Activator.imageDescriptorFromPlugin("net.sf.smbt.ui", "icons/new/world_of_motion_volume.png")); configAction = new Action() { public void run() { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault().getActiveShell(), "net.sf.smbt.ui.lemur.ui.prefs.JZMUIPreferencePage", null, null); if (dialog != null) { dialog.open(); } } }; configAction.setEnabled(true); configAction.setText("OSC/Midi Configuration"); configAction.setToolTipText("OSC/Midi Configuration"); configAction.setImageDescriptor( Activator.imageDescriptorFromPlugin("net.sf.smbt.ui", "icons/actions/mail-send-receive.png")); // // 2nd monitor // openIn2ndMonitorAction = new Action() { public void run() { FileDialog fileSelectionDialog = new FileDialog(Display.getDefault().getActiveShell()); String jzmlFilePath = fileSelectionDialog.open(); if (jzmlFilePath != null && !jzmlFilePath.equals("")) { LemurLiveApp lemurLiveApp = JzmlUtils.INSTANCE.loadLemurLiveAppFromXML(jzmlFilePath); if (lemurLiveApp != null && lemurLiveApp.getElements().size() > 0) { JZJazzInterface jzJazzInterface = (JZJazzInterface) lemurLiveApp.getElements().get(0); JzmuiControllerUtils.INSTANCE.initConnections(lemurLiveApp); JzmuiControllerUtils.INSTANCE.hookAdapters(lemurLiveApp); TangibleGuiUtuils.INSTANCE.doIt(jzJazzInterface); } } } }; openIn2ndMonitorAction.setEnabled(true); // 2+ monitor ??? openIn2ndMonitorAction.setText("Open in 2nd monitor"); openIn2ndMonitorAction.setToolTipText("Open in 2nd monitor"); openIn2ndMonitorAction.setImageDescriptor( Activator.imageDescriptorFromPlugin("net.sf.smbt.ui", "icons/new/clapperboard.png")); }
From source file:net.sourceforge.sqlexplorer.dialogs.CreateAliasDlg.java
License:Open Source License
protected Control createDialogArea(Composite parent) { // top level composite Composite parentComposite = (Composite) super.createDialogArea(parent); // create a composite with standard margins and spacing Composite composite = new Composite(parentComposite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout);/*from w w w . ja v a 2 s . c o m*/ final GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true); gd_composite.heightHint = 238; composite.setLayoutData(gd_composite); composite.setFont(parentComposite.getFont()); Composite nameGroup = new Composite(composite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 3; layout.marginWidth = 10; nameGroup.setLayout(layout); GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); data.heightHint = 211; nameGroup.setLayoutData(data); Label label = new Label(nameGroup, SWT.WRAP); label.setText("Name"); //$NON-NLS-1$ nameField = new Text(nameGroup, SWT.BORDER); if (type != Type.CREATE) nameField.setText(alias.getName()); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); data.horizontalSpan = 2; data.widthHint = SIZING_TEXT_FIELD_WIDTH; nameField.setLayoutData(data); nameField.addKeyListener(new KeyListener() { public void keyPressed(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; public void keyReleased(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; }); Label label2 = new Label(nameGroup, SWT.WRAP); label2.setText("Driver"); //$NON-NLS-1$ cboDriver = new Combo(nameGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); final GridData gd_driver = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); gd_driver.widthHint = SIZING_TEXT_FIELD_WIDTH; cboDriver.setLayoutData(gd_driver); String defaultDriverName = SQLExplorerPlugin.getDefault().getPluginPreferences() .getString(IConstants.DEFAULT_DRIVER); ManagedDriver defaultDriver = null; int defaultDriverIndex = 0; populateCombo(); for (Entry<Integer, ManagedDriver> entry : comboDriverIndexes.entrySet()) { ManagedDriver driver = entry.getValue(); if (driver.getName().startsWith(defaultDriverName)) { defaultDriver = driver; defaultDriverIndex = entry.getKey(); break; } } Button btnListDrivers = new Button(nameGroup, SWT.NULL); btnListDrivers.setText(Messages.getString("AliasDialog.EditDrivers")); //$NON-NLS-1$ final GridData gd_btnListDrivers = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); btnListDrivers.setLayoutData(gd_btnListDrivers); btnListDrivers.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(getShell(), null, new String[] { DriverPreferencePage.class.getName() }, null); if (dlg.open() == IDialogConstants.OK_ID) populateCombo(); } }); Label label3 = new Label(nameGroup, SWT.WRAP); label3.setText("URL"); //$NON-NLS-1$ urlField = new Text(nameGroup, SWT.BORDER); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); data.horizontalSpan = 2; data.widthHint = SIZING_TEXT_FIELD_WIDTH; urlField.setLayoutData(data); urlField.addKeyListener(new KeyListener() { public void keyPressed(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; public void keyReleased(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; }); new Label(nameGroup, SWT.NONE); noUsernameRequired = new Button(nameGroup, SWT.CHECK); noUsernameRequired.setText("Username is not required for this database"); new Label(nameGroup, SWT.NONE); Label label4 = new Label(nameGroup, SWT.WRAP); label4.setText("User Name"); //$NON-NLS-1$ userField = new Text(nameGroup, SWT.BORDER); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); data.horizontalSpan = 2; data.widthHint = SIZING_TEXT_FIELD_WIDTH; userField.setLayoutData(data); userField.addKeyListener(new KeyListener() { public void keyPressed(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; public void keyReleased(org.eclipse.swt.events.KeyEvent e) { CreateAliasDlg.this.validate(); }; }); Label label5 = new Label(nameGroup, SWT.WRAP); label5.setText("Password"); //$NON-NLS-1$ passwordField = new Text(nameGroup, SWT.BORDER); passwordField.setEchoChar('*'); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); data.horizontalSpan = 2; data.widthHint = SIZING_TEXT_FIELD_WIDTH; passwordField.setLayoutData(data); cboDriver.addSelectionListener(new SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { int selIndex = cboDriver.getSelectionIndex(); ManagedDriver driver = comboDriverIndexes.get(selIndex); urlField.setText(driver.getUrl()); CreateAliasDlg.this.validate(); }; }); if (!comboDriverIndexes.isEmpty() && defaultDriver != null) { cboDriver.select(defaultDriverIndex); urlField.setText(defaultDriver.getUrl()); } new Label(nameGroup, SWT.NONE); final Composite connectionPropertiesComposite = new Composite(nameGroup, SWT.NONE); connectionPropertiesComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; connectionPropertiesComposite.setLayout(gridLayout); new Label(nameGroup, SWT.NONE); new Label(nameGroup, SWT.NONE); /* final Button */ autoLogonButton = new Button(connectionPropertiesComposite, SWT.CHECK); autoLogonButton.setToolTipText("If set, SQLExplorer will try to logon without prompting"); final GridData gd_autoLogonButton = new GridData(158, SWT.DEFAULT); autoLogonButton.setLayoutData(gd_autoLogonButton); autoLogonButton.setText("Auto logon"); /* final Button */ autoCommitButton = new Button(connectionPropertiesComposite, SWT.CHECK); autoCommitButton.setToolTipText("Sets the default for new SQL Editors"); autoCommitButton.setText("Auto Commit"); /* final Button */ logonAtStartupButton = new Button(connectionPropertiesComposite, SWT.CHECK); logonAtStartupButton.setToolTipText("If set, SQLExplorer will establish a connection during startup"); logonAtStartupButton.setText("Logon during startup"); /* final Button */ commitOnCloseButton = new Button(connectionPropertiesComposite, SWT.CHECK); commitOnCloseButton.setToolTipText("Sets the default for new SQL editors"); commitOnCloseButton.setText("Commit on close"); new Label(nameGroup, SWT.NONE); autoLogonButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { boolean checked = autoLogonButton.getSelection(); logonAtStartupButton.setEnabled(checked); if (!checked) logonAtStartupButton.setSelection(false); } }); logonAtStartupButton.setEnabled(alias.isConnectAtStartup()); logonAtStartupButton.setSelection(alias.isConnectAtStartup()); autoLogonButton.setSelection(alias.isConnectAtStartup()); autoCommitButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { commitOnCloseButton.setEnabled(!autoCommitButton.getSelection()); } }); User user = alias.getDefaultUser(); if (user != null) { autoCommitButton.setSelection(user.isAutoCommit()); commitOnCloseButton.setEnabled(!user.isAutoCommit()); commitOnCloseButton.setSelection(user.isCommitOnClose()); } noUsernameRequired.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { userField.setEnabled(!noUsernameRequired.getSelection()); passwordField.setEnabled(!noUsernameRequired.getSelection()); } }); if (alias.hasNoUserName()) { noUsernameRequired.setSelection(true); userField.setEnabled(false); passwordField.setEnabled(false); } else { noUsernameRequired.setSelection(false); userField.setEnabled(true); passwordField.setEnabled(true); if (alias.getDefaultUser() != null) { userField.setText(alias.getDefaultUser().getUserName()); passwordField.setText(alias.getDefaultUser().getPassword()); } } if (type != Type.CREATE) { if (alias.getDriver() != null) cboDriver.setText(alias.getDriver().getName()); urlField.setText(alias.getUrl()); } return parentComposite; }
From source file:org.apache.directory.studio.connection.ui.actions.PropertiesAction.java
License:Apache License
/** * {@inheritDoc}/*from w w w.j a va2 s . co m*/ */ 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 ww . j a va 2 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(); } } } }
From source file:org.apache.directory.studio.ldapbrowser.common.actions.PropertiesAction.java
License:Apache License
/** * {@inheritDoc}/*from w w w .jav a 2 s. c om*/ */ public void run() { IAdaptable element = null; String pageId = null; String title = null; if (getSelectedValues().length == 1) { element = (IAdaptable) getSelectedValues()[0]; pageId = BrowserCommonConstants.PROP_VALUE; title = getSelectedValues()[0].toString(); } else if (getSelectedAttributes().length == 1) { element = (IAdaptable) getSelectedAttributes()[0]; pageId = BrowserCommonConstants.PROP_ATTRIBUTE; title = getSelectedAttributes()[0].toString(); } else if (getSelectedAttributeHierarchies().length == 1) { IAttribute att = getSelectedAttributeHierarchies()[0].getAttribute(); element = att; pageId = BrowserCommonConstants.PROP_ATTRIBUTE; title = att.toString(); } else if (getSelectedSearches().length == 1) { element = (IAdaptable) getSelectedSearches()[0]; pageId = BrowserCommonConstants.PROP_SEARCH; title = getSelectedSearches()[0].getName(); } else if (getSelectedBookmarks().length == 1) { element = (IAdaptable) getSelectedBookmarks()[0]; pageId = BrowserCommonConstants.PROP_BOOKMARK; title = getSelectedBookmarks()[0].getName(); } else if (getSelectedEntries().length == 1) { element = (IAdaptable) getSelectedEntries()[0]; pageId = BrowserCommonConstants.PROP_ENTRY; title = getSelectedEntries()[0].getDn().getName(); } else if (getSelectedSearchResults().length == 1) { element = (IAdaptable) getSelectedSearchResults()[0]; pageId = BrowserCommonConstants.PROP_ENTRY; title = getSelectedSearchResults()[0].getDn().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.PropertiesForX"), title)); //$NON-NLS-1$ dialog.open(); } }
From source file:org.apache.directory.studio.ldapbrowser.ui.actions.BrowserPasteAction.java
License:Apache License
private void pasteSearches(ISearch[] searches) { IBrowserConnection browserConnection = null; if (getSelectedBrowserViewCategories().length > 0) { browserConnection = getSelectedBrowserViewCategories()[0].getParent(); } else if (getSelectedSearches().length > 0) { browserConnection = getSelectedSearches()[0].getBrowserConnection(); }/*from www .j a v a 2s . com*/ if (browserConnection != null) { ISearch clone = null; for (ISearch search : searches) { SearchParameter searchParameter = (SearchParameter) search.getSearchParameter().clone(); clone = new Search(browserConnection, searchParameter); browserConnection.getSearchManager().addSearch(clone); } if (searches.length == 1) { IAdaptable element = (IAdaptable) clone; String pageId = BrowserCommonConstants.PROP_SEARCH; String title = clone.getName(); 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.PropertiesForX"), title)); //$NON-NLS-1$ dialog.open(); } } }
From source file:org.apache.directory.studio.ldapservers.actions.PropertiesAction.java
License:Apache License
/** * {@inheritDoc}/*from www. jav a2 s . c om*/ */ public void run() { if (view != null) { StructuredSelection selection = (StructuredSelection) view.getViewer().getSelection(); if (!selection.isEmpty()) { LdapServer server = (LdapServer) selection.getFirstElement(); PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(view.getViewSite().getShell(), server, LdapServersPluginConstants.PROP_SERVER_PROPERTY_PAGE, null, null); dialog.getShell().setText(NLS.bind(Messages.getString("PropertiesAction.PropertiesFor"), //$NON-NLS-1$ shorten(server.getName(), 30))); dialog.open(); } } }
From source file:org.apache.felix.sigil.eclipse.internal.install.OSGiInstallManager.java
License:Apache License
private void showInstallPrefs(final IPreferenceStore prefs) { Runnable r = new Runnable() { public void run() { MessageDialogWithToggle questionDialog = MessageDialogWithToggle.openYesNoQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Sigil Configuration", "Missing OSGi installation. Open preferences to configure it now?", "Do not show this message again", false, null, null); prefs.setValue(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, questionDialog.getToggleState()); if (questionDialog.getReturnCode() == IDialogConstants.YES_ID) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, SigilCore.OSGI_INSTALLS_PREFERENCES_ID, null, null); dialog.open(); }/*w w w. j a va2 s.co m*/ } }; Display d = Display.getCurrent(); if (d == null) { d = Display.getDefault(); d.asyncExec(r); } else { d.syncExec(r); } }