Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2012-05-02 09:45:14 -0400
committerMikaël Barbero2012-05-02 09:45:14 -0400
commit5a55fa8d5b72ce4ca6938e5d247501c8d9e36ffb (patch)
tree597d5c2a56a319949fcb0fe9bd40f4cca7b6120e
parent7967497ffe1550c22b3e141cd33f898fe8265df6 (diff)
downloadorg.eclipse.emf.compare-5a55fa8d5b72ce4ca6938e5d247501c8d9e36ffb.tar.gz
org.eclipse.emf.compare-5a55fa8d5b72ce4ca6938e5d247501c8d9e36ffb.tar.xz
org.eclipse.emf.compare-5a55fa8d5b72ce4ca6938e5d247501c8d9e36ffb.zip
do not use the root adapter factory, but the provided one (it has to
delegate to the correct one) add some javadoc (happy checkstyle) use some static imports to guava
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java31
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/provider/EObjectNode.java19
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffContainer.java69
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffElement.java49
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffNode.java12
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/AttributeChangeNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/CompareNodeAdapterFactory.java86
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ComparisonNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ConflictNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/EquivalenceNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchResourceNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ReferenceChangeNode.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ResourceAttachmentChangeNode.java5
15 files changed, 191 insertions, 123 deletions
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
index 8912626f6..92eb3b054 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/CompareItemProviderAdapterFactorySpec.java
@@ -15,7 +15,6 @@ import com.google.common.base.Preconditions;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory;
-import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
/**
@@ -55,30 +54,9 @@ public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAd
}
/**
- * Returns the {@link #getRootAdapterFactory() root adapter factory} of the given
- * <code>adapterAdapter</code> if it is a {@link ComposeableAdapterFactory composeable} one.
- *
- * @param adapterFactory
- * the adapter factory
- * @return either the {@link #getRootAdapterFactory() root adapter factory} of the given
- * <code>adapterAdapter</code> or <code>adapterAdapter</code>.
- */
- static AdapterFactory getRootAdapterFactoryIfComposeable(AdapterFactory adapterFactory) {
- AdapterFactory af = adapterFactory;
- // If the adapter factory is composeable, we'll adapt using the root.
- if (adapterFactory instanceof ComposeableAdapterFactory) {
- af = ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory();
- }
- return af;
- }
-
- /**
* Returns the text of the given <code>object</code> by adapting it to {@link IItemLabelProvider} and
* asking for its {@link IItemLabelProvider#getText(Object) text}. Returns null if <code>object</code> is
* null.
- * <p>
- * The {@link AdapterFactory} used to adapt <code>object</code> is either the given {@link AdapterFactory}
- * or its root if it is an {@link ComposeableAdapterFactory}.
*
* @param adapterFactory
* the adapter factory to adapt from
@@ -91,8 +69,7 @@ public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAd
static String getText(AdapterFactory adapterFactory, Object object) {
Preconditions.checkNotNull(adapterFactory);
if (object != null) {
- AdapterFactory af = getRootAdapterFactoryIfComposeable(adapterFactory);
- Object adapter = af.adapt(object, IItemLabelProvider.class);
+ Object adapter = adapterFactory.adapt(object, IItemLabelProvider.class);
if (adapter instanceof IItemLabelProvider) {
return ((IItemLabelProvider)adapter).getText(object);
}
@@ -104,9 +81,6 @@ public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAd
* Returns the image of the given <code>object</code> by adapting it to {@link IItemLabelProvider} and
* asking for its {@link IItemLabelProvider#getImage(Object) text}. Returns null if <code>object</code> is
* null.
- * <p>
- * The {@link AdapterFactory} used to adapt <code>object</code> is either the given {@link AdapterFactory}
- * or its root if it is an {@link ComposeableAdapterFactory}.
*
* @param adapterFactory
* the adapter factory to adapt from
@@ -119,8 +93,7 @@ public class CompareItemProviderAdapterFactorySpec extends CompareItemProviderAd
static Object getImage(AdapterFactory adapterFactory, Object object) {
Preconditions.checkNotNull(adapterFactory);
if (object != null) {
- AdapterFactory af = getRootAdapterFactoryIfComposeable(adapterFactory);
- Object adapter = af.adapt(object, IItemLabelProvider.class);
+ Object adapter = adapterFactory.adapt(object, IItemLabelProvider.class);
if (adapter instanceof IItemLabelProvider) {
return ((IItemLabelProvider)adapter).getImage(object);
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
index 3f735bdf0..b78ca688f 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchItemProviderSpec.java
@@ -40,10 +40,10 @@ public class MatchItemProviderSpec extends MatchItemProvider {
@Override
public Object getImage(Object object) {
Match match = (Match)object;
- Object ret = CompareItemProviderAdapterFactorySpec.getImage(adapterFactory, match.getLeft());
+ Object ret = CompareItemProviderAdapterFactorySpec.getImage(getRootAdapterFactory(), match.getLeft());
if (ret == null) {
- ret = CompareItemProviderAdapterFactorySpec.getImage(adapterFactory, match.getRight());
+ ret = CompareItemProviderAdapterFactorySpec.getImage(getRootAdapterFactory(), match.getRight());
}
if (ret == null) {
@@ -61,10 +61,10 @@ public class MatchItemProviderSpec extends MatchItemProvider {
@Override
public String getText(Object object) {
Match match = (Match)object;
- String ret = CompareItemProviderAdapterFactorySpec.getText(adapterFactory, match.getLeft());
+ String ret = CompareItemProviderAdapterFactorySpec.getText(getRootAdapterFactory(), match.getLeft());
if (ret == null) {
- ret = CompareItemProviderAdapterFactorySpec.getText(adapterFactory, match.getRight());
+ ret = CompareItemProviderAdapterFactorySpec.getText(getRootAdapterFactory(), match.getRight());
}
if (ret == null) {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/provider/EObjectNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/provider/EObjectNode.java
index bbd7ff153..31b75544a 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/provider/EObjectNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/provider/EObjectNode.java
@@ -29,7 +29,6 @@ import org.eclipse.emf.compare.ide.ui.EMFCompareIDEUIPlugin;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.swt.graphics.Image;
@@ -80,7 +79,7 @@ public class EObjectNode implements ITypedElement, IEObjectAccessor, IStreamCont
* @see org.eclipse.compare.ITypedElement#getImage()
*/
public Image getImage() {
- Adapter adapter = getRootAdapterFactoryIfComposeable().adapt(fEObject, IItemLabelProvider.class);
+ Adapter adapter = fAdapterFactory.adapt(fEObject, IItemLabelProvider.class);
if (adapter instanceof IItemLabelProvider) {
Object image = ((IItemLabelProvider)adapter).getImage(fEObject);
return ExtendedImageRegistry.getInstance().getImage(image);
@@ -89,22 +88,6 @@ public class EObjectNode implements ITypedElement, IEObjectAccessor, IStreamCont
}
/**
- * Returns the {@link #getRootAdapterFactory() root adapter factory} of the given
- * <code>adapterAdapter</code> if it is a {@link ComposeableAdapterFactory composeable} one.
- *
- * @return either the {@link #getRootAdapterFactory() root adapter factory} of this
- * <code>adapterAdapter</code> or <code>adapterAdapter</code>.
- */
- private AdapterFactory getRootAdapterFactoryIfComposeable() {
- AdapterFactory af = fAdapterFactory;
- // If the adapter factory is composeable, we'll adapt using the root.
- if (fAdapterFactory instanceof ComposeableAdapterFactory) {
- af = ((ComposeableAdapterFactory)fAdapterFactory).getRootAdapterFactory();
- }
- return af;
- }
-
- /**
* {@inheritDoc}
*
* @see org.eclipse.compare.ITypedElement#getType()
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffContainer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffContainer.java
index 52529f3de..192306da5 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffContainer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffContainer.java
@@ -10,11 +10,16 @@
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.isEmpty;
+import static com.google.common.collect.Iterables.toArray;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Lists.newArrayList;
+
import com.google.common.base.Function;
import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
@@ -61,13 +66,12 @@ public abstract class AbstractEDiffContainer extends AbstractEDiffElement implem
public boolean hasChildren() {
boolean ret = false;
if (target instanceof EObject) {
- Adapter treeItemContentProvider = getRootAdapterFactoryIfComposeable().adapt(target,
+ Adapter treeItemContentProvider = getAdapterFactory().adapt(target,
ITreeItemContentProvider.class);
if (treeItemContentProvider instanceof ITreeItemContentProvider) {
- List<IDiffElement> children = Lists.newArrayList(getChildren());
- Iterable<IDiffElement> notMatchChildren = Iterables.filter(children, Predicates
- .not(Predicates.instanceOf(MatchNode.class)));
- if (!Iterables.isEmpty(notMatchChildren)) {
+ List<IDiffElement> children = newArrayList(getChildren());
+ Iterable<IDiffElement> notMatchChildren = filter(children, not(instanceOf(MatchNode.class)));
+ if (!isEmpty(notMatchChildren)) {
ret = true;
} else {
ret = hasChildren(notMatchChildren);
@@ -78,17 +82,20 @@ public abstract class AbstractEDiffContainer extends AbstractEDiffElement implem
}
/**
- * @param notMatchChildren
- * @return
+ * Returns true if one of the given <code>elements</code> is a {@link IDiffContainer} and it
+ * {@link IDiffContainer#hasChildren() has children}. Returns false if the given iterable is empty.
+ *
+ * @param elements
+ * the elements to test
+ * @return true true if one of the given <code>elements</code> is a {@link IDiffContainer} and it
+ * {@link IDiffContainer#hasChildren() has children}, false otherwise.
*/
- private static boolean hasChildren(Iterable<IDiffElement> notMatchChildren) {
+ private static boolean hasChildren(Iterable<IDiffElement> elements) {
boolean ret = false;
- for (IDiffElement child : notMatchChildren) {
- if (child instanceof IDiffContainer) {
- if (((IDiffContainer)child).hasChildren()) {
- ret = true;
- break;
- }
+ for (IDiffElement child : elements) {
+ if (child instanceof IDiffContainer && ((IDiffContainer)child).hasChildren()) {
+ ret = true;
+ break;
}
}
return ret;
@@ -102,13 +109,13 @@ public abstract class AbstractEDiffContainer extends AbstractEDiffElement implem
public IDiffElement[] getChildren() {
IDiffElement[] ret = EMPTY_ARRAY__DIFF_ELEMENT;
if (target instanceof EObject) {
- Adapter treeItemContentProvider = getRootAdapterFactoryIfComposeable().adapt(target,
+ Adapter treeItemContentProvider = getAdapterFactory().adapt(target,
ITreeItemContentProvider.class);
if (treeItemContentProvider instanceof ITreeItemContentProvider) {
Collection<?> children = ((ITreeItemContentProvider)treeItemContentProvider)
.getChildren(target);
- Iterable<?> childrenToDisplay = Iterables.filter(children, fNeedDisplay);
- ret = Iterables.toArray(adapt(childrenToDisplay, getAdapterFactory(), IDiffElement.class),
+ Iterable<?> childrenToDisplay = filter(children, fNeedDisplay);
+ ret = toArray(adapt(childrenToDisplay, getAdapterFactory(), IDiffElement.class),
IDiffElement.class);
}
}
@@ -141,13 +148,27 @@ public abstract class AbstractEDiffContainer extends AbstractEDiffElement implem
throw new UnsupportedOperationException();
}
- protected static <T> Iterable<T> adapt(Iterable<?> iterable, final AdapterFactory adapterFactory,
- final Class<T> clazz) {
+ /**
+ * Adapts each elements of the the given <code>iterable</code> to the given <code>type</code> by using the
+ * given <code>adapterFactory</code>.
+ *
+ * @param <T>
+ * the type of returned elements.
+ * @param iterable
+ * the iterable to transform.
+ * @param adapterFactory
+ * the {@link AdapterFactory} used to adapt elements
+ * @param type
+ * the target type of adapted elements
+ * @return an iterable with element of type <code>type</code>.
+ */
+ private static <T> Iterable<T> adapt(Iterable<?> iterable, final AdapterFactory adapterFactory,
+ final Class<T> type) {
Function<Object, Object> adaptFunction = new Function<Object, Object>() {
public Object apply(Object input) {
- return adapterFactory.adapt(input, clazz);
+ return adapterFactory.adapt(input, type);
}
};
- return Iterables.filter(Iterables.transform(iterable, adaptFunction), clazz);
+ return filter(transform(iterable, adaptFunction), type);
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffElement.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffElement.java
index 1f0b25844..f0d1422bb 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffElement.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffElement.java
@@ -17,21 +17,31 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.swt.graphics.Image;
/**
+ * An EMF {@link Adapter} implementing the {@link IDiffElement} interface.
+ * <p>
+ * It is delegating {@link #getImage()} and {@link #getName()} to an adapter retrieved from an
+ * {@link AdapterFactory}.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public abstract class AbstractEDiffElement extends AdapterImpl implements IDiffElement {
+ /**
+ * The {@link AdapterFactory} used to implement {@link #getName()} and {@link #getImage()}.
+ */
private final AdapterFactory fAdapterFactory;
/**
+ * Simple constructor storing the given {@link AdapterFactory}.
+ *
* @param adapterFactory
+ * the factory.
*/
public AbstractEDiffElement(AdapterFactory adapterFactory) {
fAdapterFactory = adapterFactory;
@@ -43,36 +53,22 @@ public abstract class AbstractEDiffElement extends AdapterImpl implements IDiffE
}
/**
- * @return
+ * Final accessor to the {@link AdapterFactory} for sub classses.
+ *
+ * @return the wrapped {@link AdapterFactory}.
*/
protected final AdapterFactory getAdapterFactory() {
return fAdapterFactory;
}
/**
- * Returns the {@link #getRootAdapterFactory() root adapter factory} of the given
- * <code>adapterAdapter</code> if it is a {@link ComposeableAdapterFactory composeable} one.
- *
- * @return either the {@link #getRootAdapterFactory() root adapter factory} of this
- * <code>adapterAdapter</code> or <code>adapterAdapter</code>.
- */
- protected final AdapterFactory getRootAdapterFactoryIfComposeable() {
- AdapterFactory af = getAdapterFactory();
- // If the adapter factory is composeable, we'll adapt using the root.
- if (fAdapterFactory instanceof ComposeableAdapterFactory) {
- af = ((ComposeableAdapterFactory)fAdapterFactory).getRootAdapterFactory();
- }
- return af;
- }
-
- /**
* {@inheritDoc}
*
* @see org.eclipse.compare.ITypedElement#getName()
*/
public String getName() {
String ret = null;
- Adapter adapter = getRootAdapterFactoryIfComposeable().adapt(target, IItemLabelProvider.class);
+ Adapter adapter = getAdapterFactory().adapt(target, IItemLabelProvider.class);
if (adapter instanceof IItemLabelProvider) {
ret = ((IItemLabelProvider)adapter).getText(target);
}
@@ -86,22 +82,15 @@ public abstract class AbstractEDiffElement extends AdapterImpl implements IDiffE
*/
public Image getImage() {
Image ret = null;
- Adapter adapter = getRootAdapterFactoryIfComposeable().adapt(target, IItemLabelProvider.class);
+ Adapter adapter = getAdapterFactory().adapt(target, IItemLabelProvider.class);
if (adapter instanceof IItemLabelProvider) {
- ret = getImageFromObject(((IItemLabelProvider)adapter).getImage(target));
+ Object imageObject = ((IItemLabelProvider)adapter).getImage(target);
+ ret = ExtendedImageRegistry.getInstance().getImage(imageObject);
}
return ret;
}
/**
- * @param object
- * @return
- */
- protected Image getImageFromObject(Object object) {
- return ExtendedImageRegistry.getInstance().getImage(object);
- }
-
- /**
* {@inheritDoc}
*
* @see org.eclipse.compare.ITypedElement#getType()
@@ -127,7 +116,7 @@ public abstract class AbstractEDiffElement extends AdapterImpl implements IDiffE
public IDiffContainer getParent() {
IDiffContainer ret = null;
if (target instanceof EObject) {
- Adapter treeItemContentProvider = getRootAdapterFactoryIfComposeable().adapt(target,
+ Adapter treeItemContentProvider = getAdapterFactory().adapt(target,
ITreeItemContentProvider.class);
if (treeItemContentProvider instanceof ITreeItemContentProvider) {
ret = getParentAndAdaptAsIDiffContainer((ITreeItemContentProvider)treeItemContentProvider);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffNode.java
index 70383ac6f..f3c716ef7 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/AbstractEDiffNode.java
@@ -53,6 +53,18 @@ public abstract class AbstractEDiffNode extends AbstractEDiffContainer implement
}
/**
+ * Sends out notification that a change has occurred on the <code>ICompareInput</code>.
+ */
+ protected void fireChange() {
+ if (fListener != null) {
+ Object[] listeners = fListener.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ((ICompareInputChangeListener)listeners[i]).compareInputChanged(this);
+ }
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.compare.structuremergeviewer.ICompareInput#copy(boolean)
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/AttributeChangeNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/AttributeChangeNode.java
index afdb14a15..aee51cb16 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/AttributeChangeNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/AttributeChangeNode.java
@@ -18,12 +18,17 @@ import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
/**
+ * Specific AbstractEDiffNode for {@link AttributeChange} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class AttributeChangeNode extends DiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public AttributeChangeNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/CompareNodeAdapterFactory.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/CompareNodeAdapterFactory.java
index 569eb460d..fa22a78fa 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/CompareNodeAdapterFactory.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/CompareNodeAdapterFactory.java
@@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.provider;
-import java.util.ArrayList;
+import static com.google.common.collect.Lists.newArrayList;
+
import java.util.Collection;
import org.eclipse.compare.ITypedElement;
@@ -20,7 +21,6 @@ import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.compare.ComparePackage;
import org.eclipse.emf.compare.util.CompareAdapterFactory;
import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
@@ -36,16 +36,31 @@ import org.eclipse.emf.edit.provider.INotifyChangedListener;
*/
public class CompareNodeAdapterFactory extends CompareAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
+ /**
+ * This keeps track of the root adapter factory that delegates to this adapter factory.
+ */
protected ComposedAdapterFactory parentAdapterFactory;
- protected IChangeNotifier changeNotifier = new ChangeNotifier();
+ /**
+ * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
+ */
+ protected final IChangeNotifier changeNotifier = new ChangeNotifier();
- protected Collection<Object> supportedTypes = new ArrayList<Object>();
+ /**
+ * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
+ */
+ protected final Collection<Object> supportedTypes = newArrayList();
+ /**
+ * Creates an {@link ComposeableAdapterFactory} with the following supported types:
+ * <ul>
+ * <li>{@link IDiffElement}</li>,
+ * <li>{@link IDiffContainer}</li>,
+ * <li>{@link ITypedElement}</li>,
+ * <li>{@link ICompareInput}</li>.
+ * </ul>
+ */
public CompareNodeAdapterFactory() {
- if (modelPackage == null) {
- modelPackage = ComparePackage.eINSTANCE;
- }
supportedTypes.add(IDiffElement.class);
supportedTypes.add(IDiffContainer.class);
supportedTypes.add(ITypedElement.class);
@@ -59,12 +74,24 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
/**
* This implementation substitutes the factory itself as the key for the adapter.
+ *
+ * @param notifier
+ * the notifier to adapt
+ * @param type
+ * unused
+ * @return a previously existing associated adapter, a new associated adapter if possible, or
+ * <code>null</code> otherwise.
*/
@Override
public Adapter adapt(Notifier notifier, Object type) {
return super.adapt(notifier, this);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.common.notify.impl.AdapterFactoryImpl#adapt(java.lang.Object, java.lang.Object)
+ */
@Override
public Object adapt(Object object, Object type) {
if (isFactoryForType(type)) {
@@ -79,13 +106,22 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
/**
* This returns the root adapter factory that contains this factory.
+ *
+ * @return the root adapter factory that contains this factory.
*/
public ComposeableAdapterFactory getRootAdapterFactory() {
- return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
+ ComposeableAdapterFactory ret = this;
+ if (parentAdapterFactory != null) {
+ ret = parentAdapterFactory.getRootAdapterFactory();
+ }
+ return ret;
}
/**
- * This sets the composed adapter factory that contains this factory.
+ * This sets the direct parent adapter factory into which this factory is composed.
+ *
+ * @param parentAdapterFactory
+ * the direct parent adapter factory into which this factory is composed
*/
public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
this.parentAdapterFactory = parentAdapterFactory;
@@ -98,7 +134,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createComparisonAdapter() {
- return new ComparisonNode(this);
+ return new ComparisonNode(getRootAdapterFactory());
}
/**
@@ -108,7 +144,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createMatchResourceAdapter() {
- return new MatchResourceNode(this);
+ return new MatchResourceNode(getRootAdapterFactory());
}
/**
@@ -118,7 +154,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createMatchAdapter() {
- return new MatchNode(this);
+ return new MatchNode(getRootAdapterFactory());
}
/**
@@ -128,7 +164,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createDiffAdapter() {
- return new DiffNode(this);
+ return new DiffNode(getRootAdapterFactory());
}
/**
@@ -138,7 +174,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createResourceAttachmentChangeAdapter() {
- return new ResourceAttachmentChangeNode(this);
+ return new ResourceAttachmentChangeNode(getRootAdapterFactory());
}
/**
@@ -148,7 +184,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createReferenceChangeAdapter() {
- return new ReferenceChangeNode(this);
+ return new ReferenceChangeNode(getRootAdapterFactory());
}
/**
@@ -158,7 +194,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createAttributeChangeAdapter() {
- return new AttributeChangeNode(this);
+ return new AttributeChangeNode(getRootAdapterFactory());
}
/**
@@ -168,7 +204,7 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createConflictAdapter() {
- return new ConflictNode(this);
+ return new ConflictNode(getRootAdapterFactory());
}
/**
@@ -178,11 +214,14 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
*/
@Override
public Adapter createEquivalenceAdapter() {
- return new EquivalenceNode(this);
+ return new EquivalenceNode(getRootAdapterFactory());
}
/**
* This adds a listener.
+ *
+ * @param notifyChangedListener
+ * the listener to add.
*/
public void addListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.addListener(notifyChangedListener);
@@ -190,6 +229,9 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
/**
* This removes a listener.
+ *
+ * @param notifyChangedListener
+ * the listener to remove.
*/
public void removeListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.removeListener(notifyChangedListener);
@@ -197,6 +239,9 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
/**
* This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
+ *
+ * @param notification
+ * the notification to fire.
*/
public void fireNotifyChanged(Notification notification) {
changeNotifier.fireNotifyChanged(notification);
@@ -206,6 +251,11 @@ public class CompareNodeAdapterFactory extends CompareAdapterFactory implements
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.provider.IDisposable#dispose()
+ */
public void dispose() {
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ComparisonNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ComparisonNode.java
index d2f4e0bce..17d94879f 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ComparisonNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ComparisonNode.java
@@ -15,12 +15,17 @@ import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.AbstractEDiffNode;
/**
+ * Specific AbstractEDiffNode for {@link Comparison} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class ComparisonNode extends AbstractEDiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public ComparisonNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ConflictNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ConflictNode.java
index 70657fcc5..2c638cab0 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ConflictNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ConflictNode.java
@@ -16,12 +16,17 @@ import org.eclipse.emf.compare.Conflict;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.AbstractEDiffNode;
/**
+ * Specific AbstractEDiffNode for {@link Conflict} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class ConflictNode extends AbstractEDiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public ConflictNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/EquivalenceNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/EquivalenceNode.java
index 376501641..a0f284abe 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/EquivalenceNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/EquivalenceNode.java
@@ -15,12 +15,17 @@ import org.eclipse.emf.compare.Equivalence;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.AbstractEDiffNode;
/**
+ * Specific AbstractEDiffNode for {@link Equivalence} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class EquivalenceNode extends AbstractEDiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public EquivalenceNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchNode.java
index b9d39e7ee..14dd7e76b 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchNode.java
@@ -19,12 +19,17 @@ import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.AbstractEDif
import org.eclipse.emf.ecore.EObject;
/**
+ * Specific AbstractEDiffNode for {@link Match} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class MatchNode extends AbstractEDiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public MatchNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchResourceNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchResourceNode.java
index bb8e8b376..6f99dc91d 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchResourceNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/MatchResourceNode.java
@@ -15,12 +15,17 @@ import org.eclipse.emf.compare.MatchResource;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.AbstractEDiffNode;
/**
+ * Specific AbstractEDiffNode for {@link MatchResource} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class MatchResourceNode extends AbstractEDiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public MatchResourceNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ReferenceChangeNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ReferenceChangeNode.java
index 111ed7017..1e67137d2 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ReferenceChangeNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ReferenceChangeNode.java
@@ -14,12 +14,17 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.ReferenceChange;
/**
+ * Specific AbstractEDiffNode for {@link ReferenceChange} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class ReferenceChangeNode extends DiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public ReferenceChangeNode(AdapterFactory adapterFactory) {
super(adapterFactory);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ResourceAttachmentChangeNode.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ResourceAttachmentChangeNode.java
index 82babdf7f..b7fab9e89 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ResourceAttachmentChangeNode.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/provider/ResourceAttachmentChangeNode.java
@@ -14,12 +14,17 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.ResourceAttachmentChange;
/**
+ * Specific AbstractEDiffNode for {@link ResourceAttachmentChange} objects.
+ *
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class ResourceAttachmentChangeNode extends DiffNode {
/**
+ * Creates a node with the given factory.
+ *
* @param adapterFactory
+ * the factory given to the super constructor.
*/
public ResourceAttachmentChangeNode(AdapterFactory adapterFactory) {
super(adapterFactory);

Back to the top