List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:bndtools.editor.BndEditor.java
License:Open Source License
public Promise<IStatus> resolveRunBundles(IProgressMonitor monitor, boolean onSave) { final Shell shell = getEditorSite().getShell(); final IFile file = ResourceUtil.getFile(getEditorInput()); if (file == null) { MessageDialog.openError(shell, "Resolution Error", "Unable to run resolution because the file is not in the workspace."); reallySave(monitor);//from ww w . ja v a 2 s . com return Central.promiseFactory().resolved(Status.CANCEL_STATUS); } Job loadWorkspaceJob = new Job("Loading workspace...") { @Override protected IStatus run(IProgressMonitor monitor) { if (monitor == null) monitor = new NullProgressMonitor(); monitor.beginTask("Loading workspace", 2); try { Central.getWorkspace(); monitor.worked(1); modelReady.getValue(); return Status.OK_STATUS; } catch (Exception e) { return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Failed to initialize workspace.", e); } finally { monitor.done(); } } }; final UIJob runResolveInUIJob = new UIJob("Resolve") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { // Make sure all the parts of this editor page have committed their // dirty state to the model for (Object pageObj : pages) { if (pageObj instanceof IFormPage) { IFormPage formPage = (IFormPage) pageObj; IManagedForm form = formPage.getManagedForm(); if (form != null) { IFormPart[] formParts = form.getParts(); for (IFormPart formPart : formParts) { if (formPart.isDirty()) formPart.commit(false); } } } } if (sourcePage.isActive() && sourcePage.isDirty()) { sourcePage.commit(false); } // Create resolver job and pre-validate final ResolveJob job = new ResolveJob(model); IStatus validation = job.validateBeforeRun(); if (!validation.isOK()) { if (onSave) reallySave(monitor); return validation; } // Add operation to perform at the end of resolution (i.e. display // results and actually save the file) final UIJob completionJob = new UIJob(shell.getDisplay(), "Display Resolution Results") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { ResolutionResult result = job.getResolutionResult(); ResolutionWizard wizard = new ResolutionWizard(model, file, result); if (onSave) { // We are in auto-resolve-on-save, only show the dialog if there is a problem wizard.setAllowFinishUnresolved(true); wizard.setPreserveRunBundlesUnresolved(true); if (result.getOutcome() != ResolutionResult.Outcome.Resolved) { WizardDialog dialog = new DuringSaveWizardDialog(shell, wizard); dialog.create(); dialog.setErrorMessage( "Resolve Failed! Saving now will not update the Run Bundles."); if (dialog.open() == Window.OK) reallySave(monitor); } else { wizard.performFinish(); reallySave(monitor); } } else { // This is an interactive resolve, always show the dialog boolean dirtyBeforeResolve = isDirty(); WizardDialog dialog = new WizardDialog(shell, wizard); if (dialog.open() == Window.OK && !dirtyBeforeResolve) { // save changes immediately if there were no unsaved changes before the resolve reallySave(monitor); } } return Status.OK_STATUS; } }; job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { completionJob.schedule(); } }); // Start job job.setUser(true); job.schedule(); return Status.OK_STATUS; } }; runResolveInUIJob.setUser(true); return JobUtil.chainJobs(loadWorkspaceJob, runResolveInUIJob); }
From source file:bndtools.editor.contents.PrivatePackagesPart.java
License:Open Source License
private void doAddPackages() { // Prepare the exclusion list based on existing private packages final Set<String> packageNameSet = new HashSet<String>(packages); // Create a filter from the exclusion list and packages matching // "java.*", which must not be included in a bundle IPackageFilter filter = new IPackageFilter() { @Override//w w w. j a v a2 s . c om public boolean select(String packageName) { return !packageName.equals("java") && !packageName.startsWith("java.") && !packageNameSet.contains(packageName); } }; IFormPage page = (IFormPage) getManagedForm().getContainer(); IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow(); // Prepare the package lister from the Java project IJavaProject javaProject = getJavaProject(); if (javaProject == null) { MessageDialog.openError(getSection().getShell(), "Error", "Cannot add packages: unable to find a Java project associated with the editor input."); return; } IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window); // Create and open the dialog PackageSelectionDialog dialog = new PackageSelectionDialog(getSection().getShell(), packageLister, filter, "Select new packages to include in the bundle."); dialog.setSourceOnly(true); dialog.setMultipleSelection(true); if (dialog.open() == Window.OK) { Object[] results = dialog.getResult(); List<String> added = new LinkedList<String>(); // Select the results for (Object result : results) { String newPackageName = (String) result; if (packages.add(newPackageName)) { added.add(newPackageName); } } // Update the model and view if (!added.isEmpty()) { viewer.add(added.toArray()); markDirty(); } } }
From source file:bndtools.editor.project.BuildSectionPart.java
License:Open Source License
void createSection(final Section section, FormToolkit toolkit) { section.setText("Build"); Composite composite = toolkit.createComposite(section); section.setClient(composite);/*from ww w . ja va 2 s . c om*/ ImageHyperlink lnkBuild = toolkit.createImageHyperlink(composite, SWT.LEFT); lnkBuild.setText("Build the Bundle"); lnkBuild.setImage(jarImg); lnkBuild.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { IFormPage page = (IFormPage) getManagedForm().getContainer(); FormEditor editor = page.getEditor(); if (EditorUtils.saveEditorIfDirty(editor, "Build Bundle", "The editor content must be saved before building.")) { buildBundleAction.run(null); } else { MessageDialog.openError(section.getShell(), "Build Bundle", "Bundle not built due to error during save."); } } }); composite.setLayout(new GridLayout(1, false)); }
From source file:br.ufam.pnmp.ezrealtime.exporter.ui.action.EZRealtime2PnmlAction.java
License:Open Source License
public void run(IAction action) { System.out.println("Export into PNML - start."); StructuredSelection selection = (StructuredSelection) this.activePart.getSite().getSelectionProvider() .getSelection();//from ww w . ja va 2 s .c om org.eclipse.core.internal.resources.File file = (org.eclipse.core.internal.resources.File) selection .getFirstElement(); String pathToRealtimeFile = file.getLocation().toFile().getAbsolutePath(); final String PNML_FILE_NAME = FileHelper.getPnmlFileSelected(selection); EZRealtimeSpec realtimeSystem; try { realtimeSystem = EZRealtimeParser.getInstance().parse(pathToRealtimeFile); java.io.File pnmlFile = new java.io.File(PNML_FILE_NAME); if (pnmlFile.exists() && pnmlFile.isFile()) { System.out.println("Deleting pnml file..."); pnmlFile.delete(); } EZRealtime2PnmlExport exportExample = new EZRealtime2PnmlExport(); exportExample.realtimeSpec2Pnml(realtimeSystem, PNML_FILE_NAME); } catch (IOException e1) { e1.printStackTrace(); } catch (PnmlException e1) { e1.printStackTrace(); } System.out.println("Export into PNML done."); Shell shell = new Shell(); try { Util.refreshWorkspace(); } catch (CoreException e) { MessageDialog.openError(shell, "Real Time Translator", "Unable do refresh the workspace.\nPlease refresh it manually"); } }
From source file:br.ufam.pnmp.ezrealtime.exporter.ui.action.Pnml2DotAction.java
License:Open Source License
public void run(IAction action) { System.out.println("Pnml2DotAction.run()"); StructuredSelection selection = (StructuredSelection) this.activePart.getSite().getSelectionProvider() .getSelection();// www. j a v a 2 s . com final String PNML_FILE_NAME = FileHelper.getPnmlFileSelected(selection); Thread t = new Thread(new Runnable() { public void run() { doExport(); } private synchronized void doExport() { try { Pnml2DotExporter exportExample = new Pnml2DotExporter(); exportExample.pnml2Dot(PNML_FILE_NAME); } catch (PnmlException e1) { e1.printStackTrace(); } } }); t.start(); Shell shell = new Shell(); try { Util.refreshWorkspace(); } catch (CoreException e) { MessageDialog.openError(shell, "DOT Translator", "Unable do refresh the workspace.\nPlease refresh it manually"); } System.out.println("Export into DOT done."); }
From source file:br.ufmg.dcc.tabuleta.actions.SaveAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.IAction#run() *///www .j av a 2 s. co m public void run() { IFile lFile = Tabuleta.getDefault().getDefaultResource(); if (lFile == null) { new SaveAsAction(aView).run(); return; } try { lFile.getParent().refreshLocal(IResource.DEPTH_ONE, null); } catch (CoreException lException) { ProblemManager.reportException(lException); } catch (OperationCanceledException lException) { ProblemManager.reportException(lException); } if (!lFile.exists()) { new SaveAsAction(aView).run(); return; } try { ModelWriter lWriter = new ModelWriter(Tabuleta.getDefault().getConcernModel()); lWriter.write(lFile); } catch (ModelIOException lException) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Tabuleta.getResourceString("actions.SaveAction.ErrorLabel"), Tabuleta.getResourceString("actions.SaveAction.ErrorMessage") + " " + lException.getMessage()); return; } // TODO: Clean this up. The save actions should not know about the view. Tabuleta.getDefault().resetDirty(); if (aView != null) { aView.updateActionState(); } }
From source file:br.ufmg.dcc.tabuleta.actions.SaveAsAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.IAction#run() *///from w w w . j a v a 2s .c o m public void run() { IFile lFile = null; SaveAsDialog lDialog = new ConcernModelSaveAsDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); IFile lCurrentFile = Tabuleta.getDefault().getDefaultResource(); if (lCurrentFile != null) { lDialog.setOriginalFile(lCurrentFile); } lDialog.open(); if (lDialog.getReturnCode() == Window.CANCEL) { return; } IPath lPath = lDialog.getResult(); lPath = addCMFileExtension(lPath); IWorkspace lWorkspace = ResourcesPlugin.getWorkspace(); lFile = lWorkspace.getRoot().getFile(lPath); if (!lFile.exists()) { try { lFile.create(null, true, null); } catch (CoreException lException) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Tabuleta.getResourceString("actions.SaveAsAction.ErrorLabel"), Tabuleta.getResourceString("actions.SaveAsAction.ErrorMessage") + " " + lException.getMessage()); return; } } try { Tabuleta.getDefault().setDefaultResource(lFile); ModelWriter lWriter = new ModelWriter(Tabuleta.getDefault().getConcernModel()); lWriter.write(lFile); } catch (ModelIOException lException) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Tabuleta.getResourceString("actions.SaveAsAction.ErrorLabel"), Tabuleta.getResourceString("actions.SaveAsAction.ErrorMessage") + " " + lException.getMessage()); return; } Tabuleta.getDefault().resetDirty(); if (aView != null) { aView.updateActionState(); } }
From source file:br.ufmg.dcc.tabuleta.ui.ProblemManager.java
License:Open Source License
/** * Reports an exception in a dialog and logs the exception. The * exception dialog does not contain the stack strace details. * @param pException The exception to report. *///from w ww .j a v a 2 s . c o m public static void reportExceptionMessage(Exception pException) { StackTraceElement[] lStackElements = pException.getStackTrace(); IStatus[] lStatuses = new IStatus[lStackElements.length + 1]; lStatuses[0] = new Status(IStatus.ERROR, Tabuleta.ID_PLUGIN, IStatus.OK, pException.getClass().getName(), pException); for (int lI = 0; lI < lStackElements.length; lI++) { lStatuses[lI + 1] = new Status(IStatus.ERROR, Tabuleta.ID_PLUGIN, IStatus.OK, " " + lStackElements[lI].toString(), pException); } String lMessage = Tabuleta.getResourceString("ui.ProblemManager.DefaultMessage"); final String lTitle = Tabuleta.getResourceString("ui.ProblemManager.DialogTitle"); if (pException.getMessage() != null) { lMessage = pException.getMessage(); } final String lMessage2 = lMessage; MultiStatus lStatus = new MultiStatus(Tabuleta.ID_PLUGIN, IStatus.OK, lStatuses, lMessage2, pException); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell[] lShells = PlatformUI.getWorkbench().getDisplay().getShells(); for (Shell lNext : lShells) { MessageDialog.openError(lNext, lTitle, lMessage2); break; } } }); Tabuleta.getDefault().getLog().log(lStatus); }
From source file:br.ufscar.dc.Dialogs.java
License:Open Source License
/** * Helper method for a standard ERROR MessageDialog * /*from w w w. j ava 2s. c o m*/ * @param message * Error message to display to user */ public static void errorDialogMessage(final String message) { runOnDisplayThread(new Runnable() { public void run() { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", message); } }); }
From source file:br.unb.cic.rtgoretoprism.action.JadexGUIAction.java
License:Open Source License
/** * Show action dialog/*from ww w .j a v a2 s . c om*/ * * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { //get the path to the Jadex library directory String bx = AgentTemplateCreatorPlugin.getDefault().getPluginPreferences() .getString(AgentTemplateCreatorPlugin.JADEX_BASE_PATH) + "/"; //construct the required CLASSPATH path (at least the one for //Jade 3.4 and Jadex 0.96). //Note: this should be really generalized // String libs = ".;" + // bx + "jadeTools.jar" + ";" + // bx + "jade.jar" + ";" + // bx + "iiop.jar" + ";" + // bx + "http.jar" + ";" + // bx + "commons-codec-1.3.jar" + ";" + // bx + "jadex_rt.jar" + ";" + // bx + "jadex_jadeadapter.jar"; String libs = ".;\"" + bx + "jadeTools.jar" + "\";\"" + bx + "jade.jar" + "\";\"" + bx + "iiop.jar" + "\";\"" + bx + "http.jar" + "\";\"" + bx + "commons-codec-1.3.jar" + "\";\"" + bx + "jadex_rt.jar" + "\";\"" + bx + "jadex_jadeadapter.jar\""; //the command to execute the platform gui String cmd = "java -cp " + libs + " jade.Boot rma:jadex.adapter.jade.tools.rma.rma"; try { //get the console for the platform MessageConsole myConsole = ConsoleUtil.findConsole("Jadex platform"); MessageConsoleStream out = myConsole.newMessageStream(); //activate on write activity out.setActivateOnWrite(true); //run the process Spawn spawn = new Spawn(cmd, out, out); spawn.start(); } catch (Exception e) { MessageDialog.openError(window.getShell(), "Error starting the Jadex platform GUI", e.toString()); } }