文档章节

常用工具类FMClientHelper

giianhui
 giianhui
发布于 2016/05/27 11:19
字数 12226
阅读 98
收藏 0
package com.kingdee.eas.fm.common.client;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.appframework.databinding.DataBinder;
import com.kingdee.bos.ctrl.common.util.StreamUtil;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.extendcontrols.QueryAgent;
import com.kingdee.bos.ctrl.kdf.data.datasource.DSParam;
import com.kingdee.bos.ctrl.kdf.export.ExportManager;
import com.kingdee.bos.ctrl.kdf.kds.KDSBook;
import com.kingdee.bos.ctrl.kdf.kds.KDSSheet;
import com.kingdee.bos.ctrl.kdf.table.ICell;
import com.kingdee.bos.ctrl.kdf.table.IColumn;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTBlock;
import com.kingdee.bos.ctrl.kdf.table.KDTDefaultCellEditor;
import com.kingdee.bos.ctrl.kdf.table.KDTIOManager;
import com.kingdee.bos.ctrl.kdf.table.KDTSelectBlock;
import com.kingdee.bos.ctrl.kdf.table.KDTSelectManager;
import com.kingdee.bos.ctrl.kdf.table.KDTSortManager;
import com.kingdee.bos.ctrl.kdf.table.KDTTreeColumn;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.util.style.StyleAttributes;
import com.kingdee.bos.ctrl.kdf.util.style.Styles.HorizontalAlignment;
import com.kingdee.bos.ctrl.swing.BasicFormattedTextField;
import com.kingdee.bos.ctrl.swing.DateTimeEditor;
import com.kingdee.bos.ctrl.swing.IKDComponent;
import com.kingdee.bos.ctrl.swing.IKDTextComponent;
import com.kingdee.bos.ctrl.swing.KDCheckBox;
import com.kingdee.bos.ctrl.swing.KDComboBox;
import com.kingdee.bos.ctrl.swing.KDContainer;
import com.kingdee.bos.ctrl.swing.KDDatePicker;
import com.kingdee.bos.ctrl.swing.KDFileChooser;
import com.kingdee.bos.ctrl.swing.KDFormattedTextField;
import com.kingdee.bos.ctrl.swing.KDLabelContainer;
import com.kingdee.bos.ctrl.swing.KDMenu;
import com.kingdee.bos.ctrl.swing.KDMenuBar;
import com.kingdee.bos.ctrl.swing.KDMenuItem;
import com.kingdee.bos.ctrl.swing.KDNumberTextField;
import com.kingdee.bos.ctrl.swing.KDPanel;
import com.kingdee.bos.ctrl.swing.KDPromptBox;
import com.kingdee.bos.ctrl.swing.KDPromptSelector;
import com.kingdee.bos.ctrl.swing.KDScrollPane;
import com.kingdee.bos.ctrl.swing.KDSpinner;
import com.kingdee.bos.ctrl.swing.KDSplitPane;
import com.kingdee.bos.ctrl.swing.KDTabbedPane;
import com.kingdee.bos.ctrl.swing.KDTextArea;
import com.kingdee.bos.ctrl.swing.KDTextField;
import com.kingdee.bos.ctrl.swing.KDToolBar;
import com.kingdee.bos.ctrl.swing.KDTree;
import com.kingdee.bos.ctrl.swing.KDWorkButton;
import com.kingdee.bos.ctrl.swing.event.CommitListener;
import com.kingdee.bos.ctrl.swing.event.DataChangeListener;
import com.kingdee.bos.ctrl.swing.event.SelectorListener;
import com.kingdee.bos.ctrl.swing.tree.DefaultKingdeeTreeNode;
import com.kingdee.bos.dao.DataAccessException;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.dao.query.IQueryExecutor;
import com.kingdee.bos.dao.query.ISQLExecutor;
import com.kingdee.bos.dao.query.QueryExecutorFactory;
import com.kingdee.bos.dao.query.SQLExecutorFactory;
import com.kingdee.bos.dao.xml.impl.MDLoader;
import com.kingdee.bos.framework.DynamicObjectFactory;
import com.kingdee.bos.framework.IDynamicObject;
import com.kingdee.bos.metadata.IMetaDataLoader;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.MetaDataClassLoader;
import com.kingdee.bos.metadata.MetaDataLoaderFactory;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.bot.BOTMappingFactory;
import com.kingdee.bos.metadata.bot.BOTMappingInfo;
import com.kingdee.bos.metadata.bot.BOTRelationCollection;
import com.kingdee.bos.metadata.bot.BOTRelationInfo;
import com.kingdee.bos.metadata.bot.DefineSysEnum;
import com.kingdee.bos.metadata.bot.IBOTMapping;
import com.kingdee.bos.metadata.data.ColumnInfo;
import com.kingdee.bos.metadata.data.DataTableInfo;
import com.kingdee.bos.metadata.entity.DataType;
import com.kingdee.bos.metadata.entity.EntityObjectInfo;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemCollection;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.PropertyCollection;
import com.kingdee.bos.metadata.entity.PropertyInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
import com.kingdee.bos.metadata.entity.SorterItemCollection;
import com.kingdee.bos.metadata.entity.SorterItemInfo;
import com.kingdee.bos.metadata.query.QueryFieldInfo;
import com.kingdee.bos.metadata.query.QueryInfo;
import com.kingdee.bos.metadata.query.SelectorInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.metadata.query.util.ConstDataType;
import com.kingdee.bos.sql.SqlTranslateException;
import com.kingdee.bos.sql.TransUtil;
import com.kingdee.bos.ui.face.AbstractUIFactory;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ui.face.IUIFactory;
import com.kingdee.bos.ui.face.IUIObject;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.ItemAction;
import com.kingdee.bos.ui.face.UIDialog;
import com.kingdee.bos.ui.face.UIException;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.bos.workflow.ProcessDefInfo;
import com.kingdee.bos.workflow.ProcessInstInfo;
import com.kingdee.bos.workflow.define.ProcessDef;
import com.kingdee.bos.workflow.monitor.client.BasicShowWfDefinePanel;
import com.kingdee.bos.workflow.monitor.client.BasicWorkFlowMonitorPanel;
import com.kingdee.bos.workflow.service.ormrpc.EnactmentServiceFactory;
import com.kingdee.bos.workflow.service.ormrpc.IEnactmentService;
import com.kingdee.eas.base.botp.BotpHelper;
import com.kingdee.eas.base.btp.BTPManagerFactory;
import com.kingdee.eas.base.btp.BTPTransformResult;
import com.kingdee.eas.base.btp.IBTPManager;
import com.kingdee.eas.base.codingrule.CodingRuleException;
import com.kingdee.eas.base.codingrule.CodingRuleManagerFactory;
import com.kingdee.eas.base.codingrule.ICodingRuleManager;
import com.kingdee.eas.base.core.Constants;
import com.kingdee.eas.base.core.fm.ContextHelperFactory;
import com.kingdee.eas.base.core.fm.IContextHelper;
import com.kingdee.eas.base.core.util.DateUtil;
import com.kingdee.eas.base.core.util.EmptyUtil;
import com.kingdee.eas.base.multiapprove.client.DesignateNextActivityPerformerUI;
import com.kingdee.eas.base.multiapprove.client.MultiApproveUtil;
import com.kingdee.eas.base.param.util.ParamManager;
import com.kingdee.eas.base.permission.IUser;
import com.kingdee.eas.base.permission.UserCollection;
import com.kingdee.eas.base.permission.UserFactory;
import com.kingdee.eas.base.permission.UserInfo;
import com.kingdee.eas.base.uiframe.client.UIFixTab;
import com.kingdee.eas.base.uiframe.client.UIModelDialogFactory;
import com.kingdee.eas.base.uiframe.client.UINewFrame;
import com.kingdee.eas.base.uiframe.client.UINewTab;
import com.kingdee.eas.basedata.assistant.AccountBankFactory;
import com.kingdee.eas.basedata.assistant.AccountBankInfo;
import com.kingdee.eas.basedata.assistant.BankFactory;
import com.kingdee.eas.basedata.assistant.BankInfo;
import com.kingdee.eas.basedata.assistant.CurrencyCollection;
import com.kingdee.eas.basedata.assistant.CurrencyFactory;
import com.kingdee.eas.basedata.assistant.CurrencyInfo;
import com.kingdee.eas.basedata.assistant.ExchangeAuxInfo;
import com.kingdee.eas.basedata.assistant.ExchangeRateFactory;
import com.kingdee.eas.basedata.assistant.ExchangeRateInfo;
import com.kingdee.eas.basedata.assistant.ExchangeTableInfo;
import com.kingdee.eas.basedata.assistant.IAccountBank;
import com.kingdee.eas.basedata.assistant.IBank;
import com.kingdee.eas.basedata.assistant.ICurrency;
import com.kingdee.eas.basedata.assistant.IExchangeRate;
import com.kingdee.eas.basedata.assistant.IPeriod;
import com.kingdee.eas.basedata.assistant.PeriodCollection;
import com.kingdee.eas.basedata.assistant.PeriodFactory;
import com.kingdee.eas.basedata.assistant.PeriodInfo;
import com.kingdee.eas.basedata.assistant.PeriodTypeInfo;
import com.kingdee.eas.basedata.assistant.PeriodUtils;
import com.kingdee.eas.basedata.assistant.SystemStatusCtrolUtils;
import com.kingdee.eas.basedata.master.account.AccountRefContrastCollection;
import com.kingdee.eas.basedata.master.account.AccountRefContrastFactory;
import com.kingdee.eas.basedata.master.account.AccountRefContrastInfo;
import com.kingdee.eas.basedata.master.account.AccountTableInfo;
import com.kingdee.eas.basedata.master.account.AccountTools;
import com.kingdee.eas.basedata.master.account.IAccountRefContrast;
import com.kingdee.eas.basedata.master.account.RefTypeEnum;
import com.kingdee.eas.basedata.master.cssp.CustomerFactory;
import com.kingdee.eas.basedata.master.cssp.client.F7CustomerTreeDetailListUI;
import com.kingdee.eas.basedata.org.CompanyOrgUnitCollection;
import com.kingdee.eas.basedata.org.CompanyOrgUnitFactory;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.eas.basedata.org.CtrlUnitInfo;
import com.kingdee.eas.basedata.org.FullOrgUnitInfo;
import com.kingdee.eas.basedata.org.ICompanyOrgUnit;
import com.kingdee.eas.basedata.org.INewOrgViewFacade;
import com.kingdee.eas.basedata.org.NewOrgUnitHelper;
import com.kingdee.eas.basedata.org.NewOrgViewFacadeFactory;
import com.kingdee.eas.basedata.org.NewOrgViewHelper;
import com.kingdee.eas.basedata.org.OrgStructureInfo;
import com.kingdee.eas.basedata.org.OrgType;
import com.kingdee.eas.basedata.org.OrgUnitInfo;
import com.kingdee.eas.basedata.org.client.OrgTreeF7PromptBox;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.fi.cas.IJournal;
import com.kingdee.eas.fi.cas.JournalFactory;
import com.kingdee.eas.fi.cas.JournalInfo;
import com.kingdee.eas.fi.cas.JournalTypeEnum;
import com.kingdee.eas.fi.cas.client.BankJournalListUI;
import com.kingdee.eas.fi.cas.client.CashClientHelper;
import com.kingdee.eas.fi.cas.client.RptCapitalSumMainUI;
import com.kingdee.eas.fi.gl.GlUtils;
import com.kingdee.eas.fi.gl.GlWebServiceUtil;
import com.kingdee.eas.fi.gl.IVoucher;
import com.kingdee.eas.fi.gl.IVoucherEntry;
import com.kingdee.eas.fi.gl.VoucherCollection;
import com.kingdee.eas.fi.gl.VoucherEntryCollection;
import com.kingdee.eas.fi.gl.VoucherEntryFactory;
import com.kingdee.eas.fi.gl.VoucherEntryInfo;
import com.kingdee.eas.fi.gl.VoucherFactory;
import com.kingdee.eas.fi.gl.VoucherInfo;
import com.kingdee.eas.fi.gl.client.RptMultiColumnDesignUI;
import com.kingdee.eas.fm.be.BankFacadeFactory;
import com.kingdee.eas.fm.be.IBankFacade;
import com.kingdee.eas.fm.common.EJBAccessFactory;
import com.kingdee.eas.fm.common.FMBgItemProp;
import com.kingdee.eas.fm.common.FMCommonFacadeFactory;
import com.kingdee.eas.fm.common.FMException;
import com.kingdee.eas.fm.common.FMHelper;
import com.kingdee.eas.fm.common.FmRpcCacheInfo;
import com.kingdee.eas.fm.common.IEJBAccess;
import com.kingdee.eas.fm.common.IFMCommonFacade;
import com.kingdee.eas.fm.common.util.ReadFileInfoHelper;
import com.kingdee.eas.fm.fs.ISettleFacade;
import com.kingdee.eas.fm.fs.ISettlementBill;
import com.kingdee.eas.fm.fs.SettleFacadeFactory;
import com.kingdee.eas.fm.fs.SettlementBillCollection;
import com.kingdee.eas.fm.fs.SettlementBillFactory;
import com.kingdee.eas.fm.fs.SettlementBillInfo;
import com.kingdee.eas.fm.fs.SettlementBillRpcCacheInfo;
import com.kingdee.eas.fm.fs.SettmentBatchInfo;
import com.kingdee.eas.fm.fs.client.SettlementBillListUI;
import com.kingdee.eas.fm.im.AccrualBillInfo;
import com.kingdee.eas.fm.im.client.AccrualBillAcceptListUI;
import com.kingdee.eas.fm.im.client.AccrualBillListUI;
import com.kingdee.eas.fm.nt.ChequeFactory;
import com.kingdee.eas.fm.nt.ChequeInfo;
import com.kingdee.eas.fm.nt.ICheque;
import com.kingdee.eas.fm.nt.NTTypeGroupEnum;
import com.kingdee.eas.fm.nt.NTTypeInfo;
import com.kingdee.eas.fm.nt.client.IBotEditUI;
import com.kingdee.eas.fm.nt.client.TeleOrderApplyUI;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.CoreBillBaseCollection;
import com.kingdee.eas.framework.CoreBillBaseInfo;
import com.kingdee.eas.framework.DeletedStatusEnum;
import com.kingdee.eas.framework.FrameWorkUtils;
import com.kingdee.eas.framework.SystemEnum;
import com.kingdee.eas.framework.client.CoreBillEditUI;
import com.kingdee.eas.framework.client.CoreBillListUI;
import com.kingdee.eas.framework.client.CoreUI;
import com.kingdee.eas.framework.client.EditUI;
import com.kingdee.eas.framework.client.IIDList;
import com.kingdee.eas.framework.client.ListUI;
import com.kingdee.eas.framework.client.RealModeIDList;
import com.kingdee.eas.framework.config.TablePreferencesHelper;
import com.kingdee.eas.ma.bg.BgCycleTypeEnum;
import com.kingdee.eas.ma.bg.BgEntryCollection;
import com.kingdee.eas.ma.bg.BgEntryInfo;
import com.kingdee.eas.ma.bg.BgItemInfo;
import com.kingdee.eas.ma.bg.BgPeriodNode;
import com.kingdee.eas.ma.bg.BgTypeInfo;
import com.kingdee.eas.ma.budget.BgControlFacadeFactory;
import com.kingdee.eas.ma.budget.BgCtrlParamCollection;
import com.kingdee.eas.ma.budget.BgCtrlResultCollection;
import com.kingdee.eas.ma.budget.BudgetCtrlFacadeFactory;
import com.kingdee.eas.ma.budget.FpCashDirectionEnum;
import com.kingdee.eas.ma.budget.IBgControlFacade;
import com.kingdee.eas.ma.budget.IBudgetCtrlFacade;
import com.kingdee.eas.ma.budget.VisualItemInfo;
import com.kingdee.eas.ma.budget.client.BgBalanceViewUI;
import com.kingdee.eas.ma.budget.client.BgItemForFpDialog;
import com.kingdee.eas.ma.budget.client.NewBgItemDialog;
import com.kingdee.eas.scm.common.client.GeneralKDPromptSelectorAdaptor;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.util.DateTimeUtils;
import com.kingdee.util.StringUtils;
import com.kingdee.util.TypeConversionUtils;
import com.kingdee.util.UuidException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.EventListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JToolBar.Separator;
import javax.swing.KeyStroke;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.AncestorListener;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import org.apache.log4j.Logger;

public final class FMClientHelper
{
  public static final Color KDTABLE_TOTAL_BG_COLOR = new Color(16185014);

  public static final Color KDTABLE_SUBTOTAL_BG_COLOR = new Color(16119270);
  public static final String KDTABLE_NUMBER_FTM = "%-.2n";
  public static final String KDTABLE_PERCENT_FTM = "%r{0.00}p";
  public static final String KDTABLE_DATE_FMT = "%{yyyy-MM-dd}t";
  public static final String ACTUAL_DIGIT_FMT = "#,##0.###########";
  public static final HashMap mapPrecOfCurrency = new HashMap(32);

  private static final Map mapPrecOfExRate = new HashMap(32);
  public static final int SUBTOTAL = 16119270;
  public static final int TOTAL = 16185014;
  public static final int PASTRECORD = 16771687;
  public static final String RES = "com.kingdee.eas.fm.common.client.FMCommonClientResource";
  public static final int DEFAULT_EXCHANGERATE_PREC = 3;
  public static final BigDecimal MAX_VALUE = new BigDecimal("9999999999999");

  public static String FMT_AMT = getNumberFtm(true, 2, 10);

  public static String FMT_EXCHANGE = getNumberFtm(false, 4, 10);

  public static String FMT_QTY = getNumberFtm(false, 4, 10);

  public static String FMT_PRICE = getNumberFtm(true, 4, 10);

  private static Logger logger = Logger.getLogger(FMClientHelper.class.getName());

  private static final Map exRateMap = new HashMap();

  private static final Map companyMap = new HashMap();

