列表界面 取值工具类
package nc.ui.pubapp.util;
import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.BillListPanel;
import nc.ui.pub.bill.BillModel;
import nc.ui.pub.bill.IBillItem;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.data.ValueUtils;
public class ListPanelValueUtils {
private BillModel billModel;
private BillListPanel listPanel;
public ListPanelValueUtils(BillListPanel billListPanel) {
this.listPanel = billListPanel;
}
public String getBodyStringValueAt(int row, String strKey) {
Object value = this.getBodyValueAt(row, strKey);
return ValueUtils.getString(value);
}
public UFBoolean getBodyUFBooleanValueAt(int row, String strKey) {
Object value = this.getBodyValueAt(row, strKey);
return ValueUtils.getUFBoolean(value);
}
public UFDouble getBodyUFDoubleValueAt(int row, String strKey) {
Object value = this.getBodyValueAt(row, strKey);
return ValueUtils.getUFDouble(value);
}
public Object getBodyValueAt(int row, String strKey) {
this.billModel = this.listPanel.getBodyBillModel();
return this.getValueAt(row, strKey);
}
public String getHeadStringValueAt(int row, String strKey) {
Object value = this.getHeadValueAt(row, strKey);
return ValueUtils.getString(value);
}
public UFBoolean getHeadUFBooleanValueAt(int row, String strKey) {
Object value = this.getHeadValueAt(row, strKey);
return ValueUtils.getUFBoolean(value);
}
public UFDouble getHeadUFDoubleValueAt(int row, String strKey) {
Object value = this.getHeadValueAt(row, strKey);
return ValueUtils.getUFDouble(value);
}
public Object getHeadValueAt(int row, String strKey) {
this.billModel = this.listPanel.getHeadBillModel();
return this.getValueAt(row, strKey);
}
public void setBodyValueAt(Object aValue, int row, String strKey) {
this.billModel = this.listPanel.getBodyBillModel();
this.setValueAt(aValue, row, strKey);
}
public void setBodyValueAt(Object aValue, int row, String strKey,
String tableCode) {
this.billModel = this.listPanel.getBodyBillModel(tableCode);
this.setValueAt(aValue, row, strKey);
}
public void setHeadValueAt(Object aValue, int row, String strKey) {
this.billModel = this.listPanel.getHeadBillModel();
this.setValueAt(aValue, row, strKey);
}
private String getCorrectItemKey(String itemKey) {
if (IBillItem.UFREF == this.getItemType(itemKey)) {
return itemKey + IBillItem.ID_SUFFIX;
}
return itemKey;
}
private int getItemType(String itemKey) {
BillItem billItem = this.billModel.getItemByKey(itemKey);
return null == billItem ? IBillItem.UNSET : billItem.getDataType();
}
private Object getValueAt(int row, String strKey) {
if (this.listPanel.getBillListData().isMeataDataTemplate()) {
int colIndex = this.billModel.getBodyColByKey(strKey);
if (colIndex < 0) {
return null;
}
Object value = this.billModel.getValueAt(row, colIndex);
BillItem item = this.billModel.getItemByKey(strKey);
Object trueValue = item.converType(value);
return trueValue;
}
return this.billModel.getValueAt(row, this.getCorrectItemKey(strKey));
}
private void setValueAt(Object aValue, int row, String strKey) {
this.billModel.setValueAt(aValue, row, this.getCorrectItemKey(strKey));
if (IBillItem.UFREF == this.getItemType(strKey)) {
this.billModel.loadLoadRelationItemValue(row, strKey);
}
}
}
卡片界面 取值工具类
package nc.ui.pubapp.util;
import nc.md.model.MetaDataException;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillData;
import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.BillModel;
import nc.ui.pub.bill.IBillItem;
import nc.ui.pubapp.uif2app.view.util.BillRowNoUtils;
import nc.vo.pub.SuperVO;
import nc.vo.pub.bill.BillTabVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.data.ValueUtils;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.model.entity.bill.IBill;
import nc.vo.pubapp.pattern.pub.PubAppTool;
import nc.vo.pubapp.util.MetaUtils;
import org.apache.commons.lang.StringUtils;
public class CardPanelValueUtils {
private BillCardPanel card;
public CardPanelValueUtils(BillCardPanel cardPanel) {
this.card = cardPanel;
}
public void addBodyLine(String sRowNOKey) {
this.card.addLine();
BillRowNoUtils.addLineRowNo(this.card, sRowNOKey);
}
public void clearAllRowValueByItemKeys(String[] itemKeys) {
this.clearAllRowValueByItemKeys(itemKeys, null);
}
public void clearAllRowValueByItemKeys(String[] itemKeys, String tableCode) {
int rowCount = this.card.getRowCount();
for (int i = 0; i < rowCount; i++) {
this.clearRowValueByItemKeys(i, itemKeys, tableCode);
}
}
public void clearHeadValueByItemKeys(String[] itemKeys) {
for (String itemKey : itemKeys) {
this.setHeadTailValue(itemKey, null);
}
}
public void clearRowValueByItemKeys(int iRow, String[] itemKeys,
String tableCode) {
for (String itemKey : itemKeys) {
this.setBodyValue(null, iRow, itemKey, tableCode);
}
}
public void delBodyLine() {
int count = this.card.getRowCount();
int[] rows = new int[count];
for (int i = 0; i < count; i++) {
rows[i] = i;
}
this.card.getBodyPanel().delLine(rows);
}
public void delBodyLine(Integer[] rowindexs) {
if (rowindexs == null || rowindexs.length == 0) {
return;
}
int[] rows = new int[rowindexs.length];
for (int i = 0; i < rowindexs.length; i++) {
rows[i] = rowindexs[i].intValue();
}
this.card.getBodyPanel().delLine(rows);
}
public String filtSuffix(String porigItemkey) {
String origItemkey = porigItemkey;
if (origItemkey != null && origItemkey.indexOf(IBillItem.ID_SUFFIX) >= 0) {
origItemkey =
origItemkey.substring(0,
origItemkey.length() - IBillItem.ID_SUFFIX.length());
}
return origItemkey;
}
@SuppressWarnings("unchecked")
public <B extends IBill> B getBillValueVO(Class<B> c) {
c.getClass();
return (B) this.card.getBillData().getBillObjectByMetaData();
}
public BillItem getBodyItem(String sItemKey) {
BillItem btTemp = this.card.getBodyItem(sItemKey);
return btTemp;
}
public String getBodyStringValue(int iRow, String sItemKey) {
Object value = this.getBodyValue(iRow, sItemKey, null);
return ValueUtils.getString(value);
}
public UFBoolean getBodyUFBooleanValue(int iRow, String sItemKey) {
Object objValue = this.getBodyValue(iRow, sItemKey);
return ValueUtils.getUFBoolean(objValue);
}
public UFDouble getBodyUFDoubleValue(int iRow, String sItemKey) {
Object objValue = this.getBodyValue(iRow, sItemKey);
return ValueUtils.getUFDouble(objValue);
}
public Object getBodyValue(int iRow, String sItemKey) {
return this.getBodyValue(iRow, sItemKey, null);
}
public Object getBodyValue(int rowIndex, String strKey, String tableCode1) {
String tableCode = tableCode1;
if (tableCode == null) {
tableCode = this.card.getCurrentBodyTableCode();
}
Object ret = null;
if (this.card.getBillData().isMeataDataTemplate()) {
int colIndex = this.card.getBodyColByKey(tableCode, strKey);
if (colIndex >= 0) {
Object value =
this.card.getBillModel(tableCode).getValueAt(rowIndex, colIndex);
BillItem item = this.card.getBodyItem(tableCode, strKey);
ret = item.converType(value);
}
}
else {
ret =
this.card.getBillModel(tableCode).getValueAt(rowIndex,
this.getCorrectItemKey(strKey));
}
return ret;
}
@SuppressWarnings("unchecked")
public <T extends SuperVO> T getBodyValueVO(int row, Class<T> clazz) {
return (T) this.card.getBillModel().getBodyValueRowVO(row, clazz.getName());
}
@SuppressWarnings("unchecked")
public <B extends IBill> B getChangeBillValueVO(Class<B> c) {
c.getClass();
return (B) this.card.getBillData().getChangeBillObjectByMetaData();
}
public BillItem getFirstChildBodyItem(String itemkey) {
String firstChildTableCode = this.getFirstChildTableCode();
if (StringUtils.isEmpty(firstChildTableCode)) {
return null;
}
return this.card.getBodyItem(firstChildTableCode, itemkey);
}
public BillItem getHeadTailItem(String sItemKey) {
BillItem btTemp = this.card.getHeadTailItem(sItemKey);
return btTemp;
}
public String getHeadTailStringValue(String sItemKey) {
BillItem btTemp = this.card.getHeadTailItem(sItemKey);
if (btTemp == null) {
return null;
}
return ValueUtils.getString(btTemp.getValueObject());
}
public UFBoolean getHeadTailUFBooleanValue(String sItemKey) {
BillItem headitem = this.card.getHeadTailItem(sItemKey);
if (null == headitem) {
return null;
}
return ValueUtils.getUFBoolean(headitem.getValueObject());
}
public UFDate getHeadTailUFDateValue(String sItemKey) {
BillItem btTemp = this.card.getHeadTailItem(sItemKey);
if (btTemp == null) {
return null;
}
return ValueUtils.getUFDate(btTemp.getValueObject());
}
public UFDouble getHeadTailUFDoubleValue(String sItemKey) {
BillItem headitem = this.card.getHeadTailItem(sItemKey);
if (null == headitem) {
return null;
}
return ValueUtils.getUFDouble(headitem.getValueObject());
}
public Object getHeadTailValue(String sItemKey) {
BillItem btTemp = this.card.getHeadTailItem(sItemKey);
if (btTemp == null) {
return null;
}
return btTemp.getValueObject();
}
public int getRowCount() {
return this.card.getRowCount();
}
public boolean isBodyItemNull(int iRow, String sItemKey, String tableCode) {
Object value = this.getBodyValue(iRow, sItemKey, tableCode);
if (value == null) {
return true;
}
return PubAppTool.isNull(value.toString());
}
public boolean isHeadItemNull(String itemKey) {
Object value = this.getHeadTailValue(itemKey);
if (value == null) {
return true;
}
return PubAppTool.isNull(value.toString());
}
public void loadEditHeadRelation(String sItemKey) {
this.card.getBillData().loadEditHeadRelation(sItemKey);
}
public void loadLoadRelationItemValue() {
this.card.getBillModel().loadLoadRelationItemValue();
}
public void resetBillData() {
this.card.setBillData(this.card.getBillData());
}
public void resetCardPanel(String rownoKey, String tableCode) {
BillItem[] headItems = this.card.getHeadItems();
if (headItems != null) {
for (BillItem item : headItems) {
item.setValue(item.getDefaultValue());
}
}
BillItem[] bodyItems = this.card.getBodyItems();
if (bodyItems != null) {
for (BillItem item : bodyItems) {
if (item.getKey().equals(rownoKey)) {
continue;
}
this.setBodyValue(item.getDefaultValue(), item.getKey(), tableCode);
}
}
BillItem[] tailItems = this.card.getTailItems();
if (tailItems != null) {
for (BillItem item : tailItems) {
item.setValue(item.getDefaultValue());
}
}
}
public void setBodyDisable() {
this.setBillItemDisable(this.card.getBodyItems());
}
public void setBodyDisable(int row, String key) {
this.card.getBillModel().setCellEditable(row, key, false);
}
public void setBodyDisable(int row, String[] keys) {
for (String key : keys) {
this.setBodyDisable(row, key);
}
}
public void setBodyDisable(String[] bodyItemKeys) {
if (bodyItemKeys == null || bodyItemKeys.length == 0) {
return;
}
for (String itemKey : bodyItemKeys) {
BillItem item = this.card.getBodyItem(itemKey);
if (item != null) {
item.setEdit(false);
}
}
}
public void setBodyEnable(int row, String key) {
this.card.getBillModel().setCellEditable(row, key, true);
}
public void setBodyEnable(int row, String[] keys) {
for (String key : keys) {
this.setBodyEnable(row, key);
}
}
public void setBodyEnable(String[] bodyItemKeys) {
if (bodyItemKeys == null || bodyItemKeys.length == 0) {
return;
}
for (String itemKey : bodyItemKeys) {
BillItem item = this.card.getBodyItem(itemKey);
if (item != null) {
item.setEdit(true);
}
}
}
public void setBodyValue(Object value, int iRow, String sItemKey) {
this.setBodyValue(value, iRow, sItemKey, null);
}
public void setBodyValue(Object value, int iRow, String sItemKey,
String tableCode) {
BillModel bm = null;
if (tableCode == null) {
bm = this.card.getBillModel();
}
else {
bm = this.card.getBillModel(tableCode);
}
if (bm == null) {
return;
}
BillItem bt = bm.getItemByKey(sItemKey);
if (bt == null) {
return;
}
int dataType = bt.getDataType();
if (IBillItem.UFREF == dataType || IBillItem.COMBO == dataType) {
bm.setValueAt(value, iRow, sItemKey + IBillItem.ID_SUFFIX);
}
else {
bm.setValueAt(value, iRow, sItemKey);
}
}
public void setBodyValue(Object value, String sItemKey) {
this.setBodyValue(value, sItemKey, null);
}
public void setBodyValue(Object value, String sItemKey, String tableCode) {
BillModel bm = null;
if (tableCode == null) {
bm = this.card.getBillModel();
}
else {
bm = this.card.getBillModel(tableCode);
}
if (bm == null) {
return;
}
BillItem bt = bm.getItemByKey(sItemKey);
if (bt == null) {
return;
}
int dataType = bt.getDataType();
for (int iRow = 0; iRow < this.card.getRowCount(); iRow++) {
if (IBillItem.UFREF == dataType || IBillItem.COMBO == dataType) {
bm.setValueAt(value, iRow, sItemKey + IBillItem.ID_SUFFIX);
}
else {
bm.setValueAt(value, iRow, sItemKey);
}
}
}
public void setBodyValueForEdit(Object value, int iRow, String itemkey) {
BillItem item = this.card.getBodyItem(itemkey);
if (item == null) {
return;
}
String key = itemkey;
int dataType = item.getDataType();
if (IBillItem.UFREF == dataType || IBillItem.COMBO == dataType) {
key = itemkey + IBillItem.ID_SUFFIX;
}
this.card.getBillModel().setValueAt(value, iRow, key);
this.card.getBillModel().loadLoadRelationItemValue(iRow, key);
this.card.getBillModel().loadEditRelationItemValue(iRow, itemkey);
}
public void setBodyValueVO(int row, SuperVO vo) {
this.card.getBillModel().setBodyRowObjectByMetaData(vo, row);
}
public void setCardDisabled() {
this.card.setEnabled(false);
}
public void setCardEnabled() {
this.card.setEnabled(true);
}
public void setHeadTailDisable() {
this.setBillItemDisable(this.card.getHeadItems());
this.setBillItemDisable(this.card.getTailItems());
}
public void setHeadTailDisable(String[] headTailItemKeys) {
if (headTailItemKeys == null || headTailItemKeys.length == 0) {
return;
}
for (String itemKey : headTailItemKeys) {
BillItem item = this.card.getHeadTailItem(itemKey);
if (item != null) {
item.setEdit(false);
}
}
}
public void setHeadTailValue(String sItemKey, Object value) {
BillItem item = this.card.getHeadItem(sItemKey);
if (item == null) {
item = this.card.getTailItem(sItemKey);
}
if (item != null) {
item.setValue(value);
}
}
public void setHeadTailValueForEdit(String sItemKey, Object value) {
BillItem item = this.card.getHeadItem(sItemKey);
if (item != null) {
this.card.setHeadItem(sItemKey, value);
}
else {
this.card.setTailItem(sItemKey, value);
}
this.card.getBillData().loadEditHeadRelation(sItemKey);
}
private String getCorrectItemKey(String itemKey) {
if (IBillItem.UFREF == this.getItemType(itemKey)) {
return itemKey + IBillItem.ID_SUFFIX;
}
return itemKey;
}
private String getFirstChildTableCode() {
BillData billData = this.card.getBillData();
String beanName =
billData.getBillTempletVO().getHeadVO().getMetadataclass();
try {
String firstChildBeanName = MetaUtils.getFirstChildBeanFullName(beanName);
BillTabVO[] tabVOs = billData.getAllTabVos();
for (BillTabVO tabVO : tabVOs) {
if (StringUtils.equals(firstChildBeanName, tabVO.getMetadataclass())) {
return tabVO.getTabcode();
}
}
}
catch (MetaDataException e) {
ExceptionUtils.wrappException(e);
}
return null;
}
private int getItemType(String itemKey) {
BillItem billItem = this.getBodyItem(itemKey);
return null == billItem ? IBillItem.UNSET : billItem.getDataType();
}
private void setBillItemDisable(BillItem[] items) {
if (items == null || items.length == 0) {
return;
}
for (BillItem item : items) {
if (item != null) {
item.setEdit(false);
}
}
}
public BillCardPanel getCardPanel() {
return this.card;
}
}