Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-03-04 14:10:29 -0500
committerAndre Weinand2002-03-04 14:10:29 -0500
commit548aebff0dd9ce98bf51b003ca4ec43677ed99f3 (patch)
tree94e1937424f496149273ae45fcc32809914c4e9d
parente2ea534d83afefb4dae225cf0b738f4b4aae1b7d (diff)
downloadeclipse.platform.team-548aebff0dd9ce98bf51b003ca4ec43677ed99f3.tar.gz
eclipse.platform.team-548aebff0dd9ce98bf51b003ca4ec43677ed99f3.tar.xz
eclipse.platform.team-548aebff0dd9ce98bf51b003ca4ec43677ed99f3.zip
more work on #9869
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java31
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java22
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java36
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java31
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java22
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java36
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java3
10 files changed, 170 insertions, 18 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
index 0af2c9111..5e8d9d6de 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
@@ -36,14 +36,33 @@ public interface IEditableContent {
/**
* This method is called on a parent to
- * - add a child,
- * - remove a child,
- * - copy the contents of a child
+ * <UL>
+ * <LI>
+ * add a child,
+ * <LI>
+ * remove a child,
+ * <LI>
+ * copy the contents of a child
+ * </UL>
*
* What to do is encoded in the two arguments as follows:
- * add: child == null other != null
- * remove: child != null other == null
- * copy: child != null other != null
+ * <TABLE>
+ * <TR>
+ * <TD>add:</TD>
+ * <TD>child == null</TD>
+ * <TD>other != null</TD>
+ * </TR>
+ * <TR>
+ * <TD>remove:</TD>
+ * <TD>child != null</TD>
+ * <TD>other == null</TD>
+ * </TR>
+ * <TR>
+ * <TD>copy:</TD>
+ * <TD>child != null</TD>
+ * <TD>other != null</TD>
+ * </TR>
+ * </TABLE>
*/
ITypedElement replace(ITypedElement child, ITypedElement other);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
index 852759114..8e1b8018e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
@@ -17,6 +17,7 @@ import org.eclipse.compare.structuremergeviewer.IStructureComparator;
public class BufferedResourceNode extends ResourceNode {
private boolean fDirty= false;
+ private IFile fDeleteFile;
/**
* Creates a <code>ResourceNode</code> for the given resource.
@@ -41,6 +42,12 @@ public class BufferedResourceNode extends ResourceNode {
*/
public void commit(IProgressMonitor pm) throws CoreException {
if (fDirty) {
+
+ if (fDeleteFile != null) {
+ fDeleteFile.delete(true, true, pm);
+ return;
+ }
+
IResource resource= getResource();
if (resource instanceof IFile) {
ByteArrayInputStream is= new ByteArrayInputStream(getContent());
@@ -64,7 +71,7 @@ public class BufferedResourceNode extends ResourceNode {
public ITypedElement replace(ITypedElement child, ITypedElement other) {
- if (child == null) {
+ if (child == null) { // add resource
// create a node without a resource behind it!
IResource resource= getResource();
if (resource instanceof IFolder) {
@@ -74,6 +81,19 @@ public class BufferedResourceNode extends ResourceNode {
}
}
+ if (other == null) { // delete resource
+ IResource resource= getResource();
+ if (resource instanceof IFolder) {
+ IFolder folder= (IFolder) resource;
+ IFile file= folder.getFile(child.getName());
+ if (file != null && file.exists()) {
+ fDeleteFile= file;
+ fDirty= true;
+ }
+ }
+ return null;
+ }
+
if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) {
IEditableContent dst= (IEditableContent) child;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
index 7c0a7f475..232a93d85 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
@@ -176,7 +176,7 @@ public class OverlayPreferenceStore implements IPreferenceStore {
} else if (STRING == d) {
if (forceInitialization)
- target.setValue(key.fKey, "1");
+ target.setValue(key.fKey, "1"); //$NON-NLS-1$
target.setValue(key.fKey, orgin.getString(key.fKey));
target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index 3f22f168c..7909e1847 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -7,7 +7,10 @@ package org.eclipse.compare.internal;
import java.text.MessageFormat;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -31,15 +34,41 @@ class ResourceCompareInput extends CompareEditorInput {
private IResource fAncestorResource;
private IResource fLeftResource;
private IResource fRightResource;
+ private DiffTreeViewer fDiffViewer;
private class MyDiffNode extends DiffNode {
+
+ private boolean fDirty= false;
+ private ITypedElement fLastId;
+ private String fLastName;
+
+
public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right) {
super(parent, description, ancestor, left, right);
}
protected void fireChange() {
super.fireChange();
setDirty(true);
+ fDirty= true;
+ if (fDiffViewer != null)
+ fDiffViewer.refresh(this);
+ }
+
+ public String getName() {
+ if (fLastName == null)
+ fLastName= super.getName();
+ if (fDirty)
+ return fLastName + " *"; //$NON-NLS-1$
+ return fLastName;
+ }
+
+ public ITypedElement getId() {
+ ITypedElement id= super.getId();
+ if (id == null)
+ return fLastId;
+ fLastId= id;
+ return id;
}
}
@@ -50,6 +79,13 @@ class ResourceCompareInput extends CompareEditorInput {
super(config);
}
+ public Viewer createDiffViewer(Composite parent) {
+ Viewer v= super.createDiffViewer(parent);
+ if (v instanceof DiffTreeViewer)
+ fDiffViewer= (DiffTreeViewer) v;
+ return v;
+ }
+
/**
* Returns true if compare can be executed for the given selection.
*/
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
index 75c91bbe5..a2960a2a7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
@@ -298,7 +298,8 @@ public class DiffNode extends DiffContainer implements ITypedElement, ICompareIn
setRight(dst);
else
setLeft(dst);
- setKind(Differencer.NO_CHANGE);
+
+ //setKind(Differencer.NO_CHANGE);
fireChange();
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
index 0af2c9111..5e8d9d6de 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IEditableContent.java
@@ -36,14 +36,33 @@ public interface IEditableContent {
/**
* This method is called on a parent to
- * - add a child,
- * - remove a child,
- * - copy the contents of a child
+ * <UL>
+ * <LI>
+ * add a child,
+ * <LI>
+ * remove a child,
+ * <LI>
+ * copy the contents of a child
+ * </UL>
*
* What to do is encoded in the two arguments as follows:
- * add: child == null other != null
- * remove: child != null other == null
- * copy: child != null other != null
+ * <TABLE>
+ * <TR>
+ * <TD>add:</TD>
+ * <TD>child == null</TD>
+ * <TD>other != null</TD>
+ * </TR>
+ * <TR>
+ * <TD>remove:</TD>
+ * <TD>child != null</TD>
+ * <TD>other == null</TD>
+ * </TR>
+ * <TR>
+ * <TD>copy:</TD>
+ * <TD>child != null</TD>
+ * <TD>other != null</TD>
+ * </TR>
+ * </TABLE>
*/
ITypedElement replace(ITypedElement child, ITypedElement other);
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
index 852759114..8e1b8018e 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
@@ -17,6 +17,7 @@ import org.eclipse.compare.structuremergeviewer.IStructureComparator;
public class BufferedResourceNode extends ResourceNode {
private boolean fDirty= false;
+ private IFile fDeleteFile;
/**
* Creates a <code>ResourceNode</code> for the given resource.
@@ -41,6 +42,12 @@ public class BufferedResourceNode extends ResourceNode {
*/
public void commit(IProgressMonitor pm) throws CoreException {
if (fDirty) {
+
+ if (fDeleteFile != null) {
+ fDeleteFile.delete(true, true, pm);
+ return;
+ }
+
IResource resource= getResource();
if (resource instanceof IFile) {
ByteArrayInputStream is= new ByteArrayInputStream(getContent());
@@ -64,7 +71,7 @@ public class BufferedResourceNode extends ResourceNode {
public ITypedElement replace(ITypedElement child, ITypedElement other) {
- if (child == null) {
+ if (child == null) { // add resource
// create a node without a resource behind it!
IResource resource= getResource();
if (resource instanceof IFolder) {
@@ -74,6 +81,19 @@ public class BufferedResourceNode extends ResourceNode {
}
}
+ if (other == null) { // delete resource
+ IResource resource= getResource();
+ if (resource instanceof IFolder) {
+ IFolder folder= (IFolder) resource;
+ IFile file= folder.getFile(child.getName());
+ if (file != null && file.exists()) {
+ fDeleteFile= file;
+ fDirty= true;
+ }
+ }
+ return null;
+ }
+
if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) {
IEditableContent dst= (IEditableContent) child;
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
index 7c0a7f475..232a93d85 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
@@ -176,7 +176,7 @@ public class OverlayPreferenceStore implements IPreferenceStore {
} else if (STRING == d) {
if (forceInitialization)
- target.setValue(key.fKey, "1");
+ target.setValue(key.fKey, "1"); //$NON-NLS-1$
target.setValue(key.fKey, orgin.getString(key.fKey));
target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index 3f22f168c..7909e1847 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -7,7 +7,10 @@ package org.eclipse.compare.internal;
import java.text.MessageFormat;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -31,15 +34,41 @@ class ResourceCompareInput extends CompareEditorInput {
private IResource fAncestorResource;
private IResource fLeftResource;
private IResource fRightResource;
+ private DiffTreeViewer fDiffViewer;
private class MyDiffNode extends DiffNode {
+
+ private boolean fDirty= false;
+ private ITypedElement fLastId;
+ private String fLastName;
+
+
public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right) {
super(parent, description, ancestor, left, right);
}
protected void fireChange() {
super.fireChange();
setDirty(true);
+ fDirty= true;
+ if (fDiffViewer != null)
+ fDiffViewer.refresh(this);
+ }
+
+ public String getName() {
+ if (fLastName == null)
+ fLastName= super.getName();
+ if (fDirty)
+ return fLastName + " *"; //$NON-NLS-1$
+ return fLastName;
+ }
+
+ public ITypedElement getId() {
+ ITypedElement id= super.getId();
+ if (id == null)
+ return fLastId;
+ fLastId= id;
+ return id;
}
}
@@ -50,6 +79,13 @@ class ResourceCompareInput extends CompareEditorInput {
super(config);
}
+ public Viewer createDiffViewer(Composite parent) {
+ Viewer v= super.createDiffViewer(parent);
+ if (v instanceof DiffTreeViewer)
+ fDiffViewer= (DiffTreeViewer) v;
+ return v;
+ }
+
/**
* Returns true if compare can be executed for the given selection.
*/
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
index 75c91bbe5..a2960a2a7 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java
@@ -298,7 +298,8 @@ public class DiffNode extends DiffContainer implements ITypedElement, ICompareIn
setRight(dst);
else
setLeft(dst);
- setKind(Differencer.NO_CHANGE);
+
+ //setKind(Differencer.NO_CHANGE);
fireChange();
}

Back to the top