예제 #1
0
 /**
  * returns a smartgwt SelectItem with the name field for the formField value descriptor.
  *
  * @param field
  * @param formField
  * @param valueMap The selection possibilities.
  * @return
  */
 protected FormItem createSelectField(
     String field, UIFormFieldValue formField, LinkedHashMap<String, String> valueMap) {
   FormItem res = new SelectItem(field, formField.getLabel());
   res.setValueMap(valueMap);
   res.setValue((String) formField.getValue());
   return res;
 }
예제 #2
0
  private void setFieldLists(
      HashMap<String, ArrayList<ClSelectionItem>> result,
      HashMap<String, String> values,
      boolean datasettings) {
    Set<String> fieldKeys = result.keySet();
    for (String key : fieldKeys) {
      FieldDefinitionItem item = formitemMap.get(key);
      if (item == null) continue;
      FormItem formItem = item.getFormItem();
      if (formItem == null
          && !(formItem instanceof ComboBoxItem
              || formItem instanceof SelectItem
              || formItem instanceof ChkGridItem)) continue;

      ArrayList<ClSelectionItem> items = result.get(key);

      setSelectItems(formItem, items);
      String val = null;

      if (item.getFieldDef().getDefaultValue() != null
          && item.getFieldDef().getDefaultValue().trim().length() > 0) {
        val = item.getFieldDef().getDefaultValue().trim();
      }
      formItem.setValue(val);
      // if (item.getFieldDef().isCalculateOnSet())
      // setCalculatorCalculate(item);
    }
    if (datasettings) setData(values);
  }
예제 #3
0
  private void comboValueChanged(String[] depFieldNames, Object selectedvalue, String parent_type) {
    HashMap<String, String> listSqls = new HashMap<String, String>();

    for (int i = 0; i < depFieldNames.length; i++) {
      String key = depFieldNames[i];
      FieldDefinitionItem item = formitemMap.get(key);
      if (item == null) continue;
      FieldDefinition fieldDef = item.getFieldDef();
      if (fieldDef == null) continue;
      FormItem formItem = item.getFormItem();
      if (formItem == null) continue;
      // result.put(key, );
      formItem.setValue((String) null);
      setSelectItems(formItem, new ArrayList<ClSelectionItem>());
      if ((fieldDef.getFieldType() == FieldDefinition.FT_COMBO
              || fieldDef.getFieldType() == FieldDefinition.FT_SELECTION
              || fieldDef.getFieldType() == FieldDefinition.FT_CHK_GRID)
          && fieldDef.getFieldSelectMethode() > 0) {

        String depFields = fieldDef.getDependencyFields();
        depFields = depFields == null ? "" : depFields;
        final String[] mydepFieldNames = depFields.split(";");
        final String myparent_type = fieldDef.getFieldSelectMethode() + "";
        if (mydepFieldNames.length > 0 && mydepFieldNames[0].length() > 0) {
          comboValueChanged(mydepFieldNames, null, myparent_type);
        }
        if (selectedvalue == null) continue;
        String value =
            fieldDef.getFieldSelectMethode() + "_" + parent_type + "_" + selectedvalue.toString();
        listSqls.put(key, value);
      }
    }
    getRemouteValues(null, -1, listSqls, false);
  }
    @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);
    }
예제 #5
0
 private void setSelectItems(FormItem si, ArrayList<ClSelectionItem> items) {
   if (items == null) {
     items = new ArrayList<ClSelectionItem>();
   }
   LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
   map.put("-1", "---");
   for (ClSelectionItem item : items) {
     map.put(item.getId() + "", item.getValue());
   }
   si.setValueMap(map);
   si.setValue("-1");
 }
 public AssetCanvas(final FormItem formItem) {
   setWidth(100);
   setAlign(Alignment.CENTER);
   previewContainer = new Canvas();
   addMember(previewContainer);
   previewContainer.setWidth(100);
   previewContainer.setHeight(100);
   previewContainer.setBorder("1px solid #a6abb4");
   imageUpdateButton = new IButton("Update Artifact");
   imageUpdateButton.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           String formItemName = formItem.getName();
           ((DynamicEntityDataSource) formItem.getForm().getDataSource())
               .getFormItemCallbackHandlerManager()
               .getFormItemCallback(formItemName)
               .execute(formItem);
         }
       });
   addMember(imageUpdateButton);
   if (formItem.getDisabled()) {
     imageUpdateButton.setVisible(false);
   }
 }
예제 #7
0
  private void addZoneCriteria(Criteria cr, FormItem fi, String fieldName) {
    Long criteria = null;
    try {
      criteria = Long.parseLong(fi.getValue().toString());
    } catch (Exception e) {

    }
    if (criteria != null) cr.addCriteria(fieldName, criteria.toString());
  }
예제 #8
0
 private void addCriteria(
     ArrayList<String> criterias, FormItem formitem, String formatedString, String notvalue) {
   Object obj = formitem.getValue();
   if (obj == null) return;
   String value = obj.toString().trim();
   if (value.length() == 0) return;
   if (value.equals(notvalue)) return;
   value = formatedString.replaceAll("%s", value);
   criterias.add(value);
 }
