Source Code Cross Referenced for JFreeReportDetailsPage.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.Arrays;
016:
017:        import org.eclipse.core.runtime.IPath;
018:        import org.eclipse.core.runtime.Path;
019:        import org.eclipse.jface.dialogs.MessageDialog;
020:        import org.eclipse.swt.SWT;
021:        import org.eclipse.swt.events.SelectionEvent;
022:        import org.eclipse.swt.events.SelectionListener;
023:        import org.eclipse.swt.layout.GridData;
024:        import org.eclipse.swt.layout.GridLayout;
025:        import org.eclipse.swt.widgets.Button;
026:        import org.eclipse.swt.widgets.Composite;
027:        import org.eclipse.swt.widgets.FileDialog;
028:        import org.eclipse.swt.widgets.Label;
029:        import org.eclipse.swt.widgets.Text;
030:        import org.pentaho.actionsequence.dom.AbstractIOElement;
031:        import org.pentaho.actionsequence.dom.ActionInput;
032:        import org.pentaho.actionsequence.dom.ActionOutput;
033:        import org.pentaho.actionsequence.dom.ActionSequenceDocument;
034:        import org.pentaho.actionsequence.dom.ActionSequenceInput;
035:        import org.pentaho.actionsequence.dom.ActionSequenceResource;
036:        import org.pentaho.actionsequence.dom.IActionInputValueProvider;
037:        import org.pentaho.actionsequence.dom.IActionSequenceElement;
038:        import org.pentaho.actionsequence.dom.actions.ActionDefinition;
039:        import org.pentaho.actionsequence.dom.actions.JFreeReportAction;
040:        import org.pentaho.designstudio.controls.ActionInputsList;
041:        import org.pentaho.designstudio.controls.ActionInputsListToolbar;
042:        import org.pentaho.designstudio.controls.ActionOutputText;
043:        import org.pentaho.designstudio.controls.ActionResourceText;
044:        import org.pentaho.designstudio.controls.NewActionInputCombo;
045:        import org.pentaho.designstudio.controls.PageTemplateText;
046:        import org.pentaho.designstudio.controls.WidgetFactory;
047:        import org.pentaho.designstudio.editors.actionsequence.pages.actions.IActionIOFilter;
048:        import org.pentaho.designstudio.editors.actionsequence.pages.actions.details.ActionDetailsPage;
049:        import org.pentaho.designstudio.messages.Messages;
050:        import org.pentaho.designstudio.util.SolutionHelper;
051:
052:        /**
053:         * The template describing the action definition used to run JFree reports.
054:         * 
055:         * @author Angelo Rodriguez
056:         */
057:        public class JFreeReportDetailsPage extends ActionDetailsPage implements 
058:                SelectionListener {
059:
060:            public static final String DISPLAY_NAME = Messages
061:                    .getString("JFreeReportDetailsPage.UI_COMPONENT_NAME_JFREE_REPORT"); //$NON-NLS-1$
062:            public static final String[] JFREE_REPORT_TYPES = new String[] {
063:                    "html", "pdf", "xls", "rtf", "csv", "xml" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$  //TODO get this from JFREE
064:
065:            class ReportResourceText extends ActionResourceText {
066:                ReportResourceText(Composite parent, Object layoutData) {
067:                    super (parent, layoutData);
068:                }
069:
070:                public void updateActionSequence() {
071:                    super .updateActionSequence();
072:                    boolean isJFreeReportSpec = !actionDefinition
073:                            .getComponentName().endsWith(
074:                                    "ReportWizardSpecComponent");
075:                    reportDataLabel.setVisible(isJFreeReportSpec);
076:                    resultSetComposite.setVisible(isJFreeReportSpec);
077:                }
078:            }
079:
080:            ReportResourceText reportDefText;
081:            NewActionInputCombo resultSetCombo;
082:            Composite resultSetComposite;
083:            Composite xslComposite;
084:            Label reportDataLabel;
085:            PageTemplateText xslFile;
086:            ActionInputsList reportParams;
087:            ActionInputsListToolbar reportParamsToolbar;
088:            ActionInputsList reportSubqueries;
089:            ActionInputsListToolbar reportSubqueriesToolbar;
090:            NewActionInputCombo reportFormat;
091:            ActionOutputText outputName;
092:            Button browseReportDefBtn;
093:            Button browseXslBtn;
094:
095:            IPath basePath;
096:
097:            /**
098:             * Creates a JFree report template.
099:             */
100:            public JFreeReportDetailsPage(IPath basePath) {
101:                super ();
102:                this .basePath = basePath;
103:            }
104:
105:            /* (non-Javadoc)
106:             * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.detailElementTemplate#getComponentClassName()
107:             */
108:            public String getComponentName() {
109:                return JFreeReportAction.COMPONENT_NAME;
110:            }
111:
112:            /* (non-Javadoc)
113:             * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.detailElementTemplate#getDisplayName()
114:             */
115:            public String getName() {
116:                return DISPLAY_NAME;
117:            }
118:
119:            public void createDetailsComposite(Composite parent) {
120:                Composite actionConfigComposite = parent;
121:                GridLayout gridLayout = new GridLayout(2, true);
122:                gridLayout.horizontalSpacing = 20;
123:                actionConfigComposite.setLayout(gridLayout);
124:
125:                WidgetFactory.createLabel(actionConfigComposite, Messages
126:                        .getString("JFreeReportDetailsPage.FILE_LOCATION")); //$NON-NLS-1$
127:
128:                reportDataLabel = WidgetFactory
129:                        .createLabel(
130:                                actionConfigComposite,
131:                                Messages
132:                                        .getString("JFreeReportDetailsPage.UI_RESULT_SET_LABEL")); //$NON-NLS-1$
133:
134:                Composite composite = WidgetFactory
135:                        .createComposite(actionConfigComposite);
136:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
137:                gridLayout = new GridLayout();
138:                gridLayout.marginHeight = 2;
139:                gridLayout.marginWidth = 1;
140:                composite.setLayout(gridLayout);
141:                reportDefText = new ReportResourceText(composite, new GridData(
142:                        GridData.FILL_HORIZONTAL));
143:                reportDefText.setBasePath(basePath);
144:
145:                resultSetComposite = WidgetFactory
146:                        .createComposite(actionConfigComposite);
147:                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
148:                gridData.verticalSpan = 2;
149:                gridData.verticalAlignment = GridData.BEGINNING;
150:                resultSetComposite.setLayoutData(gridData);
151:                gridLayout = new GridLayout();
152:                gridLayout.marginHeight = 1;
153:                gridLayout.marginWidth = 1;
154:                resultSetComposite.setLayout(gridLayout);
155:
156:                gridData = new GridData(GridData.FILL_HORIZONTAL);
157:                gridData.verticalAlignment = GridData.BEGINNING;
158:                resultSetCombo = new NewActionInputCombo(resultSetComposite,
159:                        gridData, false);
160:
161:                browseReportDefBtn = WidgetFactory
162:                        .createButton(
163:                                actionConfigComposite,
164:                                Messages
165:                                        .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
166:                browseReportDefBtn.addSelectionListener(this );
167:
168:                gridData = new GridData(GridData.FILL_HORIZONTAL);
169:                gridData.horizontalAlignment = GridData.END;
170:                browseReportDefBtn.setLayoutData(gridData);
171:
172:                gridData = new GridData();
173:                gridData.horizontalSpan = 2;
174:                WidgetFactory
175:                        .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
176:
177:                Composite reportParamsToolbarComposite = WidgetFactory
178:                        .createComposite(actionConfigComposite);
179:                gridLayout = new GridLayout(2, false);
180:                gridLayout.marginWidth = 0;
181:                gridLayout.marginHeight = 0;
182:                reportParamsToolbarComposite.setLayout(gridLayout);
183:                reportParamsToolbarComposite.setLayoutData(new GridData(
184:                        GridData.FILL_HORIZONTAL));
185:                WidgetFactory
186:                        .createLabel(
187:                                reportParamsToolbarComposite,
188:                                Messages
189:                                        .getString("JFreeReportDetailsPage.UI_REPORT_PARAMETERS_LABEL")); //$NON-NLS-1$
190:
191:                Composite subQueryToolbarComposite = WidgetFactory
192:                        .createComposite(actionConfigComposite);
193:                gridLayout = new GridLayout(2, false);
194:                gridLayout.marginWidth = 0;
195:                gridLayout.marginHeight = 0;
196:                subQueryToolbarComposite.setLayout(gridLayout);
197:                subQueryToolbarComposite.setLayoutData(new GridData(
198:                        GridData.FILL_HORIZONTAL));
199:                WidgetFactory.createLabel(subQueryToolbarComposite, Messages
200:                        .getString("JFreeReportDetailsPage.UI_SUBREPORT_DATA")); //$NON-NLS-1$
201:
202:                reportParams = new ActionInputsList(actionConfigComposite);
203:                reportParams.setFilter(new IActionIOFilter() {
204:
205:                    public boolean accept(AbstractIOElement ioElement) {
206:                        String name = null;
207:                        String type = ioElement.getType();
208:                        if ((ioElement instanceof  ActionSequenceInput)
209:                                || (ioElement instanceof  ActionInput)) {
210:                            name = ioElement.getName();
211:                        } else if (ioElement instanceof  ActionOutput) {
212:                            name = ((ActionOutput) ioElement).getPublicName();
213:                        }
214:                        return !Arrays.asList(
215:                                actionDefinition.getReservedInputNames())
216:                                .contains(name)
217:                                && !ActionSequenceDocument.SQL_QUERY_TYPE
218:                                        .equals(type)
219:                                && !ActionSequenceDocument.MDX_QUERY_TYPE
220:                                        .equals(type)
221:                                && !ActionSequenceDocument.XQUERY_TYPE
222:                                        .equals(type)
223:                                && !ActionSequenceDocument.HQL_QUERY_TYPE
224:                                        .equals(type)
225:                                && !ActionSequenceDocument.RESULTSET_TYPE
226:                                        .equals(type);
227:                    }
228:
229:                });
230:                gridData = new GridData(GridData.FILL_HORIZONTAL);
231:                gridData.verticalSpan = 5;
232:                gridData.heightHint = 150;
233:                reportParams.getControl().setLayoutData(gridData);
234:
235:                reportSubqueries = new ActionInputsList(actionConfigComposite);
236:                reportSubqueries.setFilter(new IActionIOFilter() {
237:
238:                    public boolean accept(AbstractIOElement ioElement) {
239:                        String name = null;
240:                        String type = ioElement.getType();
241:                        if ((ioElement instanceof  ActionSequenceInput)
242:                                || (ioElement instanceof  ActionInput)) {
243:                            name = ioElement.getName();
244:                        } else if (ioElement instanceof  ActionOutput) {
245:                            name = ((ActionOutput) ioElement).getPublicName();
246:                        }
247:                        return !JFreeReportAction.DATA_ELEMENT.equals(name)
248:                                && (ActionSequenceDocument.RESULTSET_TYPE
249:                                        .equals(type)
250:                                        || ActionSequenceDocument.MDX_QUERY_TYPE
251:                                                .equals(type)
252:                                        || ActionSequenceDocument.SQL_QUERY_TYPE
253:                                                .equals(type)
254:                                        || ActionSequenceDocument.XQUERY_TYPE
255:                                                .equals(type) || ActionSequenceDocument.HQL_QUERY_TYPE
256:                                        .equals(type));
257:                    }
258:
259:                });
260:                gridData = new GridData(GridData.FILL_HORIZONTAL);
261:                gridData.verticalSpan = 5;
262:                gridData.heightHint = 150;
263:                reportSubqueries.getControl().setLayoutData(gridData);
264:
265:                reportParamsToolbar = new ActionInputsListToolbar(
266:                        reportParamsToolbarComposite, reportParams);
267:                gridData = new GridData(GridData.FILL_HORIZONTAL);
268:                gridData.horizontalAlignment = GridData.END;
269:                reportParamsToolbar.getControl().setLayoutData(gridData);
270:
271:                reportSubqueriesToolbar = new ActionInputsListToolbar(
272:                        subQueryToolbarComposite, reportSubqueries);
273:                gridData = new GridData(GridData.FILL_HORIZONTAL);
274:                gridData.horizontalAlignment = GridData.END;
275:                reportSubqueriesToolbar.getControl().setLayoutData(gridData);
276:
277:                gridData = new GridData();
278:                gridData.horizontalSpan = 2;
279:                WidgetFactory
280:                        .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
281:
282:                WidgetFactory
283:                        .createLabel(
284:                                actionConfigComposite,
285:                                Messages
286:                                        .getString("JFreeReportDetailsPage.UI_REPORT_FORMAT_LABEL")); //$NON-NLS-1$
287:                WidgetFactory
288:                        .createLabel(
289:                                actionConfigComposite,
290:                                Messages
291:                                        .getString("JFreeReportDetailsPage.UI_REPORT_DESTINATION_LABEL")); //$NON-NLS-1$
292:                reportFormat = new NewActionInputCombo(actionConfigComposite,
293:                        new GridData(GridData.FILL_HORIZONTAL));
294:                outputName = new ActionOutputText(actionConfigComposite,
295:                        new GridData(GridData.FILL_HORIZONTAL));
296:
297:                gridData = new GridData();
298:                gridData.horizontalSpan = 2;
299:                WidgetFactory
300:                        .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
301:
302:                xslComposite = WidgetFactory
303:                        .createComposite(actionConfigComposite);
304:                xslComposite.setLayoutData(new GridData(
305:                        GridData.FILL_HORIZONTAL));
306:                gridLayout = new GridLayout();
307:                gridLayout.marginWidth = 1;
308:                gridLayout.marginHeight = 1;
309:                xslComposite.setLayout(gridLayout);
310:
311:                WidgetFactory
312:                        .createLabel(
313:                                xslComposite,
314:                                Messages
315:                                        .getString("JFreeReportDetailsPage.UI_STYLESHEET_LABEL")); //$NON-NLS-1$
316:
317:                xslFile = new PageTemplateText(xslComposite, new GridData(
318:                        GridData.FILL_HORIZONTAL));
319:                xslFile.setBasePath(basePath);
320:
321:                browseXslBtn = WidgetFactory
322:                        .createButton(
323:                                xslComposite,
324:                                Messages
325:                                        .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
326:                browseXslBtn.addSelectionListener(this );
327:                gridData = new GridData(GridData.FILL_HORIZONTAL);
328:                gridData.horizontalAlignment = GridData.END;
329:                browseXslBtn.setLayoutData(gridData);
330:            }
331:
332:            public void refresh() {
333:                super .refresh();
334:
335:                reportParams.setInput(actionDefinition);
336:                reportParamsToolbar.refresh();
337:                reportSubqueries.setInput(actionDefinition);
338:                reportSubqueriesToolbar.refresh();
339:                resultSetCombo.setTargetInput(actionDefinition,
340:                        JFreeReportAction.DATA_ELEMENT,
341:                        ActionSequenceDocument.RESULTSET_TYPE);
342:                xslFile
343:                        .setActionDefinition((JFreeReportAction) actionDefinition);
344:                reportFormat.setTargetInput(actionDefinition,
345:                        JFreeReportAction.OUTPUT_TYPE_ELEMENT,
346:                        ActionSequenceDocument.STRING_TYPE);
347:                reportFormat.setDefaultConstants(JFREE_REPORT_TYPES);
348:                outputName.setTargetOutput(actionDefinition,
349:                        JFreeReportAction.OUTPUT_REPORT);
350:                if (actionDefinition.getComponentName().endsWith(
351:                        "JFreeReportComponent")) { //$NON-NLS-1$
352:                    resultSetComposite.setVisible(true);
353:                    reportDataLabel.setVisible(true);
354:                } else {
355:                    resultSetComposite.setVisible(false);
356:                    reportDataLabel.setVisible(false);
357:                }
358:                reportDefText.setTargetResource(actionDefinition,
359:                        JFreeReportAction.REPORT_DEFINITION_ELEMENT);
360:                xslComposite.setVisible(((JFreeReportAction) actionDefinition)
361:                        .getXsl() != IActionInputValueProvider.NULL_INPUT);
362:            }
363:
364:            public boolean accepts(IActionSequenceElement element) {
365:                boolean result = false;
366:                if (element instanceof  JFreeReportAction) {
367:                    ActionDefinition actionDefinition = (ActionDefinition) element;
368:                    String actionDefClassName = actionDefinition
369:                            .getComponentName();
370:                    if (("." + actionDefClassName).endsWith(".JFreeReportComponent")) { //$NON-NLS-1$ //$NON-NLS-2$
371:                        result = (actionDefinition.getInputParam("source") == null) && (actionDefinition.getComponentDefinitionValue("source") == null); //$NON-NLS-1$ //$NON-NLS-2$
372:                    } else if (("." + actionDefClassName).endsWith(".ReportWizardSpecComponent")) { //$NON-NLS-1$ //$NON-NLS-2$
373:                        result = true;
374:                    }
375:                }
376:                return result;
377:            }
378:
379:            private void setResourcePath(String fileName, Text text) {
380:                String fileSolution = SolutionHelper.getSolutionName(fileName);
381:                Path filePath = new Path(fileName);
382:                String baseSolution = SolutionHelper.getSolutionName(basePath
383:                        .toString());
384:                String solutionRoot = SolutionHelper.getSolutionRoot(basePath
385:                        .toString());
386:
387:                if ((baseSolution != null) && baseSolution.equals(fileSolution)) {
388:                    if (filePath.matchingFirstSegments(basePath) == basePath
389:                            .segmentCount()) {
390:                        IPath relativeFilePath = filePath
391:                                .removeFirstSegments(basePath.segmentCount());
392:                        text.setText(relativeFilePath.setDevice(
393:                                ActionSequenceResource.SOLUTION_SCHEME + ":")
394:                                .toString());
395:                    } else {
396:                        Path solutionPath = new Path(solutionRoot);
397:                        IPath relativePath = filePath
398:                                .removeFirstSegments(solutionPath
399:                                        .segmentCount());
400:                        IPath absPath = relativePath.makeAbsolute().setDevice(
401:                                ActionSequenceResource.SOLUTION_SCHEME + ":"); //$NON-NLS-1$
402:                        text.setText(absPath.toString());
403:                    }
404:                } else {
405:                    text.setText(ActionSequenceResource.FILE_SCHEME + ":"
406:                            + fileName);
407:                }
408:            }
409:
410:            public boolean checkResourceReferences(
411:                    ActionDefinition actionDefinition) {
412:                boolean result = false;
413:                if (actionDefinition.getComponentName().endsWith(
414:                        "JFreeReportComponent")) { //$NON-NLS-1$
415:                    result = ((actionDefinition
416:                            .getResourceParam(JFreeReportAction.REPORT_DEFINITION_ELEMENT) != null) || (actionDefinition
417:                            .getDocument()
418:                            .getResource(
419:                                    JFreeReportAction.REPORT_DEFINITION_ELEMENT) == null));
420:                } else if (actionDefinition.getComponentName().endsWith(
421:                        "ReportWizardSpecComponent")) { //$NON-NLS-1$
422:                    result = ((actionDefinition
423:                            .getResourceParam(JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT) != null) || (actionDefinition
424:                            .getDocument().getResource(
425:                                    JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT) == null));
426:                } else {
427:                    result = true;
428:                }
429:                return result;
430:            }
431:
432:            public void fixResourceReferences(ActionDefinition actionDefinition) {
433:                if (actionDefinition.getComponentName().endsWith(
434:                        "JFreeReportComponent")) { //$NON-NLS-1$
435:                    if ((actionDefinition
436:                            .getResourceParam(JFreeReportAction.REPORT_DEFINITION_ELEMENT) == null)
437:                            && (actionDefinition
438:                                    .getDocument()
439:                                    .getResource(
440:                                            JFreeReportAction.REPORT_DEFINITION_ELEMENT) != null)) {
441:                        actionDefinition
442:                                .addResourceParam(JFreeReportAction.REPORT_DEFINITION_ELEMENT);
443:                    }
444:                }
445:                if (actionDefinition.getComponentName().endsWith(
446:                        "ReportWizardSpecComponent")) { //$NON-NLS-1$
447:                    if ((actionDefinition
448:                            .getResourceParam(JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT) == null)
449:                            && (actionDefinition.getDocument().getResource(
450:                                    JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT) != null)) {
451:                        actionDefinition
452:                                .addResourceParam(JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT);
453:                    }
454:                }
455:            }
456:
457:            private void setPageTemplate(String fileName, Text text) {
458:                String fileSolution = SolutionHelper.getSolutionName(fileName);
459:                Path filePath = new Path(fileName);
460:                String baseSolution = SolutionHelper.getSolutionName(basePath
461:                        .toString());
462:                String solutionRoot = SolutionHelper.getSolutionRoot(basePath
463:                        .toString());
464:
465:                if (fileName.endsWith(".xsl")) { //$NON-NLS-1$
466:                    if ((baseSolution != null)
467:                            && baseSolution.equals(fileSolution)) {
468:                        boolean result = true;
469:                        if (filePath.matchingFirstSegments(basePath) == basePath
470:                                .segmentCount()) {
471:                            IPath relativeFilePath = filePath
472:                                    .removeFirstSegments(basePath
473:                                            .segmentCount());
474:                            if (relativeFilePath.segmentCount() != 1) {
475:                                MessageDialog
476:                                        .openWarning(
477:                                                text.getShell(),
478:                                                Messages
479:                                                        .getString("JFreeReportDetailsPage.INVALID_FILE_LOCATION"), Messages.getString("JFreeReportDetailsPage.INVALID_XSL_LOCATION")); //$NON-NLS-1$ //$NON-NLS-2$
480:                                result = false;
481:                            }
482:                        } else {
483:                            IPath solutionPath = new Path(solutionRoot);
484:                            IPath defaultXslPath = solutionPath
485:                                    .removeLastSegments(1).append(
486:                                            "system/custom/xsl"); //$NON-NLS-1$
487:                            if (!defaultXslPath.equals(filePath
488:                                    .removeLastSegments(1))) {
489:                                MessageDialog
490:                                        .openWarning(
491:                                                text.getShell(),
492:                                                Messages
493:                                                        .getString("JFreeReportDetailsPage.INVALID_FILE_LOCATION"), Messages.getString("JFreeReportDetailsPage.INVALID_XSL_LOCATION")); //$NON-NLS-1$ //$NON-NLS-2$
494:                                result = false;
495:                            }
496:                        }
497:                        if (result) {
498:                            text.setText(filePath.lastSegment());
499:                        }
500:                    } else {
501:                        text.setText(filePath.lastSegment());
502:                    }
503:                } else {
504:                    if ((baseSolution != null)
505:                            && baseSolution.equals(fileSolution)) {
506:                        if (filePath.matchingFirstSegments(basePath) == basePath
507:                                .segmentCount()) {
508:                            IPath relativeFilePath = filePath
509:                                    .removeFirstSegments(basePath
510:                                            .segmentCount());
511:                            text.setText(relativeFilePath.setDevice(null)
512:                                    .toString());
513:                        } else {
514:                            Path solutionPath = new Path(solutionRoot);
515:                            IPath relativePath = filePath
516:                                    .removeFirstSegments(solutionPath
517:                                            .segmentCount());
518:                            IPath absPath = relativePath.makeAbsolute()
519:                                    .setDevice("solution:"); //$NON-NLS-1$
520:                            text.setText(absPath.toString());
521:                        }
522:                    } else {
523:                        text.setText(fileName);
524:                    }
525:                }
526:            }
527:
528:            public void widgetDefaultSelected(SelectionEvent e) {
529:            }
530:
531:            public void widgetSelected(SelectionEvent e) {
532:                if (e.getSource() == browseReportDefBtn) {
533:                    FileDialog fileChooser = new FileDialog(browseReportDefBtn
534:                            .getShell(), SWT.OPEN);
535:                    fileChooser
536:                            .setText(Messages
537:                                    .getString("JFreeReportDetailsPage.SELECT_REPORT_DEFINITION")); //$NON-NLS-1$
538:                    fileChooser.setFilterExtensions(new String[] {
539:                            "*.xml", "*.xreportspec", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
540:                    fileChooser
541:                            .setFilterNames(new String[] {
542:                                    Messages
543:                                            .getString("JFreeReportDetailsPage.REPORT_DEFINITION"), Messages.getString("JFreeReportDetailsPage.REPORT_WIZARD_SPEC"), Messages.getString("JFreeReportDetailsPage.ALL_FILES") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
544:                    fileChooser.setFilterPath(basePath.toString());
545:                    String filename = fileChooser.open();
546:                    if (filename != null) {
547:                        setResourcePath(filename, (Text) reportDefText
548:                                .getControl());
549:                    }
550:                } else {
551:                    FileDialog fileChooser = new FileDialog(browseXslBtn
552:                            .getShell(), SWT.OPEN);
553:                    fileChooser
554:                            .setText(Messages
555:                                    .getString("SecureFilterDetailsPage.SELECT_XSL_STYLESHEET")); //$NON-NLS-1$
556:                    fileChooser.setFilterExtensions(new String[] {
557:                            "*.xsl", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
558:                    fileChooser
559:                            .setFilterNames(new String[] {
560:                                    Messages
561:                                            .getString("SecureFilterDetailsPage.STYLE_SHEET_FILE_TYPE_LABEL"), Messages.getString("SecureFilterDetailsPage.ALL_FILES_LABEL") }); //$NON-NLS-1$ //$NON-NLS-2$
562:                    fileChooser.setFilterPath(basePath.toString());
563:                    String filename = fileChooser.open();
564:                    if (filename != null) {
565:                        setPageTemplate(filename, (Text) xslFile.getControl());
566:                    }
567:                }
568:            }
569:        }
w_w__w.ja_v___a___2__s__.__c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.