List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:com.microsoft.tfs.client.eclipse.ui.actions.vc.DisconnectProjectAction.java
License:Open Source License
@Override public void doRun(final IAction action) { final IProject[] projects = (IProject[]) adaptSelectionToArray(IProject.class); String title;//from w w w . jav a 2 s . c om String prompt; String progress; String errorText; if (projects.length == 1) { title = Messages.getString("DisconnectProjectAction.SingleDisconnectDialogTitle"); //$NON-NLS-1$ prompt = Messages.getString("DisconnectProjectAction.SingleDisconnectDialogText"); //$NON-NLS-1$ progress = Messages.getString("DisconnectProjectAction.SingleDisconnectProgressText"); //$NON-NLS-1$ errorText = Messages.getString("DisconnectProjectAction.SingleDisconnectErrorText"); //$NON-NLS-1$ } else { title = Messages.getString("DisconnectProjectAction.MultiDisconnectDialogTitle"); //$NON-NLS-1$ prompt = Messages.getString("DisconnectProjectAction.MultiDisconnectDialogText"); //$NON-NLS-1$ progress = Messages.getString("DisconnectProjectAction.MultiDisconnectProgressText"); //$NON-NLS-1$ errorText = Messages.getString("DisconnectProjectAction.MultiDisconnectErrorText"); //$NON-NLS-1$ } final boolean result = MessageDialog.openConfirm(getShell(), title, prompt); if (result == false) { /* User cancelled */ return; } /* * Determine the repositories that will be brought offline after * disconnecting this project. */ final Map<TFSRepository, Set<IProject>> repositoryToProjectList = TFSEclipseClientPlugin.getDefault() .getProjectManager().getRepositoryToProjectMap(); for (int i = 0; i < projects.length; i++) { final TFSRepository repository = TFSEclipseClientPlugin.getDefault().getProjectManager() .getRepository(projects[i]); if (repository != null) { final Set<IProject> projectsForRepository = repositoryToProjectList.get(repository); if (projectsForRepository != null) { projectsForRepository.remove(projects[i]); } } } /* * If there are any repositories that will be brought offline, prompt to * save WIT editors before that happens. */ boolean needsSavePrompt = false; for (final Entry<TFSRepository, Set<IProject>> entry : repositoryToProjectList.entrySet()) { if (entry.getValue().size() == 0) { needsSavePrompt = true; break; } } /* Prompt for save */ if (needsSavePrompt) { if (EditorHelper.saveAllDirtyEditors(new TFSEditorSaveableFilter(TFSEditorSaveableType.ALL)) == false) { /* User cancelled */ return; } } /* Disconnect the projects */ final CommandList disconnectCommands = new CommandList(progress, errorText); for (int i = 0; i < projects.length; i++) { disconnectCommands.addCommand(new DisconnectProjectCommand(projects[i])); } execute(disconnectCommands); }
From source file:com.microsoft.webapp.debug.WebAppLaunchConfigurationDelegate.java
License:Open Source License
@Override public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { final ILaunchConfiguration configToUse = config; String port = "8000"; Map<String, String> conMap = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, new HashMap<String, String>()); for (java.util.Map.Entry<String, String> entry : conMap.entrySet()) { if (entry.getKey().equalsIgnoreCase("port")) { port = entry.getValue();//from w w w .j a v a2s .co m } } final String portToDisplayError = port; try { // check port availability if (Utils.isPortAvailable(Integer.parseInt(port))) { // get web app name to which user want to debug his application String website = config.getAttribute(AzureLaunchConfigurationAttributes.WEBSITE_DISPLAY, ""); if (!website.isEmpty()) { website = website.substring(0, website.indexOf('(')).trim(); Map<WebSite, WebSiteConfiguration> webSiteConfigMap = PreferenceWebAppUtil.load(); // retrieve web apps configurations for (Entry<WebSite, WebSiteConfiguration> entry : webSiteConfigMap.entrySet()) { final WebSite websiteTemp = entry.getKey(); if (websiteTemp.getName().equals(website)) { // check is there a need for preparation AzureManager manager = AzureManagerImpl.getManager(); final WebSiteConfiguration webSiteConfiguration = entry.getValue(); final WebSitePublishSettings webSitePublishSettings = manager.getWebSitePublishSettings( webSiteConfiguration.getSubscriptionId(), webSiteConfiguration.getWebSpaceName(), website); // case - if user uses shortcut without going to Azure Tab Map<String, Boolean> mp = Activator.getDefault().getWebsiteDebugPrep(); if (!mp.containsKey(website)) { mp.put(website, false); } Activator.getDefault().setWebsiteDebugPrep(mp); if (Activator.getDefault().getWebsiteDebugPrep().get(website).booleanValue()) { // already prepared. Just start debugSession.bat // retrieve MSDeploy publish profile WebSitePublishSettings.MSDeployPublishProfile msDeployProfile = null; for (PublishProfile pp : webSitePublishSettings.getPublishProfileList()) { if (pp instanceof MSDeployPublishProfile) { msDeployProfile = (MSDeployPublishProfile) pp; break; } } if (msDeployProfile != null) { ProcessBuilder pb = null; String os = System.getProperty("os.name").toLowerCase(); String webAppDirPath = String.format("%s%s%s", PluginUtil.pluginFolder, File.separator, com.microsoft.webapp.util.Messages.webAppPluginID); if (Activator.IS_WINDOWS) { String command = String.format(Messages.command, port, website, msDeployProfile.getUserName(), msDeployProfile.getPassword()); pb = new ProcessBuilder("cmd", "/c", "start", "cmd", "/k", command); } else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os.indexOf("aix") > 0) { // escape $ for linux String userName = "\\" + msDeployProfile.getUserName(); String command = String.format(Messages.commandSh, port, website, userName, msDeployProfile.getPassword()); pb = new ProcessBuilder("/bin/bash", "-c", command); } else { // escape $ for mac String userName = "'" + msDeployProfile.getUserName() + "'"; // On mac, you need to specify exact path of JAR String command = String.format(Messages.commandMac, webAppDirPath + "/", port, website, userName, msDeployProfile.getPassword()); String commandNext = "tell application \"Terminal\" to do script \"" + command + "\""; pb = new ProcessBuilder("osascript", "-e", commandNext); } pb.directory(new File(webAppDirPath)); try { pb.start(); Thread.sleep(10000); } catch (Exception e) { Activator.getDefault().log(Messages.errTtl, e); } super.launch(config, mode, launch, monitor); } } else { // start the process of preparing the web app, in a blocking way Display.getDefault().syncExec(new Runnable() { @Override public void run() { boolean choice = MessageDialog.openConfirm(PluginUtil.getParentShell(), Messages.title, Messages.remoteDebug); if (choice) { IRunnableWithProgress op = new PrepareForDebug(websiteTemp, webSiteConfiguration, webSitePublishSettings); try { new ProgressMonitorDialog(PluginUtil.getParentShell()).run(true, true, op); MessageDialog.openInformation(PluginUtil.getParentShell(), Messages.title, Messages.debugReady); } catch (Exception e) { Activator.getDefault().log(e.getMessage(), e); } } WebAppUtils.openDebugLaunchDialog(configToUse); } }); } break; } } } } else { Display.getDefault().syncExec(new Runnable() { @Override public void run() { PluginUtil.displayErrorDialog(PluginUtil.getParentShell(), Messages.errTtl, String.format(Messages.portMsg, portToDisplayError)); WebAppUtils.openDebugLaunchDialog(configToUse); } }); } } catch (Exception ex) { Activator.getDefault().log(ex.getMessage(), ex); } }
From source file:com.microsoftopentechnologies.wacommon.commoncontrols.ManageSubscriptionPanel.java
License:Open Source License
private void clearSubscriptions(boolean isSigningOut) { boolean choice = MessageDialog.openConfirm(new Shell(), (isSigningOut ? "Clear Subscriptions" : "Sign out"), (isSigningOut ? "Are you sure you would like to clear all subscriptions?" : "Are you sure you would like to sign out?")); if (choice) { AzureManager apiManager = AzureManagerImpl.getManager(); apiManager.clearAuthentication(); apiManager.clearImportedPublishSettingsFiles(); WizardCacheManager.clearSubscriptions(); PreferenceUtil.save();/* ww w . j a v a 2 s. co m*/ subscriptionList.clear(); tableViewer.refresh(); // todo ? // DefaultLoader.getIdeHelper().unsetProperty(AppSettingsNames.SELECTED_SUBSCRIPTIONS); removeButton.setEnabled(false); refreshSignInCaption(); } }
From source file:com.midrange.rse_enhancements.chgmsg.ChangeMessageTextAction.java
License:Open Source License
@Override public void run(IAction action) { Shell shell = getShell();/*ww w .ja va2 s .co m*/ IQSYSMessageDescription message = getFirstSelectedRemoteFile(); String id = message.getID(); QSYSRemoteMessageFile file = (QSYSRemoteMessageFile) message.getFile(); try { message = file.getMessageDescription(id, new NullProgressMonitor()); String library = file.getLibrary(); String name = file.getName(); EditMessageTextDialog dialog = new EditMessageTextDialog(shell, message); // dialog.setMessageText(message.getHelp()); if (dialog.open() == Window.OK) { String updatedText = dialog.getMessageText(); String cmd = MessageFormat.format(CHGMSGD_CMD, message.getID(), library, name, fixQuotes(updatedText)); String humanCommand = MessageFormatter.formatForHumans(cmd); boolean confirmCommand = preferenceStore.getBoolean(PreferenceConstants.P_CONFIRM_UPDATE_MESSAGE); if (!confirmCommand || MessageDialog.openConfirm(shell, "OK to run command", humanCommand)) { runCommand(cmd); registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, message, file, getSubSystem(), null, null); } } } catch (SystemMessageException e) { SystemMessageDialog.displayMessage(e); } catch (Exception e) { SystemMessageDialog.displayExceptionMessage(shell, e); } }
From source file:com.mobilesorcery.sdk.ui.targetphone.internal.EditDeviceListDialog.java
License:Open Source License
protected void clearDeviceList(Shell parent) { if (MessageDialog.openConfirm(parent, "Are you sure?", "This will clear the list of target devices -- are you sure?")) { TargetPhonePlugin.getDefault().clearHistory(); close();/* w w w. j a v a 2s .c o m*/ } }
From source file:com.nextep.designer.beng.ui.handlers.RemoveDeliveryItemHandler.java
License:Open Source License
/** * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) *//*from w w w . j a v a 2 s . c om*/ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // Retrieving delivery type ISelection sel = HandlerUtil.getCurrentSelection(event); if (sel instanceof IStructuredSelection) { final IStructuredSelection s = (IStructuredSelection) sel; if (s.size() > 1) { final boolean confirmed = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), MessageFormat.format(BengUIMessages.getString("confirmRemoveDeliveryItemTitle"), s.size()), //$NON-NLS-1$ MessageFormat.format(BengUIMessages.getString("confirmRemoveDeliveryItem"), s.size()) //$NON-NLS-1$ ); if (!confirmed) { throw new CancelException("Operation cancelled by user."); } } // Removing all selected items for (Object o : s.toList()) { if (o instanceof IDeliveryItem<?>) { IDeliveryItem<?> i = (IDeliveryItem<?>) o; IDeliveryModule m = i.getParentModule(); m.removeDeliveryItem(i); } } } return null; }
From source file:com.nextep.designer.dbgm.ui.editors.PhysicalPropertiesOverviewFormEditor.java
License:Open Source License
@Override protected void createControls(IManagedForm managedForm, FormToolkit toolkit, Composite editor) { // Creating the physical properties button physicalPropertiesButton = toolkit.createButton(editor, DBGMUIMessages.getString("editor.physProps.physicalCheck"), //$NON-NLS-1$ SWT.CHECK);/* www .ja va 2s. c o m*/ physicalPropertiesButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 5, 1)); physicalPropertiesButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (physicalPropertiesButton.getSelection()) { final IPhysicalObject t = getModel(); if (t.getPhysicalProperties() == null) { ITypedObjectUIController controller = UIControllerFactory .getController(t.getPhysicalPropertiesType()); controller.emptyInstance(t.getName(), t); refresh(); } } else { final IPhysicalObject t = getModel(); if (t.getPhysicalProperties() != null) { final boolean confirmed = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), DBGMUIMessages.getString("editor.physProps.confirmRemovalTitle"), //$NON-NLS-1$ DBGMUIMessages.getString("editor.physProps.confirmRemovalMsg")); //$NON-NLS-1$ if (confirmed) { CorePlugin.getService(IWorkspaceUIService.class).remove(t.getPhysicalProperties()); } else { physicalPropertiesButton.setSelection(true); } } } } }); // Creating tablespace text toolkit.createLabel(editor, DBGMUIMessages.getString("editor.physProps.tablespace")); //$NON-NLS-1$ tablespaceText = toolkit.createText(editor, "", SWT.BORDER); //$NON-NLS-1$ tablespaceText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1)); }
From source file:com.nextep.designer.dbgm.ui.handlers.EditDiagramItemHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection s = HandlerUtil.getCurrentSelection(event); if (s instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) s; if (!sel.isEmpty()) { if (sel.size() > WARN_DIALOG_ABOVE) { final boolean confirmed = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), MessageFormat.format(DBGMUIMessages.getString("editDiagramItemWarnCountTitle"), sel.size()), MessageFormat.format(DBGMUIMessages.getString("editDiagramItemWarnCount"), sel.size(), sel.size())); if (!confirmed) { return null; }/* w w w . j ava 2 s . c o m*/ } for (Iterator<?> it = sel.iterator(); it.hasNext();) { final Object o = it.next(); if (o instanceof DiagramItemPart || o instanceof ConnectionEditPart) { Object model = ((GraphicalEditPart) o).getModel(); Object innerModel = model; if (model instanceof IDiagramItem) { innerModel = ((IDiagramItem) model).getItemModel(); } if (innerModel instanceof ITypedObject) { UIControllerFactory.getController(((ITypedObject) innerModel).getType()) .defaultOpen((ITypedObject) innerModel); } } } } } return null; }
From source file:com.nextep.designer.synch.ui.services.impl.SynchronizationUIService.java
License:Open Source License
@Override public void submit(final ISynchronizationResult result) { // If result has not yet been generated we generate and submit without // notice// ww w .j a v a2 s .c o m if (result.getGenerationResult() == null) { synchronizationService.buildScript(result, null); } // If result is dirty we need to regenerate it so we prompt if (result.isDirty()) { final boolean confirmed = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), SynchUIMessages.getString("service.synch.needsSqlGenerationTitle"), //$NON-NLS-1$ SynchUIMessages.getString("service.synch.needsSqlGenerationMsg")); //$NON-NLS-1$ if (confirmed) { buildScript(result); } } else { // Building UI scripts final String jobName = MessageFormat.format(SynchUIMessages.getString("synch.job.submitScript"), //$NON-NLS-1$ result.getConnection().getName()); Job j = new Job(jobName) { @Override protected IStatus run(IProgressMonitor monitor) { try { monitor.beginTask(jobName, 1); monitor.subTask(""); //$NON-NLS-1$ final ISQLScript script = result.getGeneratedScript(); SubmitionManager.submit(result.getConnection(), script, result.getGenerationResult(), monitor); SQLEditorUIServices.getInstance().annotateVisibleEditor(); showScript(result); return Status.OK_STATUS; } catch (CancelException e) { return Status.CANCEL_STATUS; } } }; j.setUser(true); j.schedule(); } }
From source file:com.nextep.designer.ui.handlers.EditTypedItemHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection s = HandlerUtil.getCurrentSelection(event); if (s instanceof IStructuredSelection) { final IStructuredSelection sel = (IStructuredSelection) s; if (!sel.isEmpty()) { // Warning before opening too many editors if (sel.size() > WARN_DIALOG_ABOVE) { final boolean confirmed = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), MessageFormat.format(UIMessages.getString("editItemWarnCountTitle"), sel.size()), //$NON-NLS-1$ MessageFormat.format(UIMessages.getString("editItemWarnCount"), sel.size(), sel //$NON-NLS-1$ .size())); if (!confirmed) { return null; }// www . j a va 2 s . co m } // If OK, we open everything final Iterator<?> selIt = sel.iterator(); while (selIt.hasNext()) { final Object o = selIt.next(); if ((o instanceof ITypedObject) && !(o instanceof IConnector<?, ?>)) { final ITypedObject t = (ITypedObject) o; UIControllerFactory.getController(t.getType()).defaultOpen(t); } } } } return null; }