diff options
author | Milos Kleint | 2011-01-20 08:39:54 +0000 |
---|---|---|
committer | Milos Kleint | 2011-01-20 08:39:54 +0000 |
commit | accdd6560306ead14f449fc692b4a17552014451 (patch) | |
tree | f89c7a4c5ee39a4563c7868bf9753cabec6196c2 /org.eclipse.m2e.editor.xml/src | |
parent | d66ea518b50e96e6e2783feb3cb9a93cdb662410 (diff) | |
download | m2e-core-accdd6560306ead14f449fc692b4a17552014451.tar.gz m2e-core-accdd6560306ead14f449fc692b4a17552014451.tar.xz m2e-core-accdd6560306ead14f449fc692b4a17552014451.zip |
files always save, documents as needed
Diffstat (limited to 'org.eclipse.m2e.editor.xml/src')
-rw-r--r-- | org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/PomEdits.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/PomEdits.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/PomEdits.java index 9b140be4..f30d37a1 100644 --- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/PomEdits.java +++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/PomEdits.java @@ -234,20 +234,21 @@ public class PomEdits { try { domModel = tuple.getFile() != null ? (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(tuple.getFile()) - : (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(tuple.getDocument()); + : (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(tuple.getDocument()); //existing shall be ok here.. domModel.aboutToChangeModel(); IStructuredTextUndoManager undo = domModel.getStructuredDocument().getUndoManager(); undo.beginRecording(domModel); try { tuple.getOperation().process(domModel.getDocument()); } finally { - undo.endRecording(domModel); + undo.endRecording(domModel); domModel.changedModel(); } } finally { if(domModel != null) { - //saving shall only happen when the model is not held elsewhere (eg. in opened view) - if(domModel.isSaveNeeded() && domModel.getReferenceCountForEdit() == 1) { + //for ducuments saving shall only happen when the model is not held elsewhere (eg. in opened view) + //for files, save always + if(tuple.getFile() != null || domModel.getReferenceCountForEdit() == 1) { domModel.save(); } domModel.releaseFromEdit(); @@ -261,6 +262,11 @@ public class PomEdits { private final IFile file; private final IDocument document; + /** + * operation on top of IFile is always saved + * @param file + * @param operation + */ public OperationTuple(IFile file, PomEdits.Operation operation) { assert file != null; assert operation != null; @@ -268,7 +274,11 @@ public class PomEdits { this.operation = operation; document = null; } - + /** + * operation on top of IDocument is only saved when noone else is editing the document. + * @param document + * @param operation + */ public OperationTuple(IDocument document, PomEdits.Operation operation) { assert operation != null; this.document = document; |