package com.vci.client.uif.actions.client; import java.util.Map; import javax.swing.JOptionPane; import com.vci.client.bof.ClientBusinessObject; import com.vci.client.bof.ClientLinkObject; import com.vci.client.common.ConfigUtils; import com.vci.client.portal.utility.PLDefination; import com.vci.client.portal.utility.UITools; import com.vci.client.ui.swing.components.VCIJOptionPane; import com.vci.client.ui.swing.components.VCIJDialog.DialogResult; import com.vci.client.uif.engine.client.UIHelper; import com.vci.client.uif.engine.client.objopt.ObjectAddEditDialog; import com.vci.client.uif.engine.common.DefaultTableNode; import com.vci.corba.portal.data.PortalVI; import com.vci.mw.ClientContextVariable; /** * 业务类型修改按钮事件 * 接受参数信息为: * btmname,oid,context * @author VCI-STGK006 * */ public class EditAction extends AbstractBusionessOperationAction { /** * 方法集合 */ private UIFUtils operation = new UIFUtils(); /** * 将操作的业务对象作为一个全局变量存储 */ private ClientBusinessObject cbo = null; /** * 按钮参数 */ private Map paramsMap = null; private boolean actionExecResult = false; public EditAction(){ super(); } @Override public String getKey() { return EDIT; } /* @Override public boolean doAction(){ boolean res = false; if(!isSelectedObject()) return false; //判断是否需要进行数据权限校验 String rightSwitch = ConfigUtils.getConfigValue("right.switch"); if(rightSwitch != null && rightSwitch.equals("on")){ // 权限检查,有权限时才执行后续的操作 if(!checkHasRight()){ VCIJOptionPane.showMessageDialog( getParentComponent(), "您没有权限进行此操作!", "提示", JOptionPane.INFORMATION_MESSAGE); return false; } } // 在选定了数据及有权限之后,执行 res = doActionDetailBySelectedObject(); return res; }*/ @Override public boolean beforePost(){ if(!super.beforePost()) { return false; } paramsMap = getButtonParams(); String batch = paramsMap.get("multiplechoice"); if(batch != null && batch.equalsIgnoreCase("true")){ return true; } else { Object[] objs = getDataModel().getSelectObjects(); if(objs.length > 1){ VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "只能选择一条数据进行此操作!"); return false; } } return true; } @Override public boolean checkHasRight(){ // 按BO进行数据权限检查 setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B); return super.checkHasRight(); } @Override public boolean doPost() { try{ //获得按钮参数 //得到打开窗口的上下文信息 String type = paramsMap.get("type"); String context = paramsMap.get("context"); if(type == null || type.equals("") || context == null || context.equals("")){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.parmerror", ""); return false; } //获得按钮打开窗口的PLDefination PLDefination plDef = getDefination(type, context); if(plDef == null){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.configerror.notformname", type, context); return false; } String formName = plDef.getTemplateId(); if(formName == null || formName.equals("")){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.configerror.notformname", type, context); return false; } //验证是否是创建LO类型 PortalVI sheet = UITools.getService().getPortalVIBySymbol(formName); if(sheet.typeFlag != 0){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.btnconferror"); return false; } // 得到修改的业务对象 cbo = getBusinessObject(); if(cbo == null){ return actionExecResult; } //创建修改窗口 ObjectAddEditDialog oad = new ObjectAddEditDialog(type, context, plDef, paramsMap, ObjectAddEditDialog.OperateType.EDIT, null, this); oad.setSelectObjects(getDataModel().getSelectObjects()); oad.setTypeFlag(0); // add by xchao 2015.08.12 // 设置新打开的上下文模块的inputdata // 设置值类型:sourceData、inputData、selectData oad = super.setTargetUILayoutPanelInputData(oad); // add by xchao 2015.08.12 end oad.init(); oad.setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT); oad.setLocationRelativeTo(ClientContextVariable.getFrame()); //设置各个属性的值 setEditDialogValue(oad, cbo); oad.setVisible(true); if(oad.getDialogResult() == DialogResult.OK){ actionExecResult = true; } else { actionExecResult = false; } } catch(Throwable e){ UIFUtils.showErrorMessage( ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.editboerror", e); } return actionExecResult; } /** * 设置窗口属性值 * 需要在创建编辑窗口初始化完成后执行设置操作 * @return */ private void setEditDialogValue(ObjectAddEditDialog oad, ClientBusinessObject cbo){ oad.getOaep().setValueToUIControl(cbo); } /** * 得到用户选择的业务对象数据 * @return */ private ClientBusinessObject getBusinessObject(){ //获得业务对象数据 Object[] objs = getDataModel().getSelectObjects(); if(objs == null || objs.length < 1){ return null; } //modify 2014.03.07 start DefaultTableNode dtn = (DefaultTableNode) objs[0]; ClientBusinessObject cbo = null; try { if(dtn.getMaterObject() instanceof ClientBusinessObject){ cbo = (ClientBusinessObject) dtn.getMaterObject(); if(cbo == null){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.notexistmsg", dtn.getValueMap().get("name")); return null; } } else if (dtn.getMaterObject() instanceof String){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.engine.folder.root.disabled"); return null; } else if(dtn.getMaterObject() instanceof ClientLinkObject){ //如果是LO,获得头端对象信息 ClientLinkObject clo = (ClientLinkObject) dtn.getMaterObject(); String oid = clo.getLinkObject().toOid; String btmName = clo.getLinkObject().toBTName; if(oid != null && !oid.equals("") && btmName != null && !btmName.equals("")) { //需要重新下载cbo对象 cbo = operation.reloadClientBusinessObject( ClientContextVariable.getFrame(), oid, btmName); //对象不存在或者已经被删除 if(cbo.getBusinessObject().oid == null || cbo.getBusinessObject().oid.equals("")){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.notexistmsg"); return null; } } } } catch (Exception e){ UIFUtils.showErrorMessage( ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.editboerror", e); return null; } //modify 2014.03.07 end return cbo; } }