Source Code Cross Referenced for MDXFieldsProvider.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » iReport 2.0.5 » it.businesslogic.ireport.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005-2007 JasperSoft http://www.jaspersoft.com
003:         *
004:         * This program is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * This program is distributed WITHOUT ANY WARRANTY; and without the
010:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
011:         * See the GNU General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU General Public License
014:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
015:         * or write to:
016:         *
017:         * Free Software Foundation, Inc.,
018:         * 59 Temple Place - Suite 330,
019:         * Boston, MA  USA  02111-1307
020:         *
021:         *
022:         * SQLFieldsProvider.java
023:         *
024:         * Created on December 7, 2006, 9:22 AM
025:         *
026:         * To change this template, choose Tools | Template Manager
027:         * and open the template in the editor.
028:         */
029:
030:        package it.businesslogic.ireport.data;
031:
032:        import it.businesslogic.ireport.FieldsProvider;
033:        import it.businesslogic.ireport.FieldsProviderEditor;
034:        import it.businesslogic.ireport.IReportConnection;
035:        import it.businesslogic.ireport.connection.JRXMLADataSourceConnection;
036:        import it.businesslogic.ireport.data.olap.CustomHTTPAuthenticator;
037:        import it.businesslogic.ireport.data.olap.OlapBrowser;
038:        import it.businesslogic.ireport.gui.MainFrame;
039:        import it.businesslogic.ireport.gui.ReportQueryDialog;
040:        import it.businesslogic.ireport.util.I18n;
041:
042:        import java.awt.Component;
043:        import java.net.Authenticator;
044:        import java.util.Map;
045:        import net.sf.jasperreports.engine.JRDataset;
046:        import net.sf.jasperreports.engine.JRException;
047:        import net.sf.jasperreports.engine.JRField;
048:        import rex.event.RexWizardEvent;
049:        import rex.event.RexWizardListener;
050:        import rex.graphics.mdxeditor.RexWizard;
051:
052:        /**
053:         *
054:         * @author gtoffoli
055:         */
056:        public class MDXFieldsProvider implements  FieldsProvider,
057:                RexWizardListener {
058:
059:            private OlapBrowser olapBrowser = null;
060:            protected String getQueryFromRex = "";
061:
062:            public static boolean useVisualDesigner = true;
063:
064:            static {
065:
066:                java.util.Properties p = new java.util.Properties();
067:                try {
068:                    p
069:                            .load(MDXFieldsProvider.class
070:                                    .getClass()
071:                                    .getResourceAsStream(
072:                                            "/it/businesslogic/ireport/data/fieldsprovider.properties"));
073:
074:                    if (p.getProperty("mdx").equals("0")) {
075:                        useVisualDesigner = false;
076:                        System.out.println("ReX designer disabled");
077:                    }
078:                } catch (Exception ex) {
079:                    ex.printStackTrace();
080:                }
081:
082:            }
083:
084:            /** Creates a new instance of SQLFieldsProvider */
085:            public MDXFieldsProvider() {
086:            }
087:
088:            /**
089:             * Returns true if the provider supports the {@link #getFields(IReportConnection,JRDataset,Map) getFields} 
090:             * operation. By returning true in this method the data source provider indicates
091:             * that it is able to introspect the data source and discover the available fields.
092:             * 
093:             * @return true if the getFields() operation is supported.
094:             */
095:            public boolean supportsGetFieldsOperation() {
096:                return false;
097:            }
098:
099:            public JRField[] getFields(IReportConnection con,
100:                    JRDataset reportDataset, Map parameters)
101:                    throws JRException, UnsupportedOperationException {
102:                return null;
103:            }
104:
105:            public boolean supportsAutomaticQueryExecution() {
106:                return true;
107:            }
108:
109:            public boolean hasQueryDesigner() {
110:                return useVisualDesigner;
111:            }
112:
113:            public boolean hasEditorComponent() {
114:                return true;
115:            }
116:
117:            /**
118:             * Copyright (C) 2006 CINCOM SYSTEMS, INC.
119:             * All Rights Reserved
120:             * www.cincom.com
121:             */
122:
123:            /*
124:             * Opens the Rex MDX Query Editor
125:             * @param MdxQuery
126:             * @retrun mdx Query from REX
127:             * sending the Query to Rex and bringing back the modified MDX query
128:             */
129:            boolean gotMdxResult = false;
130:
131:            public String designQuery(IReportConnection con, String query,
132:                    ReportQueryDialog reportQueryDialog) throws JRException,
133:                    UnsupportedOperationException {
134:
135:                String newMDXQuery = query;
136:                if (query == null)
137:                    newMDXQuery = "";
138:
139:                if (con instanceof  JRXMLADataSourceConnection) {
140:                    String strURL = ((JRXMLADataSourceConnection) con).getUrl();
141:
142:                    String strDataSource = ((JRXMLADataSourceConnection) con)
143:                            .getDatasource();
144:
145:                    String strCatalog = ((JRXMLADataSourceConnection) con)
146:                            .getCatalog();
147:
148:                    String strCubeName = ((JRXMLADataSourceConnection) con)
149:                            .getCube();
150:
151:                    String username = ((JRXMLADataSourceConnection) con)
152:                            .getUsername();
153:                    if (username != null && username.length() > 0) {
154:
155:                        Authenticator.setDefault(new CustomHTTPAuthenticator(
156:                                username, ((JRXMLADataSourceConnection) con)
157:                                        .getPassword()));
158:                    }
159:
160:                    //invoke MDXEditor
161:                    RexWizard mdxWizard = new RexWizard(strURL, strDataSource,
162:                            strCatalog, strCubeName, newMDXQuery, I18n
163:                                    .getCurrentLocale());
164:                    // Passing the MDX Query to Rex Wizard 
165:                    mdxWizard.addRexWizardListener(this );
166:
167:                    mdxWizard.showDialog();
168:
169:                    //Wait for the return value....
170:                    //System.out.println("Waiting for MDX query");
171:                    //System.out.flush();
172:                    //while (!gotMdxResult)
173:                    //{
174:                    //    Thread.yield();
175:                    //}
176:
177:                    //System.out.println("My MDX query " + getQueryFromRex);
178:                    //System.out.flush();
179:                    //condition added to handle Cancel click's in RexWizard
180:                    if (getQueryFromRex.length() > 0) {
181:                        return getQueryFromRex;
182:                    }
183:                } else {
184:                    javax.swing.JOptionPane
185:                            .showMessageDialog(
186:                                    MainFrame.getMainInstance(),
187:                                    I18n
188:                                            .getString(
189:                                                    "messages.reportQueryDialog.connectionNotSupported",
190:                                                    "In order to use the MDX query designer, you need an XMLA datasource active."),
191:                                    "", javax.swing.JOptionPane.WARNING_MESSAGE);
192:                    return null;
193:
194:                }
195:
196:                return query;
197:            }
198:
199:            /**
200:             * Rex Passes the MDX query to Report Query Dialog
201:             */
202:            public void getMdx(RexWizardEvent evt) {
203:
204:                getQueryFromRex = evt.getQuery();
205:                gotMdxResult = true;
206:
207:            }
208:
209:            /* end of modifications */
210:
211:            public FieldsProviderEditor getEditorComponent(
212:                    ReportQueryDialog reportQueryDialog) {
213:
214:                if (olapBrowser == null) {
215:                    olapBrowser = new OlapBrowser();
216:                    olapBrowser.setReportQueryDialog(reportQueryDialog);
217:                    if (reportQueryDialog != null) {
218:                        olapBrowser.setJTableFields(reportQueryDialog
219:                                .getFieldsTable());
220:                    }
221:                }
222:                return olapBrowser;
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.