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); }
public FormDefinitionPanel( FormDefinition definition, FieldDefinitionListValue listValue, DocType docType, DocPanelSettingDataComplete dataComplete) { super(); this.listValue = listValue; this.dataComplete = dataComplete; this.docType = docType; this.setWidth100(); this.setHeight100(); ArrayList<FormGroup> formGroups = definition.getFormGroups(); formitemMap = new HashMap<String, FieldDefinitionItem>(); ArrayList<MyDynamicForm> dynFields = new ArrayList<MyDynamicForm>(); for (FormGroup formGroup : formGroups) { ArrayList<FieldDefinition> fields = formGroup.getFieldDefinitions(); MyDynamicForm dynamicForm = new MyDynamicForm(); dynamicForm.setNewLine(formGroup.getNewLine() == 1); ArrayList<FormItem> items = new ArrayList<FormItem>(); for (FieldDefinition fieldDefinition : fields) { FieldDefinitionItem fi = createField(fieldDefinition); if (fi != null) { items.add(fi.getFormItem()); if (fieldDefinition.isFieldReadOnly()) fi.getFormItem().setCanEdit(false); formitemMap.put(fieldDefinition.getFieldName(), fi); } } // dynamicForm.setAlign(Alignment.LEFT); switch (formGroup.getLabelOrientation()) { case FormGroup.FTORIENTATION_LEFT: dynamicForm.setTitleOrientation(TitleOrientation.LEFT); break; case FormGroup.FTORIENTATION_TOP: dynamicForm.setTitleOrientation(TitleOrientation.TOP); break; case FormGroup.FTORIENTATION_RIGHT: dynamicForm.setTitleOrientation(TitleOrientation.RIGHT); break; default: break; } int numofColumns = 0; if (definition.isHorizontal()) { numofColumns = formGroup.getNumofColumns() > 0 ? formGroup.getNumofColumns() : 1; } else { numofColumns = formGroup.getNumofColumns() > 0 ? formGroup.getNumofColumns() : items.size(); } numofColumns = numofColumns * (formGroup.getLabelOrientation() == FormGroup.FTORIENTATION_TOP ? 1 : 2); dynamicForm.setNumCols(numofColumns); if (formGroup.getGroupHeight() != null && !formGroup.getGroupHeight().isEmpty()) { dynamicForm.setHeight(formGroup.getGroupHeight()); } if (formGroup.getGroupWidth() != null && !formGroup.getGroupWidth().isEmpty()) { dynamicForm.setWidth(formGroup.getGroupWidth()); } dynamicForm.setFields(items.toArray(new FormItem[] {})); dynFields.add(dynamicForm); if (formGroup.getGroupTitle() != null && formGroup.getGroupTitle().length() > 0) { dynamicForm.setIsGroup(true); dynamicForm.setGroupTitle( DocFlow.getCaption(formGroup.getFieldCaptionId(), formGroup.getGroupTitle())); } // this.addMember(dynamicForm); listValue.setFieldDefinitionListValue(formitemMap, this); } Layout container = this; if (definition.isHorizontal()) { container = createNewPanel(); } for (MyDynamicForm dynamicForm : dynFields) { if (dynamicForm.isNewLine()) { container = createNewPanel(); } container.addMember(dynamicForm); } Set<String> fieldKeys = formitemMap.keySet(); for (String key : fieldKeys) { final FieldDefinitionItem item = formitemMap.get(key); FieldDefinition fieldDef = item.getFieldDef(); if (fieldDef.getCalculatorClass() != null) { final ICalculatorClass classCalculator = listValue.getCalculetorClass(fieldDef.getCalculatorClass()); if (classCalculator != null) { item.getFormItem() .addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { classCalculator.calculate(formitemMap, item); } }); } } if (fieldDef.isClearComboValue()) { PickerIcon eraserValuePicker = new PickerIcon( new Picker("eraser.png"), new FormItemClickHandler() { public void onFormItemClick(FormItemIconClickEvent event) { item.getFormItem().setValue((Object) null); fireChangedEvent(item.getFormItem()); } }); item.getFormItem().setIcons(eraserValuePicker); } if ((fieldDef.getFieldType() == FieldDefinition.FT_COMBO || fieldDef.getFieldType() == FieldDefinition.FT_SELECTION)) { if (fieldDef.getFieldSelectMethode() > 0) { String depFields = fieldDef.getDependencyFields(); depFields = depFields == null ? "" : depFields; final String[] depFieldNames = depFields.split(";"); final String parent_type = fieldDef.getFieldSelectMethode() + ""; if (depFieldNames.length > 0 && depFieldNames[0].length() > 0) { item.getFormItem() .addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { if (settingMyself) return; try { settingMyself = true; comboValueChanged(depFieldNames, event.getValue(), parent_type); } finally { settingMyself = false; } } }); } } } } }