List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:com.aptana.ide.syncing.ui.views.SmartSyncDialog.java
License:Open Source License
/** * @see org.eclipse.jface.window.Window#open() *//*from w w w . j a va 2 s .c o m*/ public int open() { if (sourceConnectionPoint instanceof IProjectProvider) { IProjectProvider projectProvider = (IProjectProvider) sourceConnectionPoint; IProject project = projectProvider.getProject(); if (project != null) { try { if (Boolean.TRUE.equals((Boolean) project.getSessionProperty(Synchronizer.SYNC_IN_PROGRESS))) { MessageDialog messageDialog = new MessageDialog(CoreUIUtils.getActiveShell(), Messages.SmartSyncDialog_SyncInProgressTitle, null, Messages.SmartSyncDialog_SyncInProgress, MessageDialog.QUESTION, new String[] { IDialogConstants.CANCEL_LABEL, Messages.SmartSyncDialog_ContinueLabel, }, 0); if (messageDialog.open() == 0) { return CANCEL; } } } catch (CoreException e) { } } } if (!compareInBackground) { super.open(); } load(true); return OK; }
From source file:com.aptana.ide.ui.ftp.dialogs.FTPConnectionPointPropertyDialog.java
License:Open Source License
@Override protected void okPressed() { if (!isValid()) { return;// w w w . ja v a 2 s . c om } if (DEFAULT_NAME.equals(nameText.getText())) { nameText.setText(hostText.getText()); } if (!connectionTested) { if (!testConnection()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.FTPConnectionPointPropertyDialog_ConfirmTitle, null, Messages.FTPConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, Messages.FTPConnectionPointPropertyDialog_LBL_Edit }, 2); int code = dlg.open(); switch (code) { case 1: super.okPressed(); case 2: return; default: } } } CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(ftpConnectionPoint), passwordText.getText().toCharArray(), savePasswordButton.getSelection()); boolean changed = savePropertiesTo(ftpConnectionPoint); if (isNew) { CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint); } else if (ftpConnectionPoint != originalFtpConnectionPoint) { CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalFtpConnectionPoint); CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint); } else if (changed) { CoreIOPlugin.getConnectionPointManager().connectionPointChanged(ftpConnectionPoint); } super.okPressed(); }
From source file:com.aptana.ide.ui.io.actions.CopyFilesOperation.java
License:Open Source License
/** * @param sourceStore/*from ww w . ja v a 2 s . c o m*/ * the file to be copied * @param destinationStore * the destination location * @param monitor * the progress monitor * @return true if the file is successfully copied, false if the operation did not go through for any reason */ protected boolean copyFile(IFileStore sourceStore, IFileStore destinationStore, IProgressMonitor monitor) { if (sourceStore == null || CloakingUtils.isFileCloaked(sourceStore)) { return false; } boolean success = true; monitor.subTask(MessageFormat.format(Messages.CopyFilesOperation_Copy_Subtask, sourceStore.getName(), destinationStore.getName())); if (destinationStore.equals(sourceStore)) { destinationStore = getNewNameFor(destinationStore); if (destinationStore == null) { return false; } } try { IFileStore[] childStores = Utils.isDirectory(sourceStore) ? sourceStore.childStores(EFS.NONE, monitor) : new IFileStore[0]; if (Utils.exists(destinationStore) && sourceStore.getName().equals(destinationStore.getName())) { // a name conflict; ask to overwrite if (overwriteStatus != OverwriteStatus.YES_TO_ALL) { final IFileStore dStore = destinationStore; final IFileStore sStore = sourceStore; fShell.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(fShell, Messages.CopyFilesOperation_OverwriteTitle, null, MessageFormat.format(Messages.CopyFilesOperation_OverwriteWarning, dStore.toString(), sStore.toString()), MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int retCode = dialog.open(); switch (retCode) { case 0: // Yes overwriteStatus = OverwriteStatus.YES; break; case 1: // Yes to All overwriteStatus = OverwriteStatus.YES_TO_ALL; break; case 2: // No overwriteStatus = OverwriteStatus.NO; break; default: overwriteStatus = OverwriteStatus.CANCEL; } } }); switch (overwriteStatus) { case CANCEL: monitor.setCanceled(true); // let it fall through since it would return false as well case NO: return false; } } } SyncUtils.copy(sourceStore, null, destinationStore, EFS.NONE, monitor); // copy the children recursively IFileStore destChildStore; for (IFileStore childStore : childStores) { destChildStore = destinationStore.getChild(childStore.getName()); copyFile(childStore, destChildStore, monitor); } } catch (CoreException e) { IdeLog.logError(IOUIPlugin.getDefault(), MessageFormat .format(Messages.CopyFilesOperation_ERR_FailedToCopy, sourceStore, destinationStore), e); success = false; } return success; }
From source file:com.aptana.internal.ui.text.spelling.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { final IScopeContext currContext = this.fLookupOrder[0]; final List /* <Key> */ changedOptions = new ArrayList(); boolean needsBuild = this.getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }//from w w w. j a v a 2 s . co m if (needsBuild) { final int count = this.getRebuildCount(); if (count > this.fRebuildCount) { needsBuild = false; // build already requested this.fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { final String[] strings = this.getFullBuildDialogStrings(true); if (strings != null) { final MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); final int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (container != null) { // no need to apply the changes to the original store: will be done // by the page container if (doBuild) { // post build this.incrementRebuildCount(); //container.registerUpdateJob(CoreUtility.getBuildJob(fProject)) // ; } } else { // apply changes right away try { this.fManager.applyChanges(); } catch (final BackingStoreException e) { // JavaPlugin.log(e); return false; } if (doBuild) { // CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//*from www .j a va 2s . c o m*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = UIUtils.getActiveShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ return Boolean.TRUE; case 1: return Boolean.TRUE; case 3: WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER); return Boolean.TRUE; default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format( Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5))); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, ((String) source).substring(10))); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } } IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, (String) source); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return Boolean.TRUE; case IDialogConstants.NO_ID: return Boolean.FALSE; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } }
From source file:com.aptana.js.debug.ui.internal.LaunchDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//*from w w w. j a v a 2s . c om*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = UIUtils.getActiveShell(); String title = Messages.LaunchDebuggerPromptStatusHandler_Title; String message = Messages.LaunchDebuggerPromptStatusHandler_DebuggerSessionIsActive; MessageDialog dlg = new MessageDialog(shell, title, null, message, MessageDialog.INFORMATION, new String[] { Messages.LaunchDebuggerPromptStatusHandler_CloseActiveSession, IDialogConstants.CANCEL_LABEL }, 1); return Boolean.valueOf(dlg.open() == Window.OK); }
From source file:com.aptana.syncing.ui.wizards.ImportConnectionsWizard.java
License:Open Source License
private int promptConflictDialog(String name, final int[] applyToAllAction) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportConnectionsWizard_Conflict_Title, null, MessageFormat.format(Messages.ImportConnectionsWizard_Conflict_Message, name), 0, new String[] { com.aptana.ui.IDialogConstants.OVERWRITE_LABEL, IDialogConstants.SKIP_LABEL, com.aptana.ui.IDialogConstants.RENAME_LABEL }, 0) {/*from w ww. j av a 2 s . c o m*/ @Override protected Control createCustomArea(Composite parent) { final Button applyToAll = new Button(parent, SWT.CHECK); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); applyToAll.setLayoutData(data); applyToAll.setText(Messages.ImportConnectionsWizard_Conflict_LBL_Apply); applyToAll.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (applyToAll.getSelection()) { applyToAllAction[0] = 0; } } public void widgetDefaultSelected(SelectionEvent e) { } }); return applyToAll; } }; int action = dialog.open(); if (applyToAllAction[0] == -1) { applyToAllAction[0] = action; } return action; }
From source file:com.aptana.terminal.internal.TerminalCloseHelper.java
License:Open Source License
public static boolean canCloseTerminal(IShellProvider shellProvider, LocalTerminalConnector terminalConnector) { List<String> processes = terminalConnector.getRunningProcesses(); if (processes.size() < 2) { return true; }/*w ww .j a va2 s. c o m*/ int closeId = 1; MessageDialog dialog = new MessageDialog(shellProvider.getShell(), Messages.TerminalCloseHelper_DialogTitle, null, Messages.TerminalCloseHelper_DialogMessage + processes.toString(), MessageDialog.QUESTION, new String[] { IDialogConstants.CANCEL_LABEL, IDialogConstants.CLOSE_LABEL }, closeId); return dialog.open() == closeId; }
From source file:com.aptana.ui.ftp.internal.FTPConnectionPropertyComposite.java
License:Open Source License
public boolean completeConnection() { if (DEFAULT_NAME.equals(nameText.getText())) { nameText.setText(hostText.getText()); }/*from www . j a va 2s . c om*/ if (!connectionTested) { if (!testConnection()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.FTPConnectionPointPropertyDialog_ConfirmTitle, null, Messages.FTPConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, Messages.FTPConnectionPointPropertyDialog_LBL_Edit }, 2); int code = dlg.open(); switch (code) { case 1: return true; case 2: return false; default: } } } CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(ftpConnectionPoint), passwordText.getText().toCharArray(), savePasswordButton.getSelection()); boolean changed = savePropertiesTo(ftpConnectionPoint); if (isNew) { CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint); } else if (ftpConnectionPoint != originalFtpConnectionPoint) // $codepro.audit.disable useEquals { ftpConnectionPoint.setId(originalFtpConnectionPoint.getId()); CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalFtpConnectionPoint); CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint); } else if (changed) { CoreIOPlugin.getConnectionPointManager().connectionPointChanged(ftpConnectionPoint); } return true; }
From source file:com.aptana.ui.s3.internal.S3ConnectionPropertyComposite.java
License:Open Source License
public boolean completeConnection() { if (DEFAULT_NAME.equals(nameText.getText())) { nameText.setText(hostText.getText()); }//from w ww. j a va2s . c o m if (!connectionTested) { if (!testConnection()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.S3ConnectionPointPropertyDialog_ConfirmTitle, null, Messages.S3ConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, Messages.S3ConnectionPointPropertyDialog_LBL_Edit }, 2); int code = dlg.open(); switch (code) { case 1: return true; case 2: return false; default: } } } CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(s3ConnectionPoint), passwordText.getText().toCharArray(), savePasswordButton.getSelection()); boolean changed = savePropertiesTo(s3ConnectionPoint); if (isNew) { CoreIOPlugin.getConnectionPointManager().addConnectionPoint(s3ConnectionPoint); } else if (s3ConnectionPoint != originalS3ConnectionPoint) { s3ConnectionPoint.setId(originalS3ConnectionPoint.getId()); CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalS3ConnectionPoint); CoreIOPlugin.getConnectionPointManager().addConnectionPoint(s3ConnectionPoint); } else if (changed) { CoreIOPlugin.getConnectionPointManager().connectionPointChanged(s3ConnectionPoint); } return true; }