Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-12-22 02:34:36 +0000
committerSergey Prigogin2016-12-22 03:11:53 +0000
commit0189eb975e89a5532be41a128ea2674dc620bd2a (patch)
treebdf8de90a4ff8d6041f9e59d8d130bb0ffcf8e1d
parent3e8d3c37e45b5f1239a9b2142dea4875a46a44e4 (diff)
downloadeclipse.platform.team-0189eb975e89a5532be41a128ea2674dc620bd2a.tar.gz
eclipse.platform.team-0189eb975e89a5532be41a128ea2674dc620bd2a.tar.xz
eclipse.platform.team-0189eb975e89a5532be41a128ea2674dc620bd2a.zip
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffNode.java99
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java72
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java17
3 files changed, 81 insertions, 107 deletions
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 513feaa72..ce9675e62 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
@@ -20,13 +20,13 @@ import com.ibm.icu.text.MessageFormat;
/**
* Diff node are used as the compare result of the differencing engine.
- * Since it implements the <code>ITypedElement</code> and <code>ICompareInput</code>
+ * Since it implements the {@link ITypedElement} and {@link ICompareInput}
* interfaces it can be used directly to display the
- * compare result in a <code>DiffTreeViewer</code> and as the input to any other
+ * compare result in a {@link DiffTreeViewer} and as the input to any other
* compare/merge viewer.
* <p>
- * <code>DiffNode</code>s are typically created as the result of performing
- * a compare with the <code>Differencer</code>.
+ * {@code DiffNode}s are typically created as the result of performing
+ * a compare with the {@link Differencer}.
* <p>
* Clients typically use this class as is, but may subclass if required.
*
@@ -42,10 +42,10 @@ public class DiffNode extends DiffContainer implements ICompareInput {
private boolean fSwapSides;
/**
- * Creates a new <code>DiffNode</code> and initializes with the given values.
+ * Creates a new {@code DiffNode} and initializes with the given values.
*
- * @param parent under which the new container is added as a child or <code>null</code>
- * @param kind of difference (defined in <code>Differencer</code>)
+ * @param parent under which the new container is added as a child or {@code null}
+ * @param kind of difference (defined in {@link Differencer})
* @param ancestor the common ancestor input to a compare
* @param left the left input to a compare
* @param right the right input to a compare
@@ -58,7 +58,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Creates a new <code>DiffNode</code> with diff kind <code>Differencer.CHANGE</code>
+ * Creates a new {@code DiffNode} with diff kind {@link Differencer#CHANGE}
* and initializes with the given values.
*
* @param left the left input to a compare
@@ -69,9 +69,9 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Creates a new <code>DiffNode</code> and initializes with the given values.
+ * Creates a new {@code DiffNode} and initializes with the given values.
*
- * @param kind of difference (defined in <code>Differencer</code>)
+ * @param kind of difference (defined in {@link Differencer})
* @param ancestor the common ancestor input to a compare
* @param left the left input to a compare
* @param right the right input to a compare
@@ -81,26 +81,26 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Creates a new <code>DiffNode</code> with the given diff kind.
+ * Creates a new {@code DiffNode} with the given diff kind.
*
- * @param kind of difference (defined in <code>Differencer</code>)
+ * @param kind of difference (defined in {@link Differencer})
*/
public DiffNode(int kind) {
super(null, kind);
}
/**
- * Creates a new <code>DiffNode</code> and initializes with the given values.
+ * Creates a new {@code DiffNode} and initializes with the given values.
*
- * @param parent under which the new container is added as a child or <code>null</code>
- * @param kind of difference (defined in <code>Differencer</code>)
+ * @param parent under which the new container is added as a child or {@code null}
+ * @param kind of difference (defined in {@link Differencer})
*/
public DiffNode(IDiffContainer parent, int kind) {
super(parent, kind);
}
/**
- * Registers a listener for changes of this <code>ICompareInput</code>.
+ * Registers a listener for changes of this {@link ICompareInput}.
* Has no effect if an identical listener is already registered.
*
* @param listener the listener to add
@@ -113,7 +113,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Unregisters a <code>ICompareInput</code> listener.
+ * Unregisters a {@link ICompareInput} listener.
* Has no effect if listener is not registered.
*
* @param listener the listener to remove
@@ -128,7 +128,7 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Sends out notification that a change has occurred on the <code>ICompareInput</code>.
+ * Sends out notification that a change has occurred on the {@link ICompareInput}.
*/
protected void fireChange() {
if (fListener != null) {
@@ -141,10 +141,10 @@ public class DiffNode extends DiffContainer implements ICompareInput {
//---- getters & setters
/**
- * Returns <code>true</code> if this node shouldn't automatically be expanded in
- * a </code>DiffTreeViewer</code>.
+ * Returns {@code true} if this node shouldn't automatically be expanded in
+ * a {@link DiffTreeViewer}.
*
- * @return <code>true</code> if node shouldn't automatically be expanded
+ * @return {@code true} if node shouldn't automatically be expanded
*/
public boolean dontExpand() {
return fDontExpand;
@@ -152,19 +152,19 @@ public class DiffNode extends DiffContainer implements ICompareInput {
/**
* Controls whether this node is not automatically expanded when displayed in
- * a </code>DiffTreeViewer</code>.
+ * a {@link DiffTreeViewer}.
*
- * @param dontExpand if <code>true</code> this node is not automatically expanded in </code>DiffTreeViewer</code>
+ * @param dontExpand if {@code true} this node is not automatically expanded in {@link DiffTreeViewer}
*/
public void setDontExpand(boolean dontExpand) {
fDontExpand= dontExpand;
}
/**
- * Returns the first not-<code>null</code> input of this node.
+ * Returns the first not-{@code null} input of this node.
* Method checks the three inputs in the order: ancestor, right, left.
*
- * @return the first not-<code>null</code> input of this node
+ * @return the first not-{@code null} input of this node
*/
public ITypedElement getId() {
if (fAncestor != null)
@@ -175,10 +175,11 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
/**
- * Returns the (non-<code>null</code>) name of the left or right side if they are identical.
+ * Returns the (non-{@code null}) name of the left or right side if they are identical.
* Otherwise both names are concatenated (separated with a slash ('/')).
* <p>
* Subclasses may re-implement to provide a different name for this node.
+ *
* @return the name of this node.
*/
@Override
@@ -224,9 +225,6 @@ public class DiffNode extends DiffContainer implements ICompareInput {
fSwapSides= swap;
}
- /* (non Javadoc)
- * see ITypedElement.getImage
- */
@Override
public Image getImage() {
ITypedElement id= getId();
@@ -235,9 +233,6 @@ public class DiffNode extends DiffContainer implements ICompareInput {
return null;
}
- /* (non Javadoc)
- * see ITypedElement.getType
- */
@Override
public String getType() {
ITypedElement id= getId();
@@ -253,12 +248,9 @@ public class DiffNode extends DiffContainer implements ICompareInput {
* @since 3.0
*/
public void setAncestor(ITypedElement ancestor) {
- fAncestor= ancestor;
+ fAncestor= ancestor;
}
- /* (non Javadoc)
- * see ICompareInput.getAncestor
- */
@Override
public ITypedElement getAncestor() {
return fAncestor;
@@ -273,9 +265,6 @@ public class DiffNode extends DiffContainer implements ICompareInput {
fLeft= left;
}
- /* (non Javadoc)
- * see ICompareInput.getLeft
- */
@Override
public ITypedElement getLeft() {
return fLeft;
@@ -290,17 +279,11 @@ public class DiffNode extends DiffContainer implements ICompareInput {
fRight= right;
}
- /* (non Javadoc)
- * see ICompareInput.getRight
- */
@Override
public ITypedElement getRight() {
return fRight;
}
- /* (non Javadoc)
- * see ICompareInput.copy
- */
@Override
public void copy(boolean leftToRight) {
//System.out.println("DiffNode.copy: " + leftToRight);
@@ -314,10 +297,11 @@ public class DiffNode extends DiffContainer implements ICompareInput {
ITypedElement dst= leftToRight ? getRight() : getLeft();
ITypedElement src= leftToRight ? getLeft() : getRight();
dst= ((IEditableContent)dstParent).replace(dst, src);
- if (leftToRight)
+ if (leftToRight) {
setRight(dst);
- else
+ } else {
setLeft(dst);
+ }
//setKind(Differencer.NO_CHANGE);
@@ -326,23 +310,17 @@ public class DiffNode extends DiffContainer implements ICompareInput {
}
}
- /* (non Javadoc)
- * see Object.hashCode
- */
@Override
public int hashCode() {
String[] path= getPath(this, 0);
int hashCode= 1;
for (int i= 0; i < path.length; i++) {
- String s= path[i];
- hashCode= (31*hashCode) + (s != null ? s.hashCode() : 0);
+ String s= path[i];
+ hashCode= (31 * hashCode) + (s != null ? s.hashCode() : 0);
}
return hashCode;
}
- /* (non Javadoc)
- * see Object.equals
- */
@Override
public boolean equals(Object other) {
if (other != null && getClass() == other.getClass()) {
@@ -350,9 +328,10 @@ public class DiffNode extends DiffContainer implements ICompareInput {
String[] path2= getPath((DiffNode) other, 0);
if (path1.length != path2.length)
return false;
- for (int i= 0; i < path1.length; i++)
+ for (int i= 0; i < path1.length; i++) {
if (! path1[i].equals(path2[i]))
return false;
+ }
return true;
}
return super.equals(other);
@@ -361,13 +340,13 @@ public class DiffNode extends DiffContainer implements ICompareInput {
private static String[] getPath(ITypedElement el, int level) {
String[] path= null;
if (el instanceof IDiffContainer) {
- IDiffContainer parent= ((IDiffContainer)el).getParent();
+ IDiffContainer parent= ((IDiffContainer) el).getParent();
if (parent != null)
- path= getPath(parent, level+1);
+ path= getPath(parent, level + 1);
}
if (path == null)
- path= new String[level+1];
- path[(path.length-1)-level]= el.getName();
+ path= new String[level + 1];
+ path[(path.length - 1) - level]= el.getName();
return path;
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java
index 49ed4f4ee..ca012ad92 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInput.java
@@ -19,34 +19,32 @@ import org.eclipse.swt.graphics.Image;
* and a name and image which is used when displaying the three way input
* in the UI, for example, in a title bar.
* <p>
- * Note: at most two sides of an <code>ICompareInput</code> can be <code>null</code>,
+ * Note: at most two sides of an {@code ICompareInput} can be {@code null},
* (as it is normal for additions or deletions) but not all three.
* <p>
- * <code>ICompareInput</code> provides methods for registering
- * <code>ICompareInputChangeListener</code>s
+ * {@code ICompareInput} provides methods for registering
+ * {@link ICompareInputChangeListener}s
* that get informed if one (or more)
- * of the three sides of an <code>ICompareInput</code> object changes its value.
+ * of the three sides of an {@code ICompareInput} object changes its value.
* <p>
* For example when accepting an incoming addition
- * the (non-<code>null</code>) left side of an <code>ICompareInput</code>
- * is copied to the right side by means of method <code>copy</code>.
- * This should trigger a call to <code>compareInputChanged</code> of registered
- * <code>ICompareInputChangeListener</code>s.
+ * the (non-{@code null}) left side of an {@code ICompareInput}
+ * is copied to the right side by means of method {@code copy}.
+ * This should trigger a call to {@link ICompareInputChangeListener#compareInputChanged} of registered
+ * {@link ICompareInputChangeListener}s.
* <p>
* Clients can implement this interface, or use the convenience implementation
- * <code>DiffNode</code>.
- * </p>
+ * {@link DiffNode}.
*
* @see StructureDiffViewer
* @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer
* @see DiffNode
*/
public interface ICompareInput {
-
/**
* Returns name of input.
* This name is displayed when this input is shown in a viewer.
- * In many cases this name is the name of one of the non-<code>null</code> sides or a combination
+ * In many cases this name is the name of one of the non-{@code null} sides or a combination
* thereof.
*
* @return name of input
@@ -56,46 +54,44 @@ public interface ICompareInput {
/**
* Returns an image representing this input.
* This image is typically displayed when this input is shown in a viewer.
- * In many cases this image is the image of one of the non-<code>null</code> sides.
+ * In many cases this image is the image of one of the non-{@code null} sides.
*
- * @return image representing this input, or <code>null</code> if no icon should be shown
+ * @return image representing this input, or {@code null} if no icon should be shown
*/
Image getImage();
/**
- * Returns the kind of difference between the
- * three sides ancestor, left and right.
- * This field is only meaningful if the <code>ICompareInput</code>
- * is the result of another compare. In this case it is used
- * together with <code>getImage</code> to compose a icon
+ * Returns the kind of difference between the three sides ancestor, left and right.
+ * This field is only meaningful if the {@code ICompareInput} is the result of another
+ * compare. In this case it is used together with {@link #getImage()} to compose an icon
* which reflects the kind of difference between the two or three elements.
*
- * @return kind of difference (see <code>Differencer</code>)
+ * @return kind of difference (see {@link Differencer})
*/
int getKind();
/**
* Returns the ancestor side of this input.
- * Returns <code>null</code> if this input has no ancestor
+ * Returns {@code null} if this input has no ancestor
* or in the two-way compare case.
*
- * @return the ancestor of this input, or <code>null</code>
+ * @return the ancestor of this input, or {@code null}
*/
ITypedElement getAncestor();
/**
* Returns the left side of this input.
- * Returns <code>null</code> if there is no left side (deletion or addition).
+ * Returns {@code null} if there is no left side (deletion or addition).
*
- * @return the left side of this input, or <code>null</code>
+ * @return the left side of this input, or {@code null}
*/
ITypedElement getLeft();
/**
* Returns the right side of this input.
- * Returns <code>null</code> if there is no right side (deletion or addition).
+ * Returns {@code null} if there is no right side (deletion or addition).
*
- * @return the right side of this input, or <code>null</code>
+ * @return the right side of this input, or {@code null}
*/
ITypedElement getRight();
@@ -117,25 +113,25 @@ public interface ICompareInput {
/**
* Copy one side (source) to the other side (destination) depending on the
- * value of <code>leftToRight</code>. This method is called from
+ * value of {@code leftToRight}. This method is called from
* a merge viewer if a corresponding action ("take left" or "take right")
* has been pressed.
* <p>
* The implementation should handle the following cases:
- * <UL>
- * <LI>
- * if the source side is <code>null</code> the destination must be deleted,
- * <LI>
- * if the destination is <code>null</code> the destination must be created
+ * <ul>
+ * <li>
+ * if the source side is {@code null} the destination must be deleted,
+ * <li>
+ * if the destination is {@code null} the destination must be created
* and filled with the contents from the source,
- * <LI>
- * if both sides are non-<code>null</code> the contents of source must be copied to destination.
- * </UL>
+ * <li>
+ * if both sides are non-{@code null} the contents of source must be copied to destination.
+ * </ul>
* In addition the implementation should send out notification to the registered
- * <code>ICompareInputChangeListener</code>.
+ * {@link ICompareInputChangeListener}.
*
- * @param leftToRight if <code>true</code> the left side is copied to the right side.
- * If <code>false</code> the right side is copied to the left side
+ * @param leftToRight if {@code true} the left side is copied to the right side.
+ * If {@code false} the right side is copied to the left side
*/
void copy(boolean leftToRight);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java
index b20603d00..cee2ccb0c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/ICompareInputChangeListener.java
@@ -12,27 +12,26 @@ package org.eclipse.compare.structuremergeviewer;
/**
* Listener that gets informed if one (or more)
- * of the three sides of an <code>ICompareInput</code> object changes its value.
+ * of the three sides of an {@link ICompareInput} object changes its value.
* <p>
* For example when accepting an incoming addition
- * the (non-null) left side of an <code>ICompareInput</code>
- * is copied to the right side (which was <code>null</code>).
- * This triggers a call to <code>compareInputChanged</code> of registered
- * <code>ICompareInputChangeListener</code>.
+ * the (non-{@code null}) left side of an {@link ICompareInput}
+ * is copied to the right side (which was {@code null}).
+ * This triggers a call to {@link #compareInputChanged} of registered
+ * {@code ICompareInputChangeListener}.
* <p>
* Note however, that listener are not informed if the content of one of the sides changes.
* <p>
* Clients may implement this interface. It is also implemented by viewers that take
- * an <code>ICompareInput</code> as input.
+ * an {@link ICompareInput} as input.
* </p>
*/
public interface ICompareInputChangeListener {
-
/**
* Called whenever the value (not the content) of one or more of the three sides
- * of a <code>ICompareInput</code> has changed.
+ * of a {@link ICompareInput} has changed.
*
- * @param source the <code>ICompareInput</code> that has changed
+ * @param source the {@link ICompareInput} that has changed
*/
void compareInputChanged(ICompareInput source);
}

Back to the top