comparison org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/JavaBeanObservableValue.d @ 98:48d4ee626868

rm databinding.observable seems to be duplicate, databinding.beans now building
author Frank Benoit <benoit@tionex.de>
date Wed, 22 Apr 2009 07:30:21 +0200
parents c86eb8b3098e
children
comparison
equal deleted inserted replaced
97:c86eb8b3098e 98:48d4ee626868
73 if (!attachListeners) { 73 if (!attachListeners) {
74 return; 74 return;
75 } 75 }
76 76
77 PropertyChangeListener listener = new class() PropertyChangeListener { 77 PropertyChangeListener listener = new class() PropertyChangeListener {
78 public void propertyChange(java.beans.PropertyChangeEvent event) { 78 public void propertyChange(java.beans.PropertyChangeEvent.PropertyChangeEvent event) {
79 if (!updating) { 79 if (!updating) {
80 final ValueDiff diff = Diffs.createValueDiff(event.getOldValue(), 80 final ValueDiff diff = Diffs.createValueDiff(event.getOldValue(),
81 event.getNewValue()); 81 event.getNewValue());
82 getRealm().exec(new class() Runnable { 82 getRealm().exec(new class() Runnable {
83 public void run() { 83 public void run() {
105 105
106 Method writeMethod = propertyDescriptor.getWriteMethod(); 106 Method writeMethod = propertyDescriptor.getWriteMethod();
107 if (!writeMethod.isAccessible()) { 107 if (!writeMethod.isAccessible()) {
108 writeMethod.setAccessible(true); 108 writeMethod.setAccessible(true);
109 } 109 }
110 writeMethod.invoke(object, new Object[] { value }); 110 writeMethod.invoke(object, [ value ]);
111 fireValueChange(Diffs.createValueDiff(oldValue, doGetValue())); 111 fireValueChange(Diffs.createValueDiff(oldValue, doGetValue()));
112 } catch (InvocationTargetException e) { 112 } catch (InvocationTargetException e) {
113 /* 113 /*
114 * InvocationTargetException wraps any exception thrown by the 114 * InvocationTargetException wraps any exception thrown by the
115 * invoked method. 115 * invoked method.
116 */ 116 */
117 throw new RuntimeException(e.getCause()); 117 throw new RuntimeException(e.getCause());
118 } catch (Exception e) { 118 } catch (Exception e) {
119 if cast(BeansObservables.DEBUG) { 119 if (BeansObservables.DEBUG) {
120 Policy 120 Policy
121 .getLog() 121 .getLog()
122 .log( 122 .log(
123 new Status( 123 new Status(
124 IStatus.WARNING, 124 IStatus.WARNING,
125 Policy.JFACE_DATABINDING, 125 Policy.JFACE_DATABINDING,
126 IStatus.OK, 126 IStatus.OK,
127 "Could not change value of " + object + "." + propertyDescriptor.getName(), e)); //$NON-NLS-1$ //$NON-NLS-2$ 127 Format("Could not change value of {}.{}", object, propertyDescriptor.getName()), e)); //$NON-NLS-1$ //$NON-NLS-2$
128 } 128 }
129 } finally { 129 } finally {
130 updating = false; 130 updating = false;
131 } 131 }
132 } 132 }
134 public Object doGetValue() { 134 public Object doGetValue() {
135 try { 135 try {
136 Method readMethod = propertyDescriptor.getReadMethod(); 136 Method readMethod = propertyDescriptor.getReadMethod();
137 if (readMethod is null) { 137 if (readMethod is null) {
138 throw new BindingException(propertyDescriptor.getName() 138 throw new BindingException(propertyDescriptor.getName()
139 + " property does not have a read method."); //$NON-NLS-1$ 139 ~ " property does not have a read method."); //$NON-NLS-1$
140 } 140 }
141 if (!readMethod.isAccessible()) { 141 if (!readMethod.isAccessible()) {
142 readMethod.setAccessible(true); 142 readMethod.setAccessible(true);
143 } 143 }
144 return readMethod.invoke(object, null); 144 return readMethod.invoke(object, null);
147 * InvocationTargetException wraps any exception thrown by the 147 * InvocationTargetException wraps any exception thrown by the
148 * invoked method. 148 * invoked method.
149 */ 149 */
150 throw new RuntimeException(e.getCause()); 150 throw new RuntimeException(e.getCause());
151 } catch (Exception e) { 151 } catch (Exception e) {
152 if cast(BeansObservables.DEBUG) { 152 if (BeansObservables.DEBUG) {
153 Policy 153 Policy
154 .getLog() 154 .getLog()
155 .log( 155 .log(
156 new Status( 156 new Status(
157 IStatus.WARNING, 157 IStatus.WARNING,
158 Policy.JFACE_DATABINDING, 158 Policy.JFACE_DATABINDING,
159 IStatus.OK, 159 IStatus.OK,
160 "Could not read value of " + object + "." + propertyDescriptor.getName(), e)); //$NON-NLS-1$ //$NON-NLS-2$ 160 Format("Could not read value of {}.{}", object, propertyDescriptor.getName()), e)); //$NON-NLS-1$ //$NON-NLS-2$
161 } 161 }
162 return null; 162 return null;
163 } 163 }
164 } 164 }
165 165