List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.arm.cmsis.pack.project.wizards.CmsisCodeTemplateNewWizard.java
License:Open Source License
/** * The worker method. It will find the container, create the file if missing * or just replace its contents, and open the editor on the newly created * file./*from w ww .j av a 2s . co m*/ */ void doFinish(String containerName, String[] fileNames, String[] templateFileNames, IProgressMonitor monitor) throws CoreException { // create a sample file for (int i = 0; i < fileNames.length; i++) { String fileName = fileNames[i]; monitor.beginTask(Messages.CmsisCodeTemplate_CreatingFile + fileName, 2); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(containerName)); if (!resource.exists() || !(resource instanceof IContainer)) { String message = NLS.bind(Messages.CmsisCodeTemplate_ContainerNotExist, containerName); throwCoreException(message); } IContainer container = (IContainer) resource; final IFile file = container.getFile(new Path(fileName)); try { InputStream stream = openContentStream(templateFileNames[i]); if (file.exists()) { getShell().getDisplay().syncExec(new Runnable() { @Override public void run() { String message = NLS.bind(Messages.CmsisCodeTemplate_FileAlreadyExist, file.getName()); overwrite = MessageDialog.openQuestion(getShell(), Messages.CmsisCodeTemplate_OverwriteExistingFile, message); } }); if (overwrite) { file.setContents(stream, true, true, monitor); } } else { file.create(stream, true, monitor); } stream.close(); } catch (IOException e) { e.printStackTrace(); } monitor.worked(1); monitor.setTaskName(Messages.CmsisCodeTemplate_OpeningFileForEditing); getShell().getDisplay().asyncExec(new Runnable() { @Override public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, file, true); } catch (PartInitException e) { e.printStackTrace(); } } }); monitor.worked(1); } }
From source file:com.arm.cmsis.pack.refclient.RefClientPackInstaller.java
License:Open Source License
@Override protected boolean confirmCopyExample(ICpExample example, File destFile, IProject project) { if (!RefClientEnvironmentProvider.isGnuarmeclipseToolchainInstalled()) { String message = "Required GNU ARM C/C++ Cross Toolchain is not installed.\nCopy the example anyway?"; boolean res = MessageDialog.openQuestion(null, "Required Toolchain not Installed", message); if (!res) return false; }/* w w w. ja v a 2 s . com*/ return super.confirmCopyExample(example, destFile, project); }
From source file:com.astra.ses.spell.dev.startup.SetPythonInterpreterCommand.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { /*/*from ww w. j av a 2 s . c o m*/ * Step 1. Resolve if Python interpreter has been set previously */ String nodeQualifier = PydevPlugin.DEFAULT_PYDEV_SCOPE; String prefName = PythonInterpreterManager.PYTHON_INTERPRETER_PATH; String prefPage = SpellPythonInterpreterPage.PAGE_ID; IEclipsePreferences confScope = new InstanceScope().getNode(nodeQualifier); String interpreter = confScope.get(prefName, ""); if (interpreter.isEmpty()) { IEclipsePreferences defScope = new DefaultScope().getNode(nodeQualifier); interpreter = defScope.get(prefName, ""); } if (!interpreter.isEmpty()) { //Python interpretar has been set return null; } /* * Step 2. Open python interpretar wizard */ String title = "Python intrepreter has not beeen set"; String message = "Python interpreter has not been configured yet. " + "It is required for procedures development.\n" + "Would you like to configure it now?\n" + "It can also be configured later through the Window > Preferences menu."; Shell shell = new Shell(); boolean open = MessageDialog.openQuestion(shell, title, message); if (open) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, prefPage, null, null, SWT.NONE); dialog.open(); } return null; }
From source file:com.astra.ses.spell.gui.model.commands.ExportAsRunFile.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./* w ww . ja v a2s.c o m*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class); String instanceId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION); try { IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class); IProcedure proc = null; if (mgr.isLocallyLoaded(instanceId)) { proc = mgr.getProcedure(instanceId); } else { proc = mgr.getRemoteProcedure(instanceId); } List<AsRunFile> toExport = new LinkedList<AsRunFile>(); ExportAsRunFileJob job = new ExportAsRunFileJob(proc); CommandHelper.executeInProgress(job, true, true); if (job.result.equals(CommandResult.SUCCESS)) { toExport.add(job.asrunFile); if (!job.asrunFile.getChildren().isEmpty()) { boolean alsoChildren = MessageDialog.openQuestion(window.getShell(), "Export children ASRUN files", "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?"); if (alsoChildren) { gatherChildAsRunFiles(job.asrunFile, toExport); } } } DirectoryDialog dialog = new DirectoryDialog(window.getShell(), SWT.SAVE); dialog.setMessage("Select directory to export ASRUN file(s) for '" + proc.getProcName() + "'"); dialog.setText("Export ASRUN"); String destination = dialog.open(); if (destination != null && !destination.isEmpty()) { SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport); CommandHelper.executeInProgress(saveJob, true, true); return saveJob.result; } else { return CommandResult.NO_EFFECT; } } catch (Exception ex) { ex.printStackTrace(); return CommandResult.FAILED; } }
From source file:com.astra.ses.spell.gui.replay.dialogs.ExecutionSelectionDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * // ww w .jav a2 s .co m * @param buttonId * The button identifier. **************************************************************************/ @Override protected void buttonPressed(int buttonId) { close(); if (buttonId == IDialogConstants.OK_ID) { if (m_selection != null) { HashMap<String, String> args = new HashMap<String, String>(); args.put(OpenProcedureReplay.ARG_ASRUN, m_selection.getASRUN()); CommandHelper.execute(OpenProcedureReplay.ID, args); } } else if (buttonId == SAVE_ID) { if (m_selection != null) { ExportAsRunFileJob job = new ExportAsRunFileJob(m_selection.getASRUN()); CommandHelper.executeInProgress(job, true, true); List<AsRunFile> toExport = new LinkedList<AsRunFile>(); if (job.result.equals(CommandResult.SUCCESS)) { toExport.add(job.asrunFile); if (!job.asrunFile.getChildren().isEmpty()) { boolean alsoChildren = MessageDialog.openQuestion(getParentShell(), "Save children ASRUN files", "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?"); if (alsoChildren) { gatherChildAsRunFiles(job.asrunFile, toExport); } } } DirectoryDialog dialog = new DirectoryDialog(getParentShell(), SWT.SAVE); dialog.setMessage("Select directory to export ASRUN file(s)"); dialog.setText("Save ASRUN"); String destination = dialog.open(); if (destination != null && !destination.isEmpty()) { SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport); CommandHelper.executeInProgress(saveJob, true, true); } } } }
From source file:com.astra.ses.spell.gui.views.controls.master.executors.ExecutorComposite.java
License:Open Source License
/*************************************************************************** * // w w w. j a v a2 s. c o m **************************************************************************/ private List<String> processMultipleAttach(String[] procIds, String what) { List<String> procedures = new ArrayList<String>(); procedures.addAll(Arrays.asList(procIds)); for (String procId : procIds) { String ma = s_cfg.getProperty(PropertyKey.MULTIPLE_ATTACH); YesNoPromptPref ynp = YesNoPromptPref.valueOf(ma); switch (ynp) { case NO: break; case PROMPT: if (hasRelatedProcedures(procId)) { if (MessageDialog.openQuestion(getShell(), "Multiple attach", "The procedure " + procId + " is related to other procedures running. Do you want to " + what + " them as well?")) { procedures.addAll(getRelatedProcedures(procId)); } } break; case YES: if (hasRelatedProcedures(procId)) { procedures.addAll(getRelatedProcedures(procId)); } break; } } return procedures; }
From source file:com.astra.ses.spell.gui.views.HistoryTreePage.java
License:Open Source License
/*************************************************************************** * // www . j a v a 2s . c o m **************************************************************************/ private void exportAsRunTree() { ExportAsRunFileJob job = new ExportAsRunFileJob(m_model); CommandHelper.executeInProgress(job, true, true); List<AsRunFile> toExport = new LinkedList<AsRunFile>(); if (job.result.equals(CommandResult.SUCCESS)) { toExport.add(job.asrunFile); if (!job.asrunFile.getChildren().isEmpty()) { boolean alsoChildren = MessageDialog.openQuestion(getShell(), "Save children ASRUN files", "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?"); if (alsoChildren) { gatherChildAsRunFiles(job.asrunFile, toExport); } } } DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE); dialog.setMessage("Select directory to export ASRUN file(s)"); dialog.setText("Save ASRUN"); String destination = dialog.open(); if (destination != null && !destination.isEmpty()) { SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport); CommandHelper.executeInProgress(saveJob, true, true); } }
From source file:com.atlassian.clover.eclipse.core.reports.GenerateReportWizard.java
/** * Generate the report as configured by the user. * * @return true if the report was successfully generated, false otherwise. */// w ww.j a v a 2 s. c om @Override public boolean performFinish() { final Shell shell = workbench.getActiveWorkbenchWindow().getShell(); // check if output directory/file exists, and prompt user for overwrite // confirmation. boolean overwrite = true; if (selectReportPage.isHtmlSelected()) { File dir = configureHtmlPage.getOutput(); if (new File(dir, "index.html").exists()) { overwrite = MessageDialog.openQuestion(shell, "Overwrite?", "It appears that a report already exists. Do you want " + "to overwrite it?"); } } else if (selectReportPage.isPdfSelected()) { if (configurePdfPage.getOutput().exists()) { overwrite = MessageDialog.openQuestion(shell, "Overwrite?", "A file with this name already exists. Do you want " + "to overwrite it?"); } } else if (selectReportPage.isXmlSelected()) { if (configureXmlPage.getOutput().exists()) { overwrite = MessageDialog.openQuestion(shell, "Overwrite?", "A file with this name already exists. Do you want " + "to overwrite it?"); } } if (!overwrite) { return false; } //Need to load AWT on the SWT UI thread so as to avoid deadlock //if this occurs in another thread maybeInitialiseAWT(); try { ReportJob reportJob = buildReportJob(); reportJob.setUser(true); reportJob.addJobChangeListener(new ReportJobListener(shell)); reportJob.schedule(); } catch (IOException e) { CloverPlugin.logError("Unable to generate report", e); } return true; }
From source file:com.bb.extensions.plugin.unittests.internal.navigator.MocksUnitTestsNavigatorElement.java
License:Open Source License
/** * Updates the mocks by pulling the newest version from the git repository. * //from w ww. j a v a 2 s . c om * @return true if the mocks have been update and false otherwise. */ public boolean updateMocks() { final boolean success[] = { true }; GitWrapper git = getGitWrapper(); try { if (git.isRepoClean() == false) { final boolean pull[] = { true }; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); pull[0] = (MessageDialog.openQuestion(activeShell, "Mocks Modified", "The mocks git repo contains local modifications, updating may cause conflicts.\n" + "Do you want to continue?")); success[0] = false; } }); if (pull[0] == true) { if (git.pullMocks() == false) { DialogUtils.showErrorDialog("Update Mocks Error", "The git pull operation on the mocks repository failed."); success[0] = false; } } } return success[0]; } finally { if (git != null) { git.closeRepository(); } } }
From source file:com.bdaum.juploadr.uploadapi.locrrest.RestLocrApi.java
License:Open Source License
private static boolean showUnfinishedUploadErrorMessage() { StringBuffer errorMessage = new StringBuffer(); errorMessage.append(Messages.getString("juploadr.locrrest.error.after.upload")); //$NON-NLS-1$ Iterator<Class<? extends PostUploadAction>> failureClasses = unfinishedActions.keySet().iterator(); while (failureClasses.hasNext()) { List<PostUploadAction> actions = getFailedActions(failureClasses.next()); if (actions != null) { Iterator<PostUploadAction> actionIter = actions.iterator(); while (actionIter.hasNext()) { PostUploadAction method = actionIter.next(); errorMessage.append(Messages.getString("juploadr.locrrest.failed.to")); //$NON-NLS-1$ errorMessage.append(method.getErrorText()); errorMessage.append("\n"); //$NON-NLS-1$ }//from w w w . java2 s . c o m } } errorMessage.append(Messages.getString("juploadr.locrrest.option.retry")); //$NON-NLS-1$ return MessageDialog.openQuestion(null, errorMessage.toString(), Messages.getString("RestLocrApi.actions_failed")); //$NON-NLS-1$ }