List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle openWarning
public static MessageDialogWithToggle openWarning(Shell parent, String title, String message, String toggleMessage, boolean toggleState, IPreferenceStore store, String key)
From source file:com.motorola.studio.android.common.preferences.DialogWithToggleUtils.java
License:Apache License
/** * Shown a warning dialog. The dialog is opened * only if it is the first time that the dialog is shown or if the user did not checked * the option "Do not show this window again" when the dialog had been opened previously. * * @param preferenceKey the key to use when persisting the user's preference * @param title the dialog's title, or <code>null</code> if none * @param message the dialogs message/*from w ww .j a v a 2 s .co m*/ * */ public static void showWarning(final String preferenceKey, final String title, final String message) { 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.openWarning(shell, title, message, UtilitiesNLS.UI_DoNotShowMEAgain, false, store, prefKey); } } }); }
From source file:info.vancauwenberge.designer.enhtrace.editor.input.LiveServerTraceEditorInput.java
License:Mozilla Public License
private static String extractServer(Server server) { String serverName = server.getDnsName(); if (serverName == null || "".equals(serverName.trim())) serverName = server.getHost();/* ww w. j a v a 2s . c om*/ IdentityVault vault = server.getIdentityVault(); if (serverName == null || "".equals(serverName.trim())) { serverName = vault.getHost(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); store.setDefault(STORE_SHOW_HOST_MISSING, true); if (store.getBoolean(STORE_SHOW_HOST_MISSING)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openWarning( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Hostname missing", "No hostname was found on server object. Defaulting to the hostname of the Identity Vault object", "Do not show this anymore", false, Activator.getDefault().getPreferenceStore(), STORE_SHOW_HOST_MISSING); } } int port = 636; if (extractUseSSL(server)) { port = vault.getLdapSecurePort(); } else { port = vault.getLdapClearTextPort(); } serverName = serverName + ":" + port; System.out .println(LiveServerTraceEditorInput.class.getName() + " - extractServer() returned: " + serverName); return serverName; }
From source file:org.bonitasoft.studio.engine.command.RunProcessCommand.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final String configurationId = retrieveConfigurationId(event); String currentTheme = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore() .getString(BonitaPreferenceConstants.DEFAULT_USERXP_THEME); String installedTheme = BonitaUserXpPreferencePage.getInstalledThemeId(); if (installedTheme != null && !installedTheme.equals(currentTheme)) { BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore() .setValue(BonitaPreferenceConstants.DEFAULT_USERXP_THEME, currentTheme); BonitaUserXpPreferencePage.updateBonitaHome(); }//from w w w . j a v a 2 s .c om final Set<AbstractProcess> executableProcesses = getProcessesToDeploy(event); if (BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore() .getBoolean(BonitaPreferenceConstants.VALIDATION_BEFORE_RUN)) { //Validate before run final ICommandService cmdService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command cmd = cmdService.getCommand("org.bonitasoft.studio.validation.batchValidation"); if (cmd.isEnabled()) { final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); Set<String> procFiles = new HashSet<String>(); for (AbstractProcess p : executableProcesses) { Resource eResource = p.eResource(); if (eResource != null) { procFiles.add(URI.decode(eResource.getURI().lastSegment())); } } try { Parameterization showReportParam = new Parameterization(cmd.getParameter("showReport"), Boolean.FALSE.toString()); Parameterization filesParam = new Parameterization(cmd.getParameter("diagrams"), procFiles.toString()); final IStatus status = (IStatus) handlerService.executeCommand( new ParameterizedCommand(cmd, new Parameterization[] { showReportParam, filesParam }), null); if (statusContainsError(status)) { if (!FileActionDialog.getDisablePopup()) { String errorMessage = Messages.errorValidationMessage + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor().getTitle() + Messages.errorValidationContinueAnywayMessage; int result = new ValidationDialog(Display.getDefault().getActiveShell(), Messages.validationFailedTitle, errorMessage, ValidationDialog.YES_NO_SEEDETAILS).open(); if (result == ValidationDialog.NO) { return null; } else if (result == ValidationDialog.SEE_DETAILS) { final IWorkbenchPage activePage = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); IEditorPart part = activePage.getActiveEditor(); if (part != null && part instanceof DiagramEditor) { MainProcess proc = ModelHelper.getMainProcess( ((DiagramEditor) part).getDiagramEditPart().resolveSemanticElement()); String partName = proc.getName() + " (" + proc.getVersion() + ")"; for (IEditorReference ref : activePage.getEditorReferences()) { if (partName.equals(ref.getPartName())) { activePage.activate(ref.getPart(true)); break; } } } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { try { activePage.showView("org.bonitasoft.studio.validation.view"); } catch (PartInitException e) { BonitaStudioLog.error(e); } } }); return null; } } } } catch (Exception e) { BonitaStudioLog.error(e); } } } IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.running, IProgressMonitor.UNKNOWN); final DeployProcessOperation operation = new DeployProcessOperation(); operation.setConfigurationId(configurationId); operation.setObjectToExclude(excludedObject); for (AbstractProcess process : executableProcesses) { operation.addProcessToDeploy(process); } status = operation.run(monitor); if (status == null) { return; } if (status.getSeverity() == IStatus.CANCEL) { return; } if (!status.isOK()) { if (!runSynchronously) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { new BonitaErrorDialog(Display.getDefault().getActiveShell(), Messages.deploymentFailedMessage, Messages.deploymentFailedMessage, status, IStatus.ERROR | IStatus.WARNING).open(); } }); } return; } final AbstractProcess p = getProcessToRun(event); hasInitiator = hasInitiator(p); if (p != null) { try { url = operation.getUrlFor(p, monitor); if (!runSynchronously) { BOSWebServerManager.getInstance().startServer(monitor); if (hasInitiator) { new OpenBrowserCommand(url, BonitaPreferenceConstants.APPLICATION_BROWSER_ID, "Bonita Application").execute(null); } else { Display.getDefault().syncExec(new Runnable() { @Override public void run() { IPreferenceStore preferenceStore = EnginePlugin.getDefault() .getPreferenceStore(); String pref = preferenceStore .getString(EnginePreferenceConstants.TOGGLE_STATE_FOR_NO_INITIATOR); if (MessageDialogWithToggle.NEVER.equals(pref)) { MessageDialogWithToggle.openWarning( Display.getDefault().getActiveShell(), Messages.noInitiatorDefinedTitle, Messages.bind(Messages.noInitiatorDefinedMessage, p.getName()), Messages.dontaskagain, false, preferenceStore, EnginePreferenceConstants.TOGGLE_STATE_FOR_NO_INITIATOR); } } }); status = openConsole(); } } } catch (Exception e) { status = new Status(IStatus.ERROR, EnginePlugin.PLUGIN_ID, e.getMessage(), e); BonitaStudioLog.error(e); } } else { if (!runSynchronously) { status = openConsole(); } } } private Status openConsole() { Status status = null; ICommandService service = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command cmd = service.getCommand("org.bonitasoft.studio.application.openConsole"); try { cmd.executeWithChecks(new ExecutionEvent()); } catch (Exception ex) { status = new Status(IStatus.ERROR, EnginePlugin.PLUGIN_ID, ex.getMessage(), ex); BonitaStudioLog.error(ex); } return status; } }; IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { if (runSynchronously) { runnable.run(Repository.NULL_PROGRESS_MONITOR); } else { service.run(true, false, runnable); } } catch (final Exception e) { BonitaStudioLog.error(e); status = new Status(IStatus.ERROR, EnginePlugin.PLUGIN_ID, e.getMessage(), e); if (!runSynchronously) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { new BonitaErrorDialog(Display.getDefault().getActiveShell(), Messages.deploymentFailedMessage, Messages.deploymentFailedMessage, e).open(); } }); } } return status; }
From source file:org.bonitasoft.studio.engine.operation.RunProcessOperation.java
License:Open Source License
private void redirectToPortalTaskList(final String togglePreference, final String shellTitle, final String message) { Display.getDefault().syncExec(new Runnable() { @Override// w ww .java2s.c om public void run() { final IPreferenceStore preferenceStore = EnginePlugin.getDefault().getPreferenceStore(); final String pref = preferenceStore.getString(togglePreference); if (MessageDialogWithToggle.NEVER.equals(pref)) { MessageDialogWithToggle.openWarning(Display.getDefault().getActiveShell(), shellTitle, message, Messages.dontaskagain, false, preferenceStore, togglePreference); } } }); status = openConsole(); }
From source file:org.eclipse.andmore.android.common.preferences.DialogWithToggleUtils.java
License:Apache License
/** * Shown a warning dialog. The dialog is opened only if it is the first time * that the dialog is shown or if the user did not checked the option * "Do not show this window again" when the dialog had been opened * previously./*from w w w . ja v a 2 s . c o m*/ * * @param preferenceKey * the key to use when persisting the user's preference * @param title * the dialog's title, or <code>null</code> if none * @param message * the dialogs message * */ public static void showWarning(final String preferenceKey, final String title, final String message) { final String prefKey = preferenceKey + TOGGLE_DIALOG; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override 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.openWarning(shell, title, message, UtilitiesNLS.UI_DoNotShowMEAgain, false, store, prefKey); } } }); }
From source file:org.eclipse.wst.sse.sieditor.ui.v2.AbstractFormPageController.java
License:Open Source License
protected void showWarningMessage(final IWorkbenchWindow window, final IPreferenceStore preferenceStore) { MessageDialogWithToggle.openWarning(window.getShell(), Messages.AbstractFormPageController_0, Messages.AbstractFormPageController_1, Messages.AbstractFormPageController_2, false, preferenceStore, ServiceInterfaceEditorPreferencePage.EDIT_REFERENCED_POPUP_NOT_SHOW_AGAIN); }
From source file:org.python.pydev.ui.dialogs.PyDialogHelpers.java
License:Open Source License
public static int openWarningWithIgnoreToggle(String title, String message, String key) { Shell shell = EditorUtils.getShell(); IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String val = store.getString(key); if (val.trim().length() == 0) { val = MessageDialogWithToggle.PROMPT; //Initial value if not specified }//from w ww. j a v a2s .c o m if (!val.equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle.openWarning(shell, title, message, "Don't show this message again", false, store, key); } return MessageDialog.OK; }
From source file:org.symbian.tools.tmw.debug.internal.launch.ResourcesChangeListener.java
License:Open Source License
public void resourceChanged(IResourceChangeEvent event) { if (event.getDelta() != null && !MessageDialogWithToggle.ALWAYS.equals(Activator.getDefault() .getPreferenceStore().getString(IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR))) { IFile[] changes = PreviewerUtil.getWebChanges(event.getDelta()); if (changes.length > 0 && isMobileApplicationResourceChanges(changes)) { Display.getDefault().asyncExec(new Runnable() { public void run() { String message = "Debug browser is not updated when the files are updated. You may notice discrepancies between your workspace contents and debug session. You should either refresh the browser or restart debugging session to see the latest changes made to the workspace."; MessageDialogWithToggle.openWarning( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Mobile Web Debugger", message, "Do not show this warning on code changes", false, Activator.getDefault().getPreferenceStore(), IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR); ResourcesPlugin.getWorkspace().removeResourceChangeListener(ResourcesChangeListener.this); }//from w w w . j a va2s .c o m }); } } }