1 package cve.esecutori.components.automatonB; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 import java.io.*; 6 import java.util.*; 7 8 import org.jdom.*; 9 import org.jdom.Document; 10 import org.jdom.Element; 11 import org.jdom.JDOMException; 12 import org.jdom.input.SAXBuilder; 13 import org.jdom.output.XMLOutputter; 14 15 import javax.swing.*; 16 17 import cve.staticLayout.*; 18 import cve.util.ConfigurationRead; 19 20 import org.apache.log4j.Logger; 21 22 31 abstract class WriteWippogSpe { 32 35 protected Document document; 36 37 protected String absoluteFileLanguage, nameFileLanguage, filePath, fileSent; 38 39 43 String getAbsoluteFile(){ 44 Cve.errLog.debug(""); 45 return absoluteFileLanguage; 46 } 47 48 53 protected File saveFileXml(String title) { 54 Cve.errLog.debug(""); 57 File current=new File (ConfigurationRead.getCveRoot()+ConfigurationRead.getCveWSpeRoot()); 58 59 File fileLang=getFileXml(current,title); 60 if (nameFileLanguage!=null) { 61 fileSent=filePath+"\\"+"Sent_"+nameFileLanguage; 62 File fileS = new File (fileSent); 63 try { 64 FileWriter outS= new FileWriter (fileS); 65 XMLOutputter fmtS = new XMLOutputter(" ",true); 66 String appS=fmtS.outputString(document); 67 outS.write(appS); 68 outS.close(); 69 } catch( IOException e) { 70 Cve.errLog.error(e.toString()); 71 ViewLog.writeInLog(" problemi nell'aprire il file sent"+"/n"); 72 } 73 } 74 return fileLang; 75 } 76 77 82 protected String saveFileAut(File fileLang) { 83 Cve.errLog.debug(""); 84 nameFileLanguage=fileLang.getPath(); 85 if (nameFileLanguage!=null) { 86 File fileAut = new File (nameFileLanguage); 87 try { 88 FileWriter outS= new FileWriter (fileAut); 89 XMLOutputter fmtS = new XMLOutputter(" ",true); 90 String appS=fmtS.outputString(document); 91 outS.write(appS); 92 outS.close(); 93 } catch( IOException e) { 94 Cve.errLog.error("problemi nell'aprire il file automa "+e.toString()); 95 } 96 } 97 return nameFileLanguage; 98 } 99 100 abstract protected void wippogDefines(); 101 abstract protected void wippogImport(); 102 abstract protected void wippogExport(); 103 104 105 106 110 private File getFileXml(File current,String title) { 111 Cve.errLog.debug(""); 112 JFrame fr=new JFrame(); 113 File file=null; 114 final JFileChooser fc = new JFileChooser(); 116 fc.setDialogTitle(title); 118 fc.setApproveButtonText("Save"); 119 fc.setCurrentDirectory(current); 120 int returnVal = fc.showOpenDialog(fr); 121 if (returnVal == JFileChooser.APPROVE_OPTION) { 122 file = fc.getSelectedFile(); 123 nameFileLanguage=file.getName(); 124 filePath=file.getParent(); 125 absoluteFileLanguage=file.getPath(); 126 127 } 128 return file; 129 } 130 131 } 132 133 | Popular Tags |