List of usage examples for org.eclipse.jface.dialogs ErrorDialog openError
public static int openError(Shell parent, String dialogTitle, String message, IStatus status)
From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsCreationWizard.java
License:Open Source License
/** * @generated// ww w .j a v a 2 s.com */ public boolean performFinish() { IRunnableWithProgress op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { diagram = ClassdiagramsDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor); if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { ClassdiagramsDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { ErrorDialog.openError(getContainer().getShell(), Messages.ClassdiagramsCreationWizardOpenEditorError, null, e.getStatus()); } } } }; try { getContainer().run(false, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), Messages.ClassdiagramsCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus()); } else { ClassdiagramsDiagramEditorPlugin.getInstance().logError("Error creating diagram", //$NON-NLS-1$ e.getTargetException()); } return false; } return diagram != null; }
From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsDiagramEditor.java
License:Open Source License
/** * @generated/*from w w w. jav a2 s . co m*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ClassdiagramsDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ClassdiagramsDiagramEditor_SaveAsErrorTitle, Messages.ClassdiagramsDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ClassdiagramsDiagramEditor_SaveErrorTitle, Messages.ClassdiagramsDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.eventb.statemachines.diagram.part.StatemachinesCreationWizard.java
License:Open Source License
/** * @generated//from w ww . j a va 2s . c o m */ public boolean performFinish() { IRunnableWithProgress op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { diagram = StatemachinesDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor); if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { StatemachinesDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { ErrorDialog.openError(getContainer().getShell(), Messages.StatemachinesCreationWizardOpenEditorError, null, e.getStatus()); } } } }; try { getContainer().run(false, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), Messages.StatemachinesCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus()); } else { StatemachinesDiagramEditorPlugin.getInstance().logError("Error creating diagram", //$NON-NLS-1$ e.getTargetException()); } return false; } return diagram != null; }
From source file:ac.soton.eventb.statemachines.diagram.part.StatemachinesDiagramEditor.java
License:Open Source License
/** * @generated/* ww w.j a va2 s.co m*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.StatemachinesDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.StatemachinesDiagramEditor_SaveAsErrorTitle, Messages.StatemachinesDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.StatemachinesDiagramEditor_SaveErrorTitle, Messages.StatemachinesDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.fmusim.components.diagram.part.ComponentsCreationWizard.java
License:Open Source License
/** * @generated// w w w . j a va 2 s. c om */ public boolean performFinish() { IRunnableWithProgress op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { diagram = ComponentsDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor); if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { ComponentsDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { ErrorDialog.openError(getContainer().getShell(), Messages.ComponentsCreationWizardOpenEditorError, null, e.getStatus()); } } } }; try { getContainer().run(false, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), Messages.ComponentsCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus()); } else { ComponentsDiagramEditorPlugin.getInstance().logError("Error creating diagram", //$NON-NLS-1$ e.getTargetException()); } return false; } return diagram != null; }
From source file:ac.soton.fmusim.components.diagram.part.ComponentsDiagramEditor.java
License:Open Source License
/** * @generated/* ww w.j a va 2s.com*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ComponentsDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ComponentsDiagramEditor_SaveAsErrorTitle, Messages.ComponentsDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ComponentsDiagramEditor_SaveErrorTitle, Messages.ComponentsDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.multisim.diagram.part.MultisimCreationWizard.java
License:Open Source License
/** * @generated/*from w w w.j a v a 2s .c o m*/ */ public boolean performFinish() { IRunnableWithProgress op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { diagram = MultisimDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), monitor); if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { MultisimDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { ErrorDialog.openError(getContainer().getShell(), Messages.MultisimCreationWizardOpenEditorError, null, e.getStatus()); } } } }; try { getContainer().run(false, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), Messages.MultisimCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus()); } else { MultisimDiagramEditorPlugin.getInstance().logError("Error creating diagram", //$NON-NLS-1$ e.getTargetException()); } return false; } return diagram != null; }
From source file:ac.soton.multisim.diagram.part.MultisimDiagramEditor.java
License:Open Source License
/** * @generated/* w w w. j a v a 2 s. co m*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.MultisimDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.MultisimDiagramEditor_SaveAsErrorTitle, Messages.MultisimDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.MultisimDiagramEditor_SaveErrorTitle, Messages.MultisimDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:ac.soton.multisim.ui.commands.ValidateCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event); // reuse GMF-generated validate action from the diagram Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run();//from ww w .j a v a 2 s .co m // show validation results IFile file = WorkspaceSynchronizer .getFile(((IDiagramWorkbenchPart) diagramEditor).getDiagram().eResource()); List<IMarker> markers = null; try { markers = ValidateAction.getErrorMarkers(file); } catch (CoreException e) { throw new ExecutionException("Validation result retrieval failed", e); } if (markers.isEmpty()) { MessageDialog.openInformation(diagramEditor.getSite().getShell(), "Validation Information", "Validation completed successfully"); } else { final String PID = MultisimDiagramEditorPlugin.ID; MultiStatus errors = new MultiStatus(PID, 1, "Diagram constraints violated", null); for (IMarker marker : markers) { errors.add( SimulationStatus.createErrorStatus(marker.getAttribute(IMarker.MESSAGE, "unknown error"))); } ErrorDialog.openError(diagramEditor.getSite().getShell(), "Validation Problems", "Problems found during validation", errors); } return null; }
From source file:ac.soton.rms.components.diagram.part.ComponentsCreationWizard.java
License:Open Source License
/** * @generated/*w ww. j a v a2 s . c o m*/ */ public boolean performFinish() { IRunnableWithProgress op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { diagram = ComponentsDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), monitor); if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { ComponentsDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { ErrorDialog.openError(getContainer().getShell(), Messages.ComponentsCreationWizardOpenEditorError, null, e.getStatus()); } } } }; try { getContainer().run(false, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), Messages.ComponentsCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus()); } else { ComponentsDiagramEditorPlugin.getInstance().logError("Error creating diagram", //$NON-NLS-1$ e.getTargetException()); } return false; } return diagram != null; }