Source Code Cross Referenced for ResourceDetailsPage.java in  » Report » pentaho-report » org » pentaho » designstudio » editors » actionsequence » pages » parameters » 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.parameters 
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:        /*******************************************************************************
014:         * Copyright (c) 2000, 2004 IBM Corporation and others.
015:         * All rights reserved. This program and the accompanying materials 
016:         * are made available under the terms of the Common Public License v1.0
017:         * which accompanies this distribution, and is available at
018:         * http://www.eclipse.org/legal/cpl-v10.html
019:         * 
020:         * Contributors:
021:         *     IBM Corporation - initial API and implementation
022:         *******************************************************************************/package org.pentaho.designstudio.editors.actionsequence.pages.parameters;
023:
024:        import java.util.ArrayList;
025:        import java.util.Arrays;
026:
027:        import org.eclipse.core.runtime.IPath;
028:        import org.eclipse.core.runtime.Path;
029:        import org.eclipse.jface.viewers.ISelection;
030:        import org.eclipse.jface.viewers.IStructuredSelection;
031:        import org.eclipse.jface.window.Window;
032:        import org.eclipse.swt.SWT;
033:        import org.eclipse.swt.events.FocusEvent;
034:        import org.eclipse.swt.events.FocusListener;
035:        import org.eclipse.swt.events.KeyEvent;
036:        import org.eclipse.swt.events.KeyListener;
037:        import org.eclipse.swt.events.ModifyEvent;
038:        import org.eclipse.swt.events.ModifyListener;
039:        import org.eclipse.swt.events.SelectionEvent;
040:        import org.eclipse.swt.events.SelectionListener;
041:        import org.eclipse.swt.layout.FillLayout;
042:        import org.eclipse.swt.layout.GridData;
043:        import org.eclipse.swt.layout.GridLayout;
044:        import org.eclipse.swt.widgets.Button;
045:        import org.eclipse.swt.widgets.Combo;
046:        import org.eclipse.swt.widgets.Composite;
047:        import org.eclipse.swt.widgets.FileDialog;
048:        import org.eclipse.swt.widgets.Label;
049:        import org.eclipse.swt.widgets.Text;
050:        import org.eclipse.ui.forms.IFormPart;
051:        import org.eclipse.ui.forms.IManagedForm;
052:        import org.eclipse.ui.forms.widgets.Section;
053:        import org.eclipse.ui.forms.widgets.TableWrapData;
054:        import org.eclipse.ui.forms.widgets.TableWrapLayout;
055:        import org.pentaho.actionsequence.dom.ActionSequenceResource;
056:        import org.pentaho.actionsequence.dom.IActionSequenceElement;
057:        import org.pentaho.designstudio.controls.WidgetFactory;
058:        import org.pentaho.designstudio.editors.actionsequence.pages.IActionSequenceDetailsPage;
059:        import org.pentaho.designstudio.messages.Messages;
060:        import org.pentaho.designstudio.util.SolutionHelper;
061:
062:        /**
063:         * Page used to view and modify the details of a specific action sequence resources.
064:         * 
065:         * @author Angelo Rodriguez
066:         *
067:         */
068:        public class ResourceDetailsPage implements  IActionSequenceDetailsPage,
069:                ModifyListener, SelectionListener {
070:            Combo resourceTypeCombo;
071:            Text resourceNameEditor;
072:            Text resourceLocationEditor;
073:            ArrayList resourceReferences = new ArrayList();
074:            Button browserBtn;
075:            Text resourceMimeTypeEditor;
076:            ActionSequenceResource actionSequenceResource;
077:            IPath basePath;
078:            protected IManagedForm mform;
079:            String originalResourceName;
080:            private boolean dirty = false;
081:
082:            /**
083:             * Creates and resource details page.
084:             */
085:            public ResourceDetailsPage(IPath basePath) {
086:                super ();
087:                this .basePath = basePath;
088:            }
089:
090:            /* (non-Javadoc)
091:             * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
092:             */
093:            public void createContents(Composite parent) {
094:                TableWrapLayout layout = new TableWrapLayout();
095:                layout.topMargin = 5;
096:                layout.leftMargin = 5;
097:                layout.rightMargin = 2;
098:                layout.bottomMargin = 5;
099:                parent.setLayout(layout);
100:
101:                createGeneralSection(parent);
102:            }
103:
104:            public void grabFocus() {
105:                resourceNameEditor.forceFocus();
106:                resourceNameEditor.selectAll();
107:            }
108:
109:            private void createGeneralSection(Composite parent) {
110:                Section section = createSection(parent, Messages
111:                        .getString("ResourceDetailsPage.UI_RESOURCE")); //$NON-NLS-1$
112:                Composite composite = (Composite) section.getClient();
113:                GridLayout layout = new GridLayout(2, true);
114:                composite.setLayout(layout);
115:
116:                composite.setLayout(layout);
117:
118:                Label label = WidgetFactory.createLabel(composite, Messages
119:                        .getString("ResourceDetailsPage.UI_NAME_LABEL")); //$NON-NLS-1$
120:                GridData data = new GridData();
121:                data.horizontalSpan = 2;
122:                label.setLayoutData(data);
123:
124:                resourceNameEditor = WidgetFactory.createText(composite, ""); //$NON-NLS-1$
125:                resourceNameEditor.setLayoutData(new GridData(
126:                        GridData.FILL_HORIZONTAL));
127:                resourceNameEditor.addKeyListener(new KeyListener() {
128:
129:                    public void keyPressed(KeyEvent e) {
130:                        e.doit = !Character.isWhitespace(e.character);
131:                    }
132:
133:                    public void keyReleased(KeyEvent e) {
134:                    }
135:
136:                });
137:                resourceNameEditor.addFocusListener(new FocusListener() {
138:
139:                    public void focusGained(FocusEvent e) {
140:                        originalResourceName = actionSequenceResource.getName();
141:                        resourceReferences.clear();
142:                        resourceReferences
143:                                .addAll(Arrays.asList(actionSequenceResource
144:                                        .getDocument().getReferencesTo(
145:                                                actionSequenceResource)));
146:                    }
147:
148:                    public void focusLost(FocusEvent e) {
149:                        String currentParamName = actionSequenceResource
150:                                .getName();
151:                        if (!currentParamName.equals(originalResourceName)
152:                                && (resourceReferences.size()) > 0) {
153:                            UpdateParamReferencesDialog renameOutputDialog = new UpdateParamReferencesDialog(
154:                                    resourceNameEditor.getShell(),
155:                                    actionSequenceResource, resourceReferences);
156:                            if (renameOutputDialog.open() == Window.CANCEL) {
157:                                resourceNameEditor
158:                                        .setText(originalResourceName);
159:                            }
160:                        }
161:                    }
162:
163:                });
164:                resourceNameEditor.addModifyListener(this );
165:                WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
166:
167:                label = WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
168:                data = new GridData();
169:                data.horizontalSpan = 2;
170:                label.setLayoutData(data);
171:
172:                label = WidgetFactory.createLabel(composite, Messages
173:                        .getString("ResourceDetailsPage.UI_LOCATION_LABEL")); //$NON-NLS-1$
174:                data = new GridData();
175:                data.horizontalSpan = 2;
176:                label.setLayoutData(data);
177:
178:                resourceLocationEditor = WidgetFactory
179:                        .createText(composite, ""); //$NON-NLS-1$
180:                resourceLocationEditor.setLayoutData(new GridData(
181:                        GridData.FILL_HORIZONTAL));
182:                resourceLocationEditor.addModifyListener(new ModifyListener() {
183:                    public void modifyText(ModifyEvent e) {
184:                        actionSequenceResource.setPath(resourceLocationEditor
185:                                .getText().trim());
186:                    }
187:                });
188:
189:                browserBtn = WidgetFactory
190:                        .createButton(
191:                                composite,
192:                                Messages
193:                                        .getString("ResourceDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
194:                browserBtn.addSelectionListener(this );
195:
196:                label = WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
197:                data = new GridData();
198:                data.horizontalSpan = 2;
199:                label.setLayoutData(data);
200:
201:                label = WidgetFactory.createLabel(composite, Messages
202:                        .getString("ResourceDetailsPage.UI_SOURCE_TYPE_LABEL")); //$NON-NLS-1$
203:                data = new GridData();
204:                data.horizontalSpan = 2;
205:                label.setLayoutData(data);
206:
207:                resourceTypeCombo = WidgetFactory.createCombo(composite,
208:                        SWT.NONE);
209:                data = new GridData(GridData.FILL_HORIZONTAL);
210:                resourceTypeCombo.setLayoutData(data);
211:                resourceTypeCombo.setItems(new String[] {
212:                        "solution-file", "file", "url" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
213:                resourceTypeCombo.addModifyListener(this );
214:
215:                WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
216:
217:                label = WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
218:                data = new GridData();
219:                data.horizontalSpan = 2;
220:                label.setLayoutData(data);
221:
222:                label = WidgetFactory.createLabel(composite, Messages
223:                        .getString("ResourceDetailsPage.UI_MIME_TYPE_LABEL")); //$NON-NLS-1$
224:                data = new GridData();
225:                data.horizontalSpan = 2;
226:                label.setLayoutData(data);
227:
228:                resourceMimeTypeEditor = WidgetFactory
229:                        .createText(composite, ""); //$NON-NLS-1$
230:                resourceMimeTypeEditor.setLayoutData(new GridData(
231:                        GridData.FILL_HORIZONTAL));
232:                resourceMimeTypeEditor.addModifyListener(new ModifyListener() {
233:                    public void modifyText(ModifyEvent e) {
234:                        actionSequenceResource
235:                                .setMimeType(resourceMimeTypeEditor.getText()
236:                                        .trim());
237:                    }
238:                });
239:            }
240:
241:            /* (non-Javadoc)
242:             * @see org.eclipse.ui.forms.IFormPart#refresh()
243:             */
244:            public void refresh() {
245:                resourceTypeCombo.removeModifyListener(this );
246:                resourceLocationEditor.removeModifyListener(this );
247:                resourceMimeTypeEditor.removeModifyListener(this );
248:                resourceNameEditor.removeModifyListener(this );
249:                try {
250:                    resourceTypeCombo.setText(""); //$NON-NLS-1$
251:                    String resourceType = actionSequenceResource.getType();
252:                    if (resourceType != null) {
253:                        resourceTypeCombo.setText(resourceType);
254:                    }
255:                    resourceLocationEditor.setText(actionSequenceResource
256:                            .getPath());
257:                    resourceMimeTypeEditor.setText(actionSequenceResource
258:                            .getMimeType());
259:                    resourceNameEditor
260:                            .setText(actionSequenceResource.getName());
261:                } finally {
262:                    resourceTypeCombo.addModifyListener(this );
263:                    resourceLocationEditor.addModifyListener(this );
264:                    resourceMimeTypeEditor.addModifyListener(this );
265:                    resourceNameEditor.addModifyListener(this );
266:                }
267:            }
268:
269:            /* (non-Javadoc)
270:             * @see org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceDetailsPage#accepts(org.dom4j.Element)
271:             */
272:            public boolean accepts(IActionSequenceElement detailElement) {
273:                return detailElement instanceof  ActionSequenceResource;
274:            }
275:
276:            public void dispose() {
277:                // TODO Auto-generated method stub
278:
279:            }
280:
281:            public void selectionChanged(IFormPart part, ISelection selection) {
282:                IStructuredSelection ssel = (IStructuredSelection) selection;
283:                if ((ssel.size() == 1)
284:                        && (ssel.getFirstElement() instanceof  ActionSequenceResource)) {
285:                    setActionSequenceElement((ActionSequenceResource) ssel
286:                            .getFirstElement());
287:                } else {
288:                    setActionSequenceElement(null);
289:                }
290:            }
291:
292:            /* (non-Javadoc)
293:             * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
294:             */
295:            public void initialize(IManagedForm form) {
296:                this .mform = form;
297:            }
298:
299:            /* (non-Javadoc)
300:             * @see org.eclipse.ui.forms.IFormPart#isDirty()
301:             */
302:            public boolean isDirty() {
303:                return dirty;
304:            }
305:
306:            /* (non-Javadoc)
307:             * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
308:             */
309:            public void commit(boolean onSave) {
310:            }
311:
312:            /* (non-Javadoc)
313:             * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
314:             */
315:            public boolean setFormInput(Object input) {
316:                return false;
317:            }
318:
319:            /* (non-Javadoc)
320:             * @see org.eclipse.ui.forms.IFormPart#setFocus()
321:             */
322:            public void setFocus() {
323:            }
324:
325:            /* (non-Javadoc)
326:             * @see org.eclipse.ui.forms.IFormPart#isStale()
327:             */
328:            public boolean isStale() {
329:                return false;
330:            }
331:
332:            protected Section createSection(Composite parent,
333:                    String sectionName, int style) {
334:                Section section = WidgetFactory.createSection(parent, style);
335:                section.setText(sectionName);
336:
337:                section.setLayoutData(new TableWrapData(
338:                        TableWrapData.FILL_GRAB, TableWrapData.TOP));
339:
340:                WidgetFactory.createSeparator(section);
341:                Composite composite = new Composite(section, SWT.NULL);
342:                composite.setLayout(new FillLayout());
343:                composite.setLayoutData(new TableWrapData(
344:                        TableWrapData.FILL_GRAB));
345:                section.setClient(composite);
346:
347:                return section;
348:            }
349:
350:            protected Section createSection(Composite parent, String sectionName) {
351:                return createSection(parent, sectionName, Section.TWISTIE
352:                        | Section.EXPANDED);
353:            }
354:
355:            protected Section createConfigurationSection(Composite parent) {
356:                return (createSection(
357:                        parent,
358:                        Messages
359:                                .getString("ResourceDetailsPage.UI_CONFIG_SECTION_LABEL"))); //$NON-NLS-1$
360:            }
361:
362:            public void modifyText(ModifyEvent e) {
363:                if (e.getSource() == resourceTypeCombo) {
364:                    actionSequenceResource.setType(resourceTypeCombo.getText()
365:                            .trim());
366:                } else if (e.getSource() == resourceLocationEditor) {
367:                    String resourceName = resourceLocationEditor.getText()
368:                            .trim();
369:                    actionSequenceResource.setPath(resourceName);
370:                } else if (e.getSource() == resourceMimeTypeEditor) {
371:                    actionSequenceResource.setMimeType(resourceMimeTypeEditor
372:                            .getText().trim());
373:                } else if (e.getSource() == resourceNameEditor) {
374:                    String name = resourceNameEditor.getText().trim();
375:                    if (name.length() > 0) {
376:                        actionSequenceResource.setName(name);
377:                    }
378:                }
379:            }
380:
381:            private void setResourcePath(String fileName) {
382:                String fileSolution = SolutionHelper.getSolutionName(fileName);
383:                Path filePath = new Path(fileName);
384:                String baseSolution = SolutionHelper.getSolutionName(basePath
385:                        .toString());
386:                String solutionRoot = SolutionHelper.getSolutionRoot(basePath
387:                        .toString());
388:
389:                if ((baseSolution != null) && baseSolution.equals(fileSolution)) {
390:                    resourceTypeCombo
391:                            .setText(ActionSequenceResource.SOLUTION_FILE_RESOURCE_TYPE);
392:                    if (filePath.matchingFirstSegments(basePath) == basePath
393:                            .segmentCount()) {
394:                        IPath relativeFilePath = filePath
395:                                .removeFirstSegments(basePath.segmentCount());
396:                        resourceLocationEditor.setText(relativeFilePath
397:                                .setDevice(null).toString());
398:                    } else {
399:                        Path solutionPath = new Path(solutionRoot);
400:                        IPath relativePath = filePath
401:                                .removeFirstSegments(solutionPath
402:                                        .segmentCount());
403:                        IPath absPath = relativePath.makeAbsolute().setDevice(
404:                                null);
405:                        resourceLocationEditor.setText(absPath.toString());
406:                    }
407:                } else {
408:                    resourceTypeCombo
409:                            .setText(ActionSequenceResource.FILE_RESOURCE_TYPE);
410:                    resourceLocationEditor.setText(fileName);
411:                }
412:            }
413:
414:            public IActionSequenceElement getActionSequenceElement() {
415:                return actionSequenceResource;
416:            }
417:
418:            public String getName() {
419:                return Messages.getString("ResourceDetailsPage.UI_INPUTS_MENU"); //$NON-NLS-1$
420:            }
421:
422:            public void setActionSequenceElement(IActionSequenceElement element) {
423:                actionSequenceResource = (ActionSequenceResource) element;
424:                refresh();
425:            }
426:
427:            public void widgetDefaultSelected(SelectionEvent e) {
428:            }
429:
430:            public void widgetSelected(SelectionEvent e) {
431:                FileDialog fileChooser = new FileDialog(browserBtn.getShell(),
432:                        SWT.OPEN);
433:                fileChooser
434:                        .setText(Messages
435:                                .getString("ResourceDetailsPage.UI_RESOURCE_SELECT_LABEL")); //$NON-NLS-1$
436:                fileChooser
437:                        .setFilterExtensions(new String[] { Messages
438:                                .getString("ResourceDetailsPage.UI_FILE_FILTER_EXTENSION") }); //$NON-NLS-1$
439:                fileChooser.setFilterNames(new String[] { Messages
440:                        .getString("ResourceDetailsPage.UI_ALL_FILES") }); //$NON-NLS-1$
441:                String filename = fileChooser.open();
442:                if (filename != null) {
443:                    setResourcePath(filename);
444:                }
445:            }
446:        }
w___w_w___.__j__a__va2__s___.__c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.