原文地址 http://blog.csdn.net/fei_lv/article/details/8695683
package com.kingdee.eas.crmsp.cmsp.client;
import java.util.Map;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.BizDataFormat;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.kdf.table.KDTDefaultCellEditor;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.util.render.ObjectValueRender;
import com.kingdee.bos.ctrl.swing.event.SelectorEvent;
import com.kingdee.bos.ctrl.swing.event.SelectorListener;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.UIException;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.crmsp.cmsp.DynamicTableItemInfo;
import com.kingdee.eas.framework.client.CoreUI;
public class F7Util
{
public static void model_show(KDTable kdtAssEntrys, String colName, CoreUI coreUI, KDBizPromptBox promptBox) throws EASBizException, BOSException
{
int rowIndex = kdtAssEntrys.getSelectManager().getActiveRowIndex();
Object value = kdtAssEntrys.getCell(rowIndex, colName).getValue();
String UICLASSNAME = "com.kingdee.eas.crmsp.cmsp.client.DynamicItemF7UI";
Map map = new UIContext();
map.put(UIContext.OWNER, coreUI);
String type = OprtState.ADDNEW;
if (value != null)
{
DynamicTableItemInfo info = (DynamicTableItemInfo) value;
map.put(UIContext.ID, info.getId().toString());
type = OprtState.EDIT;
}
else
{
type = OprtState.ADDNEW;
}
try
{
IUIWindow uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(UICLASSNAME, map, null, type);
promptBox.setSelector((DynamicItemF7UI) uiWindow.getUIObject());
uiWindow.show();
Object returnData = ((DynamicItemF7UI) uiWindow.getUIObject()).getData();
if(returnData!=null && ((DynamicTableItemInfo)returnData).getId()!=null)
kdtAssEntrys.getCell(rowIndex, colName).setValue(((DynamicItemF7UI) uiWindow.getUIObject()).getData());
}
catch (UIException e)
{
e.printStackTrace();
}
}
public static void initPromptBoxF7(final KDTable kdtAssEntrys, final String colName, final CoreUI coreUI)
{
final KDBizPromptBox standardPromptBox = new KDBizPromptBox();
standardPromptBox.setQueryInfo("com.kingdee.eas.crmsp.cmsp.app.DynamicTableItemQuery");
standardPromptBox.setVisible(true);
standardPromptBox.setEditable(false);
standardPromptBox.setDisplayFormat("$name$");
standardPromptBox.setEditFormat("$name$");
standardPromptBox.setCommitFormat("$number$");
KDTDefaultCellEditor standardCellEditor = new KDTDefaultCellEditor(standardPromptBox);
kdtAssEntrys.getColumn(colName).setEditor(standardCellEditor);
ObjectValueRender kdtBjEntry_marketAvg_OVR = new ObjectValueRender();
kdtBjEntry_marketAvg_OVR.setFormat(new BizDataFormat("$name$"));
kdtAssEntrys.getColumn(colName).setRenderer(kdtBjEntry_marketAvg_OVR);
standardPromptBox.addSelectorListener(new SelectorListener()
{
public void willShow(SelectorEvent arg0)
{
try
{
model_show(kdtAssEntrys, colName, coreUI, standardPromptBox);
}
catch (EASBizException e)
{
e.printStackTrace();
}
catch (BOSException e)
{
e.printStackTrace();
}
}
});
}
}