List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle openOkCancelConfirm
public static MessageDialogWithToggle openOkCancelConfirm(Shell parent, String title, String message, String toggleMessage, boolean toggleState, IPreferenceStore store, String key)
From source file:au.gov.ga.earthsci.bookmark.part.BookmarksController.java
License:Apache License
@Override public boolean deleteBookmarkList(IBookmarkList list) { if (list == null || list == bookmarks.getDefaultList()) { return false; }/* ww w. j a v a2 s . c om*/ if (preferences.askForListDeleteConfirmation()) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm( Display.getDefault().getActiveShell(), Messages.BookmarksController_BookmarkListDeleteDialogTitle, Messages.BookmarksController_BookmarkListDeleteDialogMessage, Messages.BookmarksController_BookmarkListDeleteDialogToggleMessage, preferences.askForListDeleteConfirmation(), null, null); if (dialog.getReturnCode() != MessageDialog.OK) { return false; } preferences.setAskForListDeleteConfirmation(dialog.getToggleState()); } return bookmarks.removeList(list); }
From source file:com.aptana.ide.debug.internal.ui.WorkbenchCloseListener.java
License:Open Source License
/** * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) *//*w w w. j a v a 2s . c o m*/ public void handleEvent(Event event) { if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1 && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell() == event.widget) { // last workbench window is about to close if ("true".equals(System.getProperty(JSDebugOptionsManager.DEBUGGER_ACTIVE))) { //$NON-NLS-1$ IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); if (store.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { if (store.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER) == false) { return; } } event.doit = false; MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget, Messages.WorkbenchCloseListener_ConfirmDebuggerExit, Messages.WorkbenchCloseListener_AptanaDebuggerIsActive_DoYouWantToExit, Messages.WorkbenchCloseListener_AlwaysExitDebuggerWithoutPrompt, false, null, null); int returnValue = dlg.getReturnCode(); if (returnValue != IDialogConstants.OK_ID) { // SWT hack - discard close event event.type = SWT.None; return; } if (dlg.getToggleState()) { store.setValue(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false); DebugUiPlugin.getDefault().savePluginPreferences(); } } } }
From source file:com.aptana.ide.rcp.IDEWorkbenchWindowAdvisor.java
License:Open Source License
public boolean preWindowShellClose() { if (getWorkbench().getWorkbenchWindowCount() > 1) { return true; }/* ww w . ja va 2s . c o m*/ // the user has asked to close the last window, while will cause the // workbench to close in due course - prompt the user for confirmation IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); boolean promptOnExit = store.getBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW); if (promptOnExit) { String message; String productName = null; IProduct product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { message = IDEWorkbenchMessages.PromptOnExitDialog_message0; } else { message = NLS.bind(IDEWorkbenchMessages.PromptOnExitDialog_message1, productName); } MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( getWindowConfigurer().getWindow().getShell(), IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, message, IDEWorkbenchMessages.PromptOnExitDialog_choice, false, null, null); if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; } if (dlg.getToggleState()) { store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false); IDEWorkbenchPlugin.getDefault().savePluginPreferences(); } } return true; }
From source file:com.aptana.js.debug.ui.internal.WorkbenchCloseListener.java
License:Open Source License
public void handleEvent(Event event) { if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1 && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().equals(event.widget)) { // last workbench window is about to close if (DebugOptionsManager.isDebuggerActive(JSDebugModel.getModelIdentifier())) { IEclipsePreferences preferences = EclipseUtil.instanceScope().getNode(JSDebugUIPlugin.PLUGIN_ID); if (!preferences.getBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, true)) { return; }/*from w w w . j av a2s . c o m*/ event.doit = false; MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget, Messages.WorkbenchCloseListener_ConfirmDebuggerExit, Messages.WorkbenchCloseListener_DebuggerIsActive_DoYouWantToExit, Messages.WorkbenchCloseListener_AlwaysExitDebuggerWithoutPrompt, false, null, null); int returnValue = dlg.getReturnCode(); if (returnValue != IDialogConstants.OK_ID) { // SWT hack - discard close event event.type = SWT.None; return; } if (dlg.getToggleState()) { preferences.putBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false); try { preferences.flush(); } catch (BackingStoreException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); } } } } }
From source file:com.aptana.rcp.IDEWorkbenchWindowAdvisor.java
License:Open Source License
/** * Asks the user whether the workbench should really be closed. Only asks if the preference is enabled. * // w w w . ja v a2s . c om * @param parentShell * the parent shell to use for the confirmation dialog * @return <code>true</code> if OK to exit, <code>false</code> if the user canceled * @since 3.6 */ static boolean promptOnExit(Shell parentShell) { IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); boolean promptOnExit = store.getBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW); if (promptOnExit) { if (parentShell == null) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow != null) { parentShell = workbenchWindow.getShell(); } } if (parentShell != null) { parentShell.setMinimized(false); parentShell.forceActive(); } String message; String productName = null; IProduct product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { message = IDEWorkbenchMessages.PromptOnExitDialog_message0; } else { message = NLS.bind(IDEWorkbenchMessages.PromptOnExitDialog_message1, productName); } MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm(parentShell, IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, message, IDEWorkbenchMessages.PromptOnExitDialog_choice, false, null, null); if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; } if (dlg.getToggleState()) { store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false); } } return true; }
From source file:com.maccasoft.ui.internal.application.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override @SuppressWarnings("deprecation") public boolean preWindowShellClose() { if (getWorkbench().getWorkbenchWindowCount() > 1) { return true; }/* w w w . j a v a2s.co m*/ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean promptOnExit = preferenceStore.getBoolean(EXIT_PROMPT_ON_CLOSE_LAST_WINDOW); if (promptOnExit) { MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( getWindowConfigurer().getWindow().getShell(), "Confirm Exit", "Exit Program ?", "Always exit without prompt", false, null, null); if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; } if (dlg.getToggleState()) { preferenceStore.setValue(EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false); Activator.getDefault().savePluginPreferences(); } } return true; }
From source file:com.motorola.studio.android.common.preferences.DialogWithToggleUtils.java
License:Apache License
/** * Show a confirmation message.//from w w w. j a va 2s . c o m * * @param preferenceKey the key to use when persisting the user's preference; * <code>null</code> if you don't want it persisted. * @param title the dialog's title, or <code>null</code> if none * @param message the dialogs message */ public static boolean showConfirmation(final String preferenceKey, final String title, final String message) { final Boolean[] reply = new Boolean[1]; final String prefKey = preferenceKey + TOGGLE_DIALOG; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { AbstractUIPlugin plugin = CommonPlugin.getDefault(); IPreferenceStore store = plugin.getPreferenceStore(); String preferenceValue = store.getString(prefKey); if (MessageDialogWithToggle.PROMPT.equals(preferenceValue) || (preferenceValue.length() == 0)) { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow(); Shell shell = ww.getShell(); MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, title, message, UtilitiesNLS.UI_AlwaysProceed, false, store, prefKey); reply[0] = (dialog.getReturnCode() == IDialogConstants.OK_ID); } else { reply[0] = preferenceValue.equals(MessageDialogWithToggle.ALWAYS); } } }); return reply[0]; }
From source file:com.safi.workshop.sqlexplorer.sqleditor.actions.ExecSQLAction.java
License:Open Source License
@Override public void run() { try {/*from www . ja v a 2 s . co m*/ if (StringUtils.isBlank(_editor.getSQLToBeExecuted())) return; // Find out how much to restrict results by Integer iMax = _editor.getLimitResults(); if (iMax == null) _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog.openError(_editor.getSite().getShell(), Messages.getString("SQLEditor.Error.InvalidRowLimit.Title"), Messages.getString("SQLEditor.Error.InvalidRowLimit")); } }); final int maxresults = (iMax == null) ? 0 : iMax.intValue(); if (maxresults < 0) throw new Exception(Messages.getString("SQLEditor.LimitRows.Error")); final ExecSQLAction action = this; boolean confirmWarnLargeMaxrows = AsteriskDiagramEditorPlugin.getDefault().getPluginPreferences() .getBoolean(IConstants.CONFIRM_BOOL_WARN_LARGE_MAXROWS); int warnLimit = AsteriskDiagramEditorPlugin.getDefault().getPluginPreferences() .getInt(IConstants.WARN_LIMIT); // Confirm with the user if they've left it too large if (confirmWarnLargeMaxrows && (maxresults == 0 || maxresults > warnLimit)) { _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( _editor.getSite().getShell(), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Title"), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Message"), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Toggle"), false, null, null); if (dlg.getReturnCode() == IDialogConstants.OK_ID) { if (dlg.getToggleState()) AsteriskDiagramEditorPlugin.getDefault().getPluginPreferences() .setValue(IConstants.CONFIRM_BOOL_WARN_LARGE_MAXROWS, false); action.run(maxresults); } } }); // Run it } else { action.run(maxresults); } } catch (final Exception e) { e.printStackTrace(); _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog.openError(_editor.getSite().getShell(), Messages.getString("SQLResultsView.Error.Title"), e.getClass().getCanonicalName() + ": " + e.getMessage()); } }); } }
From source file:com.siteview.mde.internal.ui.wizards.exports.AntGeneratingExportWizard.java
License:Open Source License
protected boolean performPreliminaryChecks() { // Check if we are going to overwrite an existing build.xml file if (!MessageDialogWithToggle.ALWAYS.equals(MDEPlugin.getDefault().getPreferenceStore() .getString(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT))) { Object[] objects = fPage.getSelectedItems(); List problemModels = new ArrayList(); for (int i = 0; i < objects.length; i++) { Object object = objects[i]; String installLocation = null; IResource underlyingResource = null; if (object instanceof WorkspaceMonitorModelBase) { installLocation = ((WorkspaceMonitorModelBase) object).getInstallLocation(); underlyingResource = ((WorkspaceMonitorModelBase) object).getUnderlyingResource(); } else if (object instanceof WorkspaceFeatureModel) { installLocation = ((WorkspaceFeatureModel) object).getInstallLocation(); underlyingResource = ((WorkspaceFeatureModel) object).getUnderlyingResource(); }/*ww w . ja va 2s . c o m*/ if (installLocation != null && underlyingResource != null) { File file = new File(installLocation, "build.xml"); //$NON-NLS-1$ if (file.exists()) { try { IFile buildFile = PDEProject.getBuildProperties(underlyingResource.getProject()); IBuildModel buildModel = new WorkspaceBuildModel(buildFile); buildModel.load(); if (buildModel != null) { IBuildEntry entry = buildModel.getBuild() .getEntry(IBuildPropertiesConstants.PROPERTY_CUSTOM); if (entry == null || !entry.contains(IBuildPropertiesConstants.TRUE)) { problemModels.add(object); } } } catch (CoreException e) { MDEPlugin.log(e); } } } } if (problemModels.size() > 0) { StringBuffer buf = new StringBuffer(); MDELabelProvider labelProvider = new MDELabelProvider(); int maxCount = 10; for (Iterator iterator = problemModels.iterator(); iterator.hasNext();) { buf.append(labelProvider.getText(iterator.next())); buf.append('\n'); maxCount--; if (maxCount <= 0) { buf.append(Dialog.ELLIPSIS); break; } } MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(getShell(), MDEUIMessages.AntGeneratingExportWizard_0, MessageFormat.format(MDEUIMessages.AntGeneratingExportWizard_1, new String[] { buf.toString() }), MDEUIMessages.AntGeneratingExportWizard_2, false, MDEPlugin.getDefault().getPreferenceStore(), IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT); if (dialog.getReturnCode() == Window.CANCEL) { return false; } } } if (fPage.doGenerateAntFile()) generateAntBuildFile(fPage.getAntBuildFileName()); return true; }
From source file:de.ovgu.featureide.ui.actions.generator.BuildAllConfigurationsAction.java
License:Open Source License
/** * Opens a dialog before building all current configuration. * /* www.jav a2 s. c o m*/ * @return true if all current configurations should be build. */ private MessageDialogWithToggle openDialog() { return MessageDialogWithToggle.openOkCancelConfirm(null, MESSAGE_TITLE_CURRENT, MESSAGE_CURRENT, TOGGLE_MESSAGE, getToggleState(), null, "key"); }