Source Code Cross Referenced for JasperReportDetailsPage.java in  » Report » pentaho-report » org » pentaho » designstudio » editors » actionsequence » pages » actions » details » reports » 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 » pentaho report » org.pentaho.designstudio.editors.actionsequence.pages.actions.details.reports 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         */
013:        package org.pentaho.designstudio.editors.actionsequence.pages.actions.details.reports;
014:
015:        import java.util.ArrayList;
016:        import java.util.Arrays;
017:
018:        import org.eclipse.core.runtime.IPath;
019:        import org.eclipse.core.runtime.Path;
020:        import org.eclipse.swt.SWT;
021:        import org.eclipse.swt.custom.StackLayout;
022:        import org.eclipse.swt.events.SelectionEvent;
023:        import org.eclipse.swt.events.SelectionListener;
024:        import org.eclipse.swt.layout.GridData;
025:        import org.eclipse.swt.layout.GridLayout;
026:        import org.eclipse.swt.widgets.Button;
027:        import org.eclipse.swt.widgets.Composite;
028:        import org.eclipse.swt.widgets.FileDialog;
029:        import org.eclipse.swt.widgets.Label;
030:        import org.eclipse.swt.widgets.Text;
031:        import org.pentaho.actionsequence.dom.AbstractIOElement;
032:        import org.pentaho.actionsequence.dom.ActionSequenceDocument;
033:        import org.pentaho.actionsequence.dom.ActionSequenceResource;
034:        import org.pentaho.actionsequence.dom.IActionInputValueProvider;
035:        import org.pentaho.actionsequence.dom.IActionSequenceElement;
036:        import org.pentaho.actionsequence.dom.actions.ActionDefinition;
037:        import org.pentaho.actionsequence.dom.actions.JasperReportAction;
038:        import org.pentaho.designstudio.controls.ActionInputsList;
039:        import org.pentaho.designstudio.controls.ActionInputsListToolbar;
040:        import org.pentaho.designstudio.controls.ActionOutputText;
041:        import org.pentaho.designstudio.controls.ActionResourceText;
042:        import org.pentaho.designstudio.controls.NewActionInputCombo;
043:        import org.pentaho.designstudio.controls.WidgetFactory;
044:        import org.pentaho.designstudio.editors.actionsequence.pages.actions.IActionIOFilter;
045:        import org.pentaho.designstudio.editors.actionsequence.pages.actions.details.ActionDetailsPage;
046:        import org.pentaho.designstudio.messages.Messages;
047:        import org.pentaho.designstudio.util.SolutionHelper;
048:
049:        /**
050:         * The template describing the action definition used to run Jasper reports.
051:         * 
052:         * @author Angelo Rodriguez
053:         */
054:        public class JasperReportDetailsPage extends ActionDetailsPage
055:                implements  IActionIOFilter, SelectionListener {
056:
057:            public static final String DISPLAY_NAME = Messages
058:                    .getString("JasperReportDetailsPage.UI_COMPONENT_NAME_JASPER_REP"); //$NON-NLS-1$
059:            public static final String[] JASPER_REPORT_TYPES = new String[] {
060:                    "html", "pdf", "xls", "csv", "xml" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$   //TODO get this from JASPER
061:
062:            ActionResourceText reportDefinition;
063:            NewActionInputCombo jdbcDriver;
064:            NewActionInputCombo jdbcConnection;
065:            NewActionInputCombo userName;
066:            NewActionInputCombo password;
067:            NewActionInputCombo jndiName;
068:            NewActionInputCombo reportFormat;
069:            StackLayout dbConnectionStackedLayout;
070:            Composite jndiComposite;
071:            Composite jdbcComposite;
072:            Composite dbConnectionComposite;
073:            Composite dbConnectionStackedComposite;
074:            Button jdbcRadioButton;
075:            Button jndiRadioButton;
076:            Label dbConnectionLabel;
077:            ActionOutputText outputName;
078:            ActionInputsList reportParams;
079:            ActionInputsListToolbar reportParamsToolbar;
080:            Button browseBtn;
081:            IPath basePath;
082:
083:            /**
084:             * Creates a Jasper report template.
085:             */
086:            public JasperReportDetailsPage(IPath basePath) {
087:                super ();
088:                this .basePath = basePath;
089:            }
090:
091:            /* (non-Javadoc)
092:             * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.ActionDefinitionTemplate#getComponentClassName()
093:             */
094:            public String getComponentName() {
095:                return JasperReportAction.COMPONENT_NAME;
096:            }
097:
098:            /* (non-Javadoc)
099:             * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.ActionDefinitionTemplate#getDisplayName()
100:             */
101:            public String getName() {
102:                return DISPLAY_NAME;
103:            }
104:
105:            private void createDbConnectionComposite(Composite parent) {
106:                dbConnectionComposite = WidgetFactory.createComposite(parent,
107:                        SWT.BORDER);
108:                GridLayout layout = new GridLayout(2, false);
109:                dbConnectionComposite.setLayout(layout);
110:                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
111:                gridData.verticalSpan = 4;
112:                dbConnectionComposite.setLayoutData(gridData);
113:
114:                jdbcRadioButton = WidgetFactory
115:                        .createButton(
116:                                dbConnectionComposite,
117:                                Messages
118:                                        .getString("JasperReportDetailsPage.UI_JDBC_LABEL"), SWT.RADIO); //$NON-NLS-1$
119:                jndiRadioButton = WidgetFactory
120:                        .createButton(
121:                                dbConnectionComposite,
122:                                Messages
123:                                        .getString("JasperReportDetailsPage.UI_JNDI_LABEL"), SWT.RADIO); //$NON-NLS-1$
124:                jdbcRadioButton.addSelectionListener(this );
125:                jndiRadioButton.addSelectionListener(this );
126:
127:                dbConnectionStackedLayout = new StackLayout();
128:                dbConnectionStackedComposite = WidgetFactory.createComposite(
129:                        dbConnectionComposite, SWT.NULL);
130:                dbConnectionStackedComposite
131:                        .setLayout(dbConnectionStackedLayout);
132:                gridData = new GridData(GridData.FILL_HORIZONTAL);
133:                gridData.horizontalSpan = 2;
134:                dbConnectionStackedComposite.setLayoutData(gridData);
135:
136:                jdbcComposite = createJdbcComposite(dbConnectionStackedComposite);
137:                jndiComposite = createJndiComposite(dbConnectionStackedComposite);
138:
139:                dbConnectionStackedLayout.topControl = null;
140:                dbConnectionStackedComposite.layout();
141:            }
142:
143:            public void createDetailsComposite(Composite parent) {
144:                Composite actionConfigComposite = parent;
145:                GridLayout gridLayout = new GridLayout(2, true);
146:                gridLayout.horizontalSpacing = 20;
147:                actionConfigComposite.setLayout(gridLayout);
148:
149:                WidgetFactory.createLabel(actionConfigComposite, Messages
150:                        .getString("JasperReportDetailsPage.17")); //$NON-NLS-1$
151:
152:                dbConnectionLabel = WidgetFactory.createLabel(
153:                        actionConfigComposite, Messages
154:                                .getString("JasperReportDetailsPage.18")); //$NON-NLS-1$
155:
156:                reportDefinition = new ActionResourceText(
157:                        actionConfigComposite, new GridData(
158:                                GridData.FILL_HORIZONTAL));
159:                reportDefinition.setBasePath(basePath);
160:                createDbConnectionComposite(actionConfigComposite);
161:
162:                browseBtn = WidgetFactory
163:                        .createButton(
164:                                actionConfigComposite,
165:                                Messages
166:                                        .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
167:                browseBtn.addSelectionListener(this );
168:                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
169:                gridData.horizontalAlignment = GridData.END;
170:                browseBtn.setLayoutData(gridData);
171:
172:                Composite composite = WidgetFactory
173:                        .createComposite(actionConfigComposite);
174:                gridLayout = new GridLayout(2, false);
175:                gridLayout.marginWidth = 0;
176:                gridLayout.marginHeight = 0;
177:                composite.setLayout(gridLayout);
178:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
179:                WidgetFactory.createLabel(composite, Messages
180:                        .getString("JasperReportDetailsPage.20")); //$NON-NLS-1$
181:
182:                reportParams = new ActionInputsList(actionConfigComposite);
183:                reportParams.setFilter(this );
184:                gridData = new GridData(GridData.FILL_HORIZONTAL);
185:                gridData.verticalAlignment = SWT.FILL;
186:                gridData.heightHint = 100;
187:                reportParams.getList().setLayoutData(gridData);
188:
189:                reportParamsToolbar = new ActionInputsListToolbar(composite,
190:                        reportParams);
191:                gridData = new GridData(GridData.FILL_HORIZONTAL);
192:                gridData.horizontalAlignment = GridData.END;
193:                reportParamsToolbar.getControl().setLayoutData(gridData);
194:
195:                Label label = WidgetFactory.createLabel(actionConfigComposite,
196:                        Messages.getString("JasperReportDetailsPage.21")); //$NON-NLS-1$
197:                gridData = new GridData();
198:                gridData.horizontalSpan = 2;
199:                label.setLayoutData(gridData);
200:
201:                WidgetFactory.createLabel(actionConfigComposite, Messages
202:                        .getString("JasperReportDetailsPage.22")); //$NON-NLS-1$
203:
204:                WidgetFactory.createLabel(actionConfigComposite, Messages
205:                        .getString("JasperReportDetailsPage.23")); //$NON-NLS-1$
206:
207:                reportFormat = new NewActionInputCombo(actionConfigComposite,
208:                        new GridData(GridData.FILL_HORIZONTAL));
209:                reportFormat.setDefaultConstants(JASPER_REPORT_TYPES);
210:
211:                outputName = new ActionOutputText(actionConfigComposite,
212:                        new GridData(GridData.FILL_HORIZONTAL));
213:            }
214:
215:            private Composite createJndiComposite(Composite parent) {
216:                Composite composite = WidgetFactory.createComposite(parent,
217:                        SWT.NONE);
218:
219:                composite.setLayout(new GridLayout());
220:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
221:
222:                WidgetFactory.createLabel(composite, Messages
223:                        .getString("JasperReportDetailsPage.24")); //$NON-NLS-1$
224:                jndiName = new NewActionInputCombo(composite, new GridData(
225:                        GridData.FILL_HORIZONTAL));
226:                return composite;
227:            }
228:
229:            private Composite createJdbcComposite(Composite parent) {
230:                Composite composite = WidgetFactory.createComposite(parent,
231:                        SWT.NONE);
232:
233:                composite.setLayout(new GridLayout());
234:
235:                WidgetFactory.createLabel(composite, Messages
236:                        .getString("JasperReportDetailsPage.25")); //$NON-NLS-1$
237:                jdbcDriver = new NewActionInputCombo(composite, new GridData(
238:                        GridData.FILL_HORIZONTAL));
239:                WidgetFactory.createLabel(composite, Messages
240:                        .getString("JasperReportDetailsPage.26")); //$NON-NLS-1$
241:                jdbcConnection = new NewActionInputCombo(composite,
242:                        new GridData(GridData.FILL_HORIZONTAL));
243:                WidgetFactory.createLabel(composite, Messages
244:                        .getString("JasperReportDetailsPage.27")); //$NON-NLS-1$
245:                userName = new NewActionInputCombo(composite, new GridData(
246:                        GridData.FILL_HORIZONTAL));
247:                WidgetFactory.createLabel(composite, Messages
248:                        .getString("JasperReportDetailsPage.28")); //$NON-NLS-1$
249:                password = new NewActionInputCombo(composite, new GridData(
250:                        GridData.FILL_HORIZONTAL));
251:
252:                return composite;
253:            }
254:
255:            public void refresh() {
256:                super .refresh();
257:
258:                reportDefinition.setTargetResource(actionDefinition,
259:                        JasperReportAction.REPORT_DEFINITION_ELEMENT);
260:                reportFormat.setTargetInput(actionDefinition,
261:                        JasperReportAction.OUTPUT_TYPE_ELEMENT,
262:                        ActionSequenceDocument.STRING_TYPE);
263:                jdbcDriver.setTargetInput(actionDefinition,
264:                        JasperReportAction.DRIVER_ELEMENT,
265:                        ActionSequenceDocument.STRING_TYPE);
266:                jdbcConnection.setTargetInput(actionDefinition,
267:                        JasperReportAction.CONNECTION_ELEMENT,
268:                        ActionSequenceDocument.STRING_TYPE);
269:                userName.setTargetInput(actionDefinition,
270:                        JasperReportAction.USER_ID_ELEMENT,
271:                        ActionSequenceDocument.STRING_TYPE);
272:                password.setTargetInput(actionDefinition,
273:                        JasperReportAction.PASSWORD_ELEMENT,
274:                        ActionSequenceDocument.STRING_TYPE);
275:                jndiName.setTargetInput(actionDefinition,
276:                        JasperReportAction.JNDI_ELEMENT,
277:                        ActionSequenceDocument.STRING_TYPE);
278:                reportParams.setInput(actionDefinition);
279:                reportParamsToolbar.refresh();
280:
281:                dbConnectionStackedLayout.topControl = null;
282:                jdbcRadioButton.removeSelectionListener(this );
283:                jndiRadioButton.removeSelectionListener(this );
284:                jdbcRadioButton.setSelection(false);
285:                jndiRadioButton.setSelection(false);
286:                if (actionDefinition instanceof  JasperReportAction) {
287:                    JasperReportAction jasperReportAction = (JasperReportAction) actionDefinition;
288:                    if ((jasperReportAction.getDriver() != IActionInputValueProvider.NULL_INPUT)
289:                            && (jasperReportAction.getJndi() == IActionInputValueProvider.NULL_INPUT)) {
290:
291:                        dbConnectionStackedLayout.topControl = jdbcComposite;
292:                        jdbcRadioButton.setSelection(true);
293:                    } else if ((jasperReportAction.getJndi() != IActionInputValueProvider.NULL_INPUT)
294:                            && (jasperReportAction.getDriver() == IActionInputValueProvider.NULL_INPUT)) {
295:
296:                        dbConnectionStackedLayout.topControl = jndiComposite;
297:                        jndiRadioButton.setSelection(true);
298:                    }
299:                }
300:                dbConnectionStackedComposite.layout();
301:                jdbcRadioButton.addSelectionListener(this );
302:                jndiRadioButton.addSelectionListener(this );
303:
304:                outputName.setTargetOutput(actionDefinition,
305:                        JasperReportAction.OUTPUT_REPORT);
306:            }
307:
308:            public boolean accepts(IActionSequenceElement actionDef) {
309:                return actionDef instanceof  JasperReportAction;
310:            }
311:
312:            public boolean accept(AbstractIOElement ioElement) {
313:                ArrayList expectedInputs = new ArrayList();
314:                if (actionDefinition != null) {
315:                    expectedInputs.addAll(Arrays.asList(actionDefinition
316:                            .getReservedInputNames()));
317:                }
318:                return (!expectedInputs.contains(ioElement.getName()));
319:            }
320:
321:            private void setResourcePath(String fileName, Text text) {
322:                String fileSolution = SolutionHelper.getSolutionName(fileName);
323:                Path filePath = new Path(fileName);
324:                String baseSolution = SolutionHelper.getSolutionName(basePath
325:                        .toString());
326:                String solutionRoot = SolutionHelper.getSolutionRoot(basePath
327:                        .toString());
328:
329:                if ((baseSolution != null) && baseSolution.equals(fileSolution)) {
330:                    if (filePath.matchingFirstSegments(basePath) == basePath
331:                            .segmentCount()) {
332:                        IPath relativeFilePath = filePath
333:                                .removeFirstSegments(basePath.segmentCount());
334:                        text.setText(relativeFilePath.setDevice(
335:                                ActionSequenceResource.SOLUTION_SCHEME + ":")
336:                                .toString());
337:                    } else {
338:                        Path solutionPath = new Path(solutionRoot);
339:                        IPath relativePath = filePath
340:                                .removeFirstSegments(solutionPath
341:                                        .segmentCount());
342:                        IPath absPath = relativePath.makeAbsolute().setDevice(
343:                                ActionSequenceResource.SOLUTION_SCHEME + ":"); //$NON-NLS-1$
344:                        text.setText(absPath.toString());
345:                    }
346:                } else {
347:                    text.setText(ActionSequenceResource.FILE_SCHEME + ":"
348:                            + fileName);
349:                }
350:            }
351:
352:            public boolean checkResourceReferences(
353:                    ActionDefinition actionDefinition) {
354:                return (actionDefinition
355:                        .getResourceParam(JasperReportAction.REPORT_DEFINITION_ELEMENT) != null)
356:                        || (actionDefinition.getDocument().getResource(
357:                                JasperReportAction.REPORT_DEFINITION_ELEMENT) == null);
358:            }
359:
360:            public void fixResourceReferences(ActionDefinition actionDefinition) {
361:                if ((actionDefinition
362:                        .getResourceParam(JasperReportAction.REPORT_DEFINITION_ELEMENT) == null)
363:                        && (actionDefinition.getDocument().getResource(
364:                                JasperReportAction.REPORT_DEFINITION_ELEMENT) != null)) {
365:                    actionDefinition
366:                            .addResourceParam(JasperReportAction.REPORT_DEFINITION_ELEMENT);
367:                }
368:            }
369:
370:            public void widgetDefaultSelected(SelectionEvent e) {
371:            }
372:
373:            public void widgetSelected(SelectionEvent e) {
374:                if ((e.getSource() == jndiRadioButton)
375:                        || (e.getSource() == jdbcRadioButton)) {
376:                    jdbcDriver.refresh();
377:                    jdbcConnection.refresh();
378:                    userName.refresh();
379:                    password.refresh();
380:                    jndiName.refresh();
381:                    if (jndiRadioButton.getSelection()) {
382:                        dbConnectionStackedLayout.topControl = jndiComposite;
383:                        dbConnectionStackedComposite.layout();
384:                    } else if (jdbcRadioButton.getSelection()) {
385:                        dbConnectionStackedLayout.topControl = jdbcComposite;
386:                        dbConnectionStackedComposite.layout();
387:                    }
388:                } else if (e.getSource() == browseBtn) {
389:                    FileDialog fileChooser = new FileDialog(browseBtn
390:                            .getShell(), SWT.OPEN);
391:                    fileChooser
392:                            .setText(Messages
393:                                    .getString("JasperReportDetailsPage.SELECT_JASPER_REPORT")); //$NON-NLS-1$
394:                    fileChooser.setFilterExtensions(new String[] {
395:                            "*.jasper", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
396:                    fileChooser
397:                            .setFilterNames(new String[] {
398:                                    Messages
399:                                            .getString("JasperReportDetailsPage.JASPER_REPORT_DEFINITON"), Messages.getString("JasperReportDetailsPage.ALL_FILES") }); //$NON-NLS-1$ //$NON-NLS-2$
400:                    fileChooser.setFilterPath(basePath.toString());
401:                    String filename = fileChooser.open();
402:                    if (filename != null) {
403:                        setResourcePath(filename, (Text) reportDefinition
404:                                .getControl());
405:                    }
406:                }
407:            }
408:
409:        }
w___w__w___.___j__av__a___2__s._c_o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.