Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-09-08 10:54:26 -0400
committerMatthias Sohn2019-09-09 03:36:33 -0400
commit1f7ff4789115be952d3b662aa53ec0dabda237e7 (patch)
treee61c744647f9c97e448d1a339297fda1ee75814b /org.eclipse.egit.ui
parente2109f760b7c980e719e6d188865e9cf1848abe2 (diff)
downloadegit-1f7ff4789115be952d3b662aa53ec0dabda237e7.tar.gz
egit-1f7ff4789115be952d3b662aa53ec0dabda237e7.tar.xz
egit-1f7ff4789115be952d3b662aa53ec0dabda237e7.zip
Fix saving in the merge editor
Somehow the local file elements in the GitMergeEditorInput got flushed only, but not saved. Add a listener that saves the item when flushed. Bug: 550870 Change-Id: Ifcb22182baa85007de20f3e7cf0d375959c79593 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java
index 887f52da4..e57e0cdc8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java
@@ -71,6 +71,8 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.internal.ui.synchronize.EditableSharedDocumentAdapter.ISharedDocumentAdapterListener;
+import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -79,6 +81,7 @@ import org.eclipse.ui.ide.IDE.SharedImages;
/**
* A Git-specific {@link CompareEditorInput}
*/
+@SuppressWarnings("restriction")
public class GitMergeEditorInput extends CompareEditorInput {
private static final String LABELPATTERN = "{0} - {1}"; //$NON-NLS-1$
@@ -374,6 +377,12 @@ public class GitMergeEditorInput extends CompareEditorInput {
left = new LocalNonWorkspaceTypedElement(repository,
location);
}
+ if (left instanceof LocalResourceTypedElement) {
+ ((LocalResourceTypedElement) left)
+ .setSharedDocumentListener(
+ new LocalResourceSaver(
+ (LocalResourceTypedElement) left));
+ }
} else {
rev = GitFileRevision.inIndex(repository, gitPath,
DirCacheEntry.STAGE_2);
@@ -488,4 +497,44 @@ public class GitMergeEditorInput extends CompareEditorInput {
public boolean canRunAsJob() {
return true;
}
+
+ private static class LocalResourceSaver
+ implements ISharedDocumentAdapterListener {
+
+ LocalResourceTypedElement element;
+
+ public LocalResourceSaver(LocalResourceTypedElement element) {
+ this.element = element;
+ }
+
+ @Override
+ public void handleDocumentConnected() {
+ // Nothing
+ }
+
+ @Override
+ public void handleDocumentDisconnected() {
+ // Nothing
+ }
+
+ @Override
+ public void handleDocumentFlushed() {
+ try {
+ element.saveDocument(true, null);
+ } catch (CoreException e) {
+ Activator.handleStatus(e.getStatus(), true);
+ }
+ }
+
+ @Override
+ public void handleDocumentDeleted() {
+ // Nothing
+ }
+
+ @Override
+ public void handleDocumentSaved() {
+ // Nothing
+ }
+
+ }
}

Back to the top