卡片表头处理工具类
package nc.ui.srmpub.util;
import nc.itf.srmpub.reference.uap.bd.supplier.SupplierPubServiceAdapter;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillItem;
import nc.vo.bd.address.AddressVO;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
/**
* <p>
* <b>本类主要完成以下功能:</b>
* <ul>
* <li>卡片表头处理工具类
* </ul>
* <p>
* <p>
*
* @version 6.3
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:37:14
*/
public class HeadUIPanelUtil {
/**
* 方法功能描述:将卡片面板标识为修改色的字段还原为默认颜色
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param color
* 要标识为的颜色<code>ColorConstants</code>
* <p>
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:42:15
*/
public static void resetColorHeadItems(BillCardPanel panel, int color) {
BillItem[] items = panel.getHeadItems();
for (BillItem item : items) {
item.setForeground(color);
}
}
/**
* 方法功能描述:对卡片表头修改过的字段用颜色color标识处理,代码放到srmpub不合理,备注字段单独处理
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param oldVo
* 旧VO
* @param color
* 要标识为的颜色<code>ColorConstants</code>
* <p>
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:40:06
*/
public static void resetColorHeadItems(BillCardPanel panel, SuperVO oldVo,
int color, String tablecode) {
// VO所有字段的数组
String[] fields = oldVo.getAttributeNames();
for (int i = 0; i < fields.length; i++) {
BillItem headItem = panel.getHeadItem(fields[i]);
if (tablecode.equals("supplierext") && fields[i].equals("vmemo")) {
headItem = panel.getHeadItem("vextmemo");
}
if (headItem == null || headItem.getKey().equals("pk_supplier")) {
continue;
}
if (tablecode.equals("supplierbase") && fields[i].equals("vextmemo")) {
continue;
}
Object clientObj = headItem.getValueObject();
Object oldObj = oldVo.getAttributeValue(fields[i]);
// /*邮政编码跟*/企业地址需要单独处理
if (headItem.getKey().equals("corpaddress")) {
AddressVO oldAddressVO =
SupplierPubServiceAdapter.getAddressVOByPk((String) oldObj);
AddressVO newAddressVO =
SupplierPubServiceAdapter.getAddressVOByPk((String) clientObj);
if (oldAddressVO == null) {
if (newAddressVO != null) {
headItem.setForeground(color);
continue;
}
}
else {
if (newAddressVO == null) {
headItem.setForeground(color);
continue;
}
if (HeadUIPanelUtil.isAddressDif(oldAddressVO, newAddressVO)) {
headItem.setForeground(color);
continue;
}
}
continue;
}
// // 邮编
// if (headItem.getKey().equals("zipcode")) {
// if (oldObj == null || "".equals(oldObj)) {
// AddressVO oldvo =
// SupplierPubServiceAdapter.getAddressVOByPk((String) oldVo
// .getAttributeValue("corpaddress"));
// oldObj = oldvo == null ? null : oldvo.getPostcode();
// }
// }
if (clientObj != null && !"".equals(clientObj) && oldObj == null) {
headItem.setForeground(color);
}
else if (clientObj != null && !"".equals(clientObj) && oldObj != null) {
if (clientObj instanceof Integer
&& Integer.valueOf(clientObj.toString()).compareTo(
Integer.valueOf(oldObj.toString())) != 0) {
headItem.setForeground(color);
}
else if (clientObj instanceof UFDouble
&& new UFDouble(String.valueOf(clientObj)).compareTo(new UFDouble(
String.valueOf(oldObj))) != 0) {
headItem.setForeground(color);
}
else if (clientObj instanceof UFDate
&& !new UFDate(clientObj.toString()).isSameDate(new UFDate(oldObj
.toString()))) {
headItem.setForeground(color);
}
else if (oldObj instanceof String
&& !clientObj.toString().equals(oldObj.toString())) {
headItem.setForeground(color);
}
}
if ((clientObj == null || "".equals(clientObj)) && oldObj != null) {
headItem.setForeground(color);
}
}
}
/**
* 方法功能描述:判断企业地址是否不一样
* <p>
* <b>参数说明</b>
*
* @param oldco
* @param newco
* @return <p>
* @since 6.5
* @author shangjd
* @time 2014-8-4 上午11:16:11
*/
private static boolean isAddressDif(AddressVO oldco, AddressVO newco) {
// 详细地址
if (newco.getDetailinfo() != null
&& !newco.getDetailinfo().equals(oldco.getDetailinfo())
|| newco.getDetailinfo() == null && oldco.getDetailinfo() != null) {
return true;
}
// 国家
if (newco.getCountry() != null
&& !newco.getCountry().equals(oldco.getCountry())
|| newco.getCountry() == null && oldco.getCountry() != null) {
return true;
}
// 省份
if (newco.getProvince() != null
&& !newco.getProvince().equals(oldco.getProvince())
|| newco.getProvince() == null && oldco.getProvince() != null) {
return true;
}
// 城市
if (newco.getCity() != null && !newco.getCity().equals(oldco.getCity())
|| newco.getCity() == null && oldco.getCity() != null) {
return true;
}
// 县区
if (newco.getVsection() != null
&& !newco.getVsection().equals(oldco.getVsection())
|| newco.getVsection() == null && oldco.getVsection() != null) {
return true;
}
// 邮编
if (newco.getPostcode() != null
&& !newco.getPostcode().equals(oldco.getPostcode())
|| newco.getPostcode() == null && oldco.getPostcode() != null) {
return true;
}
return false;
}
}
卡片表体处理工具类
package nc.ui.srmpub.util;
import java.awt.Color;
import nc.ui.pub.beans.constenum.IConstEnum;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.BillScrollPane;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.srmpub.res.field.SRMPubName;
import nc.vo.srmpub.util.SRMBaseUtil;
/**
* <p>
* <b>本类主要完成以下功能:</b>
* <ul>
* <li>卡片表体处理工具类
* </ul>
* <p>
* <p>
*
* @version 6.3
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午01:55:50
*/
public class BodyUIPanelUtil {
/**
* 方法功能描述:清空卡片面板表体上的值
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param tableCode
* 页签编码
* <p>
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:30:31
*/
public static void clearBodyUIPanel(BillCardPanel panel, String tableCode) {
BillScrollPane pane = panel.getBodyPanel(tableCode);
int rowcount = pane.getTableModel().getRowCount();
// 当表体表格中有数据,则清空
if (rowcount > 0) {
int[] rows = new int[rowcount];
for (int i = 0; i < rowcount; i++) {
rows[i] = i;
}
pane.delLine(rows);
}
}
/**
* 方法功能描述:将表体面板标识为他色的字段还原为默认颜色color
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param tableCode
* 表格编码
* @param color
* 要标识为的颜色<code>Color</code>
* <p>
* @since 6.3
* @author miaoff
* @time 2014-2-11 上午09:22:24
*/
public static void resetColorAction(BillCardPanel panel, String tableCode,
Color color) {
BillScrollPane pane = panel.getBodyPanel(tableCode);
int rowcount = pane.getTableModel().getRowCount();
// 当表体表格中有数据,则清空
if (rowcount > 0) {
BillItem[] items = panel.getBillData().getBodyShowItems(tableCode);
for (int i = 0; i < rowcount; i++) {
for (int j = 0; j < items.length; j++) {
pane.setCellForeGround(i, items[j].getKey(), color);
}
}
}
}
/**
* 方法功能描述:将卡片表体面板上的所有字段标识为color颜色
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param tableCode
* 页签编码
* @param color
* 要标识为的颜色<code>Color</code>
* <p>
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:28:58
*/
public static void resetColorBodyItems(BillCardPanel panel, String tableCode,
Color color) {
BillScrollPane pane = panel.getBodyPanel(tableCode);
int rowcount = pane.getTableModel().getRowCount();
if (rowcount > 0) {
BillItem[] items = panel.getBillData().getBodyShowItems(tableCode);
for (int i = 0; i < rowcount; i++) {
for (int j = 0; j < items.length; j++) {
pane.setCellForeGround(i, items[j].getKey(), color);
}
}
}
}
/**
* 方法功能描述:将卡片表体修改过的字段用颜色color标识处理<br>
* <b>注意事项:</b>
* <ol>
* <li>页签编码为VO主键字段</li>
* </ol>
* <p>
* <b>参数说明</b>
*
* @param panel
* 卡片面板
* @param oldVo
* 旧VO
* @param color
* 要标识为的颜色<code>Color</code>
* <p>
* @since 6.3
* @author miaoff
* @time 2014-1-27 下午02:10:06
*/
public static void resetColorBodyItems(BillCardPanel panel, SuperVO[] oldVos,
Color color) {
if (SRMBaseUtil.isArrayElementsNull(oldVos)) {
return;
}
// VO所有字段数组
String[] fields = oldVos[0].getAttributeNames();
// 卡片表体页签pane
BillScrollPane pane = panel.getBodyPanel(oldVos[0].getPrimaryKey());
for (int i = 0; i < oldVos.length; i++) {
for (int j = 0; j < fields.length; j++) {
Object clientAttrValue = panel.getBodyValueAt(i, fields[j]);
Object oldAttrValue = oldVos[i].getAttributeValue(fields[j]);
if (clientAttrValue != null && oldAttrValue == null
&& !SRMPubName.CROWNO.equals(fields[j])
&& !clientAttrValue.equals(oldAttrValue)) {
pane.setCellForeGround(i, fields[j], color);
}
else if (clientAttrValue != null && oldAttrValue != null) {
if (oldAttrValue instanceof Integer
&& Integer.valueOf(clientAttrValue.toString()).compareTo(
Integer.valueOf(oldAttrValue.toString())) != 0) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof UFDouble
&& new UFDouble(clientAttrValue.toString())
.compareTo(new UFDouble(oldAttrValue.toString())) != 0) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof UFDate
&& !new UFDate(clientAttrValue.toString()).isSameDate(new UFDate(
oldAttrValue.toString()))) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof String
&& !clientAttrValue.toString().equals(oldAttrValue.toString())) {
pane.setCellForeGround(i, fields[j], color);
}
else if (!clientAttrValue.equals(oldAttrValue)) {
pane.setCellForeGround(i, fields[j], color);
}
}
}
}
}
public static void resetColorBodyItemsByShangjd(BillCardPanel panel, int i,
String tableCode, SuperVO oldVo, Color color) {
// VO所有字段数组
String[] fields = oldVo.getAttributeNames();
// 卡片表体页签pane
BillScrollPane pane = panel.getBodyPanel(tableCode);
for (int j = 0; j < fields.length; j++) {
Object clientAttrValue =
panel.getBillModel(tableCode).getValueObjectAt(i, fields[j]);
if (clientAttrValue instanceof IConstEnum) {
clientAttrValue = ((IConstEnum) clientAttrValue).getValue();
}
Object oldAttrValue = oldVo.getAttributeValue(fields[j]);
if (clientAttrValue != null && oldAttrValue == null
&& !SRMPubName.CROWNO.equals(fields[j])
&& !clientAttrValue.equals(oldAttrValue)) {
pane.setCellForeGround(i, fields[j], color);
}
else if (clientAttrValue != null && oldAttrValue != null) {
if (oldAttrValue instanceof Integer
&& Integer.valueOf(clientAttrValue.toString()).compareTo(
Integer.valueOf(oldAttrValue.toString())) != 0) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof UFDouble
&& new UFDouble(clientAttrValue.toString()).compareTo(new UFDouble(
oldAttrValue.toString())) != 0) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof UFDate
&& !new UFDate(clientAttrValue.toString()).isSameDate(new UFDate(
oldAttrValue.toString()))) {
pane.setCellForeGround(i, fields[j], color);
}
else if (oldAttrValue instanceof String
&& !clientAttrValue.toString().equals(oldAttrValue.toString())) {
pane.setCellForeGround(i, fields[j], color);
}
else if (!clientAttrValue.equals(oldAttrValue)) {
pane.setCellForeGround(i, fields[j], color);
}
}
}
}
}