Source Code Cross Referenced for ActionSequenceOutputsTree.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:        package org.pentaho.designstudio.editors.actionsequence.pages.parameters;
014:
015:        import java.util.ArrayList;
016:        import java.util.Iterator;
017:
018:        import org.dom4j.Element;
019:        import org.eclipse.jface.viewers.IStructuredSelection;
020:        import org.eclipse.jface.viewers.ITreeContentProvider;
021:        import org.eclipse.jface.viewers.StructuredSelection;
022:        import org.eclipse.jface.viewers.TreeViewer;
023:        import org.eclipse.jface.viewers.Viewer;
024:        import org.eclipse.jface.viewers.ViewerDropAdapter;
025:        import org.eclipse.swt.dnd.DND;
026:        import org.eclipse.swt.dnd.Transfer;
027:        import org.eclipse.swt.dnd.TransferData;
028:        import org.eclipse.swt.graphics.Image;
029:        import org.eclipse.swt.widgets.Display;
030:        import org.eclipse.swt.widgets.Tree;
031:        import org.eclipse.swt.widgets.Widget;
032:        import org.pentaho.actionsequence.dom.AbstractIOElement;
033:        import org.pentaho.actionsequence.dom.ActionControlStatement;
034:        import org.pentaho.actionsequence.dom.ActionOutput;
035:        import org.pentaho.actionsequence.dom.ActionSequenceDocument;
036:        import org.pentaho.actionsequence.dom.ActionSequenceInput;
037:        import org.pentaho.actionsequence.dom.ActionSequenceOutput;
038:        import org.pentaho.actionsequence.dom.IActionSequenceDocumentListener;
039:        import org.pentaho.actionsequence.dom.actions.ActionDefinition;
040:        import org.pentaho.designstudio.controls.ActionSequenceParamTransfer;
041:        import org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceLabelProvider;
042:
043:        /**
044:         * Tree viewer used for viewing and modifying the inputs, outputs, and resources in a 
045:         * component definition
046:         * 
047:         * @author Angelo Rodriguez
048:         */
049:        public class ActionSequenceOutputsTree extends TreeViewer implements 
050:                IActionSequenceDocumentListener {
051:
052:            public class LabelProvider extends ActionSequenceLabelProvider {
053:                public LabelProvider(Display display) {
054:                    super (display);
055:                }
056:
057:                public Image getImage(Object obj) {
058:                    Image image = null;
059:                    if (obj instanceof  ActionSequenceOutput) {
060:                        image = super .getImage(((ActionSequenceOutput) obj)
061:                                .getElement());
062:                    } else {
063:                        image = super .getImage(obj);
064:                    }
065:                    return image;
066:                }
067:
068:                public String getText(Object obj) {
069:                    String text = null;
070:                    if (obj instanceof  ActionSequenceOutput) {
071:                        text = super .getText(((ActionSequenceOutput) obj)
072:                                .getElement());
073:                    } else {
074:                        text = super .getText(obj);
075:                    }
076:                    return text;
077:                }
078:
079:            }
080:
081:            public class ContentProvider implements  ITreeContentProvider {
082:
083:                public ContentProvider() {
084:                }
085:
086:                /* (non-Javadoc)
087:                 * Method declared on ITreeContentProvider.
088:                 */
089:                public Object[] getChildren(Object parent) {
090:                    return hasChildren(parent) ? actionSequence.getOutputs()
091:                            : new Object[0];
092:                }
093:
094:                /* (non-Javadoc)
095:                 * Method declared on ITreeContentProvider.
096:                 */
097:                public Object getParent(Object child) {
098:                    return child instanceof  ActionSequenceOutput ? getOutputRoot()
099:                            : null;
100:                }
101:
102:                /* (non-Javadoc)
103:                 * Method declared on ITreeContentProvider.
104:                 */
105:                public boolean hasChildren(Object node) {
106:                    return (node instanceof  Element)
107:                            && (actionSequence.getOutputs().length > 0);
108:                }
109:
110:                /* (non-Javadoc)
111:                 * Method declared on ITreeContentProvider.
112:                 */
113:                public Object[] getElements(Object inputElement) {
114:                    ArrayList elements = new ArrayList();
115:                    Element outputRoot = getOutputRoot();
116:                    if (outputRoot != null) {
117:                        elements.add(outputRoot);
118:                    }
119:                    return elements.toArray();
120:                }
121:
122:                /* (non-Javadoc)
123:                 * Method declared on ITreeContentProvider.
124:                 */
125:                public void dispose() {
126:                    actionSequence = null;
127:                }
128:
129:                /* (non-Javadoc)
130:                 * Method declared on ITreeContentProvider.
131:                 */
132:                public void inputChanged(Viewer viewer, Object oldInput,
133:                        Object newInput) {
134:                    if (actionSequence != null) {
135:                        actionSequence
136:                                .removeListener(ActionSequenceOutputsTree.this );
137:                    }
138:                    if (newInput instanceof  ActionSequenceDocument) {
139:                        actionSequence = (ActionSequenceDocument) newInput;
140:                        actionSequence
141:                                .addListener(ActionSequenceOutputsTree.this );
142:                    } else {
143:                        actionSequence = null;
144:                    }
145:                }
146:
147:            }
148:
149:            class DropAdapter extends ViewerDropAdapter {
150:
151:                DropAdapter() {
152:                    super (ActionSequenceOutputsTree.this );
153:                }
154:
155:                /* (non-Javadoc)
156:                 * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
157:                 */
158:                public boolean performDrop(Object data) {
159:                    return addOutput((AbstractIOElement) data);
160:                }
161:
162:                /*
163:                 * (non-Javadoc)
164:                 * 
165:                 * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object,
166:                 *      int, org.eclipse.swt.dnd.TransferData)
167:                 */
168:                public boolean validateDrop(Object target, int op,
169:                        TransferData type) {
170:                    return true;
171:                }
172:            }
173:
174:            protected ActionSequenceDocument actionSequence;
175:            private ContentProvider treeContentProvider;
176:            private DropAdapter dropAdapter;
177:
178:            /**
179:             * Create an action sequence inputs, outputs, and resources viewer.
180:             * @param parent the tree being managed by this viewer
181:             */
182:            public ActionSequenceOutputsTree(Tree tree) {
183:                super (tree);
184:                init();
185:            }
186:
187:            public boolean addOutput(AbstractIOElement output) {
188:                boolean result = false;
189:                String name = ""; //$NON-NLS-1$
190:                String type = ""; //$NON-NLS-1$
191:                if ((output instanceof  ActionSequenceInput)
192:                        || (output instanceof  ActionOutput)) {
193:                    if (output instanceof  ActionSequenceInput) {
194:                        name = ((ActionSequenceInput) output).getName();
195:                        type = ((ActionSequenceInput) output).getType();
196:                    } else {
197:                        name = ((ActionOutput) output).getPublicName();
198:                        type = ((ActionOutput) output).getType();
199:                    }
200:                    ActionSequenceOutput docOutput = actionSequence
201:                            .createOutput(name, type);
202:                    refresh();
203:                    result = true;
204:                    setSelection(new StructuredSelection(docOutput));
205:                    getTree().forceFocus();
206:                }
207:                return result;
208:            }
209:
210:            private void init() {
211:                treeContentProvider = new ContentProvider();
212:                setContentProvider(treeContentProvider);
213:                setLabelProvider(new LabelProvider(getTree().getDisplay()));
214:
215:                int ops = DND.DROP_MOVE | DND.DROP_COPY;
216:                dropAdapter = new DropAdapter();
217:                addDropSupport(ops,
218:                        new Transfer[] { ActionSequenceParamTransfer
219:                                .getInstance() }, dropAdapter);
220:            }
221:
222:            /**
223:             * Deletes the selection inputs, outputs, and resources from the action sequence and this viewer.
224:             */
225:            public void deleteSelectedOutputs() {
226:                IStructuredSelection selection = (IStructuredSelection) getSelection();
227:                for (Iterator iter = selection.iterator(); iter.hasNext();) {
228:                    Object output = iter.next();
229:                    if (output instanceof  ActionSequenceOutput) {
230:                        actionSequence
231:                                .deleteOutput(((ActionSequenceOutput) output)
232:                                        .getName());
233:                    }
234:                }
235:            }
236:
237:            private Element getOutputRoot() {
238:                Element outputRoot = null;
239:                if (actionSequence != null) {
240:                    Element docRoot = actionSequence.getDocument()
241:                            .getRootElement();
242:                    if (docRoot != null) {
243:                        outputRoot = docRoot
244:                                .element(ActionSequenceDocument.DOC_OUTPUTS_NAME);
245:                    }
246:                }
247:                return outputRoot;
248:            }
249:
250:            public void ioAdded(AbstractIOElement io) {
251:                Element outputElement = getOutputRoot();
252:                if (outputElement != null) {
253:                    Widget outputItem = findItem(outputElement);
254:                    if (outputItem == null) {
255:                        createTreeItem(getTree(), outputElement, -1);
256:                    } else {
257:                        refresh(outputElement);
258:                    }
259:                }
260:            }
261:
262:            public void ioChanged(AbstractIOElement io) {
263:                if (io instanceof  ActionSequenceOutput) {
264:                    update(io, null);
265:                }
266:            }
267:
268:            public void ioRemoved(Object parent, AbstractIOElement io) {
269:                if (io instanceof  ActionSequenceOutput) {
270:                    remove(io);
271:                }
272:            }
273:
274:            public void ioRenamed(AbstractIOElement io) {
275:                if (io instanceof  ActionSequenceOutput) {
276:                    update(io, null);
277:                }
278:            }
279:
280:            public void actionAdded(ActionDefinition action) {
281:            }
282:
283:            public void actionChanged(ActionDefinition action) {
284:            }
285:
286:            public void actionRemoved(Object parent, ActionDefinition action) {
287:            }
288:
289:            public void actionRenamed(ActionDefinition action) {
290:            }
291:
292:            public void controlStatementAdded(
293:                    ActionControlStatement controlStatement) {
294:            }
295:
296:            public void controlStatementChanged(
297:                    ActionControlStatement controlStatement) {
298:            }
299:
300:            public void controlStatementRemoved(Object parent,
301:                    ActionControlStatement controlStatement) {
302:            }
303:
304:            public void resourceAdded(Object resource) {
305:            }
306:
307:            public void resourceChanged(Object resource) {
308:            }
309:
310:            public void resourceRemoved(Object parent, Object resource) {
311:            }
312:
313:            public void resourceRenamed(Object resource) {
314:            }
315:
316:            public void headerChanged(
317:                    ActionSequenceDocument actionSequenceDocument) {
318:            }
319:        }
w_w___w__.___j_a_v_a_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.