Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-05-28 16:10:18 +0000
committerChristian W. Damus2014-05-28 16:11:08 +0000
commitc4947dc4356b00a035216d2c348a99085ebe0e1b (patch)
treeb17da7d686b8c3d5ce4227dc3729cbff81d27785
parentf9df2dc4d622a5a20b449aff8a2030a642721dd4 (diff)
downloadorg.eclipse.papyrus-c4947dc4356b00a035216d2c348a99085ebe0e1b.tar.gz
org.eclipse.papyrus-c4947dc4356b00a035216d2c348a99085ebe0e1b.tar.xz
org.eclipse.papyrus-c4947dc4356b00a035216d2c348a99085ebe0e1b.zip
436072: [Widgets] Un-focusing a StringCombo widget dirties the model unnecessarily
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436072 Fix the logic in the CComboObservable of the StringCombo editor widget such that it only fires a change when the user actually changes the text.
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
index c9ffbc6cefc..bdcaee9f811 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,8 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
+ * Christian W. Damus (CEA) - bug 436072
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
@@ -124,27 +126,36 @@ public class StringCombo extends ReferenceCombo {
if(modelProperty instanceof AggregatedObservable && ((AggregatedObservable)modelProperty).hasDifferentValues()) {
combo.setText(UnchangedObject.instance.toString());
} else if(value instanceof String) {
- previousValue = combo.getText();
- combo.setText((String)value);
+ // This is the new baseline value (coming from the model) against which to compare a future edit by the user
+ previousValue = (String)value;
+ combo.setText(previousValue);
}
}
//Enter pressed
public void keyReleased(KeyEvent e) {
if((e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) && e.stateMask == SWT.NONE) {
- doFireChange();
+ maybeFireChange();
e.doit = false; //Stops the propagation of the event
}
}
//Selection change
public void widgetSelected(SelectionEvent e) {
- doFireChange();
+ maybeFireChange();
}
//Focus lost
public void focusLost(FocusEvent e) {
- doFireChange();
+ maybeFireChange();
+ }
+
+ void maybeFireChange() {
+ // Only report a change if there is actually a change, otherwise we get a no-op command that dirties the editor
+ final String currentValue = doGetValue();
+ if((currentValue == null) ? previousValue != null : !currentValue.equals(previousValue)) {
+ doFireChange();
+ }
}
private void doFireChange() {

Back to the top