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.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; }/*www . j av a 2 s . c om*/ 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 w ww . j av a2 s. 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 2 s . com*/ 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.radrails.rcp.IDEWorkbenchAdvisor.java
License:Open Source License
/** * Initialize the listener for settings changes. *///from ww w. ja va 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.rcp.IDEWorkbenchAdvisor.java
License:Open Source License
/** * Initialize the listener for settings changes. */// w w w. j a va2s . c om 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.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 w w. j ava 2 s. co 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; }//from w w w.j av a 2 s . co 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 w w w .j a v a 2 s .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()); }/* w w w . j a va 2 s .c om*/ 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; }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * The constructor./* ww w . j a v a 2 s. c o m*/ */ public UISeeCodePlugin() { super(); plugin = this; try { resourceBundle = ResourceBundle.getBundle("com.arc.cdt.debug.seecode.ui.SeeCode"); } catch (MissingResourceException x) { resourceBundle = null; } // // Create the object that intercepts "create-display" // // events from the core plugin so as to create // // the Custom seecode displays. // new DisplayCreatorDelegate(); // The core plugin doesn't "see" us to avoid // circular dependencies. But it needs to // instantiate the CustomDisplayCallback class // that is defined in this package. // We use a callback to do that: SeeCodePlugin.getDefault().setCustomDisplayCallbackCreator(new ICustomDisplayCallbackCreator() { @Override public ICustomDisplayCallback create(ICDITarget target) { return new CustomDisplayCallback(target); } }); SeeCodePlugin.getDefault().setLicenseExpirationChecker(new ILicenseExpirationChecker() { @Override public void checkLicenseExpiration(int days) { UISeeCodePlugin.this.checkLicensingAlert(days); } }); SeeCodePlugin.getDefault().setLicensingFailure(new ILicenseFailure() { @Override public void reportLicenseFailure(final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "A valid license for " + UISeeCodePlugin.getTheDebuggerName() + " was not found.\n\n" + msg; IStatus status = makeErrorStatus(fullMsg); ErrorDialog.openError(shell, UISeeCodePlugin.getDebuggerName() + " Licensing Failure", null, status); } }); } }); SeeCodePlugin.getDefault().setStatusWriter(new IStatusWriter() { @Override public void setStatus(final String msg) { // We need to get to the status line manager, but we can only get // access to from a viewsite. Unfortunately, we have // no direct reference to such. Therefore, look for // the debug view whose ID is "org.eclipse.debug.ui.DebugView" PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart viewPart = page.findView(IDebugUIConstants.ID_DEBUG_VIEW); if (viewPart != null) { IStatusLineManager statusLine = viewPart.getViewSite().getActionBars() .getStatusLineManager(); statusLine.setMessage(msg); } } } } }); } }); SeeCodePlugin.getDefault().setTermSimInstantiator(new TermSimInstantiator()); SeeCodePlugin.getDefault().setDisplayError(new IDisplayMessage() { @Override public void displayError(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showError(title, msg); } }); } @Override public void displayNote(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showNote(title, msg); } }); } }); SeeCodePlugin.getDefault().setEngineVersionStrategyCallback(new IEngineResolver() { @Override public boolean useToolSetEngine(final int bundledEngineId, final int toolsetEngineId, final String toolsetPath) { switch (SeeCodePlugin.getDefault().getPreferences().getInt( ISeeCodeConstants.PREF_ENGINE_VERSION_MANAGEMENT, ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET)) { case ISeeCodeConstants.ENGINE_VERSION_PROMPT: if (bundledEngineId != toolsetEngineId) { final boolean results[] = new boolean[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { results[0] = new PromptForEngineSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), bundledEngineId, toolsetEngineId, toolsetPath).open(); } }); return results[0]; } return false; case ISeeCodeConstants.ENGINE_VERSION_USE_BUNDLED: return false; case ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET: return true; case ISeeCodeConstants.ENGINE_VERSION_USE_LATEST: return toolsetEngineId > bundledEngineId; } return false; // shouldn't get here } }); /* SeeCodePlugin.getDefault().setProgramLoadTimeoutCallback(new IDiagnoseProgramLoadTimeout(){ public void diagnoseTimeout (final String exeName, final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run () { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine timed out while loading\n\"" + exeName + "\".\n" + "The current timeout for loading a program is " + timeout + " milliseconds.\n" + "If you have a slow target connection, or if you are doing a long-running\n"+ "blast operation, you may need to increase the timeout value. Go to the\n" + "preference page: \"Windows->Preferences->C/C++->Debugger->MetaWare Debugger\".\n"; IStatus status = SeeCodePlugin.makeErrorStatus(fullMsg); ErrorDialog.openError(shell, "Program load timeout failure", null, status); } }); }});*/ SeeCodePlugin.getDefault().setLoadTimeoutCallback(new ITimeoutCallback() { private int _newTimeout = 0; @Override public int getNewTimeout(final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine is attempting to load a program and it has not\n" + "completed after \"" + (timeout + 500) / 1000 + "\" seconds (as specified in the " + "MetaWare Debugger\npreferences page).\n\n" + "If you are loading over a slow connnection, or if you are doing a blast\n" + "operation, the engine may need more time.\n\n" + "What do you want the IDE to do?\n"; MessageDialog dialog = new MessageDialog(shell, "Engine Timeout Alert", null, // accept fullMsg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { Composite container = new Group(parent, 0); container.setLayout(new GridLayout(4, false)); GridData gd = new GridData(); gd.horizontalSpan = 1; gd.grabExcessHorizontalSpace = false; final Button b1 = new Button(container, SWT.RADIO); b1.setLayoutData(gd); b1.setText("Wait no longer;"); // Label on button appears to be limited in size; add additional // as a label Label label1 = new Label(container, SWT.LEFT); label1.setText("abort if load is not yet complete."); GridData gd1 = new GridData(); gd1.horizontalSpan = 3; gd1.grabExcessHorizontalSpace = true; label1.setLayoutData(gd1); gd = new GridData(); gd.horizontalSpan = 4; gd.grabExcessHorizontalSpace = true; final Button b2 = new Button(container, SWT.RADIO); b2.setLayoutData(gd); b2.setText("Continue waiting indefinitely."); final Button b3 = new Button(container, SWT.RADIO); b3.setText("Wait for an additional number of seconds"); b3.setLayoutData(gd); final Label label = new Label(container, SWT.LEFT); label.setText(" Number of additional seconds to wait: "); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); final Text field = new Text(container, SWT.SINGLE); field.setText("" + (timeout + 500) / 1000); gd = new GridData(); gd.horizontalSpan = 2; gd.grabExcessHorizontalSpace = true; gd.minimumWidth = 80; field.setLayoutData(gd); SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { if (e.widget == b1) { _newTimeout = 0; field.setEnabled(false); label.setEnabled(false); } else if (e.widget == b2) { _newTimeout = -1; field.setEnabled(false); label.setEnabled(false); } else { field.setEnabled(true); label.setEnabled(true); try { _newTimeout = Integer.parseInt(field.getText()) * 1000; } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } } }; b1.addSelectionListener(listener); b2.addSelectionListener(listener); b3.addSelectionListener(listener); field.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { try { if (b3.getSelection()) { _newTimeout = Integer.parseInt(field.getText()) * 1000; if (_newTimeout < 0) { field.setText("0"); _newTimeout = 0; } } } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } }); return container; } }; if (dialog.open() != Window.OK) { _newTimeout = 0; // terminate immediately. } } }); return _newTimeout; } }); /* * Set the Run wrapper for all engine callbacks so that they are in the UI thread. */ SeeCodePlugin.getDefault().setCallbackRunner(new IRunner() { @Override public void invoke(Runnable run, boolean async) throws Throwable { Display display = PlatformUI.getWorkbench().getDisplay(); try { // Run asynchronously to avoid deadlock of UI thread is // waiting for the engine to return. // display is null or disposed after workbench has shutdown, // but the engine may still be sending stuff... if (display != null && !display.isDisposed()) { if (async) { display.asyncExec(run); } else display.syncExec(run); } } catch (SWTException e) { if (e.throwable != null) { // If the display is disposed of after the above // check, but before the "run" is invoked, then // we can get an exception. Ignore such cases. if (display != null && !display.isDisposed()) throw e.throwable; } throw e; } } }); }