|
1 /* |
|
2 * Copyright (c) 2007 Borland Software Corporation |
|
3 * |
|
4 * All rights reserved. This program and the accompanying materials |
|
5 * are made available under the terms of the Eclipse Public License v1.0 |
|
6 * which accompanies this distribution, and is available at |
|
7 * http://www.eclipse.org/legal/epl-v10.html |
|
8 * |
|
9 * Contributors: |
|
10 * Alexander Shatalin (Borland) - initial API and implementation |
|
11 */ |
|
12 |
|
13 «IMPORT "http://www.eclipse.org/gmf/2008/GenModel"» |
|
14 |
|
15 «REM»Inner class of DocumentProvider«ENDREM» |
|
16 «DEFINE ResourceSetModificationListener FOR gmfgen::GenDiagram-» |
|
17 «EXPAND xpt::Common::generatedClassComment» |
|
18 private class ResourceSetModificationListener extends org.eclipse.emf.ecore.util.EContentAdapter { |
|
19 |
|
20 «EXPAND attributes-» |
|
21 |
|
22 «EXPAND constructor-» |
|
23 |
|
24 «EXPAND notifyChanged-» |
|
25 |
|
26 «EXPAND additions-» |
|
27 } |
|
28 «ENDDEFINE» |
|
29 |
|
30 «DEFINE attributes FOR gmfgen::GenDiagram-» |
|
31 «EXPAND xpt::Common::generatedMemberComment» |
|
32 private org.eclipse.emf.transaction.NotificationFilter myModifiedFilter; |
|
33 |
|
34 «EXPAND xpt::Common::generatedMemberComment» |
|
35 private ResourceSetInfo myInfo; |
|
36 «ENDDEFINE» |
|
37 |
|
38 «DEFINE constructor FOR gmfgen::GenDiagram-» |
|
39 «EXPAND xpt::Common::generatedMemberComment» |
|
40 public ResourceSetModificationListener(ResourceSetInfo info) { |
|
41 myInfo = info; |
|
42 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)); |
|
43 } |
|
44 «ENDDEFINE» |
|
45 |
|
46 «DEFINE notifyChanged FOR gmfgen::GenDiagram-» |
|
47 «EXPAND xpt::Common::generatedMemberComment» |
|
48 public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) { |
|
49 if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.ResourceSet) { |
|
50 super.notifyChanged(notification); |
|
51 } |
|
52 if (!notification.isTouch() && myModifiedFilter.matches(notification)) { |
|
53 if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.Resource) { |
|
54 org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) notification.getNotifier(); |
|
55 if (resource.isLoaded()) { |
|
56 boolean modified = false; |
|
57 for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) { |
|
58 org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next(); |
|
59 if (nextResource.isLoaded()) { |
|
60 modified = nextResource.isModified(); |
|
61 } |
|
62 } |
|
63 boolean dirtyStateChanged = false; |
|
64 synchronized (myInfo) { |
|
65 if (modified != myInfo.fCanBeSaved) { |
|
66 myInfo.fCanBeSaved = modified; |
|
67 dirtyStateChanged = true; |
|
68 } |
|
69 «IF null == editorGen.application-» |
|
70 if (!resource.isModified()) { |
|
71 myInfo.setSynchronized(resource); |
|
72 } |
|
73 «ENDIF-» |
|
74 } |
|
75 if (dirtyStateChanged) { |
|
76 fireElementDirtyStateChanged(myInfo.getEditorInput(), modified); |
|
77 |
|
78 if (!modified) { |
|
79 myInfo.setModificationStamp(computeModificationStamp(myInfo)); |
|
80 } |
|
81 } |
|
82 } |
|
83 } |
|
84 } |
|
85 } |
|
86 «ENDDEFINE» |
|
87 |
|
88 «DEFINE additions FOR gmfgen::GenDiagram-» |
|
89 «ENDDEFINE» |