Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-10-12 05:44:31 -0400
committerStephane Begaudeau2016-10-13 08:24:12 -0400
commit31c139c4e0933943f16ae5fb0b9d0dab5f125397 (patch)
tree257c871e417aecde39ff70e5dcfc1daadb317146
parent884e4c55a8d9d4b65b302e9aea8985d870147139 (diff)
downloadorg.eclipse.eef-31c139c4e0933943f16ae5fb0b9d0dab5f125397.tar.gz
org.eclipse.eef-31c139c4e0933943f16ae5fb0b9d0dab5f125397.tar.xz
org.eclipse.eef-31c139c4e0933943f16ae5fb0b9d0dab5f125397.zip
Revert "[496011] Defer the evaluation of select candidates"v1.7.1_RC1v1.7.1
This reverts commit efa5ed85bf4a038c35f769f579290cb1bc5094f3. Change-Id: Id9c7ced9f557dc8b5774bbf69cc8612642c5b730 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFSelectController.java5
-rw-r--r--plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFSelectController.java24
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java38
-rw-r--r--tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/AbstractEEFControllerTests.java18
-rw-r--r--tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/EEFSelectControllerTests.java3
5 files changed, 5 insertions, 83 deletions
diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFSelectController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFSelectController.java
index a96ed8000..010af3275 100644
--- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFSelectController.java
+++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFSelectController.java
@@ -57,9 +57,4 @@ public interface IEEFSelectController extends IEEFWidgetController {
*/
void removeNewCandidatesConsumer();
- /**
- * Compute the candidates.
- */
- void computeCandidates();
-
}
diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFSelectController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFSelectController.java
index f3f7fbe39..143ffd19e 100644
--- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFSelectController.java
+++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFSelectController.java
@@ -100,27 +100,6 @@ public class EEFSelectController extends AbstractEEFWidgetController implements
public void refresh() {
super.refresh();
- // Evaluate the value expression
- String valueExpression = this.description.getValueExpression();
- Object value = this.newEval().evaluate(valueExpression);
-
- // By default only the selected value is available in the candidates list
- // The items list must contain at least one element else the widget is not enabled
- List<Object> candidates = new ArrayList<Object>();
- candidates.add(value);
- EEFSelectController.this.newCandidatesConsumer.apply(candidates);
-
- // Set the value
- EEFSelectController.this.newValueConsumer.apply(value);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.eef.core.api.controllers.IEEFSelectController#computeCandidates()
- */
- @Override
- public void computeCandidates() {
String candidatesExpression = this.description.getCandidatesExpression();
EAttribute candidatesExpressionEAttribute = EefPackage.Literals.EEF_SELECT_DESCRIPTION__CANDIDATES_EXPRESSION;
@@ -136,6 +115,9 @@ public class EEFSelectController extends AbstractEEFWidgetController implements
}
}
});
+
+ String valueExpression = this.description.getValueExpression();
+ this.newEval().call(valueExpression, this.newValueConsumer);
}
/**
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java
index 1d33f34d5..b23f1cdb0 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFSelectLifecycleManager.java
@@ -40,16 +40,12 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
@@ -95,11 +91,6 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
private SelectionListener selectionListener;
/**
- * The mouse listener on the combo.
- */
- private MouseListener mouseListener;
-
- /**
* The reference value of the selection, as last rendered from the state of the actual model.
*/
private ISelection referenceValue;
@@ -210,27 +201,6 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
};
this.combo.addSelectionListener(this.selectionListener);
- this.mouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- // Nothing to do
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- // Delay the computation of the candidates until the user click on the combo
- controller.computeCandidates();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- // Nothing to do
- }
-
- };
- this.combo.addMouseListener(this.mouseListener);
-
// Set combo value
this.controller.onNewValue(new IConsumer<Object>() {
@Override
@@ -254,8 +224,7 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
// Set combo items
this.controller.onNewCandidates(new IConsumer<List<Object>>() {
@Override
- public void apply(final List<Object> value) {
- ISelection selection = comboViewer.getSelection();
+ public void apply(List<Object> value) {
if (!combo.isDisposed()) {
if (value != null) {
Object[] candidates = value.toArray();
@@ -268,16 +237,12 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
} else {
comboViewer.setInput(null);
}
- comboViewer.setSelection(selection, true);
if (!combo.isEnabled()) {
combo.setEnabled(true);
}
}
-
- combo.setCursor(new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW));
}
});
-
}
/**
@@ -291,7 +256,6 @@ public class EEFSelectLifecycleManager extends AbstractEEFWidgetLifecycleManager
if (!combo.isDisposed()) {
this.combo.removeSelectionListener(this.selectionListener);
- this.combo.removeMouseListener(this.mouseListener);
}
this.controller.removeNewValueConsumer();
this.controller.removeNewCandidatesConsumer();
diff --git a/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/AbstractEEFControllerTests.java b/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/AbstractEEFControllerTests.java
index d8b377e45..d1a1ca6b6 100644
--- a/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/AbstractEEFControllerTests.java
+++ b/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/AbstractEEFControllerTests.java
@@ -21,7 +21,6 @@ import org.eclipse.eef.EEFWidgetDescription;
import org.eclipse.eef.EefPackage;
import org.eclipse.eef.core.api.EEFExpressionUtils;
import org.eclipse.eef.core.api.EditingContextAdapter;
-import org.eclipse.eef.core.api.controllers.IEEFSelectController;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.tests.internal.AQLInterpreter;
import org.eclipse.eef.tests.internal.EEFDataTests;
@@ -40,6 +39,7 @@ import org.junit.Before;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
+
import static org.junit.Assert.assertTrue;
@@ -126,14 +126,6 @@ public abstract class AbstractEEFControllerTests {
assertThat(label, is(expectedLabel));
atomicBoolean.set(true);
});
- if (controller instanceof IEEFSelectController) {
- ((IEEFSelectController) controller).onNewCandidates(candidates -> {
- // do nothing
- });
- ((IEEFSelectController) controller).onNewValue(value -> {
- // do nothing
- });
- }
controller.refresh();
assertTrue(atomicBoolean.get());
}
@@ -145,14 +137,6 @@ public abstract class AbstractEEFControllerTests {
atomicBoolean.set(true);
});
controller.computeHelp();
- if (controller instanceof IEEFSelectController) {
- ((IEEFSelectController) controller).onNewCandidates(candidates -> {
- // do nothing
- });
- ((IEEFSelectController) controller).onNewValue(value -> {
- // do nothing
- });
- }
controller.refresh();
assertTrue(atomicBoolean.get());
}
diff --git a/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/EEFSelectControllerTests.java b/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/EEFSelectControllerTests.java
index c51151977..78e0a22bf 100644
--- a/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/EEFSelectControllerTests.java
+++ b/tests/org.eclipse.eef.tests/src/org/eclipse/eef/tests/internal/controllers/EEFSelectControllerTests.java
@@ -56,9 +56,6 @@ public class EEFSelectControllerTests extends AbstractEEFControllerTests {
public void testValue() {
AtomicBoolean atomicBoolean = new AtomicBoolean(false);
IEEFSelectController controller = this.selectController(EEFDataTests.EEFSELECTCONTROLLERTESTS_VALUE);
- controller.onNewCandidates(candidates -> {
- // do nothing
- });
controller.onNewValue(value -> {
assertThat(value, is("public")); //$NON-NLS-1$
atomicBoolean.set(true);

Back to the top