1 24 25 package org.objectweb.cjdbc.console.gui.threads; 26 27 import java.awt.event.KeyEvent ; 28 import java.awt.event.KeyListener ; 29 import java.util.ArrayList ; 30 31 import javax.swing.JTextPane ; 32 import javax.swing.event.CaretEvent ; 33 import javax.swing.event.CaretListener ; 34 35 import org.objectweb.cjdbc.common.xml.XmlValidator; 36 37 43 public class GuiParsingThread extends Thread 44 implements 45 KeyListener , 46 CaretListener 47 { 48 private JTextPane xmlTextPane; 49 private JTextPane outputPane; 50 51 54 59 public GuiParsingThread(JTextPane xmlTextPane) 60 { 61 this.xmlTextPane = xmlTextPane; 62 68 } 69 70 73 public void run() 74 { 75 while (true) 76 { 77 synchronized (this) 78 { 79 try 80 { 81 wait(); 82 } 83 catch (InterruptedException e) 84 { 85 } 86 XmlValidator validator = new XmlValidator("c-jdbc-controller.dtd", 87 xmlTextPane.getText()); 88 StringBuffer buffer = new StringBuffer (); 89 ArrayList exceptions = validator.getExceptions(); 90 for (int i = 0; i < exceptions.size(); i++) 91 buffer.append(((Exception ) (exceptions.get(i))).getMessage() + "\n"); 92 outputPane.setText(buffer.toString()); 93 } 94 } 95 } 96 97 100 public void keyPressed(KeyEvent e) 101 { 102 synchronized (this) 103 { 104 this.notify(); 105 } 106 } 107 108 111 public void keyReleased(KeyEvent e) 112 { 113 } 114 115 118 public void keyTyped(KeyEvent e) 119 { 120 121 } 122 123 128 public void setOutputPane(JTextPane rightPane) 129 { 130 this.outputPane = rightPane; 131 } 132 133 136 public void caretUpdate(CaretEvent e) 137 { 138 204 } 205 206 } | Popular Tags |