summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-02-27 05:48:43 (EST)
committer Gerrit Code Review @ Eclipse.org2013-03-07 09:48:00 (EST)
commit6fb047374981258a4e158ff053757f4ea519396d (patch)
tree7a6b27b97751eb7fd91d11d877fad6dca22786b8
parentfb215529eaeebf77158aac0208057fe68da0ce91 (diff)
downloadorg.eclipse.emf.compare-6fb047374981258a4e158ff053757f4ea519396d.zip
org.eclipse.emf.compare-6fb047374981258a4e158ff053757f4ea519396d.tar.gz
org.eclipse.emf.compare-6fb047374981258a4e158ff053757f4ea519396d.tar.bz2
[401873] Display unresolved differences number next to groups names.refs/changes/92/10692/5
When display by groups (By side, By By kind...), display unresolved differences number next to groups names. Bug : 401873 Change-Id: Iedf500dbbed4edc803f1b0890623ae6dbc14ad8d
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java36
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DefaultDifferenceGroup.java29
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DifferenceGroup.java10
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/ThreeWayComparisonGroupProvider.java4
4 files changed, 72 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
index a6d58f4..d8ec3dd 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewerLabelProvider.java
@@ -27,15 +27,30 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
+/**
+ * A specialized {@link AdapterFactoryLabelProvider.FontAndColorProvider} for the structure merge viewer.
+ *
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelProvider.FontAndColorProvider implements IStyledLabelProvider {
/**
+ * Constructor calling super {@link #FontAndColorProvider(AdapterFactory, Viewer)}.
+ *
* @param adapterFactory
+ * The adapter factory.
+ * @param viewer
+ * The viewer.
*/
public EMFCompareStructureMergeViewerLabelProvider(AdapterFactory adapterFactory, Viewer viewer) {
super(adapterFactory, viewer);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#getText(java.lang.Object)
+ */
@Override
public String getText(Object element) {
return getStyledText(element).getString();
@@ -80,6 +95,11 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
return super.getBackground(object);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#getImage(java.lang.Object)
+ */
@Override
public Image getImage(Object element) {
final Image ret;
@@ -99,6 +119,13 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
return ret;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see
+ * org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider.getStyledText(java
+ * .lang.Object)
+ */
public StyledString getStyledText(Object element) {
final StyledString ret;
if (element instanceof Adapter) {
@@ -110,7 +137,8 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
ret = styledText;
}
} else if (element instanceof DifferenceGroup) {
- ret = new StyledString(((DifferenceGroup)element).getName());
+ StyledStringConverter stringConverter = new StyledStringConverter();
+ return stringConverter.toJFaceStyledString(((DifferenceGroup)element).getStyledName());
} else {
ret = new StyledString(super.getText(element));
}
@@ -137,13 +165,13 @@ class EMFCompareStructureMergeViewerLabelProvider extends AdapterFactoryLabelPro
if (object == null) {
return null;
}
-
+ StyledString ret = null;
Object itemStyledLabelProvider = adapterFactory.adapt(object, IItemStyledLabelProvider.class);
if (itemStyledLabelProvider instanceof IItemStyledLabelProvider) {
StyledStringConverter stringConverter = new StyledStringConverter();
- return stringConverter.toJFaceStyledString(((IItemStyledLabelProvider)itemStyledLabelProvider)
+ ret = stringConverter.toJFaceStyledString(((IItemStyledLabelProvider)itemStyledLabelProvider)
.getStyledText(object));
}
- return null;
+ return ret;
}
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DefaultDifferenceGroup.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DefaultDifferenceGroup.java
index 38f302d..0c063d0 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DefaultDifferenceGroup.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DefaultDifferenceGroup.java
@@ -15,6 +15,10 @@ import com.google.common.collect.Iterables;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceState;
+import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
+import org.eclipse.emf.compare.provider.utils.IStyledString;
+import org.eclipse.emf.compare.provider.utils.IStyledString.Style;
import org.eclipse.swt.graphics.Image;
/**
@@ -43,6 +47,15 @@ public class DefaultDifferenceGroup implements DifferenceGroup {
protected final Comparison comparison;
/**
+ * A predicate to know if the given {@link Diff} is in an UNRESOLVED state.
+ */
+ private static final Predicate<Diff> unresolved = new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ return DifferenceState.UNRESOLVED == input.getState();
+ }
+ };
+
+ /**
* Instantiates this group given the comparison and filter that should be used in order to determine its
* list of differences.
* <p>
@@ -129,6 +142,22 @@ public class DefaultDifferenceGroup implements DifferenceGroup {
/**
* {@inheritDoc}
*
+ * @see org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.DifferenceGroup#getStyledName()
+ */
+ public IStyledString.IComposedStyledString getStyledName() {
+ final IStyledString.IComposedStyledString ret = new ComposedStyledString(getName());
+ int unresolvedDiffs = Iterables.size(Iterables.filter(getDifferences(), unresolved));
+ ret.append(" [" + unresolvedDiffs + " unresolved difference", Style.DECORATIONS_STYLER);
+ if (unresolvedDiffs > 1) {
+ ret.append("s", Style.DECORATIONS_STYLER);
+ }
+ ret.append("]", Style.DECORATIONS_STYLER);
+ return ret;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.DifferenceGroup#getImage()
*/
public Image getImage() {
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DifferenceGroup.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DifferenceGroup.java
index e265e7a..2207c93 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DifferenceGroup.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/DifferenceGroup.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.provider.utils.IStyledString;
import org.eclipse.swt.graphics.Image;
/**
@@ -38,13 +39,20 @@ public interface DifferenceGroup {
Comparison getComparison();
/**
- * A human-readable label for this group. This will be displayed in the EMF Compare UI.
+ * A human-readable label for this group.
*
* @return A human-readable label for this group that can be displayed to the user.
*/
String getName();
/**
+ * The styled label for the this group. This will be displayed in the EMF Compare UI.
+ *
+ * @return A human-readable styled label for this group that can be displayed to the user.
+ */
+ IStyledString.IComposedStyledString getStyledName();
+
+ /**
* The icon that is to be used for this group in the compare UI.
*
* @return Icon that is to be used for this group in the compare UI. If {@code null}, a default image will
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/ThreeWayComparisonGroupProvider.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/ThreeWayComparisonGroupProvider.java
index 596cea1..9ebf5dd 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/ThreeWayComparisonGroupProvider.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/structuremergeviewer/groups/ThreeWayComparisonGroupProvider.java
@@ -90,8 +90,8 @@ public class ThreeWayComparisonGroupProvider implements IDifferenceGroupProvider
*
* @see org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroupProvider#setDefaultSelected(boolean)
*/
- public void setDefaultSelected(boolean activeByDefault) {
- this.activeByDefault = activeByDefault;
+ public void setDefaultSelected(boolean active) {
+ this.activeByDefault = active;
}
/**