Mercurial > projects > dwt2
comparison org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/ControlObservableValue.d @ 85:6be48cf9f95c
Work on databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Apr 2009 13:54:50 +0200 |
parents | 0a55d2d5a946 |
children |
comparison
equal
deleted
inserted
replaced
84:fcf926c91ca4 | 85:6be48cf9f95c |
---|---|
10 * Brad Reynolds - bug 164653 | 10 * Brad Reynolds - bug 164653 |
11 * Matt Carter - bug 170668 | 11 * Matt Carter - bug 170668 |
12 * Brad Reynolds - bug 170848 | 12 * Brad Reynolds - bug 170848 |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module org.eclipse.jface.internal.databinding.swt.ControlObservableValue; | 14 module org.eclipse.jface.internal.databinding.swt.ControlObservableValue; |
15 import org.eclipse.jface.internal.databinding.swt.SWTProperties; | |
15 | 16 |
16 import java.lang.all; | 17 import java.lang.all; |
17 | 18 |
18 import java.util.HashMap; | 19 import java.util.HashMap; |
19 import java.util.Map; | 20 import java.util.Map; |
39 private static Map SUPPORTED_ATTRIBUTES; | 40 private static Map SUPPORTED_ATTRIBUTES; |
40 static this() { | 41 static this() { |
41 SUPPORTED_ATTRIBUTES = new HashMap(); | 42 SUPPORTED_ATTRIBUTES = new HashMap(); |
42 SUPPORTED_ATTRIBUTES.put(SWTProperties.ENABLED, Boolean.TYPE); | 43 SUPPORTED_ATTRIBUTES.put(SWTProperties.ENABLED, Boolean.TYPE); |
43 SUPPORTED_ATTRIBUTES.put(SWTProperties.VISIBLE, Boolean.TYPE); | 44 SUPPORTED_ATTRIBUTES.put(SWTProperties.VISIBLE, Boolean.TYPE); |
44 SUPPORTED_ATTRIBUTES.put(SWTProperties.TOOLTIP_TEXT, String.classinfo); | 45 SUPPORTED_ATTRIBUTES.put(SWTProperties.TOOLTIP_TEXT, Class.fromType!(String)); |
45 SUPPORTED_ATTRIBUTES.put(SWTProperties.FOREGROUND, Color.classinfo); | 46 SUPPORTED_ATTRIBUTES.put(SWTProperties.FOREGROUND, Class.fromType!(Color)); |
46 SUPPORTED_ATTRIBUTES.put(SWTProperties.BACKGROUND, Color.classinfo); | 47 SUPPORTED_ATTRIBUTES.put(SWTProperties.BACKGROUND, Class.fromType!(Color)); |
47 SUPPORTED_ATTRIBUTES.put(SWTProperties.FONT, Font.classinfo); | 48 SUPPORTED_ATTRIBUTES.put(SWTProperties.FONT, Class.fromType!(Font)); |
48 } | 49 } |
49 | 50 |
50 /** | 51 /** |
51 * @param control | 52 * @param control |
52 * @param attribute | 53 * @param attribute |
56 this.control = control; | 57 this.control = control; |
57 this.attribute = attribute; | 58 this.attribute = attribute; |
58 if (SUPPORTED_ATTRIBUTES.keySet().contains(attribute)) { | 59 if (SUPPORTED_ATTRIBUTES.keySet().contains(attribute)) { |
59 this.valueType = SUPPORTED_ATTRIBUTES.get(attribute); | 60 this.valueType = SUPPORTED_ATTRIBUTES.get(attribute); |
60 } else { | 61 } else { |
61 throw new IllegalArgumentException(); | 62 throw new IllegalArgumentException(null); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 public void doSetValue(Object value) { | 66 public void doSetValue(Object value) { |
66 Object oldValue = doGetValue(); | 67 Object oldValue = doGetValue(); |
67 if (attribute.equals(SWTProperties.ENABLED)) { | 68 if (attribute.equals(SWTProperties.ENABLED)) { |
68 control.setEnabled((cast(Boolean) value).booleanValue()); | 69 control.setEnabled((cast(Boolean) value).booleanValue()); |
69 } else if (attribute.equals(SWTProperties.VISIBLE)) { | 70 } else if (attribute.equals(SWTProperties.VISIBLE)) { |
70 control.setVisible((cast(Boolean) value).booleanValue()); | 71 control.setVisible((cast(Boolean) value).booleanValue()); |
71 } else if (attribute.equals(SWTProperties.TOOLTIP_TEXT)) { | 72 } else if (attribute.equals(SWTProperties.TOOLTIP_TEXT)) { |
72 control.setToolTipText(cast(String) value); | 73 control.setToolTipText(stringcast(value)); |
73 } else if (attribute.equals(SWTProperties.FOREGROUND)) { | 74 } else if (attribute.equals(SWTProperties.FOREGROUND)) { |
74 control.setForeground(cast(Color) value); | 75 control.setForeground(cast(Color) value); |
75 } else if (attribute.equals(SWTProperties.BACKGROUND)) { | 76 } else if (attribute.equals(SWTProperties.BACKGROUND)) { |
76 control.setBackground(cast(Color) value); | 77 control.setBackground(cast(Color) value); |
77 } else if (attribute.equals(SWTProperties.FONT)) { | 78 } else if (attribute.equals(SWTProperties.FONT)) { |
86 } | 87 } |
87 if (attribute.equals(SWTProperties.VISIBLE)) { | 88 if (attribute.equals(SWTProperties.VISIBLE)) { |
88 return control.getVisible() ? Boolean.TRUE : Boolean.FALSE; | 89 return control.getVisible() ? Boolean.TRUE : Boolean.FALSE; |
89 } | 90 } |
90 if (attribute.equals(SWTProperties.TOOLTIP_TEXT)) { | 91 if (attribute.equals(SWTProperties.TOOLTIP_TEXT)) { |
91 return control.getToolTipText(); | 92 return stringcast(control.getToolTipText()); |
92 } | 93 } |
93 if (attribute.equals(SWTProperties.FOREGROUND)) { | 94 if (attribute.equals(SWTProperties.FOREGROUND)) { |
94 return control.getForeground(); | 95 return control.getForeground(); |
95 } | 96 } |
96 if (attribute.equals(SWTProperties.BACKGROUND)) { | 97 if (attribute.equals(SWTProperties.BACKGROUND)) { |