List of usage examples for org.eclipse.jface.dialogs MessageDialog CONFIRM
int CONFIRM
To view the source code for org.eclipse.jface.dialogs MessageDialog CONFIRM.
Click Source Link
From source file:com.vectrace.MercurialEclipse.menu.UpdateJob.java
License:Open Source License
/** * Call from the UI thread./*w ww. java 2 s . co m*/ * @return True if loss was confirmed. */ private static boolean showConfirmDataLoss(Shell shell) { MessageDialog dialog = new MessageDialog(shell, Messages.getString("UpdateJob.uncommittedChanges1"), null, Messages.getString("UpdateJob.uncommittedChanges2"), MessageDialog.CONFIRM, new String[] { Messages.getString("UpdateJob.continueAndDiscard"), IDialogConstants.CANCEL_LABEL }, 1 // default index - cancel ); dialog.setBlockOnOpen(true); return dialog.open() == 0; }
From source file:com.vectrace.MercurialEclipse.synchronize.actions.PushPullSynchronizeOperation.java
License:Open Source License
private void checkChangesets(final IProgressMonitor monitor, int csCount, RepositoryChangesetGroup rcGroup) { if (csCount < 1) { // paranoia... monitor.setCanceled(true);/*from w w w .j a v a 2 s.c o m*/ return; } final String title; final String message; // // Get the repo logical name in order to embed it in the message shown to the user. // IPreferenceStore store = MercurialEclipsePlugin.getDefault().getPreferenceStore(); boolean showRepoLogicalName = store .getBoolean(MercurialPreferenceConstants.PREF_SHOW_LOGICAL_NAME_OF_REPOSITORIES); String repoName = ""; if (rcGroup.getRoot() != null && showRepoLogicalName) { IHgRepositoryLocation repoLocation = participant.getRepositoryLocation(rcGroup.getRoot()); if (!StringUtils.isEmpty(repoLocation.getLogicalName())) { repoName = " ([" + repoLocation.getLogicalName() + "])"; } } // if (isPull) { title = "Hg Pull"; message = "Pulling " + csCount + " changesets (or more) from the remote repository" + repoName + ".\n" + "The pull will fetch the *latest* version available remotely.\n" + "Continue?"; } else { if (csCount == 1) { return; } title = "Hg Push"; message = "Pushing " + csCount + " changesets to the remote repository" + repoName + ". Continue?"; } getShell().getDisplay().syncExec(new Runnable() { public void run() { if (!MercurialEclipsePlugin.showDontShowAgainConfirmDialog(title, message, MessageDialog.CONFIRM, MercurialPreferenceConstants.PREF_SHOW_PULL_WARNING_DIALOG, getShell())) { monitor.setCanceled(true); } } }); }
From source file:com.vectrace.MercurialEclipse.synchronize.actions.PushPullSynchronizeOperation.java
License:Open Source License
/** * Checks whether all conditions (related to projects) necessary for a normal operation are * fulfilled. The monitor is canceled when the operation should not continue. * <p>/*from w w w .j a v a 2s . c o m*/ * Conditions: * <ul> * <li>There must be at least one project. * <li>All projects impacted must be open. * </ul> */ private void checkProjects(final IProgressMonitor monitor, HgRoot hgRoot) { Set<IProject> projects = ResourceUtils.getProjects(hgRoot); if (!isPull || projects.size() <= 1) { if (projects.size() == 0) { // paranoia monitor.setCanceled(true); } return; } final String title = "Hg Pull"; final String message = "Pull will affect " + projects.size() + " projects in workspace. Continue?"; getShell().getDisplay().syncExec(new Runnable() { public void run() { if (!MercurialEclipsePlugin.showDontShowAgainConfirmDialog(title, message, MessageDialog.CONFIRM, MercurialPreferenceConstants.PREF_SHOW_MULTIPLE_PROJECTS_DIALOG, getShell())) { monitor.setCanceled(true); } } }); }
From source file:com.vectrace.MercurialEclipse.views.PatchQueueView.java
License:Open Source License
/** * @see com.vectrace.MercurialEclipse.views.AbstractRootView#createActions() */// w w w . j a v a 2 s . c o m @Override protected void createActions() { qImportAction = new Action("qimport...", MercurialEclipsePlugin.getImageDescriptor("import.gif")) { //$NON-NLS-1$ @Override public void run() { try { QImportHandler.openWizard(hgRoot, getSite().getShell()); } catch (Exception e) { MercurialEclipsePlugin.logError(e); } } }; qImportAction.setEnabled(false); qNewAction = new Action("qnew...", MercurialEclipsePlugin.getImageDescriptor("import.gif")) { //$NON-NLS-1$ @Override public void run() { try { QNewHandler.openWizard(hgRoot, getSite().getShell()); } catch (Exception e) { MercurialEclipsePlugin.logError(e); } } }; qNewAction.setEnabled(false); qRefreshAction = new Action("qrefresh...", //$NON-NLS-1$ MercurialEclipsePlugin.getImageDescriptor("actions/qrefresh.gif")) { @Override public void run() { QRefreshHandler.openWizard(hgRoot, getSite().getShell()); } }; qRefreshAction.setEnabled(false); qGotoAction = new MQPatchAction(Messages.getString("PatchQueueView.switchTo"), RefreshRootJob.LOCAL_AND_OUTGOING, "QPushRejectsDialog.conflict", false) { @Override public boolean doInvoke() throws HgException { // Switch to the first selected patch. There is only one patch selected because // the action is disabled if zero or more than one patches are selected. Patch patch = table.getSelection(); if (patch != null) { if (patch.isApplied()) { HgQPopClient.pop(hgRoot, false, patch.getName()); } else { HgQPushClient.push(hgRoot, false, patch.getName()); } return true; } return false; } }; qGotoAction.setImageDescriptor(MercurialEclipsePlugin.getImageDescriptor("actions/switch.gif")); qGotoAction.setEnabled(false); qPushAllAction = new MQPatchAction(Messages.getString("PatchQueueView.applyAll"), RefreshRootJob.LOCAL_AND_OUTGOING, "QPushRejectsDialog.conflict", true) { @Override public boolean doInvoke() throws HgException { HgQPushClient.pushAll(hgRoot, false); return true; } }; qPushAllAction.setEnabled(true); qPopAllAction = new MQAction(Messages.getString("PatchQueueView.unapplyAll"), RefreshRootJob.LOCAL_AND_OUTGOING) { @Override public boolean invoke() throws HgException { HgQPopClient.popAll(hgRoot, false); return true; } }; qPopAllAction.setEnabled(false); qFoldAction = new MQPatchAction("qfold", RefreshRootJob.LOCAL_AND_OUTGOING, "QFoldRejectsDialog.conflict", false) { @Override public boolean doInvoke() throws HgException { List<Patch> patches = new ArrayList<Patch>(table.getSelections()); if (patches.size() > 0) { Collections.sort(patches, new Comparator<Patch>() { public int compare(Patch o1, Patch o2) { return TableSortListener.sort(o1.getIndex(), o2.getIndex()); } }); HgQFoldClient.fold(hgRoot, true, null, patches); return true; } return false; } @Override protected boolean isPatchConflict(HgException e) { return HgQFoldClient.isPatchConflict(e); } }; qFoldAction.setEnabled(false); stripAction = new Action("strip...", MercurialEclipsePlugin.getImageDescriptor("actions/revert.gif")) { //$NON-NLS-1$ @Override public void run() { try { // TODO: set initial selection to selected applied patch StripHandler.openWizard(hgRoot, getSite().getShell(), null); } catch (Exception e) { MercurialEclipsePlugin.logError(e); } } }; stripAction.setEnabled(false); qDeleteAction = new Action("qdelete...", MercurialEclipsePlugin.getImageDescriptor("rem_co.gif")) { //$NON-NLS-1$ @Override public void run() { QDeleteHandler.openWizard(hgRoot, getSite().getShell(), false); } }; qDeleteAction.setEnabled(false); qFinishAction = new MQAction("qfinish", MercurialEclipsePlugin.getImageDescriptor("actions/qrefresh.gif"), RefreshRootJob.LOCAL) { @Override public boolean invoke() throws HgException { List<Patch> patches = table.getSelections(); Patch max = null; boolean unappliedSelected = false; for (Patch p : patches) { if (p.isApplied()) { if (max == null || p.getIndex() > max.getIndex()) { max = p; } } else { unappliedSelected = true; } } List<Patch> toApply = new ArrayList<Patch>(table.getItems()); for (Iterator<Patch> it = toApply.iterator(); it.hasNext();) { Patch cur = it.next(); if (!cur.isApplied()) { it.remove(); } else if (max != null && cur.getIndex() > max.getIndex()) { it.remove(); } } if (toApply.size() == 0) { MessageDialog.openInformation(getSite().getShell(), "No applied patches", "Only applied patches can be promoted."); } else if (max == null) { if (unappliedSelected) { MessageDialog.openInformation(getSite().getShell(), "Only applied patches can be promoted", "Only applied patches can be promoted. Select an applied patch to promote."); } else if (MercurialEclipsePlugin.showDontShowAgainConfirmDialog("Promote all applied patches?", "No patches selected, promote all " + toApply.size() + " applied patches?", MessageDialog.CONFIRM, MercurialPreferenceConstants.PREF_SHOW_QFINISH_WARNING_DIALOG, getSite().getShell())) { HgQFinishClient.finish(hgRoot, toApply); return true; } } else if (toApply.size() == 1 || MercurialEclipsePlugin.showDontShowAgainConfirmDialog( "QFinish multiple patches", "Promote " + toApply.size() + " patches?", MessageDialog.CONFIRM, MercurialPreferenceConstants.PREF_SHOW_QFINISH_WARNING_DIALOG, getSite().getShell())) { HgQFinishClient.finish(hgRoot, toApply); return true; } return false; } }; qFinishAction.setEnabled(false); table.getTableViewer().addPostSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateEnablement((IStructuredSelection) event.getSelection()); } }); }
From source file:com.xse.eclipseui.dialog.MessageDialogHelper.java
License:Open Source License
/** * Convenience method to open a simple confirm (OK/Cancel) dialog. * * @param title//ww w . j a v a 2 s .c o m * the dialog's title, or <code>null</code> if none * @param message * the message * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise */ public static boolean openConfirm(final String title, final String message) { final ValueContainer<Boolean> result = new ValueContainer<>(Boolean.FALSE); Display.getDefault().syncExec(new Runnable() { @Override public void run() { result.setValue(Boolean.valueOf(MessageDialog.open(MessageDialog.CONFIRM, Display.getDefault().getActiveShell(), title, message, SWT.NONE))); } }); return result.getValue().booleanValue(); }
From source file:cu.uci.abos.core.util.MessageDialogUtil.java
License:Open Source License
public static void openConfirm(Shell parent, String title, String message, DialogCallback callback) { open(MessageDialog.CONFIRM, parent, title, message, callback); }
From source file:cu.uci.abos.core.util.MessageDialogUtil.java
License:Open Source License
private static String[] getButtonLabels(int kind) { String[] dialogButtonLabels;// w ww . j a v a 2 s. com switch (kind) { case MessageDialog.ERROR: case MessageDialog.INFORMATION: case MessageDialog.WARNING: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_CLOSE }; break; } case MessageDialog.CONFIRM: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL }; break; } case MessageDialog.QUESTION: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL }; break; } case MessageDialog.QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL, AbosMessages.get().BUTTON_CLOSE }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); } } return dialogButtonLabels; }
From source file:de.blizzy.backup.BackupShell.java
License:Open Source License
BackupShell(Display display) { shell = new Shell(display, SWT.SHELL_TRIM ^ SWT.MAX); shell.setText(Messages.Title_BlizzysBackup); shell.setImages(BackupApplication.getWindowImages()); GridLayout layout = new GridLayout(1, false); layout.marginWidth = 20;//from w w w.j av a 2s . c o m layout.marginHeight = 20; layout.verticalSpacing = 15; shell.setLayout(layout); Composite logoAndHeaderComposite = new Composite(shell, SWT.NONE); layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = 15; logoAndHeaderComposite.setLayout(layout); Canvas logoCanvas = new Canvas(logoAndHeaderComposite, SWT.DOUBLE_BUFFERED); logoCanvas.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { Image image = BackupPlugin.getDefault().getImageDescriptor("etc/logo/logo_48.png") //$NON-NLS-1$ .createImage(e.display); e.gc.drawImage(image, 0, 0); image.dispose(); } }); GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); gd.widthHint = 48; gd.heightHint = 48; logoCanvas.setLayoutData(gd); Link headerText = new Link(logoAndHeaderComposite, SWT.NONE); headerText.setText(NLS.bind(Messages.Version, BackupPlugin.VERSION, BackupPlugin.COPYRIGHT_YEARS)); Composite buttonsComposite = new Composite(shell, SWT.NONE); layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = 10; layout.verticalSpacing = 15; buttonsComposite.setLayout(layout); buttonsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); FontData[] fontDatas = buttonsComposite.getFont().getFontData(); for (FontData fontData : fontDatas) { fontData.setHeight((int) (fontData.getHeight() * 1.5d)); } final Font bigFont = new Font(display, fontDatas); Point extent = getMaxTextExtent(display, bigFont, Messages.Button_Settings, Messages.Button_Restore, Messages.Button_BackupNow); Button settingsButton = new Button(buttonsComposite, SWT.PUSH); settingsButton.setText(Messages.Button_Settings); settingsButton.setFont(bigFont); gd = new GridData(SWT.FILL, SWT.FILL, false, true); gd.widthHint = (int) (extent.x * 1.6d); gd.heightHint = extent.y * 2; settingsButton.setLayoutData(gd); Label label = new Label(buttonsComposite, SWT.NONE); label.setText(Messages.ModifyBackupSettings); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); restoreButton = new Button(buttonsComposite, SWT.PUSH); restoreButton.setText(Messages.Button_Restore); restoreButton.setFont(bigFont); gd = new GridData(SWT.FILL, SWT.FILL, false, true); gd.widthHint = (int) (extent.x * 1.6d); gd.heightHint = extent.y * 2; restoreButton.setLayoutData(gd); updateRestoreButton(); label = new Label(buttonsComposite, SWT.NONE); label.setText(Messages.RestoreFromBackup); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); backupNowButton = new Button(buttonsComposite, SWT.PUSH); backupNowButton.setText(Messages.Button_BackupNow); backupNowButton.setFont(bigFont); gd = new GridData(SWT.FILL, SWT.FILL, false, true); gd.widthHint = (int) (extent.x * 1.6d); gd.heightHint = extent.y * 2; backupNowButton.setLayoutData(gd); updateBackupNowButton(); label = new Label(buttonsComposite, SWT.NONE); label.setText(Messages.RunBackupNow); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); if (BackupPlugin.getDefault().isCheckGui()) { checkButton = new Button(buttonsComposite, SWT.PUSH); checkButton.setText(Messages.Button_Check); checkButton.setFont(bigFont); gd = new GridData(SWT.FILL, SWT.FILL, false, true); gd.widthHint = (int) (extent.x * 1.6d); gd.heightHint = extent.y * 2; checkButton.setLayoutData(gd); updateCheckButton(); label = new Label(buttonsComposite, SWT.NONE); label.setText(Messages.CheckBackup); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); } Composite progressStatusComposite = new Composite(shell, SWT.NONE); layout = new GridLayout(1, false); layout.marginWidth = 0; layout.marginHeight = 0; progressStatusComposite.setLayout(layout); progressStatusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); progressComposite = new Composite(progressStatusComposite, SWT.NONE); layout = new GridLayout(3, false); layout.marginWidth = 0; layout.marginHeight = 0; progressComposite.setLayout(layout); progressComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); progressBar = new ProgressBar(progressComposite, SWT.HORIZONTAL | SWT.SMOOTH); progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); progressBar.setMinimum(0); updateProgressVisibility(); ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); pauseAction = new Action(Messages.Button_PauseBackup, IAction.AS_CHECK_BOX) { @Override public void run() { if (backupRun != null) { backupRun.setPaused(pauseAction.isChecked()); } } }; ImageDescriptor imgDesc = BackupPlugin.getDefault().getImageDescriptor("etc/icons/pause.gif"); //$NON-NLS-1$ pauseAction.setImageDescriptor(imgDesc); pauseAction.setToolTipText(Messages.Button_PauseBackup); toolBarManager.add(pauseAction); stopAction = new Action() { @Override public void run() { if (backupRun != null) { pauseAction.setChecked(false); pauseAction.setEnabled(false); stopAction.setEnabled(false); backupRun.stopBackup(); } } }; imgDesc = BackupPlugin.getDefault().getImageDescriptor("etc/icons/stop.gif"); //$NON-NLS-1$ stopAction.setImageDescriptor(imgDesc); stopAction.setToolTipText(Messages.Button_StopBackup); toolBarManager.add(stopAction); ToolBar toolBar = toolBarManager.createControl(progressComposite); toolBar.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); statusLabel = new Link(progressStatusComposite, SWT.NONE); statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); updateStatusLabel(null); shell.pack(); headerText.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { new LicenseDialog(shell).open(); } }); settingsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { editSettings(); } }); restoreButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { restore(); } }); backupNowButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BackupApplication.scheduleBackupRun(true); } }); if (checkButton != null) { checkButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BackupApplication.runCheck(); } }); } statusLabel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.text.equals("errors")) { //$NON-NLS-1$ showErrors(); } } }); shell.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { bigFont.dispose(); } }); shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) { MessageDialog dlg = new MessageDialog(shell, Messages.Title_ExitApplication, null, Messages.ExitApplication, MessageDialog.CONFIRM, new String[] { Messages.Button_Exit, Messages.Button_MinimizeOnly }, 1); if (dlg.open() == 0) { BackupApplication.quit(); } else { e.doit = false; BackupApplication.hideShell(); } } @Override public void shellIconified(ShellEvent e) { e.doit = false; BackupApplication.hideShell(); } }); shell.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { handleDispose(); } }); BackupApplication.getSettingsManager().addListener(settingsListener); settingsButton.forceFocus(); }
From source file:de.uni_koeln.ub.drc.ui.handlers.ExitHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); EditView ev = (EditView) activeWorkbenchWindow.getActivePage().findView(EditView.ID); if (ev != null && ev.isDirty()) { MessageDialog dialog = new MessageDialog(ev.getSite().getShell(), Messages.get().SavePage, null, Messages.get().CurrentPageModified, MessageDialog.CONFIRM, new String[] { IDialogConstantsHelper.getYesLabel(), IDialogConstantsHelper.getNoLabel() }, 0); dialog.create();//from w ww.j a v a2 s . c om if (dialog.open() == Window.OK) { ev.doSave(new NullProgressMonitor()); } } // SessionContextSingleton.getInstance().exit(); return PlatformUI.getWorkbench().close(); }
From source file:de.uni_koeln.ub.drc.ui.views.EditView.java
License:Open Source License
private void attachSelectionListener() { ISelectionService selectionService = (ISelectionService) getSite().getService(ISelectionService.class); ScrolledCompositeHelper.fixWrapping(sc, editComposite); selectionService.addSelectionListener(new ISelectionListener() { @Override/*w ww . j ava 2 s .c o m*/ public void selectionChanged(IWorkbenchPart part, ISelection selection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.getFirstElement() instanceof Page) { @SuppressWarnings("unchecked") List<Page> pages = structuredSelection.toList(); if (pages != null && pages.size() > 0) { Page page = pages.get(0); if (dirtyable) { MessageDialog dialog = new MessageDialog(editComposite.getShell(), Messages.get().SavePage, null, Messages.get().CurrentPageModified, MessageDialog.CONFIRM, new String[] { IDialogConstantsHelper.getYesLabel(), IDialogConstantsHelper.getNoLabel() }, 0); dialog.create(); if (dialog.open() == Window.OK) { doSave(new NullProgressMonitor()); } } editComposite.update(page); sc.setMinHeight(editComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); if (page.id().equals(SessionContextSingleton.getInstance().getCurrentUser().latestPage())) { focusLatestWord(); } } } } }); }