List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:org.eclipse.titanium.error.GUIErrorHandler.java
License:Open Source License
@Override public void reportWarning(final String text) { ErrorMessage.show("Warning", text, MessageDialog.WARNING); }
From source file:org.eclipse.tycho.targeteditor.dialogs.RepositoryDeletionConfirmDialog.java
License:Open Source License
RepositoryDeletionConfirmDialog(final List<IRepository> selectedRepositories, final List<IRepository> extraDeletedRepositories) { super(null, DIALOG_TITLE, null, DIALOG_MESSAGE, MessageDialog.WARNING, DIALOG_BUTTON_LABELS, 0); final StringBuffer textBuffer = new StringBuffer(); textBuffer.append("Repositories selected for deletion:"); appendRepositories(textBuffer, selectedRepositories); textBuffer.append("\n"); textBuffer.append("Repositories in the same location that also will be deleted:"); appendRepositories(textBuffer, extraDeletedRepositories); // TODO publish additional help page // textBuffer.append("\n"); // textBuffer.append("More information: ...wiki.../Remove+Repository+from+a+Location+with+many+Repositories"); repositoriesText = textBuffer.toString(); }
From source file:org.eclipse.ui.ide.dialogs.ResourceEncodingFieldEditor.java
License:Open Source License
protected void doStore() { String encoding = getSelectedEncoding(); // Clear the value if nothing is selected if (isDefaultSelected()) { encoding = null;/*from w ww.jav a 2 s . co m*/ } // Don't update if the same thing is selected final boolean hasSameEncoding = hasSameEncoding(encoding); final boolean hasSameSeparateDerivedEncodings = hasSameSeparateDerivedEncodings(); if (hasSameEncoding && hasSameSeparateDerivedEncodings) { return; } String descriptionCharset = getCharsetFromDescription(); if (descriptionCharset != null && !(descriptionCharset.equals(encoding)) && encoding != null) { Shell shell = null; DialogPage page = getPage(); if (page != null) { shell = page.getShell(); } MessageDialog dialog = new MessageDialog(shell, IDEWorkbenchMessages.ResourceEncodingFieldEditor_EncodingConflictTitle, null, NLS.bind(IDEWorkbenchMessages.ResourceEncodingFieldEditor_EncodingConflictMessage, encoding, descriptionCharset), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // yes is the // default if (dialog.open() > 0) { return; } } IDEEncoding.addIDEEncoding(encoding); final String finalEncoding = encoding; Job charsetJob = new Job(IDEWorkbenchMessages.IDEEncoding_EncodingJob) { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ protected IStatus run(IProgressMonitor monitor) { try { if (!hasSameEncoding) { if (resource instanceof IContainer) { ((IContainer) resource).setDefaultCharset(finalEncoding, monitor); } else { ((IFile) resource).setCharset(finalEncoding, monitor); } } if (!hasSameSeparateDerivedEncodings) { Preferences prefs = new ProjectScope((IProject) resource) .getNode(ResourcesPlugin.PI_RESOURCES); if (getStoredSeparateDerivedEncodingsValue()) prefs.remove(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS); else prefs.putBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, true); prefs.flush(); } return Status.OK_STATUS; } catch (CoreException e) {// If there is an error return the // default IDEWorkbenchPlugin.log(IDEWorkbenchMessages.ResourceEncodingFieldEditor_ErrorStoringMessage, e.getStatus()); return e.getStatus(); } catch (BackingStoreException e) { IDEWorkbenchPlugin.log(IDEWorkbenchMessages.ResourceEncodingFieldEditor_ErrorStoringMessage, e); return new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, e.getMessage(), e); } } }; charsetJob.schedule(); }
From source file:org.eclipse.ui.internal.operations.AdvancedValidationUserApprover.java
License:Open Source License
private IStatus reportAndInterpretStatus(IStatus status, IAdaptable uiInfo, IUndoableOperation operation, int doing) { // Nothing to report if we are running automated tests. We will treat // warnings as if they were authorized by the user. if (AUTOMATED_MODE) { if (status.getSeverity() == IStatus.WARNING) { return Status.OK_STATUS; }//from ww w.j av a 2 s . com return status; } // CANCEL status is assumed to be initiated by the user, so there // is nothing to report. if (status.getSeverity() == IStatus.CANCEL) { return status; } // Other status severities are reported with a message dialog. // First obtain a shell and set up the dialog title. boolean createdShell = false; IStatus reportedStatus = status; Shell shell = getShell(uiInfo); if (shell == null) { createdShell = true; shell = new Shell(); } // Set up the dialog. For non-error statuses, we use a warning dialog // that allows the user to proceed or to cancel out of the operation. if (!(status.getSeverity() == IStatus.ERROR)) { String warning, title; switch (doing) { case UNDOING: warning = WorkbenchMessages.Operations_proceedWithNonOKUndoStatus; if (status.getSeverity() == IStatus.INFO) { title = WorkbenchMessages.Operations_undoInfo; } else { title = WorkbenchMessages.Operations_undoWarning; } break; case REDOING: warning = WorkbenchMessages.Operations_proceedWithNonOKRedoStatus; if (status.getSeverity() == IStatus.INFO) { title = WorkbenchMessages.Operations_redoInfo; } else { title = WorkbenchMessages.Operations_redoWarning; } break; default: // EXECUTING warning = WorkbenchMessages.Operations_proceedWithNonOKExecuteStatus; if (status.getSeverity() == IStatus.INFO) { title = WorkbenchMessages.Operations_executeInfo; } else { title = WorkbenchMessages.Operations_executeWarning; } break; } String message = NLS.bind(warning, new Object[] { status.getMessage(), operation.getLabel() }); String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, buttons, 0); int dialogAnswer = dialog.open(); // The user has been given the specific status and has chosen // to proceed or to cancel. The user choice determines what // the status should be at this point, OK or CANCEL. if (dialogAnswer == Window.OK) { reportedStatus = Status.OK_STATUS; } else { reportedStatus = Status.CANCEL_STATUS; } } else { String title, stopped; switch (doing) { case UNDOING: title = WorkbenchMessages.Operations_undoProblem; stopped = WorkbenchMessages.Operations_stoppedOnUndoErrorStatus; break; case REDOING: title = WorkbenchMessages.Operations_redoProblem; stopped = WorkbenchMessages.Operations_stoppedOnRedoErrorStatus; break; default: // EXECUTING title = WorkbenchMessages.Operations_executeProblem; stopped = WorkbenchMessages.Operations_stoppedOnExecuteErrorStatus; break; } // It is an error condition. The user has no choice to proceed, so // we only report what has gone on. We use a warning icon instead of // an error icon since there has not yet been a failure. String message = NLS.bind(stopped, status.getMessage(), operation.getLabel()); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); // ok dialog.open(); } if (createdShell) { shell.dispose(); } return reportedStatus; }
From source file:org.eclipse.ui.internal.views.markers.DeleteHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) { final MarkerSupportView view = getView(event); if (view == null) return this; final IMarker[] selected = getSelectedMarkers(event); // Verify.//from w w w. java2s . co m MessageDialog dialog = new MessageDialog(view.getSite().getShell(), MarkerMessages.deleteActionConfirmTitle, null, // icon MarkerMessages.deleteActionConfirmMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() != 0) { return view; } WorkspaceJob deleteJob = new WorkspaceJob(IDEWorkbenchMessages.MarkerDeleteHandler_JobTitle) { //See Bug#250807 public IStatus runInWorkspace(IProgressMonitor monitor) { monitor.beginTask(IDEWorkbenchMessages.MarkerDeleteHandler_JobMessageLabel, 10 * selected.length); try { IUndoableOperation op = new DeleteMarkersOperation(selected, view.getDeleteOperationName(selected)); op.addContext(view.getUndoContext()); execute(op, MarkerMessages.deleteMarkers_errorMessage, monitor, WorkspaceUndoUtil.getUIInfoAdapter(view.getSite().getShell())); } finally { monitor.done(); } return Status.OK_STATUS; } }; deleteJob.setUser(true); deleteJob.schedule(); return this; }
From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java
License:Open Source License
private MessageDialog getWarningDialog(String title, String message) { return new MessageDialog(getShell(), title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); }
From source file:org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.java
License:Open Source License
/** * This implementation asks the user for the workspace path of a file resource and saves the document there. * * @param progressMonitor the progress monitor to be used * @since 3.2//from ww w .j a v a2s .c om */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); final IEditorInput input = getEditorInput(); IDocumentProvider provider = getDocumentProvider(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_title, null, NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_message, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { EditorsPlugin.log(ex.getStatus()); String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title; String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, ex.getMessage()); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else newInput = new FileStoreEditorInput(fileStore); } else { SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) dialog.setOriginalFile(original); else dialog.setOriginalName(input.getName()); dialog.create(); if (provider.isDeleted(input) && original != null) { String message = NLSUtility.format( TextEditorMessages.AbstractDecoratedTextEditor_warning_saveAs_deleted, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title; String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, x.getMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); } if (progressMonitor != null) progressMonitor.setCanceled(!success); }
From source file:org.eclipse.vex.ui.internal.editor.VexEditor.java
License:Open Source License
/** * Asks the user for the workspace path of a file resource and saves the document there. * * @param progressMonitor/*from w w w . j ava 2s . co m*/ * the monitor in which to run the operation */ protected void performSaveAs(final IProgressMonitor progressMonitor) { final Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); final IDocumentProvider provider = getDocumentProvider(); final IEditorInput input = getEditorInput(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { final FileDialog dialog = new FileDialog(shell, SWT.SAVE); final IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } final String path = dialog.open(); if (path == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { final String title = Messages.getString("VexEditor.saveAs.overwrite.title"); final String message = MessageFormat .format(Messages.getString("VexEditor.saveAs.overwrite.message"), path); final MessageDialog overwriteDialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (final CoreException ex) { VexPlugin.getDefault().log(IStatus.ERROR, ex.getLocalizedMessage(), ex); final String title = Messages.getString("VexEditor.saveAs.error.title"); final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.error.message"), ex.getLocalizedMessage()); MessageDialog.openError(shell, title, msg); return; } final IFile file = getWorkspaceFile(fileStore); if (file != null) { newInput = new FileEditorInput(file); } else { newInput = new FileStoreEditorInput(fileStore); } } else { final SaveAsDialog dialog = new SaveAsDialog(shell); final IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } else { dialog.setOriginalName(input.getName()); } dialog.create(); if (provider.isDeleted(input) && original != null) { final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.deleted"), original.getName()); dialog.setErrorMessage(null); dialog.setMessage(msg, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } final IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); syncDocumentProvider(); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (final CoreException ex) { final IStatus status = ex.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { VexPlugin.getDefault().log(IStatus.ERROR, ex.getLocalizedMessage(), ex); final String title = Messages.getString("VexEditor.saveAs.error.title"); final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.error.message"), ex.getLocalizedMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) { setInput(newInput); setClean(); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.wb.internal.core.utils.ui.UiUtils.java
License:Open Source License
/** * Opens standard warning dialog.//from ww w . j a v a 2 s .c om */ public static void openWarning(Shell parent, String title, String message) { MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); }
From source file:org.eclipse.wb.internal.swt.model.layout.absolute.AbsoluteLayoutInfo.java
License:Open Source License
/** * Absolute layout is place when layout stops. So, even while at design time we show correct GUI, * at run time complex layout of child will not work without special tricks. So, we ask user to * use {@link FormLayout} instead on "absolute". *//*from ww w .j ava 2 s.co m*/ private void whenSetComplexLayout_forChildComposite() { addBroadcastListener(new JavaEventListener() { @Override public void addAfter(JavaInfo parent, JavaInfo child) throws Exception { if (child instanceof LayoutInfo && !(child instanceof AbsoluteLayoutInfo) && parent instanceof CompositeInfo && parent.getParent() == getComposite()) { int result = openQuestion(); if (result == 0) { LayoutInfo formLayout = (LayoutInfo) JavaInfoUtils.createJavaInfo(getEditor(), "org.eclipse.swt.layout.FormLayout", new ConstructorCreationSupport()); getComposite().setLayout(formLayout); } } } private int openQuestion() { MessageDialog dialog = new MessageDialog(DesignerPlugin.getShell(), ModelMessages.AbsoluteLayoutInfo_layoutConfirmTitle, null, ModelMessages.AbsoluteLayoutInfo_layoutConfirmMessage1 + ModelMessages.AbsoluteLayoutInfo_layoutConfirmMessage2 + ModelMessages.AbsoluteLayoutInfo_layoutConfirmMessage3 + ModelMessages.AbsoluteLayoutInfo_layoutConfirmMessage4 + ModelMessages.AbsoluteLayoutInfo_layoutConfirmMessage5, MessageDialog.WARNING, new String[] { ModelMessages.AbsoluteLayoutInfo_layoutConfirmButtonYes, ModelMessages.AbsoluteLayoutInfo_layoutConfirmButtonNo }, 0); return dialog.open(); } }); }