View Javadoc

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.jface.viewers.ComboViewer;
19  import org.eclipse.swt.widgets.Combo;
20  import org.seasar.framework.beans.PropertyDesc;
21  import org.seasar.framework.util.StringUtil;
22  import org.seasar.uruma.binding.value.ValueBinder;
23  import org.seasar.uruma.component.UIComponent;
24  
25  /**
26   * {@link ComboViewer} のための {@link ValueBinder} です。<br />
27   * 
28   * @author y-komori
29   */
30  public class ComboViewerValueBinder extends AbstractValueBinder<ComboViewer> {
31  
32      /**
33       * {@link ComboViewerValueBinder} を構築します。<br />
34       * 
35       */
36      public ComboViewerValueBinder() {
37          super(ComboViewer.class);
38      }
39  
40      /*
41       * @see org.seasar.uruma.binding.value.binder.AbstractValueBinder#doImportValue(java.lang.Object,
42       *      java.lang.Object, org.seasar.framework.beans.PropertyDesc)
43       */
44      @Override
45      public void doImportValue(final ComboViewer widget, final Object formObj,
46              final PropertyDesc propDesc, final UIComponent uiComp) {
47          Combo combo = widget.getCombo();
48          String text = combo.getText();
49          text = StringUtil.isEmpty(text) ? null : text;
50  
51          logBinding(IMPORT_VALUE, widget, null, formObj, propDesc, text);
52  
53          propDesc.setValue(formObj, text);
54      }
55  }