Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Daussy2014-03-10 13:20:24 +0000
committerArthur Daussy2014-03-13 11:51:14 +0000
commit8538ce3ddd29ad2248400e18734649e84e8da7f6 (patch)
tree8a5f192dd7a3142ab7d482d9483dd4a41cd09950 /plugins/org.eclipse.emf.compare.rcp
parent56582547fa8979f9b28442498267b9d1e3d3cd60 (diff)
downloadorg.eclipse.emf.compare-8538ce3ddd29ad2248400e18734649e84e8da7f6.tar.gz
org.eclipse.emf.compare-8538ce3ddd29ad2248400e18734649e84e8da7f6.tar.xz
org.eclipse.emf.compare-8538ce3ddd29ad2248400e18734649e84e8da7f6.zip
[429636] Refactoring of IDifferenceGroupProvider
Replace "defaultSelected" by a rank mechanism. Move description attribute to IDifferenceGroupProvider.Descriptor Bug: 429636 Change-Id: I5daab85c14a9c0bfc4856f84af2ac2b336481ac0 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.rcp')
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/AbstractItemDescriptor.java5
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/ItemUtil.java52
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/preferences/EMFComparePreferences.java21
3 files changed, 76 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/AbstractItemDescriptor.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/AbstractItemDescriptor.java
index 03a226137..013537e65 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/AbstractItemDescriptor.java
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/AbstractItemDescriptor.java
@@ -128,4 +128,9 @@ public abstract class AbstractItemDescriptor<T> implements IItemDescriptor<T> {
};
}
+ @Override
+ public String toString() {
+ return "StaticItemDescriptor [Label=" + getLabel() + ", Description=" + getDescription() + ", rank=" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ + getRank() + ", id=" + getID() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/ItemUtil.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/ItemUtil.java
index 63c7493d8..2497c746d 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/ItemUtil.java
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/extension/impl/ItemUtil.java
@@ -10,9 +10,12 @@
*******************************************************************************/
package org.eclipse.emf.compare.rcp.internal.extension.impl;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+import com.google.common.collect.Sets.SetView;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -121,13 +124,13 @@ public final class ItemUtil {
* @param preferenceKey
* Key for this {@link IItemDescriptor} in preferences
* @param itemPreferences
- * {@link IEclipsePreferences} where are stored {@link IItemDescriptor} values
+ * {@link Preferences} where are stored {@link IItemDescriptor} values
* @param <T>
* Type of {@link IItemDescriptor}
* @return List of {@link IItemDescriptor} or null if nothing in preferences
*/
public static <T> List<IItemDescriptor<T>> getItemsDescriptor(IItemRegistry<T> registry,
- String preferenceKey, IEclipsePreferences itemPreferences) {
+ String preferenceKey, Preferences itemPreferences) {
String diffEngineKey = itemPreferences.get(preferenceKey, null);
List<IItemDescriptor<T>> result = null;
if (diffEngineKey != null) {
@@ -188,4 +191,49 @@ public final class ItemUtil {
return activeFactory;
}
+
+ /**
+ * Return an ordered list of {@link IItemDescriptor}. The order in the list is either define by the rank
+ * in the registry or from preference is the rank has been overloaded. If any descriptor has been added or
+ * removed from last modification in the preference. This method will merge the modification.
+ *
+ * @param orderedDefaultDescriptor
+ * List of ordered default {@link IItemDescriptor}.
+ * @param descriptorRegistry
+ * Registry of descriptor.
+ * @param orderedItemPreferenceKey
+ * Key in preferences where are stored the new order of descriptor
+ * @param preferences
+ * holding user preferences.
+ * @return Ordered list of descriptor.
+ * @param <T>
+ * Descriptor type.
+ */
+ public static <T> List<IItemDescriptor<T>> getOrderedItems(
+ List<IItemDescriptor<T>> orderedDefaultDescriptor, IItemRegistry<T> descriptorRegistry,
+ String orderedItemPreferenceKey, Preferences preferences) {
+ List<IItemDescriptor<T>> itemsDescriptor = ItemUtil.getItemsDescriptor(descriptorRegistry,
+ orderedItemPreferenceKey, preferences);
+
+ if (itemsDescriptor == null) {
+ itemsDescriptor = orderedDefaultDescriptor;
+ } else {
+ HashSet<IItemDescriptor<T>> descriptorFromPrefSet = Sets.newLinkedHashSet(itemsDescriptor);
+ HashSet<IItemDescriptor<T>> defaultDescriptorSet = Sets
+ .newLinkedHashSet(orderedDefaultDescriptor);
+
+ // Remove descriptor
+ SetView<IItemDescriptor<T>> descriptorToRemove = Sets.difference(descriptorFromPrefSet,
+ defaultDescriptorSet);
+ Iterables.removeAll(itemsDescriptor, descriptorToRemove);
+
+ // Add new descriptor
+ SetView<IItemDescriptor<T>> descriptorToAdd = Sets.difference(defaultDescriptorSet,
+ descriptorFromPrefSet);
+ Iterables.addAll(itemsDescriptor, descriptorToAdd);
+
+ }
+ return itemsDescriptor;
+ }
+
}
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/preferences/EMFComparePreferences.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/preferences/EMFComparePreferences.java
index b3a82e1ef..49ad5463d 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/preferences/EMFComparePreferences.java
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/preferences/EMFComparePreferences.java
@@ -35,6 +35,12 @@ public final class EMFComparePreferences {
/** Disabled post processors preference. */
public static final String DISABLED_POST_PROCESSOR = "org.eclipse.emf.compare.preference.postprocessor.disabled"; //$NON-NLS-1$
+ /** Ordered list of groups for two way comparison. */
+ public static final String TWO_WAY_GROUP_RANKING = "org.eclipse.emf.compare.preference.groups.2way"; //$NON-NLS-1$
+
+ /** Ordered list of groups for three way comparison. */
+ public static final String THREE_WAY_GROUP_RANKING = "org.eclipse.emf.compare.preference.groups.3way"; //$NON-NLS-1$
+
/**
* Private constructor. Not to be called.
*/
@@ -42,4 +48,19 @@ public final class EMFComparePreferences {
// Hide default constructor.
}
+ /**
+ * Value of {@link EMFComparePreferences#THREE_WAY_COMPARISON_AUTOMATIC_BEHAVIOR} and
+ * {@link EMFComparePreferences#TWO_WAY_COMPARISON_AUTOMATIC_BEHAVIOR}.
+ *
+ * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
+ */
+ public static enum GroupAutomaticBehavior {
+ /** Never synchronize current selected group with preferences. */
+ NEVER,
+ /** Always synchronize current selected group with preferences. */
+ ALWAYS,
+ /** Ask each time the user if he want to synchronize. */
+ ASK_EACH_TIME
+ }
+
}

Back to the top