1 /*
2 * XMLCV - Gestion de CV sous forme XML
3 *
4 * Copyright (C) 2004-2005, Damien Raude-Morvan
5 *
6 * This file is part of XMLCV.
7 *
8 * XMLCV is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * XMLCV is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with XMLCV; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Contacts :
23 * - Sébastien Mathy <smathy@tuxfamily.org>
24 * - Emmanuel Berre <eberre@tuxfamily.org>
25 * - Damien Raude-Morvan <drazzib@drazzib.com>
26 */
27 package org.xmlcv;
28
29 import java.io.File;
30
31 import javax.xml.transform.stream.StreamSource;
32
33 import org.xmlcv.util.Config;
34
35 /***
36 * Thread for AWT Preview <b><i>REALLY BROKEN </i> </b>
37 *
38 * @see org.xmlcv.Convert
39 * @version $Revision: 114 $
40 * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
41 */
42 public class ConvertPreview extends Convert {
43
44 /***
45 * Convert a <code>in</code> file to a HTML with an <code>xslt</code>
46 * stylesheet, the resulting streaming is shown in an AWT Frame.
47 *
48 * @param in
49 * xml file at XMLCV format
50 * @param xslt
51 * xslt stylsheet applied to <code>in</code>
52 */
53 public ConvertPreview(File in, File xslt) {
54 super(new StreamSource(in), new StreamSource(xslt));
55 }
56
57 /***
58 * @param cv
59 */
60 public ConvertPreview(CVModel cv) {
61 super(new StreamSource(cv.getInputStream()), new StreamSource(
62 Config.STYLES_XSL_FO));
63 this.go();
64 }
65
66 public static final String TRANSLATION_PATH = "/org/apache/fop/viewer/resources/"; //$NON-NLS-1$
67
68 /*
69 * protected PreviewDialog createPreviewDialog(FOUserAgent renderer) {
70 * PreviewDialog frame = new PreviewDialog(renderer); frame.validate();
71 * frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); //
72 * center window Dimension screenSize =
73 * Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize =
74 * frame.getSize(); if (frameSize.height > screenSize.height)
75 * frameSize.height = screenSize.height; if (frameSize.width >
76 * screenSize.width) frameSize.width = screenSize.width;
77 * frame.setLocationRelativeTo(null); frame.setVisible(true); return frame; }
78 */
79
80 /*
81 * private SecureResourceBundle getResourceBundle(String path) throws
82 * IOException { URL url = getClass().getResource(path); if (url == null) { //
83 * if the given resource file not found, the english resource uses // as
84 * default path = path.substring(0, path.lastIndexOf(".")) + ".en"; url =
85 * getClass().getResource(path); } return new
86 * SecureResourceBundle(url.openStream()); }
87 */
88
89 public void go() {
90
91 /*
92 * //Setup l18n //String language = System.getProperty("user.language");
93 * //Translator translator = getResourceBundle(TRANSLATION_PATH // +
94 * "resources." + language); //translator.setMissingEmphasized(false);
95 *
96 * //UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH // +
97 * "messages." + language));
98 *
99 * //Setup renderer AWTRenderer renderer = new AWTRenderer();
100 * FOUserAgent agent = new FOUserAgent();
101 * agent.setRendererOverride(renderer); // Create preview dialog (target
102 * for the AWTRenderer) PreviewDialog frame =
103 * createPreviewDialog(agent); //renderer.setProgressListener(frame);
104 * //renderer.setComponent(frame); // Setup Driver Fop driver = new
105 * Fop(Constants.RENDER_AWT); //driver.setLogger(new
106 * ConsoleLogger(ConsoleLogger.LEVEL_INFO));
107 * //driver.setRenderer(renderer); // build FO tree: time
108 * //frame.progress(translator.getString("Build FO tree") + " ...");
109 *
110 * Result res; try { setupTransformer();
111 *
112 * res = new SAXResult(driver.getDefaultHandler());
113 * this._transformer.transform(this._srcXml, res); // Show page
114 * //frame.progress(translator.getString("Show")); frame.showPage(); }
115 * catch (FOPException e) { e.printStackTrace(); } catch
116 * (TransformerException e) { e.printStackTrace(); }
117 */
118
119 }
120 }