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.apache.directory.studio.ldapservers.apacheds.CreateConnectionAction.java
License:Apache License
/** * Reports to the user an error message indicating the server * configuration could not be read correctly. * * @param message// w w w .j a v a 2 s.com * the message */ private void reportErrorReadingServerConfiguration(ServersView view, String message) { MessageDialog dialog = new MessageDialog(view.getSite().getShell(), Messages.getString("CreateConnectionAction.UnableReadServerConfiguration"), //$NON-NLS-1$ null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); }
From source file:org.apache.directory.studio.ldapservers.apacheds.ExtensionUtils.java
License:Apache License
/** * Reports to the user an error message indicating the server * configuration could not be read correctly. * * @param message//from w ww. j a v a 2 s . c o m * the message */ private static void reportErrorReadingServerConfiguration(ServersView view, String message) { MessageDialog dialog = new MessageDialog(view.getSite().getShell(), Messages.getString("CreateConnectionAction.UnableReadServerConfiguration"), //$NON-NLS-1$ null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.view.ViewUtils.java
License:Apache License
/** * Displays an error message dialog with the given title and message. * * @param title the title of the window/* www. j av a 2s . c o m*/ * @param message the message to display * @return <code>true</code> if the user presses the OK or Yes button, * <code>false</code> otherwise */ public static boolean displayErrorMessageDialog(String title, String message) { return displayMessageDialog(MessageDialog.ERROR, title, message); }
From source file:org.apache.directory.studio.templateeditor.view.preferences.PreferencesTemplatesManager.java
License:Apache License
/** * Saves the modifications back to the initial manager. *//*from ww w . j a v a2s .c o m*/ public boolean saveModifications() { // Getting original templates Template[] originalTemplates = manager.getTemplates(); // Creating a list of original templates List<Template> originalTemplatesList = new ArrayList<Template>(); // Looping on original templates for (Template originalTemplate : originalTemplates) { // Checking if the enablement state has been changed boolean isEnabled = isEnabled(originalTemplate); if (manager.isEnabled(originalTemplate) != isEnabled) { if (isEnabled) { manager.enableTemplate(originalTemplate); } else { manager.disableTemplate(originalTemplate); } } // Checking if the default state has been changed boolean isDefaultTemplate = isDefaultTemplate(originalTemplate); if (manager.isDefaultTemplate(originalTemplate) != isDefaultTemplate) { if (isDefaultTemplate) { manager.setDefaultTemplate(originalTemplate); } else { manager.unSetDefaultTemplate(originalTemplate); } } // Checking if the original template has been removed if (!templatesList.contains(originalTemplate)) { if (!manager.removeTemplate((FileTemplate) originalTemplate)) { // Creating and opening the error dialog String dialogTitle = Messages .getString("PreferencesTemplatesManager.UnableToRemoveTheTemplate"); //$NON-NLS-1$ String dialogMessage = MessageFormat.format( Messages.getString("PreferencesTemplatesManager.TheTemplateCouldNotBeRemoved") //$NON-NLS-1$ + EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString( "PreferencesTemplatesManager.SeeTheLogsFileForMoreInformation"), //$NON-NLS-1$ originalTemplate.getTitle()); MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); return false; } } // Adding the template to the list originalTemplatesList.add(originalTemplate); } // Looping on the new templates list for (Template template : templatesList) { // Checking if the template has been added if (!originalTemplatesList.contains(template)) { // Adding the new template if (!manager.addTemplate(new File(((PreferencesFileTemplate) template).getFilePath()))) { // Creating and opening the error dialog String dialogTitle = Messages.getString("PreferencesTemplatesManager.UnableToAddTheTemplate"); //$NON-NLS-1$ String dialogMessage = MessageFormat.format( Messages.getString("PreferencesTemplatesManager.TheTemplateCouldNotBeAdded") //$NON-NLS-1$ + EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString( "PreferencesTemplatesManager.SeeTheLogsFileForMoreInformation"), //$NON-NLS-1$ template.getTitle()); MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); return false; } // Setting the enablement state to the new template boolean isEnabled = isEnabled(template); if (isEnabled) { manager.enableTemplate(template); } else { manager.disableTemplate(template); } // Setting the default state has been changed boolean isDefaultTemplate = isDefaultTemplate(template); if (isDefaultTemplate) { manager.setDefaultTemplate(template); } else { manager.unSetDefaultTemplate(template); } } } return true; }
From source file:org.apache.directory.studio.templateeditor.view.preferences.TemplateEntryEditorPreferencePage.java
License:Apache License
/** * Implements the remove template action. *//*from w w w . j av a 2s . c o m*/ @SuppressWarnings("unchecked") private void removeTemplateAction() { StructuredSelection selection = (StructuredSelection) templatesViewer.getSelection(); if (!selection.isEmpty()) { Iterator<Object> selectionIterator = ((StructuredSelection) templatesViewer.getSelection()).iterator(); while (selectionIterator.hasNext()) { Object selectedObject = selectionIterator.next(); if (selectedObject instanceof Template) { Template template = (Template) selectedObject; if (!manager.removeTemplate(template)) { // Creating and opening the dialog String dialogTitle = Messages .getString("TemplateEntryEditorPreferencePage.UnableToRemoveTheTemplate"); //$NON-NLS-1$ String dialogMessage = MessageFormat.format(Messages .getString("TemplateEntryEditorPreferencePage.TheTemplateCouldNotBeRemoved") //$NON-NLS-1$ + EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString( "TemplateEntryEditorPreferencePage.SeeTheLogsFileForMoreInformation"), //$NON-NLS-1$ template.getTitle()); MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); } } } } }
From source file:org.apache.directory.studio.templateeditor.view.wizards.ExportTemplatesWizard.java
License:Apache License
/** * {@inheritDoc}//from w w w .ja va 2 s . c o m */ public boolean performFinish() { // Saving the dialog settings page.saveDialogSettings(); // Getting the selected templates and export directory final Template[] selectedTemplates = page.getSelectedTemplates(); final File exportDirectory = new File(page.getExportDirectory()); // Creating a list where all the template files that could not be // exported will be stored final List<Template> failedTemplates = new ArrayList<Template>(); if (selectedTemplates != null) { try { getContainer().run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { for (Template selectedTemplate : selectedTemplates) { try { // Creating the output stream FileOutputStream fos = new FileOutputStream( new File(exportDirectory, selectedTemplate.getId() + ".xml")); //$NON-NLS-1$ // Exporting the template TemplateIO.save(selectedTemplate, fos); fos.close(); } catch (FileNotFoundException e) { // Logging the error EntryTemplatePluginUtils.logError(e, Messages.getString( "ExportTemplatesWizard.TheTemplateCouldNotBeExportedBecauseOfTheFollowingError"), //$NON-NLS-1$ selectedTemplate.getTitle(), selectedTemplate.getId(), e.getMessage()); // Adding the template to the failed templates list failedTemplates.add(selectedTemplate); } catch (IOException e) { // Logging the error EntryTemplatePluginUtils.logError(e, Messages.getString( "ExportTemplatesWizard.TheTemplateCouldNotBeExportedBecauseOfTheFollowingError"), //$NON-NLS-1$ selectedTemplate.getTitle(), selectedTemplate.getId(), e.getMessage()); // Adding the template to the failed templates list failedTemplates.add(selectedTemplate); } } } }); } catch (InvocationTargetException e) { // Nothing to do (it will never occur) } catch (InterruptedException e) { // Nothing to do. } } // Handling the templates that could not be exported if (failedTemplates.size() > 0) { String title = null; String message = null; // Only one template could not be imported if (failedTemplates.size() == 1) { // Getting the failed template Template failedTemplate = failedTemplates.get(0); // Creating the title and message title = Messages.getString("ExportTemplatesWizard.ATemplateCouldNotBeExported"); //$NON-NLS-1$ message = MessageFormat.format( Messages.getString("ExportTemplatesWizard.TheTemplateCouldNotBeExported"), failedTemplate //$NON-NLS-1$ .getTitle(), failedTemplate.getId()); } // Several templates could not be imported else { title = Messages.getString("ExportTemplatesWizard.SeveralTemplatesCouldNotBeExported"); //$NON-NLS-1$ message = Messages.getString("ExportTemplatesWizard.TheFollowingTemplatesCouldNotBeExported"); //$NON-NLS-1$ for (Template failedTemplate : failedTemplates) { message += EntryTemplatePluginUtils.LINE_SEPARATOR + " - " //$NON-NLS-1$ + MessageFormat.format("{0} ({1})", failedTemplate.getTitle(), failedTemplate.getId()); //$NON-NLS-1$ } } // Common ending message message += EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString("ExportTemplatesWizard.SeeTheLogsFileForMoreInformation"); //$NON-NLS-1$ // Creating and opening the dialog MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); } return true; }
From source file:org.apache.directory.studio.templateeditor.view.wizards.ImportTemplatesWizard.java
License:Apache License
/** * {@inheritDoc}//from ww w. ja v a 2 s.com */ public boolean performFinish() { // Saving the dialog settings page.saveDialogSettings(); // Getting the templates to be imported final File[] selectedTemplateFiles = page.getSelectedTemplateFiles(); // Creating a list where all the template files that could not be // imported will be stored final List<File> failedTemplates = new ArrayList<File>(); // Running the code to add the templates in a separate container // with progress monitor try { getContainer().run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { for (File selectedTemplateFile : selectedTemplateFiles) { if (!manager.addTemplate(selectedTemplateFile)) { failedTemplates.add(selectedTemplateFile); } } } }); } catch (InvocationTargetException e) { // Nothing to do (it will never occur) } catch (InterruptedException e) { // Nothing to do. } // Handling the templates that could not be added if (failedTemplates.size() > 0) { String title = null; String message = null; // Only one template could not be imported if (failedTemplates.size() == 1) { title = Messages.getString("ImportTemplatesWizard.ATemplateCouldNotBeImported"); //$NON-NLS-1$ message = MessageFormat.format( Messages.getString("ImportTemplatesWizard.TheTemplateCouldNotBeImported"), //$NON-NLS-1$ failedTemplates.get(0).getAbsolutePath()); } // Several templates could not be imported else { title = Messages.getString("ImportTemplatesWizard.SeveralTemplatesCouldNotBeImported"); //$NON-NLS-1$ message = Messages.getString("ImportTemplatesWizard.TheFollowingTemplatesCouldNotBeImported"); //$NON-NLS-1$ for (File failedTemplate : failedTemplates) { message += EntryTemplatePluginUtils.LINE_SEPARATOR + " - " //$NON-NLS-1$ + failedTemplate.getAbsolutePath(); } } // Common ending message message += EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString("ImportTemplatesWizard.SeeTheLogsFileForMoreInformation"); //$NON-NLS-1$ // Creating and opening the dialog MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); } return true; }
From source file:org.bbaw.pdr.ae.common.utils.OpenExternalBrowser.java
License:Open Source License
/** * Opens the specified web page in the user's default browser * @param url A web address (URL) of a web page (ex: * "http://www.google.com/")//from ww w . ja v a 2s.c om */ public static void openURL(String url) { try { // attempt to use Desktop library from JDK 1.6+ Class<?> d = Class.forName("java.awt.Desktop"); d.getDeclaredMethod("browse", new Class[] { java.net.URI.class }).invoke( d.getDeclaredMethod("getDesktop").invoke(null), new Object[] { java.net.URI.create(url) }); // above code mimicks: java.awt.Desktop.getDesktop().browse() } catch (Exception ignore) { // library not available or failed String osName = System.getProperty("os.name"); try { if (osName.startsWith("Mac OS")) { Class.forName("com.apple.eio.FileManager") .getDeclaredMethod("openURL", new Class[] { String.class }) .invoke(null, new Object[] { url }); } else if (osName.startsWith("Windows")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { // assume Unix or Linux String browser = null; for (String b : browsers) if (browser == null && Runtime.getRuntime().exec(new String[] { "which", b }) .getInputStream().read() != -1) Runtime.getRuntime().exec(new String[] { browser = b, url }); if (browser == null) throw new Exception(Arrays.toString(browsers)); } } catch (Exception e) { MessageDialog md = new MessageDialog(null, "Error", null, errMsg + "\n" + e.toString(), MessageDialog.ERROR, new String[] { "OK" }, 0); md.open(); } } }
From source file:org.bbaw.pdr.ae.repositoryconnection.commands.UpdateAllDataHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { if (!_urChecker.isUserGuest()) { ProgressMonitorDialog dialog = new ProgressMonitorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.setCancelable(true);/*ww w . j ava 2 s .com*/ try { dialog.run(true, true, new IRunnableWithProgress() { private IStatus _updateStatus; @Override public void run(final IProgressMonitor monitor) { // Activator.getDefault().getPreferenceStore().getString("REPOSITORY_URL")); if (monitor.isCanceled()) { monitor.setCanceled(true); } final User user = Facade.getInstanz().getCurrentUser(); IUpdateManager[] updateManagers = Facade.getInstanz().getUpdateManagers(); for (IUpdateManager manager : updateManagers) { try { if (user != null) { _updateStatus = manager.updateAllData(user.getPdrId().toString(), user.getAuthentication().getPassword(), monitor); } } catch (final Exception e) { e.printStackTrace(); UIJob job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); //Display display = workbench.getDisplay(); //Shell shell = new Shell(display); Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); String info = NLMessages.getString("Command_update_error") + "\n\n" + e.getMessage(); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } // catch (final UnsupportedEncodingException e) // { // e.printStackTrace(); // // UIJob job = new UIJob("Feedbackup") // { // @Override // public IStatus runInUIThread(final IProgressMonitor monitor) // { // IWorkbench workbench = PlatformUI.getWorkbench(); // Display display = workbench.getDisplay(); // Shell shell = new Shell(display); // String info = NLMessages.getString("Command_update_error") + "\n\n" // + e.getMessage(); // MessageDialog infoDialog = new MessageDialog(shell, NLMessages // .getString("Command_update_error"), null, info, MessageDialog.ERROR, // new String[] // {"OK"}, 0); //$NON-NLS-1$ // infoDialog.open(); // // return Status.OK_STATUS; // } // }; // job.setUser(true); // job.schedule(); // } // catch (final Exception e) // { // e.printStackTrace(); // // UIJob job = new UIJob("Feedbackup") // { // @Override // public IStatus runInUIThread(final IProgressMonitor monitor) // { // IWorkbench workbench = PlatformUI.getWorkbench(); // Display display = workbench.getDisplay(); // Shell shell = new Shell(display); // String info = NLMessages.getString("Command_update_error") + "\n\n" // + e.getMessage(); // MessageDialog infoDialog = new MessageDialog(shell, NLMessages // .getString("Command_update_error"), null, info, MessageDialog.ERROR, // new String[] // {"OK"}, 0); //$NON-NLS-1$ // infoDialog.open(); // return Status.OK_STATUS; // } // }; // job.setUser(true); // job.schedule(); // } } // for-loop UIJob job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { Facade.getInstanz().refreshAllData(); IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = null; if (_updateStatus != null) if (_updateStatus.isMultiStatus()) { info = NLMessages.getString("Command_update_error"); for (IStatus status : _updateStatus.getChildren()) { info += "\n\n" + status.getMessage(); Throwable e = status.getException(); if (e != null) { info += "\n\n" + e.getMessage(); for (StackTraceElement ste : e.getStackTrace()) info += "\n" + ste; } } RepoUpdateStatusDialog statusDialog = new RepoUpdateStatusDialog(shell, _updateStatus, _updateStatus.getSeverity() < IStatus.WARNING ? NLMessages.getString("Command_update_successful") : NLMessages.getString("Command_update_error")); statusDialog.setTitle("Update Status Report"); statusDialog.open(); } else { if (_updateStatus.equals(Status.OK_STATUS)) { info = NLMessages.getString("Command_update_successful"); } else { if (_updateStatus.equals(Status.CANCEL_STATUS)) { info = NLMessages.getString("Command_update_error"); } else { info = NLMessages.getString("Command_update_error_server"); info += "\n\n" + ((Status) _updateStatus).getMessage(); if (_updateStatus.getException() != null) { info += "\n"; for (StackTraceElement ste : _updateStatus.getException() .getStackTrace()) info += "\n" + ste; } } } MessageDialog infoDialog = new MessageDialog(shell, info, null, info, MessageDialog.INFORMATION, new String[] { "OK" }, 0); //$NON-NLS-1$ infoDialog.open(); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); monitor.done(); } }); } catch (final InvocationTargetException e) { e.printStackTrace(); UIJob job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages.getString("Command_update_error") + e.toString() + "\n\n" + e.getMessage() + "\n\n" + e.getCause().toString() + "\n" + e.getCause().getMessage(); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } catch (final InterruptedException e) { e.printStackTrace(); UIJob job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages.getString("Command_update_error") + e.toString() + "\n\n" + e.getMessage(); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } else { MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commandsr_guest_user"), //$NON-NLS-1$ NLMessages.getString("Commandsr_guest_user_denied")); } return null; }
From source file:org.bonitasoft.studio.application.BonitaStudioApplication.java
License:Open Source License
protected void openErrorDialog(final Display display, final String javaVersion) { final Shell shell = new Shell(display); try {//from w w w . j ava2s . c o m final Version version = Version.parseVersion(ProductVersion.CURRENT_VERSION); final String uriWithProductVersion = ONLINE_DOC_REQUIREMENTS + version.getMajor() + "." + version.getMinor(); final URI uri = new URI(uriWithProductVersion); final MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell, Messages.incompatibleJavaVersionTitle, null, Messages.bind(Messages.incompatibleJavaVersionMessage, org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0, uri); messageDialog.open(); } catch (final URISyntaxException e) { BonitaStudioLog.error(e); } finally { shell.dispose(); } }