UIFormActionField.java

  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. import java.util.HashMap;
  19. import java.util.Map;

  20. import org.exoplatform.ecm.webui.form.DialogFormField;
  21. import org.exoplatform.ecm.webui.utils.DialogFormUtil;
  22. import org.exoplatform.webui.form.UIFormInputBase;
  23. import org.exoplatform.webui.form.UIFormStringInput;

  24. /**
  25.  * Created by The eXo Platform SAS
  26.  * @author : Hoa.Pham
  27.  *          hoa.pham@exoplatform.com
  28.  * Jun 23, 2008
  29.  */
  30. public class UIFormActionField extends DialogFormField {

  31.   public UIFormActionField(String name, String label, String[] arguments) {
  32.     super(name, label, arguments);
  33.   }

  34.   @SuppressWarnings("unchecked")
  35.   public <T extends UIFormInputBase> T createUIFormInput() throws Exception {
  36.     UIFormStringInput uiInput = new UIFormStringInput(name, name, defaultValue) ;
  37.     //TODO need use full class name for validate type.
  38.     if(validateType != null) {
  39.       DialogFormUtil.addValidators(uiInput, validateType);
  40.     }
  41.     if(label != null && label.length()!=0) {
  42.       uiInput.setLabel(label);
  43.     }
  44.     uiInput.setReadOnly(!isEditable());
  45.     return (T)uiInput;
  46.   }

  47.   public Map<String, String> getSelectorInfo() {
  48.     Map<String, String> map = new HashMap<String, String>() ;
  49.     map.put("selectorClass", selectorClass) ;
  50.     map.put("returnField", name) ;
  51.     map.put("selectorIcon", selectorIcon) ;
  52.     map.put("workspaceField", workspaceField) ;
  53.     if(selectorParams != null) map.put("selectorParams", selectorParams) ;
  54.     return map;
  55.   }

  56.   public boolean useSelector() { return selectorClass != null; }
  57. }