diff options
| author | Mélanie Bats | 2016-11-02 16:22:42 +0000 |
|---|---|---|
| committer | Mélanie Bats | 2016-11-02 16:22:42 +0000 |
| commit | 0dcc9b430de1602d054611634947cd0b981fafc5 (patch) | |
| tree | 9d451a5423d06c3347640bd68831886e258520a2 | |
| parent | c79e6ad9ea6ace9c56ad0f800627979d64899f5b (diff) | |
| download | org.eclipse.eef-0dcc9b430de1602d054611634947cd0b981fafc5.tar.gz org.eclipse.eef-0dcc9b430de1602d054611634947cd0b981fafc5.tar.xz org.eclipse.eef-0dcc9b430de1602d054611634947cd0b981fafc5.zip | |
[501903] The selection variable refers to the hyperlink element
Bug: 501903
Change-Id: I1d72d0762cf1142d3ff38cd745f4b6af3e0a1ad8
Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
3 files changed, 33 insertions, 12 deletions
diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFHyperlinkController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFHyperlinkController.java index 12d55f99d..1c1954de6 100644 --- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFHyperlinkController.java +++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFHyperlinkController.java @@ -34,7 +34,7 @@ public interface IEEFHyperlinkController extends IEEFWidgetController { * @param consumer * The consumer of the new value of the hyperlink */ - void onNewValue(IConsumer<String> consumer); + void onNewValue(IConsumer<Object> consumer); /** * Remove the consumer of the new value of the hyperlink. @@ -49,4 +49,13 @@ public interface IEEFHyperlinkController extends IEEFWidgetController { */ void action(EEFWidgetAction action); + /** + * Compute the display value. + * + * @param value + * Element associated to the hyperlink + * @return The display value + */ + String computeDisplayValue(Object value); + } diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFHyperlinkController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFHyperlinkController.java index 90ebe71e9..1677d1bdf 100644 --- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFHyperlinkController.java +++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFHyperlinkController.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.eef.core.internal.controllers; +import com.google.common.base.Objects; + import java.util.HashMap; import java.util.Map; @@ -47,7 +49,7 @@ public class EEFHyperlinkController extends AbstractEEFWidgetController implemen /** * The consumer of a new value of the text. */ - private IConsumer<String> newValueConsumer; + private IConsumer<Object> newValueConsumer; /** * The constructor. @@ -80,15 +82,27 @@ public class EEFHyperlinkController extends AbstractEEFWidgetController implemen String valueExpression = this.description.getValueExpression(); Object valueExpressionResult = this.newEval().evaluate(valueExpression); + if (valueExpressionResult != null) { + this.newValueConsumer.apply(valueExpressionResult); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.core.api.controllers.IEEFHyperlinkController#computeDisplayValue(java.lang.Object) + */ + @Override + public String computeDisplayValue(Object value) { String displayExpression = this.description.getDisplayExpression(); + String text = null; if (!Util.isBlank(displayExpression)) { Map<String, Object> variables = new HashMap<String, Object>(); variables.putAll(this.variableManager.getVariables()); - variables.put(EEFExpressionUtils.EEFReference.VALUE, valueExpressionResult); - EvalFactory.of(this.interpreter, variables).logIfInvalidType(String.class).call(displayExpression, this.newValueConsumer); - } else if (valueExpressionResult != null) { - this.newValueConsumer.apply(valueExpressionResult.toString()); + variables.put(EEFExpressionUtils.EEFReference.VALUE, value); + text = EvalFactory.of(this.interpreter, variables).logIfInvalidType(String.class).evaluate(displayExpression); } + return Objects.firstNonNull(text, ""); //$NON-NLS-1$ } /** @@ -119,7 +133,7 @@ public class EEFHyperlinkController extends AbstractEEFWidgetController implemen * @see org.eclipse.eef.core.api.controllers.IEEFTextController#onNewValue(org.eclipse.eef.core.api.controllers.IConsumer) */ @Override - public void onNewValue(IConsumer<String> consumer) { + public void onNewValue(IConsumer<Object> consumer) { this.newValueConsumer = consumer; } diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java index 3d0880ebc..be91d8269 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFHyperlinkLifecycleManager.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.eef.ide.ui.internal.widgets; -import com.google.common.base.Objects; - import java.util.ArrayList; import java.util.List; @@ -204,12 +202,12 @@ public class EEFHyperlinkLifecycleManager extends AbstractEEFWidgetLifecycleMana this.hyperlinkListener = new EEFHyperlinkListener(this.hyperlink, this.container, this.controller); hyperlink.addMouseListener(hyperlinkListener); - this.controller.onNewValue(new IConsumer<String>() { + this.controller.onNewValue(new IConsumer<Object>() { @Override - public void apply(String value) { + public void apply(Object value) { if (!hyperlink.isDisposed()) { if (!(hyperlink.getText() != null && hyperlink.getText().equals(value))) { - String text = Objects.firstNonNull(value, ""); //$NON-NLS-1$ + String text = controller.computeDisplayValue(value); hyperlink.setText(text); hyperlink.setData(value); } |
