package com.vci.client.uif.actions.client;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import javax.swing.JOptionPane;
|
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.client.portal.utility.PLDefination;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.components.VCIJOptionPane;
|
import com.vci.client.uif.engine.common.DefaultTableNode;
|
import com.vci.mw.ClientContextVariable;
|
|
/**
|
* link类型移除按钮事件
|
* 对于link对象的删除,只删除link对象
|
* @author VCI-STGK006
|
*
|
*/
|
public class RemoveAction extends AbstractBatchBusionessOperationAction {
|
/**
|
* 操作方法集合
|
*/
|
private UIFUtils operation =
|
new UIFUtils();
|
|
public RemoveAction(){
|
super();
|
}
|
|
@Override
|
public String getKey() {
|
return REMOVE;
|
}
|
|
@Override
|
public boolean checkHasRight(){
|
// 按LBO进行数据权限检查
|
setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_L);
|
return super.checkHasRight();
|
}
|
|
@Override
|
public boolean beforePost() {
|
boolean res = false;
|
// 删除前,给出提示
|
if(getQuestionDialogResult("您确定要执行移除操作吗") == VCIJOptionPane.OK_OPTION){
|
res = true;
|
} else {
|
res = false;
|
}
|
return res;
|
}
|
|
@Override
|
public boolean doPost() {
|
try {
|
//检查用户选择数据
|
Object[] objs = getDataModel().getSelectObjects();
|
if(objs == null || objs.length < 1){
|
return false;
|
}
|
PLDefination defination = getDefination();
|
//modify 2014.03.09 start
|
//得到所有要移除的link对象
|
List<ClientLinkObject> loList = new ArrayList<ClientLinkObject>();
|
for(int i = 0; i < objs.length; i++){
|
DefaultTableNode dtn = (DefaultTableNode) objs[i];
|
try {
|
//判断主对象类型,修改link是主对象类型一定是link对象
|
if (dtn.getMaterObject() instanceof ClientLinkObject){
|
ClientLinkObject lo = (ClientLinkObject) dtn.getMaterObject();
|
if(lo == null || lo.getLinkObject().oid == null
|
|| "".equals(lo.getLinkObject().oid)){
|
int confirm = VCIOptionPane.showConfirmDialog(
|
ClientContextVariable.getFrame(),
|
"关系不存在或者已经被删除.\n是否继续执行移除操作?",
|
"系统提示",JOptionPane.YES_NO_OPTION);
|
if(confirm == JOptionPane.NO_OPTION){
|
return false;
|
}
|
} else {
|
//XXX lo中的信息不全,暂时使用上下文link类型代替lo的link类型
|
//这样做在特定条件下是有问题的
|
lo.getLinkObject().ltName = defination.getLinkType();
|
loList.add(lo);
|
}
|
} else {
|
//主对象为其他类型的处理
|
UIFUtils.showMessage(ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.syserror.btnconferror");
|
return false;
|
}
|
|
} catch (Exception e){
|
UIFUtils.showErrorMessage(
|
ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.removeerror", e);
|
return false;
|
}
|
}
|
|
//移除所有查找到的link对象
|
boolean success = false;
|
if(!loList.isEmpty()){
|
success = operation.deleteLinkObject(
|
ClientContextVariable.getFrame(), loList.toArray(new ClientLinkObject[0]));
|
if(success){
|
UIFUtils.showMessage(
|
ClientContextVariable.getFrame(),
|
"uifmodel.plm.uif.actions.removesuccessmsg","");
|
}
|
}
|
return success;
|
//modify 2014.03.09 end
|
} catch (Exception e){
|
UIFUtils.showErrorMessage(
|
ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.removeerror", e);
|
return false;
|
}
|
}
|
}
|