package com.vci.client.uif.actions.client;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.vci.client.bof.ClientBusinessObject;
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.client.uif.engine.common.DefaultTableNode;
|
import com.vci.client.uif.engine.common.IDataNode;
|
import com.vci.mw.ClientContextVariable;
|
|
/**
|
* 剪切对象及关系
|
* @author VCI-STGK006
|
*
|
*/
|
public class CutAction extends AbstractBatchBusionessOperationAction {
|
/**
|
* 操作方法集合
|
*/
|
private UIFUtils operation =
|
new UIFUtils();
|
|
public CutAction(){
|
super();
|
}
|
|
@Override
|
public String getKey() {
|
return CUT;
|
}
|
|
@Override
|
public boolean checkHasRight(){
|
// 按LBO进行数据权限检查
|
setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_L);
|
return super.checkHasRight();
|
}
|
|
@Override
|
public boolean doPost() {
|
|
|
try {
|
//获得业务对象数据
|
Object[] objs = getDataModel().getSelectObjects();
|
if(objs == null || objs.length < 1){
|
return false;
|
}
|
String loName = "";
|
List<ClientLinkObject> loList = new ArrayList<ClientLinkObject>();
|
for(int i = 0; i < objs.length; i++){
|
IDataNode dtn = (DefaultTableNode) objs[i];
|
try {
|
//判断主对象类型,修改link是主对象类型一定是link对象
|
if (dtn.getMaterObject() instanceof ClientLinkObject){
|
ClientLinkObject lo = (ClientLinkObject) dtn.getMaterObject();
|
loName = this.getParameterValue(ValueType.RuntimeData, "linktypename", i);
|
String foid = this.getParameterValue(ValueType.RuntimeData, "f_oid", i);
|
String fbtmName = this.getParameterValue(ValueType.RuntimeData, "f_btwname", i);;
|
String toid = this.getParameterValue(ValueType.RuntimeData, "t_oid", i);
|
String tbtmName = this.getParameterValue(ValueType.RuntimeData, "t_btwname", i);
|
//如果操作所需参数不存在则直接停止操作
|
if(foid == null || foid.equals("") ||fbtmName == null || fbtmName.equals("")
|
|| toid == null || toid.equals("") ||tbtmName == null || tbtmName.equals("")){
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.syserror.parmerror.bo");
|
return false;
|
}
|
//下载from对象
|
ClientBusinessObject fcbo = operation
|
.reloadClientBusinessObject(ClientContextVariable.getFrame(), foid, fbtmName);
|
//对象不存在或者已经被删除
|
if(fcbo.getBusinessObject().oid == null || fcbo.getBusinessObject().oid.equals("")){
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.notexistmsg", "父对象");
|
return false;
|
}
|
//下载to对象
|
ClientBusinessObject tcbo = operation
|
.reloadClientBusinessObject(ClientContextVariable.getFrame(), toid, tbtmName);
|
//对象不存在或者已经被删除
|
if(tcbo.getBusinessObject().oid == null || tcbo.getBusinessObject().oid.equals("")){
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.notexistmsg",
|
this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i));
|
return false;
|
}
|
//添加link
|
if(dtn.isForward()){
|
lo.setFromBO(fcbo);
|
lo.setToBO(tcbo);
|
loList.add(lo);
|
} else {
|
lo.setFromBO(tcbo);
|
lo.setToBO(fcbo);
|
loList.add(lo);
|
}
|
} else {
|
//主对象为其他类型的处理
|
|
}
|
} catch (Exception e){
|
UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),e);
|
return false;
|
}
|
}
|
//modify 2014.03.09 end
|
//直接复制link对象(数据、link信息等)
|
//将复制的所有to端对象对应的link对象存储到剪切板
|
if(loList.isEmpty()){
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.copynotexistmsg");
|
return false;
|
} else {
|
ClipboardData cd = new ClipboardData(
|
ClipboardData.ClipboardOperation.cut,
|
ClipboardData.ClipboardDataType.LO,
|
loName, loList.toArray(new ClientLinkObject[0]));
|
ClientBusinessObjectClipboard.getInstance().setContents(cd);
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.cutsuccessmsg","");
|
return false;
|
}
|
} catch (Exception e) {
|
UIFUtils.showErrorMessage(
|
ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.copyerror", e);
|
return false;
|
}
|
}
|
}
|