List of usage examples for org.eclipse.jface.dialogs IMessageProvider WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs IMessageProvider WARNING.
Click Source Link
From source file:org.eclipse.gmf.examples.mindmap.diagram.part.MindmapDiagramEditor.java
License:Open Source License
/** * @generated/*from w ww .j av a 2 s . com*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.MindmapDiagramEditor_SavingDeletedFile, 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; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.MindmapDiagramEditor_SaveAsErrorTitle, Messages.MindmapDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.MindmapDiagramEditor_SaveErrorTitle, Messages.MindmapDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.gmf.examples.taipan.port.diagram.part.PortDiagramEditor.java
License:Open Source License
/** * @generated//from www. java 2 s . c om */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.PortDiagramEditor_SavingDeletedFile, 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; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.PortDiagramEditor_SaveAsErrorTitle, Messages.PortDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.PortDiagramEditor_SaveErrorTitle, Messages.PortDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.gmf.graphdef.editor.part.GMFGraphDiagramEditor.java
License:Open Source License
/** * @generated//ww w. jav a2 s. co m */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.GMFGraphDiagramEditor_SavingDeletedFile, 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; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.GMFGraphDiagramEditor_SaveAsErrorTitle, Messages.GMFGraphDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.GMFGraphDiagramEditor_SaveErrorTitle, Messages.GMFGraphDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.gmf.internal.bridge.transform.GMFGenNewFileCreationPage.java
License:Open Source License
private void validateFileExists() { IPath resourcePath = getContainerFullPath().append(getFileName()); if (isFileExists(resourcePath)) { setMessage(Messages.ResourceGroup_nameExists, IMessageProvider.WARNING); }/*w w w. j a v a 2 s .co m*/ }
From source file:org.eclipse.gmf.internal.bridge.transform.ModelConfigurationPage.java
License:Open Source License
void setStatusMessage(IStatus status) { if (status == null || status.isOK()) { setMessage(null);//w w w.j a v a 2 s . c o m setErrorMessage(null); } else if (IStatus.INFO == status.getSeverity()) { setMessage(status.getMessage(), IMessageProvider.INFORMATION); setErrorMessage(null); } else if (IStatus.WARNING == status.getSeverity()) { setMessage(status.getMessage(), IMessageProvider.WARNING); setErrorMessage(null); } else if (IStatus.ERROR == status.getSeverity()) { setMessage(null); setErrorMessage(status.getMessage()); } else if (IStatus.CANCEL == status.getSeverity()) { setMessage(null); setErrorMessage(status.getMessage()); } }
From source file:org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.editor.IDEDiagramDocumentEditor.java
License:Open Source License
/** * Performs a save as and reports the result state back to the * given progress monitor. This default implementation does nothing. * Subclasses may reimplement.//from ww w. j a v a2s.c o m * * @param progressMonitor the progress monitor for communicating result state or <code>null</code> */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) dialog.setOriginalFile(original); dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(EditorMessages.Editor_warning_save_delete, 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; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileSaveAs_DialogTitle, org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileSaveAs_DialogMessageText); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) ErrorDialog.openError(shell, EditorMessages.Editor_error_saving_title2, EditorMessages.Editor_error_saving_message2, x.getStatus()); } finally { provider.changed(newInput); if (success) { setInput(newInput); /* * Bugzilla 255264: If nothing was selected on the diagram this * implies that contents editpart is selected. When the diagram * is "saved as" to another file new editparts are created and * old ones disposed. Consequently, views displaying data about * selected objects on the diaqram must be updated - it a * another diagram editpart selected now. Threfore, we need to * call deselectAll() such that the selection event is fired * with the implicitly selected diagram editpart. */ getGraphicalViewer().deselectAll(); } } if (progressMonitor != null) progressMonitor.setCanceled(!success); }
From source file:org.eclipse.gmf.runtime.emf.ui.preferences.NewPathVariableDialog.java
License:Open Source License
/** * Validates the current values of the variable name and location entry * fields. A warning or error message is shown in the title area, if * appropriate, and the OK button is disabled if any input is invalid. * Moreover, in edit mode, the OK button is disabled if the user hasn't * changed either the variable name or the location. *//*ww w . j ava2 s .c o m*/ private void validateInputs() { IStatus status = Status.OK_STATUS; boolean isError = false; String name = nameText.getText(); String location = locationText.getText(); boolean hasName = name.length() > 0; boolean hasLocation = location.length() > 0; if (hasName && !name.equals(initialName)) { status = validateName(name); } if (!status.isOK()) { isError = true; setMessage(status.getMessage(), IMessageProvider.ERROR); } else if (hasLocation && !location.equals(initialLocation)) { status = validateLocation(new Path(location)); if (!status.isOK()) { isError = status.getSeverity() >= IStatus.ERROR; setMessage(status.getMessage(), isError ? IMessageProvider.ERROR : IMessageProvider.WARNING); } } if (status.isOK()) { setMessage(plainMsg); } if (initialName != null) { // edit mode. Check that either the name or the location is changed if (name.equals(initialName) && location.equals(initialLocation)) { // force OK button to be disabled hasName = false; } } // dialog not complete if error or missing an input getButton(IDialogConstants.OK_ID).setEnabled(!isError && hasName && hasLocation); }
From source file:org.eclipse.gmf.tooling.simplemap.diagram.part.SimplemapDiagramEditor.java
License:Open Source License
/** * @generated/* w ww. ja v a2s.c om*/ */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.SimplemapDiagramEditor_SavingDeletedFile, 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; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.SimplemapDiagramEditor_SaveAsErrorTitle, Messages.SimplemapDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.SimplemapDiagramEditor_SaveErrorTitle, Messages.SimplemapDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.gmt.modisco.jm2t.ui.wizard.page.NewGeneratorConfigurationComposite.java
License:Open Source License
protected void validate() { if (generatorConfiguration == null) { wizard.setMessage("", IMessageProvider.ERROR); return;/*from ww w . j a v a 2 s. co m*/ } IStatus status = generatorConfiguration.validate(); if (status == null || status.isOK()) wizard.setMessage(null, IMessageProvider.NONE); else if (status.getSeverity() == IStatus.WARNING) wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); else wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); wizard.update(); }
From source file:org.eclipse.ice.client.widgets.ICEFormEditor.java
License:Open Source License
/** * This operation changes the dirty state of the FormEditor. * /* ww w . j a v a2s . co m*/ * @param value */ public void setDirty(boolean value) { // Set the dirty value and fire a property change dirty = value; firePropertyChange(PROP_DIRTY); // Push a message to the message manager if (getHeaderForm() != null) { final IMessageManager messageManager = getHeaderForm().getMessageManager(); if (dirty) { messageManager.addMessage("statusUpdate", "There are unsaved changes on the form.", null, IMessageProvider.WARNING); } else { messageManager.removeMessage("statusUpdate"); // messageManager.addMessage("statusUpdate", "Form Saved", null, // IMessageProvider.INFORMATION); } } }