List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:com.aptana.ide.core.ui.CoreUIUtils.java
License:Open Source License
/** * Logs an error// w w w . ja v a 2 s . c om * * @param shell * @param plugin * @param title * the title of the dialog * @param message * the message to log */ public static void logAndDialogError(Shell shell, Plugin plugin, String title, String message) { MessageDialog.openError(shell, title, message); IdeLog.logError(plugin, message); }
From source file:com.aptana.ide.core.ui.CoreUIUtils.java
License:Open Source License
/** * Logs an error/*w w w . ja v a2 s . c om*/ * * @param shell * @param plugin * @param title * the title of the dialog * @param message * the message to log * @param th */ public static void logAndDialogError(Shell shell, Plugin plugin, String title, String message, Throwable th) { MessageDialog.openError(shell, title, message); IdeLog.logError(plugin, message, th); }
From source file:com.aptana.ide.core.ui.CoreUIUtils.java
License:Open Source License
/** * @param message/*ww w . ja va 2s . c o m*/ * @param e * @param log */ public static void showError(final String message, final Exception e, final boolean log) { UIJob errorJob = new UIJob(Messages.CoreUIUtils_MSG_ShowingError) { public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.CoreUIUtils_MSG_Error, message); if (log) { IdeLog.logError(CoreUIPlugin.getDefault(), message, e); } return Status.OK_STATUS; } }; errorJob.schedule(); }
From source file:com.aptana.ide.core.ui.install.PlatformValidatorPatcher.java
License:Open Source License
/** * @param file/* w w w .ja v a 2s. c om*/ * @return */ public static boolean exportPreferences(File file) { IPreferencesService service = Platform.getPreferencesService(); try { FileOutputStream transfers = new FileOutputStream(file); String[] fos = new String[0]; service.exportPreferences(service.getRootNode(), transfers, fos); transfers.flush(); transfers.close(); return true; } catch (final IOException e) { IdeLog.logError(CoreUIPlugin.getDefault(), Messages.getString("PlatformValidatorPatcher.ERR_ErrorExportingPreferences"), e); //$NON-NLS-1$ UIJob job = new UIJob("Export Preferences") { //$NON-NLS-1$ /** * */ public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getDisplay().getActiveShell(), new String(), e.getLocalizedMessage()); return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); return false; } catch (final CoreException e) { IdeLog.logError(CoreUIPlugin.getDefault(), Messages.getString("PlatformValidatorPatcher.ERR_ErrorExportingPreferences"), e); //$NON-NLS-1$ UIJob job = new UIJob("Export Preferences") { //$NON-NLS-1$ /** * */ public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getDisplay().getActiveShell(), new String(), e.getLocalizedMessage()); return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); return false; } }
From source file:com.aptana.ide.core.ui.install.PlatformValidatorPatcher.java
License:Open Source License
/** * @param file//from w ww.j a v a 2 s. c om * @return */ public static boolean importPreferences(File file) { IPreferencesService service = Platform.getPreferencesService(); try { IStatus importPreferences = service.importPreferences(new FileInputStream(file)); return importPreferences.getCode() == IStatus.OK; } catch (final CoreException e) { IdeLog.logError(CoreUIPlugin.getDefault(), Messages.getString("PlatformValidatorPatcher.ERR_ErrorImportingPreferences"), e); //$NON-NLS-1$ UIJob job = new UIJob("Import Preferences") { //$NON-NLS-1$ /** * */ public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getDisplay().getActiveShell(), new String(), e.getLocalizedMessage()); return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); return false; } catch (final FileNotFoundException e) { IdeLog.logError(CoreUIPlugin.getDefault(), Messages.getString("PlatformValidatorPatcher.ERR_ErrorImportingPreferences"), e); //$NON-NLS-1$ UIJob job = new UIJob("Import Preferences") { //$NON-NLS-1$ /** * */ public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(getDisplay().getActiveShell(), new String(), e.getLocalizedMessage()); return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); return false; } }
From source file:com.aptana.ide.core.ui.wizards.BaseWizard.java
License:Open Source License
private IProject createNewProject() { if (project != null) { return project; }//from ww w .j ava 2 s . c o m // get a project handle final IProject newProjectHandle = getProjectHandle(); if (newProjectHandle == null) { return null; } // get a project descriptor IPath newPath = getProjectPath(); final IProjectDescription description = createProjectDescription(newProjectHandle.getName(), newPath); // create the new project operation WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { if (monitor != null) { monitor.beginTask(WizardMessages.BaseWizard_MSG_CreatingProject, 2000); } newProjectHandle.create(description, new SubProgressMonitor(monitor, 1000)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } newProjectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1000)); if (monitor != null) { monitor.done(); } } }; // run the new project creation operation try { getContainer().run(false, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { // ie.- one of the steps resulted in a core exception Throwable t = e.getTargetException(); if (t instanceof CoreException) { if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError(getShell(), EclipseUIUtils.ResourceMessages_NewProject_errorMessage, NLS.bind(EclipseUIUtils.ResourceMessages_NewProject_caseVariantExistsError, newProjectHandle.getName())); } else { ErrorDialog.openError(getShell(), EclipseUIUtils.ResourceMessages_NewProject_errorMessage, null, // no // special // message ((CoreException) t).getStatus()); } } else { // CoreExceptions are handled above, but unexpected runtime // exceptions and errors may still occur. EclipseUIUtils.getIDEWorkbenchPlugin().getLog().log(new Status(IStatus.ERROR, EclipseUIUtils.IDEWorkbenchPlugin_IDE_WORKBENCH, 0, t.toString(), t)); MessageDialog.openError(getShell(), EclipseUIUtils.ResourceMessages_NewProject_errorMessage, NLS.bind(EclipseUIUtils.ResourceMessages_NewProject_internalError, t.getMessage())); } return null; } project = newProjectHandle; return project; }
From source file:com.aptana.ide.core.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * Display an error dialog with the specified message. * //w w w. j av a 2 s . c o m * @param message * the error message */ protected void displayErrorDialog(String message) { MessageDialog.openError(getContainer().getShell(), getErrorDialogTitle(), message); }
From source file:com.aptana.ide.core.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * Create the project described in record. * // ww w .ja va2 s . co m * @param record * @return an new project if successful, null if failed. */ private IProject createExistingProject(final ProjectRecord record) { String projectName = record.getProjectName(); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProject project = workspace.getRoot().getProject(projectName); if (record.description == null) { record.description = workspace.newProjectDescription(projectName); IPath locationPath = new Path(record.projectSystemFile.getAbsolutePath()); // IPath locationPath = new // Path(record.projectFile.getFullPath(record.projectFile.getRoot())); // If it is under the root use the default location if (Platform.getLocation().isPrefixOf(locationPath)) { record.description.setLocation(null); } else { record.description.setLocation(locationPath); } } else { record.description.setName(projectName); } WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 2000); //$NON-NLS-1$ project.create(record.description, new SubProgressMonitor(monitor, 1000)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1000)); } }; // run the new project creation operation try { getContainer().run(true, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { // ie.- one of the steps resulted in a core exception Throwable t = e.getTargetException(); if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError(getShell(), DataTransferMessages.WizardExternalProjectImportPage_errorMessage, NLS.bind(DataTransferMessages.WizardExternalProjectImportPage_caseVariantExistsError, record.description.getName())); } else { ErrorDialog.openError(getShell(), DataTransferMessages.WizardExternalProjectImportPage_errorMessage, ((CoreException) t).getLocalizedMessage(), ((CoreException) t).getStatus()); } return null; } try { showView("com.aptana.ide.ui.io.fileExplorerView", PlatformUI.getWorkbench().getActiveWorkbenchWindow()); //$NON-NLS-1$ } catch (PartInitException e) { } BasicNewResourceWizard.selectAndReveal(project, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); return project; }
From source file:com.aptana.ide.editor.erb.wizards.ERBNewFileWizard.java
License:Open Source License
public boolean performFinish() { SimpleNewWizardPage page = (SimpleNewWizardPage) getPages()[0]; final String containerName = page.getContainerName(); final String fileName = page.getFileName(); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { doFinish(containerName, fileName, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done();/*from w w w . ja v a 2s. c o m*/ } } }; try { getContainer().run(true, false, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { Throwable realException = e.getTargetException(); MessageDialog.openError(getShell(), com.aptana.ide.editors.wizards.Messages.SimpleNewFileWizard_Error, realException.getMessage()); return false; } return true; }
From source file:com.aptana.ide.editor.text.GenericTextEditor.java
License:Open Source License
/** * Creates the job that monitors the underlying grammar file being used. If the grammar file changes the parser is * recreated and an entire reparse is done. The parser is only changed if the new grammar file parses correctly. */// w ww . j a v a 2 s. com private void createGrammarFileMonitor() { grammarFileMonitor = new Job(Messages.GenericTextEditor_MONITOR_GRAMMAR_FILE) { private long stamp = grammarFile.lastModified(); protected IStatus run(IProgressMonitor monitor) { if (stamp < grammarFile.lastModified()) { stamp = grammarFile.lastModified(); TokenList oldList = LanguageRegistry.getTokenList(language); if (oldList != null) { LanguageRegistry.unregisterTokenList(oldList); } try { IParser newParser = createParser(); FileService context = FileContextManager.get(GenericTextEditor.this.getEditorInput()); parser = newParser; context.setParser(parser); editor.getFileContext().setFileContext(context); context.doFullParse(); UIJob refreshEditor = new UIJob(Messages.GenericTextEditor_REFRESHING_LEXER) { public IStatus runInUIThread(IProgressMonitor monitor) { editor.getViewer().getTextWidget().redraw(); editor.getViewer().getTextWidget().update(); return Status.OK_STATUS; } }; refreshEditor.schedule(); } catch (final Exception e) { if (oldList != null) { LanguageRegistry.registerTokenList(oldList); } UIJob errorJob = new UIJob(Messages.GenericTextEditor_ERROR_PARSING_LEXER) { public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(shell, Messages.GenericTextEditor_ERROR_PARSING_LEXER, Messages.GenericTextEditor_ERROR_OCCURED_DURING_PARSE_LEXER); return Status.OK_STATUS; } }; errorJob.schedule(); } } this.schedule(1000); return Status.OK_STATUS; } }; grammarFileMonitor.setSystem(true); grammarFileMonitor.schedule(1000); }