KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cve > esecutori > components > automatonB > WriteWippogSpe


1 package cve.esecutori.components.automatonB;
2
3 import java.io.File JavaDoc;
4 import java.io.IOException JavaDoc;
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 /**
23 * Classe astratta che mette a disposizione i metodi per la creazione di una specifica Wippog
24 *
25 * @see cve.esecutori.components.automatonB.IGenerationSentence
26 * @see cve.esecutori.components.automatonB.IAutomaControllo
27 *
28 * @version 1.0 09/01/02
29 * @author Domenico Ventriglia
30 */

31 abstract class WriteWippogSpe {
32    /**
33    * document dom generato,
34    */

35    protected Document document;
36
37    protected String JavaDoc absoluteFileLanguage, nameFileLanguage, filePath, fileSent;
38
39    /**
40    * Restituisce nome del file
41    *
42    */

43    String JavaDoc getAbsoluteFile(){
44       Cve.errLog.debug("");
45       return absoluteFileLanguage;
46    }
47
48    /**
49    * pre: deve essere creato il documento sentDoc
50    * post:result e' la scrittura del documento sul file nomefile
51    *
52    */

53    protected File JavaDoc saveFileXml(String JavaDoc title) {
54       //File current=new File(ConfigurationRead.getCveRoot()+"/VisualLanguage/SpecificheWippog");
55
//GF Lettura path da cveConfiguration
56
Cve.errLog.debug("");
57       File JavaDoc current=new File JavaDoc(ConfigurationRead.getCveRoot()+ConfigurationRead.getCveWSpeRoot());
58
59       File JavaDoc fileLang=getFileXml(current,title);
60       if (nameFileLanguage!=null) {
61          fileSent=filePath+"\\"+"Sent_"+nameFileLanguage;
62          File JavaDoc fileS = new File JavaDoc(fileSent);
63          try {
64             FileWriter outS= new FileWriter (fileS);
65             XMLOutputter fmtS = new XMLOutputter(" ",true);
66             String JavaDoc appS=fmtS.outputString(document);
67             outS.write(appS);
68             outS.close();
69          } catch( IOException JavaDoc 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    /**
78    * pre: deve essere creato il documento sentDoc
79    * post:result e' la scrittura del documento sul file nomefile
80    *
81    */

82    protected String JavaDoc saveFileAut(File JavaDoc fileLang) {
83       Cve.errLog.debug("");
84       nameFileLanguage=fileLang.getPath();
85       if (nameFileLanguage!=null) {
86          File JavaDoc fileAut = new File JavaDoc(nameFileLanguage);
87          try {
88             FileWriter outS= new FileWriter (fileAut);
89             XMLOutputter fmtS = new XMLOutputter(" ",true);
90             String JavaDoc appS=fmtS.outputString(document);
91             outS.write(appS);
92             outS.close();
93          } catch( IOException JavaDoc 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    /* ############### PRIVATE ########### */
105
106    /**
107    * Logica: dialog per la scelta del nome del file da salvare
108    * Result: il nome del file da salvare
109    */

110    private File JavaDoc getFileXml(File JavaDoc current,String JavaDoc title) {
111       Cve.errLog.debug("");
112       JFrame fr=new JFrame();
113       File JavaDoc file=null;
114       //File current=new File("c:/cve1.0/VisualLanguage/SpecificheWippog");
115
final JFileChooser fc = new JFileChooser();
116       //fc.setDialogType(JFileChooser.CUSTOM_DIALOG);
117
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