1 29 30 package it.businesslogic.ireport.data; 31 32 import it.businesslogic.ireport.FieldsProvider; 33 import it.businesslogic.ireport.FieldsProviderEditor; 34 import it.businesslogic.ireport.IReportConnection; 35 import it.businesslogic.ireport.connection.JRXMLADataSourceConnection; 36 import it.businesslogic.ireport.data.olap.OlapBrowser; 37 import it.businesslogic.ireport.gui.MainFrame; 38 import it.businesslogic.ireport.gui.ReportQueryDialog; 39 import it.businesslogic.ireport.util.I18n; 40 import java.awt.Component ; 41 import java.util.Map ; 42 import net.sf.jasperreports.engine.JRDataset; 43 import net.sf.jasperreports.engine.JRException; 44 import net.sf.jasperreports.engine.JRField; 45 import rex.event.RexWizardEvent; 46 import rex.event.RexWizardListener; 47 import rex.graphics.mdxeditor.RexWizard; 48 49 53 public class MDXFieldsProvider implements FieldsProvider, RexWizardListener { 54 55 private OlapBrowser olapBrowser = null; 56 protected String getQueryFromRex = ""; 57 58 public static boolean useVisualDesigner = true; 59 60 static { 61 62 java.util.Properties p = new java.util.Properties (); 63 try { 64 p.load( MDXFieldsProvider.class.getClass().getResourceAsStream("/it/businesslogic/ireport/data/fieldsprovider.properties") ); 65 66 if (p.getProperty("mdx").equals("0")) 67 { 68 useVisualDesigner = false; 69 System.out.println("ReX designer disabled"); 70 } 71 } catch (Exception ex) 72 { 73 ex.printStackTrace(); 74 } 75 76 } 77 78 79 80 81 public MDXFieldsProvider() { 82 } 83 84 91 public boolean supportsGetFieldsOperation() { 92 return false; 93 } 94 95 public JRField[] getFields(IReportConnection con, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { 96 return null; 97 } 98 99 public boolean supportsAutomaticQueryExecution() { 100 return true; 101 } 102 103 public boolean hasQueryDesigner() { 104 return useVisualDesigner; 105 } 106 107 public boolean hasEditorComponent() { 108 return true; 109 } 110 111 116 117 123 boolean gotMdxResult = false; 124 public String designQuery(IReportConnection con, String query, ReportQueryDialog reportQueryDialog) throws JRException, UnsupportedOperationException { 125 126 String newMDXQuery = query; 127 if (query == null) newMDXQuery = ""; 128 129 if (con instanceof JRXMLADataSourceConnection) 130 { 131 String strURL = ((JRXMLADataSourceConnection)con).getUrl(); 132 133 String strDataSource = ((JRXMLADataSourceConnection)con).getDatasource(); 134 135 String strCatalog = ((JRXMLADataSourceConnection)con).getCatalog(); 136 137 String strCubeName=((JRXMLADataSourceConnection)con).getCube(); 138 139 141 RexWizard mdxWizard= new RexWizard(strURL, strDataSource, strCatalog, 142 strCubeName,newMDXQuery); 143 mdxWizard.addRexWizardListener(this); 145 146 mdxWizard.showDialog(); 147 148 156 if (getQueryFromRex.length() > 0){ 160 return getQueryFromRex; 161 } 162 } 163 else 164 { 165 javax.swing.JOptionPane.showMessageDialog(MainFrame.getMainInstance(), 166 I18n.getString("messages.reportQueryDialog.connectionNotSupported","In order to use the MDX query designer, you need an XMLA datasource active."), 167 "",javax.swing.JOptionPane.WARNING_MESSAGE ); 168 return null; 169 170 } 171 172 return query; 173 } 174 175 178 public void getMdx(RexWizardEvent evt){ 179 180 getQueryFromRex = evt.getQuery(); 181 gotMdxResult = true; 182 183 } 184 185 186 187 public FieldsProviderEditor getEditorComponent(ReportQueryDialog reportQueryDialog) { 188 189 if (olapBrowser == null) 190 { 191 olapBrowser = new OlapBrowser(); 192 olapBrowser.setReportQueryDialog(reportQueryDialog); 193 if (reportQueryDialog != null) 194 { 195 olapBrowser.setJTableFields( reportQueryDialog.getFieldsTable() ); 196 } 197 } 198 return olapBrowser; 199 } 200 201 } 202 | Popular Tags |