예제 #9
0
 protected int getItemValue(FormItem item) {
   int val = 0;
   try {
     val = Integer.parseInt(item.getValue().toString());
   } catch (Exception e) {
     // TODO: handle exception
   }
   if (val < 0) val = 0;
   return val;
 }
예제 #10
0
 private void setDefaultValue(FieldDefinition field, FormItem fi) {
   if (field.getDefaultValue() != null && field.getDefaultValue().trim().length() > 0) {
     String defValue = field.getDefaultValue().trim();
     if (defValue.toLowerCase().equals("$regionId".toLowerCase())) {
       defValue = null;
     }
     if (defValue != null && defValue.toLowerCase().equals("$subregionId".toLowerCase())) {
       defValue = null;
     }
     fi.setValue(defValue);
   }
 }
예제 #11
0
 public static void setSelectItems(FormItem si, ArrayList<ClSelectionItem> items) {
   if (items == null) {
     items = new ArrayList<ClSelectionItem>();
   }
   if (si instanceof ChkGridItem) {
     ((ChkGridItem) si).setItems(items);
     return;
   }
   LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
   for (ClSelectionItem item : items) {
     map.put(item.getId() + "", item.getValue());
   }
   si.setValueMap(map);
 }
예제 #12
0
    private void init(final ListGridRecord sampleRecord, final boolean add) {
      final Form form = new Form(nameItem, mudpitItem, categoryItem);
      form.setWrapItemTitles(false);
      nameItem.setValue(sampleRecord.getAttributeAsString("Name"));
      nameItem.addChangedHandler(
          new ChangedHandler() {
            public void onChanged(final ChangedEvent event) {
              checkOk();
            }
          });
      mudpitItem.setValue(sampleRecord.getAttributeAsBoolean("Mudpit"));
      categoryItem.setValue(sampleRecord.getAttributeAsString("Category"));

      final Label label = new Label(CONSTANTS.scaffoldWizardSampleSearchLabel());
      label.setWidth100();
      label.setHeight(12);

      final TreeOptions treeOptions = new TreeOptions();
      treeOptions.setInitialItems(
          locationFactory.getTropixObjectSourceRootItems(TropixObjectTreeItemExpanders.get(types)));
      treeOptions.setShowPredicate(getShowItemPredicate());
      treeOptions.setSelectionPredicate(LocationPredicates.getTropixObjectNotFolderPredicate());
      treeOptions.setSelectionType(SelectionType.MULTIPlE);
      @SuppressWarnings("unchecked")
      final Collection<TreeItem> selectedItems =
          (Collection<TreeItem>) sampleRecord.getAttributeAsObject("Selection");
      treeOptions.setExpandIds(Locations.getAncestorIds(selectedItems));
      treeOptions.setSelectedItems(selectedItems);
      final TreeComponent tree = treeComponentFactory.get(treeOptions);
      tree.addMultiSelectionListener(this);
      final TreeGrid treeGrid = tree.get();
      treeGrid.setTooltip("Hold the control key to select multiple items.");
      final VLayout layout = new VLayout();
      layout.addMember(form);
      layout.addMember(label);
      layout.addMember(treeGrid);
      layout.setSize("500px", "500px");
      okButton =
          SmartUtils.getButton(
              add ? "Add" : "Update",
              null,
              new Command() {
                public void execute() {
                  sampleRecord.setAttribute("Name", (String) nameItem.getValue());
                  sampleRecord.setAttribute("Category", (String) categoryItem.getValue());
                  sampleRecord.setAttribute("Mudpit", (Boolean) mudpitItem.getValue());
                  sampleRecord.setAttribute("Selection", selection);
                  if (add) {
                    dataSource.addData(sampleRecord);
                    records.add(sampleRecord);
                  }
                  listGrid.markForRedraw();
                  get().markForDestroy();
                  checkValid();
                }
              });
      final Button cancelButton = SmartUtils.getCancelButton(this);
      final Layout opsLayout = new CanvasWithOpsLayout<VLayout>(layout, okButton, cancelButton);
      final Window window =
          PopOutWindowBuilder.titled((add ? "Add" : "Update") + " Sample")
              .withContents(opsLayout)
              .autoSized()
              .get();
      setWidget(window);
      checkOk();
      get().draw();
    }
예제 #13
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);
 }
예제 #14
0
 /**
  * returns a smartgwt TextItem with the name field for the formField value descriptor.
  *
  * @param field
  * @param formField
  * @return
  */
 private FormItem createStringFormField(String field, UIFormFieldValue formField) {
   //		log("createStringFormField for " + field);
   FormItem res = new TextItem(field, formField.getLabel());
   res.setValue((String) formField.getValue());
   return res;
 }
 protected void setFilter(String name, String value) {
   FormItem item = this.filterForm.getItem(name);
   if (null != item) {
     item.setValue(value);
   }
 }