List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:com.aptana.ide.core.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user * whether the existing resource at the given path should be overwritten. * /* w w w . j av a2s . c o m*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or * <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//*from w ww .j ava 2 s .c om*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); 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[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$ /* continue */ case 1: return new Boolean(true); case 3: WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$ return new Boolean(true); default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, new String[] { ((String) source).substring(5) })); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, new String[] { ((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; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } } IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return new Boolean(true); } } String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, new String[] { (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(IDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return new Boolean(true); case IDialogConstants.NO_ID: return new Boolean(false); default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.debug.internal.ui.LaunchDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//*from ww w . ja v a2 s .c o m*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); 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 new Boolean(dlg.open() == 0); }
From source file:com.aptana.ide.rcp.IDEWorkbenchAdvisor.java
License:Open Source License
/** * Initialize the listener for settings changes. *//*from www.j a v a 2 s . c o m*/ private void initializeSettingsChangeListener() { settingsChangeListener = new Listener() { boolean currentHighContrast = Display.getCurrent().getHighContrast(); public void handleEvent(org.eclipse.swt.widgets.Event event) { if (Display.getCurrent().getHighContrast() == currentHighContrast) return; currentHighContrast = !currentHighContrast; // make sure they really want to do this if (new MessageDialog(null, IDEWorkbenchMessages.SystemSettingsChange_title, null, IDEWorkbenchMessages.SystemSettingsChange_message, MessageDialog.QUESTION, new String[] { IDEWorkbenchMessages.SystemSettingsChange_yes, IDEWorkbenchMessages.SystemSettingsChange_no }, 1).open() == Window.OK) { PlatformUI.getWorkbench().restart(); } } }; }
From source file:com.aptana.ide.server.ui.views.actions.OpenStatisticsAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.Action#run() *///from w w w.java2 s . c o m public void run() { ISelection selection = provider.getSelection(); if (selection instanceof StructuredSelection && !selection.isEmpty()) { StructuredSelection ss = (StructuredSelection) selection; if (ss.getFirstElement() != null && ss.getFirstElement() instanceof IServer) { IServer server = (IServer) ss.getFirstElement(); if (server.suppliesStatisticsInterface()) { server.showStatisticsInterface(); } else { String stats = server.fetchStatistics(); MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), StringUtils.format(Messages.OpenStatisticsAction_Stats_Title, server.getName()), null, stats, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0) { protected Control createMessageArea(Composite composite) { super.createMessageArea(composite); GridData mlData = new GridData(SWT.FILL, SWT.FILL, true, true); super.messageLabel.setLayoutData(mlData); return composite; } protected int getMessageLabelStyle() { return SWT.LEFT; } }; dialog.open(); } } } }
From source file:com.aptana.ide.syncing.ui.actions.SyncActionEventHandler.java
License:Open Source License
private void showError(final String message, final Exception e) { fContinue = false;/* w w w . ja va 2 s .c o m*/ UIUtils.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog md = new MessageDialog(UIUtils.getActiveShell(), CoreStrings.ERROR + " " + fTaskTitle, //$NON-NLS-1$ null, message, MessageDialog.WARNING, new String[] { CoreStrings.CONTINUE, CoreStrings.CANCEL }, 1); fContinue = (md.open() == 0); } }); }
From source file:com.aptana.ide.syncing.ui.dialogs.SiteConnectionsEditorDialog.java
License:Open Source License
protected boolean doSelectionChange() { if (sitePropertiesWidget.isChanged()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.SiteConnectionsEditorDialog_SaveConfirm_Title, null, MessageFormat.format(Messages.SiteConnectionsEditorDialog_SaveConfirm_Message, sitePropertiesWidget.getSource().getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1);/*ww w . j a v a 2s. co m*/ switch (dlg.open()) { case 1: if (sitePropertiesWidget.applyChanges()) { break; } else { // unresolved error exists in the current selection MessageDialog.openWarning(getShell(), Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Title, Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Message); } case 2: return false; } } return true; }
From source file:com.aptana.ide.syncing.ui.views.SmartSyncDialog.java
License:Open Source License
/** * @see org.eclipse.jface.window.Window#open() *///from www .j av a 2s .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;/*from ww w . j av a 2s . co m*/ } 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 w ww .ja va2s . 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; }