List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.
Click Source Link
From source file:org.eclipse.emf.ecp.ecoreeditor.internal.CreateDialog.java
License:Open Source License
@Override protected void okPressed() { getParentShell().forceFocus();// ww w.j a v a 2 s.c om final Diagnostic result = Diagnostician.INSTANCE.validate(newObject); if (result.getSeverity() == Diagnostic.OK) { super.okPressed(); } else { // Get the error count and create an appropriate Error message: final int errorCount = result.getChildren().size(); String errorMessage = String.format( "%d %s occured while analyzing your inputs. The following errors were found:\r\n", errorCount, errorCount == 1 ? "error" : "errors"); int messageCount = 1; for (final Diagnostic d : result.getChildren()) { errorMessage += String.format("\r\n%d. %s", messageCount++, d.getMessage()); } MessageDialog.open(MessageDialog.ERROR, getParentShell(), "Error", errorMessage, SWT.NONE); } }
From source file:org.eclipse.emf.ecp.view.internal.editor.controls.EditableEReferenceLabelControlSWTRenderer.java
License:Open Source License
/** * Shows an error message dialog indicating a failed value link due to an exception. * * @param shell The parent {@link Shell} of the message dialog * @param ex The {@link Exception} causing the failure *//*from w ww. j a v a2s . c o m*/ protected void showLinkValueFailedMessageDialog(Shell shell, final Exception ex) { final MessageDialog dialog = new MessageDialog(shell, "Link Value Failed", null, //$NON-NLS-1$ "The value could not be linked due to an exception: " + ex.getMessage(), MessageDialog.ERROR, //$NON-NLS-1$ new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY) }, 0); new ECPDialogExecutor(dialog) { @Override public void handleResult(int codeResult) { // no op } }.execute(); }
From source file:org.eclipse.emf.ecp.view.model.internal.preview.e3.views.PreviewView.java
License:Open Source License
/** * Loads an xmi into the preview./*from w w w. j av a2 s . c o m*/ */ private void loadSampleData() { if (view == null || view.getRootEClass() == null) { return; } final FileDialog dialog = new FileDialog(parent.getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] { "*.xmi" }); //$NON-NLS-1$ final String result = dialog.open(); if (result == null) { return; } final ResourceSet rs = new ResourceSetImpl(); final AdapterFactoryEditingDomain domain = new AdapterFactoryEditingDomain( new ComposedAdapterFactory(new AdapterFactory[] { new CustomReflectiveItemProviderAdapterFactory(), new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE) }), new BasicCommandStack(), rs); rs.eAdapters().add(new AdapterFactoryEditingDomain.EditingDomainProvider(domain)); final Resource resource = rs.createResource(URI.createFileURI(result)); try { resource.load(null); } catch (final IOException ex) { // do nothing - exceptions treated below } if (!resource.getContents().isEmpty()) { sampleData = resource.getContents().get(0); if (sampleData != null && sampleData.eClass() == view.getRootEClass()) { render(); } else { new MessageDialog(parent.getShell(), Messages.PreviewView_WrongInputTypeError, null, String.format(Messages.PreviewView_WrongInputTypeErrorDetails, sampleData.eClass().getName(), view.getRootEClass().getName()), MessageDialog.ERROR, new String[] { Messages.PreviewView_OK }, 0).open(); sampleData = null; } } else { sampleData = null; new MessageDialog(parent.getShell(), Messages.PreviewView_WrongInputFileContentError, null, Messages.PreviewView_WrongInputFileContentErrorDetails, MessageDialog.ERROR, new String[] { Messages.PreviewView_OK }, 0).open(); } }
From source file:org.eclipse.emfforms.internal.editor.ui.CreateDialog.java
License:Open Source License
@Override protected void okPressed() { getParentShell().forceFocus();/* w w w. j a v a2 s .c o m*/ final Diagnostic result = Diagnostician.INSTANCE.validate(newObject); if (result.getSeverity() == Diagnostic.OK) { super.okPressed(); } else { // Get the error count and create an appropriate Error message: final int errorCount = result.getChildren().size(); final StringBuilder sb = new StringBuilder(); sb.append(errorCount); sb.append(" "); sb.append(errorCount == 1 ? "error" : "errors"); sb.append(" occured while analyzing your inputs. The following errors were found:\r\n"); int messageCount = 1; for (final Diagnostic d : result.getChildren()) { sb.append("\r\n"); sb.append(messageCount++); sb.append(". "); sb.append(d.getMessage()); } final String errorMessage = sb.toString(); MessageDialog.open(MessageDialog.ERROR, getParentShell(), "Error", errorMessage, SWT.NONE); } }
From source file:org.eclipse.gef.examples.ediagram.editor.EDiagramEditor.java
License:Open Source License
public void doSave(IProgressMonitor monitor) { ArrayList saveFailed = new ArrayList(); for (Iterator iter = rsrcSet.getResources().iterator(); iter.hasNext();) { Resource rsrc = (Resource) iter.next(); try {/* w w w. jav a 2 s. c o m*/ if (!isReadOnly(rsrc)) rsrc.save(Collections.EMPTY_MAP); } catch (Exception e) { EDiagramPlugin.INSTANCE.log(e); saveFailed.add(rsrc); } } if (saveFailed.isEmpty()) getCommandStack().markSaveLocation(); else { String error = "The following resources could not be saved:\n"; for (Iterator iter = saveFailed.iterator(); iter.hasNext();) error += '\n' + ((Resource) iter.next()).getURI().toString(); error += "\n\nSee the error log for details."; MessageDialog dialog = new MessageDialog(getGraphicalControl().getShell(), "Errors Detected", null, error, MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); } }
From source file:org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.actions.GenerateExtendedCCSLFile.java
License:Open Source License
@Override protected String getTransformationURI() { //use the extension of the model file String fileExtension = modelUriString.substring(modelUriString.lastIndexOf('.') + 1, modelUriString.length());//from w ww.ja v a 2 s .com List<ConcurrentLanguageDefinitionExtension> applicableLanguageDefinitions = new ArrayList<ConcurrentLanguageDefinitionExtension>(); for (ConcurrentLanguageDefinitionExtension lde : ConcurrentLanguageDefinitionExtensionPoint .getSpecifications()) { // select only applicable languages for the file extension if (lde.getFileExtensions().contains(fileExtension)) { applicableLanguageDefinitions.add(lde); } } ConcurrentLanguageDefinitionExtension selectedLanguageDefinition = null; if (applicableLanguageDefinitions.size() == 0) { MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "No applicable language found", null, "No applicable language found for file extension " + fileExtension + ".", MessageDialog.ERROR, new String[0], -1); dialog.open(); return null; } else if (applicableLanguageDefinitions.size() == 1) { selectedLanguageDefinition = applicableLanguageDefinitions.get(0); } else { ListDialog dialog = new ListDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.setContentProvider(new ArrayContentProvider()); dialog.setTitle("Language selection"); dialog.setMessage("Which language do you want to use"); dialog.setLabelProvider(new ArrayLabelProvider()); List<Object[]> input = new ArrayList<Object[]>(); for (LanguageDefinitionExtension lde : applicableLanguageDefinitions) { input.add(new Object[] { lde.getName(), lde }); } dialog.setInput(input); // user pressed cancel if (dialog.open() != Window.OK) { return null; } Object[] result = dialog.getResult(); if (result.length == 0) { MessageDialog dialog2 = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Please select a language", null, "Please select a language for file extension " + fileExtension + ".", MessageDialog.ERROR, new String[0], -1); dialog2.open(); return null; } Object[] selected = ((Object[]) result[0]); selectedLanguageDefinition = (ConcurrentLanguageDefinitionExtension) selected[1]; } String uri = selectedLanguageDefinition.getQVTOPath(); if (!uri.startsWith("platform:/plugin")) uri = "platform:/plugin" + uri; return uri; }
From source file:org.eclipse.gmf.runtime.diagram.ui.render.actions.CopyToImageAction.java
License:Open Source License
/** * Displays the dialog and performs <code>OutOfMemoryError</code> checking * //from w ww. ja va2 s.c om * @param dialog the copy to image dialog */ private void runCopyToImageUI(CopyToImageDialog dialog) { if (dialog.open() == CopyToImageDialog.CANCEL) { return; } if (!overwriteExisting()) { return; } Trace.trace(DiagramUIRenderPlugin.getInstance(), "Copy Diagram to " + dialog.getDestination().toOSString() //$NON-NLS-1$ + " as " + dialog.getImageFormat().toString()); //$NON-NLS-1$ final MultiStatus status = new MultiStatus(DiagramUIRenderPlugin.getPluginId(), DiagramUIRenderStatusCodes.OK, DiagramUIRenderMessages.CopyToImageAction_Label, null); IRunnableWithProgress runnable = createRunnable(status); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( Display.getCurrent().getActiveShell()); try { progressMonitorDialog.run(false, true, runnable); } catch (InvocationTargetException e) { Log.warning(DiagramUIRenderPlugin.getInstance(), DiagramUIRenderStatusCodes.IGNORED_EXCEPTION_WARNING, e.getTargetException().getMessage(), e.getTargetException()); if (e.getTargetException() instanceof OutOfMemoryError) { if (dialog.exportToHTML()) { openErrorDialog(DiagramUIRenderMessages.CopyToImageAction_outOfMemoryMessage); } else { if (new MessageDialog(dialog.getShell(), DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_title, null, DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_message, MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) .open() == 0) { runCopyToImageUI(dialog); } } } else if (e.getTargetException() instanceof SWTError) { /** * SWT returns an out of handles error when processing large * diagrams */ if (dialog.exportToHTML()) { openErrorDialog(DiagramUIRenderMessages.CopyToImageAction_outOfMemoryMessage); } else { if (new MessageDialog(dialog.getShell(), DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_title, null, DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_message, MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) .open() == 0) { runCopyToImageUI(dialog); } } } else { openErrorDialog(e.getTargetException().getMessage()); } return; } catch (InterruptedException e) { /* the user pressed cancel */ Log.warning(DiagramUIRenderPlugin.getInstance(), DiagramUIRenderStatusCodes.IGNORED_EXCEPTION_WARNING, e.getMessage(), e); } if (!status.isOK()) { openErrorDialog(status.getChildren()[0].getMessage()); } }
From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java
License:Open Source License
private static String[] getButtonLabels(final int kind) { String[] dialogButtonLabels;/* www. j av a 2s . co m*/ switch (kind) { case MessageDialog.ERROR: case MessageDialog.INFORMATION: case MessageDialog.WARNING: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL }; break; } case MessageDialog.CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } case MessageDialog.QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL }; break; } case MessageDialog.QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); } } return dialogButtonLabels; }
From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java
License:Open Source License
public static void openError(final Shell parent, final String title, final String message, final DialogCallback callback) { open(MessageDialog.ERROR, parent, title, message, callback); }
From source file:org.eclipse.jst.j2ee.internal.actions.J2EEDeployAction.java
License:Open Source License
public boolean checkEnabled(Shell shell) { try {/*from w ww . j a va 2 s .co m*/ DeployerRegistry reg = DeployerRegistry.instance(); List components = DeployerRegistry.getSelectedModules(selection.toArray()); for (int i = 0; i < components.size(); i++) { IVirtualComponent component = (IVirtualComponent) components.get(i); IProject proj = component.getProject(); if (proj == null) { displayMessageDialog(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_FOUND"), shell); //$NON-NLS-1$ return false; } IRuntime runtime = J2EEProjectUtilities.getServerRuntime(proj); if (runtime == null) { String message = MessageFormat.format( J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_NOT_FOUND"), //$NON-NLS-1$ new Object[] { proj.getName() }); RuntimeSelectionDialog selectionDialog = new RuntimeSelectionDialog(shell, J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"), //$NON-NLS-1$ null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0, proj); selectionDialog.open(); runtime = J2EEProjectUtilities.getServerRuntime(proj); if (runtime == null) return false; } List visitors = reg.getDeployModuleExtensions(proj, runtime); if (visitors.isEmpty()) { displayMessageDialog( MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_SUPPORTED"), //$NON-NLS-1$ new Object[] { proj.getName() }), shell); return false; } } return true; } catch (CoreException e) { J2EEUIPlugin.logError(e); } return false; }