List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.toubassi.filebunker.ui.configuration.EditWebMailFileStoreDialog.java
License:Open Source License
private boolean validateFields() { if (emailField.getText().length() == 0) { MessageDialog.openError(getShell(), "Error", "Please specify a " + "valid gmail address for this email repository."); return false; } else {//from w w w . j a v a 2s . c om String address = emailField.getText() + "@gmail.com"; try { new InternetAddress(address); } catch (AddressException e) { MessageDialog.openError(getShell(), "Error", "Please specify a " + "valid gmail address for this email repository."); return false; } for (int i = 0; i < stores.size(); i++) { FileStore otherStore = (FileStore) stores.get(i); if (otherStore instanceof WebMailFileStore) { WebMailFileStore webMailStore = (WebMailFileStore) otherStore; if (webMailStore != store && webMailStore.email().equals(address)) { MessageDialog.openError(getShell(), "Error", "You have already " + "defined an email repository for " + address + ". Please " + "specify a unique email address."); return false; } } } // If the store's email was changed, and the store does contain backup files, // then warn the user because changing the name is tantamount to deleting the // old store (and the files backed up to that store cannot be restored). if (store.email() != null && !address.equals(store.email()) && vault.doesStoreContainBackupFiles(store)) { boolean ok = MessageDialog.openQuestion(getShell(), "Warning", "You have changed the email address to " + address + ". Files have previously been backed up to " + store.email() + " and will not be accessible if you " + "proceed with the change of email address. Do you want " + "to proceed?"); if (!ok) { return false; } } } String passwordValue = passwordField.getText(); String confirmPasswordValue = confirmPasswordField.getText(); if (!passwordValue.equals(confirmPasswordValue)) { MessageDialog.openError(getShell(), "Error", "The password has not " + "been correctly confirmed. The 'Password' and 'Confirm " + "Password' fields should match to ensure that your password " + "is recorded correctly."); return false; } if (passwordValue.length() == 0) { MessageDialog.openError(getShell(), "Error", "Please specify the password " + "that you use to login to your gmail account."); return false; } return true; }
From source file:com.vectrace.MercurialEclipse.actions.MergeWithCurrentChangesetAction.java
License:Open Source License
@Override public void run() { final MercurialRevision rev = getRevision(); new SafeWorkspaceJob(Messages.getString("MergeWithCurrentChangesetAction.0") + rev.getContentIdentifier() //$NON-NLS-1$ + Messages.getString("MergeWithCurrentChangesetAction.1")) { //$NON-NLS-1$ @Override//from w w w . j a va 2s. c o m protected org.eclipse.core.runtime.IStatus runSafe(org.eclipse.core.runtime.IProgressMonitor monitor) { try { monitor.beginTask( Messages.getString("MergeWithCurrentChangesetAction.2") + rev.getContentIdentifier() //$NON-NLS-1$ + Messages.getString("MergeWithCurrentChangesetAction.3"), //$NON-NLS-1$ 3); monitor.subTask(Messages.getString("MergeWithCurrentChangesetAction.4")); //$NON-NLS-1$ final HgRoot root = rev.getHgRoot(); if (root == null) { MercurialEclipsePlugin.logError(new IllegalStateException("Hg root not found for: " + rev)); return Status.CANCEL_STATUS; } monitor.worked(1); monitor.subTask(Messages.getString("MergeWithCurrentChangesetAction.5")); //$NON-NLS-1$ new SafeUiJob("Merging...") { //$NON-NLS-1$ @Override protected IStatus runSafe(IProgressMonitor m) { Shell activeShell = getDisplay().getActiveShell(); try { if (HgStatusClient.isDirty(root)) { if (!MessageDialog.openQuestion(activeShell, Messages.getString("MergeWithCurrentChangesetAction.6"), //$NON-NLS-1$ Messages.getString("MergeWithCurrentChangesetAction.7"))) { //$NON-NLS-1$ return super.runSafe(m); } } MergeHandler.mergeAndCommit(root, activeShell, m, true, rev.getChangeSet(), true); } catch (Exception e) { MercurialEclipsePlugin.logError(e); MercurialEclipsePlugin.showError(e); } return super.runSafe(m); } }.schedule(); } catch (Exception e) { MercurialEclipsePlugin.logError(e); MercurialEclipsePlugin.showError(e); } monitor.done(); return super.runSafe(monitor); } }.schedule(); super.run(); }
From source file:com.vectrace.MercurialEclipse.history.MercurialHistoryPage.java
License:Open Source License
public BaseSelectionListenerAction getRevertAction() { if (revertAction == null) { final String replaceString = Messages.getString("MercurialHistoryPage.replaceCurrentWithSelected"); final String restoreString = Messages.getString("MercurialHistoryPage.restoreDeletedFile"); final String undoMoveString = Messages.getString("MercurialHistoryPage.undoMove"); revertAction = new BaseSelectionListenerAction(replaceString) { @Override//from w w w. j a va2s .c o m public void run() { IStructuredSelection selection = getStructuredSelection(); if (selection.isEmpty()) { return; } ActionRevert revert = new ActionRevert(); MercurialRevision revision = (MercurialRevision) selection.getFirstElement(); IResource selectedElement = revision.getResource(); MercurialStatusCache cache = MercurialStatusCache.getInstance(); if (!cache.isUnknown(selectedElement) && !cache.isClean(selectedElement) && !MessageDialog.openQuestion(getControl().getShell(), Messages.getString("MercurialHistoryPage.UncommittedChanges"), //$NON-NLS-1$ Messages.getString("MercurialHistoryPage.file") + selectedElement.getName() //$NON-NLS-1$ + Messages.getString("MercurialHistoryPage.hasUncommittedChanges"))) { //$NON-NLS-1$ return; } selection = new StructuredSelection(selectedElement); revert.setChangesetToRevert(revision.getChangeSet()); revert.selectionChanged(this, selection); revert.run(this); } @Override protected boolean updateSelection(IStructuredSelection sSelection) { if (sSelection.size() != 1) { return false; } if (sSelection.size() == 1) { Object element = sSelection.getFirstElement(); if (element instanceof MercurialRevision) { MercurialRevision rev = (MercurialRevision) element; if (rev.getResource() instanceof IFile) { if (rev.getChangeSet().isRemoved(rev.getResource())) { setText(restoreString); } else if (rev.getChangeSet().isMoved(rev.getResource())) { setText(undoMoveString); } else { setText(replaceString); } return true; } } } return false; } }; revertAction.setImageDescriptor(MercurialEclipsePlugin.getImageDescriptor("actions/revert.gif")); //$NON-NLS-1$ } return revertAction; }
From source file:com.vectrace.MercurialEclipse.menu.SwitchHandler.java
License:Open Source License
@Override public void run(HgRoot hgRoot) throws CoreException { boolean lossConfirmed = false; if (HgStatusClient.isDirty(hgRoot)) { if (!MessageDialog.openQuestion(getShell(), Messages.getString("SwitchHandler.pendingChangesConfirmation.1"), //$NON-NLS-1$ Messages.getString("SwitchHandler.pendingChangesConfirmation.2"))) { //$NON-NLS-1$ return; }//from www . j av a 2 s . c o m lossConfirmed = true; } RevisionChooserDialog dialog = new RevisionChooserDialog(getShell(), Messages.getString("SwitchHandler.switchTo") + (hgRoot != null ? ": " + hgRoot.getName() : ""), //$NON-NLS-1$ hgRoot); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { UpdateJob job = new UpdateJob(dialog.getRevision(), true, hgRoot, false); job.setDataLossConfirmed(lossConfirmed); job.schedule(); } }
From source file:com.vectrace.MercurialEclipse.team.CompareAction.java
License:Open Source License
/** * @param file non null//from w w w. j a v a 2s . co m */ @Override protected void run(final IResource resource) throws TeamException { Job job = new Job("Diff for " + resource.getName()) { @Override protected IStatus run(IProgressMonitor monitor) { boolean workspaceUpdateConflict = isUncommittedCompare && resource instanceof IFile && MercurialStatusCache.getInstance().isWorkspaceUpdateConfict((IFile) resource); if (workspaceUpdateConflict) { // This job shouldn't run in the UI thread despite needing it a lot because it // invokes hg multiple times. final Boolean[] resultRef = { Boolean.FALSE }; getShell().getDisplay().syncExec(new Runnable() { public void run() { resultRef[0] = Boolean.valueOf(MessageDialog.openQuestion(getShell(), "Compare", "This file is in conflict. Would you like to use resolve to *RESTART* the merge with 3-way differences? Warning: if resolve fails this operations can potentially lose changes. If in doubt select 'No'.")); } }); workspaceUpdateConflict = resultRef[0].booleanValue(); } if (mergeEnabled || workspaceUpdateConflict) { CompareUtils.openMergeEditor((IFile) resource, workspaceUpdateConflict); return Status.OK_STATUS; } boolean clean = MercurialStatusCache.getInstance().isClean(resource); if (!clean) { compareToLocal(resource); return Status.OK_STATUS; } try { HgRoot root = MercurialRootCache.getInstance().getHgRoot(resource); Changeset[] parents = HgParentClient.getParents(root, resource); ChangeSet cs = LocalChangesetCache.getInstance().get(root, parents[0]); if (cs != null) { // TODO: compare with parent on a project? if (resource instanceof IFile) { CompareUtils.openEditor(resource, MercurialUtilities.getParentRevision(cs, (IFile) resource), false, null); } return Status.OK_STATUS; } } catch (TeamException e) { MercurialEclipsePlugin.logError(e); } // something went wrong. So compare to local compareToLocal(resource); return Status.OK_STATUS; } }; job.schedule(); }
From source file:com.vectrace.MercurialEclipse.utils.CompareUtils.java
License:Open Source License
public static void openEditor(final IResource left, final RevisionNode right, final boolean dialog, final ISynchronizePageConfiguration configuration) throws HgException { Assert.isNotNull(right);//from www . ja va2 s .c om if (!left.getProject().isOpen()) { final boolean[] open = new boolean[1]; Runnable runnable = new Runnable() { public void run() { open[0] = MessageDialog.openQuestion(null, "Compare", "To compare selected file, enclosing project must be opened.\n" + "Open the appropriate project (may take time)?"); } }; getDisplay().syncExec(runnable); if (open[0]) { try { left.getProject().open(null); } catch (CoreException e) { MercurialEclipsePlugin.logError(e); } } else { return; } } if (dialog) { // TODO: is it intentional the config is ignored? openCompareDialog(getPrecomputedCompareInput(null, left, null, right)); } else { openEditor(getPrecomputedCompareInput(configuration, left, null, right)); } }
From source file:com.wdev91.eclipse.copyright.preferences.CopyrightPreferencePage.java
License:Open Source License
/** * Deletes the currently selected Copyright. *///ww w .j a v a 2s .com protected void deleteCopyright() { Copyright c = getSelection(); if (c != null && MessageDialog.openQuestion(this.getShell(), Messages.CopyrightPreferencePage_titleDelete, NLS.bind(Messages.CopyrightPreferencePage_msgConfirmDelete, c.getLabel()))) { if (input.deleteCopyright(c)) { copyrightsList.remove(c); updateContent(); } } }
From source file:com.wdev91.eclipse.copyright.preferences.ProjectCopyrightPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Font font = parent.getFont(); Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0;//from w ww.j av a2 s. co m layout.marginWidth = 0; top.setLayout(layout); top.setFont(font); Label l1 = new Label(top, SWT.NONE); l1.setText(Messages.CopyrightPreferencePage_labelOwner); ownerText = new Text(top, SWT.BORDER); GridData data = new GridData(); data.widthHint = 200; ownerText.setLayoutData(data); enableButton = new Button(top, SWT.CHECK); enableButton.setText(Messages.ProjectCopyrightPreferencePage_checkboxEnable); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; enableButton.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; new Label(top, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(data); tab = new TabFolder(top, SWT.TOP); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; tab.setLayoutData(data); TabItem headerTab = new TabItem(tab, SWT.NONE); headerTab.setText(Messages.CopyrightPreferencePage_labelHeader); headerText = new Text(tab, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); headerTab.setControl(headerText); TabItem formatsTab = new TabItem(tab, SWT.NONE); formatsTab.setText(Messages.ProjectCopyrightPreferencePage_tabFormats); formats = new FormatsPanel(tab, SWT.NONE); formatsTab.setControl(formats); enableButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { boolean enabled = enableButton.getSelection(); if (firstEnabled && enabled) { if (MessageDialog.openQuestion(getShell(), Messages.ProjectCopyrightPreferencePage_tabFormats, Messages.ProjectCopyrightPreferencePage_msgInitialize)) { formats.setFormats(CopyrightManager.getHeadersFormats()); } firstEnabled = false; } doEnable(enabled); } }); doEnable(false); ProjectPreferences preferences = CopyrightManager.getProjectPreferences(project); if (preferences != null && preferences != ProjectPreferences.NO_PREFS) { if (preferences.getOwner() != null) { ownerText.setText(preferences.getOwner()); } if (preferences.getHeaderText() != null || preferences.getFormats() != null) { enableButton.setSelection(true); String text = preferences.getHeaderText(); if (text != null) { headerText.setText(text); } Map<String, HeaderFormat> hf = preferences.getFormats(); if (hf != null) { formats.setFormats(hf.values()); } doEnable(true); } } PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, CONTEXT_ID); ownerText.setFocus(); return top; }
From source file:com.windowtester.eclipse.ui.launcher.RecorderWorkbenchLaunchConfDelegate.java
License:Open Source License
private void optionallyInjectBundles(final ILaunchConfiguration configuration) throws CoreException { if (BundleInjection.isDisabled()) return;//from www. j av a2s. c o m if (!validConfig(configuration)) { injectBundles = configuration.getAttribute(INJECT_BUNDLES_KEY, true); if (!injectBundles) { Display.getDefault().syncExec(new Runnable() { public void run() { boolean openQuestion = MessageDialog.openQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("RecorderWorkbenchLaunchConfDelegate.MISSED_BUNDLES_TITLE"), //$NON-NLS-1$ Messages.getString("RecorderWorkbenchLaunchConfDelegate.MISSED_BUNDLES_QUESTION")); //$NON-NLS-1$ injectBundles = openQuestion; try { ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy(); copy.setAttribute(INJECT_BUNDLES_KEY, injectBundles); copy.doSave(); } catch (CoreException e) { LogHandler.log(e); } } }); } } }
From source file:de.anbos.eclipse.logviewer.plugin.action.delegate.ClearHistoryActionDelegate.java
License:Apache License
private boolean askClear(Shell shell) { return MessageDialog.openQuestion(shell, LogViewerPlugin.getResourceString("misc.clearhisrory.title"), LogViewerPlugin.getResourceString("misc.clearhisrory.text")); }