1 | final Map<Object, Object> saveOptions = new HashMap<Object, Object>();↵ | | 1 | final Map<Object, Object> saveOptions = new HashMap<Object, Object>();↵
|
2 | saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);↵ | | 2 | saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);↵
|
|
3 | // Do the work within an operation because this is a long running activity that modifies the workbench.↵ | | 3 | // Do the work within an operation because this is a long running activity that modifies the workbench.↵
|
4 | //↵ | | 4 | //↵
|
5 | WorkspaceModifyOperation operation =↵ | | 5 | WorkspaceModifyOperation operation =↵
|
6 | new WorkspaceModifyOperation()↵ | | 6 | new WorkspaceModifyOperation()↵
|
7 | {↵ | | 7 | {↵
|
8 | // This is the method that gets invoked when the operation runs.↵ | | 8 | // This is the method that gets invoked when the operation runs.↵
|
9 | //↵ | | 9 | //↵
|
10 | @Override↵ | | 10 | @Override↵
|
11 | public void execute(IProgressMonitor monitor)↵ | | 11 | public void execute(IProgressMonitor monitor)↵
|
12 | {↵ | | 12 | {↵
|
13 | // Save the resources to the file system.↵ | | 13 | // Save the resources to the file system.↵
|
14 | //↵ | | 14 | //↵
|
15 | boolean first = true;↵ | | 15 | boolean first = true;↵
|
16 | for (Resource resource : editingDomain.getResourceSet().getResources())↵ | | 16 | for (Resource resource : editingDomain.getResourceSet().getResources())↵
|
17 | {↵ | | 17 | {↵
|
18 | if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))↵ | | 18 | if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))↵
|
19 | {↵ | | 19 | {↵
|
20 | try↵ | | 20 | try↵
|
21 | {↵ | | 21 | {↵
|
22 | long timeStamp = resource.getTimeStamp();↵ | | 22 | long timeStamp = resource.getTimeStamp();↵
|
23 | resource.save(saveOptions);↵ | | 23 | resource.save(saveOptions);↵
|
24 | if (resource.getTimeStamp() != timeStamp)↵ | | 24 | if (resource.getTimeStamp() != timeStamp)↵
|
25 | {↵ | | 25 | {↵
|
26 | savedResources.add(resource);↵ | | 26 | savedResources.add(resource);↵
|
27 | }↵ | | 27 | }↵
|
28 | }↵ | | 28 | }↵
|
29 | catch (Exception exception)↵ | | 29 | catch (Exception exception)↵
|
30 | {↵ | | 30 | {↵
|
31 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));↵ | | 31 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));↵
|
32 | }↵ | | 32 | }↵
|
33 | first = false;↵ | | 33 | first = false;↵
|
34 | }↵ | | 34 | }↵
|
35 | }↵ | | 35 | }↵
|
36 | }↵ | | 36 | }↵
|
37 | };↵ | | 37 | };↵
|
|
38 | updateProblemIndication = false;↵ | | 38 | updateProblemIndication = false;↵
|
39 | try↵ | | 39 | try↵
|
40 | {↵ | | 40 | {↵
|
41 | // This runs the options, and shows progress.↵ | | 41 | // This runs the options, and shows progress.↵
|
42 | //↵ | | 42 | //↵
|
43 | new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);↵ | | 43 | new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);↵
|
|
44 | // Refresh the necessary state.↵ | | 44 | // Refresh the necessary state.↵
|
45 | //↵ | | 45 | //↵
|
46 | ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();↵ | | 46 | ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();↵
|
47 | firePropertyChange(IEditorPart.PROP_DIRTY);↵ | | 47 | firePropertyChange(IEditorPart.PROP_DIRTY);↵
|
48 | }↵ | | 48 | }↵
|
49 | catch (Exception exception)↵ | | 49 | catch (Exception exception)↵
|
50 | {↵ | | 50 | {↵
|
51 | // Something went wrong that shouldn't.↵ | | 51 | // Something went wrong that shouldn't.↵
|
52 | //↵ | | 52 | //↵
|
53 | Ecore2XMLUIPlugin.INSTANCE.log(exception);↵ | | 53 | EcoreEditorPlugin.INSTANCE.log(exception);↵
|
54 | }↵ | | 54 | }↵
|
55 | updateProblemIndication = true;↵ | | 55 | updateProblemIndication = true;↵
|
56 | updateProblemIndication(); | | 56 | updateProblemIndication();
|