1 | protected Viewer currentViewer;↵ | | 1 | protected Viewer currentViewer;↵
|
|
2 | /**↵ | | 2 | /**↵
|
3 | * This listens to which ever viewer is active.↵ | | 3 | * This listens to which ever viewer is active.↵
|
4 | * <!-- begin-user-doc -->↵ | | 4 | * <!-- begin-user-doc -->↵
|
5 | * <!-- end-user-doc -->↵ | | 5 | * <!-- end-user-doc -->↵
|
6 | * @generated↵ | | 6 | * @generated↵
|
7 | */↵ | | 7 | */↵
|
8 | protected ISelectionChangedListener selectionChangedListener;↵ | | 8 | protected ISelectionChangedListener selectionChangedListener;↵
|
|
9 | /**↵ | | 9 | /**↵
|
10 | * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.↵ | | 10 | * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.↵
|
11 | * <!-- begin-user-doc -->↵ | | 11 | * <!-- begin-user-doc -->↵
|
12 | * <!-- end-user-doc -->↵ | | 12 | * <!-- end-user-doc -->↵
|
13 | * @generated↵ | | 13 | * @generated↵
|
14 | */↵ | | 14 | */↵
|
15 | protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();↵ | | 15 | protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();↵
|
|
16 | /**↵ | | 16 | /**↵
|
17 | * This keeps track of the selection of the editor as a whole.↵ | | 17 | * This keeps track of the selection of the editor as a whole.↵
|
18 | * <!-- begin-user-doc -->↵ | | 18 | * <!-- begin-user-doc -->↵
|
19 | * <!-- end-user-doc -->↵ | | 19 | * <!-- end-user-doc -->↵
|
20 | * @generated↵ | | 20 | * @generated↵
|
21 | */↵ | | 21 | */↵
|
22 | protected ISelection editorSelection = StructuredSelection.EMPTY;↵ | | 22 | protected ISelection editorSelection = StructuredSelection.EMPTY;↵
|
|
23 | /**↵ | | 23 | /**↵
|
24 | * The MarkerHelper is responsible for creating workspace resource markers presented↵ | | 24 | * The MarkerHelper is responsible for creating workspace resource markers presented↵
|
25 | * in Eclipse's Problems View.↵ | | 25 | * in Eclipse's Problems View.↵
|
26 | * <!-- begin-user-doc -->↵ | | 26 | * <!-- begin-user-doc -->↵
|
27 | * <!-- end-user-doc -->↵ | | 27 | * <!-- end-user-doc -->↵
|
28 | * @generated↵ | | 28 | * @generated↵
|
29 | */↵ | | 29 | */↵
|
30 | protected MarkerHelper markerHelper = new EditUIMarkerHelper();↵ | | 30 | protected MarkerHelper markerHelper = new EditUIMarkerHelper();↵
|
|
31 | /**↵ | | 31 | /**↵
|
32 | * This listens for when the outline becomes active↵ | | 32 | * This listens for when the outline becomes active↵
|
33 | * <!-- begin-user-doc -->↵ | | 33 | * <!-- begin-user-doc -->↵
|
34 | * <!-- end-user-doc -->↵ | | 34 | * <!-- end-user-doc -->↵
|
35 | * @generated↵ | | 35 | * @generated↵
|
36 | */↵ | | 36 | */↵
|
37 | protected IPartListener partListener =↵ | | 37 | protected IPartListener partListener =↵
|
38 | new IPartListener()↵ | | 38 | new IPartListener()↵
|
39 | {↵ | | 39 | {↵
|
40 | public void partActivated(IWorkbenchPart p)↵ | | 40 | public void partActivated(IWorkbenchPart p)↵
|
41 | {↵ | | 41 | {↵
|
42 | if (p instanceof ContentOutline)↵ | | 42 | if (p instanceof ContentOutline)↵
|
43 | {↵ | | 43 | {↵
|
44 | if (((ContentOutline)p).getCurrentPage() == contentOutlinePage)↵ | | 44 | if (((ContentOutline)p).getCurrentPage() == contentOutlinePage)↵
|
45 | {↵ | | 45 | {↵
|
46 | getActionBarContributor().setActiveEditor(EcoreEditor.this);↵ | | 46 | getActionBarContributor().setActiveEditor(Ecore2XMLEditor.this);↵
|
|
47 | setCurrentViewer(contentOutlineViewer);↵ | | 47 | setCurrentViewer(contentOutlineViewer);↵
|
48 | }↵ | | 48 | }↵
|
49 | }↵ | | 49 | }↵
|
50 | else if (p instanceof PropertySheet)↵ | | 50 | else if (p instanceof PropertySheet)↵
|
51 | {↵ | | 51 | {↵
|
52 | if (((PropertySheet)p).getCurrentPage() == propertySheetPage)↵ | | 52 | if (((PropertySheet)p).getCurrentPage() == propertySheetPage)↵
|
53 | {↵ | | 53 | {↵
|
54 | getActionBarContributor().setActiveEditor(EcoreEditor.this);↵ | | 54 | getActionBarContributor().setActiveEditor(Ecore2XMLEditor.this);↵
|
55 | handleActivate();↵ | | 55 | handleActivate();↵
|
56 | }↵ | | 56 | }↵
|
57 | }↵ | | 57 | }↵
|
58 | else if (p == EcoreEditor.this)↵ | | 58 | else if (p == Ecore2XMLEditor.this)↵
|
59 | {↵ | | 59 | {↵
|
60 | handleActivate();↵ | | 60 | handleActivate();↵
|
61 | }↵ | | 61 | }↵
|
62 | }↵ | | 62 | }↵
|
63 | public void partBroughtToTop(IWorkbenchPart p)↵ | | 63 | public void partBroughtToTop(IWorkbenchPart p)↵
|
64 | {↵ | | 64 | {↵
|
65 | // Ignore.↵ | | 65 | // Ignore.↵
|
66 | }↵ | | 66 | }↵
|
67 | public void partClosed(IWorkbenchPart p)↵ | | 67 | public void partClosed(IWorkbenchPart p)↵
|
68 | {↵ | | 68 | {↵
|
69 | // Ignore.↵ | | 69 | // Ignore.↵
|
70 | }↵ | | 70 | }↵
|
71 | public void partDeactivated(IWorkbenchPart p)↵ | | 71 | public void partDeactivated(IWorkbenchPart p)↵
|
72 | {↵ | | 72 | {↵
|
73 | // Ignore.↵ | | 73 | // Ignore.↵
|
74 | }↵ | | 74 | }↵
|
75 | public void partOpened(IWorkbenchPart p)↵ | | 75 | public void partOpened(IWorkbenchPart p)↵
|
76 | {↵ | | 76 | {↵
|
77 | // Ignore.↵ | | 77 | // Ignore.↵
|
78 | }↵ | | 78 | }↵
|
79 | };↵ | | 79 | };↵
|
|
80 | /**↵ | | 80 | /**↵
|
81 | * Resources that have been removed since last activation.↵ | | 81 | * Resources that have been removed since last activation.↵
|
82 | * <!-- begin-user-doc -->↵ | | |
|
83 | * <!-- end-user-doc -->↵ | | |
|
84 | * @generated↵ | | 82 | * @generated↵
|
85 | */↵ | | 83 | */↵
|
86 | protected Collection<Resource> removedResources = new ArrayList<Resource>();↵ | | 84 | protected Collection<Resource> removedResources = new ArrayList<Resource>();↵
|
|
87 | /**↵ | | 85 | /**↵
|
88 | * Resources that have been changed since last activation.↵ | | 86 | * Resources that have been changed since last activation.↵
|
89 | * <!-- begin-user-doc -->↵ | | |
|
90 | * <!-- end-user-doc -->↵ | | |
|
91 | * @generated↵ | | 87 | * @generated↵
|
92 | */↵ | | 88 | */↵
|
93 | protected Collection<Resource> changedResources = new ArrayList<Resource>();↵ | | 89 | protected Collection<Resource> changedResources = new ArrayList<Resource>();↵
|
|
94 | /**↵ | | 90 | /**↵
|
95 | * Resources that have been saved.↵ | | 91 | * Resources that have been saved.↵
|
96 | * <!-- begin-user-doc -->↵ | | |
|
97 | * <!-- end-user-doc -->↵ | | |
|
98 | * @generated↵ | | 92 | * @generated↵
|
99 | */↵ | | 93 | */↵
|
100 | protected Collection<Resource> savedResources = new ArrayList<Resource>();↵ | | 94 | protected Collection<Resource> savedResources = new ArrayList<Resource>();↵
|
|
101 | /**↵ | | 95 | /**↵
|
102 | * Map to store the diagnostic associated with a resource.↵ | | 96 | * Map to store the diagnostic associated with a resource.↵
|
103 | * <!-- begin-user-doc -->↵ | | 97 | * <!-- begin-user-doc -->↵
|
104 | * <!-- end-user-doc -->↵ | | 98 | * <!-- end-user-doc -->↵
|
105 | * @generated↵ | | 99 | * @generated↵
|
106 | */↵ | | 100 | */↵
|
107 | protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();↵ | | 101 | protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();↵
|
|
108 | /**↵ | | 102 | /**↵
|
109 | * Controls whether the problem indication should be updated.↵ | | 103 | * Controls whether the problem indication should be updated.↵
|
110 | * <!-- begin-user-doc -->↵ | | 104 | * <!-- begin-user-doc -->↵
|
111 | * <!-- end-user-doc -->↵ | | 105 | * <!-- end-user-doc -->↵
|
112 | * @generated↵ | | 106 | * @generated↵
|
113 | */↵ | | 107 | */↵
|
114 | protected boolean updateProblemIndication = true;↵ | | 108 | protected boolean updateProblemIndication = true;↵
|
|
115 | /**↵ | | 109 | /**↵
|
116 | * Adapter used to update the problem indication when resources are demanded loaded.↵ | | 110 | * Adapter used to update the problem indication when resources are demanded loaded.↵
|
117 | * <!-- begin-user-doc -->↵ | | 111 | * <!-- begin-user-doc -->↵
|
118 | * <!-- end-user-doc -->↵ | | 112 | * <!-- end-user-doc -->↵
|
119 | * @generated↵ | | 113 | * @generated↵
|
120 | */↵ | | 114 | */↵
|
121 | protected EContentAdapter problemIndicationAdapter = ↵ | | 115 | protected EContentAdapter problemIndicationAdapter = ↵
|
122 | new EContentAdapter()↵ | | 116 | new EContentAdapter()↵
|
123 | {↵ | | 117 | {↵
|
124 | @Override↵ | | 118 | @Override↵
|
125 | public void notifyChanged(Notification notification)↵ | | 119 | public void notifyChanged(Notification notification)↵
|
126 | {↵ | | 120 | {↵
|
127 | if (notification.getNotifier() instanceof Resource)↵ | | 121 | if (notification.getNotifier() instanceof Resource)↵
|
128 | {↵ | | 122 | {↵
|
129 | switch (notification.getFeatureID(Resource.class))↵ | | 123 | switch (notification.getFeatureID(Resource.class))↵
|
130 | {↵ | | 124 | {↵
|
131 | case Resource.RESOURCE__IS_LOADED:↵ | | 125 | case Resource.RESOURCE__IS_LOADED:↵
|
132 | case Resource.RESOURCE__ERRORS:↵ | | 126 | case Resource.RESOURCE__ERRORS:↵
|
133 | case Resource.RESOURCE__WARNINGS:↵ | | 127 | case Resource.RESOURCE__WARNINGS:↵
|
134 | {↵ | | 128 | {↵
|
135 | Resource resource = (Resource)notification.getNotifier();↵ | | 129 | Resource resource = (Resource)notification.getNotifier();↵
|
136 | Diagnostic diagnostic = analyzeResourceProblems(resource, null);↵ | | 130 | Diagnostic diagnostic = analyzeResourceProblems(resource, null);↵
|
137 | if (diagnostic.getSeverity() != Diagnostic.OK)↵ | | 131 | if (diagnostic.getSeverity() != Diagnostic.OK)↵
|
138 | {↵ | | 132 | {↵
|
139 | resourceToDiagnosticMap.put(resource, diagnostic);↵ | | 133 | resourceToDiagnosticMap.put(resource, diagnostic);↵
|
140 | }↵ | | 134 | }↵
|
141 | else↵ | | 135 | else↵
|
142 | {↵ | | 136 | {↵
|
143 | resourceToDiagnosticMap.remove(resource);↵ | | 137 | resourceToDiagnosticMap.remove(resource);↵
|
144 | }↵ | | 138 | }↵
|
|
145 | if (updateProblemIndication)↵ | | 139 | if (updateProblemIndication)↵
|
146 | {↵ | | 140 | {↵
|
147 | getSite().getShell().getDisplay().asyncExec↵ | | 141 | getSite().getShell().getDisplay().asyncExec↵
|
148 | (new Runnable()↵ | | 142 | (new Runnable()↵
|
149 | {↵ | | 143 | {↵
|
150 | public void run()↵ | | 144 | public void run()↵
|
151 | {↵ | | 145 | {↵
|
152 | updateProblemIndication();↵ | | 146 | updateProblemIndication();↵
|
153 | }↵ | | 147 | }↵
|
154 | });↵ | | 148 | });↵
|
155 | }↵ | | 149 | }↵
|
156 | break;↵ | | 150 | break;↵
|
157 | }↵ | | 151 | }↵
|
158 | }↵ | | 152 | }↵
|
159 | }↵ | | 153 | }↵
|
160 | else↵ | | 154 | else↵
|
161 | {↵ | | 155 | {↵
|
162 | super.notifyChanged(notification);↵ | | 156 | super.notifyChanged(notification);↵
|
163 | }↵ | | 157 | }↵
|
164 | }↵ | | 158 | }↵
|
|
165 | @Override↵ | | 159 | @Override↵
|
166 | protected void setTarget(Resource target)↵ | | 160 | protected void setTarget(Resource target)↵
|
167 | {↵ | | 161 | {↵
|
168 | basicSetTarget(target);↵ | | 162 | basicSetTarget(target);↵
|
169 | }↵ | | 163 | }↵
|
|
170 | @Override↵ | | 164 | @Override↵
|
171 | protected void unsetTarget(Resource target)↵ | | 165 | protected void unsetTarget(Resource target)↵
|
172 | {↵ | | 166 | {↵
|
173 | basicUnsetTarget(target);↵ | | 167 | basicUnsetTarget(target);↵
|
174 | }↵ | | 168 | }↵
|
175 | };↵ | | 169 | };↵
|
|
176 | /**↵ | | 170 | /**↵
|
177 | * This listens for workspace changes.↵ | | 171 | * This listens for workspace changes.↵
|
178 | * <!-- begin-user-doc -->↵ | | 172 | * <!-- begin-user-doc -->↵
|
179 | * <!-- end-user-doc -->↵ | | 173 | * <!-- end-user-doc -->↵
|
180 | * @generated↵ | | 174 | * @generated↵
|
181 | */↵ | | 175 | */↵
|
182 | protected IResourceChangeListener resourceChangeListener =↵ | | 176 | protected IResourceChangeListener resourceChangeListener =↵
|
183 | new IResourceChangeListener()↵ | | 177 | new IResourceChangeListener()↵
|
184 | {↵ | | 178 | {↵
|
185 | public void resourceChanged(IResourceChangeEvent event)↵ | | 179 | public void resourceChanged(IResourceChangeEvent event)↵
|
186 | {↵ | | 180 | {↵
|
187 | IResourceDelta delta = event.getDelta();↵ | | 181 | IResourceDelta delta = event.getDelta();↵
|
188 | try↵ | | 182 | try↵
|
189 | {↵ | | 183 | {↵
|
190 | class ResourceDeltaVisitor implements IResourceDeltaVisitor↵ | | 184 | class ResourceDeltaVisitor implements IResourceDeltaVisitor↵
|
191 | {↵ | | 185 | {↵
|
192 | protected ResourceSet resourceSet = editingDomain.getResourceSet();↵ | | 186 | protected ResourceSet resourceSet = editingDomain.getResourceSet();↵
|
193 | protected Collection<Resource> changedResources = new ArrayList<Resource>();↵ | | 187 | protected Collection<Resource> changedResources = new ArrayList<Resource>();↵
|
194 | protected Collection<Resource> removedResources = new ArrayList<Resource>();↵ | | 188 | protected Collection<Resource> removedResources = new ArrayList<Resource>();↵
|
|
195 | public boolean visit(IResourceDelta delta)↵ | | 189 | public boolean visit(IResourceDelta delta)↵
|
196 | {↵ | | 190 | {↵
|
197 | if (delta.getResource().getType() == IResource.FILE)↵ | | 191 | if (delta.getResource().getType() == IResource.FILE)↵
|
198 | {↵ | | 192 | {↵
|
199 | if (delta.getKind() == IResourceDelta.REMOVED ||↵ | | 193 | if (delta.getKind() == IResourceDelta.REMOVED ||↵
|
200 | delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS)↵ | | 194 | delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS)↵
|
201 | {↵ | | 195 | {↵
|
202 | Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);↵ | | 196 | Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);↵
|
203 | if (resource != null)↵ | | 197 | if (resource != null)↵
|
204 | {↵ | | 198 | {↵
|
205 | if (delta.getKind() == IResourceDelta.REMOVED)↵ | | 199 | if (delta.getKind() == IResourceDelta.REMOVED)↵
|
206 | {↵ | | 200 | {↵
|
207 | removedResources.add(resource);↵ | | 201 | removedResources.add(resource);↵
|
208 | }↵ | | 202 | }↵
|
209 | else if (!savedResources.remove(resource))↵ | | 203 | else if (!savedResources.remove(resource))↵
|
210 | {↵ | | 204 | {↵
|
211 | changedResources.add(resource);↵ | | 205 | changedResources.add(resource);↵
|
212 | }↵ | | 206 | }↵
|
213 | }↵ | | 207 | }↵
|
214 | }↵ | | 208 | }↵
|
215 | }↵ | | 209 | }↵
|
|
216 | return true;↵ | | 210 | return true;↵
|
217 | }↵ | | 211 | }↵
|
|
218 | public Collection<Resource> getChangedResources()↵ | | 212 | public Collection<Resource> getChangedResources()↵
|
219 | {↵ | | 213 | {↵
|
220 | return changedResources;↵ | | 214 | return changedResources;↵
|
221 | }↵ | | 215 | }↵
|
|
222 | public Collection<Resource> getRemovedResources()↵ | | 216 | public Collection<Resource> getRemovedResources()↵
|
223 | {↵ | | 217 | {↵
|
224 | return removedResources;↵ | | 218 | return removedResources;↵
|
225 | }↵ | | 219 | }↵
|
226 | }↵ | | 220 | }↵
|
|
227 | ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();↵ | | 221 | ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();↵
|
228 | delta.accept(visitor);↵ | | 222 | delta.accept(visitor);↵
|
|
229 | if (!visitor.getRemovedResources().isEmpty())↵ | | 223 | if (!visitor.getRemovedResources().isEmpty())↵
|
230 | {↵ | | 224 | {↵
|
231 | removedResources.addAll(visitor.getRemovedResources());↵ | | 225 | removedResources.addAll(visitor.getRemovedResources());↵
|
232 | if (!isDirty())↵ | | 226 | if (!isDirty())↵
|
233 | {↵ | | 227 | {↵
|
234 | getSite().getShell().getDisplay().asyncExec↵ | | 228 | getSite().getShell().getDisplay().asyncExec↵
|
235 | (new Runnable()↵ | | 229 | (new Runnable()↵
|
236 | {↵ | | 230 | {↵
|
237 | public void run()↵ | | 231 | public void run()↵
|
238 | {↵ | | 232 | {↵
|
239 | getSite().getPage().closeEditor(EcoreEditor.this, false);↵ | | 233 | getSite().getPage().closeEditor(Ecore2XMLEditor.this, false);↵
|
240 | }↵ | | 234 | }↵
|
241 | });↵ | | 235 | });↵
|
242 | }↵ | | 236 | }↵
|
243 | }↵ | | 237 | }↵
|
|
244 | if (!visitor.getChangedResources().isEmpty())↵ | | 238 | if (!visitor.getChangedResources().isEmpty())↵
|
245 | {↵ | | 239 | {↵
|
246 | changedResources.addAll(visitor.getChangedResources());↵ | | 240 | changedResources.addAll(visitor.getChangedResources());↵
|
247 | if (getSite().getPage().getActiveEditor() == EcoreEditor.this)↵ | | 241 | if (getSite().getPage().getActiveEditor() == Ecore2XMLEditor.this)↵
|
248 | {↵ | | 242 | {↵
|
249 | getSite().getShell().getDisplay().asyncExec↵ | | 243 | getSite().getShell().getDisplay().asyncExec↵
|
250 | (new Runnable()↵ | | 244 | (new Runnable()↵
|
251 | {↵ | | 245 | {↵
|
252 | public void run()↵ | | 246 | public void run()↵
|
253 | {↵ | | 247 | {↵
|
254 | handleActivate();↵ | | 248 | handleActivate();↵
|
255 | }↵ | | 249 | }↵
|
256 | });↵ | | 250 | });↵
|
257 | }↵ | | 251 | }↵
|
258 | }↵ | | 252 | }↵
|
259 | }↵ | | 253 | }↵
|
260 | catch (CoreException exception)↵ | | 254 | catch (CoreException exception)↵
|
261 | {↵ | | 255 | {↵
|
262 | EcoreEditorPlugin.INSTANCE.log(exception);↵ | | 256 | Ecore2XMLUIPlugin.INSTANCE.log(exception);↵
|
263 | }↵ | | 257 | }↵
|
264 | }↵ | | 258 | }↵
|
265 | };↵ | | 259 | };↵
|
|
266 | /**↵ | | 260 | /**↵
|
267 | * Handles activation of the editor or it's associated views.↵ | | 261 | * Handles activation of the editor or it's associated views.↵
|
268 | * <!-- begin-user-doc -->↵ | | |
|
269 | * <!-- end-user-doc -->↵ | | |
|
270 | * @generated↵ | | 262 | * @generated↵
|
271 | */↵ | | 263 | */↵
|
272 | protected void handleActivate()↵ | | 264 | protected void handleActivate()↵
|
273 | {↵ | | 265 | {↵
|
274 | // Recompute the read only state.↵ | | 266 | // Recompute the read only state.↵
|
275 | //↵ | | 267 | //↵
|
276 | if (editingDomain.getResourceToReadOnlyMap() != null)↵ | | 268 | if (editingDomain.getResourceToReadOnlyMap() != null)↵
|
277 | {↵ | | 269 | {↵
|
278 | editingDomain.getResourceToReadOnlyMap().clear();↵ | | 270 | editingDomain.getResourceToReadOnlyMap().clear();↵
|
|
279 | // Refresh any actions that may become enabled or disabled.↵ | | 271 | // Refresh any actions that may become enabled or disabled.↵
|
280 | //↵ | | 272 | //↵
|
281 | setSelection(getSelection());↵ | | 273 | setSelection(getSelection());↵
|
282 | }↵ | | 274 | }↵
|
|
283 | if (!removedResources.isEmpty())↵ | | 275 | if (!removedResources.isEmpty())↵
|
284 | {↵ | | 276 | {↵
|
285 | if (handleDirtyConflict())↵ | | 277 | if (handleDirtyConflict())↵
|
286 | {↵ | | 278 | {↵
|
287 | getSite().getPage().closeEditor(EcoreEditor.this, false);↵ | | 279 | getSite().getPage().closeEditor(Ecore2XMLEditor.this, false);↵
|
288 | }↵ | | 280 | }↵
|
289 | else↵ | | 281 | else↵
|
290 | {↵ | | 282 | {↵
|
291 | removedResources.clear();↵ | | 283 | removedResources.clear();↵
|
292 | changedResources.clear();↵ | | 284 | changedResources.clear();↵
|
293 | savedResources.clear();↵ | | 285 | savedResources.clear();↵
|
294 | }↵ | | 286 | }↵
|
295 | }↵ | | 287 | }↵
|
296 | else if (!changedResources.isEmpty())↵ | | 288 | else if (!changedResources.isEmpty())↵
|
297 | {↵ | | 289 | {↵
|
298 | changedResources.removeAll(savedResources);↵ | | 290 | changedResources.removeAll(savedResources);↵
|
299 | handleChangedResources();↵ | | 291 | handleChangedResources();↵
|
300 | changedResources.clear();↵ | | 292 | changedResources.clear();↵
|
301 | savedResources.clear();↵ | | 293 | savedResources.clear();↵
|
302 | }↵ | | 294 | }↵
|
303 | }↵ | | 295 | }↵
|
|
304 | /**↵ | | 296 | /**↵
|
305 | * Handles what to do with changed resources on activation.↵ | | 297 | * Handles what to do with changed resources on activation.↵
|
306 | * <!-- begin-user-doc -->↵ | | |
|
307 | * <!-- end-user-doc -->↵ | | |
|
308 | * @generated↵ | | 298 | * @generated↵
|
309 | */↵ | | 299 | */↵
|
310 | protected void handleChangedResources()↵ | | 300 | protected void handleChangedResources()↵
|
311 | {↵ | | 301 | {↵
|
312 | if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict()))↵ | | 302 | if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict()))↵
|
313 | {↵ | | 303 | {↵
|
314 | if (isDirty())↵ | | 304 | if (isDirty())↵
|
315 | {↵ | | 305 | {↵
|
316 | changedResources.addAll(editingDomain.getResourceSet().getResources());↵ | | 306 | changedResources.addAll(editingDomain.getResourceSet().getResources());↵
|
317 | }↵ | | 307 | }↵
|
318 | editingDomain.getCommandStack().flush();↵ | | 308 | editingDomain.getCommandStack().flush();↵
|
|
319 | updateProblemIndication = false;↵ | | 309 | updateProblemIndication = false;↵
|
320 | for (Resource resource : changedResources)↵ | | 310 | for (Resource resource : changedResources)↵
|
321 | {↵ | | 311 | {↵
|
322 | if (resource.isLoaded())↵ | | 312 | if (resource.isLoaded())↵
|
323 | {↵ | | 313 | {↵
|
324 | resource.unload();↵ | | 314 | resource.unload();↵
|
325 | try↵ | | 315 | try↵
|
326 | {↵ | | 316 | {↵
|
327 | resource.load(Collections.EMPTY_MAP);↵ | | 317 | resource.load(Collections.EMPTY_MAP);↵
|
328 | }↵ | | 318 | }↵
|
329 | catch (IOException exception)↵ | | 319 | catch (IOException exception)↵
|
330 | {↵ | | 320 | {↵
|
331 | if (!resourceToDiagnosticMap.containsKey(resource))↵ | | 321 | if (!resourceToDiagnosticMap.containsKey(resource))↵
|
332 | {↵ | | 322 | {↵
|
333 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));↵ | | 323 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));↵
|
334 | }↵ | | 324 | }↵
|
335 | }↵ | | 325 | }↵
|
336 | }↵ | | 326 | }↵
|
337 | }↵ | | 327 | }↵
|
|
338 | if (AdapterFactoryEditingDomain.isStale(editorSelection))↵ | | 328 | if (AdapterFactoryEditingDomain.isStale(editorSelection))↵
|
339 | {↵ | | 329 | {↵
|
340 | setSelection(StructuredSelection.EMPTY);↵ | | 330 | setSelection(StructuredSelection.EMPTY);↵
|
341 | }↵ | | 331 | }↵
|
|
342 | updateProblemIndication = true;↵ | | 332 | updateProblemIndication = true;↵
|
343 | updateProblemIndication();↵ | | 333 | updateProblemIndication();↵
|
344 | }↵ | | 334 | }↵
|
345 | }↵ | | 335 | }↵
|
346 | ↵ | | 336 | ↵
|
347 | /**↵ | | 337 | /**↵
|
348 | * Updates the problems indication with the information described in the specified diagnostic.↵ | | 338 | * Updates the problems indication with the information described in the specified diagnostic.↵
|
349 | * <!-- begin-user-doc -->↵ | | 339 | * <!-- begin-user-doc -->↵
|
350 | * <!-- end-user-doc -->↵ | | 340 | * <!-- end-user-doc -->↵
|
351 | * @generated↵ | | 341 | * @generated↵
|
352 | */↵ | | 342 | */↵
|
353 | protected void updateProblemIndication()↵ | | 343 | protected void updateProblemIndication()↵
|
354 | {↵ | | 344 | {↵
|
355 | if (updateProblemIndication)↵ | | 345 | if (updateProblemIndication)↵
|
356 | {↵ | | 346 | {↵
|
357 | BasicDiagnostic diagnostic =↵ | | 347 | BasicDiagnostic diagnostic =↵
|
358 | new BasicDiagnostic↵ | | 348 | new BasicDiagnostic↵
|
359 | (Diagnostic.OK,↵ | | 349 | (Diagnostic.OK,↵
|
360 | "org.eclipse.emf.ecore.editor",↵ | | 350 | "org.eclipse.emf.mapping.ecore2xml.edit", //$NON-NLS-1$↵
|
361 | 0,↵ | | 351 | 0,↵
|
362 | null,↵ | | 352 | null,↵
|
363 | new Object [] { editingDomain.getResourceSet() });↵ | | 353 | new Object [] { editingDomain.getResourceSet() });↵
|
364 | for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values())↵ | | 354 | for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values())↵
|
365 | {↵ | | 355 | {↵
|
366 | if (childDiagnostic.getSeverity() != Diagnostic.OK)↵ | | 356 | if (childDiagnostic.getSeverity() != Diagnostic.OK)↵
|
367 | {↵ | | 357 | {↵
|
368 | diagnostic.add(childDiagnostic);↵ | | 358 | diagnostic.add(childDiagnostic);↵
|
369 | }↵ | | 359 | }↵
|
370 | }↵ | | 360 | }↵
|
|
371 | int lastEditorPage = getPageCount() - 1;↵ | | 361 | int lastEditorPage = getPageCount() - 1;↵
|
372 | if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart)↵ | | 362 | if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart)↵
|
373 | {↵ | | 363 | {↵
|
374 | ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);↵ | | 364 | ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);↵
|
375 | if (diagnostic.getSeverity() != Diagnostic.OK)↵ | | 365 | if (diagnostic.getSeverity() != Diagnostic.OK)↵
|
376 | {↵ | | 366 | {↵
|
377 | setActivePage(lastEditorPage);↵ | | 367 | setActivePage(lastEditorPage);↵
|
378 | }↵ | | 368 | }↵
|
379 | }↵ | | 369 | }↵
|
380 | else if (diagnostic.getSeverity() != Diagnostic.OK)↵ | | 370 | else if (diagnostic.getSeverity() != Diagnostic.OK)↵
|
381 | {↵ | | 371 | {↵
|
382 | ProblemEditorPart problemEditorPart = new ProblemEditorPart();↵ | | 372 | ProblemEditorPart problemEditorPart = new ProblemEditorPart();↵
|
383 | problemEditorPart.setDiagnostic(diagnostic);↵ | | 373 | problemEditorPart.setDiagnostic(diagnostic);↵
|
384 | problemEditorPart.setMarkerHelper(markerHelper);↵ | | 374 | problemEditorPart.setMarkerHelper(markerHelper);↵
|
385 | try↵ | | 375 | try↵
|
386 | {↵ | | 376 | {↵
|
387 | addPage(++lastEditorPage, problemEditorPart, getEditorInput());↵ | | 377 | addPage(++lastEditorPage, problemEditorPart, getEditorInput());↵
|
388 | setPageText(lastEditorPage, problemEditorPart.getPartName());↵ | | 378 | setPageText(lastEditorPage, problemEditorPart.getPartName());↵
|
389 | setActivePage(lastEditorPage);↵ | | 379 | setActivePage(lastEditorPage);↵
|
390 | showTabs();↵ | | 380 | showTabs();↵
|
391 | }↵ | | 381 | }↵
|
392 | catch (PartInitException exception)↵ | | 382 | catch (PartInitException exception)↵
|
393 | {↵ | | 383 | {↵
|
394 | EcoreEditorPlugin.INSTANCE.log(exception);↵ | | 384 | Ecore2XMLUIPlugin.INSTANCE.log(exception);↵
|
395 | }↵ | | 385 | }↵
|
396 | }↵ | | 386 | }↵
|
|
397 | if (markerHelper.hasMarkers(editingDomain.getResourceSet()))↵ | | 387 | if (markerHelper.hasMarkers(editingDomain.getResourceSet()))↵
|
398 | {↵ | | 388 | {↵
|
399 | markerHelper.deleteMarkers(editingDomain.getResourceSet());↵ | | 389 | markerHelper.deleteMarkers(editingDomain.getResourceSet());↵
|
400 | if (diagnostic.getSeverity() != Diagnostic.OK)↵ | | 390 | if (diagnostic.getSeverity() != Diagnostic.OK)↵
|
401 | {↵ | | 391 | {↵
|
402 | try↵ | | 392 | try↵
|
403 | {↵ | | 393 | {↵
|
404 | markerHelper.createMarkers(diagnostic);↵ | | 394 | markerHelper.createMarkers(diagnostic);↵
|
405 | }↵ | | 395 | }↵
|
406 | catch (CoreException exception)↵ | | 396 | catch (CoreException exception)↵
|
407 | {↵ | | 397 | {↵
|
408 | EcoreEditorPlugin.INSTANCE.log(exception);↵ | | 398 | Ecore2XMLUIPlugin.INSTANCE.log(exception);↵
|
409 | }↵ | | 399 | }↵
|
410 | }↵ | | 400 | }↵
|
411 | }↵ | | 401 | }↵
|
412 | }↵ | | 402 | }↵
|
413 | }↵ | | 403 | }↵
|
|
414 | /**↵ | | 404 | /**↵
|
415 | * Shows a dialog that asks if conflicting changes should be discarded.↵ | | 405 | * Shows a dialog that asks if conflicting changes should be discarded.↵
|
416 | * <!-- begin-user-doc -->↵ | | |
|
417 | * <!-- end-user-doc -->↵ | | |
|
418 | * @generated↵ | | 406 | * @generated↵
|
419 | */↵ | | 407 | */↵
|
420 | protected boolean handleDirtyConflict()↵ | | 408 | protected boolean handleDirtyConflict()↵
|
421 | {↵ | | 409 | {↵
|
422 | return↵ | | 410 | return↵
|
423 | MessageDialog.openQuestion↵ | | 411 | MessageDialog.openQuestion↵
|
424 | (getSite().getShell(),↵ | | 412 | (getSite().getShell(),↵
|
425 | getString("_UI_FileConflict_label"),↵ | | 413 | getString("_UI_FileConflict_label"), //$NON-NLS-1$↵
|
426 | getString("_WARN_FileConflict"));↵ | | 414 | getString("_WARN_FileConflict")); //$NON-NLS-1$↵
|
427 | }↵ | | 415 | }↵
|
|
428 | /**↵ | | 416 | /**↵
|
429 | * This creates a model editor.↵ | | 417 | * This creates a model editor.↵
|
430 | * <!-- begin-user-doc -->↵ | | 418 | * <!-- begin-user-doc -->↵
|
431 | * <!-- end-user-doc -->↵ | | 419 | * <!-- end-user-doc -->↵
|
432 | * @generated↵ | | 420 | * @generated↵
|
433 | */↵ | | 421 | */↵
|
434 | public EcoreEditor()↵ | | 422 | public Ecore2XMLEditor()↵
|
435 | {↵ | | 423 | {↵
|
436 | super();↵ | | 424 | super();↵
|
437 | initializeEditingDomain(); | | 425 | initializeEditingDomain();
|