00001
00025
package org.objectweb.cjdbc.console.gui.threads;
00026
00027
import java.awt.event.KeyEvent;
00028
import java.awt.event.KeyListener;
00029
import java.util.ArrayList;
00030
00031
import javax.swing.JTextPane;
00032
import javax.swing.event.CaretEvent;
00033
import javax.swing.event.CaretListener;
00034
00035
import org.objectweb.cjdbc.common.xml.XmlValidator;
00036
00037
import com.wutka.dtd.DTD;
00038
import com.wutka.dtd.DTDParser;
00039
00046 public class GuiParsingThread extends Thread
00047 implements
00048 KeyListener,
00049 CaretListener
00050 {
00051 private JTextPane
xmlTextPane;
00052 private JTextPane
outputPane;
00053 private DTDParser
dtdparser;
00054 private DTD
dtd;
00055
00061 public GuiParsingThread(JTextPane xmlTextPane)
00062 {
00063
this.xmlTextPane = xmlTextPane;
00064
00065
try
00066 {
00067
this.dtdparser =
new DTDParser(
this.getClass().getResource(
00068
"/c-jdbc-controller.dtd"));
00069
dtd =
dtdparser.parse();
00070 }
00071
catch (Exception e)
00072 {
00073 e.printStackTrace();
00074 }
00075 }
00076
00082 public DTD
getDtd()
00083 {
00084
return dtd;
00085 }
00086
00090 public void run()
00091 {
00092
while (
true)
00093 {
00094
synchronized (
this)
00095 {
00096
try
00097 {
00098 wait();
00099 }
00100
catch (InterruptedException e)
00101 {
00102 }
00103
XmlValidator validator =
new XmlValidator(
"c-jdbc-controller.dtd",
00104
xmlTextPane.getText());
00105 StringBuffer buffer =
new StringBuffer();
00106 ArrayList exceptions = validator.
getExceptions();
00107
for (
int i = 0; i < exceptions.size(); i++)
00108 buffer.append(((Exception) (exceptions.get(i))).getMessage() +
"\n");
00109
outputPane.setText(buffer.toString());
00110 }
00111 }
00112 }
00113
00117 public void keyPressed(KeyEvent e)
00118 {
00119
synchronized (
this)
00120 {
00121
this.notify();
00122 }
00123 }
00124
00128 public void keyReleased(KeyEvent e)
00129 {
00130 }
00131
00135 public void keyTyped(KeyEvent e)
00136 {
00137
00138 }
00139
00145 public void setOutputPane(JTextPane rightPane)
00146 {
00147
this.outputPane = rightPane;
00148 }
00149
00153 public void caretUpdate(CaretEvent e)
00154 {
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 }