Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Constant2018-08-13 08:08:35 -0400
committerOlivier Constant2018-08-28 07:53:42 -0400
commitf236216d3784a69ca61b4c8ba20449552b337417 (patch)
tree1bdb2af5fc0aafa03c51eb321f2194ae165e1ea1
parent9e0e0abd702d2d0d9c9f67fd00b3429ae25162d7 (diff)
downloadorg.eclipse.emf.diffmerge.core-f236216d3784a69ca61b4c8ba20449552b337417.tar.gz
org.eclipse.emf.diffmerge.core-f236216d3784a69ca61b4c8ba20449552b337417.tar.xz
org.eclipse.emf.diffmerge.core-f236216d3784a69ca61b4c8ba20449552b337417.zip
Bug 536586 - Make technical representation applicable to header
Work started, requires completion of work on viewer properties Change-Id: I60fb3b3fdb8efd8883fba61fd9137f191fa7ea41 Signed-off-by: Olivier Constant <olivier.constant@thalesgroup.com>
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/messages.properties4
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/util/DiffDelegatingLabelProvider.java183
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java2
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EMFDiffNode.java71
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EnhancedFeaturesViewer.java19
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/FeaturesViewer.java26
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ValuesViewer.java46
7 files changed, 248 insertions, 103 deletions
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/messages.properties b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/messages.properties
index fed9b2d6..94b6f9e5 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/messages.properties
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/messages.properties
@@ -222,6 +222,6 @@ UnmatchedElementCategory_DescriptionLeft=Elements that are only present in the l
UnmatchedElementCategory_DescriptionRight=Elements that are only present in the right-hand side.
UnmatchedElementCategory_TextLeft=Additional elements on the left
UnmatchedElementCategory_TextRight=Additional elements on the right
-ValuesViewer_ContainerLabel= %1$s (in %2$s)
-ValuesViewer_FeatureLabel= %1$s (via %2$s)
+ValuesViewer_ContainerLabel=(in %s)
+ValuesViewer_FeatureLabel=(via %s)
ValuesViewer_OrderLabel=<Order>
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/util/DiffDelegatingLabelProvider.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/util/DiffDelegatingLabelProvider.java
index 7eb44c76..ee3810e8 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/util/DiffDelegatingLabelProvider.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/util/DiffDelegatingLabelProvider.java
@@ -267,44 +267,6 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
}
/**
- * Decorate the given label of the given value presence so that it conveniently
- * describes the value
- * @param valueLabel_p a potentially null string
- * @param valuePresence_p a non-null value presence
- * @return a potentially null string
- */
- protected String getDecoratedTextFromHolder(String valueLabel_p, IValuePresence valuePresence_p) {
- String result = valueLabel_p;
- if (valuePresence_p instanceof IReferenceValuePresence) {
- EObject value = ((IReferenceValuePresence)valuePresence_p).getValue();
- EObject container = value.eContainer();
- String containerLabel = container == null? null:
- getDelegate().getText(container);
- if (containerLabel != null) {
- result = String.format(Messages.ValuesViewer_ContainerLabel, result, containerLabel);
- }
- }
- return result;
- }
-
- /**
- * Decorate the given label of the given value presence so that it conveniently
- * describes the holder
- * @param holderLabel_p a potentially null string
- * @param valuePresence_p a non-null value presence
- * @return a potentially null string
- */
- protected String getDecoratedTextFromValue(String holderLabel_p, IValuePresence valuePresence_p) {
- String result = holderLabel_p;
- EStructuralFeature feature = valuePresence_p.getFeature();
- if (feature != null) {
- String featureText = getText(feature);
- String.format(Messages.ValuesViewer_FeatureLabel, holderLabel_p, featureText);
- }
- return result;
- }
-
- /**
* Return the default diff label decorator for this label provider
* @return a non-null object
*/
@@ -418,17 +380,9 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
*/
@Override
public Image getImage(Object element_p) {
- Image base;
- if (isOwnershipFeature(getElementToRepresent(element_p))) {
- base = getOwnershipFeatureImage();
- } else if (isOrderDifference(element_p)) {
- base = getOrderDifferenceImage();
- } else {
- base = getUndecoratedImage(element_p);
- }
Image result = getDiffLabelDecorator().getImage(
element_p,
- base,
+ getUndecoratedImage(element_p),
getDifferenceKind(element_p),
getSide(),
getDiffNode());
@@ -534,20 +488,9 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
*/
@Override
public String getText(Object element_p) {
- String base;
- if (isOrderDifference(element_p)) {
- base = Messages.ValuesViewer_OrderLabel;
- } else if (element_p instanceof IValuePresence) {
- IValuePresence valuePresence = (IValuePresence)element_p;
- base = getUndecoratedText(element_p);
- base = isFromValue(valuePresence)? getDecoratedTextFromValue(base, valuePresence):
- getDecoratedTextFromHolder(base, valuePresence);
- } else {
- base = getUndecoratedText(element_p);
- }
CharSequence label = getDiffLabelDecorator().getText(
element_p,
- base,
+ getUndecoratedText(element_p),
getDifferenceKind(element_p),
getSide(),
getDiffNode());
@@ -565,11 +508,9 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
*/
@Override
public String getToolTipText(Object element_p) {
- Object elementToRepresent = getElementToRepresent(element_p);
- String base = super.getToolTipText(elementToRepresent);
String result = getDiffLabelDecorator().getToolTipText(
element_p,
- base,
+ getUndecoratedToolTipText(element_p),
getDifferenceKind(element_p),
getSide(),
getDiffNode());
@@ -613,10 +554,18 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
* @see org.eclipse.emf.common.ui.viewer.IUndecoratingLabelProvider#getUndecoratedImage(java.lang.Object)
*/
public Image getUndecoratedImage(Object element_p) {
- Object elementToRepresent = getElementToRepresent(element_p);
- return elementToRepresent == element_p?
- super.getImage(elementToRepresent):
- getUndecoratedImage(elementToRepresent);
+ Image result;
+ if (isOwnershipFeature(element_p)) {
+ result = getOwnershipFeatureImage();
+ } else if (isOrderDifference(element_p)) {
+ result = getOrderDifferenceImage();
+ } else {
+ Object elementToRepresent = getElementToRepresent(element_p);
+ result = (elementToRepresent == element_p)?
+ super.getImage(elementToRepresent):
+ getUndecoratedImage(elementToRepresent);
+ }
+ return result;
}
/**
@@ -624,22 +573,97 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
* @see DiffDelegatingLabelProvider#getStyledText(Object)
*/
public StyledString getUndecoratedStyledText(Object element_p) {
- Object elementToRepresent = getElementToRepresent(element_p);
- return elementToRepresent == element_p?
- super.getStyledText(elementToRepresent):
- getUndecoratedStyledText(elementToRepresent);
+ StyledString result;
+ if (element_p instanceof IValuePresence) {
+ result = getUndecoratedStyledTextFromValuePresence((IValuePresence)element_p);
+ } else {
+ Object elementToRepresent = getElementToRepresent(element_p);
+ result = (elementToRepresent == element_p)?
+ super.getStyledText(elementToRepresent):
+ getUndecoratedStyledText(elementToRepresent);
+ }
+ return result;
+ }
+
+ /**
+ * Return an undecorated styled label for the given value presence representing
+ * the value from the point of view of the holder
+ * @param valueLabel_p a potentially null string
+ * @param valuePresence_p a non-null value presence
+ * @return a potentially null styled string
+ */
+ protected StyledString getUndecoratedStyledTextFromHolder(String valueLabel_p,
+ IValuePresence valuePresence_p) {
+ StyledString result = new StyledString(valueLabel_p);
+ if (valuePresence_p instanceof IReferenceValuePresence) {
+ EObject value = ((IReferenceValuePresence)valuePresence_p).getValue();
+ EObject container = value.eContainer();
+ String containerLabel = (container == null)? null:
+ getUndecoratedText(container);
+ if (containerLabel != null) {
+ containerLabel = String.format(Messages.ValuesViewer_ContainerLabel, containerLabel);
+ result.append(' ');
+ result.append(containerLabel, StyledString.QUALIFIER_STYLER);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return an undecorated styled label for the given value presence representing
+ * the holder from the point of view of the value
+ * @param holderLabel_p a potentially null string
+ * @param valuePresence_p a non-null value presence
+ * @return a potentially null styled string
+ */
+ protected StyledString getUndecoratedStyledTextFromValue(String holderLabel_p,
+ IValuePresence valuePresence_p) {
+ StyledString result = new StyledString(holderLabel_p);
+ EStructuralFeature feature = valuePresence_p.getFeature();
+ if (feature != null) {
+ String featureText = getUndecoratedText(feature);
+ if (featureText != null) {
+ featureText = String.format(Messages.ValuesViewer_FeatureLabel, featureText);
+ result.append(' ');
+ result.append(featureText, StyledString.QUALIFIER_STYLER);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return an undecorated styled label for the given value presence
+ * @param valuePresence_p a non-null object
+ * @return a potentially null styled string
+ */
+ protected StyledString getUndecoratedStyledTextFromValuePresence(
+ IValuePresence valuePresence_p) {
+ StyledString result;
+ String base = getUndecoratedText(valuePresence_p);
+ result = isFromValue(valuePresence_p)?
+ getUndecoratedStyledTextFromValue(base, valuePresence_p):
+ getUndecoratedStyledTextFromHolder(base, valuePresence_p);
+ return result;
}
/**
* @see org.eclipse.emf.common.ui.viewer.IUndecoratingLabelProvider#getUndecoratedText(java.lang.Object)
*/
public String getUndecoratedText(Object element_p) {
- Object elementToRepresent = getElementToRepresent(element_p);
- return elementToRepresent == element_p?
- super.getText(elementToRepresent):
- getUndecoratedText(elementToRepresent);
+ String result;
+ if (isOrderDifference(element_p)) {
+ result = Messages.ValuesViewer_OrderLabel;
+ } else if (element_p instanceof EStructuralFeature && !isTextTechnicalForMeta()) {
+ result = UIUtil.getFormattedFeatureText((EStructuralFeature)element_p);
+ } else {
+ Object elementToRepresent = getElementToRepresent(element_p);
+ result = (elementToRepresent == element_p)?
+ super.getText(elementToRepresent):
+ getUndecoratedText(elementToRepresent);
+ }
+ return result;
}
-
+
/**
* Return the undecorated tool tip text
* @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
@@ -679,6 +703,15 @@ implements IUndecoratingLabelProvider, ITreePathLabelProvider, IDiffLabelDecorat
}
/**
+ * Return whether meta-elements (instances of EClass, EStructuralFeature, etc.)
+ * must have technical vs. user-friendly labels
+ */
+ protected boolean isTextTechnicalForMeta() {
+ // Override if needed
+ return false;
+ }
+
+ /**
* Set the diff label decorator of this label provider
* @param diffDecorator_p a potentially null object, where null stands for default
*/
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
index 881b5b52..0b6fe7e4 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
@@ -1221,7 +1221,7 @@ public class ComparisonViewer extends AbstractComparisonViewer {
*/
@Override
public void widgetSelected(SelectionEvent e_p) {
- _viewerFeatures.getInnerViewer().setTechnical(result.getSelection());
+ _viewerFeatures.getInnerViewer().setTechnical(result.getSelection()); //TODO change this
}
});
return result;
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EMFDiffNode.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EMFDiffNode.java
index 263f43b8..48bbd1ad 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EMFDiffNode.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EMFDiffNode.java
@@ -17,7 +17,9 @@ package org.eclipse.emf.diffmerge.ui.viewers;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.compare.IPropertyChangeNotifier;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.core.commands.operations.IOperationHistory;
@@ -44,6 +46,8 @@ import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.IWorkspaceCommandStack;
import org.eclipse.emf.workspace.ResourceUndoContext;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IEditorInput;
@@ -51,7 +55,11 @@ import org.eclipse.ui.IEditorInput;
* An ICompareInput that wraps a model comparison.
* @author Olivier Constant
*/
-public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomainProvider {
+public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomainProvider,
+IPropertyChangeNotifier {
+
+ /** The name of the "use technical labels" property */
+ public static final String PROPERTY_TECHNICAL_LABELS = "PROPERTY_TECHNICAL_LABELS"; //$NON-NLS-1$
/** The resource manager */
private final ComparisonResourceManager _resourceManager;
@@ -65,6 +73,9 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
/** The optional listener that reacts to changes on the editing domain */
protected IOperationHistoryListener _domainChangeListener;
+ /** The non-null set of property change listeners */
+ private final Set<IPropertyChangeListener> _changeListeners;
+
/** The optional associated editor input */
private IEditorInput _editorInput;
@@ -86,6 +97,10 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
/** Whether to use custom labels for differences */
private boolean _useCustomLabels;
+ /** Whether to use technical (vs. simplified) labels to represent,
+ * in particular, meta elements */
+ private boolean _useTechicalLabels;
+
/** Whether the left model is editable */
private boolean _isTargetEditable;
@@ -186,6 +201,7 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
_categoryManager = new CategoryManager(this);
_useCustomIcons = true;
_useCustomLabels = false;
+ _useTechicalLabels = false;
_isTargetEditionPossible = (leftRole_p == Role.TARGET)? isLeftEditionPossible_p:
isRightEditionPossible_p;
_isReferenceEditionPossible = (leftRole_p == Role.TARGET)? isRightEditionPossible_p:
@@ -203,6 +219,14 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
_defaultCoverChildren = true;
_defaultIncrementalMode = false;
_domainChangeListener = (domain_p == null)? null: createDomainListener(domain_p);
+ _changeListeners = new HashSet<IPropertyChangeListener>(1);
+ }
+
+ /**
+ * @see org.eclipse.compare.IPropertyChangeNotifier#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener_p) {
+ _changeListeners.add(listener_p);
}
/**
@@ -260,6 +284,20 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
_domainChangeListener = null;
}
_editorInput = null;
+ _changeListeners.clear();
+ }
+
+ /**
+ * Notify listeners of a property change event
+ * @param propertyName_p the non-null name of the property
+ * @param newValue_p the potentially null, new value of the property
+ */
+ protected void firePropertyChangeEvent(String propertyName_p, Object newValue_p) {
+ PropertyChangeEvent event = new PropertyChangeEvent(
+ this, propertyName_p, null, newValue_p);
+ for (IPropertyChangeListener listener : _changeListeners) {
+ listener.propertyChange(event);
+ }
}
/**
@@ -527,6 +565,13 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
}
/**
+ * @see org.eclipse.compare.IPropertyChangeNotifier#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener_p) {
+ _changeListeners.remove(listener_p);
+ }
+
+ /**
* Set the default value for the "cover children" property as proposed to the user when merging
*/
public void setDefaultCoverChildren(boolean coverChildren_p) {
@@ -662,20 +707,30 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
}
/**
- * Set whether this viewer should use custom icons to represent differences
+ * Set whether viewers must use custom icons to represent differences
*/
public void setUseCustomIcons(boolean useCustom_p) {
_useCustomIcons = useCustom_p;
}
/**
- * Set whether this viewer should use custom labels to represent differences
+ * Set whether viewers must use custom labels to represent differences
*/
public void setUseCustomLabels(boolean useCustom_p) {
_useCustomLabels = useCustom_p;
}
/**
+ * Set whether viewers must use technical (vs. simplified) labels to represent,
+ * in particular, meta elements
+ * @param useTechicalLabels_p whether techical labels must be used
+ */
+ public void setUseTechicalLabels(boolean useTechicalLabels_p) {
+ _useTechicalLabels = useTechicalLabels_p;
+ firePropertyChangeEvent(PROPERTY_TECHNICAL_LABELS, Boolean.valueOf(useTechicalLabels_p));
+ }
+
+ /**
* Re-compute filtering and differences numbers
*/
public void updateDifferenceNumbers() {
@@ -691,10 +746,18 @@ public class EMFDiffNode extends DiffNode implements IDisposable, IEditingDomain
}
/**
- * Return whether this viewer uses custom labels to represent differences
+ * Return whether viewers must custom labels to represent differences
*/
public boolean usesCustomLabels() {
return _useCustomLabels;
}
+ /**
+ * Return whether viewers must use technical (vs. simplified) labels to represent,
+ * in particular, meta elements
+ */
+ public boolean usesTechicalLabels() {
+ return _useTechicalLabels;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EnhancedFeaturesViewer.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EnhancedFeaturesViewer.java
index 52159d41..c44a8420 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EnhancedFeaturesViewer.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/EnhancedFeaturesViewer.java
@@ -69,6 +69,20 @@ public class EnhancedFeaturesViewer extends HeaderViewer<FeaturesViewer> {
}
/**
+ * Return context-sensitive text for the header
+ * @param input_p a non-null input object
+ * @return a potentially null string
+ */
+ protected String getContextualText(FeaturesInput input_p) {
+ EObject element = getDrivingElement(input_p);
+ String formattedTypeText = input_p.getContext().usesTechicalLabels()?
+ element.eClass().getName(): UIUtil.getFormattedTypeText(element);
+ String result = String.format(
+ Messages.EnhancedFeaturesViewer_DetailsWithSelection, formattedTypeText);
+ return result;
+ }
+
+ /**
* Return the default text for the header
* @return a potentially null string
*/
@@ -108,10 +122,7 @@ public class EnhancedFeaturesViewer extends HeaderViewer<FeaturesViewer> {
String newText;
if (input_p instanceof FeaturesInput) {
FeaturesInput input = (FeaturesInput)input_p;
- EObject element = getDrivingElement(input);
- String formattedTypeText = UIUtil.getFormattedTypeText(element);
- newText = String.format(
- Messages.EnhancedFeaturesViewer_DetailsWithSelection, formattedTypeText);
+ newText = getContextualText(input);
} else {
newText = getDefaultText();
}
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/FeaturesViewer.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/FeaturesViewer.java
index 1e7dced9..b075df0f 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/FeaturesViewer.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/FeaturesViewer.java
@@ -25,7 +25,6 @@ import org.eclipse.emf.diffmerge.ui.EMFDiffMergeUIPlugin;
import org.eclipse.emf.diffmerge.ui.diffuidata.MatchAndFeature;
import org.eclipse.emf.diffmerge.ui.diffuidata.impl.MatchAndFeatureImpl;
import org.eclipse.emf.diffmerge.ui.util.DiffDelegatingLabelProvider;
-import org.eclipse.emf.diffmerge.ui.util.UIUtil;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
@@ -103,9 +102,6 @@ public class FeaturesViewer extends TableViewer implements IDifferenceRelatedVie
/** Whether all features must be shown, including those with no difference */
private boolean _showAllFeatures;
- /** Whether a technical, more precise but less user-friendly representation must be used */
- private boolean _useTechnicalRepresentation;
-
/**
* Constructor
@@ -125,7 +121,6 @@ public class FeaturesViewer extends TableViewer implements IDifferenceRelatedVie
setContentProvider(new ContentProvider());
setLabelProvider(new LabelProvider());
_showAllFeatures = false;
- _useTechnicalRepresentation = false;
getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
setComparator(new ViewerComparator());
}
@@ -175,7 +170,7 @@ public class FeaturesViewer extends TableViewer implements IDifferenceRelatedVie
* Return whether a technical, more precise but less user-friendly representation is being used
*/
public boolean isTechnical() {
- return _useTechnicalRepresentation;
+ return getInput() != null? getInput().getContext().usesTechicalLabels(): false;
}
/**
@@ -193,8 +188,11 @@ public class FeaturesViewer extends TableViewer implements IDifferenceRelatedVie
*/
public void setTechnical(boolean technical_p) {
if (technical_p != isTechnical()) {
- _useTechnicalRepresentation = technical_p;
- refresh(true);
+ FeaturesInput input = getInput();
+ if (input != null) {
+ input.getContext().setUseTechicalLabels(technical_p);
+ refresh(true);
+ }
}
}
@@ -291,17 +289,11 @@ public class FeaturesViewer extends TableViewer implements IDifferenceRelatedVie
return null;
}
/**
- * @see org.eclipse.emf.diffmerge.ui.util.DiffDelegatingLabelProvider#getUndecoratedText(java.lang.Object)
+ * @see org.eclipse.emf.diffmerge.ui.util.DiffDelegatingLabelProvider#isTextTechnicalForMeta()
*/
@Override
- public String getUndecoratedText(Object element_p) {
- String result;
- if (element_p instanceof EStructuralFeature && !isTechnical()) {
- result = UIUtil.getFormattedFeatureText((EStructuralFeature)element_p);
- } else {
- result = super.getUndecoratedText(element_p);
- }
- return result;
+ protected boolean isTextTechnicalForMeta() {
+ return isTechnical();
}
}
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ValuesViewer.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ValuesViewer.java
index f4303490..5d417308 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ValuesViewer.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ValuesViewer.java
@@ -33,6 +33,8 @@ import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -123,6 +125,9 @@ IDifferenceRelatedViewer {
/** Whether all values must be shown, including those not related to a difference */
private boolean _showAllValues;
+ /** A listener to changes on properties of the input */
+ protected final IPropertyChangeListener _inputPropertyChangeListener;
+
/**
* Constructor
@@ -145,10 +150,28 @@ IDifferenceRelatedViewer {
setLabelProvider(new LabelProvider());
_sideIsLeft = sideIsLeft_p;
_showAllValues = false;
+ _inputPropertyChangeListener = createInputPropertyChangeListener();
getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
/**
+ * Create and return a listener to changes on properties of the input
+ * @return a non-null object
+ */
+ protected IPropertyChangeListener createInputPropertyChangeListener() { //TODO do the same on (Enhanced)FeaturesViewer
+ return new IPropertyChangeListener() {
+ /**
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event_p) {
+ if (EMFDiffNode.PROPERTY_TECHNICAL_LABELS.equals(event_p.getProperty())) {
+ refresh(true);
+ }
+ }
+ };
+ }
+
+ /**
* @see org.eclipse.jface.viewers.ContentViewer#getInput()
*/
@Override
@@ -174,6 +197,22 @@ IDifferenceRelatedViewer {
}
/**
+ * @see org.eclipse.jface.viewers.AbstractTableViewer#inputChanged(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected void inputChanged(Object input_p, Object oldInput_p) {
+ if (oldInput_p instanceof ValuesInput) {
+ ((ValuesInput)oldInput_p).getContext().removePropertyChangeListener(
+ _inputPropertyChangeListener);
+ }
+ if (input_p instanceof ValuesInput) {
+ ((ValuesInput)input_p).getContext().addPropertyChangeListener(
+ _inputPropertyChangeListener);
+ }
+ super.inputChanged(input_p, oldInput_p);
+ }
+
+ /**
* @see org.eclipse.emf.diffmerge.ui.viewers.IDifferenceRelatedViewer#isDifferenceAgnostic()
*/
public boolean isDifferenceAgnostic() {
@@ -341,6 +380,13 @@ IDifferenceRelatedViewer {
protected boolean isFromValue(IValuePresence valuePresence_p) {
return isOwnership(getInput());
}
+ /**
+ * @see org.eclipse.emf.diffmerge.ui.util.DiffDelegatingLabelProvider#isTextTechnicalForMeta()
+ */
+ @Override
+ protected boolean isTextTechnicalForMeta() {
+ return getInput() != null? getInput().getContext().usesTechicalLabels(): false;
+ }
}
}

Back to the top