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.efaps.eclipse.wizards.CopyCIWizardPage.java
License:Apache License
public void createNewFiles(final String _fileNames) { final String[] filenames = _fileNames.split("\n"); for (final String fileNameTmp : filenames) { if (fileNameTmp != null && !fileNameTmp.isEmpty()) { this.fileName = fileNameTmp.trim(); final IPath containerPath = getContainerFullPath(); final IPath newFilePath = containerPath.append(fileNameTmp.trim() + ".xml"); final IFile newFileHandle = createFileHandle(newFilePath); final InputStream initialContents = getInitialContents(); final IRunnableWithProgress op = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { final CreateFileOperation op = new CreateFileOperation(newFileHandle, null, initialContents, IDEWorkbenchMessages.WizardNewFileCreationPage_title); try { // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901 // directly execute the operation so that the undo state is // not preserved. Making this undoable resulted in too many // accidental file deletions. op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); } catch (final ExecutionException e) { getContainer().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (e.getCause() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle, null, ((CoreException) e.getCause()).getStatus()); } else { IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$ MessageDialog.openError(getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind( IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getCause().getMessage())); }/*from ww w . ja v a 2s. com*/ } }); } } }; try { getContainer().run(true, true, op); } catch (final InterruptedException e) { } catch (final InvocationTargetException e) { IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$ MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getTargetException().getMessage()), SWT.SHEET); } } } this.fileName = null; }
From source file:org.emftext.language.xpath2.resource.xpath2.ui.Xpath2UIPlugin.java
License:Open Source License
public static void showErrorDialog(final String title, final String message) { Display.getDefault().asyncExec(new Runnable() { public void run() { Shell parent = new Shell(); MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { };//from w w w . j av a2s . c om dialog.open(); } }); }
From source file:org.emftext.runtime.ui.EMFTextRuntimeUIPlugin.java
License:Open Source License
public void showErrorDialog(final String title, final String message) { Display.getDefault().asyncExec(new Runnable() { public void run() { Shell parent = new Shell(); MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { };//from ww w . java 2 s. com dialog.open(); } }); }
From source file:org.entirej.framework.plugin.preferences.EntirejConnectionPreferencePage.java
License:Apache License
/** * Creates the field editors. Field editors are abstractions of the common * GUI blocks needed to manipulate various types of preferences. Each field * editor knows how to save and restore itself. *//*from w ww .j av a 2 s .com*/ @Override public void createFieldEditors() { if (getElement() instanceof IProject) { addField(new LabelFieldEditor(getFieldEditorParent(), "Database Settings:")); addField(new LabelFieldEditor(getFieldEditorParent(), "")); final StringFieldEditor driver = new StringFieldEditor(EntireJFrameworkPlugin.P_DBDRIVER, " &Driver:", getFieldEditorParent()); addField(driver); final StringFieldEditor url = new StringFieldEditor(EntireJFrameworkPlugin.P_URL, " &Connection URL:", getFieldEditorParent()); addField(url); final StringFieldEditor schema = new StringFieldEditor(EntireJFrameworkPlugin.P_SCHEMA, " &Schema:", getFieldEditorParent()); addField(schema); final StringFieldEditor user = new StringFieldEditor(EntireJFrameworkPlugin.P_USERNAME, " User&name:", getFieldEditorParent()); addField(user); final StringFieldEditor password = new StringFieldEditor(EntireJFrameworkPlugin.P_PASSWORD, " P&assword:", getFieldEditorParent()); password.getTextControl(getFieldEditorParent()).setEchoChar('*'); addField(password); final IProject project = (IProject) getElement(); new Label(getFieldEditorParent(), SWT.NONE); final Button test = new Button(getFieldEditorParent(), SWT.PUSH); test.setText("Validate"); addField(new LabelFieldEditor(getFieldEditorParent(), "") { @Override public void setEnabled(boolean enabled, Composite parent) { super.setEnabled(enabled, parent); test.setEnabled(enabled); } @Override public int getNumberOfControls() { return 1; } }); new Label(getFieldEditorParent(), SWT.NONE); test.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { final String driverV = driver.getStringValue(); final String urlV = url.getStringValue(); final String schemaV = schema.getStringValue(); final String userV = user.getStringValue(); final String passV = password.getStringValue(); final IRunnableWithProgress activation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Validating connection", 2); monitor.worked(1); try { validConnection(driverV, urlV, schemaV, userV, passV, project); final Display display = EJCorePlugin.getStandardDisplay(); display.asyncExec(new Runnable() { public void run() { // Validation error MessageDialog dialog = new MessageDialog(getShell(), // "Validation", // null, "Successfully validated!", MessageDialog.INFORMATION, // new String[] { IDialogConstants.OK_LABEL }, // 0); dialog.open(); } }); } catch (EJDevFrameworkException e) { final String error = e.getMessage(); final Display display = EJCorePlugin.getStandardDisplay(); display.asyncExec(new Runnable() { public void run() { // Validation error MessageDialog dialog = new MessageDialog(getShell(), // "Validation error", // null, error, MessageDialog.ERROR, // new String[] { IDialogConstants.OK_LABEL }, // 0); dialog.open(); } }); } monitor.worked(2); } finally { monitor.done(); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, activation); } catch (InvocationTargetException e) { EJCoreLog.log(e); } catch (InterruptedException e) { EJCoreLog.log(e); } } }); } }
From source file:org.erlide.ui.util.PopupDialog.java
License:Open Source License
public static void show(final String title, final String message, final int delay, final int anchor, final boolean centered) { // if (Workbench.getInstance()==null) // return;// w w w . ja va 2s .c om final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); final Shell shell = window == null ? null : window.getShell(); final Display display = window == null ? workbench.getDisplay() : window.getShell().getDisplay(); // balloon if (delay >= 0) { display.syncExec(new Runnable() { @Override public void run() { win = new BalloonWindow(display, SWT.ON_TOP | SWT.TITLE | SWT.TOOL); win.setText(title); final Layout layout = new FillLayout(); final Composite ct = win.getContents(); ct.setLayout(layout); final Label l = new Label(ct, SWT.LEFT | SWT.WRAP); l.setBackground(ct.getBackground()); l.setForeground(ct.getForeground()); l.setText(message); // l.setBounds(0, 0, 60, 60); l.setBounds(ct.getClientArea()); l.pack(); ct.pack(); win.addSelectionControl(l); final Rectangle r = display.getPrimaryMonitor().getBounds(); final Rectangle rr = win.getContents().getBounds(); if (centered) { win.setLocation(r.x + r.width / 2 - rr.width / 2, r.y + r.height / 2 - rr.height / 2); } else { final Shell activeShell = display.getActiveShell(); if (activeShell != null) { final Rectangle shellBounds = activeShell.getBounds(); win.setLocation(shellBounds.x + shellBounds.width - 10, shellBounds.y + shellBounds.height - 10); } else { win.setLocation(r.x + r.width - 10, r.y + r.height - 30); } } win.setAnchor(anchor); win.setVisible(true); } }); final UIJob job = new UIJob("close balloon") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { if (!win.getContents().isDisposed()) { win.getContents().getShell().close(); // display.dispose(); } return new Status(IStatus.OK, ErlideUIPlugin.PLUGIN_ID, IStatus.OK, "", null); } }; job.schedule(delay); } else { // regular dialog final MessageDialog dlg = new MessageDialog(shell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 0); dlg.open(); } }
From source file:org.gw4e.eclipse.facade.DialogManager.java
License:Open Source License
/** * Display an error message in a Dialog/*from ww w.j av a 2s.co m*/ * * @param message */ public static void displayErrorMessage(String title, String message) { MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] { MessageUtil.getString("close") }, 0); int result = dialog.open(); dialog.close(); }
From source file:org.gw4e.eclipse.launching.GW4ELaunchShortcut.java
License:Open Source License
private void launch(Object[] elements, String mode) { try {//from ww w . ja v a 2 s .co m IJavaElement[] ijes = null; List<IJavaElement> jes = new ArrayList<IJavaElement>(); for (int i = 0; i < elements.length; i++) { Object selected = elements[i]; if (selected instanceof IJavaElement) { IJavaElement element = (IJavaElement) selected; switch (element.getElementType()) { case IJavaElement.COMPILATION_UNIT: jes.add(element); break; } } } ijes = new IJavaElement[jes.size()]; jes.toArray(ijes); ILaunchConfigurationWorkingCopy wc = buildLaunchConfiguration(ijes); if (wc == null) return; ILaunchConfiguration config = findExistingORCreateLaunchConfiguration(wc, mode); DebugUITools.launch(config, mode); } catch (Exception e) { ResourceManager.logException(e); MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "GW4E Launcher", (Image) null, "Unable to launch. See error in Error view.", MessageDialog.ERROR, new String[] { "Close" }, 0); dialog.open(); } }
From source file:org.gw4e.eclipse.launching.GW4ELaunchShortcut.java
License:Open Source License
protected ILaunchConfigurationWorkingCopy buildLaunchConfiguration(IJavaElement[] elements) throws CoreException { IJavaElement mainElement = null;//from w ww.jav a 2 s.c o m for (int i = 0; i < elements.length; i++) { IJavaElement element = elements[i]; if (JDTManager.hasStartableGraphWalkerAnnotation(element)) { mainElement = element; break; } } if (mainElement == null) { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "GW4E Launcher", (Image) null, MessageUtil.getString("nostartvalueinannotation"), MessageDialog.ERROR, new String[] { "Close" }, 0); dialog.open(); return null; } ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(GW4ELAUNCHCONFIGURATIONTYPE); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, DebugPlugin.getDefault() .getLaunchManager().generateLaunchConfigurationName(mainElement.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, elements[0].getJavaProject().getElementName()); String mainElementName = elementToJavaClassName(mainElement); StringBuffer sb = new StringBuffer(mainElementName).append(";"); String[] classnames = elementToJavaClassName(elements); for (int i = 0; i < classnames.length; i++) { if (classnames[i].equals(mainElementName)) continue; sb.append(classnames[i]).append(";"); } wc.setAttribute(LaunchingConstant.CONFIG_TEST_CLASSES, sb.toString()); return wc; }
From source file:org.hibernate.eclipse.codegen.ExportAntCodeGenWizardPage.java
License:Open Source License
public IFile createNewFile() { codeGenXMLFactory = null;// w w w.j a v a 2 s.c o m IFile res = super.createNewFile(); if (codeGenXMLFactory != null && res != null) { final String propFileContentPreSave = codeGenXMLFactory.getPropFileContentPreSave(); if (!CodeGenXMLFactory.isEmpty(propFileContentPreSave)) { IPath path = res.getFullPath(); path = path.removeLastSegments(1); path = path.append(codeGenXMLFactory.getExternalPropFileName()); final IFile newFileHandle = createFileHandle(path); final InputStream initialContents = new ByteArrayInputStream(propFileContentPreSave.getBytes()); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { CreateFileOperation op = new CreateFileOperation(newFileHandle, null, initialContents, IDEWorkbenchMessages.WizardNewFileCreationPage_title); try { // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901 // directly execute the operation so that the undo state is // not preserved. Making this undoable resulted in too many // accidental file deletions. op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); } catch (final ExecutionException e) { getContainer().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (e.getCause() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), // Was // Utilities.getFocusShell() IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle, null, // no special // message ((CoreException) e.getCause()).getStatus()); } else { IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$ MessageDialog.openError(getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind( IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getCause().getMessage())); } } }); } } }; try { getContainer().run(true, true, op); } catch (InterruptedException e) { } catch (InvocationTargetException e) { // Execution Exceptions are handled above but we may still get // unexpected runtime errors. IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$ MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage, e.getTargetException().getMessage()), SWT.SHEET); } } } return res; }
From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java
License:Open Source License
public static void error(String string) { MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ClasspathUIPlugin_ERROR, Display.getDefault().getSystemImage(SWT.ICON_ERROR), string, MessageDialog.ERROR, new String[] { Messages.ClasspathUIPlugin_OK, }, 0); dialog.setBlockOnOpen(true);/*w w w.j av a 2 s.c o m*/ dialog.open(); }