@Override
    public void setItems(FormItem... items) {
      for (FormItem nextFormItem : items) {
        nextFormItem.setWrapTitle(false);
        nextFormItem.setWidth(300); // wider than default
        if (nextFormItem instanceof TextItem) {
          nextFormItem.addKeyPressHandler(this);
        } else if (nextFormItem instanceof SelectItem) {
          nextFormItem.addChangedHandler(this);
        } else if (nextFormItem instanceof EnhancedSearchBarItem) {
          // searchBarItem = (SearchBarItem) nextFormItem;
          // searchBarItem.getSearchBar().addKeyPressHandler(this);
          String name = searchBarItem.getName();
          searchBarItem.setName(name + "_hidden");
          hiddenItem = new HiddenItem(name);
          // hiddenItem.setValue(searchBarItem.getSearchBar().getValue());
        }
      }

      if (hiddenItem != null) {
        FormItem[] tmpItems = new FormItem[items.length + 1];
        System.arraycopy(items, 0, tmpItems, 0, items.length);
        tmpItems[items.length] = hiddenItem;
        items = tmpItems;
      }

      super.setItems(items);
    }
Exemplo n.º 2
0
 private FieldDefinitionItem createField(FieldDefinition field) {
   FormItem fi = null;
   switch (field.getFieldType()) {
     case FieldDefinition.FT_STRING:
       fi = new TextItem();
       break;
     case FieldDefinition.FT_INTEGER:
       fi = new IntegerItem();
       break;
     case FieldDefinition.FT_DOUBLE:
       fi = new FloatItem();
       break;
     case FieldDefinition.FT_BOOLEAN:
       fi = new CheckboxItem();
       break;
     case FieldDefinition.FT_TEXTAREA:
       fi = new TextAreaItem();
       // fi.setWidth("10000px");
       break;
     case FieldDefinition.FT_STATICTEXT:
       fi = new StaticTextItem();
       break;
     case FieldDefinition.FT_COMBO:
       fi = new ComboBoxItem();
       if (field.isNoUnknownValueComboValue())
         ((ComboBoxItem) fi).setAddUnknownValues(!field.isNoUnknownValueComboValue());
       break;
     case FieldDefinition.FT_SELECTION:
       fi = new SelectItem();
       if (field.isNoUnknownValueComboValue())
         ((SelectItem) fi).setAddUnknownValues(!field.isNoUnknownValueComboValue());
       break;
     case FieldDefinition.FT_DATE:
       fi = new CurrentTimeItem();
       break;
     case FieldDefinition.FT_CHK_GRID:
       fi = new ChkGridItem();
       break;
     case FieldDefinition.FT_MAP_ITEM:
       fi = new MapButton(this, field);
       break;
     case FieldDefinition.FT_IMAGE_ITEM:
       fi = new ImageItem(this, field);
       break;
     case FieldDefinition.FT_CUSTOM:
       fi = new CanvasItem();
       break;
     default:
       break;
   }
   if (fi == null) {
     return null;
   }
   fi.setTitle(DocFlow.getCaption(field.getFieldCaptionId(), field.getFieldCaption()));
   if (field.getFieldWidth() != null && !field.getFieldWidth().isEmpty()) {
     fi.setWidth(field.getFieldWidth());
   }
   if (field.getFieldHeight() != null && !field.getFieldHeight().isEmpty()) {
     fi.setHeight(field.getFieldHeight());
   }
   if (field.isFieldReadOnly()) {
     if (field.getFieldType() == FieldDefinition.FT_COMBO
         || field.getFieldType() == FieldDefinition.FT_SELECTION
         || field.getFieldType() == FieldDefinition.FT_DATE) fi.setCanEdit(false);
     else fi.setCanEdit(false);
   }
   setDefaultValue(field, fi);
   if (field.isHidden()) fi.setVisible(false);
   if (field.isDisabled()) {
     fi.setDisabled(true);
   }
   return new FieldDefinitionItem(field, fi);
 }