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.syncing.doms.Sync.java
License:Open Source License
/** * Downloads the file in the current editor. *//*from www. jav a 2 s. c o m*/ public static void downloadCurrentEditor() { IEditorPart editor = CoreUIUtils.getActiveEditor(); if (editor == null) { if (!downloadCurrentSelection()) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.Sync_TTL_UnableToDownload, Messages.Sync_ERR_YouMustHaveACurrentlyOpenEditorToDownload); } return; } IEditorInput input = editor.getEditorInput(); if (input instanceof FileEditorInput) { download(((FileEditorInput) input).getFile()); } else if (input instanceof IPathEditorInput) { download(((IPathEditorInput) input).getPath()); } else if (input instanceof IURIEditorInput) { IURIEditorInput editorInput = (IURIEditorInput) input; try { download(EFS.getStore(editorInput.getURI())); } catch (CoreException e) { } } else { downloadCurrentSelection(); } }
From source file:com.aptana.ide.syncing.ui.wizards.RemoteProjectWizard.java
License:Open Source License
private IProject createNewProject() { if (newProject != null) { return newProject; }/*from www . j a v a2s . c o m*/ // get a project handle final IProject newProjectHandle = mainPage.getProjectHandle(); // get a project descriptor IPath newPath = null; if (!mainPage.useDefaults()) { newPath = mainPage.getLocationPath(); } IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); description.setLocation(newPath); description.setNatureIds(new String[] { "com.aptana.ide.project.remote.nature" }); //$NON-NLS-1$ // create the new project operation WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { if (monitor != null) { monitor.beginTask(Messages.RemoteProjectWizard_MSG_CreatingRemoteProject, 1); } createProject(description, newProjectHandle, monitor); if (monitor != null) { monitor.worked(1); monitor.done(); } } }; // run the new project creation operation try { getContainer().run(true, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { // i.e. 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(), ResourceMessages.NewProject_errorMessage, NLS .bind(ResourceMessages.NewProject_caseVariantExistsError, newProjectHandle.getName())); } else { ErrorDialog.openError(getShell(), ResourceMessages.NewProject_errorMessage, null, ((CoreException) t).getStatus()); } } else { // CoreExceptions are handled above, but unexpected runtime // exceptions and errors may still occur. IDEWorkbenchPlugin.getDefault().getLog() .log(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 0, t.toString(), t)); MessageDialog.openError(getShell(), ResourceMessages.NewProject_errorMessage, NLS.bind(ResourceMessages.NewProject_internalError, t.getMessage())); } return null; } newProject = newProjectHandle; return newProject; }
From source file:com.aptana.ide.syncing.ui.wizards.SyncExportPage.java
License:Open Source License
/** * @return true if operation succeeded//from w w w .j a v a 2 s . c om */ public boolean performFinish() { String path = pathText.getText(); boolean overwrite = overwriteButton.getSelection(); File file = new File(path); if (file.exists()) { if (!overwrite) { if (!MessageDialog.openConfirm(getShell(), Messages.SyncExportPage_Overwrite, StringUtils.format(Messages.SyncExportPage_Confirm_Overwrite, file.getAbsolutePath()))) { return false; } } if (!file.canWrite()) { MessageDialog.openError(pathText.getShell(), Messages.SyncExportPage_Error, StringUtils.format(Messages.SyncExportPage_NOT_WRITABLE, file.getAbsolutePath())); return false; } } // CoreIOPlugin.getConnectionPointManager().saveState(new Path(path)); SyncingPlugin.getSiteConnectionManager().saveState(new Path(path)); getPreferenceStore().setValue(IPreferenceConstants.EXPORT_INITIAL_PATH, path); getPreferenceStore().setValue(IPreferenceConstants.EXPORT_OVEWRITE_FILE_WITHOUT_WARNING, overwrite); return true; }
From source file:com.aptana.ide.syncing.ui.wizards.SyncImportPage.java
License:Open Source License
/** * @return success//from ww w .java 2s .c o m */ public boolean performFinish() { String path = pathText.getText(); File file = new File(path); if (!file.exists()) { MessageDialog.openError(getShell(), Messages.SyncImportPage_FILE_NOT_EXIST, StringUtils.format(Messages.SyncImportPage_FILE_NOT_EXIST_DESC, file.getAbsolutePath())); return false; } if (!file.canRead()) { MessageDialog.openError(getShell(), Messages.SyncImportPage_FILE_NOT_READABLE, StringUtils.format(Messages.SyncImportPage_FILE_NOT_READABLE_DESC, file.getAbsolutePath())); return false; } // CoreIOPlugin.getConnectionPointManager().loadState(new Path(path)); SyncingPlugin.getSiteConnectionManager().loadState(new Path(path)); IOUIPlugin.refreshNavigatorView(null); getPreferenceStore().setValue(IPreferenceConstants.EXPORT_INITIAL_PATH, path); return true; }
From source file:com.aptana.ide.ui.ftp.dialogs.FTPConnectionPointPropertyDialog.java
License:Open Source License
private void showErrorDialog(Throwable e) { String message = Messages.FTPConnectionPointPropertyDialog_DefaultErrorMsg; if (e instanceof CoreException) { message = ((CoreException) e).getStatus().getMessage(); }//from w ww . j a va 2 s. co m MessageDialog.openError(getShell(), Messages.FTPConnectionPointPropertyDialog_ErrorTitle, message); }
From source file:com.aptana.ide.ui.UIUtils.java
License:Open Source License
private static void showErrorDialog(String title, String message) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message); }
From source file:com.aptana.ide.update.portal.clients.PluginsManager.java
License:Open Source License
public static void install(String pluginId) { Plugin plugin = FeatureUtil.findRemotePlugin(pluginId); if (plugin == null) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.PluginsManager_ERR_TTL_Unable_find_plugin, Messages.PluginsManager_ERR_MSG_Unable_find_plugin + pluginId); return;/*from www .ja va 2s . c o m*/ } if (FeatureUtil.isInstalled(pluginId)) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.PluginsManager_TTL_Plugin_already_installed, Messages.PluginsManager_INF_MSG_Feature_selected_already_installed); return; } try { getPluginManager().install(new Plugin[] { plugin }, new NullProgressMonitor()); } catch (PluginManagerException e) { IdeLog.logError(Activator.getDefault(), e.getMessage(), e); MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.PluginsManager_ERR_TTL_Unable_install_plugin, Messages.PluginsManager_ERR_MSG_Unable_install_plugin + pluginId); } }
From source file:com.aptana.ide.wizards.LibraryProjectWizard.java
License:Open Source License
/** * Creates a new project resource with the selected name. * <p>//from ww w .j av a2 s . c om * In normal usage, this method is invoked after the user has pressed Finish on the wizard; the enablement of the * Finish button implies that all controls on the pages currently contain valid values. * </p> * <p> * Note that this wizard caches the new project once it has been successfully created; subsequent invocations of * this method will answer the same project resource without attempting to create it again. * </p> * * @return the created project resource, or <code>null</code> if the project was not created */ private IProject createNewProject() { if (newProject != null) { return newProject; } // get a project handle final IProject newProjectHandle = mainPage.getProjectHandle(); // get a project descriptor IPath newPath = null; if (!mainPage.useDefaults()) { newPath = mainPage.getLocationPath(); } IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); description.setLocation(newPath); // update the referenced project if provided if (referencePage != null) { IProject[] refProjects = referencePage.getReferencedProjects(); if (refProjects.length > 0) { description.setReferencedProjects(refProjects); } } // create the new project operation WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { if (monitor != null) { monitor.beginTask(Messages.LibraryProjectWizard_CreatingProject, 1); } createProject(description, newProjectHandle, monitor); if (monitor != null) { monitor.worked(1); monitor.done(); } } }; // 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 (t instanceof CoreException) { if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError(getShell(), ResourceMessages.NewProject_errorMessage, NLS .bind(ResourceMessages.NewProject_caseVariantExistsError, newProjectHandle.getName())); } else { ErrorDialog.openError(getShell(), ResourceMessages.NewProject_errorMessage, null, // no // special // message ((CoreException) t).getStatus()); } } else { // CoreExceptions are handled above, but unexpected runtime // exceptions and errors may still occur. IDEWorkbenchPlugin.getDefault().getLog() .log(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 0, t.toString(), t)); MessageDialog.openError(getShell(), ResourceMessages.NewProject_errorMessage, NLS.bind(ResourceMessages.NewProject_internalError, t.getMessage())); } return null; } newProject = newProjectHandle; return newProject; }
From source file:com.aptana.jira.ui.handlers.SubmitTicketHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { SubmitTicketDialog dialog = new SubmitTicketDialog(UIUtils.getActiveShell()); if (dialog.open() == Window.OK) { // runs in a job since it could be long-running final JiraIssueType type = dialog.getType(); final JiraIssueSeverity severity = dialog.getSeverity(); final String summary = dialog.getSummary(); final String description = dialog.getDescription(); final boolean studioLogSelected = dialog.getStudioLogSelected(); final boolean diagnosticLogSelected = dialog.getDiagnosticLogSelected(); final Set<IPath> screenshots = dialog.getScreenshots(); Job job = new Job(StringUtil.ellipsify(Messages.SubmitTicketHandler_JobTitle)) { @Override/*from w w w . j a v a 2 s . co m*/ protected IStatus run(IProgressMonitor monitor) { JiraManager manager = getJiraManager(); JiraIssue issue = null; try { issue = manager.createIssue(type, severity, summary, description); } catch (final JiraException e) { // shows an error message UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { // using workbench window's shell instead of UIUtils.getActiveShell() since the latter // could be the shell of job's progress dialog and would cause this dialog to close // automatically when job finishes MessageDialog.openError(UIUtils.getActiveWorkbenchWindow().getShell(), Messages.SubmitTicketHandler_ERR_CreateFailed, e.getMessage()); } }); } catch (final IOException e) { // shows an error message. In this case likely to be because we couldn't create the temp file // for the description UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { // using workbench window's shell instead of UIUtils.getActiveShell() since the latter // could be the shell of job's progress dialog and would cause this dialog to close // automatically when job finishes MessageDialog.openError(UIUtils.getActiveWorkbenchWindow().getShell(), Messages.SubmitTicketHandler_ERR_CreateFailed, e.getMessage()); } }); } if (issue != null) { // issue is successfully created; now adds the attachments try { if (studioLogSelected) { String logFile = System.getProperty("osgi.logfile"); //$NON-NLS-1$ File file = new File(logFile); if (file.exists()) { manager.addAttachment(Path.fromOSString(file.getAbsolutePath()), issue); } } if (diagnosticLogSelected) { String logContent = DiagnosticHandler.getLogContent(); try { File file = File.createTempFile("diagnostic", ".log"); //$NON-NLS-1$ //$NON-NLS-2$ file.deleteOnExit(); IOUtil.write(new FileOutputStream(file), logContent); manager.addAttachment(Path.fromOSString(file.getAbsolutePath()), issue); } catch (IOException e) { IdeLog.logWarning(JiraCorePlugin.getDefault(), e); } } for (IPath screenshot : screenshots) { manager.addAttachment(screenshot, issue); } } catch (JiraException e) { IdeLog.logWarning(JiraCorePlugin.getDefault(), e); } // shows a success message showSuccess(issue); } return Status.OK_STATUS; } }; job.schedule(); } return null; }
From source file:com.aptana.jira.ui.preferences.JiraPreferencePageProvider.java
License:Open Source License
private boolean login(boolean test) { final String username = usernameText.getText(); final String password = passwordText.getText(); if (StringUtil.isEmpty(username)) { if (test) { MessageDialog.openError(main.getShell(), Messages.JiraPreferencePageProvider_ERR_InvalidInput_Title, Messages.JiraPreferencePageProvider_ERR_EmptyUsername); return false; }// w w w . j a v a 2s . com return true; } if (StringUtil.isEmpty(password)) { if (test) { MessageDialog.openError(main.getShell(), Messages.JiraPreferencePageProvider_ERR_InvalidInput_Title, Messages.JiraPreferencePageProvider_ERR_EmptyPassword); return false; } return true; } setUILocked(true); firePreValidationStartEvent(); try { ModalContext.run(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.JiraPreferencePageProvider_ValidateCredentials, IProgressMonitor.UNKNOWN); try { getJiraManager().login(username, password); // successful; now re-layout to show the logout components UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { updateUserText(); layout(); } }); } catch (JiraException e) { throw new InvocationTargetException(e); } finally { if (!monitor.isCanceled()) { monitor.done(); } } } }, true, getProgressMonitor(), UIUtils.getDisplay()); } catch (InvocationTargetException e) { if (main != null && !main.isDisposed()) { MessageDialog.openError(main.getShell(), Messages.JiraPreferencePageProvider_ERR_LoginFailed_Title, e.getTargetException().getMessage()); } return false; } catch (Exception e) { IdeLog.logError(JiraUIPlugin.getDefault(), e); } finally { setUILocked(false); firePostValidationEndEvent(); } return true; }