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.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. * // ww w . j a va 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.ide.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 va 2s . 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.ide.samples.ui.SamplesView.java
License:Open Source License
private File createTemporaryFile(final File file) { String fileName = FileUtils.stripExtension(file.getName()); String fileExt = "." + FileUtils.getExtension(file.getName()); //$NON-NLS-1$ File newFile = null;//from ww w . j av a 2 s .c om try { newFile = File.createTempFile(fileName, fileExt); } catch (final IOException e1) { _viewer.getControl().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError(_viewer.getControl().getShell(), Messages.SamplesView_UnableToPreview, Messages.SamplesView_ErrorOpening); IdeLog.logError(SamplesUIPlugin.getDefault(), StringUtils.format(Messages.SamplesView_UnableToCreateTemp, file.getAbsolutePath()), e1); } }); return null; } return newFile; }
From source file:com.aptana.ide.server.internal.XAMPPServer.java
License:Open Source License
/** * Starts the server//from ww w. ja v a 2 s. c om * * @throws CoreException */ public void start() throws CoreException { String executable = getPath(); String workingDirectory = null; if (executable != null && executable.length() > 0) { int index = executable.lastIndexOf(File.separatorChar); if (index > 0) { workingDirectory = executable.substring(0, index); } } IProcess exec = null; List<IServerLauncher> launchers = ServerLaunchers.getLaunchers(this.getServerType().getId()); if (launchers != null && launchers.size() != 0) { IServerLauncher launcher = launchers.get(0); if (!launcher.isConfigured()) { IServerEnvironmentConfigurator configurator = launcher.getConfigurator(); if (configurator.requiresAdditionalInformation()) { List<IServerLauncher> toConfigure = new ArrayList<IServerLauncher>(); toConfigure.add(launcher); ServerLauncherConfigurationWizard wizard = new ServerLauncherConfigurationWizard(getName(), toConfigure); WizardRunable runnable = new WizardRunable(wizard); Display.getDefault().syncExec(runnable); int result = runnable.getReturnCode(); if (result != Window.OK) { return; } } } exec = launcher.exec(executable, getPathParameters(), workingDirectory); if (exec == null) { MessageDialog.openError(null, Messages.XAMPPServer_Error_Title, Messages.XAMPPServer_Error_Start); } } else { exec = LaunchUtils.exec(executable, getPathParameters(), workingDirectory); } if (exec != null) { registerProcess(exec); } running = true; }
From source file:com.aptana.ide.server.internal.XAMPPServer.java
License:Open Source License
/** * Stops the server/*from www .ja va2 s.c om*/ * * @throws CoreException */ public void stop() throws CoreException { String executable = getStopPath(); String workingDirectory = null; if (executable != null && executable.length() > 0) { int index = executable.lastIndexOf(File.separatorChar); if (index > 0) { workingDirectory = executable.substring(0, index); } } IProcess exec = null; List<IServerLauncher> launchers = ServerLaunchers.getLaunchers(this.getServerType().getId()); if (launchers != null && launchers.size() != 0) { IServerLauncher launcher = launchers.get(0); if (!launcher.isConfigured()) { IServerEnvironmentConfigurator configurator = launcher.getConfigurator(); if (configurator.requiresAdditionalInformation()) { List<IServerLauncher> toConfigure = new ArrayList<IServerLauncher>(); toConfigure.add(launcher); ServerLauncherConfigurationWizard wizard = new ServerLauncherConfigurationWizard(getName(), toConfigure); WizardRunable runnable = new WizardRunable(wizard); Display.getDefault().syncExec(runnable); int result = runnable.getReturnCode(); if (result != Window.OK) { return; } } } exec = launcher.exec(executable, getStopPathParameters(), workingDirectory); if (exec == null) { MessageDialog.openError(null, Messages.XAMPPServer_Error_Title, Messages.XAMPPServer_Error_Stop); } } else { exec = LaunchUtils.exec(executable, getStopPathParameters(), workingDirectory); } if (exec != null) { registerProcess(exec); } running = false; }
From source file:com.aptana.ide.server.ui.LoadServerStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *///from ww w .j av a2 s . co m public Object handleStatus(final IStatus status, final Object source) throws CoreException { final Display default1 = Display.getDefault(); default1.asyncExec(new Runnable() { public void run() { Throwable exception = status.getException(); MessageDialog.openError(default1.getActiveShell(), StringUtils.format(Messages.LoadServerStatusHandler_HANDLE_SERVER_LOAD_ERROR_TITLE, source.toString()), StringUtils.format(Messages.LoadServerStatusHandler_Description, new String[] { source.toString(), exception.getClass().getName(), exception.getMessage() != null ? exception.getMessage() : "" })); //$NON-NLS-1$ } }); return null; }
From source file:com.aptana.ide.server.ui.views.actions.NewServerAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.Action#run() *//*from ww w . j av a 2s . com*/ public void run() { try { ICanAdd adapter = (ICanAdd) type.getAdapter(ICanAdd.class); if (adapter != null) { adapter.doAdd(); return; } IConfigurationDialog dialog = ServerDialogPageRegistry.getInstance().getDialog(type.getId()); dialog.setConfiguration(ServerManager.getInstance().getInitialServerConfiguration(type.getId())); dialog.setEdit(false); Dialog dialog3 = dialog.getDialog(); int open = dialog3.open(); if (open == Dialog.OK) { IAbstractConfiguration configuration = dialog.getConfiguration(); createdServer = ServerManager.getInstance().addServer(configuration); //checking if server requires patching List<IServerPatcher> patchers = ServerPatchers.getPatchers(createdServer.getServerType().getId()); if (patchers != null && patchers.size() != 0) { List<IServerPatcher> requiredPatchers = new ArrayList<IServerPatcher>(); for (IServerPatcher patcher : patchers) { if (patcher.checkPatchRequired(createdServer)) { requiredPatchers.add(patcher); } } //if patching is required if (requiredPatchers.size() != 0) { ServerPatchingWizard wizard = new ServerPatchingWizard(createdServer.getName(), requiredPatchers); WizardDialog wizardDialog = new WizardDialog(Display.getDefault().getActiveShell(), (IWizard) wizard); wizardDialog.create(); int result = wizardDialog.open(); if (result == Window.OK) { for (IServerPatcher patcher : requiredPatchers) { if (patcher.isConfigured()) { patcher.applyPatch(createdServer); } } } } } } } catch (Exception e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error while adding server", //$NON-NLS-1$ e.getMessage()); IdeLog.log(ServerUIPlugin.getDefault(), IStatus.ERROR, "exception while opening new server dialog", e); //$NON-NLS-1$ } }
From source file:com.aptana.ide.server.ui.views.GenericServersView.java
License:Open Source License
private void doDelete() { IStructuredSelection selection = (IStructuredSelection) serverViewer.getSelection(); if (selection.isEmpty()) { return;/*from www. j a v a 2 s .co m*/ } IServer server = (IServer) selection.getFirstElement(); if (!server.canDelete().isOK()) { return; } boolean mayStop = (server.getServerState() != IServer.STATE_STOPPED && server.getServerState() != IServer.STATE_UNKNOWN); boolean askStopBeforeDelete = (server.askStopBeforeDelete().getCode() == IStatus.OK); DeleteServerConfirmDialog dlg = new DeleteServerConfirmDialog(getViewSite().getShell(), Messages.ServersView_CONFIRM_DELETE, null, StringUtils.format(Messages.ServersView_CONFIRM_DELETE_TEXT, server.getName()), MessageDialog.QUESTION, new String[] { Messages.GenericServersView_YES, Messages.GenericServersView_NO }, 0, mayStop, askStopBeforeDelete); int openConfirm = dlg.open(); if (openConfirm != 0) { return; } boolean doStop = dlg.shouldStop; if (doStop) { server.stop(true, null, null); } try { ServerCore.getServerManager().removeServer(server); } catch (CoreException e) { MessageDialog.openError(getViewSite().getShell(), Messages.ServersView_CONFIRM_DELETE, StringUtils.format(Messages.ServersView_CONFIRM_DELETE_TEXT, server.getName())); } }
From source file:com.aptana.ide.server.ui.views.GenericServersView.java
License:Open Source License
private void doEdit(final IServer server) { // if (server.getServerState() != IServer.STATE_STOPPED && server.getServerState() != IServer.STATE_UNKNOWN) // {/* ww w .j av a 2s .c o m*/ // MessageDialog.openInformation(serverViewer.getControl().getShell(), // Messages.GenericServersView_ServerReadOnly_TITLE, // Messages.GenericServersView_ServerReadOnlyDescription); // return; // } IStatus canModify = server.canModify(); if (canModify != null && canModify.getCode() != IStatus.OK) { MessageDialog.openInformation(serverViewer.getControl().getShell(), Messages.GenericServersView_READONLY_TITLE, Messages.GenericServersView_READONLY_DESCRIPTION); return; } ICanEdit adapter = (ICanEdit) server.getAdapter(ICanEdit.class); if (adapter != null) { adapter.doEdit(); return; } IConfigurationDialog dialog = ServerDialogPageRegistry.getInstance() .getDialog(server.getServerType().getId()); Configuration cf = new Configuration(); server.storeConfiguration(cf); dialog.setConfiguration(cf); dialog.setServer(server); dialog.setEdit(true); int open = dialog.getDialog().open(); if (open == Dialog.OK) { IAbstractConfiguration configuration = dialog.getConfiguration(); // configuration.setStringAttribute(IServer.KEY_ID,ServerManager.getFreeId()); configuration.setStringAttribute(IServer.KEY_TYPE, server.getServerType().getId()); try { server.reconfigure(configuration); } catch (CoreException e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.GenericServersView_ERROR_WHILE_EDITING_DESCRIPTION, e.getMessage()); IdeLog.log(ServerUIPlugin.getDefault(), IStatus.ERROR, Messages.GenericServersView_ERROR_WHILE_EDITING_TITLE, e); } } IStructuredSelection selection = (IStructuredSelection) serverViewer.getSelection(); this.pauseAction.selectionChanged(new SelectionChangedEvent(this.serverViewer, selection)); }
From source file:com.aptana.ide.syncing.doms.Sync.java
License:Open Source License
/** * Uploads the file in the current editor. *//*ww w. j a v a2s .c om*/ public static void uploadCurrentEditor() { IEditorPart editor = CoreUIUtils.getActiveEditor(); if (editor == null) { if (!uploadCurrentSelection()) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.Sync_TTL_UnableToUpload, Messages.Sync_ERR_YouMustHaveACurrentlyOpenEditorToUpload); } return; } IEditorInput input = editor.getEditorInput(); if (input instanceof FileEditorInput) { upload(((FileEditorInput) input).getFile()); } else if (input instanceof IPathEditorInput) { IPath path = ((IPathEditorInput) input).getPath(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFileForLocation(path); if (file != null) { upload(file); } else { upload(path); } } else if (input instanceof IURIEditorInput) { IURIEditorInput editorInput = (IURIEditorInput) input; try { upload(EFS.getStore(editorInput.getURI())); } catch (CoreException e) { } } else { uploadCurrentSelection(); } }