Source Code Cross Referenced for KettleTransformationDetailsPage.java in  » Report » pentaho-report » org » pentaho » designstudio » editors » actionsequence » pages » actions » details » kettle » 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.kettle 
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.kettle;
014:
015:        import java.net.URI;
016:        import java.net.URISyntaxException;
017:        import java.text.MessageFormat;
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:
021:        import org.eclipse.core.runtime.IPath;
022:        import org.eclipse.core.runtime.Path;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.custom.StackLayout;
025:        import org.eclipse.swt.events.SelectionEvent;
026:        import org.eclipse.swt.events.SelectionListener;
027:        import org.eclipse.swt.layout.GridData;
028:        import org.eclipse.swt.layout.GridLayout;
029:        import org.eclipse.swt.widgets.Button;
030:        import org.eclipse.swt.widgets.Composite;
031:        import org.eclipse.swt.widgets.FileDialog;
032:        import org.eclipse.swt.widgets.Text;
033:        import org.pentaho.actionsequence.dom.AbstractIOElement;
034:        import org.pentaho.actionsequence.dom.ActionInputConstant;
035:        import org.pentaho.actionsequence.dom.ActionResource;
036:        import org.pentaho.actionsequence.dom.ActionSequenceDocument;
037:        import org.pentaho.actionsequence.dom.ActionSequenceResource;
038:        import org.pentaho.actionsequence.dom.IActionSequenceElement;
039:        import org.pentaho.actionsequence.dom.actions.ActionDefinition;
040:        import org.pentaho.actionsequence.dom.actions.KettleTransformAction;
041:        import org.pentaho.designstudio.controls.ActionInputsList;
042:        import org.pentaho.designstudio.controls.ActionInputsListToolbar;
043:        import org.pentaho.designstudio.controls.ActionOutputText;
044:        import org.pentaho.designstudio.controls.ActionResourceText;
045:        import org.pentaho.designstudio.controls.NewActionInputCombo;
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:        public class KettleTransformationDetailsPage extends ActionDetailsPage
053:                implements  SelectionListener, IActionIOFilter {
054:
055:            ActionResourceText kettleResourceFilePath;
056:            NewActionInputCombo kettleRepositoryFile;
057:            NewActionInputCombo kettleRepositoryDir;
058:
059:            Button browseKettleTransformBtn;
060:
061:            NewActionInputCombo transformationStep;
062:
063:            ActionOutputText transformationOutput;
064:
065:            IPath basePath;
066:
067:            StackLayout stackLayout = new StackLayout();
068:            Composite stackedComposite;
069:            Composite repositoryFileComposite;
070:            Composite resourceFileComposite;
071:
072:            ActionInputsList inputParameters;
073:            ActionInputsListToolbar inputParametersToolbar;
074:            Button useKettleRepositoryBtn;
075:
076:            public KettleTransformationDetailsPage(IPath basePath) {
077:                this .basePath = basePath;
078:            }
079:
080:            public String getComponentName() {
081:                return KettleTransformAction.COMPONENT_NAME;
082:            }
083:
084:            public void createDetailsComposite(Composite parent) {
085:                Composite actionConfigComposite = parent;
086:
087:                GridLayout gridLayout = new GridLayout(2, true);
088:                gridLayout.horizontalSpacing = 20;
089:                actionConfigComposite.setLayout(gridLayout);
090:
091:                useKettleRepositoryBtn = WidgetFactory
092:                        .createButton(
093:                                actionConfigComposite,
094:                                Messages
095:                                        .getString("KettleTransformationDetailsPage.USET_KETTLE_REPOS"), SWT.CHECK); //$NON-NLS-1$
096:                useKettleRepositoryBtn.addSelectionListener(this );
097:
098:                Composite composite = WidgetFactory
099:                        .createComposite(actionConfigComposite);
100:                gridLayout = new GridLayout(2, false);
101:                gridLayout.marginWidth = 0;
102:                gridLayout.marginHeight = 0;
103:                composite.setLayout(gridLayout);
104:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
105:
106:                WidgetFactory
107:                        .createLabel(
108:                                composite,
109:                                Messages
110:                                        .getString("KettleTransformationDetailsPage.TRANSFORMATION_INPUTS_LABEL")); //$NON-NLS-1$
111:
112:                stackedComposite = WidgetFactory
113:                        .createComposite(actionConfigComposite);
114:                stackedComposite.setLayoutData(new GridData(
115:                        GridData.FILL_HORIZONTAL));
116:                stackLayout.marginHeight = 2;
117:                stackLayout.marginWidth = 1;
118:                stackedComposite.setLayout(stackLayout);
119:
120:                repositoryFileComposite = WidgetFactory
121:                        .createComposite(stackedComposite);
122:                gridLayout = new GridLayout();
123:                gridLayout.marginWidth = 1;
124:                gridLayout.marginHeight = 1;
125:                repositoryFileComposite.setLayout(gridLayout);
126:                WidgetFactory.createLabel(repositoryFileComposite, "Directory"); //$NON-NLS-1$
127:                kettleRepositoryDir = new NewActionInputCombo(
128:                        repositoryFileComposite, new GridData(
129:                                GridData.FILL_HORIZONTAL));
130:                kettleRepositoryDir.setRemoveInputWhenNoValue(false);
131:                WidgetFactory
132:                        .createLabel(
133:                                repositoryFileComposite,
134:                                Messages
135:                                        .getString("KettleTransformationDetailsPage.TRANSFORMATION_FILE_LABEL")); //$NON-NLS-1$
136:                kettleRepositoryFile = new NewActionInputCombo(
137:                        repositoryFileComposite, new GridData(
138:                                GridData.FILL_HORIZONTAL));
139:                kettleRepositoryFile.setRemoveInputWhenNoValue(false);
140:
141:                resourceFileComposite = WidgetFactory
142:                        .createComposite(stackedComposite);
143:                gridLayout = new GridLayout();
144:                gridLayout.marginWidth = 1;
145:                gridLayout.marginHeight = 1;
146:                resourceFileComposite.setLayout(gridLayout);
147:                GridData gridData = new GridData();
148:                gridData.grabExcessVerticalSpace = true;
149:                gridData.verticalAlignment = SWT.END;
150:                WidgetFactory
151:                        .createLabel(
152:                                resourceFileComposite,
153:                                Messages
154:                                        .getString("KettleTransformationDetailsPage.TRANSFORMATION_FILE_LABEL")).setLayoutData(gridData); //$NON-NLS-1$
155:                kettleResourceFilePath = new ActionResourceText(
156:                        resourceFileComposite, new GridData(
157:                                GridData.FILL_HORIZONTAL));
158:                kettleResourceFilePath.setBasePath(basePath);
159:                browseKettleTransformBtn = WidgetFactory
160:                        .createButton(
161:                                resourceFileComposite,
162:                                Messages
163:                                        .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.NONE); //$NON-NLS-1$
164:                browseKettleTransformBtn.addSelectionListener(this );
165:                gridData = new GridData();
166:                gridData.horizontalAlignment = GridData.END;
167:                gridData.verticalAlignment = SWT.BEGINNING;
168:                browseKettleTransformBtn.setLayoutData(gridData);
169:
170:                inputParameters = new ActionInputsList(actionConfigComposite);
171:                gridData = new GridData(GridData.FILL_HORIZONTAL);
172:                gridData.verticalAlignment = SWT.FILL;
173:                gridData.verticalSpan = 5;
174:                inputParameters.getControl().setLayoutData(gridData);
175:                inputParameters.setFilter(this );
176:
177:                inputParametersToolbar = new ActionInputsListToolbar(composite,
178:                        inputParameters);
179:                gridData = new GridData(GridData.FILL_HORIZONTAL);
180:                gridData.horizontalAlignment = GridData.END;
181:                inputParametersToolbar.getControl().setLayoutData(gridData);
182:
183:                WidgetFactory
184:                        .createLabel(
185:                                actionConfigComposite,
186:                                Messages
187:                                        .getString("KettleTransformationDetailsPage.TRANSFORMATION_STEP")); //$NON-NLS-1$
188:
189:                transformationStep = new NewActionInputCombo(
190:                        actionConfigComposite, new GridData(
191:                                GridData.FILL_HORIZONTAL));
192:
193:                WidgetFactory
194:                        .createLabel(
195:                                actionConfigComposite,
196:                                Messages
197:                                        .getString("KettleTransformationDetailsPage.OUTPUT_NAME")); //$NON-NLS-1$
198:
199:                gridData = new GridData(GridData.FILL_HORIZONTAL);
200:                gridData.verticalAlignment = GridData.BEGINNING;
201:                transformationOutput = new ActionOutputText(
202:                        actionConfigComposite, gridData);
203:            }
204:
205:            public boolean accepts(IActionSequenceElement actionDef) {
206:                return actionDef instanceof  KettleTransformAction;
207:            }
208:
209:            public void refresh() {
210:                super .refresh();
211:                useKettleRepositoryBtn.removeSelectionListener(this );
212:                kettleResourceFilePath.setTargetResource(actionDefinition,
213:                        KettleTransformAction.TRANSFORMATION_FILE_ELEMENT);
214:                kettleRepositoryFile.setTargetInput(actionDefinition,
215:                        KettleTransformAction.REPOSITORY_TRANSFORMATION,
216:                        ActionSequenceDocument.STRING_TYPE);
217:                kettleRepositoryDir.setTargetInput(actionDefinition,
218:                        KettleTransformAction.REPOSITORY_DIRECTORY,
219:                        ActionSequenceDocument.STRING_TYPE);
220:                transformationStep.setTargetInput(actionDefinition,
221:                        KettleTransformAction.TRANSFORMATION_STEP_ELEMENT,
222:                        ActionSequenceDocument.STRING_TYPE);
223:                transformationOutput.setTargetOutput(actionDefinition,
224:                        KettleTransformAction.OUTPUT_RESULT_SET);
225:                inputParameters.setInput(actionDefinition);
226:                inputParametersToolbar.refresh();
227:                ActionResource actionResource = actionDefinition
228:                        .getResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT);
229:                if (actionResource == null) {
230:                    useKettleRepositoryBtn.setSelection(true);
231:                    stackLayout.topControl = repositoryFileComposite;
232:                } else {
233:                    useKettleRepositoryBtn.setSelection(false);
234:                    stackLayout.topControl = resourceFileComposite;
235:                }
236:                useKettleRepositoryBtn.addSelectionListener(this );
237:            }
238:
239:            private void setResourcePath(String fileName, Text text) {
240:                String fileSolution = SolutionHelper.getSolutionName(fileName);
241:                Path filePath = new Path(fileName);
242:                String baseSolution = SolutionHelper.getSolutionName(basePath
243:                        .toString());
244:                String solutionRoot = SolutionHelper.getSolutionRoot(basePath
245:                        .toString());
246:
247:                if ((baseSolution != null) && baseSolution.equals(fileSolution)) {
248:                    if (filePath.matchingFirstSegments(basePath) == basePath
249:                            .segmentCount()) {
250:                        IPath relativeFilePath = filePath
251:                                .removeFirstSegments(basePath.segmentCount());
252:                        text.setText(relativeFilePath.setDevice(
253:                                ActionSequenceResource.SOLUTION_SCHEME + ":")
254:                                .toString());
255:                    } else {
256:                        Path solutionPath = new Path(solutionRoot);
257:                        IPath relativePath = filePath
258:                                .removeFirstSegments(solutionPath
259:                                        .segmentCount());
260:                        IPath absPath = relativePath.makeAbsolute().setDevice(
261:                                ActionSequenceResource.SOLUTION_SCHEME + ":"); //$NON-NLS-1$
262:                        text.setText(absPath.toString());
263:                    }
264:                } else {
265:                    text.setText(ActionSequenceResource.FILE_SCHEME + ":"
266:                            + fileName);
267:                }
268:            }
269:
270:            public boolean checkResourceReferences(
271:                    ActionDefinition actionDefinition) {
272:                return (actionDefinition
273:                        .getResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT) != null)
274:                        || (actionDefinition
275:                                .getDocument()
276:                                .getResource(
277:                                        KettleTransformAction.TRANSFORMATION_FILE_ELEMENT) == null);
278:            }
279:
280:            public void fixResourceReferences(ActionDefinition actionDefinition) {
281:                if ((actionDefinition
282:                        .getResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT) == null)
283:                        && (actionDefinition
284:                                .getDocument()
285:                                .getResource(
286:                                        KettleTransformAction.TRANSFORMATION_FILE_ELEMENT) != null)) {
287:                    actionDefinition
288:                            .addResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT);
289:                }
290:            }
291:
292:            public String getName() {
293:                return Messages
294:                        .getString("KettleTransformationDetailsPage.KETTLE_TRANSFORMATION"); //$NON-NLS-1$
295:            }
296:
297:            public void widgetDefaultSelected(SelectionEvent e) {
298:            }
299:
300:            private void setUseKettleRepository(boolean useKettleRepository) {
301:                KettleTransformAction kettleTransformAction = (KettleTransformAction) actionDefinition;
302:                if (useKettleRepository) {
303:                    ActionResource actionResource = actionDefinition
304:                            .getResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT);
305:                    if (actionResource != null) {
306:                        String logicalName = actionResource.getPublicName();
307:                        actionDefinition
308:                                .removeResourceParam(KettleTransformAction.TRANSFORMATION_FILE_ELEMENT);
309:                        ActionSequenceResource actionSequenceResource = actionDefinition
310:                                .getDocument().getResource(logicalName);
311:                        if ((actionSequenceResource != null)
312:                                && (actionDefinition
313:                                        .getDocument()
314:                                        .getReferencesTo(actionSequenceResource).length == 0)) {
315:                            actionSequenceResource.delete();
316:                        }
317:                    }
318:                    kettleTransformAction.setDirectory(new ActionInputConstant(
319:                            ""));
320:                    kettleTransformAction
321:                            .setTransformation(new ActionInputConstant(""));
322:                    stackLayout.topControl = repositoryFileComposite;
323:                } else {
324:                    try {
325:                        actionDefinition
326:                                .setResourceUri(
327:                                        KettleTransformAction.TRANSFORMATION_FILE_ELEMENT,
328:                                        new URI(
329:                                                ActionSequenceResource.FILE_SCHEME,
330:                                                " ", null), "text/plain");
331:                    } catch (URISyntaxException e) {
332:                        // Hard coded URI in try block is always valid.
333:                    }
334:                    kettleTransformAction.setDirectory(null);
335:                    kettleTransformAction.setTransformation(null);
336:                    stackLayout.topControl = resourceFileComposite;
337:                }
338:                kettleRepositoryFile.refresh();
339:                kettleRepositoryDir.refresh();
340:                kettleResourceFilePath.refresh();
341:                stackedComposite.layout();
342:            }
343:
344:            private void selectKettleTransform() {
345:                FileDialog fileChooser = new FileDialog(
346:                        browseKettleTransformBtn.getShell(), SWT.OPEN);
347:                fileChooser
348:                        .setText(MessageFormat
349:                                .format(
350:                                        Messages
351:                                                .getString("AbstractKettleDetailsPage.FILE_CHOOSER_TITLE"), new Object[] { Messages.getString("KettleTransformationDetailsPage.TRANSFORMATION_FILE_LABEL") })); //$NON-NLS-1$ //$NON-NLS-2$
352:                fileChooser
353:                        .setFilterExtensions(new String[] { "*.ktr", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
354:                fileChooser
355:                        .setFilterNames(new String[] {
356:                                "Kettle Transformation", Messages.getString("JFreeReportDetailsPage.ALL_FILES") }); //$NON-NLS-2$
357:                String filename = fileChooser.open();
358:                if (filename != null) {
359:                    setResourcePath(filename, (Text) kettleResourceFilePath
360:                            .getControl());
361:                }
362:            }
363:
364:            public void widgetSelected(SelectionEvent e) {
365:                if (e.getSource() == useKettleRepositoryBtn) {
366:                    setUseKettleRepository(useKettleRepositoryBtn
367:                            .getSelection());
368:                } else if (e.getSource() == browseKettleTransformBtn) {
369:                    selectKettleTransform();
370:                }
371:            }
372:
373:            public boolean accept(AbstractIOElement ioElement) {
374:                ArrayList expectedInputs = new ArrayList();
375:                if (actionDefinition != null) {
376:                    expectedInputs.addAll(Arrays.asList(actionDefinition
377:                            .getReservedInputNames()));
378:                }
379:                return (!expectedInputs.contains(ioElement.getName()));
380:            }
381:
382:        }
w___w__w.j_ava__2__s___.___co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.