Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2006-02-06 15:00:13 +0000
committerashatalin2006-02-06 15:00:13 +0000
commit4f0bb4089edff452135cba784c627fd5fb7dd796 (patch)
tree6ce93fcef88f77896292cc31515b79fb75ea9d3e
parent0afc85409f21930bdfd14c75909a49fc2daf1b48 (diff)
downloadorg.eclipse.gmf-tooling-4f0bb4089edff452135cba784c627fd5fb7dd796.tar.gz
org.eclipse.gmf-tooling-4f0bb4089edff452135cba784c627fd5fb7dd796.tar.xz
org.eclipse.gmf-tooling-4f0bb4089edff452135cba784c627fd5fb7dd796.zip
#126543
Marking editor as dirty on changes in the referenced resources.
-rw-r--r--examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/providers/EcoreAbstractParser.java13
-rw-r--r--examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/editor/EcoreDocumentProvider.java24
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/part/TaiPanDocumentProvider.java24
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanAbstractParser.java13
-rw-r--r--examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanParserProvider.java8
-rw-r--r--plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/DocumentProviderGenerator.java2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/editor/DocumentProvider.javajet22
7 files changed, 87 insertions, 19 deletions
diff --git a/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/providers/EcoreAbstractParser.java b/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/providers/EcoreAbstractParser.java
index e8d7dec4b..83b6cd045 100644
--- a/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/providers/EcoreAbstractParser.java
+++ b/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/providers/EcoreAbstractParser.java
@@ -6,6 +6,8 @@ import java.text.ParsePosition;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -259,6 +261,17 @@ public abstract class EcoreAbstractParser implements IParser {
} else {
value = new InvalidValue("Value of type Double is expected");
}
+ } else if (type instanceof EEnum) {
+ if (value instanceof String) {
+ EEnumLiteral literal = ((EEnum) type).getEEnumLiteralByLiteral((String) value);
+ if (literal == null) {
+ value = new InvalidValue("Unknown literal: " + value);
+ } else {
+ value = literal.getInstance();
+ }
+ } else {
+ value = new InvalidValue("Value of type String is expected");
+ }
}
}
return value;
diff --git a/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/editor/EcoreDocumentProvider.java b/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/editor/EcoreDocumentProvider.java
index c63c518ee..e989f987d 100644
--- a/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/editor/EcoreDocumentProvider.java
+++ b/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/editor/EcoreDocumentProvider.java
@@ -152,14 +152,28 @@ public class EcoreDocumentProvider extends FileDiagramDocumentProvider {
public boolean matches(Notification notification) {
Diagram diagram = document.getDiagram();
Object notifier = notification.getNotifier();
- if (diagram != null && notifier instanceof Resource) {
- Resource notifierResource = (Resource) notifier;
+ Resource resource = null;
+ if (notifier instanceof EObject) {
+ resource = ((EObject) notifier).eResource();
+ } else if (notifier instanceof Resource) {
+ resource = (Resource) notifier;
+ }
+ if (diagram != null && resource != null) {
Set externalResources = getReferencedResources(diagram);
for (Iterator it = externalResources.iterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
- if (notifierResource == nextResource) {
- return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED
- && notification.getNewBooleanValue() == true;
+ if (resource == nextResource) {
+ if (notifier == resource) {
+ return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED
+ && notification.getNewBooleanValue() == true;
+ } else {
+ /*
+ * Handling notification from the objects stored in this resource it is necessary
+ * if setTrackingModification(true) was not called. I.e. now for all the objects
+ * stored in external resources.
+ */
+ return true;
+ }
}
}
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/part/TaiPanDocumentProvider.java b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/part/TaiPanDocumentProvider.java
index ca7073d86..8336d65cc 100644
--- a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/part/TaiPanDocumentProvider.java
+++ b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/part/TaiPanDocumentProvider.java
@@ -163,14 +163,28 @@ public class TaiPanDocumentProvider extends FileDiagramDocumentProvider {
public boolean matches(Notification notification) {
Diagram diagram = document.getDiagram();
Object notifier = notification.getNotifier();
- if (diagram != null && notifier instanceof Resource) {
- Resource notifierResource = (Resource) notifier;
+ Resource resource = null;
+ if (notifier instanceof EObject) {
+ resource = ((EObject) notifier).eResource();
+ } else if (notifier instanceof Resource) {
+ resource = (Resource) notifier;
+ }
+ if (diagram != null && resource != null) {
Set externalResources = getReferencedResources(diagram);
for (Iterator it = externalResources.iterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
- if (notifierResource == nextResource) {
- return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED
- && notification.getNewBooleanValue() == true;
+ if (resource == nextResource) {
+ if (notifier == resource) {
+ return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED
+ && notification.getNewBooleanValue() == true;
+ } else {
+ /*
+ * Handling notification from the objects stored in this resource it is necessary
+ * if setTrackingModification(true) was not called. I.e. now for all the objects
+ * stored in external resources.
+ */
+ return true;
+ }
}
}
}
diff --git a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanAbstractParser.java b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanAbstractParser.java
index bb9f54129..ab31bc4e9 100644
--- a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanAbstractParser.java
+++ b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanAbstractParser.java
@@ -17,6 +17,8 @@ import java.text.ParsePosition;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -270,6 +272,17 @@ public abstract class TaiPanAbstractParser implements IParser {
} else {
value = new InvalidValue("Value of type Double is expected");
}
+ } else if (type instanceof EEnum) {
+ if (value instanceof String) {
+ EEnumLiteral literal = ((EEnum) type).getEEnumLiteralByLiteral((String) value);
+ if (literal == null) {
+ value = new InvalidValue("Unknown literal: " + value);
+ } else {
+ value = literal.getInstance();
+ }
+ } else {
+ value = new InvalidValue("Value of type String is expected");
+ }
}
}
return value;
diff --git a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanParserProvider.java b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanParserProvider.java
index 17837d4b1..a0fe636e5 100644
--- a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanParserProvider.java
+++ b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/providers/TaiPanParserProvider.java
@@ -53,8 +53,8 @@ public class TaiPanParserProvider extends AbstractProvider implements IParserPro
features.add(TaiPanPackage.eINSTANCE.getItem().getEStructuralFeature("article"));
features.add(TaiPanPackage.eINSTANCE.getItem().getEStructuralFeature("quantity"));
TaiPanStructuralFeaturesParser parser = new TaiPanStructuralFeaturesParser(features);
- ((TaiPanStructuralFeaturesParser) parser).setViewPattern("- {0} [{1,number,integer}]");
- ((TaiPanStructuralFeaturesParser) parser).setEditPattern("{0}:{1,number,integer}");
+ parser.setViewPattern("- {0} [{1,number,integer}]");
+ parser.setEditPattern("{0}:{1,number,integer}");
return parser;
}
@@ -147,8 +147,8 @@ public class TaiPanParserProvider extends AbstractProvider implements IParserPro
*/
protected IParser createRouteROUTERELIABILITY_4009_TEXTParser() {
TaiPanStructuralFeatureParser parser = new TaiPanStructuralFeatureParser(TaiPanPackage.eINSTANCE.getRoute().getEStructuralFeature("reliability"));
- ((TaiPanStructuralFeatureParser) parser).setViewPattern("reliability: {0,number,percent}");
- ((TaiPanStructuralFeatureParser) parser).setEditPattern("{0,number,percent}");
+ parser.setViewPattern("reliability: {0,number,percent}");
+ parser.setEditPattern("{0,number,percent}");
return parser;
}
diff --git a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/DocumentProviderGenerator.java b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/DocumentProviderGenerator.java
index 6ffb36628..16b9dc2ed 100644
--- a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/DocumentProviderGenerator.java
+++ b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/DocumentProviderGenerator.java
@@ -20,7 +20,7 @@ public class DocumentProviderGenerator
protected final String TEXT_3 = NL + "import java.util.ArrayList;" + NL + "import java.util.Collection;" + NL + "import java.util.Collections;" + NL + "import java.util.HashSet;" + NL + "import java.util.Iterator;" + NL + "import java.util.List;" + NL + "import java.util.Set;" + NL + "" + NL + "import org.eclipse.core.resources.IFile;" + NL + "import org.eclipse.core.resources.IResource;" + NL + "import org.eclipse.core.runtime.CoreException;" + NL + "import org.eclipse.core.runtime.IProgressMonitor;" + NL + "import org.eclipse.core.runtime.SubProgressMonitor;" + NL + "import org.eclipse.core.runtime.jobs.ISchedulingRule;" + NL + "import org.eclipse.core.runtime.jobs.MultiRule;" + NL + "import org.eclipse.emf.common.notify.Notification;" + NL + "import org.eclipse.emf.ecore.EObject;" + NL + "import org.eclipse.emf.ecore.resource.Resource;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramModificationListener;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.document.FileDiagramDocumentProvider;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.document.FileDiagramModificationListener;" + NL + "import org.eclipse.gmf.runtime.emf.core.edit.MEditingDomain;" + NL + "import org.eclipse.gmf.runtime.emf.core.edit.MFilter;" + NL + "import org.eclipse.gmf.runtime.emf.core.edit.MListener;" + NL + "import org.eclipse.gmf.runtime.emf.core.util.ResourceUtil;" + NL + "import org.eclipse.gmf.runtime.notation.Diagram;" + NL + "import org.eclipse.ui.IFileEditorInput;";
protected final String TEXT_4 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
protected final String TEXT_5 = " extends FileDiagramDocumentProvider {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void saveDocumentToFile(IDocument document, IFile file, boolean overwrite, IProgressMonitor monitor) throws CoreException {" + NL + "\t\tmonitor.beginTask(\"\", 100); //$NON-NLS-1$" + NL + "\t\tsuper.saveDocumentToFile(document, file, overwrite, new SubProgressMonitor(monitor, 20));" + NL + "" + NL + "\t\tIProgressMonitor subMonitor = new SubProgressMonitor(monitor, 20);" + NL + "\t\tDiagram diagram = (Diagram)document.getContent();" + NL + "\t\tSet externalResources = getReferencedResources(diagram);" + NL + "\t\tsubMonitor.done();" + NL + "\t\t" + NL + "\t\tsubMonitor = new SubProgressMonitor(monitor, 60);" + NL + "\t\tsubMonitor.beginTask(\"Saving external resources\", externalResources.size());" + NL + "\t\tfor (Iterator it = externalResources.iterator(); it.hasNext();) {" + NL + "\t\t\tResource nextResource = (Resource) it.next();" + NL + "\t\t\tsubMonitor.setTaskName(\"Saving \" + nextResource.getURI());" + NL + "\t\t\tResourceUtil.save(nextResource);" + NL + "\t\t\tsubMonitor.worked(1);" + NL + "\t\t}" + NL + "\t\tsubMonitor.done();" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ISchedulingRule getSaveRule(Object element) {" + NL + "\t\tIDiagramDocument diagramDocument = getDiagramDocument(element);" + NL + "\t\tif (diagramDocument != null) {" + NL + "\t\t\tDiagram diagram = diagramDocument.getDiagram();" + NL + "\t\t\tif (diagram != null) {" + NL + "\t\t\t\tCollection rules = new ArrayList();" + NL + "\t\t\t\t" + NL + "\t\t\t\tResource resource = ((EObject)diagram).eResource();\t" + NL + "\t\t\t\tIFile resourceFile = ResourceUtil.getFile(resource);" + NL + "\t\t\t\trules.add(computeSaveSchedulingRule(resourceFile));" + NL + "\t\t\t\t" + NL + "\t\t\t\tSet externalResources = getReferencedResources(diagram);" + NL + "\t\t\t\tfor (Iterator it = externalResources.iterator(); it.hasNext();) {" + NL + "\t\t\t\t\tResource nextResource = (Resource) it.next();" + NL + "\t\t\t\t\tIFile nextResourceFile = ResourceUtil.getFile(nextResource);" + NL + "\t\t\t\t\trules.add(computeSaveSchedulingRule(nextResourceFile));" + NL + "\t\t\t\t}" + NL + "\t\t\t\t" + NL + "\t\t\t\treturn new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn super.getSaveRule(element);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected FileInfo createFileInfo(IDocument document, FileSynchronizer synchronizer, IFileEditorInput input) {" + NL + "\t\tassert document instanceof DiagramDocument;" + NL + "" + NL + "\t\tDiagramModificationListener diagramListener = new CustomModificationListener(this, (DiagramDocument) document, input);" + NL + "\t\tDiagramFileInfo info = new DiagramFileInfo(document, synchronizer, diagramListener);" + NL + "" + NL + "\t\tdiagramListener.startListening();" + NL + "\t\treturn info;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static Set getReferencedResources(Diagram diagram) {" + NL + "\t\tResource diagramResource = ((EObject) diagram).eResource();" + NL + "\t\tif (diagramResource == null) {" + NL + "\t\t\treturn Collections.EMPTY_SET;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\treturn new HashSet(MEditingDomain.INSTANCE.getImports(diagramResource));" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ISchedulingRule computeSaveSchedulingRule(IResource toCreateOrModify) {" + NL + "\t\tif (toCreateOrModify.exists() && toCreateOrModify.isSynchronized(IResource.DEPTH_ZERO))" + NL + "\t\t\treturn fResourceRuleFactory.modifyRule(toCreateOrModify);" + NL + "" + NL + "\t\tIResource parent= toCreateOrModify;" + NL + "\t\tdo {" + NL + "\t\t\t /*" + NL + "\t\t\t * XXX This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601" + NL + "\t\t\t * IResourceRuleFactory.createRule should iterate the hierarchy itself." + NL + "\t\t\t */" + NL + "\t\t\ttoCreateOrModify= parent;" + NL + "\t\t\tparent= toCreateOrModify.getParent();" + NL + "\t\t} while (parent != null && !parent.exists() && !parent.isSynchronized(IResource.DEPTH_ZERO));" + NL + "" + NL + "\t\treturn fResourceRuleFactory.createRule(toCreateOrModify);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate class CustomModificationListener extends FileDiagramModificationListener {" + NL + "\t" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate MListener myListener = null;" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t \tpublic CustomModificationListener(";
- protected final String TEXT_6 = " documentProviderParameter, DiagramDocument documentParameter, IFileEditorInput inputParameter) {" + NL + "\t\t\tsuper(documentProviderParameter, documentParameter, inputParameter);" + NL + "\t \t\tfinal DiagramDocument document = documentParameter;" + NL + "\t\t\tMFilter diagramResourceSavedFilter = new MFilter() {" + NL + "\t\t\t\tpublic boolean matches(Notification notification) {" + NL + "\t\t\t\t\tDiagram diagram = document.getDiagram();" + NL + "\t\t\t\t\tObject notifier = notification.getNotifier();" + NL + "\t\t\t\t\tif (diagram != null && notifier instanceof Resource) {" + NL + "\t\t\t\t\t\tResource notifierResource = (Resource) notifier;" + NL + "\t\t\t\t\t\tSet externalResources = getReferencedResources(diagram);" + NL + "\t\t\t\t\t\tfor (Iterator it = externalResources.iterator(); it.hasNext();) {" + NL + "\t\t\t\t\t\t\tResource nextResource = (Resource) it.next();" + NL + "\t\t\t\t\t\t\tif (notifierResource == nextResource) {" + NL + "\t\t\t\t\t\t\t\treturn notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue() == true;" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\treturn false;" + NL + "\t\t\t\t};" + NL + "\t\t\t};" + NL + "\t\t\tif (myListener == null) {" + NL + "\t\t\t\tmyListener = new MListener(diagramResourceSavedFilter) {" + NL + "" + NL + "\t\t\t\t\tpublic void onEvent(List events) {" + NL + "\t\t\t\t\t\tdocument.setContent(document.getContent());" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t};" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void startListening() {" + NL + "\t\t\tsuper.startListening();" + NL + "\t\t\tmyListener.startListening();" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void stopListening() {" + NL + "\t\t\tmyListener.stopListening();" + NL + "\t\t\tsuper.stopListening();" + NL + "\t\t}" + NL + "" + NL + "\t}" + NL + "\t" + NL + "}";
+ protected final String TEXT_6 = " documentProviderParameter, DiagramDocument documentParameter, IFileEditorInput inputParameter) {" + NL + "\t\t\tsuper(documentProviderParameter, documentParameter, inputParameter);" + NL + "\t \t\tfinal DiagramDocument document = documentParameter;" + NL + "\t\t\tMFilter diagramResourceSavedFilter = new MFilter() {" + NL + "\t\t\t\tpublic boolean matches(Notification notification) {" + NL + "\t\t\t\t\tDiagram diagram = document.getDiagram();" + NL + "\t\t\t\t\tObject notifier = notification.getNotifier();" + NL + "\t\t\t\t\tResource resource = null;" + NL + "\t\t\t\t\tif (notifier instanceof EObject) {" + NL + "\t\t\t\t\t\tresource = ((EObject) notifier).eResource();" + NL + "\t\t\t\t\t} else if (notifier instanceof Resource) {" + NL + "\t\t\t\t\t\tresource = (Resource) notifier;" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\tif (diagram != null && resource != null) {" + NL + "\t\t\t\t\t\tSet externalResources = getReferencedResources(diagram);" + NL + "\t\t\t\t\t\tfor (Iterator it = externalResources.iterator(); it.hasNext();) {" + NL + "\t\t\t\t\t\t\tResource nextResource = (Resource) it.next();" + NL + "\t\t\t\t\t\t\tif (resource == nextResource) {" + NL + "\t\t\t\t\t\t\t\tif (notifier == resource) {" + NL + "\t\t\t\t\t\t\t\t\treturn notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue() == true;" + NL + "\t\t\t\t\t\t\t\t} else {" + NL + "/*" + NL + " * Handling notification from the objects stored in this resource it is necessary " + NL + " * if setTrackingModification(true) was not called. I.e. now for all the objects " + NL + " * stored in external resources. " + NL + " */" + NL + "\t\t\t\t\t\t\t\t\treturn true;" + NL + "\t\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t\t}" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t\treturn false;" + NL + "\t\t\t\t};" + NL + "\t\t\t};" + NL + "\t\t\tif (myListener == null) {" + NL + "\t\t\t\tmyListener = new MListener(diagramResourceSavedFilter) {" + NL + "" + NL + "\t\t\t\t\tpublic void onEvent(List events) {" + NL + "\t\t\t\t\t\tdocument.setContent(document.getContent());" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t};" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void startListening() {" + NL + "\t\t\tsuper.startListening();" + NL + "\t\t\tmyListener.startListening();" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void stopListening() {" + NL + "\t\t\tmyListener.stopListening();" + NL + "\t\t\tsuper.stopListening();" + NL + "\t\t}" + NL + "" + NL + "\t}" + NL + "\t" + NL + "}";
protected final String TEXT_7 = NL;
public String generate(Object argument)
diff --git a/plugins/org.eclipse.gmf.codegen/templates/editor/DocumentProvider.javajet b/plugins/org.eclipse.gmf.codegen/templates/editor/DocumentProvider.javajet
index c21e69e72..4505593a0 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/editor/DocumentProvider.javajet
+++ b/plugins/org.eclipse.gmf.codegen/templates/editor/DocumentProvider.javajet
@@ -156,13 +156,27 @@ public class <%=genDiagram.getDocumentProviderClassName()%> extends FileDiagramD
public boolean matches(Notification notification) {
Diagram diagram = document.getDiagram();
Object notifier = notification.getNotifier();
- if (diagram != null && notifier instanceof Resource) {
- Resource notifierResource = (Resource) notifier;
+ Resource resource = null;
+ if (notifier instanceof EObject) {
+ resource = ((EObject) notifier).eResource();
+ } else if (notifier instanceof Resource) {
+ resource = (Resource) notifier;
+ }
+ if (diagram != null && resource != null) {
Set externalResources = getReferencedResources(diagram);
for (Iterator it = externalResources.iterator(); it.hasNext();) {
Resource nextResource = (Resource) it.next();
- if (notifierResource == nextResource) {
- return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue() == true;
+ if (resource == nextResource) {
+ if (notifier == resource) {
+ return notification.getEventType() == Notification.SET && notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue() == true;
+ } else {
+/*
+ * Handling notification from the objects stored in this resource it is necessary
+ * if setTrackingModification(true) was not called. I.e. now for all the objects
+ * stored in external resources.
+ */
+ return true;
+ }
}
}
}

Back to the top