1 /*
2 * Copyright 2004-2008 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.uruma.binding.value.binder;
17
18 import org.eclipse.swt.browser.Browser;
19 import org.seasar.framework.beans.PropertyDesc;
20 import org.seasar.uruma.binding.value.ValueBinder;
21 import org.seasar.uruma.component.UIComponent;
22
23 /**
24 * {@link Browser} のための {@link ValueBinder} です。<br />
25 *
26 * @author y.sugigami
27 */
28 public class BrowserValueBinder extends AbstractValueBinder<Browser> {
29
30 /**
31 * {@link BrowserValueBinder} を構築します。<br />
32 *
33 */
34 public BrowserValueBinder() {
35 super(Browser.class);
36 }
37
38 /*
39 * @see org.seasar.uruma.binding.value.binder.AbstractValueBinder#doImportValue(java.lang.Object,
40 * java.lang.Object, org.seasar.framework.beans.PropertyDesc)
41 */
42 @Override
43 public void doImportValue(final Browser widget, final Object formObj,
44 final PropertyDesc propDesc, final UIComponent uiComp) {
45 Object value = propDesc.getValue(widget);
46
47 // 空文字列の入力は null として扱う
48 if (value instanceof String && ((String) value).length() == 0) {
49 value = null;
50 }
51
52 logBinding(IMPORT_VALUE, widget, propDesc, formObj, propDesc, value);
53
54 propDesc.setValue(formObj, value);
55 }
56
57 /*
58 * @see org.seasar.uruma.binding.value.binder.AbstractValueBinder#doExportValue(java.lang.Object,
59 * java.lang.Object, org.seasar.framework.beans.PropertyDesc)
60 */
61 @Override
62 protected void doExportValue(final Browser widget, final Object formObj,
63 final PropertyDesc propDesc, final UIComponent uiComp) {
64
65 Object value = propDesc.getValue(formObj);
66
67 if (value == null) {
68 value = "";
69 }
70
71 logBinding(EXPORT_VALUE, formObj, propDesc, widget, propDesc, value);
72
73 widget.setText((String) value);
74
75 }
76 }