View Javadoc
1   /*
2    * Copyright (C) 2003-2008 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.form.field;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.exoplatform.ecm.webui.form.DialogFormField;
23  import org.exoplatform.ecm.webui.utils.DialogFormUtil;
24  import org.exoplatform.webui.form.UIFormInputBase;
25  import org.exoplatform.webui.form.UIFormStringInput;
26  
27  /**
28   * Created by The eXo Platform SAS
29   * @author : Hoa.Pham
30   *          hoa.pham@exoplatform.com
31   * Jun 23, 2008
32   */
33  public class UIFormActionField extends DialogFormField {
34  
35    public UIFormActionField(String name, String label, String[] arguments) {
36      super(name, label, arguments);
37    }
38  
39    @SuppressWarnings("unchecked")
40    public <T extends UIFormInputBase> T createUIFormInput() throws Exception {
41      UIFormStringInput uiInput = new UIFormStringInput(name, name, defaultValue) ;
42      //TODO need use full class name for validate type.
43      if(validateType != null) {
44        DialogFormUtil.addValidators(uiInput, validateType);
45      }
46      if(label != null && label.length()!=0) {
47        uiInput.setLabel(label);
48      }
49      uiInput.setReadOnly(!isEditable());
50      return (T)uiInput;
51    }
52  
53    public Map<String, String> getSelectorInfo() {
54      Map<String, String> map = new HashMap<String, String>() ;
55      map.put("selectorClass", selectorClass) ;
56      map.put("returnField", name) ;
57      map.put("selectorIcon", selectorIcon) ;
58      map.put("workspaceField", workspaceField) ;
59      if(selectorParams != null) map.put("selectorParams", selectorParams) ;
60      return map;
61    }
62  
63    public boolean useSelector() { return selectorClass != null; }
64  }