KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > wizard > XmlValidatorFrame


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.wizard;
26
27 import java.awt.Color JavaDoc;
28 import java.awt.HeadlessException JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 import javax.swing.JFrame JavaDoc;
32 import javax.swing.JTextArea JavaDoc;
33
34 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
35 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
36 import org.objectweb.cjdbc.console.gui.jtools.JTextAreaWriter;
37
38 /**
39  * Used to report results of validating a database xml configuration file.
40  *
41  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
42  * @version 1.0
43  */

44 public class XmlValidatorFrame extends JFrame JavaDoc
45 {
46
47   final String JavaDoc eol = System.getProperty("line.separator");
48   JTextArea JavaDoc report;
49   JTextAreaWriter writer;
50
51   /**
52    * Creates a new <code>XmlValidatorFrame</code> object
53    *
54    * @param fileName the file to validate
55    * @throws java.awt.HeadlessException if an error occurs
56    */

57   public XmlValidatorFrame(String JavaDoc fileName) throws HeadlessException JavaDoc
58   {
59     super(WizardTranslate.get("init.validator.frame"));
60     GuiConstants.centerComponent(this, WizardConstants.VALIDATOR_WIDTH,
61         WizardConstants.VALIDATOR_HEIGHT);
62     this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
63     report = new JTextArea JavaDoc();
64     writer = new JTextAreaWriter(report);
65     report.setForeground(new Color JavaDoc(9498256));
66     this.getContentPane().add(report);
67     this.pack();
68     this.setVisible(true);
69     writeLine(WizardTranslate.get("init.validator.echo", fileName));
70   }
71
72   /**
73    * Append a line to the text area
74    *
75    * @param s the string to append
76    */

77   public void writeLine(String JavaDoc s)
78   {
79     try
80     {
81       writer.write(s + eol);
82       writer.flush();
83       report.repaint();
84     }
85     catch (IOException JavaDoc e)
86     {
87       e.printStackTrace();
88     }
89   }
90
91   /**
92    * Set Warning color on the report
93    */

94   public void setWarning()
95   {
96     report.setForeground(new Color JavaDoc(16758465));
97   }
98
99 }
Popular Tags