summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-04-07 11:18:46 (EDT)
committerCarsten Drossel2009-04-07 11:18:46 (EDT)
commit80507d8ef4de1845b51938edc604724c318a5b3e (patch)
tree8ce5baa268ac2f439a7c13938ee31cba843d19f0
parentda47faa3bb078ba2db4c7daffe0be000387a0185 (diff)
downloadorg.eclipse.riena-80507d8ef4de1845b51938edc604724c318a5b3e.zip
org.eclipse.riena-80507d8ef4de1845b51938edc604724c318a5b3e.tar.gz
org.eclipse.riena-80507d8ef4de1845b51938edc604724c318a5b3e.tar.bz2
bug 269349 - problems with MarkerSupport in shared views
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidgetSharedViewTest.java108
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MarkerSupport.java37
2 files changed, 127 insertions, 18 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidgetSharedViewTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidgetSharedViewTest.java
new file mode 100644
index 0000000..58f1962
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TextRidgetSharedViewTest.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.internal.ui.ridgets.swt;
+
+import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.riena.core.util.ReflectionUtils;
+import org.eclipse.riena.tests.RienaTestCase;
+import org.eclipse.riena.tests.collect.UITestCase;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+
+/**
+ * Test for the MarkerSupport in a shared view.
+ */
+@UITestCase
+public class TextRidgetSharedViewTest extends RienaTestCase {
+
+ private Shell shell;
+ private Text widget;
+ private ITextRidget textRidget1;
+ private ITextRidget textRidget2;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Display display = Display.getDefault();
+
+ Realm realm = SWTObservables.getRealm(display);
+ assertNotNull(realm);
+ ReflectionUtils.invokeHidden(realm, "setDefault", realm);
+
+ shell = new Shell(SWT.SYSTEM_MODAL | SWT.ON_TOP);
+ shell.setLayout(new RowLayout(SWT.VERTICAL));
+
+ widget = new Text(shell, SWT.NONE);
+
+ textRidget1 = new TextRidget();
+ textRidget1.setUIControl(widget);
+
+ textRidget2 = new TextRidget();
+
+ shell.setSize(130, 100);
+ shell.setLocation(0, 0);
+ shell.open();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ textRidget1 = null;
+ textRidget2 = null;
+ widget = null;
+ shell.dispose();
+ shell = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Test for bug 269349.
+ */
+ public void testMandatoryMarkersInSharedViews() throws Exception {
+
+ Color normalBackground = widget.getBackground();
+
+ textRidget1.setMandatory(true);
+ textRidget2.setMandatory(true);
+
+ Color mandatoryBackground = widget.getBackground();
+ assertFalse(normalBackground.equals(mandatoryBackground));
+
+ assertEquals(mandatoryBackground, widget.getBackground());
+
+ textRidget1.setUIControl(null);
+ textRidget2.setUIControl(widget);
+
+ assertEquals(mandatoryBackground, widget.getBackground());
+
+ textRidget2.setText("Text");
+
+ assertEquals(normalBackground, widget.getBackground());
+
+ textRidget2.setUIControl(null);
+ textRidget1.setUIControl(widget);
+
+ assertEquals(mandatoryBackground, widget.getBackground());
+
+ textRidget1.setText("Text");
+
+ assertEquals(normalBackground, widget.getBackground());
+ }
+
+}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MarkerSupport.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MarkerSupport.java
index 2a5198b..6c31191 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MarkerSupport.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/MarkerSupport.java
@@ -35,6 +35,10 @@ import org.eclipse.riena.ui.ridgets.swt.AbstractActionRidget;
*/
public class MarkerSupport extends AbstractMarkerSupport {
+ private static final String PRE_MANDATORY_BACKGROUND_KEY = "org.eclipse.riena.MarkerSupport.preMandatoryBackground"; //$NON-NLS-1$
+ private static final String PRE_OUTPUT_BACKGROUND_KEY = "org.eclipse.riena.MarkerSupport.preoutputBackground"; //$NON-NLS-1$
+ private static final String PRE_NEGATIVE_FOREGROUND_KEY = "org.eclipse.riena.MarkerSupport.preNegativeForeground"; //$NON-NLS-1$
+
static {
// avoid inlining HIDE_DISABLED_RIDGET_CONTENT
String value = System.getProperty("HIDE_DISABLED_RIDGET_CONTENT"); //$NON-NLS-1$
@@ -51,9 +55,6 @@ public class MarkerSupport extends AbstractMarkerSupport {
*/
public static final boolean HIDE_DISABLED_RIDGET_CONTENT;
- private Color preOutputBg;
- private Color preMandatoryBg;
- private Color preNegativeFg;
private ControlDecoration errorDecoration;
public MarkerSupport(IMarkableRidget ridget, PropertyChangeSupport propertyChangeSupport) {
@@ -96,23 +97,23 @@ public class MarkerSupport extends AbstractMarkerSupport {
// ////////////////
private void addMandatory(Control control) {
- if (preMandatoryBg == null) {
- preMandatoryBg = control.getBackground();
+ if (control.getData(PRE_MANDATORY_BACKGROUND_KEY) == null) {
+ control.setData(PRE_MANDATORY_BACKGROUND_KEY, control.getBackground());
Color color = Activator.getSharedColor(control.getDisplay(), SharedColors.COLOR_MANDATORY);
control.setBackground(color);
}
}
private void addNegative(Control control) {
- if (preNegativeFg == null) {
- preNegativeFg = control.getForeground();
+ if (control.getData(PRE_NEGATIVE_FOREGROUND_KEY) == null) {
+ control.setData(PRE_NEGATIVE_FOREGROUND_KEY, control.getForeground());
control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_RED));
}
}
private void addOutput(Control control, Color color) {
- if (preOutputBg == null) {
- preOutputBg = control.getBackground();
+ if (control.getData(PRE_OUTPUT_BACKGROUND_KEY) == null) {
+ control.setData(PRE_OUTPUT_BACKGROUND_KEY, control.getBackground());
control.setBackground(color);
}
if (isButton(control)) {
@@ -121,23 +122,23 @@ public class MarkerSupport extends AbstractMarkerSupport {
}
private void clearMandatory(Control control) {
- if (preMandatoryBg != null) {
- control.setBackground(preMandatoryBg);
- preMandatoryBg = null;
+ if (control.getData(PRE_MANDATORY_BACKGROUND_KEY) != null) {
+ control.setBackground((Color) control.getData(PRE_MANDATORY_BACKGROUND_KEY));
+ control.setData(PRE_MANDATORY_BACKGROUND_KEY, null);
}
}
private void clearNegative(Control control) {
- if (preNegativeFg != null) {
- control.setForeground(preNegativeFg);
- preNegativeFg = null;
+ if (control.getData(PRE_NEGATIVE_FOREGROUND_KEY) != null) {
+ control.setForeground((Color) control.getData(PRE_NEGATIVE_FOREGROUND_KEY));
+ control.setData(PRE_NEGATIVE_FOREGROUND_KEY, null);
}
}
private void clearOutput(Control control) {
- if (preOutputBg != null) {
- control.setBackground(preOutputBg);
- preOutputBg = null;
+ if (control.getData(PRE_OUTPUT_BACKGROUND_KEY) != null) {
+ control.setBackground((Color) control.getData(PRE_OUTPUT_BACKGROUND_KEY));
+ control.setData(PRE_OUTPUT_BACKGROUND_KEY, null);
}
if (isButton(control)) {
control.setVisible(ridget.isVisible());