previewForm.setName("preview");
edit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
SystemLauncher launcher = new SystemLauncher(){
public void completed(){
}
public void write(String line){
//Do nothing....
}
};
//TODO: 1. 서버에 있는 Form html을 읽어서 file로 저장.
//FIXME: production 버전을 갖고 와야함
FormActivity formActivity = (FormActivity) getActivity();
HtmlFormContext formContext = (HtmlFormContext) formActivity.getVariableForHtmlFormContext().getDefaultValue();
String formDefID[] = formContext.getFormDefId().split("@");
openedForm = new OpenedForm();
openedForm.formDefVerId = formDefID[1];
openedForm.formName = formDefID[0].replaceAll("[\\[||\\]]","");
openedForm.launcher = launcher; //may result huge memory resident in the static variable "openedForms"
String fileName = openedForm.formName + ".jsp";
String tempFilePath = System.getProperty("temp.path", "C:\\uengine\\");
File newFile = new File(tempFilePath);
if(!newFile.exists()){
newFile.mkdirs();
}
tempFilePath = tempFilePath + File.separatorChar + fileName;
openedForm.localFilePath = tempFilePath;
InputStream is;
try {
is = ProcessDesigner.getInstance().getClientProxy().showFormDefinitionWithVersionId(formDefID[1]);
File outFile = new File(tempFilePath);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
/*if(is!=null){
byte [] buf = new byte[1024];
int len;
while ((len = is.read(buf)) > 0) {
bos.write(buf, 0, len);
}
is.close();
}
bos.close();*/
if(is!=null)
org.uengine.util.UEngineUtil.copyStream(is, bos);
openedForm.lastModified = outFile.lastModified();
//openedForm.
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String tool = System.getProperty("form.editor", "notepad");
//review: this command will work only in Windows
launcher.run(
"cmd /c \"" + tool + "\" " + tempFilePath
);
openedForms.put(openedForm.formName, openedForm);