package com.vci.client.uif.actions.client; import java.util.Map; 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.IDataNode; import com.vci.corba.portal.data.PortalVI; import com.vci.mw.ClientContextVariable; /** * link创建按钮 * 通过选择to端对象创建link * @author VCI-STGK006 * */ public class ChooseAction extends DoseNotSelectDataHasRightCheckAction{ /** * 创建窗口 */ private ObjectAddEditDialog oad; /** * 按钮参数 */ private Map paramsMap = null; /** * 判断form的类型 * 不同的form类型得到属性的key是不同的 * 0:业务类型,1:链接类型 */ private int operationType = 0; /** * 是否需要先选择数据然后执行创建操作 */ boolean needSelect = false; public ChooseAction(){ super(); } @Override public String getKey() { return CHOOSE; } public boolean checkHasRight(){ // 按LBO进行数据权限检查 setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_FB); return super.checkHasRight(); } /** * 判断执行Action任务之前是否需要先选择数据 */ public boolean beforePost() { //获得按钮参数 paramsMap = getButtonParams(); if(paramsMap.containsKey("needselect")){ String value = paramsMap.get("needselect"); if(value.equalsIgnoreCase("true")){ needSelect = true; } } if(needSelect){ if(!isSelectedObject()) return false; Object[] objs = getDataModel().getSelectObjects(); if(objs.length > 1){ VCIJOptionPane.showMessage(getParentComponent(), "只能选择一条数据执行创建操作!"); return false; } } return true; } @Override public boolean doPost() { try { //获得按钮参数 paramsMap = getButtonParams(); //得到打开窗口的上下文信息 String type = paramsMap.get("type"); String context = paramsMap.get("context"); String directionStr = paramsMap.get("direction"); if(type == null || type.equals("") || context == null || context.equals("")){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.parmerror", ""); return false; } /** * 判断是否是正向还是反向 */ boolean direction = true; if(directionStr != null && directionStr.trim().equalsIgnoreCase("false")){ direction = 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; } //判断创建表单类型 PortalVI sheet = UITools.getService().getPortalVIBySymbol(formName); if(sheet != null){ this.operationType = sheet.typeFlag; } //打开创建但link窗口 oad = new ObjectAddEditDialog(type, context, plDef, paramsMap, ObjectAddEditDialog.OperateType.SELECT, null, this); //获得sourceDate,source可能来自用户选择的数据,也可能来自父窗口传递的数据 if(needSelect){ oad.setSourceDataNode((IDataNode)getDataModel().getSelectObjects()[0]); } else { oad.setSourceDataNode(getRegionPanel().getSourceData()); } oad.setTypeFlag(operationType); oad.init(); oad.setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT); oad.setLocationRelativeTo(ClientContextVariable.getFrame()); oad.setVisible(true); if(oad.getDialogResult() == DialogResult.OK){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.choosesuccessmsg"); return true; } else { return false; } } catch (Throwable e){ UIFUtils.showErrorMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.chooseerror",e); return false; } } }