Source Code Cross Referenced for UIPlanElementNode.java in  » Science » Cougaar12_4 » org » cougaar » mlm » debug » ui » 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 » Science » Cougaar12_4 » org.cougaar.mlm.debug.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.mlm.debug.ui;
028:
029:        import java.util.Iterator;
030:
031:        import org.cougaar.core.mts.MessageAddress;
032:        import org.cougaar.planning.ldm.asset.AggregateAsset;
033:        import org.cougaar.planning.ldm.asset.Asset;
034:        import org.cougaar.planning.ldm.plan.Aggregation;
035:        import org.cougaar.planning.ldm.plan.Allocation;
036:        import org.cougaar.planning.ldm.plan.AllocationResult;
037:        import org.cougaar.planning.ldm.plan.AssetTransfer;
038:        import org.cougaar.planning.ldm.plan.Expansion;
039:        import org.cougaar.planning.ldm.plan.PlanElement;
040:        import org.cougaar.planning.ldm.plan.Schedule;
041:        import org.cougaar.planning.ldm.plan.ScheduleElement;
042:        import org.cougaar.planning.ldm.plan.Task;
043:        import org.cougaar.planning.ldm.plan.Verb;
044:        import org.cougaar.planning.ldm.plan.Workflow;
045:
046:        /** A tree node for a PlanElement.
047:         Overrides the UITreeNode loadChildren, toString and isLeaf
048:         methods to dynamically display the children (tasks and dispositions)
049:         of plan elements.
050:         */
051:
052:        public class UIPlanElementNode extends UITreeNode {
053:            PlanElement planElement;
054:
055:            /** Creates a tree node for a plan element by calling
056:              the UITreeNode constructor.
057:              @param planElement plan element for which to create a tree node
058:             */
059:
060:            public UIPlanElementNode(PlanElement planElement) {
061:                super (planElement);
062:                this .planElement = planElement;
063:            }
064:
065:            /** PlanElement is never a leaf.
066:              @return false
067:             */
068:
069:            public boolean isLeaf() {
070:                return false;
071:            }
072:
073:            /** Representation of a PlanElement in the tree.
074:              @return PlanElement, type of PlanElement, Task Verb
075:             */
076:
077:            public String toString() {
078:                //    return planElement.toString();
079:                String disp = "disposition";
080:                if (planElement instanceof  Allocation)
081:                    disp = "Allocation";
082:                else if (planElement instanceof  Aggregation)
083:                    disp = "Aggregation";
084:                else if (planElement instanceof  AssetTransfer)
085:                    disp = "Asset Transfer";
086:                else if (planElement instanceof  Expansion)
087:                    disp = "Expansion";
088:                Task task = planElement.getTask();
089:                Verb verb = task.getVerb();
090:                String verbString = "";
091:                if (verb != null)
092:                    verbString = verb.toString();
093:                return "Plan Element" + " " + disp + " " + verbString;
094:            }
095:
096:            private int loadAssets(AggregateAsset a, int position, String prefix) {
097:                int count = 0;
098:                if (a.getAsset() == null)
099:                    return 0; // no nodes added
100:                int quantity = 1;
101:                //if ( aggregateProp instanceof SimpleAggregateAssetProperty ) {
102:                //SimpleAggregateAssetProperty saap = (SimpleAggregateAssetProperty)aggregateProp;
103:                quantity = (int) a.getQuantity();
104:
105:                insert(new UIStringNode("Number of assets: "
106:                        + String.valueOf(quantity)), position++);
107:                //int quantityhack = 9999;
108:                //insert(new UIStringNode("Number of assets: " + String.valueOf(quantityhack)), position++);
109:                insert(new UIAssetNode(a.getAsset(), prefix), position++);
110:                count++;
111:
112:                return count + 1;// number of assets inserted +1 for count field
113:            }
114:
115:            /** The children of all dispositions are:
116:                  current schedule, penalty value, and direct objects (assets)
117:              A disposition can be an allocation, expansion or asset transfer.
118:              The children of an allocation are:
119:                  asset, estinated schedule, estimated penalty value
120:              The children of an expansion are:
121:                  workflow
122:              The children of an asset transfer are:
123:                  asset, assignor cluster, assignee cluster, schedule
124:              Any asset can be an aggregate asset, in which case this
125:              steps through the enumeration of assets and creates a node for each.
126:             */
127:
128:            public synchronized void loadChildren() {
129:                Task task = planElement.getTask();
130:                ScheduleElement schedule = null;
131:                //PenaltyValue penaltyValue;
132:                AllocationResult allocationresult = null;
133:                Asset asset;
134:
135:                int i = 0;
136:
137:                insert(new UITaskNode(task), i++);
138:
139:                //Schedule schedule;
140:
141:                /*
142:                Enumeration e = planElement.getDirectObjects();
143:                if (e != null) {
144:                  while (e.hasMoreElements()) {
145:                asset = (Asset)e.nextElement();
146:                if (asset != null)
147:                  if (asset instanceof AggregateAsset)
148:                    i = i + loadAssets((AggregateAsset)asset, i, "Direct Object: ");
149:                  else
150:                    insert(new UIAssetNode(asset, "Direct Object: "), i++);
151:                else
152:                  insert(new UIStringNode("null"), i++);
153:                  }
154:                }
155:                 */
156:                if (planElement instanceof  Allocation) {
157:                    Allocation allocation = (Allocation) planElement;
158:                    asset = (Asset) allocation.getAsset();
159:                    if (asset != null)
160:                        if (asset instanceof  AggregateAsset)
161:                            i = i
162:                                    + loadAssets((AggregateAsset) asset, i,
163:                                            "Allocated Asset: ");
164:                        else
165:                            insert(new UIAssetNode(asset, "Allocated Asset: "),
166:                                    i++);
167:                    //schedule = allocation.getEstimatedSchedule();
168:                    if (schedule != null)
169:                        insert(new UIScheduleElementNode(schedule,
170:                                "Estimated Schedule: "), i++);
171:                    allocationresult = planElement.getEstimatedResult();
172:                    if (allocationresult != null)
173:                        insert(new UIPenaltyValueNode(allocationresult,
174:                                "Estimated Result: "), i++);
175:                    //schedule = allocation.getReportedSchedule();
176:                    if (schedule != null)
177:                        insert(new UIScheduleElementNode(schedule,
178:                                "Reported Schedule: "), i++);
179:                    allocationresult = planElement.getReportedResult();
180:                    if (allocationresult != null)
181:                        insert(new UIPenaltyValueNode(allocationresult,
182:                                "Reported Result: "), i++);
183:                } else if (planElement instanceof  Expansion) {
184:                    // uncomment to display estimated schedule and penalty
185:                    //schedule = ((Expansion)planElement).getEstimatedSchedule();
186:                    //if (schedule != null)
187:                    //insert(new UIScheduleElementNode(schedule, "Estimated Schedule: "), i++);
188:
189:                    // jlv test - uncomment to show EPV
190:                    allocationresult = planElement.getEstimatedResult();
191:                    if (allocationresult != null)
192:                        insert(new UIPenaltyValueNode(allocationresult,
193:                                "Estimated Result: "), i++);
194:
195:                    Workflow workflow = ((Expansion) planElement).getWorkflow();
196:                    insert(new UIWorkflowNode(workflow), i++);
197:                } else if (planElement instanceof  AssetTransfer) {
198:                    asset = (Asset) ((AssetTransfer) planElement).getAsset();
199:                    if (asset != null)
200:                        if (asset instanceof  AggregateAsset)
201:                            i = i + loadAssets((AggregateAsset) asset, i, "");
202:                        else
203:                            insert(new UIAssetNode(asset, ""), i++);
204:                    MessageAddress assignor = ((AssetTransfer) planElement)
205:                            .getAssignor();
206:                    String assignorString = "Assigned By: ";
207:                    if (assignor != null)
208:                        assignorString = assignorString + assignor.getAddress();
209:                    insert(new UIStringNode(assignorString), i++);
210:                    Asset assignee = ((AssetTransfer) planElement)
211:                            .getAssignee();
212:                    String assigneeString = "Assigned To: ";
213:                    if (assignee != null)
214:                        if (assignee instanceof  AggregateAsset)
215:                            i = i
216:                                    + loadAssets((AggregateAsset) assignee, i,
217:                                            "");
218:                        else
219:                            insert(new UIAssetNode(assignee, ""), i++);
220:                    Schedule availSchedule = ((AssetTransfer) planElement)
221:                            .getSchedule();
222:                    if ((availSchedule != null) && (availSchedule.size() > 0)) {
223:                        Iterator iterator = availSchedule.iterator();
224:                        while (iterator.hasNext()) {
225:                            schedule = (ScheduleElement) iterator.next();
226:                            insert(new UIScheduleElementNode(schedule, ""), i++);
227:                        }
228:                    }
229:                    allocationresult = ((AssetTransfer) planElement)
230:                            .getEstimatedResult();
231:                    if (allocationresult != null)
232:                        insert(new UIPenaltyValueNode(allocationresult,
233:                                "Estimated Result: "), i++);
234:                }
235:            }
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.