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.php.debug.ui.phpini.PHPIniEditor.java
License:Open Source License
/** * Validate the PHP extensions./*from w ww. ja va 2s. c o m*/ * * @return True, if a validation process was initiated; False otherwise. A validation will not be initiated unless * the {@link #openFile(String)} was called before. */ public boolean validateExtensions() { if (provider == null) return false; if (provider.isDirtyINI()) { // Inform the user that the ini should be saved before the validation starts if (!MessageDialog.openQuestion(viewer.getTree().getShell(), Messages.PHPIniEditor_extensionValidatorTitle, Messages.PHPIniEditor_extensionValidatorQuestion)) { return false; } else { try { provider.save(); } catch (IOException e) { MessageDialog.openError(viewer.getTree().getShell(), Messages.PHPIniEditor_errorTitle, Messages.PHPIniEditor_errorSavingIniMessage); IdeLog.logError(PHPDebugPlugin.getDefault(), "Error saving the php.ini", e, IDebugScopes.DEBUG); //$NON-NLS-1$ } } } // Expand the tree Display.getDefault().asyncExec(new Runnable() { public void run() { viewer.expandAll(); } }); // Validate the extensions (new PHPIniValidator(provider, phpExePath, debuggerID)).validate(); // Refresh viewer.refresh(true); viewer.getTree().getParent().layout(true, true); return true; }
From source file:com.aptana.portal.ui.dispatch.configurationProcessors.installer.InstallerOptionsDialog.java
License:Open Source License
@Override protected void okPressed() { if (createInstallDir) { File f = new File(path.getText()); if (!f.exists() && !f.mkdirs()) { // Display an error message about the problem and return here to prevent a dialog close. MessageDialog.openError(getParentShell(), Messages.InstallerOptionsDialog_creatingDirectoriesErrorTitle, Messages.InstallerOptionsDialog_creatingDirectoriesErrorMessage); return; }/*from www. j a va 2 s. c o m*/ } super.okPressed(); }
From source file:com.aptana.projects.wizards.AbstractNewProjectWizard.java
License:Open Source License
@Override public boolean performFinish() { newProject = mainPage.getProjectHandle(); destPath = mainPage.getLocationPath(); location = null;/*ww w . ja v a 2 s . c o m*/ if (!mainPage.useDefaults()) { location = mainPage.getLocationURI(); } else { destPath = destPath.append(newProject.getName()); } if (templatesPage != null) { selectedTemplate = templatesPage.getSelectedTemplate(); } if (referencePage != null) { refProjects = referencePage.getReferencedProjects(); } boolean success = false; try { getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 6); try { createNewProject(subMonitor.newChild(4)); } catch (InvocationTargetException e) { throw new CoreException(new Status(IStatus.ERROR, ProjectsPlugin.PLUGIN_ID, 0, e.getMessage(), e.getTargetException())); } // Allow the project contributors to do work ProjectWizardContributionManager projectWizardContributionManager = ProjectsPlugin .getDefault().getProjectWizardContributionManager(); final IStatus contributorStatus = projectWizardContributionManager .performProjectFinish(newProject, subMonitor.newChild(1)); if (contributorStatus != null && !contributorStatus.isOK()) { // FIXME This UI code shouldn't be here, throw an exception up and handle it! // Show the error. Should we cancel project creation? UIUtils.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError(UIUtils.getActiveWorkbenchWindow().getShell(), Messages.AbstractNewProjectWizard_ProjectListenerErrorTitle, contributorStatus.getMessage()); } }); } // Perform post project hooks IStudioProjectListener[] projectListeners = new IStudioProjectListener[0]; IProjectDescription description = newProject.getDescription(); if (description != null) { projectListeners = StudioProjectListenersManager.getManager() .getProjectListeners(description.getNatureIds()); } int listenerSize = projectListeners.length; SubMonitor hookMonitor = SubMonitor.convert(subMonitor.newChild(1), Messages.AbstractNewProjectWizard_ProjectListener_TaskName, Math.max(1, listenerSize)); for (IStudioProjectListener projectListener : projectListeners) { if (projectListener != null) { final IStatus status = projectListener.projectCreated(newProject, hookMonitor.newChild(1)); // Show a dialog if there are failures if (status != null && status.matches(IStatus.ERROR)) { // FIXME This UI code shouldn't be here, throw an exception up and handle it! UIUtils.getDisplay().syncExec(new Runnable() { public void run() { String message = status.getMessage(); if (status instanceof ProcessStatus) { message = ((ProcessStatus) status).getStdErr(); } MessageDialog.openError( UIUtils.getActiveWorkbenchWindow().getShell(), Messages.AbstractNewProjectWizard_ProjectListenerErrorTitle, message); } }); } } } } }; try { ResourcesPlugin.getWorkspace().run(runnable, monitor); } catch (CoreException e) { throw new InvocationTargetException(e, Messages.AbstractNewProjectWizard_ProjectListener_NoDescriptor_Error); } } }); success = true; } catch (InterruptedException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, ProjectsPlugin.PLUGIN_ID, e.getMessage(), e), StatusManager.BLOCK); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ExecutionException && t.getCause() instanceof CoreException) { CoreException cause = (CoreException) t.getCause(); StatusAdapter status; if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { status = new StatusAdapter(new Status(IStatus.WARNING, ProjectsPlugin.PLUGIN_ID, NLS.bind(Messages.NewProjectWizard_Warning_DirectoryExists, mainPage.getProjectHandle().getName()), cause)); } else { status = new StatusAdapter(new Status(cause.getStatus().getSeverity(), ProjectsPlugin.PLUGIN_ID, Messages.NewProjectWizard_CreationProblem, cause)); } status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.NewProjectWizard_CreationProblem); StatusManager.getManager().handle(status, StatusManager.BLOCK); } else { StatusAdapter status = new StatusAdapter(new Status(IStatus.WARNING, ProjectsPlugin.PLUGIN_ID, 0, NLS.bind(Messages.NewProjectWizard_InternalError, t.getMessage()), t)); status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.NewProjectWizard_CreationProblem); StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK); } } if (!success) { return false; } // TODO Run all of this in a job? updatePerspective(); selectAndReveal(newProject); openIndexFile(); sendProjectCreateEvent(); return true; }
From source file:com.aptana.rcp.IDEApplication.java
License:Open Source License
/** * Return true if a valid workspace path has been set and false otherwise. Prompt for and set the path if possible * and required./* w w w . ja v a 2 s. c o m*/ * * @return true if a valid instance location has been set and false otherwise */ private boolean checkInstanceLocation(Shell shell) { // -data @none was specified but an ide requires workspace Location instanceLoc = Platform.getInstanceLocation(); if (instanceLoc == null) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceMandatoryTitle, IDEWorkbenchMessages.IDEApplication_workspaceMandatoryMessage); return false; } // -data "/valid/path", workspace already set if (instanceLoc.isSet()) { // make sure the meta data version is compatible (or the user has // chosen to overwrite it). if (!checkValidWorkspace(shell, instanceLoc.getURL())) { return false; } // at this point its valid, so try to lock it and update the // metadata version information if successful try { if (instanceLoc.lock()) { writeWorkspaceVersion(); return true; } // we failed to create the directory. // Two possibilities: // 1. directory is already in use // 2. directory could not be created File workspaceDirectory = new File(instanceLoc.getURL().getFile()); if (workspaceDirectory.exists()) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotLockTitle, IDEWorkbenchMessages.IDEApplication_workspaceCannotLockMessage); } else { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage); } } catch (IOException e) { IDEWorkbenchPlugin.log("Could not obtain lock for workspace location", //$NON-NLS-1$ e); MessageDialog.openError(shell, IDEWorkbenchMessages.InternalError, e.getMessage()); } return false; } // IPreferenceStore store = new ScopedPreferenceStore(new ConfigurationScope(), // IDEWorkbenchPlugin.IDE_WORKBENCH); // // boolean handledSHOW_WORKSPACE_SELECTION_DIALOG = store // .getBoolean(OVERRIDE_SHOW_WORKSPACE_SELECTION_DIALOG_DEFAULT); // if (!handledSHOW_WORKSPACE_SELECTION_DIALOG) // { // // We start with not asking the user for the workspace // store.setValue(IDE.Preferences.SHOW_WORKSPACE_SELECTION_DIALOG, false); // store.setValue(OVERRIDE_SHOW_WORKSPACE_SELECTION_DIALOG_DEFAULT, true); // } // -data @noDefault or -data not specified, prompt and set ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc.getDefault()); boolean force = false; while (true) { URL workspaceUrl = promptForWorkspace(shell, launchData, force); if (workspaceUrl == null) { return false; } // if there is an error with the first selection, then force the // dialog to open to give the user a chance to correct force = true; try { // the operation will fail if the url is not a valid // instance data area, so other checking is unneeded if (instanceLoc.set(workspaceUrl, true)) { launchData.writePersistedData(); writeWorkspaceVersion(); return true; } } catch (IOException e) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage); return false; } // by this point it has been determined that the workspace is // already in use -- force the user to choose again MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceInUseTitle, IDEWorkbenchMessages.IDEApplication_workspaceInUseMessage); } }
From source file:com.aptana.rcp.IDEApplication.java
License:Open Source License
/** * Open a workspace selection dialog on the argument shell, populating the argument data with the user's selection. * Perform first level validation on the selection by comparing the version information. This method does not * examine the runtime state (e.g., is the workspace already locked?). * //from w w w.j a v a2s . c o m * @param shell * @param launchData * @param force * setting to true makes the dialog open regardless of the showDialog value * @return An URL storing the selected workspace or null if the user has canceled the launch operation. */ private URL promptForWorkspace(Shell shell, ChooseWorkspaceData launchData, boolean force) { URL url = null; do { // okay to use the shell now - this is the splash shell new ChooseWorkspaceDialog(shell, launchData, false, true).prompt(force); String instancePath = launchData.getSelection(); if (instancePath == null) { return null; } // the dialog is not forced on the first iteration, but is on every // subsequent one -- if there was an error then the user needs to be // allowed to fix it force = true; // 70576: don't accept empty input if (instancePath.length() <= 0) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceEmptyTitle, IDEWorkbenchMessages.IDEApplication_workspaceEmptyMessage); continue; } // create the workspace if it does not already exist File workspace = new File(instancePath); if (!workspace.exists()) { workspace.mkdir(); } try { // Don't use File.toURL() since it adds a leading slash that // Platform does not // handle properly. See bug 54081 for more details. String path = workspace.getAbsolutePath().replace(File.separatorChar, '/'); url = new URL("file", null, path); //$NON-NLS-1$ } catch (MalformedURLException e) { MessageDialog.openError(shell, IDEWorkbenchMessages.IDEApplication_workspaceInvalidTitle, IDEWorkbenchMessages.IDEApplication_workspaceInvalidMessage); continue; } } while (!checkValidWorkspace(shell, url)); return url; }
From source file:com.aptana.syncing.ui.wizards.ExportConnectionsWizard.java
License:Open Source License
@Override public boolean performFinish() { IPath path = mainPage.getLocation(); boolean isOverwriting = mainPage.isOverwritingExistingFile(); // saves the preferences IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(SyncingUIPlugin.PLUGIN_ID); prefs.put(IPreferenceConstants.EXPORT_INITIAL_PATH, path.toOSString()); prefs.putBoolean(IPreferenceConstants.EXPORT_OVEWRITE_FILE_WITHOUT_WARNING, isOverwriting); try {/*w w w .j a va2s. co m*/ prefs.flush(); } catch (BackingStoreException e) { IdeLog.logError(SyncingUIPlugin.getDefault(), Messages.ExportConnectionsWizard_ERR_FailSaveExportPrefs, e); } File file = path.toFile(); if (file.exists()) { if (!isOverwriting) { if (!MessageDialog.openConfirm(getShell(), Messages.ExportConnectionsWizard_Overwrite_Title, MessageFormat.format(Messages.ExportConnectionsWizard_Overwrite_Message, file.getAbsolutePath()))) { return false; } } if (!file.canWrite()) { MessageDialog.openError(getShell(), Messages.ExportConnectionsWizard_Error_Title, MessageFormat .format(Messages.ExportConnectionsWizard_Error_Message, file.getAbsolutePath())); return false; } } CoreIOPlugin.getConnectionPointManager().saveState(path); return true; }
From source file:com.aptana.ui.s3.internal.S3ConnectionPropertyComposite.java
License:Open Source License
private void showErrorDialog(Throwable e) { String message = Messages.S3ConnectionPointPropertyDialog_DefaultErrorMsg; if (e instanceof CoreException) { message = ((CoreException) e).getStatus().getMessage(); }/*from w w w . j a v a 2s . co m*/ MessageDialog.openError(getShell(), Messages.S3ConnectionPointPropertyDialog_ErrorTitle, message); }
From source file:com.aptana.ui.util.UIUtils.java
License:Open Source License
private static void showErrorDialog(String title, String message) { MessageDialog.openError(getActiveWorkbenchWindow().getShell(), title, message); }
From source file:com.aptana.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * Create the project described in record. * //from www .j a va 2 s .c o m * @param record * @return an new project if successful, null if failed. */ private IProject createExistingProject(final ProjectRecord record) { Object[] checkedNatures = fTableViewer.getCheckedElements(); final List<String> natureIds = new ArrayList<String>(); 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); } for (Object nature : checkedNatures) { natureIds.add(nature.toString()); } // promotes the primary nature to the front if (fPrimaryNature != null) { natureIds.remove(fPrimaryNature); natureIds.add(0, fPrimaryNature); } // if nothing is checked off, we use the default web nature if (natureIds.isEmpty()) { natureIds.add(0, APTANA_WEB_NATURE); } record.description.setNatureIds(natureIds.toArray(new String[natureIds.size()])); 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)); project.setDescription(record.description, monitor); // We close and open the project to apply the natures correctly // project.close(monitor); // 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; }