Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2015-03-25 13:18:09 +0000
committerEd Merks2015-03-25 13:18:09 +0000
commit5ce762d2b21c17b9ff4e9e7f8eae8cf038f3c9f8 (patch)
tree7993c070285572023f059c57d6a0cfcebd993c4d
parentb4eec9d759c40a7d8530b6edb80b8fdb913a3f92 (diff)
downloadorg.eclipse.emf-5ce762d2b21c17b9ff4e9e7f8eae8cf038f3c9f8.tar.gz
org.eclipse.emf-5ce762d2b21c17b9ff4e9e7f8eae8cf038f3c9f8.tar.xz
org.eclipse.emf-5ce762d2b21c17b9ff4e9e7f8eae8cf038f3c9f8.zip
[434699] Editor's diagnostic analysis should when purely warnings.
-rw-r--r--plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java2
-rw-r--r--plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet5
2 files changed, 4 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java b/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java
index bb017ce72..c8bde8ac7 100644
--- a/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java
+++ b/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/templates/editor/Editor.java
@@ -190,7 +190,7 @@ public class Editor
protected final String TEXT_173 = NL + "\t\tURI resourceURI = EditUIUtil.getURI(getEditorInput());";
protected final String TEXT_174 = NL + "\t\tURI resourceURI = URI.createURI(getEditorInput().getName());";
protected final String TEXT_175 = NL + "\t\t// Assumes that the input is a file object." + NL + "\t\t//" + NL + "\t\tIFileEditorInput modelFile = (IFileEditorInput)getEditorInput();" + NL + "\t\tURI resourceURI = URI.createPlatformResourceURI(modelFile.getFile().getFullPath().toString(), true);";
- protected final String TEXT_176 = NL + "\t\tException exception = null;" + NL + "\t\tResource resource = null;" + NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\t// Load the resource through the editing domain." + NL + "\t\t\t//" + NL + "\t\t\tresource = editingDomain.getResourceSet().getResource(resourceURI, true);" + NL + "\t\t}" + NL + "\t\tcatch (Exception e)" + NL + "\t\t{" + NL + "\t\t\texception = e;" + NL + "\t\t\tresource = editingDomain.getResourceSet().getResource(resourceURI, false);" + NL + "\t\t}" + NL + "" + NL + "\t\tDiagnostic diagnostic = analyzeResourceProblems(resource, exception);" + NL + "\t\tif (diagnostic.getSeverity() != Diagnostic.OK)" + NL + "\t\t{" + NL + "\t\t\tresourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));" + NL + "\t\t}" + NL + "\t\teditingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns a diagnostic describing the errors and warnings listed in the resource" + NL + "\t * and the specified exception (if any)." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Diagnostic analyzeResourceProblems(Resource resource, Exception exception)" + NL + "\t{" + NL + "\t\tif (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty())" + NL + "\t\t{" + NL + "\t\t\tBasicDiagnostic basicDiagnostic =" + NL + "\t\t\t\tnew BasicDiagnostic" + NL + "\t\t\t\t\t(Diagnostic.ERROR," + NL + "\t\t\t\t\t \"";
+ protected final String TEXT_176 = NL + "\t\tException exception = null;" + NL + "\t\tResource resource = null;" + NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\t// Load the resource through the editing domain." + NL + "\t\t\t//" + NL + "\t\t\tresource = editingDomain.getResourceSet().getResource(resourceURI, true);" + NL + "\t\t}" + NL + "\t\tcatch (Exception e)" + NL + "\t\t{" + NL + "\t\t\texception = e;" + NL + "\t\t\tresource = editingDomain.getResourceSet().getResource(resourceURI, false);" + NL + "\t\t}" + NL + "" + NL + "\t\tDiagnostic diagnostic = analyzeResourceProblems(resource, exception);" + NL + "\t\tif (diagnostic.getSeverity() != Diagnostic.OK)" + NL + "\t\t{" + NL + "\t\t\tresourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));" + NL + "\t\t}" + NL + "\t\teditingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns a diagnostic describing the errors and warnings listed in the resource" + NL + "\t * and the specified exception (if any)." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Diagnostic analyzeResourceProblems(Resource resource, Exception exception)" + NL + "\t{" + NL + "\t\tboolean hasErrors = !resource.getErrors().isEmpty();" + NL + "\t\tif (hasErrors || !resource.getWarnings().isEmpty())" + NL + "\t\t{" + NL + "\t\t\tBasicDiagnostic basicDiagnostic =" + NL + "\t\t\t\tnew BasicDiagnostic" + NL + "\t\t\t\t\t(hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING," + NL + "\t\t\t\t\t \"";
protected final String TEXT_177 = "\",";
protected final String TEXT_178 = NL + "\t\t\t\t\t 0," + NL + "\t\t\t\t\t getString(\"_UI_CreateModelError_message\", resource.getURI()),";
protected final String TEXT_179 = NL + "\t\t\t\t\t new Object [] { exception == null ? (Object)resource : exception });" + NL + "\t\t\tbasicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));" + NL + "\t\t\treturn basicDiagnostic;" + NL + "\t\t}" + NL + "\t\telse if (exception != null)" + NL + "\t\t{" + NL + "\t\t\treturn" + NL + "\t\t\t\tnew BasicDiagnostic" + NL + "\t\t\t\t\t(Diagnostic.ERROR," + NL + "\t\t\t\t\t \"";
diff --git a/plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet b/plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet
index 14c6b76ea..e4dc4b4cf 100644
--- a/plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet
+++ b/plugins/org.eclipse.emf.codegen.ecore/templates/editor/Editor.javajet
@@ -1305,11 +1305,12 @@ public class <%=genPackage.getEditorClassName()%>
*/
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception)
{
- if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty())
+ boolean hasErrors = !resource.getErrors().isEmpty();
+ if (hasErrors || !resource.getWarnings().isEmpty())
{
BasicDiagnostic basicDiagnostic =
new BasicDiagnostic
- (Diagnostic.ERROR,
+ (hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING,
"<%=genPackage.getGenModel().getEditorPluginID()%>",<%=genModel.getNonNLS()%>
0,
getString("_UI_CreateModelError_message", resource.getURI()),<%=genModel.getNonNLS()%>

Back to the top