  public static void checkMoreThanMax(KDFormattedTextField checkedComp, KDLabelContainer prmtComp)
  {
    if (null == checkedComp.getBigDecimalValue()) {
      return;
    }
    if (checkedComp.getBigDecimalValue().compareTo(MAX_VALUE) > 0) {
      checkedComp.setValue(Constants.ZERO);
      MsgBox.showInfo(checkedComp.getBoundLabelText() + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "134_FMClientHelper") + prmtComp.getBoundLabelText());
      SysUtil.abort();
    }
  }

  public static String getNumberFtm(BOSUuid currencyId)
  {
    int preCurrency = getPrecOfCurrency(currencyId);
    StringBuffer numberFormate = new StringBuffer("##,###,###,###,###,##0.");
    for (int i = 0; i < preCurrency; i++) {
      numberFormate.append("0");
    }
    return numberFormate.toString();
  }

  public static String getNumberFtm(int precision)
  {
    StringBuffer numberFormate = new StringBuffer("##,###,###,###,###,##0");
    if (precision > 0) {
      numberFormate.append(".");
    }
    for (int i = 0; i < precision; i++) {
      numberFormate.append("0");
    }
    return numberFormate.toString();
  }

  public static String getNumberFtm() {
    return "%r-[ ]{###,###,###.##}15.2n";
  }

  public static String getNumberFtm(boolean needSplit3, int fixDisp, int maxPrecision)
  {
    if (maxPrecision < fixDisp) {
      return null;
    }
    String pre = needSplit3 ? "###,###,###,###,##0." : "##############0.";
    boolean isFixDispOver = false;
    String pos = "";
    int i = 1; for (int n = maxPrecision; i <= n; i++) {
      isFixDispOver = i > fixDisp;
      if (!isFixDispOver)
        pos = pos + "0";
      else {
        pos = pos + "#";
      }
    }
    return pre + pos;
  }

  public static int getLocalCurPre() {
    int pre = 0;
    Iterator iter = mapPrecOfCurrency.values().iterator();
    while (iter.hasNext()) {
      Integer currencyPre = (Integer)iter.next();
      if (currencyPre.intValue() > pre) {
        pre = currencyPre.intValue();
      }
    }
    return pre;
  }

  public static int getPrecOfCurrency(BOSUuid currencyId) {
    if (mapPrecOfCurrency.size() == 0) {
      setPrecOfCurrenty(mapPrecOfCurrency);
    }

    if (!mapPrecOfCurrency.containsKey(currencyId)) {
      CurrencyInfo info = getCurrencyInfo(currencyId);
      if (info != null) {
        mapPrecOfCurrency.put(info.getId(), new Integer(info.getPrecision()));

        return info.getPrecision();
      }
      return 10;
    }

    return ((Integer)mapPrecOfCurrency.get(currencyId)).intValue();
  }

  public static CurrencyInfo getCurrencyInfo(BOSUuid id) {
    IObjectPK pk = new ObjectUuidPK(id);

    CurrencyInfo info = null;
    try {
      ICurrency iCurrency = CurrencyFactory.getRemoteInstance();
      info = iCurrency.getCurrencyInfo(pk);
    } catch (BOSException e) {
      e.printStackTrace();
    } catch (EASBizException e) {
      e.printStackTrace();
    }
    return info;
  }

  private static void setPrecOfCurrenty(HashMap map) {
    String str = "select fid,fprecision from t_bd_currency";
    ISQLExecutor sqlExe = SQLExecutorFactory.getRemoteInstance(str);
    IRowSet rs = null;
    try
    {
      rs = sqlExe.executeSQL();

      while (rs.next())
        map.put(BOSUuid.read(rs.getString(1)), new Integer(rs.getInt(2)));
    }
    catch (BOSException bose)
    {
      return;
    } catch (SQLException sqle) {
      return;
    }
  }

  public static void initOrgF7(BgTypeInfo bgTypeInfo, KDBizPromptBox bizPromptOrgUnit)
  {
    initOrgF7(bgTypeInfo, bizPromptOrgUnit, false);
  }

  public static void initOrgF7(BgTypeInfo bgTypeInfo, KDBizPromptBox bizPromptOrgUnit, boolean isMultiChoose)
  {
    bizPromptOrgUnit.setData(null);
    bizPromptOrgUnit.setEnabled(true);
    bizPromptOrgUnit.setEnabledMultiSelection(isMultiChoose);

    OrgType[] orgType = { OrgType.Company };
    OrgTreeF7PromptBox box = new OrgTreeF7PromptBox(null, orgType);

    bizPromptOrgUnit.setEditFormat("$name$");
    bizPromptOrgUnit.setDisplayFormat("$name$");
    bizPromptOrgUnit.setSelector(box);
    box.show();
  }

  public static DefaultKingdeeTreeNode getPeriodTreeRoot(BgEntryCollection bgEntries)
  {
    DefaultKingdeeTreeNode root = new DefaultKingdeeTreeNode();

    Iterator iter = bgEntries.iterator();
    BgEntryInfo bgEntryInfo;
    while (iter.hasNext()) {
      bgEntryInfo = (BgEntryInfo)iter.next();
    }

    return root;
  }

  public static DefaultKingdeeTreeNode getPeriodTreeRoot(Vector vector)
  {
    DefaultKingdeeTreeNode root = new DefaultKingdeeTreeNode();
    DefaultKingdeeTreeNode yearRoot = null;
    DefaultKingdeeTreeNode seasonRoot = null;

    for (int i = 0; i < vector.size(); i++) {
      BgPeriodNode tmpBgPeriodNode = (BgPeriodNode)vector.get(i);
      DefaultKingdeeTreeNode tmpTreeNode = new DefaultKingdeeTreeNode(tmpBgPeriodNode);

      if (tmpBgPeriodNode.getBgCycle().equals(BgCycleTypeEnum.Year)) {
        root.add(tmpTreeNode);
        yearRoot = tmpTreeNode;
      } else if (tmpBgPeriodNode.getBgCycle().equals(BgCycleTypeEnum.Season))
      {
        yearRoot.add(tmpTreeNode);
        seasonRoot = tmpTreeNode; } else {
        if (!tmpBgPeriodNode.getBgCycle().equals(BgCycleTypeEnum.Period))
          continue;
        seasonRoot.add(tmpTreeNode);
      }
    }

    return root;
  }

  public static BgPeriodNode getCurrentBgPeriodNode(KDTree treeBgPeriod)
  {
    DefaultKingdeeTreeNode node = (DefaultKingdeeTreeNode)treeBgPeriod.getLastSelectedPathComponent();

    if (node == null) {
      return null;
    }

    if (node.getUserObject() == null) {
      return null;
    }

    return (BgPeriodNode)node.getUserObject();
  }

  public static BgPeriodNode getEndBgPeriodNode(KDTree treeBgPeriod)
  {
    DefaultKingdeeTreeNode node = (DefaultKingdeeTreeNode)treeBgPeriod.getPathForRow(treeBgPeriod.getRowCount() - 1).getLastPathComponent();

    if (node == null) {
      return null;
    }

    if (node.getUserObject() == null) {
      return null;
    }

    return (BgPeriodNode)node.getUserObject();
  }

  public static void clearTable(KDTable kdTable)
  {
    kdTable.removeHeadRows();
    kdTable.removeRows();
    kdTable.removeColumns();
  }

  public static void treeFormTable(KDTable kdTable)
  {
    kdTable.getTreeColumn().setOrientation(0);

    int maxDepth = 0;

    for (int i = 0; i < kdTable.getRowCount(); i++) {
      BgItemInfo bgItemInfo = (BgItemInfo)kdTable.getRow(i).getCell(0).getValue();

      if (bgItemInfo == null) {
        return;
      }

      if (bgItemInfo.getLongNumber() != null) {
        int depth = StringUtils.occurencesOf(bgItemInfo.getItemNumber(), '.');

        kdTable.getRow(i).setTreeLevel(depth);

        if (maxDepth < depth) {
          maxDepth = depth;
        }
      }
    }

    kdTable.getTreeColumn().setDepth(maxDepth);
  }

  /** @deprecated */
  public static void setSelectObject(KDComboBox cbo, Object anObject)
  {
    if (CoreBaseInfo.class.isInstance(anObject)) {
      CoreBaseInfo newObject = (CoreBaseInfo)anObject;

      for (int i = 0; i < cbo.getItemCount(); i++) {
        Object obj = cbo.getItemAt(i);

        if ((obj instanceof CoreBaseInfo)) {
          CoreBaseInfo info = (CoreBaseInfo)cbo.getItemAt(i);
          if (obj == null) {
            continue;
          }
          if (newObject.getId().equals(info.getId())) {
            cbo.setSelectedIndex(i);
            break;
          }
        }
      }
    } else {
      cbo.setSelectedItem(anObject);
    }
  }

  public static void setSelectObject(KDComboBox cbo, Object anObject, boolean notifyEvent)
  {
    if (notifyEvent) {
      setSelectObject(cbo, anObject);
      return;
    }

    ActionListener[] l = cbo.getActionListeners();
    int i = 0; for (int n = l.length; i < n; i++) {
      cbo.removeActionListener(l[i]);
    }

    ItemListener[] itemListener = cbo.getItemListeners();
    int i = 0; for (int n = itemListener.length; i < n; i++)
      cbo.removeItemListener(itemListener[i]);
    try
    {
      setSelectObject(cbo, anObject);
    }
    finally {
      int i = 0; for (int n = l.length; i < n; i++) {
        cbo.addActionListener(l[i]);
        cbo.addItemListener(itemListener[i]);
      }
      int i = 0; for (int n = itemListener.length; i < n; i++)
        cbo.addItemListener(itemListener[i]);
    }
  }

  public static Set getSelectedRows(KDTable table)
  {
    ArrayList arrayList = table.getSelectManager().getBlocks();

    TreeSet set = new TreeSet();

    int i = 0; for (int size = arrayList.size(); i < size; i++)
    {
      KDTBlock block = (KDTBlock)arrayList.get(i);

      int top = block.getTop();
      int bottom = block.getBottom();

      for (int j = top; j <= bottom; j++) {
        Integer theInteger = new Integer(j);
        set.add(theInteger);
      }
    }

    return set;
  }

  public static int getSelectedRow(KDTable table)
  {
    KDTSelectBlock selectBlock = table.getSelectManager().get();

    if (selectBlock == null) {
      return -1;
    }

    return selectBlock.getTop();
  }

  public static boolean verifyTooBigger(String value, double target)
  {
    boolean result = false;
    try
    {
      double big = Double.parseDouble(value);

      if (big >= target)
        result = true;
    }
    catch (NumberFormatException e) {
      result = true;
    }

    return result;
  }

  public static boolean verifyIsNumber(String value)
  {
    boolean result = true;
    try
    {
      new BigDecimal(value);
    } catch (NumberFormatException e) {
      result = false;
    }

    return result;
  }

  public static boolean verifyIsInteger(String value)
  {
    boolean result = true;
    try
    {
      big = Integer.parseInt(value);
    }
    catch (NumberFormatException e)
    {
      int big;
      result = false;
    }

    return result;
  }

  public static boolean verifyIsPlus(String value)
    throws NumberFormatException
  {
    boolean result = true;
    float big = Float.parseFloat(value);

    if (big <= 0.0F) {
      result = false;
    }

    return result;
  }

  public static boolean verifyIsPlus1(String value)
    throws NumberFormatException
  {
    boolean result = true;
    float big = Float.parseFloat(value);

    if (big < 0.0F) {
      result = false;
    }

    return result;
  }

  public static DecimalFormat getDecimalFormat()
  {
    DecimalFormat format = new DecimalFormat("#.##");
    format.setMaximumFractionDigits(2);
    format.setMinimumFractionDigits(2);

    return format;
  }

  public static DecimalFormat getDecimalFormat(int length)
  {
    DecimalFormat format = new DecimalFormat("#.##");

    if (length == 3)
      format = new DecimalFormat("#.###");
    else if (length == 4) {
      format = new DecimalFormat("#.####");
    }

    format.setMaximumFractionDigits(length);
    format.setMinimumFractionDigits(length);

    return format;
  }

  public static boolean isModifiable(CoreBaseInfo info, String companyId)
  {
    boolean result = false;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();
      result = codingRuleManager.isModifiable(info, companyId);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return result;
  }

  public static boolean isAddView(CoreBaseInfo info, String companyId)
  {
    boolean rst = hasNumber(info, companyId);
    if (rst == true)
      try
      {
        ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();
        return codingRuleManager.isAddView(info, companyId);
      } catch (BOSException e) {
      } catch (CodingRuleException e) {
      }
      catch (EASBizException e) {
      }
    return false;
  }

  public static void initNumber(CoreBaseInfo info, KDTextField txtField, String companyId)
  {
    if (!EmptyUtil.isEmpty(info.getString("number"))) {
      txtField.setEnabled(false);
      return;
    }
    boolean rst = hasNumber(info, companyId);

    if (rst)
    {
      txtField.setEditable(false);
      txtField.setEnabled(false);
      txtField.setRequired(false);
      String number = getDispNumber(info, companyId);
      if (!EmptyUtil.isEmpty(number)) {
        info.setString("number", number);
        txtField.setText(number);
      }

      if (isModifiable(info, companyId)) {
        txtField.setEditable(true);
        txtField.setEnabled(true);
        txtField.setRequired(true);
      }
    }
    else
    {
      txtField.setEnabled(true);
      txtField.setEditable(true);
      txtField.setRequired(true);
    }
  }

  public static void initNumber(CoreBaseInfo info, KDTextField txtField, String companyId, String bindingproperty)
  {
    if (!FMHelper.isEmpty(info.getString("number"))) {
      txtField.setEnabled(false);
      return;
    }
    boolean rst = false;
    String number = null;
    if (hasNumber(info, companyId)) {
      number = getDispNumber(info, companyId);
      rst = true;
    } else if (hasNumber(info, companyId, bindingproperty)) {
      number = getDispNumber(info, companyId, bindingproperty);
      rst = true;
    }

    if (rst)
    {
      txtField.setEditable(false);
      txtField.setEnabled(false);
      txtField.setRequired(false);
      if (!FMHelper.isEmpty(number)) {
        info.setString("number", number);
        txtField.setText(number);
      }

      if (isModifiable(info, companyId)) {
        txtField.setEditable(true);
        txtField.setEnabled(true);
        txtField.setRequired(true);
      }
    }
    else
    {
      txtField.setEnabled(true);
      txtField.setEditable(true);
      txtField.setRequired(true);
    }
  }

  public static void initNumber(CoreBaseInfo info, KDTextField txtField, String companyId, FmRpcCacheInfo rpcCacheInfo)
  {
    if (rpcCacheInfo != null)
    {
      if (!FMHelper.isEmpty(info.getString("number"))) {
        txtField.setEnabled(false);
        return;
      }

      if (rpcCacheInfo.isHasCodeRule())
      {
        String number = rpcCacheInfo.getNumber();
        info.setString("number", number);
        txtField.setText(number);

        txtField.setEditable(rpcCacheInfo.isModifiable());
        txtField.setEnabled(rpcCacheInfo.isModifiable());
        txtField.setRequired(rpcCacheInfo.isModifiable());
      }
      else
      {
        txtField.setEnabled(true);
        txtField.setEditable(true);
        txtField.setRequired(true);
      }
    } else {
      initNumber(info, txtField, companyId);
    }
  }

  public static void initReadNumber(CoreBaseInfo info, KDTextField txtField, String companyId)
  {
    if (!FMHelper.isEmpty(info.getString("number"))) {
      txtField.setEnabled(false);
      return;
    }
    boolean rst = hasNumber(info, companyId);

    if (rst)
    {
      txtField.setEditable(false);
      txtField.setEnabled(false);
      txtField.setRequired(false);
      String number = readDispNumber(info, companyId);
      if (!FMHelper.isEmpty(number)) {
        info.setString("number", number);
        txtField.setText(number);
      }
    }
    else {
      txtField.setEnabled(true);
      txtField.setEditable(true);
      txtField.setRequired(true);
    }
  }

  private static String readDispNumber(CoreBaseInfo info, String companyId)
  {
    String number = null;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();
      if ((codingRuleManager.isAddView(info, companyId)) && (!codingRuleManager.isUseIntermitNumber(info, companyId)))
      {
        number = codingRuleManager.readNumber(info, companyId);
      }
    } catch (BOSException e) {
    } catch (CodingRuleException e) {
    }
    catch (EASBizException e) {
    }
    return number;
  }

  public static String getDispNumber(CoreBaseInfo info, String companyId)
  {
    String number = null;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();
      if ((codingRuleManager.isAddView(info, companyId)) && (!codingRuleManager.isUseIntermitNumber(info, companyId)))
      {
        number = codingRuleManager.getNumber(info, companyId);
      }
    } catch (BOSException e) {
    } catch (CodingRuleException e) {
    }
    catch (EASBizException e) {
    }
    return number;
  }

  private static String getDispNumber(CoreBaseInfo info, String companyId, String bindingproperty)
  {
    String number = null;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();
      if ((codingRuleManager.isAddView(info, companyId, bindingproperty)) && (!codingRuleManager.isUseIntermitNumber(info, companyId, bindingproperty)))
      {
        number = codingRuleManager.getNumber(info, companyId, bindingproperty, "");
      }
    } catch (BOSException e) {
    }
    catch (CodingRuleException e) {
    }
    catch (EASBizException e) {
    }
    return number;
  }

  public static void initNumber(CoreBaseInfo info, IColumn col, String companyId)
  {
    boolean rst = hasNumber(info, companyId);

    if (!rst)
    {
      col.getStyleAttributes().setLocked(false);
    }
    else
    {
      col.getStyleAttributes().setLocked(true);
      col.getStyleAttributes().setBackground(Color.LIGHT_GRAY);
    }
  }

  public static boolean hasNumber(CoreBaseInfo info, String companyId)
  {
    if ((info == null) || (companyId == null) || (companyId.equals(""))) {
      return false;
    }

    boolean result = false;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();

      result = codingRuleManager.isExist(info, companyId);
    }
    catch (Exception e)
    {
    }

    return result;
  }

  public static boolean hasNumber(CoreBaseInfo info, String companyId, String bindingproperty)
  {
    if ((info == null) || (companyId == null) || (companyId.equals(""))) {
      return false;
    }

    boolean result = false;
    try
    {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();

      result = codingRuleManager.isExist(info, companyId, bindingproperty);
    }
    catch (Exception e)
    {
    }

    return result;
  }

  private static String getNumber(CoreBaseInfo info, String companyId)
  {
    if ((info == null) || (companyId == null) || (companyId.equals(""))) {
      return null;
    }

    String result = null;
    try {
      ICodingRuleManager codingRuleManager = CodingRuleManagerFactory.getRemoteInstance();

      result = codingRuleManager.getNumber(info, companyId);
    } catch (Exception e) {
      result = null;
      e.printStackTrace();
    }
    if ((result != null) && (result.equals(""))) {
      result = null;
    }
    return result;
  }

  public static void initSpinAfterNow(KDSpinner spnBeginYear, KDSpinner spnBeginMonth, KDSpinner spnEndYear, KDSpinner spnEndMonth)
  {
    Calendar instance = Calendar.getInstance();
    int thisYear = instance.get(1);
    SpinnerNumberModel yModel = new SpinnerNumberModel(thisYear, thisYear, 2999, 1);

    spnBeginYear.setModel(yModel);

    SpinnerNumberModel yModel1 = new SpinnerNumberModel(thisYear, thisYear, 2999, 1);

    spnEndYear.setModel(yModel1);
    int thisMonth = instance.get(2) + 1;

    SpinnerNumberModel mModel = new SpinnerNumberModel(thisMonth, 1, 12, 1);
    spnBeginMonth.setModel(mModel);

    SpinnerNumberModel mModel1 = new SpinnerNumberModel(thisMonth, 1, 12, 1);
    spnEndMonth.setModel(mModel1);
  }

  public static void initSpinFromTO(KDSpinner spnBeginYear, KDSpinner spnBeginMonth, KDSpinner spnEndYear, KDSpinner spnEndMonth)
  {
    Calendar instance = Calendar.getInstance();
    int thisYear = instance.get(1);
    SpinnerNumberModel yModel = new SpinnerNumberModel(thisYear, 2000, 2999, 1);

    spnBeginYear.setModel(yModel);

    SpinnerNumberModel yModel1 = new SpinnerNumberModel(thisYear, 2000, 2999, 1);

    spnEndYear.setModel(yModel1);

    int thisMonth = instance.get(2) + 1;

    SpinnerNumberModel mModel = new SpinnerNumberModel(thisMonth, 1, 12, 1);
    spnBeginMonth.setModel(mModel);

    SpinnerNumberModel mModel1 = new SpinnerNumberModel(thisMonth, 1, 12, 1);
    spnEndMonth.setModel(mModel1);
  }

  /** @deprecated */
  public static void clearTree(KDTree tree)
  {
    if ((tree == null) || (tree.getModel() == null)) {
      return;
    }

    tree.removeAllChildrenFromParent((MutableTreeNode)tree.getModel().getRoot());
  }

  public static void initCurrency(KDComboBox cbo)
    throws BOSException, EASBizException
  {
    ICurrency iCurrency = CurrencyFactory.getRemoteInstance();
    CurrencyCollection currencyCollection = iCurrency.getCurrencyCollection(true);

    FMHelper.sortCollection(currencyCollection, new String[] { "number" });

    cbo.removeAllItems();
    cbo.addItems(currencyCollection.toArray());
  }

  public static void initCurrency(KDComboBox cbo, CurrencyCollection currencyCollection)
  {
    FMHelper.sortCollection(currencyCollection, new String[] { "number" });

    if ((cbo.getActionListeners() != null) && (cbo.getActionListeners().length > 0))
    {
      ActionListener actionTmp = cbo.getActionListeners()[0];
      cbo.removeActionListener(cbo.getActionListeners()[0]);
      cbo.removeAllItems();
      cbo.addItems(currencyCollection.toArray());
      cbo.addActionListener(actionTmp);
    } else {
      cbo.removeAllItems();
      cbo.addItems(currencyCollection.toArray());
    }
  }

  public static List getAllSelectedRow(KDTable tblMain)
  {
    List selectBlocks = tblMain.getSelectManager().getBlocks();
    KDTSelectBlock selectBlock = null;
    List rowList = new ArrayList();

    for (int i = 0; i < selectBlocks.size(); i++) {
      selectBlock = (KDTSelectBlock)selectBlocks.get(i);

      for (int j = selectBlock.getTop(); j <= selectBlock.getBottom(); j++) {
        IRow row = tblMain.getRow(j);
        rowList.add(row);
      }
    }

    return rowList;
  }

  public static void suiteWidth(KDTable tbl, int k)
  {
    int width = 0;

    for (int i = 0; i < tbl.getColumnCount(); i++) {
      if (i != k) {
        width += tbl.getColumn(i).getWidth();
      }
    }

    tbl.getColumn(k).setWidth(tbl.getWidth() - width);
  }

  public static void suiteWidth(KDTable tbl, int tblWidth, int k) {
    int width = 0;

    for (int i = 0; i < tbl.getColumnCount(); i++) {
      if (i != k) {
        width += tbl.getColumn(i).getWidth();
      }
    }

    tbl.getColumn(k).setWidth(tblWidth - width);
  }

  public static DefaultKingdeeTreeNode goLeaf(KDTree tree)
  {
    TreeModel model = tree.getModel();

    if (model == null) {
      return null;
    }

    Object objNode = model.getRoot();

    while (tree.getModel().getChildCount(objNode) > 0) {
      objNode = tree.getModel().getChild(objNode, 0);
    }
    tree.setSelectionNode((DefaultKingdeeTreeNode)objNode);
    return (DefaultKingdeeTreeNode)objNode;
  }

  public static void goCurrentOrgNode(KDTree tree)
  {
    TreeModel model = tree.getModel();
    if (model == null) {
      return;
    }
    IContextHelper ctxHelper = ContextHelperFactory.getRemoteInstance();
    BOSUuid currOrgId = ctxHelper.getCurrentCompany().getId();
    goOrgViewNode(tree, currOrgId);
  }

  public static void goOrgViewNode(KDTree tree, BOSUuid currOrgId)
  {
    int i = 0; for (int height = tree.getRowCount(); i < height; i++) {
      TreePath tp = tree.getPathForRow(i);
      if (tp == null) {
        continue;
      }
      DefaultKingdeeTreeNode tn = (DefaultKingdeeTreeNode)tp.getLastPathComponent();

      OrgStructureInfo orgViewInfo = (OrgStructureInfo)tn.getUserObject();

      if (orgViewInfo.getId().equals(currOrgId)) {
        tree.setSelectionNode(tn);
        return;
      }
    }

    int i = 0; for (int height = tree.getRowCount(); i < height; i++) {
      TreePath tp = tree.getPathForRow(i);
      if (tp == null) {
        continue;
      }
      DefaultKingdeeTreeNode tn = (DefaultKingdeeTreeNode)tp.getLastPathComponent();

      OrgStructureInfo orgViewInfo = (OrgStructureInfo)tn.getUserObject();

      if (orgViewInfo != null) {
        tree.setSelectionNode(tn);
        return;
      }
    }
  }

  public static KDTDefaultCellEditor getCurrencyEditor(int prec)
  {
    KDFormattedTextField currencyTxtFiled = new KDFormattedTextField();
    currencyTxtFiled.setDataType(1);
    currencyTxtFiled.setPrecision(prec);
    KDTDefaultCellEditor cellEditor = new KDTDefaultCellEditor(currencyTxtFiled);

    return cellEditor;
  }

  public static KDTDefaultCellEditor getNumberEditor() {
    KDNumberTextField numberTextField = new KDNumberTextField();
    numberTextField.setDataType(6);
    KDTDefaultCellEditor cellEditor = new KDTDefaultCellEditor(numberTextField);

    return cellEditor;
  }

  public static DefaultTreeModel getCompanyTreeModel(boolean isContainSealUp)
    throws EASBizException, BOSException
  {
    INewOrgViewFacade iNewOrgView = null;
    iNewOrgView = NewOrgViewFacadeFactory.getRemoteInstance();

    IRowSet rows = iNewOrgView.buildViewRowSet("00000000-0000-0000-0000-0000000000024F2827FD", "00000000-0000-0000-0000-000000000000CCE7AED4", isContainSealUp);

    DefaultKingdeeTreeNode root = NewOrgViewHelper.buildTreeByRowSet(rows);

    return new DefaultTreeModel(root);
  }

  public static CompanyOrgUnitCollection getCompanyCollection(String[] companyId)
    throws BOSException
  {
    return getCompanyOrgUnitCollection(companyId);
  }

  public static void initComboCurrency(KDComboBox comboCurrency, boolean isSelBaseCurr)
    throws EASBizException, BOSException
  {
    ICurrency iCurrency = CurrencyFactory.getRemoteInstance();
    CurrencyCollection currencyCollection = iCurrency.getCurrencyCollection(true);

    initComboCurrency(comboCurrency, currencyCollection, isSelBaseCurr);
  }

  public static void initComboCurrency(KDComboBox comboCurrency)
    throws EASBizException, BOSException
  {
    initComboCurrency(comboCurrency, false);
  }

  public static void initComboCurrency(KDComboBox comboCurrency, CurrencyCollection currencyCollection, boolean isSelBaseCurr)
    throws EASBizException, BOSException
  {
    FMHelper.sortCollection(currencyCollection, new String[] { "number" });

    comboCurrency.removeAllItems();
    comboCurrency.addItems(currencyCollection.toArray());
    if (isSelBaseCurr) {
      CompanyOrgUnitInfo company = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      CurrencyInfo currency = getBaseCurrency(company);
      setSelectObject(comboCurrency, currency);
    }
  }

  public static void initComboCurrency(KDComboBox comboCurrency, boolean isSelBaseCurr, boolean isExcludeClosed)
    throws EASBizException, BOSException
  {
    ICurrency iCurrency = CurrencyFactory.getRemoteInstance();
    CurrencyCollection currencyCollection = iCurrency.getCurrencyCollection(true);

    initComboCurrency(comboCurrency, currencyCollection, isSelBaseCurr, isExcludeClosed);
  }

  public static void initComboCurrency(KDComboBox comboCurrency, CurrencyCollection currencyCollection, boolean isSelBaseCurr, boolean isExcludeClosed)
    throws EASBizException, BOSException
  {
    if (isExcludeClosed)
      comboCurrency.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
          try {
            if (e.getStateChange() == 1)
              return;
            KDComboBox source = (KDComboBox)e.getSource();
            Object selectedItem = source.getSelectedItem();
            if ((selectedItem != null) && ((selectedItem instanceof CurrencyInfo))) {
              CurrencyInfo currency = (CurrencyInfo)selectedItem;
              if (DeletedStatusEnum.DELETED.equals(currency.getDeletedStatus())) {
                source.setSelectedItem(e.getItem());
                MsgBox.showInfo(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "17_FMClientHelper"));
              }
            }
          }
          catch (Exception exc) {
            exc.printStackTrace();
            SysUtil.abort(exc);
          }
          finally
          {
          }
        }
      });
    FMHelper.sortCollection(currencyCollection, new String[] { "number" });

    comboCurrency.removeAllItems();
    comboCurrency.addItems(currencyCollection.toArray());

    if (isSelBaseCurr) {
      CompanyOrgUnitInfo company = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      CurrencyInfo currency = getBaseCurrency(company);
      setSelectObject(comboCurrency, currency);
    }
  }

  public static void initComboCurrency(KDComboBox comboCurrency, boolean isSelBaseCurr, String oprtState)
    throws EASBizException, BOSException
  {
    boolean isExcludeClosed = false;
    if ((FMHelper.isEmpty(oprtState)) || (oprtState.equals(OprtState.VIEW)) || (oprtState.equals("FINDVIEW")))
    {
      isExcludeClosed = false;
    }
    else if ((oprtState.equals(OprtState.ADDNEW)) || (oprtState.equals(OprtState.EDIT)))
    {
      isExcludeClosed = true;
    }
    else {
      isExcludeClosed = true;
    }

    initComboCurrency(comboCurrency, isSelBaseCurr, isExcludeClosed);
  }

  public static void initComboCurrency(KDComboBox comboCurrency, CurrencyCollection currencyCollection, boolean isSelBaseCurr, String oprtState)
    throws EASBizException, BOSException
  {
    boolean isExcludeClosed = false;
    if ((FMHelper.isEmpty(oprtState)) || (oprtState.equals(OprtState.VIEW)) || (oprtState.equals("FINDVIEW")))
    {
      isExcludeClosed = false;
    }
    else if ((oprtState.equals(OprtState.ADDNEW)) || (oprtState.equals(OprtState.EDIT)))
    {
      isExcludeClosed = true;
    }
    else {
      isExcludeClosed = true;
    }

    initComboCurrency(comboCurrency, currencyCollection, isSelBaseCurr, isExcludeClosed);
  }

  public static void initCurrencyComboBox(KDComboBox comboCurrency, CurrencyCollection currencyColl, boolean isSelBaseCurr, String oprtState)
    throws EASBizException, BOSException
  {
    ActionListener[] l = comboCurrency.getActionListeners();
    int i = 0; for (int n = l.length; i < n; i++) {
      comboCurrency.removeActionListener(l[i]);
    }

    ItemListener[] itemListener = comboCurrency.getItemListeners();
    int i = 0; for (int n = itemListener.length; i < n; i++)
      comboCurrency.removeItemListener(itemListener[i]);
    try
    {
      initComboCurrency(comboCurrency, currencyColl, isSelBaseCurr, oprtState);
    }
    finally {
      int i = 0; for (int n = l.length; i < n; i++) {
        comboCurrency.addActionListener(l[i]);
        comboCurrency.addItemListener(itemListener[i]);
      }
      int i = 0; for (int n = itemListener.length; i < n; i++)
        comboCurrency.addItemListener(itemListener[i]);
    }
  }

  public static void initComboCompany(KDComboBox comboCompany, CompanyOrgUnitInfo curCompany)
    throws EASBizException, BOSException
  {
    if ((curCompany == null) || (GlUtils.isCompanyUnion(curCompany))) {
      String innerSql = "SELECT FCompanyID FROM t_bd_accountbanks WHERE FIsMotherAccount = 1 ";
      FilterInfo filter = new FilterInfo();
      filter.getFilterItems().add(new FilterItemInfo("id", innerSql, CompareType.INNER));

      filter.getFilterItems().add(new FilterItemInfo("longNumber", curCompany.getLongNumber() + "!%", CompareType.LIKE));

      filter.getFilterItems().add(new FilterItemInfo("isBizUnit", "1"));

      EntityViewInfo evi = new EntityViewInfo();
      evi.setFilter(filter);
      ICompanyOrgUnit iCompanyOrgUnit = CompanyOrgUnitFactory.getRemoteInstance();

      CompanyOrgUnitCollection CompanyOrgUnitColl = iCompanyOrgUnit.getCompanyOrgUnitCollection(evi);

      FMHelper.sortCollection(CompanyOrgUnitColl, new String[] { "number" });

      comboCompany.addItems(CompanyOrgUnitColl.toArray());
    }
    else
    {
      comboCompany.addItem(curCompany);
      setSelectObject(comboCompany, curCompany);
      comboCompany.setEnabled(false);
    }
  }

  public static void currencyFormat(BOSUuid currencyId, ICell cell)
  {
    if ((currencyId == null) || (cell == null)) {
      return;
    }
    int prec = getPrecOfCurrency(currencyId);
    KDTDefaultCellEditor editor = getCurrencyEditor(prec);
    String numberFmt = getNumberFtm(currencyId);
    cell.getStyleAttributes().setNumberFormat(numberFmt);
    cell.setEditor(editor);
  }

  public static void currencyFormat(BOSUuid currencyId, IColumn col)
  {
    if ((currencyId == null) || (col == null)) {
      return;
    }
    int prec = getPrecOfCurrency(currencyId);
    KDTDefaultCellEditor editor = getCurrencyEditor(prec);
    String numberFmt = getNumberFtm(currencyId);
    col.getStyleAttributes().setNumberFormat(numberFmt);
    col.setEditor(editor);
  }

  public static void currencyFormat(String numberFmt, IColumn col)
  {
    KDTDefaultCellEditor editor = getNumberEditor();
    col.getStyleAttributes().setNumberFormat(numberFmt);

    col.setEditor(editor);
  }

  public static CurrencyInfo getBaseCurrency(CompanyOrgUnitInfo company)
    throws EASBizException, BOSException
  {
    CurrencyInfo currency = ContextHelperFactory.getRemoteInstance().getCompanyBaseCurrency(company);

    return currency;
  }

  public static void checkSelected(Component ui, KDTable table)
  {
    if ((table.getRowCount() == 0) || (table.getSelectManager().getActiveRowIndex() == -1))
    {
      MsgBox.showWarning(ui, EASResource.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_MustSelected"));

      SysUtil.abort();
    }
  }

  public static void showSubmitSuccess(CoreUI ui, CoreBaseInfo info)
  {
    String classAlias = FrameWorkUtils.getClassAlias(info);
    ui.setMessageText(classAlias + " " + EASResource.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_Save_OK"));

    ui.showMessage();
  }

  public static void showSubmitMsg(CoreUI ui, String s)
  {
    ui.setMessageText(s);
    ui.showMessage();
  }

  public static OrgUnitInfo getGroupOrg()
  {
    OrgUnitInfo groupOrg = null;
    try
    {
      groupOrg = NewOrgUnitHelper.getRootCU();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return groupOrg;
  }

  public static CompanyOrgUnitInfo getCompanyByBankAcct(String acctBankId)
    throws EASBizException, BOSException
  {
    SelectorItemCollection src = new SelectorItemCollection();
    src.add(new SelectorItemInfo("*"));
    src.add(new SelectorItemInfo("company.*"));
    IAccountBank iAccountBank = AccountBankFactory.getRemoteInstance();
    AccountBankInfo accountBank = iAccountBank.getAccountBankInfo(new ObjectUuidPK(acctBankId), src);

    CompanyOrgUnitInfo comapny = accountBank.getCompany();
    return comapny;
  }

  public static CompanyOrgUnitCollection getCompanyOrgUnitCollection(String[] companyIds)
    throws BOSException
  {
    if (FMHelper.isEmpty(companyIds)) {
      return new CompanyOrgUnitCollection();
    }
    Set set = FMHelper.asSet(companyIds);
    EntityViewInfo ev = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    ev.getSelector().add("*");

    ev.getSelector().add("accountTable.id");
    ev.getSelector().add("accountTable.number");
    ev.getSorter().add(new SorterItemInfo("longnumber"));
    filter.getFilterItems().add(new FilterItemInfo("id", set, CompareType.INCLUDE));

    ev.setFilter(filter);
    CompanyOrgUnitCollection coll = null;

    ICompanyOrgUnit company = CompanyOrgUnitFactory.getRemoteInstance();
    coll = company.getCompanyOrgUnitCollection(ev);

    return coll;
  }

  public static CompanyOrgUnitCollection getCompanyOrgUnitCollection(Set companyIdSet)
    throws BOSException
  {
    if (FMHelper.isEmpty(companyIdSet)) {
      return new CompanyOrgUnitCollection();
    }
    EntityViewInfo ev = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    ev.getSelector().add("*");

    ev.getSelector().add("accountTable.id");
    ev.getSelector().add("accountTable.number");
    ev.getSorter().add(new SorterItemInfo("longnumber"));
    filter.getFilterItems().add(new FilterItemInfo("id", companyIdSet, CompareType.INCLUDE));

    ev.setFilter(filter);
    CompanyOrgUnitCollection coll = null;

    ICompanyOrgUnit company = CompanyOrgUnitFactory.getRemoteInstance();
    coll = company.getCompanyOrgUnitCollection(ev);

    return coll;
  }

  public static CompanyOrgUnitCollection getCompanyOrgUnitCollection(Set companyIdSet, boolean isContainSealUp)
    throws BOSException
  {
    if (FMHelper.isEmpty(companyIdSet)) {
      return new CompanyOrgUnitCollection();
    }
    EntityViewInfo ev = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    ev.getSelector().add("*");

    ev.getSelector().add("accountTable.id");
    ev.getSelector().add("accountTable.number");
    ev.getSorter().add(new SorterItemInfo("longnumber"));
    filter.getFilterItems().add(new FilterItemInfo("id", companyIdSet, CompareType.INCLUDE));

    if (!isContainSealUp)
    {
      filter.getFilterItems().add(new FilterItemInfo("isSealUp", Boolean.valueOf(isContainSealUp)));
    }

    ev.setFilter(filter);
    CompanyOrgUnitCollection coll = null;

    ICompanyOrgUnit company = CompanyOrgUnitFactory.getRemoteInstance();
    coll = company.getCompanyOrgUnitCollection(ev);

    return coll;
  }

  public static CompanyOrgUnitCollection getCompanyOrgUnitCollection(Set companyIdSet, boolean isContainSealUp, SelectorItemCollection sic)
    throws BOSException
  {
    if (FMHelper.isEmpty(companyIdSet)) {
      return new CompanyOrgUnitCollection();
    }
    EntityViewInfo evi = new EntityViewInfo();

    evi.setSelector(sic);

    evi.getSorter().add(new SorterItemInfo("longnumber"));

    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("id", companyIdSet, CompareType.INCLUDE));

    if (!isContainSealUp) {
      filter.getFilterItems().add(new FilterItemInfo("isSealUp", Boolean.valueOf(isContainSealUp)));
    }

    evi.setFilter(filter);
    CompanyOrgUnitCollection coll = null;

    ICompanyOrgUnit company = CompanyOrgUnitFactory.getRemoteInstance();
    coll = company.getCompanyOrgUnitCollection(evi);

    return coll;
  }

  public static IRowSet getRowSet(IMetaDataPK mainQueryPK, EntityViewInfo evi)
  {
    IQueryExecutor exec = QueryExecutorFactory.getRemoteInstance(mainQueryPK);

    exec.setObjectView(evi);
    IRowSet rowSet = null;
    try {
      rowSet = exec.executeQuery();
    }
    catch (BOSException e)
    {
      SysUtil.abort(e);
    }
    return rowSet;
  }

  public static void setNumberFormat(KDTable tblMain, String columnKey, String currencyID)
  {
    String numberFormat = null;
    if (currencyID == null)
      numberFormat = "%r-[ ]{###,###,##0.00}15.2n";
    else {
      numberFormat = getNumberFtm(BOSUuid.read(currencyID));
    }
    StyleAttributes styleAttributes = tblMain.getColumn(columnKey).getStyleAttributes();

    styleAttributes.setNumberFormat(numberFormat);
    styleAttributes.setHorizontalAlign(Styles.HorizontalAlignment.RIGHT);
  }

  public static void setNumberFormat(KDTable tblMain, int columnIndex, String currencyID)
  {
    String numberFormat = null;
    if (currencyID == null)
      numberFormat = "%r-[ ]{###,###,##0.00}15.2n";
    else {
      numberFormat = getNumberFtm(BOSUuid.read(currencyID));
    }
    StyleAttributes styleAttributes = tblMain.getColumn(columnIndex).getStyleAttributes();

    styleAttributes.setNumberFormat(numberFormat);
    styleAttributes.setHorizontalAlign(Styles.HorizontalAlignment.RIGHT);
  }

  public static void setActualDigitNumberFormat(ICell cell)
  {
    if (cell == null) {
      throw new IllegalArgumentException("cell is null");
    }
    if (cell.getValue() == null)
    {
      return;
    }
    DecimalFormat df = new DecimalFormat("#,##0.###########");
    cell.setValue(df.format(cell.getValue()));
  }

  public static void setActualDigitNumberFormat(KDTable table, String columnKey)
  {
    StyleAttributes styleAttributes = table.getColumn(columnKey).getStyleAttributes();

    styleAttributes.setNumberFormat("%r-[ ]{###,###,###.##########}n");
    styleAttributes.setHorizontalAlign(Styles.HorizontalAlignment.RIGHT);
  }

  public static void setActualDigitNumberFormat(KDTable table, String columnKey, int scale)
  {
    StyleAttributes styleAttributes = table.getColumn(columnKey).getStyleAttributes();

    String strScale = "";
    for (int i = 0; i < scale; i++) {
      strScale = strScale + "#";
    }
    styleAttributes.setNumberFormat("%r-[ ]{###,###,###." + strScale + "}n");

    styleAttributes.setHorizontalAlign(Styles.HorizontalAlignment.RIGHT);
  }

  /** @deprecated */
  public static void clearF7(KDBizPromptBox f7Item)
  {
    EntityViewInfo ev = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("id", "null"));
    ev.setFilter(filter);
    f7Item.setEntityViewInfo(ev);
  }

  public static void setNumberFormat(IRow row, String columnKey, String currencyID)
  {
    String numberFormat = getNumberFtm(BOSUuid.read(currencyID));
    StyleAttributes styleAttributes = row.getCell(columnKey).getStyleAttributes();

    styleAttributes.setNumberFormat(numberFormat);
    styleAttributes.setHorizontalAlign(Styles.HorizontalAlignment.RIGHT);
  }

  public static void exportToExcel(Component ui, KDTable table)
    throws Exception
  {
    String filePath = null;

    KDFileChooser fileChooser = new KDFileChooser();
    fileChooser.setDialogTitle(EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "exportToExcel"));
    fileChooser.setAcceptAllFileFilterUsed(true);
    fileChooser.setFileFilter(new ExcelFileFilter());

    String fileName = null;
    if (fileChooser.showSaveDialog(ui) == 0) {
      filePath = fileChooser.getSelectedFile().getPath();
      fileName = fileChooser.getSelectedFile().getName();

      if (!filePath.toLowerCase().endsWith(".xls"))
        filePath = filePath + ".xls";
    }
    else
    {
      return;
    }

    if (filePath == null) {
      return;
    }
    if (fileName.lastIndexOf(".") != -1) {
      fileName = fileName.substring(0, fileName.lastIndexOf("."));
    }
    KDSBook kdsBook = new KDSBook(fileName);

    String sheetName = fileName;

    KDSSheet kdsSheet = table.getIOManager().saveToKDSSheet(kdsBook, true, false, sheetName);

    kdsBook.addSheet(null, kdsSheet);

    ExportManager export = new ExportManager();
    try
    {
      export.exportToExcel(kdsBook, filePath);
    } catch (RuntimeException e1) {
      MsgBox.showWarning(ui, EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "fileIsOpen"));
    }
  }

  public static void exportExcel(Component ui, KDTable table, boolean flag)
    throws Exception
  {
    String filePath = null;

    KDFileChooser fileChooser = new KDFileChooser();

    fileChooser.setAcceptAllFileFilterUsed(true);
    fileChooser.setFileFilter(new ExcelFileFilter());

    String fileName = null;

    File fileDir = null;
    String totalFileName = null;

    if (fileChooser.showSaveDialog(ui) == 0) {
      filePath = fileChooser.getSelectedFile().getPath();
      fileDir = new File(filePath.substring(0, filePath.lastIndexOf("\\")));

      fileName = fileChooser.getSelectedFile().getName();

      totalFileName = fileName;
      if (!fileName.toLowerCase().endsWith(".xls")) {
        totalFileName = fileName + ".xls";
      }

      if (!filePath.toLowerCase().endsWith(".xls"))
        filePath = filePath + ".xls";
    }
    else
    {
      return;
    }

    if (filePath == null)
    {
      return;
    }
    if (fileName.lastIndexOf(".") != -1) {
      fileName = fileName.substring(0, fileName.lastIndexOf("."));
    }
    File[] files = null;
    int status = -1;
    if ((fileDir != null) && (fileDir.isDirectory())) {
      files = fileDir.listFiles();
      for (int i = 0; i < files.length; i++)
      {
        if (!files[i].isFile())
          continue;
        if (!files[i].getName().equals(totalFileName)) {
          continue;
        }
        status = MsgBox.showConfirm2(ui, EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "FileExisted"));

        if (status == 2) {
          return;
        }

      }

    }

    KDSBook kdsBook = new KDSBook(fileName);

    String sheetName = fileName;
    KDSSheet kdsSheet;
    KDSSheet kdsSheet;
    if (flag) {
      kdsSheet = table.getIOManager().saveToKDSSheet(kdsBook, true, false, sheetName);
    }
    else {
      kdsSheet = table.getIOManager().saveToKDSSheet(kdsBook, true, false, false, sheetName);
    }

    kdsBook.addSheet(null, kdsSheet);

    ExportManager export = new ExportManager();
    try
    {
      export.exportToExcel(kdsBook, filePath);
    } catch (RuntimeException e1) {
      MsgBox.showWarning(ui, EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "fileIsOpen"));
    }
  }

  public static void exportExcel(Component ui, KDTable table)
    throws Exception
  {
    exportExcel(ui, table, false);
  }

  public static Frame getFrameAncestor(Component c) {
    for (Component p = c; p != null; p = p.getParent()) {
      if ((p instanceof Frame)) {
        return (Frame)p;
      }
    }
    return null;
  }

  public static IMetaDataPK getActionPK(ItemAction action)
  {
    if (action == null) {
      return null;
    }
    String actoinName = action.getClass().getName();
    if (actoinName.indexOf("$") >= 0) {
      actoinName = actoinName.substring(actoinName.indexOf("$") + 1);
    }

    return new MetaDataPK(actoinName);
  }

  public static void showSuccessInfo(Component ui, Component component)
  {
    if (!(component instanceof KDWorkButton)) {
      return;
    }
    String text = ((KDWorkButton)component).getText();
    MsgBox.showInfo(ui, text + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));
  }

  public static void showCanNotInfo(Component ui, ItemAction action) {
    if (action == null) {
      return;
    }
    MsgBox.showError(ui, EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "18_FMClientHelper") + action.getExtendProperty("Name"));
    SysUtil.abort();
  }

  public static void showSuccessInfo(CoreUI ui, ItemAction action) {
    if (action == null) {
      return;
    }
    ui.setMessageText(action.getExtendProperty("Name") + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));

    ui.showMessage();
  }

  public static void showSuccessMessage(CoreUI ui, ActionEvent e)
  {
    if ((e == null) || (!(e.getSource() instanceof Component))) {
      return;
    }

    String actionCommand = e.getActionCommand();

    if ((e.getSource() instanceof AbstractButton)) {
      AbstractButton btn = (AbstractButton)e.getSource();
      String txt = btn.getText();
      try
      {
        actionCommand = txt.replaceAll("\\(+[A-Z]+\\)", "");
      }
      catch (Exception ex) {
        logger.error(ex.getMessage());
        actionCommand = "";
      }
    }

    if (!FMHelper.isEmpty(actionCommand)) {
      ui.setMessageText(actionCommand + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));

      ui.showMessage();
      return;
    }

    Component component = (Component)e.getSource();
    showSuccessInfo(ui, component);
  }

  public static void showSuccessMessageBox(CoreUI ui, ActionEvent e)
  {
    if ((e == null) || (!(e.getSource() instanceof Component))) {
      return;
    }
    String actionCommand = e.getActionCommand();

    if ((e.getSource() instanceof AbstractButton)) {
      AbstractButton btn = (AbstractButton)e.getSource();
      String txt = btn.getText();
      try
      {
        actionCommand = txt.replaceAll("\\(+[A-Z]+\\)", "");
      }
      catch (Exception ex) {
        logger.error(ex.getMessage());
        actionCommand = "";
      }
    }
    if (!FMHelper.isEmpty(actionCommand))
    {
      MsgBox.showInfo(ui, actionCommand + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));

      return;
    }

    Component component = (Component)e.getSource();
    showSuccessMessageBox(ui, component);
  }

  public static void showSuccessMessage(CoreUI ui, ActionEvent e, int successCounts)
  {
    if ((e == null) || (!(e.getSource() instanceof Component))) {
      return;
    }
    String actionCommand = e.getActionCommand();

    if ((e.getSource() instanceof AbstractButton)) {
      AbstractButton btn = (AbstractButton)e.getSource();
      String txt = btn.getText();
      try
      {
        actionCommand = txt.replaceAll("\\(+[A-Z]+\\)", "");
      }
      catch (Exception ex) {
        logger.error(ex.getMessage());
        actionCommand = "";
      }
    }
    if (!FMHelper.isEmpty(actionCommand)) {
      String msg = MessageFormat.format(EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "successCounts"), new Object[] { actionCommand, new Integer(successCounts) });

      ui.setMessageText(msg);
      ui.showMessage();
      return;
    }

    Component component = (Component)e.getSource();
    showSuccessInfo(ui, component);
  }

  public static void showSuccessMessage(CoreUI ui, Component component)
  {
    if (!(component instanceof AbstractButton)) {
      return;
    }

    String text = ((AbstractButton)component).getText();
    if (FMHelper.isEmpty(text)) {
      text = ((AbstractButton)component).getToolTipText();
    }
    ui.setMessageText(text + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));
    ui.showMessage();
  }

  public static void showSuccessMessageBox(CoreUI ui, Component component) {
    if (!(component instanceof AbstractButton)) {
      return;
    }

    String text = ((AbstractButton)component).getText();
    if (FMHelper.isEmpty(text)) {
      text = ((AbstractButton)component).getToolTipText();
    }

    MsgBox.showInfo(ui, text + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "SUCCESS"));
  }

  public static void printTDMetaDataField(String pkName)
    throws BOSException
  {
    MetaDataLoaderFactory.setClientMetaDataPath("W:\\apusic\\metas;W:\\eas\\Server\\server\\metas\\*.jar");

    IMetaDataLoader loader = MetaDataLoaderFactory.getRemoteMetaDataLoader();

    IMetaDataPK pk = new MetaDataPK(pkName);
    QueryInfo q = loader.getQuery(pk);
    SelectorInfo s = q.getSelector();

    for (int i = 0; i < s.size(); i++)
      System.out.println(" <Field name=\"" + s.get(i).getName() + "\" alias=\"" + s.get(i).getDisplayName() + "\" description=\"" + s.get(i).getDisplayName() + "\" type=\"" + getTDDataType(s.get(i).getReturnType().toString()) + "\" expr=\"" + s.get(i).getName() + "\" />");
  }

  public static String getTDDataType(String bosType)
  {
    if (bosType == null) {
      return "string";
    }
    if (bosType.equals("String")) {
      return "string";
    }
    if (bosType.equals("Int")) {
      return "integer";
    }
    if (bosType.equals("Number")) {
      return "decimal";
    }
    if (bosType.equals("String")) {
      return "string";
    }
    if (bosType.equals("Date")) {
      return "datetime";
    }
    return bosType.toLowerCase();
  }

  public static void printImport(String metaPK) throws BOSException
  {
    IMetaDataLoader loader = MetaDataLoaderFactory.getRemoteMetaDataLoader();

    IMetaDataPK pk = new MetaDataPK(metaPK);

    EntityObjectInfo entity = loader.getEntity(pk);
    DataTableInfo table = entity.getTable();
    PropertyCollection properties = entity.getPropertiesRuntime();
    String sp = "\t";
    for (int i = 0; i < properties.size(); i++) {
      PropertyInfo p = properties.get(i);

      DataType dataType = DataType.getEnum(p.getString("datatype"));
      if (p.getMappingField() == null) {
        continue;
      }
      ColumnInfo col = table.getColumnByName(p.getMappingField().getName());

      if (col == null)
      {
        continue;
      }
      System.out.println(p.getName() + sp + getDataTypeAilas(dataType) + sp + col.getLength() + sp + p.getAlias());
    }
  }

  private static String getDataTypeAilas(DataType dataType)
  {
    if (dataType == null) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "19_FMClientHelper");
    }
    if (dataType.equals(DataType.STRING)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "19_FMClientHelper");
    }

    if (dataType.equals(DataType.DATE)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "20_FMClientHelper");
    }
    if (dataType.equals(DataType.TIME)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "20_FMClientHelper");
    }
    if (dataType.equals(DataType.TIMESTAMP)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "20_FMClientHelper");
    }
    if (dataType.equals(DataType.DECIMAL)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "21_FMClientHelper");
    }
    if (dataType.equals(DataType.BOOLEAN)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "22_FMClientHelper");
    }

    return dataType.toString();
  }

  /** @deprecated */
  public static void updateUITitle(CoreUIObject ui, String title)
  {
    String resPath = "com.kingdee.eas.fm.common.FMResource";
    String strTitle = title;
    if ((ui.getOprtState().equals(OprtState.VIEW)) || (ui.getOprtState().equals("FINDVIEW")))
    {
      ui.setUITitle(strTitle + " - " + EASResource.getString(resPath, "view"));
    }
    else if (ui.getOprtState().equals(OprtState.EDIT)) {
      ui.setUITitle(strTitle + " - " + EASResource.getString(resPath, "edit"));
    }
    else if (ui.getOprtState().equals(OprtState.ADDNEW)) {
      ui.setUITitle(strTitle + " - " + EASResource.getString(resPath, "new"));
    }
    else
      ui.setUITitle(strTitle);
  }

  public static void UpdateFilterUITitle(CoreUIObject ui, String title)
  {
    String resPath = "com.kingdee.eas.fm.common.FMResource";
    String strTitle = title;
    ui.setUITitle(strTitle + " - " + EASResource.getString(resPath, "query"));
  }

  public static VoucherCollection getVoucherCollection(String billId)
    throws BOSException, EASBizException
  {
    String[] srcEntriesID = { billId };
    IBTPManager iBTPManager = BTPManagerFactory.getRemoteInstance();

    BOSObjectType voucherBosType = new VoucherInfo().getBOSType();

    BOTRelationCollection relationColl = iBTPManager.getDestRelation(billId);

    VoucherCollection colVoucher = null;

    if ((relationColl != null) && (!relationColl.isEmpty()))
    {
      Set voucherIds = new HashSet();

      BOTRelationInfo relationInfo = null;
      int i = 0; for (int size = relationColl.size(); i < size; i++) {
        relationInfo = relationColl.get(i);
        if (!relationInfo.getDestEntityID().equals(voucherBosType.toString()))
        {
          continue;
        }
        voucherIds.add(relationInfo.getDestObjectID());
      }

      if ((voucherIds != null) && (voucherIds.size() != 0))
      {
        IVoucher iVoucher = VoucherFactory.getRemoteInstance();
        SelectorItemCollection cel = new SelectorItemCollection();
        cel.add("*");
        cel.add("creator.*");
        EntityViewInfo view = new EntityViewInfo();
        view.getSelector().addObjectCollection(cel);
        FilterInfo filter = new FilterInfo();

        FilterItemInfo filterItem = new FilterItemInfo("id", voucherIds, CompareType.INCLUDE);

        filter.getFilterItems().add(filterItem);
        view.setFilter(filter);
        colVoucher = iVoucher.getVoucherCollection(view);
      }
    }
    if (colVoucher == null) {
      colVoucher = new VoucherCollection();
    }
    return colVoucher;
  }

  public static String getBillNumber(String id)
    throws Exception
  {
    if ((id == null) || (id.trim().length() == 0)) {
      return null;
    }
    IObjectPK pk = new ObjectUuidPK(id);
    BOSUuid bosId = BOSUuid.read(id);

    IObjectValue info = DynamicObjectFactory.getRemoteInstance().getValue(bosId.getType(), pk);

    return info.getString("number");
  }

  public static Object[] removeVirtualCompany(Object[] fullOrgUnits)
    throws Exception
  {
    List list = new ArrayList();
    SelectorItemCollection selectors = new SelectorItemCollection();
    selectors.add(new SelectorItemInfo("id"));
    selectors.add(new SelectorItemInfo("number"));
    selectors.add(new SelectorItemInfo("name"));
    selectors.add(new SelectorItemInfo("isBizUnit"));
    selectors.add(new SelectorItemInfo("isOnlyUnion"));
    FullOrgUnitInfo orgUnit = null;
    CompanyOrgUnitInfo company = null;
    for (int i = 0; i < fullOrgUnits.length; i++) {
      orgUnit = (FullOrgUnitInfo)fullOrgUnits[i];
      company = CompanyOrgUnitFactory.getRemoteInstance().getCompanyOrgUnitInfo(new ObjectUuidPK(orgUnit.getId()), selectors);

      if (!GlUtils.isCompanyUnion(company)) {
        list.add(orgUnit);
      }
    }

    return list.toArray();
  }

  public static void viewSubmitProccess(CoreUIObject ui, BOSObjectType bosType)
    throws Exception
  {
    if (FMHelper.isEmpty(bosType)) {
      return;
    }

    IEnactmentService service = EnactmentServiceFactory.createRemoteEnactService();

    String procDefID = service.findSubmitProcDef(bosType, SysContext.getSysContext().getCurrentUserInfo().getId().toString());

    if (procDefID != null)
    {
      ProcessDefInfo processDefInfo = service.getProcessDefInfo(procDefID);

      ProcessDef processDef = EnactmentServiceFactory.createRemoteEnactService().getProcessDefByDefineHashValue(processDefInfo.getMd5HashValue());

      Locale currentLocale = SysContext.getSysContext().getLocale();

      String procDefDiagramTitle = processDef.getName(currentLocale);

      UIContext uiContext = new UIContext(ui);
      uiContext.put("define", processDef);
      uiContext.put("title", procDefDiagramTitle);

      String className = BasicShowWfDefinePanel.class.getName();
      IUIFactory uiFactory = UIFactory.createUIFactory(getEditUIMode(ui));
      IUIWindow uiWindow = uiFactory.create(className, uiContext);

      uiWindow.show();
    } else {
      MsgBox.showInfo(ui, EASResource.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_WFHasNotDef"));
    }
  }

  public static void viewProccessDef(CoreUIObject ui, String funcName, String packageName, String operationName)
    throws Exception
  {
    IEnactmentService service = EnactmentServiceFactory.createRemoteEnactService();
    String procDefID = service.findProcDef(ContextHelperFactory.getRemoteInstance().getCurrentUser().getId().toString(), funcName, operationName);

    if (procDefID != null)
    {
      ProcessDefInfo processDefInfo = service.getProcessDefInfo(procDefID);

      ProcessDef processDef = EnactmentServiceFactory.createRemoteEnactService().getProcessDefByDefineHashValue(processDefInfo.getMd5HashValue());

      Locale currentLocale = SysContext.getSysContext().getLocale();

      String procDefDiagramTitle = processDef.getName(currentLocale);

      UIContext uiContext = new UIContext(ui);
      uiContext.put("define", processDef);
      uiContext.put("title", procDefDiagramTitle);

      String className = BasicShowWfDefinePanel.class.getName();
      IUIFactory uiFactory = UIFactory.createUIFactory(getEditUIMode(ui));
      IUIWindow uiWindow = uiFactory.create(className, uiContext);

      uiWindow.show();
    } else {
      MsgBox.showInfo(ui, EASResource.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_WFHasNotDef"));
    }
  }

  public static void viewDoProccess(CoreUIObject ui, String id)
    throws BOSException
  {
    if (id == null);
    IEnactmentService service2 = EnactmentServiceFactory.createRemoteEnactService();

    ProcessInstInfo instInfo = null;
    ProcessInstInfo[] procInsts = service2.getProcessInstanceByHoldedObjectId(id);

    int i = 0; for (int n = procInsts.length; i < n; i++) {
      if ("open.running".equals(procInsts[i].getState())) {
        instInfo = procInsts[i];
      }
    }
    if (instInfo == null)
    {
      MsgBox.showInfo(ui, EASResource.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_WFHasNotInstance"));
    }
    else
    {
      UIContext uiContext = new UIContext(ui);
      uiContext.put("id", instInfo.getProcInstId());
      String className = BasicWorkFlowMonitorPanel.class.getName();
      IUIWindow uiWindow = UIFactory.createUIFactory(getEditUIMode(ui)).create(className, uiContext);

      uiWindow.show();
    }
  }

  public static void viewAuditResult(CoreUIObject ui, String id)
    throws BOSException
  {
    if ((id == null) || (id.trim().length() < 1)) {
      return;
    }

    MultiApproveUtil.showApproveHis(BOSUuid.read(id), UIModelDialogFactory.class.getName(), ui);
  }

  public static void viewNextPerson(CoreUIObject ui, String id)
    throws BOSException
  {
    if (id == null) {
      return;
    }
    DesignateNextActivityPerformerUI.designateNextActivityPerformerByBillId(ui, id);
  }

  /** @deprecated */
  public static String getEditUIMode(CoreUIObject ui)
  {
    Object win = ui.getUIWindow();
    if ((win instanceof UINewFrame))
      return UIFactoryName.NEWWIN;
    if ((win instanceof UIDialog)) {
      return UIFactoryName.MODEL;
    }

    return UIFactoryName.NEWTAB;
  }

  public static void setNumberValueForCell(Component ui, ICell cell, BigDecimal number)
  {
    if ((cell != null) && (!cell.getStyleAttributes().isLocked()) && (number != null))
    {
      if (!isExceedMaxValue(ui, number))
        cell.setValue(number);
    }
  }

  public static boolean isExceedMaxValue(Component ui, BigDecimal number)
  {
    if (number.compareTo(Constants.MAX_VALUE) > 0) {
      MsgBox.showWarning(ui, formatMessage("com.kingdee.eas.fm.common.client.FMCommonClientResource", "numberValueTooLarge", null));

      return true;
    }
    return false;
  }

  public static String formatMessage(String resPath, String resName, Object[] args)
  {
    if ((resPath == null) || (resName == null)) {
      throw new IllegalArgumentException("resPath or resName is nul!");
    }
    String str = EASResource.getString(resPath, resName);
    if ((args == null) || (args.length == 0)) {
      return str;
    }
    return MessageFormat.format(str, args);
  }

  public static void clearSeparatorOnToolBar(KDToolBar toolBar)
  {
    int size = toolBar.getComponentCount();
    Component c = null;
    boolean isSeparator = false;
    int lastVisibleBtnPosition = 0;
    for (int i = 0; i < size; i++) {
      c = toolBar.getComponentAtIndex(i);
      if (c.isVisible()) {
        if ((c instanceof JToolBar.Separator)) {
          if (isSeparator) {
            c.setVisible(false);
          }
          isSeparator = true;
        } else {
          isSeparator = false;
          lastVisibleBtnPosition = i;
        }
      }
    }

    for (int i = lastVisibleBtnPosition; i < size; i++) {
      c = toolBar.getComponentAtIndex(i);
      if ((c instanceof JToolBar.Separator))
        c.setVisible(false);
    }
  }

  public static void clearSeparatorOnMenu(KDMenu menu)
  {
    int size = menu.getMenuComponentCount();

    Component c = null;
    boolean isSeparator = false;
    int lastVisibleBtnPosition = 0;
    for (int i = 0; i < size; i++) {
      c = menu.getMenuComponent(i);
      if (c.isVisible()) {
        if ((c instanceof JSeparator)) {
          if (isSeparator) {
            c.setVisible(false);
          }
          isSeparator = true;
        } else {
          isSeparator = false;
          lastVisibleBtnPosition = i;
        }
      }
    }

    for (int i = lastVisibleBtnPosition; i < size; i++) {
      c = menu.getMenuComponent(i);
      if ((c instanceof JSeparator))
        c.setVisible(false);
    }
  }

  public static void disableSomeTableUserPreferenceConf(TablePreferencesHelper tHelper)
  {
    tHelper.setCanSetBGColor(false);
    tHelper.setCanSetForeColor(false);
  }

  public static String getAccountTabled(String strCompanyId) throws BOSException, EASBizException
  {
    if (FMHelper.isEmpty(strCompanyId)) {
      return null;
    }
    ICompanyOrgUnit company = CompanyOrgUnitFactory.getRemoteInstance();
    CompanyOrgUnitInfo comInfo = company.getCompanyOrgUnitInfo(new ObjectUuidPK(strCompanyId));

    String strAccountTableId = comInfo.getAccountTable().getId().toString();
    return strAccountTableId;
  }

  public static PeriodInfo getGLCurrentPeriod(Component comp, CompanyOrgUnitInfo companyInfo)
    throws EASBizException, BOSException
  {
    PeriodInfo currentPeriod = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.GENERALLEDGER, companyInfo);

    if (currentPeriod == null) {
      MsgBox.showWarning(comp, EASResource.getString("com.kingdee.eas.fm.common.FMResource", "GL_CurrentPeriod_NULL"));

      SysUtil.abort();
    }
    return currentPeriod;
  }

  public static void viewDetailBill(CoreUIObject owner, String billId, CompanyOrgUnitInfo company)
    throws Exception
  {
    String[] idList = new String[1];
    idList[0] = billId;
    viewDetailBill(owner, idList, company);
  }

  public static void viewJournal(CoreUIObject owner, String billId, CompanyOrgUnitInfo company)
    throws Exception
  {
    if (FMHelper.isEmpty(billId)) {
      throw new Exception("idList is null or empty!");
    }

    String popUi = null;

    UIContext uiContext = new UIContext(owner);
    uiContext.put("company", company);
    IUIWindow uiWindow = null;

    uiContext.put("ID", billId);

    IJournal journal = JournalFactory.getRemoteInstance();
    ObjectUuidPK pk = new ObjectUuidPK(billId);
    JournalInfo j = journal.getJournalInfo(pk);
    if (j.getType() == JournalTypeEnum.BANK)
      popUi = "com.kingdee.eas.fi.cas.client.BankJournalUI";
    else {
      popUi = "com.kingdee.eas.fi.cas.client.CashJournalUI";
    }

    uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(popUi, uiContext, null, "VIEW");

    uiWindow.show();
  }

  public static void viewDetailBill(CoreUIObject owner, String[] idList, CompanyOrgUnitInfo company)
    throws Exception
  {
    if ((idList == null) || (idList.length == 0)) {
      throw new Exception("idList is null or empty!");
    }

    IMetaDataLoader loader = MetaDataLoaderFactory.getRemoteMetaDataLoader();

    BOSObjectType bosType = getBOSType(owner, idList);

    idList = getValidIds(idList, bosType);

    if ((bosType == null) || (idList == null) || (idList.length < 1)) {
      return;
    }
    if (bosType.equals(new VoucherEntryInfo().getBOSType()))
    {
      IVoucherEntry voucher = VoucherEntryFactory.getRemoteInstance();
      EntityViewInfo view = new EntityViewInfo();
      FilterInfo filter = new FilterInfo();
      filter.getFilterItems().add(new FilterItemInfo("id", FMHelper.asSet(idList), CompareType.INCLUDE));

      view.setFilter(filter);
      VoucherEntryCollection entry = voucher.getVoucherEntryCollection(view);

      Set voucherIds = new HashSet();
      for (int i = 0; i < entry.size(); i++) {
        voucherIds.add(entry.get(i).getBill().getId().toString());
      }

      idList = (String[])voucherIds.toArray(new String[0]);
      bosType = new VoucherInfo().getBOSType();
    }
    else if (bosType.equals(new SettmentBatchInfo().getBOSType()))
    {
      ISettlementBill voucher = SettlementBillFactory.getRemoteInstance();
      EntityViewInfo view = new EntityViewInfo();
      FilterInfo filter = new FilterInfo();
      filter.getFilterItems().add(new FilterItemInfo("settBatch", FMHelper.asSet(idList), CompareType.INCLUDE));

      view.setFilter(filter);
      SettlementBillCollection entry = voucher.getSettlementBillCollection(view);

      Set voucherIds = new HashSet();
      for (int i = 0; i < entry.size(); i++) {
        voucherIds.add(entry.get(i).getId().toString());
      }

      idList = (String[])voucherIds.toArray(new String[0]);
      bosType = new SettlementBillInfo().getBOSType();
    }

    EntityObjectInfo entity = loader.getEntity(bosType);
    String popUi = null;

    UIContext uiContext = new UIContext(owner);
    uiContext.put("company", company);

    uiContext.put(OrgType.Company, company);
    IUIWindow uiWindow = null;
    String infoID = null;

    if (idList.length == 1) {
      infoID = idList[0];
      uiContext.put("ID", infoID);

      if ((owner instanceof BankJournalListUI)) {
        uiContext.put("TYPE", "OUTER");
      }
      else {
        uiContext.put("TYPE", "INNER");
      }

      if (bosType.equals(new ChequeInfo().getBOSType())) {
        EntityViewInfo view = new EntityViewInfo();
        SelectorItemCollection sic = new SelectorItemCollection();
        sic.add(new SelectorItemInfo("ntType.group"));
        ChequeInfo info = ChequeFactory.getRemoteInstance().getChequeInfo(new ObjectUuidPK(infoID), sic);

        if (!info.getNtType().getGroup().equals(NTTypeGroupEnum.CHEQUE))
          popUi = TeleOrderApplyUI.class.getName();
        else
          popUi = entity.getExtendedProperty("editUI");
      }
      else {
        popUi = entity.getExtendedProperty("editUI");
      }
      uiWindow = UIFactory.createUIFactory(getEditUIMode(owner)).create(popUi, uiContext, null, "FINDVIEW");
    }
    else
    {
      uiContext.put("IDList", idList);
      popUi = entity.getExtendedProperty("listUI");

      uiContext.put("IsFromOtherSys", "findview");
      uiWindow = UIFactory.createUIFactory(getEditUIMode(owner)).create(popUi, uiContext, null, "FINDVIEW");
    }

    uiWindow.show();
  }

  public static void viewDetailBill(CoreUIObject owner, UIContext uiContext, String[] idList, CompanyOrgUnitInfo company)
    throws Exception
  {
    if ((idList == null) || (idList.length == 0)) {
      throw new Exception("idList is null or empty!");
    }

    IMetaDataLoader loader = MetaDataLoaderFactory.getRemoteMetaDataLoader();

    BOSObjectType bosType = getBOSType(owner, idList);

    idList = getValidIds(idList, bosType);

    if ((bosType == null) || (idList == null) || (idList.length < 1)) {
      return;
    }
    if (bosType.equals(new VoucherEntryInfo().getBOSType()))
    {
      IVoucherEntry voucher = VoucherEntryFactory.getRemoteInstance();
      EntityViewInfo view = new EntityViewInfo();
      FilterInfo filter = new FilterInfo();
      filter.getFilterItems().add(new FilterItemInfo("id", FMHelper.asSet(idList), CompareType.INCLUDE));

      view.setFilter(filter);
      VoucherEntryCollection entry = voucher.getVoucherEntryCollection(view);

      Set voucherIds = new HashSet();
      for (int i = 0; i < entry.size(); i++) {
        voucherIds.add(entry.get(i).getBill().getId().toString());
      }

      idList = (String[])voucherIds.toArray(new String[0]);
      bosType = new VoucherInfo().getBOSType();
    }

    EntityObjectInfo entity = loader.getEntity(bosType);
    String popUi = null;

    if (uiContext == null) {
      uiContext = new UIContext(owner);
    }

    uiContext.put("company", company);

    uiContext.put(OrgType.Company, company);
    IUIWindow uiWindow = null;
    String infoID = null;

    if (idList.length == 1) {
      infoID = idList[0];
      uiContext.put("ID", infoID);
      popUi = entity.getExtendedProperty("editUI");
      uiWindow = UIFactory.createUIFactory(getEditUIMode(owner)).create(popUi, uiContext, null, "FINDVIEW");
    }
    else
    {
      uiContext.put("IDList", idList);

      popUi = getListUIName(bosType, entity, uiContext);

      uiContext.put("IsFromOtherSys", "findview");
      uiWindow = UIFactory.createUIFactory(getEditUIMode(owner)).create(popUi, uiContext, null, "FINDVIEW");
    }

    uiWindow.show();
  }

  private static String getListUIName(BOSObjectType bosType, EntityObjectInfo entity, UIContext uiContext)
  {
    if (bosType.equals(new AccrualBillInfo().getBOSType())) {
      String type = (String)uiContext.get("TYPE");

      if ((type != null) && (type.equals("INNER"))) {
        uiContext.put("UIClassParam", "INNER_QUERY");

        return AccrualBillAcceptListUI.class.getName();
      }if ((type != null) && (type.equals("OUTER")))
      {
        return AccrualBillListUI.class.getName();
      }
    }
    return entity.getExtendedProperty("listUI");
  }

  private static String[] getValidIds(String[] idList, BOSObjectType bosType)
  {
    if ((idList == null) || (bosType == null)) {
      return null;
    }

    Set idSet = new HashSet();
    int i = 0; for (int len = idList.length; i < len; i++) {
      if (bosType.equals(BOSUuid.read(idList[i]).getType())) {
        idSet.add(idList[i]);
      }
    }
    return (String[])idSet.toArray(new String[0]);
  }

  private static BOSObjectType getBOSType(IUIObject ui, String[] idList) {
    if (FMHelper.isEmpty(idList)) {
      return null;
    }
    Set set = new HashSet();
    BOSObjectType bosType = null;
    for (int i = 0; i < idList.length; i++) {
      bosType = BOSUuid.read(idList[i]).getType();
      set.add(bosType);
    }
    if ((set == null) || (set.size() == 0)) {
      return null;
    }

    if (set.size() > 1) {
      try {
        bosType = BizTypeChooseUI.showDialogWindow(ui, set);
      } catch (UIException e) {
        e.printStackTrace();
        return null;
      }
    }

    return bosType;
  }

  public static void isBillExists(String billId, BOSObjectType bosType)
    throws BOSException
  {
    IDynamicObject doCtrl = DynamicObjectFactory.getRemoteInstance();
    try {
      doCtrl.getValue(bosType, "select id where id='" + billId + "'");
    } catch (DataAccessException exp) {
      MsgBox.showError(EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "billNoExist"));
      SysUtil.abort(exp);
    }
  }

  public static boolean isHasAsstAcct(String accountId)
  {
    String sql = "SELECT COUNT(*) AS fsize FROM T_BD_AccountView acct INNER JOIN T_BD_AsstAccount assAcct ON acct.FCAA = assAcct.FID INNER JOIN   T_BD_AsstActGroupDetail assAcctDetail ON   assAcct.FID = assAcctDetail.FAsstAccountID INNER JOIN  T_BD_AsstActType assAcctType ON   assAcctDetail.FAsstActTypeID = assAcctType.FID  WHERE assAcctType.FAsstHGAttribute = 'bankAccount' AND acct.FID = '";

    sql = sql + accountId + "'";
    try {
      IRowSet rowSet = SQLExecutorFactory.getRemoteInstance(sql).executeSQL();

      if (rowSet.next()) {
        Object oSize = rowSet.getObject("fsize");
        if (oSize != null) {
          int size = TypeConversionUtils.objToInt(oSize);
          if (size > 0)
            return true;
        }
      }
    }
    catch (BOSException e) {
      e.printStackTrace();
      SysUtil.abort(e);
    } catch (SQLException e) {
      e.printStackTrace();
      SysUtil.abort(e);
    }
    return false;
  }

  public static void setTextFieldFormat(JComponent source, boolean selectAll, boolean removeZero)
  {
    for (int i = 0; i < source.getComponentCount(); i++) {
      Component c = source.getComponent(i);
      if ((c instanceof JComponent))
        if (((JComponent)c).getComponentCount() > 0) {
          setTextFieldFormat((JComponent)c, selectAll, removeZero);
        } else {
          if ((c instanceof KDFormattedTextField)) {
            ((KDFormattedTextField)c).setSelectAllOnFocus(selectAll);

            ((KDFormattedTextField)c).setRemoveingZeroInDispaly(removeZero);

            ((KDFormattedTextField)c).setRemoveingZeroInEdit(removeZero);
          }

          if ((c instanceof KDTextField))
            ((KDTextField)c).addFocusListener(new FocusListener(selectAll, c) { private final boolean val$selectAll;
              private final Component val$c;

              public void focusGained(FocusEvent e) { if (this.val$selectAll)
                  ((KDTextField)this.val$c).selectAll();
              }

              public void focusLost(FocusEvent e)
              {
              }
            });
        }
    }
  }

  public static void setComponentEnable(JComponent source, boolean enable)
  {
    for (int i = 0; i < source.getComponentCount(); i++) {
      Component c = source.getComponent(i);
      if (((c instanceof JComponent)) && (((JComponent)c).getComponentCount() > 0))
      {
        if ((c instanceof KDBizPromptBox)) {
          ((KDBizPromptBox)c).setEnabled(enable);
        }
        if ((c instanceof KDDatePicker)) {
          ((KDDatePicker)c).setEnabled(enable);
        }
        if ((c instanceof KDComboBox)) {
          ((KDComboBox)c).setEnabled(enable);
        }
        if ((c instanceof KDTable)) {
          ((KDTable)c).getStyleAttributes().setLocked(!enable);
        }

        setComponentEnable((JComponent)c, enable);
      } else {
        if ((c instanceof KDFormattedTextField)) {
          ((KDFormattedTextField)c).setEnabled(enable);
        }
        if ((c instanceof KDTextField)) {
          ((KDTextField)c).setEnabled(enable);
        }
        if ((c instanceof KDWorkButton)) {
          ((KDWorkButton)c).setEnabled(enable);
        }
        if ((c instanceof KDCheckBox))
          ((KDCheckBox)c).setEnabled(enable);
      }
    }
  }

  /** @deprecated */
  public static void setFirstFocus(Component[] controls)
  {
    for (int i = 0; i < controls.length; i++) {
      Component control = controls[i];
      if ((control.isVisible()) && (control.isEnabled())) {
        control.requestFocus();
        break;
      }
    }
  }

  public static String getKDTNumFormat(int prec)
  {
    if (prec <= 0) {
      return "%r-[]{#,##0}f";
    }
    StringBuffer sb = new StringBuffer();
    sb.append("%r-[]{#,##0.");
    for (int i = 0; i < prec; i++) {
      sb.append("0");
    }
    sb.append("}f");
    return sb.toString();
  }

  public static void hideIfBizUnitCompany(KDTable kdt, String colName)
    throws EASBizException, BOSException
  {
    IContextHelper helper = ContextHelperFactory.getRemoteInstance();
    IColumn col = kdt.getColumn(colName);
    if (helper.isOnlyUnion(helper.getCurrentCompany()))
      col.getStyleAttributes().setHided(false);
    else
      col.getStyleAttributes().setHided(true);
  }

  public static void setEditable(JComponent component, boolean editable)
  {
    if ((component instanceof KDBizPromptBox)) {
      KDBizPromptBox bizBox = (KDBizPromptBox)component;
      bizBox.setEditable(editable);
      bizBox.setEnabled(editable);
    } else if ((component instanceof KDComboBox)) {
      KDComboBox cbx = (KDComboBox)component;
      cbx.setEnabled(editable);
    } else if ((component instanceof KDDatePicker)) {
      KDDatePicker cbx = (KDDatePicker)component;
      cbx.setEditable(editable);
      cbx.setEnabled(editable);
    } else if ((component instanceof KDCheckBox)) {
      KDCheckBox cb = (KDCheckBox)component;
      cb.setEnabled(editable);
    } else if (((component instanceof IKDTextComponent)) && (!(component instanceof KDComboBox)))
    {
      ((IKDTextComponent)component).setEditable(editable);
    }
  }

  public static void lockRow(KDTable kdt, int rowIndex, String[] colNames)
  {
    IRow row = kdt.getRow(rowIndex);
    if (colNames != null) {
      int i = 0; for (int n = colNames.length; i < n; i++) {
        ICell cell = row.getCell(colNames[i]);
        cell.getStyleAttributes().setLocked(true);
      }
    } else {
      int i = 0; for (int n = kdt.getColumnCount(); i < n; i++) {
        ICell cell = row.getCell(i);
        cell.getStyleAttributes().setLocked(true);
      }
    }
  }

  public static void verifyMoreThanZero(CoreUIObject ui, KDFormattedTextField txt)
  {
    FMClientVerifyHelper.verifyEmpty(ui, txt);
    String text = "";
    if ((txt.getParent() instanceof KDLabelContainer)) {
      text = ((KDLabelContainer)txt.getParent()).getBoundLabelText();
    }

    if (txt.getBigDecimalValue().signum() <= 0) {
      text = text + EASResource.getString("com.kingdee.eas.fm.fin.client.FinClientResource", "MustMoreThanOne");

      txt.requestFocus();
      MsgBox.showWarning(ui, text);
      SysUtil.abort();
    }
  }

  public static void verifyNotNegtive(CoreUIObject ui, KDFormattedTextField txt)
  {
    FMClientVerifyHelper.verifyEmpty(ui, txt);
    String text = "";
    if ((txt.getParent() instanceof KDLabelContainer)) {
      text = ((KDLabelContainer)txt.getParent()).getBoundLabelText();
    }
    if (txt.getBigDecimalValue().signum() < 0) {
      text = text + EASResource.getString("com.kingdee.eas.fm.fin.client.FinClientResource", "MustNotNegtive");

      txt.requestFocus();
      MsgBox.showWarning(ui, text);
      SysUtil.abort();
    }
  }

  public static void checkOnlyUnion(String oprtState)
    throws EASBizException, BOSException
  {
    CompanyOrgUnitInfo company = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

    if ((ContextHelperFactory.getRemoteInstance().isOnlyUnion(company)) && (!oprtState.equalsIgnoreCase("FINDVIEW")) && (!oprtState.equalsIgnoreCase("VIEW")))
    {
      throw new FMException(FMException.UNIONCANNOTOPRT);
    }
  }

  public static void checkOnlyUnion() throws EASBizException, BOSException {
    CompanyOrgUnitInfo company = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

    if (ContextHelperFactory.getRemoteInstance().isOnlyUnion(company))
      throw new FMException(FMException.UNIONCANNOTOPRT);
  }

  public static void initCurrencyField(BasicFormattedTextField txt)
  {
    txt.setHorizontalAlignment(4);
    if ((txt instanceof KDFormattedTextField)) {
      KDFormattedTextField ftTxt = (KDFormattedTextField)txt;
      ftTxt.setDataType(BigDecimal.class);
      ftTxt.setRemoveingZeroInDispaly(false);
      ftTxt.setRemoveingZeroInEdit(true);
    } else if ((txt instanceof KDNumberTextField)) {
      KDNumberTextField numText = (KDNumberTextField)txt;
      numText.setDataType(BigDecimal.class);
      numText.setRemoveingZeroInDispaly(false);
      numText.setRemoveingZeroInEdit(true);
    }
  }

  public static void initDecimalField(BasicFormattedTextField txt)
  {
    txt.setHorizontalAlignment(4);
    if ((txt instanceof KDFormattedTextField)) {
      KDFormattedTextField ftTxt = (KDFormattedTextField)txt;
      ftTxt.setDataType(BigDecimal.class);
      ftTxt.setRemoveingZeroInDispaly(true);
    } else if ((txt instanceof KDNumberTextField)) {
      KDNumberTextField numText = (KDNumberTextField)txt;
      numText.setDataType(BigDecimal.class);
      numText.setRemoveingZeroInDispaly(true);
    }
  }

  public static void addSqlMenu(CoreUIObject uiObject, KDMenu menu) {
    menu.add(new AbstractHidedMenuItem("ctrl shift Q", uiObject) { private final CoreUIObject val$uiObject;

      public void action_actionPerformed() { try { IUIFactory fy = UIFactory.createUIFactory(UIFactoryName.NEWTAB);

          UIContext uiContext = new UIContext(this.val$uiObject);
          IUIWindow wnd = fy.create("com.kingdee.eas.fm.common.client.FMIsqlUI", uiContext);

          wnd.show();
        } catch (UIException e) {
          SysUtil.abort(e);
        }
      }
    });
  }

  public static EntityViewInfo getNothingFilter()
  {
    EntityViewInfo evi = new EntityViewInfo();
    evi.setFilter(new FilterInfo());
    evi.getFilter().getFilterItems().add(new FilterItemInfo("id", "", CompareType.EQUALS));

    return evi;
  }

  public static void setActionEnable(ItemAction[] actions, boolean enabled)
  {
    if (actions == null) {
      return;
    }
    int i = 0; for (int len = actions.length; i < len; i++)
      actions[i].setEnabled(enabled);
  }

  public static void setActionVisible(ItemAction[] actions, boolean visible)
  {
    if (actions == null) {
      return;
    }
    int i = 0; for (int len = actions.length; i < len; i++)
      actions[i].setVisible(visible);
  }

  public static void setCompEnable(IKDComponent[] components, boolean enabled)
  {
    if (components == null) {
      return;
    }

    int i = 0; for (int len = components.length; i < len; i++)
      if ((components[i] instanceof KDTextField))
        ((KDTextField)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDDatePicker))
      {
        ((KDDatePicker)components[i]).setEnabled(enabled);
      } else if ((components[i] instanceof KDFormattedTextField))
        ((KDFormattedTextField)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDComboBox))
        ((KDComboBox)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDBizPromptBox))
        ((KDBizPromptBox)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDCheckBox))
        ((KDCheckBox)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDSpinner))
        ((KDSpinner)components[i]).setEnabled(enabled);
      else if ((components[i] instanceof KDTextArea))
        ((KDTextArea)components[i]).setEnabled(enabled);
  }

  public static Set getAllComponents(Container container)
  {
    Component[] components = container.getComponents();
    Set compSet = new HashSet();
    int i = 0; for (int n = components.length; i < n; i++) {
      Component comp = components[i];
      compSet.add(comp);

      if ((!(comp instanceof KDPanel)) && (!(comp instanceof KDScrollPane)) && (!(comp instanceof KDSplitPane)) && (!(comp instanceof KDTabbedPane)) && (!(comp instanceof KDLabelContainer)) && (!(comp instanceof KDContainer)) && (!(comp instanceof JPanel)))
      {
        continue;
      }

      compSet.addAll(getAllComponents((Container)comp));
    }

    return compSet;
  }

  public static Map removeCompListeners(CoreUI ui)
    throws Exception
  {
    Map map = new HashMap();

    Class[] lstClasses = { ActionListener.class, KeyListener.class, AncestorListener.class, SelectorListener.class, CommitListener.class, DataChangeListener.class, FocusListener.class, ItemListener.class };

    int lstClassLen = lstClasses.length;

    Set allLeafComponents = getAllComponents(ui);
    Iterator iter = allLeafComponents.iterator();
    while (iter.hasNext()) {
      Component comp = (Component)iter.next();
      if (!(comp instanceof IKDTextComponent))
      {
        continue;
      }
      Map listenerMap = new HashMap();

      for (int i = 0; i < lstClassLen; i++)
      {
        Class lstClass = lstClasses[i];
        EventListener[] listeners;
        EventListener[] listeners;
        if (((comp instanceof KDDatePicker)) && (lstClass.equals(DataChangeListener.class))) {
          KDDatePicker kddp = (KDDatePicker)comp;
          DateTimeEditor dtEditor = kddp.getEditor();
          listeners = dtEditor.getListeners(lstClass);
        } else {
          listeners = comp.getListeners(lstClass);
        }

        listenerMap.put(lstClass.getName(), listeners);

        String className = getClassName(lstClass.getName());

        int j = 0; for (int len = listeners.length; j < len; j++)
        {
          Class[] ptTypes = { lstClass };
          Method method = comp.getClass().getMethod("remove" + className, ptTypes);

          method.invoke(comp, new Object[] { listeners[j] });
        }

      }

      map.put(comp.getName(), listenerMap);
    }

    return map;
  }

  public static void addCompListeners(CoreUI ui, Map map)
    throws Exception
  {
    if ((map == null) || (map.isEmpty())) {
      return;
    }

    Set allLeafComponents = getAllComponents(ui);
    Iterator iter = allLeafComponents.iterator();
    while (iter.hasNext()) {
      Component comp = (Component)iter.next();
      if (!(comp instanceof IKDTextComponent)) {
        continue;
      }
      String compName = comp.getName();
      Map listenerMap = (Map)map.get(compName);

      if ((listenerMap == null) || (listenerMap.isEmpty()))
      {
        continue;
      }
      Iterator iter2 = listenerMap.entrySet().iterator();
      while (iter2.hasNext()) {
        Map.Entry entry = (Map.Entry)iter2.next();

        Class lstClass = Class.forName(entry.getKey().toString());
        EventListener[] listeners = (EventListener[])entry.getValue();

        String className = getClassName(lstClass.getName());

        int i = 0; for (int len = listeners.length; i < len; i++)
        {
          Class[] ptTypes = { lstClass };

          Method method = comp.getClass().getMethod("add" + className, ptTypes);

          method.invoke(comp, new Object[] { listeners[i] });
        }
      }
    }
  }

  public static Map removeComponentListeners(JComponent comp)
    throws Exception
  {
    Class[] lstClasses = { ActionListener.class, KeyListener.class, AncestorListener.class, SelectorListener.class, CommitListener.class, DataChangeListener.class, FocusListener.class, ItemListener.class };

    int lstClassLen = lstClasses.length;

    Map listenerMap = new HashMap();

    for (int i = 0; i < lstClassLen; i++)
    {
      Class lstClass = lstClasses[i];

      EventListener[] listeners = comp.getListeners(lstClass);

      listenerMap.put(lstClass.getName(), listeners);

      String className = getClassName(lstClass.getName());

      int j = 0; for (int len = listeners.length; j < len; j++)
      {
        Class[] ptTypes = { lstClass };
        Method method = comp.getClass().getMethod("remove" + className, ptTypes);

        method.invoke(comp, new Object[] { listeners[j] });
      }
    }

    return listenerMap;
  }

  public static void addComponentListeners(JComponent comp, Map listenerMap)
    throws Exception
  {
    if ((listenerMap == null) || (listenerMap.isEmpty())) {
      return;
    }

    Iterator iter2 = listenerMap.entrySet().iterator();
    while (iter2.hasNext()) {
      Map.Entry entry = (Map.Entry)iter2.next();

      Class lstClass = Class.forName(entry.getKey().toString());
      EventListener[] listeners = (EventListener[])entry.getValue();

      String className = getClassName(lstClass.getName());

      int i = 0; for (int len = listeners.length; i < len; i++)
      {
        Class[] ptTypes = { lstClass };

        Method method = comp.getClass().getMethod("add" + className, ptTypes);

        method.invoke(comp, new Object[] { listeners[i] });
      }
    }
  }

  private static String getClassName(String classSpaceName)
  {
    int lastIndexOf = classSpaceName.lastIndexOf(".");
    return classSpaceName.substring(lastIndexOf + 1, classSpaceName.length());
  }

  /** @deprecated */
  public static boolean isAcctHasAcctBankAssis(String acctViewId)
    throws EASBizException, BOSException, UuidException
  {
    StringBuffer sb = new StringBuffer();
    sb.append("SELECT T_BD_AsstActType.FRealtionDataObject AS tName, A.FID FROM T_BD_AccountView A INNER JOIN T_BD_AsstAccount ON A.FCAA = T_BD_AsstAccount.FID INNER JOIN T_BD_AsstActGroupDetail ON T_BD_AsstAccount.FID = T_BD_AsstActGroupDetail.FAsstAccountID INNER JOIN T_BD_AsstActType ON T_BD_AsstActGroupDetail.FAsstActTypeID = T_BD_AsstActType.FID  WHERE (T_BD_AsstActType.FRealtionDataObject = 'T_BD_AccountBanks') and A.fid='" + acctViewId + "'");

    IRowSet rs = SQLExecutorFactory.getRemoteInstance(sb.toString()).executeSQL();
    try
    {
      if (rs.next())
        return true;
    }
    catch (SQLException e) {
      throw new BOSException(e);
    }
    return false;
  }

  public static int getExchangeRatePrec(String sourceCurID, String desCurID)
    throws BOSException, EASBizException
  {
    ExchangeRateInfo erInfo = findExchangeRate(sourceCurID, desCurID);
    if ((erInfo != null) && (erInfo.getExchangeAux() != null)) {
      int prec = erInfo.getExchangeAux().getPrecision();
      return prec;
    }

    return 3;
  }

  public static ExchangeRateInfo findExchangeRate(String sourceCurID, String desCurID)
    throws BOSException, EASBizException
  {
    CompanyOrgUnitInfo clearingHouseCompany = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

    ExchangeTableInfo baseExchangeTable = clearingHouseCompany.getBaseExchangeTable();

    if (baseExchangeTable == null) {
      MsgBox.showError(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "23_FMClientHelper") + clearingHouseCompany.getName() + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "24_FMClientHelper"));

      SysUtil.abort();
    }
    IObjectPK destCurrpk = new ObjectUuidPK(desCurID);
    IObjectPK excTablepk = new ObjectUuidPK(baseExchangeTable.getId());
    IExchangeRate iexchangRate = ExchangeRateFactory.getRemoteInstance();
    IObjectPK sourceCurrpk = new ObjectUuidPK(sourceCurID);
    ExchangeRateInfo erInfo = iexchangRate.getExchangeRate(excTablepk, sourceCurrpk, destCurrpk, new Date(System.currentTimeMillis()));

    return erInfo;
  }

  public static ExchangeRateInfo getExRateInfo(String companyId, String srcCurrId, String destCurrId, Date date)
    throws BOSException, EASBizException
  {
    if ((FMHelper.isEmpty(companyId)) || (FMHelper.isEmpty(srcCurrId))) {
      return null;
    }

    if (date == null) {
      date = new Date();
    }
    date = DateTimeUtils.truncateDate(date);

    String key = companyId + "_" + srcCurrId + "_" + destCurrId + "_" + date.toString();

    if (exRateMap.containsKey(key)) {
      return (ExchangeRateInfo)exRateMap.get(key);
    }

    CompanyOrgUnitInfo company = getCompany(companyId);

    ExchangeTableInfo baseExTable = company.getBaseExchangeTable();
    if (baseExTable == null) {
      MsgBox.showError(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "23_FMClientHelper") + company.getName() + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "24_FMClientHelper"));
      SysUtil.abort();
    }

    String exTableId = baseExTable.getId().toString();

    if (FMHelper.isEmpty(destCurrId)) {
      destCurrId = company.getBaseCurrency().getId().toString();
    }

    IObjectPK exTablePk = new ObjectUuidPK(exTableId);
    IObjectPK srcCurrPk = new ObjectUuidPK(srcCurrId);
    IObjectPK destCurrPk = new ObjectUuidPK(destCurrId);

    IExchangeRate iExRate = ExchangeRateFactory.getRemoteInstance();
    ExchangeRateInfo exRateInfo = iExRate.getExchangeRate(exTablePk, srcCurrPk, destCurrPk, date);

    exRateMap.put(key, exRateInfo);

    return exRateInfo;
  }

  public static ExchangeRateInfo getExRateInfo(String companyId, String srcCurrId, String destCurrId, Date date, SettlementBillRpcCacheInfo rpcCacheInfo)
    throws BOSException, EASBizException
  {
    if ((FMHelper.isEmpty(companyId)) || (FMHelper.isEmpty(srcCurrId))) {
      return null;
    }

    if (date == null) {
      date = new Date();
    }
    date = DateTimeUtils.truncateDate(date);

    String key = companyId + "_" + srcCurrId + "_" + destCurrId + "_" + date.toString();

    if (exRateMap.containsKey(key)) {
      return (ExchangeRateInfo)exRateMap.get(key);
    }
    CompanyOrgUnitInfo company = null;
    if ((rpcCacheInfo.getCurrentCompany() != null) && (rpcCacheInfo.getCurrentCompany().getId().toString().equals(companyId)))
    {
      company = rpcCacheInfo.getCurrentCompany();
    }
    else
    {
      company = getCompany(companyId);
    }

    ExchangeTableInfo baseExTable = company.getBaseExchangeTable();
    if (baseExTable == null) {
      MsgBox.showError(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "23_FMClientHelper") + company.getName() + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "24_FMClientHelper"));
      SysUtil.abort();
    }

    String exTableId = baseExTable.getId().toString();

    if (FMHelper.isEmpty(destCurrId)) {
      destCurrId = company.getBaseCurrency().getId().toString();
    }

    IObjectPK exTablePk = new ObjectUuidPK(exTableId);
    IObjectPK srcCurrPk = new ObjectUuidPK(srcCurrId);
    IObjectPK destCurrPk = new ObjectUuidPK(destCurrId);

    IExchangeRate iExRate = ExchangeRateFactory.getRemoteInstance();
    ExchangeRateInfo exRateInfo = iExRate.getExchangeRate(exTablePk, srcCurrPk, destCurrPk, date);

    exRateMap.put(key, exRateInfo);

    return exRateInfo;
  }

  public static CompanyOrgUnitInfo getCompany(String companyId)
    throws EASBizException, BOSException
  {
    CompanyOrgUnitInfo company = null;

    if (companyMap.containsKey(companyId)) {
      company = (CompanyOrgUnitInfo)companyMap.get(companyId);
    } else {
      company = CompanyOrgUnitFactory.getRemoteInstance().getCompanyOrgUnitInfo(new ObjectUuidPK(companyId));

      companyMap.put(companyId, company);
    }
    return company;
  }

  public static int getPrecOfExRate(String companyId, String srcCurrId, String destCurrId, Date date)
    throws BOSException, EASBizException
  {
    if (FMHelper.isEmpty(destCurrId)) {
      CompanyOrgUnitInfo company = getCompany(companyId);
      destCurrId = company.getBaseCurrency().getId().toString();
    }

    String key = srcCurrId + "_" + destCurrId;

    if (mapPrecOfExRate.containsKey(key)) {
      return ((Integer)mapPrecOfExRate.get(key)).intValue();
    }
    ExchangeRateInfo exRateInfo = getExRateInfo(companyId, srcCurrId, destCurrId, date);

    int prec = 5;
    if (exRateInfo != null) {
      prec = exRateInfo.getPrecision();
    }

    if (srcCurrId.equals(destCurrId)) {
      prec = getPrecOfCurrency(BOSUuid.read(destCurrId));
    }

    mapPrecOfExRate.put(key, new Integer(prec));

    return prec;
  }

  public static BigDecimal getExRate(String companyId, String srcCurrId, String destCurrId, Date date)
    throws BOSException, EASBizException
  {
    ExchangeRateInfo exRateInfo = getExRateInfo(companyId, srcCurrId, destCurrId, date);

    if (exRateInfo != null) {
      return exRateInfo.getConvertRate();
    }
    return Constants.ONE;
  }

  public static PeriodCollection getValidPeriodColl(CompanyOrgUnitInfo curCompany)
  {
    PeriodCollection pc2 = new PeriodCollection();
    EntityViewInfo evi = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("periodType", curCompany.getAccountPeriodType().getId().toString(), CompareType.EQUALS));

    evi.getSorter().add(new SorterItemInfo("periodYear"));
    evi.getSorter().add(new SorterItemInfo("periodNumber"));
    evi.setFilter(filter);
    PeriodCollection pc = null;
    try {
      pc = PeriodFactory.getRemoteInstance().getPeriodCollection(evi);
    } catch (BOSException e) {
      SysUtil.abort(e);
    }
    if (GlUtils.isCompanyUnion(curCompany)) {
      pc2 = pc;
    }
    else {
      PeriodInfo startPeriod = null;
      try {
        startPeriod = SystemStatusCtrolUtils.getStartPeriod(null, SystemEnum.CASHMANAGEMENT, curCompany);
      }
      catch (Exception e) {
        SysUtil.abort(e);
      }
      if (startPeriod == null) {
        MsgBox.showError(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "25_FMClientHelper"));
        SysUtil.abort();
      }

      for (int i = 0; i < pc.size(); i++) {
        PeriodInfo p = pc.get(i);
        if (p.getBeginDate().compareTo(startPeriod.getBeginDate()) >= 0) {
          pc2.add(p);
        }
      }
    }
    return pc2;
  }

  public static TreeMap periodAssembleMap(PeriodCollection pc) {
    TreeMap result = new TreeMap();
    Iterator iter = pc.iterator();

    while (iter.hasNext()) {
      PeriodInfo pi = (PeriodInfo)iter.next();
      Integer year = new Integer(pi.getPeriodYear());
      if (!result.containsKey(year)) {
        PeriodCollection periodSubCo = new PeriodCollection();
        periodSubCo.add(pi);
        result.put(year, periodSubCo);
      } else {
        PeriodCollection periodSubCo = (PeriodCollection)result.get(year);

        periodSubCo.add(pi);
      }
    }
    return result;
  }

  public static void main(String[] args)
    throws Exception
  {
    String queryPk = "com.kingdee.eas.fm.nt.app.PayableBillTDQuery";
    printTDMetaDataField(queryPk);
  }

  public static void generateDestBill(CoreBillListUI owner, String srcBosType, String destBosType, CoreBillBaseCollection billCollection)
    throws Exception
  {
    String openType;
    String openType;
    if ((owner != null) && ((owner.getUIWindow() instanceof UINewTab))) {
      openType = UIFactoryName.NEWTAB;
    }
    else
    {
      String openType;
      if ((owner != null) && ((owner.getUIWindow() instanceof UIFixTab))) {
        openType = UIFactoryName.FIXTAB;
      }
      else
      {
        openType = UIFactoryName.MODEL;
      }
    }
    generateDestBill(owner, srcBosType, destBosType, billCollection, openType);
  }

  public static void generateDestBill(CoreBillListUI owner, String srcBosType, String destBosType, String billId)
    throws Exception
  {
    String openType;
    String openType;
    if ((owner != null) && ((owner.getUIWindow() instanceof UINewTab))) {
      openType = UIFactoryName.NEWTAB;
    }
    else
    {
      String openType;
      if ((owner != null) && ((owner.getUIWindow() instanceof UIFixTab))) {
        openType = UIFactoryName.FIXTAB;
      }
      else
        openType = UIFactoryName.MODEL;
    }
    generateDestBill(owner, srcBosType, destBosType, billId, openType);
  }

  public static void generateDestBill(CoreBillListUI owner, String srcBosType, String destBosType, String billId, String openType)
    throws Exception
  {
    CoreBillBaseInfo billInfo = (CoreBillBaseInfo)EJBAccessFactory.createRemoteInstance().getEntityInfo(billId, owner.getBOTPSelectors());

    CoreBillBaseCollection billCollection = new CoreBillBaseCollection();
    billCollection.add(billInfo);

    generateDestBill(owner, srcBosType, destBosType, billCollection, openType);
  }

  private static void generateDestBill(CoreBillListUI owner, String srcBosType, String destBosType, CoreBillBaseCollection srcBillCollection, String openType)
    throws Exception
  {
    IBOTMapping botMapping = BOTMappingFactory.getRemoteInstance();
    CoreBillBaseInfo billInfo = srcBillCollection.get(0);

    owner.beforeTransform(srcBillCollection, destBosType);
    BOTMappingInfo botMappingInfo = botMapping.getMapping(billInfo, destBosType, DefineSysEnum.BTP);

    if (botMappingInfo == null) {
      throw new FMException(FMException.NODESTBILL);
    }

    IBTPManager iBTPManager = BTPManagerFactory.getRemoteInstance();

    BTPTransformResult btpResult = null;

    String[] ids = new String[srcBillCollection.size()];
    for (int i = 0; i < srcBillCollection.size(); i++)
    {
      CoreBaseInfo info = srcBillCollection.get(i);
      ids[i] = info.getId().toString();
    }
    btpResult = iBTPManager.transformForBotp(ids, new String[] { owner.getEntriesName() }, new ArrayList(), getBotpSelectors(botMappingInfo, destBosType, iBTPManager), destBosType, new ObjectUuidPK(botMappingInfo.getId().toString()), srcBosType);

    IObjectCollection destBillCols = btpResult.getBills();
    BOTRelationCollection botRelationCols = btpResult.getBOTRelationCollection();

    int showUIMode = botMappingInfo.getIsShowEditUI();
    if (showUIMode == 1) {
      String destBillEditUIClassName = iBTPManager.getEntityObjectInfoExtendPro(destBosType, "editUI");
      Map map;
      Map map;
      if ((owner != null) && ((owner.getUIWindow() instanceof UINewTab)))
      {
        map = new UIContext(owner);
      }
      else {
        map = new UIContext(owner);
      }

      map.put("srcBillID", billInfo.getId().toString());
      map.put("BOTPViewStatus", new Integer(1));

      map.put("fmtype", "createTo");
      IUIWindow uiWindow = null;

      if (destBillCols.size() > 1) {
        IIDList idList = RealModeIDList.getEmptyIDList();

        int i = 0; for (int count = destBillCols.size(); i < count; i++) {
          CoreBillBaseInfo destBillInfo = (CoreBillBaseInfo)destBillCols.getObject(i);

          iBTPManager.saveRelations(destBillInfo, botRelationCols);
          idList.add(destBillInfo.getId().toString());
        }

        idList.setCurrentIndex(0);
        map.put("ID", idList.getCurrentID());
        map.put("IDList", idList);

        uiWindow = UIFactory.createUIFactory(openType).create(destBillEditUIClassName, map, null, OprtState.EDIT);
      }
      else
      {
        IObjectValue dataObject = destBillCols.getObject(0);

        map.put("InitDataObject", dataObject);
        map.put("BOTPUIParam", "test");
        uiWindow = UIFactory.createUIFactory(openType).create(destBillEditUIClassName, map, null, OprtState.ADDNEW);

        IUIObject uiObject = uiWindow.getUIObject();

        if ((uiObject instanceof IBotEditUI)) {
          ((IBotEditUI)uiObject).initDataObject(dataObject);
        }

        if ((uiWindow.getUIObject().getDataObject() == null) || (uiWindow.getUIObject().getDataObject().get("id") == null) || (!uiWindow.getUIObject().getDataObject().get("id").toString().equals(dataObject.get("id").toString())))
        {
          uiObject.setDataObject(dataObject);
          uiObject.loadFields();
        }

        ((CoreBillEditUI)uiWindow.getUIObject()).setMakeRelations(botRelationCols);
      }

      uiWindow.show();
    }
    else {
      int i = 0; for (int count = destBillCols.size(); i < count; i++) {
        CoreBillBaseInfo destBillInfo = (CoreBillBaseInfo)destBillCols.getObject(i);

        iBTPManager.submitRelations(destBillInfo, botRelationCols);
      }
    }
  }

  private static SelectorItemCollection getBotpSelectors(BOTMappingInfo botMappingInfo, String destBillTypeBOSType, IBTPManager iBTPManager)
    throws Exception
  {
    SelectorItemCollection botpSelectors = new SelectorItemCollection();

    if (botMappingInfo.getIsTempSave() != 2)
    {
      botpSelectors = BotpHelper.getBOTPSelectors(botMappingInfo);
    }
    else
    {
      String destBillEditUIClassName = iBTPManager.getEntityObjectInfoExtendPro(destBillTypeBOSType, "editUI");

      if (!StringUtils.isEmpty(destBillEditUIClassName)) {
        try
        {
          Class c = null;
          try {
            c = Class.forName(destBillEditUIClassName + "CTEx", false, AbstractUIFactory.class.getClassLoader());
          }
          catch (ClassNotFoundException ex) {
            try {
              c = Class.forName(destBillEditUIClassName + "PIEx", false, AbstractUIFactory.class.getClassLoader());
            }
            catch (ClassNotFoundException _) {
              c = Class.forName(destBillEditUIClassName);
            }
          }
          IUIObject uiObj = (IUIObject)c.newInstance();
          if ((uiObj instanceof EditUI))
          {
            botpSelectors = ((EditUI)uiObj).getSelectors();
          }
        }
        catch (Exception _)
        {
        }
      }

    }

    return botpSelectors;
  }

  public static void viewBgBalance(Component owner, String boName, BgCtrlParamCollection paramColl, IObjectValue info)
    throws BOSException, EASBizException
  {
    IBgControlFacade iBgControlFacade = BgControlFacadeFactory.getRemoteInstance();

    BgCtrlResultCollection coll = iBgControlFacade.getBudget(boName, paramColl, info);

    UIContext uiContext = new UIContext(owner);
    uiContext.put("BGBALANCE", coll);

    IUIWindow uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(BgBalanceViewUI.class.getName(), uiContext, null, OprtState.VIEW);

    uiWindow.show();
  }

  public static void viewBgBalance4ListUI(Component owner, String fid)
    throws BOSException, EASBizException
  {
    IBudgetCtrlFacade iBgControlFacade = BudgetCtrlFacadeFactory.getRemoteInstance();

    BgCtrlResultCollection coll = iBgControlFacade.getBudget(fid);

    UIContext uiContext = new UIContext(owner);
    uiContext.put("BGBALANCE", coll);

    IUIWindow uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(BgBalanceViewUI.class.getName(), uiContext, null, OprtState.VIEW);

    uiWindow.show();
  }

  public static void viewBgBaoListlance(Component ownerUI, String boId)
    throws BOSException, EASBizException
  {
    BgCtrlResultCollection ctrlResultCol = BudgetCtrlFacadeFactory.getRemoteInstance().getBudget(boId);

    UIContext uiContext = new UIContext(ownerUI);

    uiContext.put("BGBALANCE", ctrlResultCol);
    IUIWindow uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(BgBalanceViewUI.class.getName(), uiContext, null, OprtState.VIEW);

    uiWindow.show();
  }

  public static String getActualAcctTable(String companyId, int beginYear, int beginMonth, int endYear, int endMonth)
  {
    if (FMHelper.isEmpty(companyId)) {
      companyId = ContextHelperFactory.getRemoteInstance().getCurrentCompany().getId().toString();
    }

    try
    {
      PeriodInfo beginPeriod = PeriodUtils.getPeriodInfo(beginYear, beginMonth, new ObjectUuidPK(companyId));

      PeriodInfo endPeriod = PeriodUtils.getPeriodInfo(endYear, endMonth, new ObjectUuidPK(companyId));

      return getActualAcctTable(companyId, beginPeriod.getBeginDate(), endPeriod.getEndDate());
    }
    catch (EASBizException e1)
    {
      e1.printStackTrace();
    } catch (BOSException e1) {
      e1.printStackTrace();
    }
    return null;
  }

  public static String getActualAcctTable(String companyId, Date beginDate, Date endDate)
  {
    CompanyOrgUnitInfo company = null;
    try
    {
      if (FMHelper.isEmpty(companyId)) {
        company = ContextHelperFactory.getRemoteInstance().getCurrentCompany();
      }
      else {
        ICompanyOrgUnit iCompany = CompanyOrgUnitFactory.getRemoteInstance();

        company = iCompany.getCompanyOrgUnitInfo(new ObjectUuidPK(companyId));
      }

      String companyid = company.getId().toString();

      AccountRefContrastCollection coll = getStrideAcctRefContrastColl(companyid, beginDate, endDate);

      if ((coll == null) || (coll.isEmpty()))
      {
        PeriodInfo period = PeriodUtils.getPeriodInfo(null, endDate, company);

        if (period == null) {
          MsgBox.showError(DateUtil.DateToString(endDate) + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "26_FMClientHelper"));

          SysUtil.abort();
        }

        int yearNumber = period.getPeriodYear();
        int monthNumber = period.getPeriodNumber();

        AccountTableInfo tbl = company.getAccountTable();
        String currTableId = AccountTools.getCurrentAcctTable(companyid, tbl.getId().toString(), yearNumber, monthNumber);

        return currTableId;
      }if ((null != coll) && (coll.get(0).getRefType() == RefTypeEnum.BOOKS))
        return coll.get(0).getEnabledAcctTable().getId().toString();
    }
    catch (EASBizException e) {
      e.printStackTrace();
    } catch (BOSException e) {
      e.printStackTrace();
    }

    String msg = new FMException(FMException.HASCOMPANYADJUSTACCT).getMessage();

    MsgBox.showError(MessageFormat.format(msg, new String[] { company.getName() }));

    SysUtil.abort();
    return null;
  }

  public static AccountRefContrastCollection getStrideAcctRefContrastColl(String companyId, Date beginDate, Date endDate)
    throws BOSException
  {
    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("company.id", companyId));

    filter.getFilterItems().add(new FilterItemInfo("enabledPeriod.endDate", DateTimeUtils.truncateDate(beginDate), CompareType.GREATER_EQUALS));

    filter.getFilterItems().add(new FilterItemInfo("enabledPeriod.endDate", DateTimeUtils.truncateDate(endDate), CompareType.LESS));

    EntityViewInfo evi = new EntityViewInfo();
    evi.setFilter(filter);

    IAccountRefContrast acctContrast = AccountRefContrastFactory.getRemoteInstance();

    AccountRefContrastCollection coll = acctContrast.getAccountRefContrastCollection(evi);

    return coll;
  }

  public static AccountRefContrastCollection getEnabledAcctRefContrastColl(String companyId, Date beginDate, Date endDate)
    throws BOSException
  {
    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("companyID.id", companyId));

    filter.getFilterItems().add(new FilterItemInfo("enabledPeriod.endDate", DateTimeUtils.truncateDate(beginDate), CompareType.GREATER_EQUALS));

    filter.getFilterItems().add(new FilterItemInfo("enabledPeriod.endDate", DateTimeUtils.truncateDate(endDate), CompareType.LESS_EQUALS));

    EntityViewInfo evi = new EntityViewInfo();
    evi.setFilter(filter);

    IAccountRefContrast acctContrast = AccountRefContrastFactory.getRemoteInstance();

    AccountRefContrastCollection coll = acctContrast.getAccountRefContrastCollection(evi);

    return coll;
  }

  public static String getActualAcctTable(int beginYear, int beginMonth, int endYear, int endMonth)
  {
    return getActualAcctTable(null, beginYear, beginMonth, endYear, endMonth);
  }

  /** @deprecated */
  public static String getActualAcctTable(Date beginDate, Date endDate)
  {
    return getActualAcctTable(null, beginDate, endDate);
  }

  public static void checkIsAdjustPeriod(Component uiComp, CompanyOrgUnitInfo companyInfo)
  {
    if (isAdjustPeriod(companyInfo)) {
      MsgBox.showError(uiComp, new FMException(FMException.CURRPERIODISADJUST).getMessage());

      SysUtil.abort();
    }
  }

  public static boolean isAdjustPeriod(CompanyOrgUnitInfo companyInfo)
  {
    PeriodInfo periodInfo = null;
    try {
      periodInfo = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.CASHMANAGEMENT, companyInfo);
    }
    catch (EASBizException e) {
      e.printStackTrace();
    } catch (BOSException e) {
      e.printStackTrace();
    }

    return (periodInfo != null) && (periodInfo.isIsAdjustPeriod());
  }

  public static void setTableAutoSorter(KDTable tbl)
  {
    KDTSortManager manager2 = new KDTSortManager(tbl);
    manager2.setSortAuto(true);

    for (int i = 0; i < tbl.getColumnCount(); i++)
      tbl.getColumn(i).setSortable(true);
  }

  public static String getSysStatusBarTitle(CoreUI ui, FmRpcCacheInfo rpcCacheInfo)
    throws EASBizException, BOSException
  {
    if (ui == null) {
      return null;
    }

    String packageName = ui.getClass().getPackage().getName();

    if (packageName.startsWith("com.kingdee.eas.fi.cas")) {
      CompanyOrgUnitInfo curC = null;
      if (rpcCacheInfo == null) {
        curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();
      }
      else {
        curC = rpcCacheInfo.getCurrentCompany();
      }
      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = null;
      if (rpcCacheInfo == null) {
        curP = CashClientHelper.getCurrentPeriod(curC);
      }
      else {
        curP = rpcCacheInfo.getCurPeriod();
      }
      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.gl")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.GENERALLEDGER, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.fa")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.FIXEDASSETS, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.lcm")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.LOWCOSTMATERIAL, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if ((packageName.startsWith("com.kingdee.eas.fm.fs")) || (packageName.startsWith("com.kingdee.eas.fm.ivt")) || (packageName.startsWith("com.kingdee.eas.fm.im")) || (packageName.startsWith("com.kingdee.eas.fm.fee")))
    {
      CompanyOrgUnitInfo curC = null;
      if (rpcCacheInfo == null) {
        curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();
      }
      else {
        curC = rpcCacheInfo.getCurrentCompany();
      }
      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      BankInfo clearingHouse = null;
      if (rpcCacheInfo == null) {
        clearingHouse = BankFactory.getRemoteInstance().getClearingHouse(curC.getId().toString());
      }
      else {
        clearingHouse = rpcCacheInfo.getClearHouse();
      }
      if (clearingHouse == null) {
        return null;
      }
      Date settleDate = clearingHouse.getSettleDate();
      if (settleDate == null) {
        return null;
      }
      return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "CHDateTile") + Constants.FORMAT_DAY.format(settleDate);
    }

    if (packageName.startsWith("com.kingdee.eas.fm.stock")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      Date settleDate = getDailySettledDate(curC.getId().toString());
      if (settleDate == null) {
        return null;
      }
      return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "EXCHDateTile") + Constants.FORMAT_DAY.format(settleDate);
    }

    return null;
  }

  public static String getSysStatusBarTitle(CoreUI ui)
    throws EASBizException, BOSException
  {
    if (ui == null) {
      return null;
    }

    String packageName = ui.getClass().getPackage().getName();

    if (packageName.startsWith("com.kingdee.eas.fi.cas")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = CashClientHelper.getCurrentPeriod(curC);
      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.gl")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.GENERALLEDGER, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.fa")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.FIXEDASSETS, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.lcm")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      PeriodInfo curP = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.LOWCOSTMATERIAL, curC);

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if ((packageName.startsWith("com.kingdee.eas.fm.fs")) || (packageName.startsWith("com.kingdee.eas.fm.ivt")) || (packageName.startsWith("com.kingdee.eas.fm.im")) || (packageName.startsWith("com.kingdee.eas.fm.fee")))
    {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      BankInfo clearingHouse = null;
      if ((ui instanceof SettlementBillListUI)) {
        SettlementBillListUI settleBillListUi = (SettlementBillListUI)ui;
        clearingHouse = settleBillListUi.rpcCacheInfo.getClearHouse();
      }
      else
      {
        clearingHouse = BankFactory.getRemoteInstance().getClearingHouse(curC.getId().toString());
      }

      if (clearingHouse == null) {
        return null;
      }
      Date settleDate = clearingHouse.getSettleDate();
      if (settleDate == null) {
        return null;
      }
      return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "CHDateTile") + Constants.FORMAT_DAY.format(settleDate);
    }

    if (packageName.startsWith("com.kingdee.eas.fm.stock")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      Date settleDate = getDailySettledDate(curC.getId().toString());
      if (settleDate == null) {
        return null;
      }
      return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "EXCHDateTile") + Constants.FORMAT_DAY.format(settleDate);
    }

    return null;
  }

  public static String getPeriodString(PeriodInfo curP)
  {
    if (curP == null) {
      return null;
    }

    return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "PeriodTitle") + curP.getPeriodYear() + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "year") + curP.getPeriodNumber() + EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "period");
  }

  public static Date getDailySettledDate(String companyId)
    throws BOSException
  {
    Date initday = new Date();

    String sql = " select FsettleDate  from T_SK_SettleDate where  FCurCompanyID='" + companyId + "' and FIsinit=0 ";
    try
    {
      IRowSet rs = SQLExecutorFactory.getRemoteInstance(sql).executeSQL();

      if (rs.next())
        initday = rs.getDate("FsettleDate");
      else
        return null;
    }
    catch (SQLException e) {
      throw FMHelper.toBOSException(e);
    }
    return initday;
  }

  public static SystemEnum getSystemEnum(CoreUI ui) {
    if (ui == null) {
      return null;
    }
    String packageName = ui.getClass().getPackage().getName();
    if (packageName.startsWith("com.kingdee.eas.fi.cas")) {
      return SystemEnum.CASHMANAGEMENT;
    }

    if ((packageName.startsWith("com.kingdee.eas.fm.fs")) || (packageName.startsWith("com.kingdee.eas.fm.ivt")) || (packageName.startsWith("com.kingdee.eas.fm.im")) || (packageName.startsWith("com.kingdee.eas.fm.fee")))
    {
      return SystemEnum.FINANCESETTLE;
    }

    if (packageName.startsWith("com.kingdee.eas.fi.cas")) {
      return SystemEnum.CASHMANAGEMENT;
    }

    if ((packageName.startsWith("com.kingdee.eas.fm.fs")) || (packageName.startsWith("com.kingdee.eas.fm.ivt")) || (packageName.startsWith("com.kingdee.eas.fm.im")) || (packageName.startsWith("com.kingdee.eas.fm.fee")))
    {
      return SystemEnum.FINANCESETTLE;
    }

    if (packageName.startsWith("com.kingdee.eas.fm.nt")) {
      return SystemEnum.NT_MANAGEMENT;
    }
    if (packageName.startsWith("com.kingdee.eas.fm.fpl")) {
      return SystemEnum.FINANCEPLAN;
    }

    return SystemEnum.FINANCEMANAGE;
  }

  public static void setCompontDisplayFormat(CoreUIObject ui, CurrencyInfo currencyInfo)
    throws EASBizException, BOSException
  {
    if (currencyInfo == null)
      return;
    int pre = FMHelper.getPrecOfCurrency(null, currencyInfo.getId().toString());

    Component[] comps = ui.getComponents();
    for (int i = 0; i < comps.length; i++) {
      Component comp = comps[i];
      if ((comp instanceof KDLabelContainer)) {
        KDLabelContainer ct = (KDLabelContainer)comp;
        JComponent editor = ct.getBoundEditor();

        if ((editor instanceof KDFormattedTextField)) {
          KDFormattedTextField txtEditor = (KDFormattedTextField)editor;
          txtEditor.setHorizontalAlignment(4);

          txtEditor.setPrecision(pre);

          txtEditor.setRemoveingZeroInDispaly(false);
        }
      }
    }
  }

  public static void setToolTipText(CoreUIObject ui)
    throws EASBizException, BOSException
  {
    Component[] comps = ui.getComponents();
    for (int i = 0; i < comps.length; i++) {
      Component comp = comps[i];
      if ((comp instanceof KDWorkButton)) {
        KDWorkButton wbComp = (KDWorkButton)comp;
        wbComp.setToolTipText(wbComp.getText());
      }
    }
  }

  public static void showMenu(CoreUIObject ui, String destui)
    throws UIException
  {
    IUIFactory uiFactory = UIFactory.createUIFactory(getEditUIMode(ui));
    UIContext uiContext = new UIContext(ui);
    IUIWindow uiWindow = uiFactory.create(destui, uiContext);
    uiWindow.show();
  }

  public static void addToolsMenu(CoreUIObject ui) throws UIException
  {
    KDMenuBar bar = ui.getUIMenuBar();
    JMenu tools = null;
    for (int i = 0; i < bar.getMenuCount(); i++) {
      tools = bar.getMenu(i);
      if ("menuTool".equalsIgnoreCase(tools.getName()))
      {
        break;
      }
    }
    if (tools == null) {
      return;
    }

    if (!containsMenuCustom(ui, tools))
      addMenuCustom(ui, tools);
  }

  public static void setEditAndBizMemuBarEnabled(CoreUIObject ui, boolean enable)
  {
    KDMenuBar bar = ui.getUIMenuBar();
    JMenu tools = null;
    for (int i = 0; i < bar.getMenuCount(); i++) {
      tools = bar.getMenu(i);
      if ((tools == null) || ((!"menuEdit".equalsIgnoreCase(tools.getName())) && (!"menuBiz".equalsIgnoreCase(tools.getName())))) {
        continue;
      }
      setMenuEnabled(tools, enable);
    }
  }

  public static void setMenuEnabled(JMenu tools, boolean enable)
  {
    Component[] menuComponents = tools.getMenuComponents();
    for (int i = 0; i < menuComponents.length; i++) {
      Component comp = menuComponents[i];
      if ((comp instanceof KDMenuItem)) {
        KDMenuItem kdmenu = (KDMenuItem)comp;
        Action action = kdmenu.getAction();
        action.setEnabled(enable);
      }
    }
  }

  private static void addMenuCustom(CoreUIObject ui, JMenu tools)
  {
    ActionCapitalSum actionCustom = new ActionCapitalSum(ui);
    KDMenuItem menuItemCustome = new KDMenuItem();
    menuItemCustome.setName("menuItemCustome");
    menuItemCustome.setAction(actionCustom);
    menuItemCustome.setMnemonic('Z');
    menuItemCustome.setText(EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "27_FMClientHelper"));
    tools.add(menuItemCustome);
  }

  private static boolean containsMenuCustom(CoreUIObject ui, JMenu tools)
  {
    boolean contains = false;
    Component[] menuComponents = tools.getMenuComponents();
    for (int i = 0; i < menuComponents.length; i++) {
      Component comp = menuComponents[i];
      if (!(comp instanceof KDMenuItem))
        continue;
      KDMenuItem kdmenu = (KDMenuItem)comp;
      if (kdmenu.getName().equals("menuItemCustome")) {
        contains = true;
        break;
      }

    }

    return contains;
  }

  public static UserInfo getUserByF7Person(CoreUI ui, KDBizPromptBox f7Person)
  {
    Object selectPerson = f7Person.getValue();
    if ((selectPerson instanceof PersonInfo)) {
      PersonInfo person = (PersonInfo)selectPerson;
      EntityViewInfo evi = new EntityViewInfo();
      FilterInfo filter = new FilterInfo();
      filter.getFilterItems().add(new FilterItemInfo("person.id", person.getId().toString()));

      evi.setFilter(filter);
      try {
        UserCollection uc = UserFactory.getRemoteInstance().getUserCollection(evi);

        if ((uc == null) || (uc.size() == 0)) {
          MsgBox.showWarning(ui, EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "29_FMClientHelper"));
          f7Person.requestFocus();
          SysUtil.abort();
        } else {
          return uc.get(0);
        }
      } catch (BOSException e) {
        e.printStackTrace();
        SysUtil.abort(e);
      }
    }
    else if ((selectPerson instanceof UserInfo)) {
      return (UserInfo)selectPerson;
    }
    return null;
  }

  public static void setCustomerFilterF7(CoreUI ui, KDBizPromptBox bizPromptBox, boolean isUnUse, FilterInfo f)
  {
    setCustomerFilterF7(ui, bizPromptBox, isUnUse, f, false);
  }

  public static void setCustomerFilterF7(CoreUI ui, KDBizPromptBox bizPromptBox, boolean isUnUse, FilterInfo f, boolean isMultiSelect)
  {
    bizPromptBox.setQueryInfo("com.kingdee.eas.basedata.master.cssp.app.F7CustomerQuery");

    isUnUse = false;
    String cuid = SysContext.getSysContext().getCurrentCtrlUnit().getId().toString();

    bizPromptBox.setCommitFormat("$number$");

    EntityViewInfo view = new EntityViewInfo();

    SorterItemCollection sorc = view.getSorter();
    SorterItemInfo sort = new SorterItemInfo("number");
    sorc.add(sort);

    FilterInfo filter = new FilterInfo();
    filter.getFilterItems().add(new FilterItemInfo("usedStatus", new Integer(0), CompareType.NOTEQUALS));
    try
    {
      FilterInfo Dfilter = GlWebServiceUtil.getDFilterInfo(CustomerFactory.getRemoteInstance(), cuid);

      if (Dfilter != null) {
        filter.mergeFilter(Dfilter, "and");
      }

    }
    catch (Exception e)
    {
      e.printStackTrace();
    }

    view.setFilter(filter);
    bizPromptBox.setEntityViewInfo(view);
  }

  public static void setCustomerF7(CoreUI ui, KDBizPromptBox bizPromptBox, boolean isUnUse, FilterInfo f)
  {
    setCustomerF7(ui, bizPromptBox, isUnUse, f, false);
  }

  public static void setCustomerF7(CoreUI ui, KDBizPromptBox bizPromptBox, boolean isUnUse, FilterInfo f, boolean isMultiSelect)
  {
    isUnUse = false;
    String cuid = SysContext.getSysContext().getCurrentCtrlUnit().getId().toString();

    bizPromptBox.setCommitFormat("$number$");

    EntityViewInfo view = new EntityViewInfo();

    SorterItemCollection sorc = view.getSorter();
    SorterItemInfo sort = new SorterItemInfo("number");
    sorc.add(sort);

    FilterInfo filter = new FilterInfo();
    view.setFilter(filter);
    FilterItemCollection fic = filter.getFilterItems();
    if (!isUnUse) {
      fic.add(new FilterItemInfo("usedStatus", new Integer(1)));
    }

    try
    {
      FilterInfo Dfilter = GlWebServiceUtil.getDFilterInfo(CustomerFactory.getRemoteInstance(), cuid);

      if (Dfilter != null) {
        filter.mergeFilter(Dfilter, "and");
      }

      if (f != null)
        filter.mergeFilter(f, "and");
    }
    catch (Exception e) {
      e.printStackTrace();
    }

    bizPromptBox.setEntityViewInfo(view);
    try {
      GeneralKDPromptSelectorAdaptor gks = new GeneralKDPromptSelectorAdaptor(bizPromptBox, new F7CustomerTreeDetailListUI(), ui, null, "com.kingdee.eas.basedata.master.cssp.app.F7CustomerQueryForVoucher", "com.kingdee.eas.basedata.master.cssp.app.F7CustomerQueryWithDefaultStandardForVoucher");

      gks.setQueryProperty("mobile", "and");
      gks.setNeedShowUnUsed(isUnUse);

      if ((ui instanceof RptMultiColumnDesignUI)) {
        gks.setNeedShowUnUsed(true);
      }
      gks.setIsMultiSelect(isMultiSelect);
      assignSelector(bizPromptBox, gks);
    } catch (Exception er) {
      er.printStackTrace();
    }
    bizPromptBox.setQueryInfo("com.kingdee.eas.basedata.master.cssp.app.F7CustomerQueryWithDefaultStandardForVoucher");
  }

  private static void assignSelector(KDPromptBox promptBox, KDPromptSelector selector)
  {
    promptBox.setSelector(selector);
  }

  public static String getSysStatusBarTitle(CoreUI ui, PeriodInfo curP)
    throws EASBizException, BOSException
  {
    if (ui == null) {
      return null;
    }

    String packageName = ui.getClass().getPackage().getName();

    if (packageName.startsWith("com.kingdee.eas.fi.cas")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.gl")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.fa")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if (packageName.startsWith("com.kingdee.eas.fi.lcm")) {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }

      if (curP == null) {
        return null;
      }
      return getPeriodString(curP);
    }

    if ((packageName.startsWith("com.kingdee.eas.fm.fs")) || (packageName.startsWith("com.kingdee.eas.fm.ivt")) || (packageName.startsWith("com.kingdee.eas.fm.im")) || (packageName.startsWith("com.kingdee.eas.fm.fee")))
    {
      CompanyOrgUnitInfo curC = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

      if (GlUtils.isCompanyUnion(curC)) {
        return null;
      }
      BankInfo clearingHouse = BankFactory.getRemoteInstance().getClearingHouse(curC.getId().toString());

      if (clearingHouse == null) {
        return null;
      }
      Date settleDate = clearingHouse.getSettleDate();
      if (settleDate == null) {
        return null;
      }
      return EASResource.getString("com.kingdee.eas.fm.common.client.FMCommonClientResource", "CHDateTile") + Constants.FORMAT_DAY.format(settleDate);
    }

    return null;
  }

  public static PeriodInfo checkIsAdjustPeriodAndReturn(Component uiComp, CompanyOrgUnitInfo companyInfo)
  {
    PeriodInfo periodInfo = null;
    try {
      periodInfo = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.CASHMANAGEMENT, companyInfo);
    }
    catch (Exception e) {
      MsgBox.showError(uiComp, e.getMessage());
      SysUtil.abort();
    }

    if ((periodInfo != null) && (periodInfo.isIsAdjustPeriod()))
    {
      MsgBox.showError(uiComp, new FMException(FMException.CURRPERIODISADJUST).getMessage());

      SysUtil.abort();
    }
    return periodInfo;
  }

  public static void checkIsAdjustPeriod(Component uiComp, PeriodInfo periodInfo)
  {
    if ((periodInfo != null) && (periodInfo.isIsAdjustPeriod()))
    {
      MsgBox.showError(uiComp, new FMException(FMException.CURRPERIODISADJUST).getMessage());

      SysUtil.abort();
    }
  }

  public static void setRequireByParam(KDBizPromptBox bizBox, String param, String companyId)
  {
    boolean val = ContextHelperFactory.getRemoteInstance().getBooleanParam(param, new ObjectUuidPK(companyId));

    if (val)
      bizBox.setRequired(true);
    else
      bizBox.setRequired(false);
  }

  public static void setRequireByParam(KDTextField txtField, String param, String companyId)
  {
    boolean val = ContextHelperFactory.getRemoteInstance().getBooleanParam(param, new ObjectUuidPK(companyId));

    if (val)
      txtField.setRequired(true);
    else
      txtField.setRequired(false);
  }

  public static void setNumberFormat(KDTable table, String[] cols, String sFmt)
  {
    int i = 0; for (int len = cols.length; i < len; i++)
      table.getColumn(cols[i]).getStyleAttributes().setNumberFormat(sFmt);
  }

  public static void setBaseFilter(KDBizPromptBox prmt)
    throws EASBizException, BOSException
  {
    EntityViewInfo ev = new EntityViewInfo();
    FilterInfo filter = new FilterInfo();
    ev.setFilter(filter);
    filter.getFilterItems().add(new FilterItemInfo("deletedStatus", new Integer(2), CompareType.NOTEQUALS));

    prmt.setEntityViewInfo(ev);
    prmt.getQueryAgent().resetRuntimeEntityView();
  }

  public static void checkPeriod(CoreUI ui)
    throws EASBizException, BOSException
  {
    CompanyOrgUnitInfo currentCompany = ContextHelperFactory.getRemoteInstance().getCurrentCompany();

    PeriodInfo currPeriodInfo = SystemStatusCtrolUtils.getCurrentPeriod(null, SystemEnum.CASHMANAGEMENT, currentCompany);

    PeriodInfo startPeriodInfo = SystemStatusCtrolUtils.getStartPeriod(null, SystemEnum.CASHMANAGEMENT, currentCompany);

    if ((currPeriodInfo == null) || (startPeriodInfo == null)) {
      MsgBox.showWarning(ui, EASResource.getString("com.kingdee.eas.fi.cas.CasResources", "StartPeriod_NullMsg"));

      SysUtil.abort();
    }
  }

  public static Date getServerDate() {
    Date date = new Date();
    try {
      date = SettleFacadeFactory.getRemoteInstance().getServerDate();
    }
    catch (EASBizException e) {
      e.printStackTrace();
    }
    catch (BOSException e) {
      e.printStackTrace();
    }
    return date;
  }

  public static void addDataFilter(FilterInfo filter, ArrayList param) throws BOSException
  {
    if ((filter == null) || (filter.getFilterItems().size() == 0)) {
      return;
    }

    if ((param == null) || (param.size() == 0)) {
      return;
    }
    FilterInfo datafilter = null;
    if ((param != null) && (param.size() > 0)) {
      DSParam dp = (DSParam)param.get(0);
      String s = dp.getColName();
      if ((s != null) && (s.equalsIgnoreCase("datafilter"))) {
        String f = dp.getAssociateField();
        try {
          datafilter = new FilterInfo(f);
        } catch (Exception e) {
          System.out.println(f);
          e.printStackTrace();
        }
      }
    }
    if ((datafilter != null) && (datafilter.getFilterItems().size() > 0))
      filter.mergeFilter(datafilter, "AND");
  }

  public static String[] IDListToArray(IIDList idlist)
  {
    String[] ids = new String[idlist.size()];
    for (int i = 0; i < idlist.size(); i++) {
      ids[i] = idlist.getID(i);
    }
    return ids;
  }

  public static Set IDListToSet(IIDList idlist) {
    Set ids = new HashSet();
    for (int i = 0; i < idlist.size(); i++) {
      ids.add(idlist.getID(i));
    }
    return ids;
  }

  public static Set list2Set(IIDList list) {
    Set idSet = new HashSet();

    if ((list == null) || (list.size() < 1)) {
      return idSet;
    }
    int i = 0; for (int size = list.size(); i < size; i++) {
      list.setCurrentIndex(i);
      idSet.add(list.getCurrentID());
    }
    return idSet;
  }

  public static void setCutValue(KDFormattedTextField cmp, Number value)
  {
    setCutValue(cmp, value, true);
  }

  public static void setCutValue(KDFormattedTextField cmp, Number value, boolean fireListener)
  {
    if (null == cmp) {
      return;
    }
    if ((value instanceof BigDecimal)) {
      value = ((BigDecimal)value).setScale(cmp.getPrecision(), 4);
    }
    cmp.setNumberValue(value, fireListener);
  }

  public static void setCutValue(KDNumberTextField cmp, Number value, boolean fireListener)
  {
    if (null == cmp) {
      return;
    }
    if ((value instanceof BigDecimal)) {
      value = ((BigDecimal)value).setScale(cmp.getPrecision(), 4);
    }

    cmp.setNumberValue(value, fireListener);
  }

  public static void initBgItemF71(KDBizPromptBox prmt) {
    NewBgItemDialog bgItemSelect = new NewBgItemDialog();
    prmt.setSelector(bgItemSelect);
    prmt.setDisplayFormat("$name$");
    prmt.setEditFormat("$number$");
    prmt.setCommitFormat("$number$;$name$");
  }

  public static void initBgItemF7(KDBizPromptBox prmtBgItem, FpCashDirectionEnum[] enums, boolean isShowLeafOnly, boolean isSelectCombinItem) {
    BgItemForFpDialog bgItemSelect = new BgItemForFpDialog();

    bgItemSelect.setSelectCombinItem(isSelectCombinItem);

    bgItemSelect.setShowLeafOnly(isShowLeafOnly);

    bgItemSelect.setCashDirection(enums);
    prmtBgItem.setSelector(bgItemSelect);
    prmtBgItem.setDisplayFormat("$name$");
    prmtBgItem.setEditFormat("$number$");
    prmtBgItem.setCommitFormat("$number$;$name$");
  }

  public static void loadFieldsBgItem(KDBizPromptBox prmt, CoreBaseInfo info, FMBgItemProp bgItemProp)
  {
    String valueBgItemID = info.getString(bgItemProp.getBgItemIDProp());
    String valueBgItemNumber = info.getString(bgItemProp.getBgItemNumberProp());

    String valueBgItemName = info.getString(bgItemProp.getBgItemNameProp());
    if (valueBgItemNumber == null) {
      prmt.setValue(null);
      return;
    }
    VisualItemInfo bgItem = new VisualItemInfo();
    BOSUuid uuId = FMHelper.isEmpty(valueBgItemID) ? null : BOSUuid.read(valueBgItemID);

    bgItem.setId(uuId);
    bgItem.setNumber(valueBgItemNumber);
    bgItem.setName(valueBgItemName);
    prmt.setValue(bgItem);
  }

  public static void loadFieldsBgItem(ICell cell, CoreBaseInfo info, FMBgItemProp bgItemProp)
  {
    String valueBgItemID = info.getString(bgItemProp.getBgItemIDProp());
    String valueBgItemNumber = info.getString(bgItemProp.getBgItemNumberProp());

    String valueBgItemName = info.getString(bgItemProp.getBgItemNameProp());
    if (valueBgItemNumber == null) {
      cell.setValue(null);
      return;
    }
    VisualItemInfo bgItem = new VisualItemInfo();
    BOSUuid uuId = valueBgItemID == null ? null : BOSUuid.read(valueBgItemID);

    bgItem.setId(uuId);
    bgItem.setNumber(valueBgItemNumber);
    bgItem.setName(valueBgItemName);
    cell.setValue(bgItem);
  }

  public static void storeFieldsBgItem(KDBizPromptBox prmt, CoreBaseInfo info, FMBgItemProp bgItemProp)
  {
    if (prmt.getValue() == null) {
      info.setString(bgItemProp.getBgItemIDProp(), null);
      info.setString(bgItemProp.getBgItemNumberProp(), null);
      info.setString(bgItemProp.getBgItemNameProp(), null);
    } else {
      VisualItemInfo bgItem = (VisualItemInfo)prmt.getValue();
      String bgItemId = bgItem.getId() == null ? null : bgItem.getId().toString();

      info.setString(bgItemProp.getBgItemIDProp(), bgItemId);
      info.setString(bgItemProp.getBgItemNumberProp(), bgItem.getNumber());

      info.setString(bgItemProp.getBgItemNameProp(), bgItem.getName());
    }
  }

  public static void storeFieldsBgItem(ICell cell, CoreBaseInfo info, FMBgItemProp bgItemProp)
  {
    if (cell.getValue() == null) {
      info.setString(bgItemProp.getBgItemIDProp(), null);
      info.setString(bgItemProp.getBgItemNumberProp(), null);
      info.setString(bgItemProp.getBgItemNameProp(), null);
    } else {
      VisualItemInfo bgItem = (VisualItemInfo)cell.getValue();
      String bgItemId = bgItem.getId() == null ? null : bgItem.getId().toString();

      info.setString(bgItemProp.getBgItemIDProp(), bgItemId);
      info.setString(bgItemProp.getBgItemNumberProp(), bgItem.getNumber());

      info.setString(bgItemProp.getBgItemNameProp(), bgItem.getName());
    }
  }

  public static void initFpOrBgF7Item(boolean isFpItem, KDLabelContainer fpF7cont, KDLabelContainer bgF7cont)
  {
    if ((fpF7cont == null) || (bgF7cont == null)) {
      return;
    }
    if (isFpItem) {
      fpF7cont.setVisible(true);
      bgF7cont.setVisible(false);
    } else {
      fpF7cont.setVisible(false);
      bgF7cont.setVisible(true);
    }
  }

  public static void initFpOrBgF7Item(boolean isFpItem, IColumn fpItem, IColumn bgItem)
  {
    if ((fpItem == null) || (bgItem == null)) {
      return;
    }
    if (isFpItem) {
      fpItem.getStyleAttributes().setHided(false);
      fpItem.setWidth(200);
      bgItem.getStyleAttributes().setHided(true);
      bgItem.setWidth(0);
    } else {
      fpItem.getStyleAttributes().setHided(true);
      fpItem.setWidth(0);
      bgItem.getStyleAttributes().setHided(false);
      bgItem.setWidth(200);
    }
  }

  public static boolean getIsFpOrBg()
  {
    try
    {
      String paramValue = ParamManager.getParamValue(null, null, "BG056");

      return (!FMHelper.isEmpty(paramValue)) && (!"0".equals(paramValue));
    }
    catch (EASBizException e)
    {
      e.printStackTrace();
    } catch (BOSException e) {
      e.printStackTrace();
    }
    return true;
  }

  public static void addViewCompHelper(CoreUI uiObject, KDMenu menu)
  {
    ViewComps viewer = new ViewComps(uiObject);
    menu.add(viewer.getMenuItemShowInfo());
  }

  private static Object getSafeValue(Object o2, Field f3) {
    f3.setAccessible(true);
    Object o3 = null;
    try {
      o3 = f3.get(o2);
    }
    catch (Exception e) {
    }
    return o3;
  }

  public static Object getField(Object obj, String fieldName)
    throws SecurityException
  {
    if (obj == null) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "30_FMClientHelper");
    }
    Field f = null;
    try {
      f = obj.getClass().getField(fieldName);
    } catch (NoSuchFieldException e) {
    }
    if (f == null) {
      try {
        f = obj.getClass().getDeclaredField(fieldName);
      } catch (NoSuchFieldException e) {
      }
      if (f == null) {
        Class superclass = obj.getClass().getSuperclass();
        while ((f == null) && (superclass != null)) {
          try {
            f = superclass.getDeclaredField(fieldName);
          } catch (NoSuchFieldException e) {
          }
          superclass = superclass.getSuperclass();
        }
      }
    }
    return f == null ? EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "31_FMClientHelper") : getSafeValue(obj, f);
  }

  public static Object invokeMethod(String methodName, Class[] parameterTypes, Object obj, Object[] args)
    throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
  {
    if ((obj == null) || (methodName == null) || (methodName.length() == 0)) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "30_FMClientHelper");
    }
    Method method = null;
    try {
      method = obj.getClass().getMethod(methodName, parameterTypes);
    } catch (NoSuchMethodException e) {
    }
    if (method == null) {
      try {
        method = obj.getClass().getDeclaredMethod(methodName, parameterTypes);
      } catch (NoSuchMethodException e) {
      }
      if (method == null) {
        Class superclass = obj.getClass().getSuperclass();
        while ((method == null) && (superclass != null)) {
          try {
            method = superclass.getDeclaredMethod(methodName, parameterTypes);
          } catch (NoSuchMethodException e) {
          }
          superclass = superclass.getSuperclass();
        }
      }
      if (method != null) {
        method.setAccessible(true);
      }
    }
    return method == null ? EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "32_FMClientHelper") : method.invoke(obj, args);
  }

  public static String getListSql(ListUI ui)
    throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, BOSException
  {
    if (ui == null) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "33_FMClientHelper");
    }
    IMetaDataPK queryPK = ui.getMainQueryPK();
    EntityViewInfo query = ui.getMainQuery();
    Object ret = invokeMethod("getQueryExecutor", new Class[] { IMetaDataPK.class, EntityViewInfo.class }, ui, new Object[] { queryPK, query });

    return ((IQueryExecutor)ret).getSQL();
  }

  public static String getF7Sql(KDBizPromptBox f7)
    throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, BOSException
  {
    if (f7 == null) {
      return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "33_FMClientHelper");
    }
    return f7.getQueryAgent().getQueryExecutor().getSQL();
  }

  public static String searchMenu(String menuName) {
    return "select fname_l2,fshortcutcode,fuiclassname,fuiclassparam  from t_bas_sysmenuitem where fname_l2 like '%" + menuName + "%' ";
  }

  public static String getTansSql(String sql, int DBtype)
    throws SqlTranslateException
  {
    return TransUtil.Translate(sql, DBtype);
  }

  public static Component getCompNameByInfoPropName(CoreUIObject ui, String propertyName)
    throws SecurityException
  {
    DataBinder dataBinder = (DataBinder)getField(ui, "dataBinder");

    return dataBinder.getComponetByField(propertyName);
  }

  public static String helps()
  {
    return EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "34_FMClientHelper") + "FMClientHelper.getField(CoreUI, \"editData\") \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "35_FMClientHelper") + "FMClientHelper.getListSql(CoreUI) \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "36_FMClientHelper") + "FMClientHelper.getF7Sql( ) \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "37_FMClientHelper") + "FMClientHelper.invoke(\"com.kingdee.eas.\",\"\", new Object[]{ }) \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "38_FMClientHelper") + "FMClientHelper.searchMenu(\"\") \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "39_FMClientHelper") + "FMClientHelper.locateClassClt(\"com.kingdee.eas..class\") \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "40_FMClientHelper") + "FMClientHelper.locateClassSvr(\"com.kingdee.eas..class\")  \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "41_FMClientHelper") + "FMClientHelper.locateMetaClt(\"\") \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "42_FMClientHelper") + "FMClientHelper.locateMetaSvr(\"\")  \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "43_FMClientHelper") + "FMClientHelper.saveClassOrJarFileClt(\"com.kingdee.eas..class\", \"c:\")  \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "44_FMClientHelper") + "FMClientHelper.saveClassOrJarFileSvr(\"com.kingdee.eas..class\", \"c:\")  \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "45_FMClientHelper") + "FMClientHelper.getCompNameByInfoPropName(CoreUI, \"number\" ) \n" + "\n" + EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "46_FMClientHelper") + "FMClientHelper.invokeMethod(\"\", new Class[]{ }, CoreUI, new Object[]{ }) \n";
  }

  public static Object invoke(String className, String methodName, Object[] args)
    throws BOSException
  {
    return DynamicObjectFactory.getRemoteInstance().invoke(className, methodName, args);
  }

  public static String locateClassClt(String className)
    throws Exception
  {
    int idx = className.lastIndexOf('.');
    String ext = className.substring(idx);
    className = className.substring(0, idx).replace('.', '/');
    if (!className.startsWith("/"))
      className = "/" + className;
    className = className + ext;
    URL classUrl = null;
    classUrl = Class.class.getResource(className);
    if (classUrl != null) {
      return classUrl.toString() + "\n" + ReadFileInfoHelper.getModifiedTimeAndSize(classUrl);
    }
    return null;
  }

  public static String saveClassOrJarFileClt(String className, String destPath)
    throws Exception
  {
    int idx = className.lastIndexOf('.');
    String ext = className.substring(idx);
    className = className.substring(0, idx).replace('.', '/');
    if (!className.startsWith("/"))
      className = "/" + className;
    className = className + ext;
    URL classUrl = null;
    classUrl = Class.class.getResource(className);
    InputStream in = null;
    if (classUrl != null)
      in = Class.class.getResourceAsStream(className);
    else
      try {
        in = new FileInputStream(new File(className));
      }
      catch (Exception e) {
      }
    if (in != null) {
      OutputStream out = new FileOutputStream(new File(destPath, className.split("/")[(className.split("/").length - 1)]));
      try
      {
        StreamUtil.copy(in, out, 32768);
      } finally {
        StreamUtil.closeStream(in);
        StreamUtil.closeStream(out);
      }
      return "ok";
    }
    return "not found";
  }

  public static String saveClassOrJarFileSvr(String className, String destPath) throws Exception
  {
    IFMCommonFacade Ifmcomm = FMCommonFacadeFactory.getRemoteInstance();
    try {
      Map ret = Ifmcomm.beforeDownLoadClassOrJarFile(className);
      boolean isSucceed = ((Boolean)ret.get("isSucceed")).booleanValue();
      if (isSucceed) {
        url = System.getProperty("UPDATE_SERVER");

        saveToFile(url + "/" + className, destPath + "/" + className);
        String str1 = "ok";
        return str1;
      }
      String url = (String)ret.get("infomation");
      return url; } finally { Ifmcomm.afterDownLoadClassOrJarFile(className); } throw localObject;
  }

  private static void saveToFile(String destUrl, String fileName)
    throws IOException
  {
    FileOutputStream fos = null;
    BufferedInputStream bis = null;
    HttpURLConnection httpUrl = null;
    URL url = null;
    byte[] buf = new byte[32768];
    int size = 0;

    url = new URL(destUrl);
    httpUrl = (HttpURLConnection)url.openConnection();

    httpUrl.connect();

    bis = new BufferedInputStream(httpUrl.getInputStream());

    File file = new File(fileName);
    if (!file.exists()) {
      if (!file.getParentFile().exists()) {
        file.getParentFile().mkdirs();
      }
      file.createNewFile();
    }
    fos = new FileOutputStream(fileName);
    try
    {
      while ((size = bis.read(buf)) != -1)
        fos.write(buf, 0, size);
    }
    finally {
      fos.close();
      bis.close();
      httpUrl.disconnect();
    }
  }

  public static String locateMetaClt(String metaName) throws Exception
  {
    int idx = metaName.lastIndexOf('.');
    String ext = metaName.substring(idx);
    metaName = metaName.substring(0, idx).replace('.', '/');
    if (!metaName.startsWith("/"))
      metaName = "/" + metaName;
    metaName = metaName + ext;
    URL classUrl = null;
    classUrl = MDLoader.createInstance(null).cl.findResource(metaName);
    if (classUrl != null) {
      return classUrl.toString() + "\n" + ReadFileInfoHelper.getModifiedTimeAndSize(classUrl);
    }
    return null;
  }

  public static String locateClassSvr(String className)
  {
    try
    {
      return FMCommonFacadeFactory.getRemoteInstance().locateClassSvr(className); } catch (Exception e) {
    }
    return null;
  }

  public static String locateMetaSvr(String metaName) {
    try {
      return FMCommonFacadeFactory.getRemoteInstance().locateMetaSvr(metaName); } catch (Exception e) {
    }
    return null;
  }

  public static void txtBoxShow(Object[] box, int alignment)
  {
    if (box == null) {
      return;
    }
    for (int i = 0; i < box.length; i++)
      if ((box[i] instanceof KDFormattedTextField)) {
        KDFormattedTextField kdBox = (KDFormattedTextField)box[i];
        kdBox.setHorizontalAlignment(alignment);
      }
  }

  public static void initSpComponents(KDComboBox cboCurrency, KDFormattedTextField txtAmt, KDFormattedTextField txtRate, KDFormattedTextField txtBaseAmt, CurrencyInfo baseCurrency, KDDatePicker bizDate, CompanyOrgUnitInfo currentCompany)
  {
    ActionHelper.initSpComponents(cboCurrency, txtAmt, txtRate, txtBaseAmt, baseCurrency, bizDate, currentCompany);
  }

  public static void initBankInterface(KDComboBox cmp, String bank)
    throws Exception
  {
    Object[] bankCert = null;
    try {
      bankCert = BankFacadeFactory.getRemoteInstance().getBankCert(bank);
    } catch (Exception e) {
      MsgBox.showWarning(e.getMessage());
    }
    cmp.removeAllItems();
    cmp.addItems(bankCert);
  }

  public static void showMsgBox(Component comp, Map value, Map color)
    throws Exception
  {
    IUIWindow uiWindow = null;
    UIContext uiContext = new UIContext(comp);
    uiContext.put("value", value);
    uiContext.put("color", color);
    uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(MsgBoxUI.class.getName(), uiContext, null, OprtState.EDIT);

    uiWindow.show();
    ((MsgBoxUI)uiWindow.getUIObject()); int result = MsgBoxUI.result;
    if (result == 0)
      SysUtil.abort();
  }

  static class ActionCapitalSum extends ItemAction
  {
    public ActionCapitalSum()
    {
      this(null);
    }

    public ActionCapitalSum(IUIObject uiObject) {
      super();
      String _tempStr = null;
      putValue("AcceleratorKey", KeyStroke.getKeyStroke("shift ctrl 1"));

      _tempStr = EASResource.getString("com.kingdee.eas.fm.common.COMMONAutoGenerateResource", "28_FMClientHelper");
      putValue("ShortDescription", _tempStr);
      putValue("LongDescription", _tempStr);
      putValue("Name", _tempStr);
    }

    public void actionPerformed(ActionEvent e) {
      try {
        FMClientHelper.showMenu((CoreUIObject)getUIObject(), RptCapitalSumMainUI.class.getName());
      }
      catch (UIException e1)
      {
        e1.printStackTrace();
      }
    }
  }
}

本文转载自:http://blog.csdn.net/giianhui/article/details/8748376

giianhui
粉丝 6
博文 287
码字总数 0
作品 0
深圳
技术主管
私信 提问
Android 通用工具库--Common4Android

Common4Android是一个通用Android工具库,包含网络库、线程管理器、常用Util工具、热修复,它拥有良好的架构,低耦合、高内聚,使用起来非常轻松。 -基类 ClassName Description BaseApplic...

徐奕
2016/08/29
1K
2
翻翻git之---实用工具类Lazy(绝对的好东西,走过路过别错过)

版权声明:本文为博主原创文章,允许转载,但请保留出处。 https://blog.csdn.net/ddwhan0123/article/details/50624061 转载请注明出处:这里写链接内容 今天还是继续昨天的从Git上找点“有...

王亟亟
2016/02/02
0
0
常用的Java开发自定义工具类UtilsTools

日常开发中经常会遇到一些常用频繁的数据类型转换、日期格式转换、非空校验、避免重复造轮子写代码一般我们一般会封装一个常用的Utils开放工具类; 最近在开发中遇到数组、list、string的转换...

ZhangLG
06/20
65
0
天蓝/jf-android

#jf-android android library项目,集成volley,eventbus,logback, butterknife,gson,recyclerview,appcompat等库,包含常用UI基类和一些常用工具。 项目结构如下: volley辅助类 cnchan...

天蓝
2016/02/02
0
0
j2ee应用快速开发手架--thinker

thinker(像一个思想者一样去写代码) 介绍 工作中的积累,搭建的j2ee应用快速开发手架,重点在代码重构,一些常用功能的演示,工具,插件等的整理 github gitoschina 个人博客:http://www.rg...

guess
2014/04/25
10.2K
7

没有更多内容

加载失败,请刷新页面

加载更多

zookeeper - leader选举

让我们分析如何在ZooKeeper集合中选举leader节点。考虑一个集群中有N个节点。leader选举的过程如下: 所有节点创建具有相同路径 /app/leader_election/guid_ 的顺序、临时节点。 ZooKeeper集...

Canaan_
15分钟前
5
0
金九银十裸辞跳槽面试,却被面试官吊打

目前已经达到金九银十的阶段,相信有不少程序员蠢蠢欲动,开始出去试试水,想要跳槽涨薪了!有一个朋友就想改变现状,于是找了大量网上的面试题,强行记下之后,开始出去“试水”。 他试水之...

别打我会飞
18分钟前
4
0
Spring 官方出品应用监控度量指标门面类库Micrometer介绍

前言 上篇文章 Spring Boot 2.x 中的 Actuator 我们提到了在Spring Boot Actuator中的metirc指标。在Spring Boot 2.x中 官方引入了新的监控门面(facade)类库Micrometer。如果你对门面不是很清...

码农小胖哥
47分钟前
3
0
获取form对象

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <......

前端老手
49分钟前
5
0
CSS-字体格式化

一、字体属性 1、自定字体的类型 font-family:黑体,华文彩云,宋体; 用逗号隔开多个字体类型 2、字体大小 font-size 取值:(1)以px为单位的数字 (2)以pt为单位的数字 (3)em/rem 3、...

wytao1995
52分钟前
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部