Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-09-12 04:47:37 -0400
committerStéphane Bégaudeau2016-09-19 08:19:20 -0400
commit0ebb6c5272c3e7e01818b0783917242fd8824b50 (patch)
treea97aa7690efbe4e5ecff52742b1d2e5fba5e1101
parent986f7c67a844e42245be06dddc8914b1d82c2abb (diff)
downloadorg.eclipse.eef-0ebb6c5272c3e7e01818b0783917242fd8824b50.tar.gz
org.eclipse.eef-0ebb6c5272c3e7e01818b0783917242fd8824b50.tar.xz
org.eclipse.eef-0ebb6c5272c3e7e01818b0783917242fd8824b50.zip
[498748] Trigger the editExpression of a text widget on focus lostv1.6.2v1.6.x
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=498748 Change-Id: Idbdc7fd537b7e6272eb69442ebd0defc1dffb4e2 Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFTextController.java41
-rw-r--r--plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java21
2 files changed, 21 insertions, 41 deletions
diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFTextController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFTextController.java
index ffd968896..12011c4c8 100644
--- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFTextController.java
+++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFTextController.java
@@ -12,10 +12,6 @@ package org.eclipse.eef.core.internal.controllers;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
import org.eclipse.eef.EEFTextDescription;
import org.eclipse.eef.EEFWidgetDescription;
@@ -52,16 +48,6 @@ public class EEFTextController extends AbstractEEFWidgetController implements IE
private IConsumer<Object> newValueConsumer;
/**
- * Executor service used to run the update of the text field.
- */
- private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
-
- /**
- * This future contains the update to be performed.
- */
- private ScheduledFuture<?> currentUpdatedValueFuture;
-
- /**
* The constructor.
*
* @param description
@@ -82,30 +68,19 @@ public class EEFTextController extends AbstractEEFWidgetController implements IE
@Override
public void updateValue(final String text) {
- if (this.currentUpdatedValueFuture != null && !this.currentUpdatedValueFuture.isDone()) {
- this.currentUpdatedValueFuture.cancel(true);
- }
-
- Runnable runnable = new Runnable() {
+ this.contextAdapter.performModelChange(new Runnable() {
@Override
public void run() {
- EEFTextController.this.contextAdapter.performModelChange(new Runnable() {
- @Override
- public void run() {
- String editExpression = EEFTextController.this.description.getEditExpression();
- EAttribute eAttribute = EefPackage.Literals.EEF_TEXT_DESCRIPTION__EDIT_EXPRESSION;
+ String editExpression = EEFTextController.this.description.getEditExpression();
+ EAttribute eAttribute = EefPackage.Literals.EEF_TEXT_DESCRIPTION__EDIT_EXPRESSION;
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.putAll(EEFTextController.this.variableManager.getVariables());
- variables.put(EEFExpressionUtils.EEFText.NEW_VALUE, text);
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.putAll(EEFTextController.this.variableManager.getVariables());
+ variables.put(EEFExpressionUtils.EEFText.NEW_VALUE, text);
- EvalFactory.of(EEFTextController.this.interpreter, variables).logIfBlank(eAttribute).call(editExpression);
- }
- });
+ EvalFactory.of(EEFTextController.this.interpreter, variables).logIfBlank(eAttribute).call(editExpression);
}
- };
- final long scheduleTime = 500L;
- this.currentUpdatedValueFuture = this.executor.schedule(runnable, scheduleTime, TimeUnit.MILLISECONDS);
+ });
}
/**
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java
index 8d64fb13d..c52a550a5 100644
--- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java
+++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java
@@ -29,8 +29,8 @@ 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.custom.StyledText;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -67,9 +67,9 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager {
private IEEFTextController controller;
/**
- * The listener on the text.
+ * The listener on the text field.
*/
- private ModifyListener modifyListener;
+ private FocusListener focusListener;
/**
* The widget factory.
@@ -177,16 +177,21 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager {
public void aboutToBeShown() {
super.aboutToBeShown();
- this.modifyListener = new ModifyListener() {
+ this.focusListener = new FocusListener() {
@Override
- public void modifyText(ModifyEvent event) {
+ public void focusLost(FocusEvent e) {
if (!EEFTextLifecycleManager.this.container.isRenderingInProgress()) {
controller.updateValue(text.getText());
EEFTextLifecycleManager.this.setStyle();
}
}
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ // do nothing
+ }
};
- this.text.addModifyListener(this.modifyListener);
+ this.text.addFocusListener(this.focusListener);
this.controller.onNewValue(new IConsumer<Object>() {
@Override
@@ -239,7 +244,7 @@ public class EEFTextLifecycleManager extends AbstractEEFWidgetLifecycleManager {
super.aboutToBeHidden();
if (!text.isDisposed()) {
- this.text.removeModifyListener(this.modifyListener);
+ this.text.removeFocusListener(this.focusListener);
}
this.controller.removeNewValueConsumer();
}

Back to the top