package com.vci.client.uif.actions.client;
|
|
import java.util.Map;
|
|
import com.vci.client.bof.ClientBusinessObject;
|
import com.vci.client.bof.ClientBusinessObjectOperation;
|
import com.vci.client.ui.swing.components.VCIJDialog;
|
import com.vci.client.ui.swing.components.VCIJDialog.DialogResult;
|
import com.vci.client.uif.engine.client.objopt.ObjectAddEditDialog;
|
import com.vci.client.uif.engine.common.IDataNode;
|
|
public class AddSaveAction extends DoseNotSelectDataAction {
|
|
@Override
|
public String getKey() {
|
return ADD_SAVE;
|
}
|
|
@Override
|
public boolean checkHasRight() {
|
return true;
|
}
|
|
@SuppressWarnings("deprecation")
|
@Override
|
public boolean doPost() {
|
// 获得按钮所属窗口
|
ObjectAddEditDialog oaed = null;
|
VCIJDialog dialog = getOwnerDialog();
|
if (dialog instanceof ObjectAddEditDialog) {
|
oaed = (ObjectAddEditDialog) dialog;
|
}
|
if (oaed == null) {
|
return false;
|
}
|
// 判断创建的是否是文件夹
|
IDataNode idn = oaed.getSourceDataNode();
|
boolean createFolder = false;
|
if(idn != null) {
|
Map<String, String> valueMap = idn.getValueMap();
|
if (valueMap.containsKey("AddCreateFolder")) {
|
createFolder = true;
|
}
|
}
|
Object obj = getDataModel().getRootObject();
|
if (obj instanceof IDataNode) {
|
IDataNode dataNode = (IDataNode) obj;
|
obj = dataNode.getMaterObject();
|
if (obj instanceof ClientBusinessObject) {
|
ClientBusinessObject cbo = (ClientBusinessObject) obj;
|
ClientBusinessObjectOperation boOperation = new ClientBusinessObjectOperation();
|
try {
|
// 如果是创建文件夹
|
if (createFolder) {
|
// 获得用于存储父对象ID的属性名称
|
Map<String, String> valueMap = idn.getValueMap();
|
String attrName = "";
|
String showLinkAbs = valueMap.get("AddShowLinkAbs");
|
String separator = valueMap.get("AddSeparator");
|
if (showLinkAbs != null && separator != null
|
&& !separator.equals("")) {
|
if (showLinkAbs.indexOf(separator) != -1) {
|
attrName = showLinkAbs.substring(0,
|
showLinkAbs.indexOf(","));
|
} else {
|
attrName = showLinkAbs;
|
}
|
}
|
if (idn.getMaterObject() instanceof String) {
|
// 如果是文件夹的根节点
|
cbo.setAttributeValue(attrName,
|
(String) idn.getMaterObject(), true);
|
|
} else {
|
cbo.setAttributeValue(attrName,
|
((ClientBusinessObject) idn
|
.getMaterObject())
|
.getBusinessObject().oid, true);
|
}
|
}
|
// 上传文件
|
if (!UploadFile(oaed, cbo)) {
|
// operation.showMessage(ClientContextVariable.getFrame(),
|
// "uifmodel.plm.uif.actions.createlinkerror");
|
// return false;
|
}
|
boOperation.saveCreateBuinessObject(cbo);
|
closeOwnerDailog(getOwnerDialog(), DialogResult.OK);
|
// 调用此按钮所在Dialog注册的回调函数
|
super.invokeOwnedDialogCallback();
|
UIFUtils.showMessage(getParentComponent(),
|
"uifmodel.plm.uif.actions.createsuccessmsg",
|
cbo.getName());
|
} catch (Exception e) {
|
UIFUtils.showErrorMessage(getParentComponent(), e);
|
}
|
}
|
}
|
return true;
|
}
|
}
|