List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:com.aptana.editor.common.preferences.ValidationPreferencePage.java
License:Open Source License
/** * If changes don't require a rebuild, return false. Otherwise prompt user and take their answer. * /* w w w.jav a 2s . co m*/ * @return */ private boolean rebuild() { if (promptForRebuild()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ValidationPreferencePage_RebuildDialogTitle, null, Messages.ValidationPreferencePage_RebuildDialogMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return (dialog.open() == 0); } return false; }
From source file:com.aptana.editor.php.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { hasChanges = false;//from www . j a v a2 s . c o m return true; } else { hasChanges = true; } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (doBuild) { prepareForBuild(); } if (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { IdeLog.logError(PHPEplPlugin.getDefault(), "Error applying changes", e); //$NON-NLS-1$ return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:com.aptana.formatter.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<PreferenceKey> changedOptions = new ArrayList<PreferenceKey>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }/*from w ww.j av a 2s .c om*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { IPreferenceChangeRebuildPrompt prompt = getPreferenceChangeRebuildPrompt(fProject == null, changedOptions); if (prompt != null) { MessageDialog dialog = new MessageDialog(getShell(), prompt.getTitle(), null, prompt.getMessage(), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); 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 incrementRebuildCount(); for (Job job : createBuildJobs(fProject)) { container.registerUpdateJob(job); } } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG); return false; } if (doBuild) { for (Job job : createBuildJobs(fProject)) { job.schedule(); } } } return true; }
From source file:com.aptana.git.ui.internal.actions.DiffHandler.java
License:Open Source License
@Override protected Object doExecute(ExecutionEvent event) throws ExecutionException { Map<String, String> diffs = new HashMap<String, String>(); List<ChangedFile> changedFiles = getSelectedChangedFiles(); if (changedFiles == null || changedFiles.isEmpty()) { return null; }/*from w ww .jav a 2 s. c o m*/ GitRepository repo = getSelectedRepository(); if (repo == null) { return null; } for (ChangedFile file : changedFiles) { if (file == null) { continue; } if (diffs.containsKey(file.getPath())) { continue; // already calculated diff... } String diff = repo.index().diffForFile(file, file.hasStagedChanges(), 3); diffs.put(file.getPath(), diff); } if (diffs.isEmpty()) { return null; } String diff = ""; //$NON-NLS-1$ try { diff = DiffFormatter.toHTML(diffs); } catch (Throwable t) { IdeLog.logError(GitUIPlugin.getDefault(), "Failed to turn diff into HTML", t, IDebugScopes.DEBUG); //$NON-NLS-1$ } final String finalDiff = diff; UIUtils.showMessageDialogFromBgThread(new SafeMessageDialogRunnable() { public int openMessageDialog() { MessageDialog dialog = new MessageDialog(getShell(), Messages.GitProjectView_GitDiffDialogTitle, null, "", 0, new String[] { IDialogConstants.OK_LABEL }, 0) //$NON-NLS-1$ { @Override protected Control createCustomArea(Composite parent) { Browser diffArea = new Browser(parent, SWT.BORDER); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.heightHint = 300; diffArea.setLayoutData(data); diffArea.setText(finalDiff); return diffArea; } @Override protected boolean isResizable() { return true; } }; return dialog.open(); } }); return null; }
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. * //from w w w . j a v a 2 s. 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) */// w ww . j a va 2 s. co m 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) */// w ww . ja v a 2 s . co 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.server.ui.views.actions.OpenStatisticsAction.java
License:Open Source License
/** * @see org.eclipse.jface.action.Action#run() *//*from w w w . j a v a 2 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;//from w w w .jav a2s . co 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 ava 2 s.c om*/ 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; }