Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#OK
The following examples show how to use
org.eclipse.jface.dialogs.MessageDialog#OK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnmanageAction.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * open the deltion confirmation dialog * returns true if deletion is confirmed */ boolean confirmDeleteProjects() { final int[] result = new int[] { MessageDialog.OK }; IProject[] projects = getSelectedProjects(); final DeleteProjectDialog dialog = new DeleteProjectDialog(shell, projects); shell.getDisplay().syncExec(new Runnable() { public void run() { result[0] = dialog.open(); } }); deleteContent = dialog.getDeleteContent(); // No longer need to show warning message if meta data is being deleted // since it is now possible to reconnect. // if (deleteContent && result[0] == 0) { // String title; // if (projects.length == 1) // title = Policy.bind("Unmanage.title"); //$NON-NLS-1$ // else // title = Policy.bind("Unmanage.titleN"); //$NON-NLS-1$ // return MessageDialog.openQuestion(shell, title, Policy.bind("Unmanage.deleteMeta"));//$NON-NLS-1$ // } return result[0] == 0; // YES }
Example 2
Source File: SplitTermHandler.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection == null || !(selection instanceof IStructuredSelection)) { return null; } IStructuredSelection currentSelection = (IStructuredSelection) selection; if (currentSelection.size() == 1) { Term termToSplit = (Term) currentSelection.getFirstElement(); if (selectionValid(termToSplit)) { SplitTermDialog dialog = new SplitTermDialog(null, termToSplit.getName()); if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) { TermSplitter.split(termToSplit, dialog.getDefaultTermName(), dialog.getFurtherTermNames()); } } else { ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected term must not have children.", null)); } } return null; }
Example 3
Source File: MergeTermsHandler.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection == null || !(selection instanceof IStructuredSelection)) { return null; } IStructuredSelection currentSelection = (IStructuredSelection) selection; if (currentSelection.size() > 1) { List<Term> termsToMerge = new ArrayList<>(currentSelection.size()); currentSelection.toList().stream().filter(s -> s instanceof Term).forEach(s -> termsToMerge.add((Term) s)); if (selectionValid(termsToMerge)) { MergeTermsDialog dialog = new MergeTermsDialog(null, termsToMerge); dialog.setBlockOnOpen(true); if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) { TermMerger.merge(termsToMerge, dialog.getTargetTerm()); } } else { ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected terms must not share their paths.", null)); } } return null; }
Example 4
Source File: ApplicationLayoutBasicsPanel.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
private boolean showConfigWarning() { String msg = "If you change the configuration, all attribute values associated with the current configuration will be lost. Do you want to continue?"; // $NLX-ApplicationLayoutBasicsPanel.Youareabouttochangetheconfigurati-1$ MessageDialog dlg = new MessageDialog( getShell(), "Domino Designer", // $NLX-ApplicationLayoutDropDialog.Dominodesigner-1$ null, // image msg, MessageDialog.WARNING, new String[]{ "Continue", "Cancel" }, // $NLX-ApplicationLayoutBasicsPanel.Continue-1$ $NLX-ApplicationLayoutBasicsPanel.Cancel-2$ 1); int code = dlg.open(); // "Continue" was returning 256.. but then started returning 0 at some point...did SWT version change (it was pending)? boolean bShouldContinue = (code == MessageDialog.OK); //Only continue if 'OK' (Continue) is pressed - otherwise bail out return bShouldContinue; }
Example 5
Source File: DbDeleteAction.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void run() { if (configs == null || configs.isEmpty()) { IDatabaseConfiguration config = Database.getActiveConfiguration(); if (config == null) return; configs = Collections.singletonList(config); } if (createMessageDialog().open() != MessageDialog.OK) return; if (!checkCloseEditors()) return; App.run(M.DeleteDatabase, () -> doDelete(), () -> { Navigator.refresh(); HistoryView.refresh(); CompareView.clear(); ValidationView.clear(); }); }
Example 6
Source File: GenerateChangeLogDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void okPressed() { if (fileButton.getSelection()) { File file = new File(fileText.getText().trim()); if (file.exists()) { String title = Policy.bind("GenerateSVNDiff.overwriteTitle"); //$NON-NLS-1$ String msg = Policy.bind("GenerateSVNDiff.overwriteMsg"); //$NON-NLS-1$ final MessageDialog messageDialog = new MessageDialog(Display.getDefault().getActiveShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); if (!(messageDialog.open() == MessageDialog.OK)) return; } } if (!generateChangeLog(false)) { return; } super.okPressed(); }
Example 7
Source File: DialogUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * openIgnoreMessageDialogInformation * * @param shell * @param title * @param message * @param store * @param key * @return int */ public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, IPreferenceStore store, String key) { if (!store.getString(key).equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle d = MessageDialogWithToggle.openInformation(shell, title, message, Messages.DialogUtils_HideMessage, false, store, key); if (d.getReturnCode() == 3) { return MessageDialog.CANCEL; } } return MessageDialog.OK; }
Example 8
Source File: DeleteTermHandler.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection == null || !(selection instanceof IStructuredSelection)) { return null; } IStructuredSelection currentSelection = (IStructuredSelection) selection; if (currentSelection.size() > 0) { MessageDialog dialog = new MessageDialog(null, "Delete Term", null, "Are you sure you want to delete terms: " + currentSelection.toList() .stream() .filter(s -> s instanceof Term) .map(s -> ((Term) s).getName()) .collect(Collectors.joining(", ")), MessageDialog.QUESTION, new String[]{"Yes", "Cancel"}, 0); dialog.setBlockOnOpen(true); if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) { List<Term> termsToDelete = new ArrayList<>(currentSelection.size()); currentSelection.toList().stream() .filter(s -> s instanceof Term) .forEach(s -> termsToDelete.add((Term) s));; TermDeleter.delete(termsToDelete); } } return null; }
Example 9
Source File: MoveTermHandler.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection == null || !(selection instanceof IStructuredSelection)) { return null; } IStructuredSelection currentSelection = (IStructuredSelection) selection; if (currentSelection.size() > 0 ) { List<Term> termsToMove = new ArrayList<>(currentSelection.size()); currentSelection.toList().stream().filter(s -> s instanceof Term).forEach(s -> termsToMove.add((Term) s)); if (selectionValid(termsToMove)) { Model allowedTargets = computeAllowedTargets(termsToMove); MoveTermDialog dialog = new MoveTermDialog( null, termsToMove.stream().map(t -> t.getName()).collect(Collectors.toList()), allowedTargets); dialog.setBlockOnOpen(true); if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) { TermMover.move(termsToMove, (Term) dialog.getResult()[0], dialog.getTermPosition()); } } else { ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected terms must not share their paths.", null)); } } return null; }
Example 10
Source File: PyDialogHelpers.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public static int openWarningWithIgnoreToggle(String title, String message, String key) { Shell shell = EditorUtils.getShell(); IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String val = store.getString(key); if (val.trim().length() == 0) { val = MessageDialogWithToggle.PROMPT; //Initial value if not specified } if (!val.equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle.openWarning(shell, title, message, "Don't show this message again", false, store, key); } return MessageDialog.OK; }
Example 11
Source File: SWTUtil.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static int statusLevelToMessageDialogKing(StatusLevel statusLevel) { switch (statusLevel) { case ERROR: return MessageDialog.ERROR; case WARNING: return MessageDialog.WARNING; case INFO: return MessageDialog.INFORMATION; case OK: return MessageDialog.OK; } throw assertFail(); }
Example 12
Source File: CommentAction.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void run(){ InputDialog inputDialog = new InputDialog(shell, "Kommentar Erfassen", "Bitte geben Sie einen Kommentar ein", comment, null, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); if (inputDialog.open() == MessageDialog.OK) { comment = inputDialog.getValue(); init(); } super.run(); }
Example 13
Source File: DateAction.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void run(){ DateTimeSelectorDialog inputDialog = new DateTimeSelectorDialog(shell, new TimeTool(localDateTime), true); if (inputDialog.open() == MessageDialog.OK) { TimeTool timeTool = inputDialog.getSelectedDate(); if (timeTool != null) { this.localDateTime = timeTool.toLocalDateTime(); init(); } } super.run(); }
Example 14
Source File: SaveDirtyEditorAbstractHandler.java From tlaplus with MIT License | 4 votes |
/** * @param event * @return true iff the dirty editor has been saved, false otherwise */ public boolean saveDirtyEditor(final ExecutionEvent event) { activeEditor = UIHelper.getActiveEditor(); if (activeEditor.isDirty()) { getPrefs().setDefault(this.getClass() + ".dontBother", false); if (getPrefs().getBoolean(this.getClass() + ".dontBother")) { // TODO decouple from ui thread // Use NullProgressMonitor instead of newly created monitor. The // parent ProgressMonitorDialog would need to be properly // initialized first. // @see Bug #256 in general/bugzilla/index.html // // Generally though, saving a resource involves I/O which should be // decoupled from the UI thread in the first place. Properly doing // this, would be from inside a Job which provides a ProgressMonitor activeEditor.doSave(new NullProgressMonitor()); } else { final Shell shell = HandlerUtil.getActiveShell(event); final MessageDialog dialog = new SaveMessageDialog(shell, getDialogTitle(), getDialogMessage()); int res = dialog.open(); if (res == 2) { // 2 is index of button in string[] below // User doesn't want to be warned about a dirty editor any longer. // Remember it for this handler (this.getClass). getPrefs().setValue(this.getClass() + ".dontBother", true); res = MessageDialog.OK; } if (res == MessageDialog.OK || res == MessageDialog.CONFIRM) { // TODO decouple from ui thread // Use NullProgressMonitor instead of newly created monitor. The // parent ProgressMonitorDialog would need to be properly // initialized first. // @see Bug #256 in general/bugzilla/index.html // // Generally though, saving a resource involves I/O which should be // decoupled from the UI thread in the first place. Properly doing // this, would be from inside a Job which provides a ProgressMonitor activeEditor.doSave(new NullProgressMonitor()); } else { return false; } } } return true; }