200 lines
7.0 KiB
Java
200 lines
7.0 KiB
Java
package com.tenwa.reckon.product;
|
|
|
|
import java.io.File;
|
|
import java.lang.reflect.Constructor;
|
|
import java.util.ArrayList;
|
|
import java.util.Hashtable;
|
|
import java.util.Iterator;
|
|
|
|
import com.amarsoft.are.lang.StringX;
|
|
import com.amarsoft.awe.dw.ASDataObject;
|
|
import com.amarsoft.awe.dw.datamodel.CatalogModel;
|
|
import com.amarsoft.awe.dw.datamodel.StyleModel;
|
|
import com.amarsoft.awe.dw.ui.page.GenHtmlImp;
|
|
import com.amarsoft.awe.dw.ui.page.body.GenBodyData;
|
|
import com.amarsoft.awe.dw.ui.page.body.GenBodyDataImp1;
|
|
import com.amarsoft.awe.dw.ui.page.body.GenBodyDataImp2;
|
|
import com.amarsoft.awe.dw.ui.style.data.PageStyleData;
|
|
import com.amarsoft.awe.dw.ui.style.data.StyleFactory;
|
|
import com.amarsoft.awe.dw.ui.util.Const;
|
|
import com.amarsoft.awe.dw.ui.util.PublicFuns;
|
|
import com.amarsoft.dict.als.cache.AWEDataWindowCache;
|
|
|
|
public class GenHtmlImpCalc extends GenHtmlImp{
|
|
|
|
public ASObjectWindowCalc datawindow;
|
|
private GenBodyData body;
|
|
|
|
public String[] groupHidden;
|
|
|
|
public static PageStyleData getPageStyleData(String dono, String styleId,
|
|
String webRootPath, String clientID) throws Exception {
|
|
String sPageStyleFactory = Const.getPageStyleFactory();
|
|
StyleFactory pfactory = (StyleFactory) Class.forName(sPageStyleFactory)
|
|
.newInstance();
|
|
if (styleId == null || styleId.equals(""))
|
|
pfactory.setDono(dono);
|
|
|
|
PageStyleData psd = pfactory.createPageData(styleId, webRootPath,
|
|
clientID);
|
|
return psd;
|
|
}
|
|
|
|
private static StyleModel getStyleModel(String modeId) {
|
|
if (StringX.isEmpty(modeId))
|
|
modeId = "default";
|
|
ArrayList list = AWEDataWindowCache.getInstance().getStyleList();
|
|
for (Iterator i$ = list.iterator(); i$.hasNext();) {
|
|
StyleModel styleModel = (StyleModel) i$.next();
|
|
if (styleModel.getStyleId().equals(modeId))
|
|
return styleModel;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static PageStyleData getPageStyleData(String modeId, String webRootPath,
|
|
String clientID) throws Exception {
|
|
PageStyleData pageStyleData = new PageStyleData();
|
|
pageStyleData.modeid = modeId;
|
|
pageStyleData.modeName = modeId;
|
|
pageStyleData.modeDesc = "";
|
|
pageStyleData.head = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "html_head");
|
|
pageStyleData.draghead = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "control_head");
|
|
pageStyleData.dragfoot = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "control_foot");
|
|
pageStyleData.grouphead = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "group_head");
|
|
pageStyleData.groupFoot = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "group_foot");
|
|
pageStyleData.groupBody1 = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "group_body1");
|
|
pageStyleData.groupBody2 = getCodeFromFile("", pageStyleData.modeid,
|
|
webRootPath, "group_body2");
|
|
return pageStyleData;
|
|
}
|
|
|
|
private static String getCodeFromFile(String html, String modeId,
|
|
String webRootPath, String filename) throws Exception {
|
|
String sFileName = "";
|
|
if (html == null || html.equals("")) {
|
|
sFileName = (new StringBuilder()).append(webRootPath)
|
|
.append("/Frame/web/dw/designer/").append(filename)
|
|
.append(".htm").toString();
|
|
} else {
|
|
sFileName = html.replaceAll("\\{ROOTPATH\\}", webRootPath);
|
|
sFileName = sFileName.replaceAll("\\{RESOURCEPATH\\}",
|
|
Const.getDWControlPath(webRootPath));
|
|
sFileName = sFileName.replaceAll("\\{MODEID\\}", modeId);
|
|
}
|
|
File file = new File(sFileName);
|
|
if (file.exists())
|
|
return PublicFuns.getBodyFromFile(file);
|
|
else
|
|
return "";
|
|
}
|
|
|
|
public GenHtmlImpCalc(ASDataObject asObj, ArrayList datas,PageStyleData pageStyleData, String[] groupinfo, int editstatus,String webRootPath,ArrayList hiddenDatas,ASObjectWindowCalc datawindow) throws Exception {
|
|
super(asObj, datas, pageStyleData, groupinfo, editstatus, webRootPath);
|
|
this.groupHidden=datawindow.getGroupHidden().split(",");
|
|
this.datawindow=datawindow;
|
|
groupOut = new String[3];
|
|
hidGroupHeadAndFoot = false;
|
|
this.asObj = asObj;
|
|
this.datas = datas;
|
|
this.pageStyleData = pageStyleData;
|
|
this.webRootPath = webRootPath;
|
|
int iColCount = 0;
|
|
if (groupinfo[9] == null || groupinfo[9].equals("")|| groupinfo[9].equals("0")) {
|
|
CatalogModel obj = AWEDataWindowCache.getInstance().getCatalogModel(asObj.getDONO());
|
|
if (obj == null || obj.getColCount() == null|| obj.getColCount().equals("0"))
|
|
iColCount = 1;
|
|
else
|
|
iColCount = Integer.parseInt(obj.getColCount());
|
|
} else {
|
|
iColCount = Integer.parseInt(groupinfo[9]);
|
|
if (iColCount == 0)
|
|
iColCount = 1;
|
|
}
|
|
String sGroupBody = "";
|
|
if (iColCount == 1 || pageStyleData.groupBodyParser != null
|
|
&& pageStyleData.groupBodyParser.trim().length() > 0) {
|
|
sGroupBody = groupinfo[6];
|
|
if (sGroupBody == null || sGroupBody.equals(""))
|
|
sGroupBody = pageStyleData.groupBody1;
|
|
} else{
|
|
sGroupBody = groupinfo[7];
|
|
if (sGroupBody == null || sGroupBody.equals(""))
|
|
sGroupBody = pageStyleData.groupBody2;
|
|
}
|
|
if (pageStyleData.groupBodyParser == null|| pageStyleData.groupBodyParser.length() == 0) {
|
|
body = new GenBodyDataImpCalc(this.asObj, datas, sGroupBody,hiddenDatas,datawindow,iColCount);
|
|
body.setEditstatus(editstatus);
|
|
} else {
|
|
Class clz = Class.forName(pageStyleData.groupBodyParser);
|
|
Constructor c = clz.getConstructor(new Class[] {ASDataObject.class,ArrayList.class, String.class });
|
|
body = (GenBodyData) c.newInstance(new Object[] { this.asObj,datas, sGroupBody });
|
|
body.setEditstatus(editstatus);
|
|
}
|
|
groupOut[1] = sGroupBody;
|
|
for (int i = 0; i < groupinfo.length; i++)
|
|
if (groupinfo[i] == null)
|
|
groupinfo[i] = "";
|
|
|
|
this.groupinfo = groupinfo;
|
|
}
|
|
|
|
public String gen(Hashtable values) throws Exception {
|
|
String sHead = getGroupHead();
|
|
groupOut[0] = sHead;
|
|
String sBody = body.getGroupBody(values, webRootPath);
|
|
String sFoot = getGroupFoot();
|
|
groupOut[2] = sFoot;
|
|
return (new StringBuilder()).append(sHead).append(sBody).append(sFoot)
|
|
.toString();
|
|
}
|
|
|
|
public String getGroupHead() {
|
|
if (hidGroupHeadAndFoot)
|
|
return "";
|
|
String sHead = "";
|
|
if (groupinfo[4] == null || groupinfo[4].trim().equals(""))
|
|
sHead = pageStyleData.grouphead;
|
|
else
|
|
sHead = groupinfo[4];
|
|
|
|
String display="block";
|
|
for(int i=0;i<this.groupHidden.length;i++){
|
|
if(groupinfo[0].equals(this.groupHidden[i])){
|
|
display="none";
|
|
break;
|
|
}
|
|
}
|
|
|
|
sHead = sHead.replaceAll("\\{INDEX\\}", groupinfo[0]);
|
|
sHead = sHead.replaceAll("\\{TITLE\\}", groupinfo[1]);
|
|
sHead = sHead.replaceAll("\\{DESC\\}", groupinfo[2]);
|
|
sHead = sHead.replaceAll("\\{SYS_EXPAND\\}",(new StringBuilder()).append("<span type=\"EXPAND\" onclick=\"try{changeExpand(this)}catch(e){};\" groupid=\"")
|
|
.append(groupinfo[0]).append("\" id=\"EXP_")
|
|
.append(groupinfo[0]).append("\"></span>")
|
|
.toString());
|
|
sHead = sHead.replaceAll("\\{RESOURCEPATH\\}",
|
|
Const.getDWControlPath(webRootPath));
|
|
sHead = sHead.replaceAll("\\{ROOTPATH\\}", webRootPath);
|
|
sHead=sHead.replaceAll("\\{display\\}", display);
|
|
return sHead;
|
|
}
|
|
|
|
public ASObjectWindowCalc getDatawindow() {
|
|
return datawindow;
|
|
}
|
|
|
|
public void setDatawindow(ASObjectWindowCalc datawindow) {
|
|
this.datawindow = datawindow;
|
|
}
|
|
|
|
|
|
}
|