Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt89
1 files changed, 89 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt
new file mode 100644
index 000000000..673974d78
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«REM»Inner class of DocumentProvider«ENDREM»
+«DEFINE ResourceSetModificationListener FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class ResourceSetModificationListener extends org.eclipse.emf.ecore.util.EContentAdapter {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND notifyChanged-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.transaction.NotificationFilter myModifiedFilter;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private ResourceSetInfo myInfo;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public ResourceSetModificationListener(ResourceSetInfo info) {
+ myInfo = info;
+ myModifiedFilter = org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.SET).or(org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.UNSET)).and(org.eclipse.emf.transaction.NotificationFilter.createFeatureFilter(org.eclipse.emf.ecore.resource.Resource.class, org.eclipse.emf.ecore.resource.Resource.RESOURCE__IS_MODIFIED));
+}
+«ENDDEFINE»
+
+«DEFINE notifyChanged FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
+ if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.ResourceSet) {
+ super.notifyChanged(notification);
+ }
+ if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
+ if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.Resource) {
+ org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) notification.getNotifier();
+ if (resource.isLoaded()) {
+ boolean modified = false;
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ if (nextResource.isLoaded()) {
+ modified = nextResource.isModified();
+ }
+ }
+ boolean dirtyStateChanged = false;
+ synchronized (myInfo) {
+ if (modified != myInfo.fCanBeSaved) {
+ myInfo.fCanBeSaved = modified;
+ dirtyStateChanged = true;
+ }
+ «IF null = editorGen.application-»
+ if (!resource.isModified()) {
+ myInfo.setSynchronized(resource);
+ }
+ «ENDIF-»
+ }
+ if (dirtyStateChanged) {
+ fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);
+
+ if (!modified) {
+ myInfo.setModificationStamp(computeModificationStamp(myInfo));
+ }
+ }
+ }
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file

Back to the top