1 29 30 package it.businesslogic.ireport.data; 31 32 import it.businesslogic.ireport.JRField; 33 import it.businesslogic.ireport.data.ejbql.EJBQLFieldsReader; 34 import it.businesslogic.ireport.gui.MainFrame; 35 import java.util.ArrayList ; 36 import java.util.List ; 37 import java.util.Vector ; 38 39 43 public class EJBQLBeanInspectorPanel extends BeanInspectorPanel { 44 45 46 public EJBQLBeanInspectorPanel() { 47 super(); 48 49 } 50 51 54 public void queryChanged(String newQuery) { 55 56 lastExecution++; 57 int thisExecution = lastExecution; 58 60 String error_msg = ""; 61 lastExecution++; 62 63 int in = lastExecution; 64 65 getReportQueryDialog().getJLabelStatusSQL().setText("Executing EJBQL query...."); 66 68 try { 69 Thread.currentThread().setContextClassLoader( MainFrame.getMainInstance().getReportClassLoader()); 70 } catch (Exception ex) 71 { 72 ex.printStackTrace(); 73 } 74 75 if (in < lastExecution) return; 77 EJBQLFieldsReader ejbqlFR = new EJBQLFieldsReader(newQuery, getReportQueryDialog().getSubDataset().getParameters()); 78 79 try { 80 Vector fields = ejbqlFR.readFields(); 81 82 List columns = new ArrayList (); 83 for (int i=0; i<fields.size(); ++i) 84 { 85 JRField field = (JRField)fields.elementAt(i); 86 columns.add( new Object []{field, field.getClassType(), field.getDescription()} ); 87 } 88 Vector v = null; 89 if (ejbqlFR.getSingleClassName() != null) 90 { 91 v = new Vector (); 92 v.add( ejbqlFR.getSingleClassName() ); 93 } 94 95 System.out.println("Single class name: " + ejbqlFR.getSingleClassName()); 96 97 setBeanExplorerFromWorker(v,true,false); 98 setColumnsFromWorker(columns); 99 100 } catch (Exception ex) 101 { 102 ex.printStackTrace(); 103 setBeanExplorerFromWorker(null,true,false); 104 setColumnErrorFromWork( "Error: " + ex.getMessage() ); 105 } 106 107 getReportQueryDialog().getJLabelStatusSQL().setText("Ready"); 108 } 109 110 } 111 | Popular Tags |