Source Code Cross Referenced for FailureConsumptionReportManager.java in  » Science » Cougaar12_4 » org » cougaar » glm » execution » eg » 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.glm.execution.eg 
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:        package org.cougaar.glm.execution.eg;
027:
028:        import org.cougaar.planning.ldm.measure.Rate;
029:        import java.awt.GridBagLayout;
030:        import java.awt.GridBagConstraints;
031:        import java.awt.event.ActionListener;
032:        import java.awt.event.ActionEvent;
033:        import java.io.IOException;
034:        import java.util.ArrayList;
035:        import java.util.Arrays;
036:        import java.util.Calendar;
037:        import java.util.Collection;
038:        import java.util.Date;
039:        import java.util.Enumeration;
040:        import java.util.GregorianCalendar;
041:        import java.util.Iterator;
042:        import java.util.List;
043:        import java.util.Properties;
044:        import java.util.SortedSet;
045:        import java.util.TreeSet;
046:        import javax.swing.JCheckBox;
047:        import javax.swing.JComponent;
048:        import javax.swing.JButton;
049:        import javax.swing.JPanel;
050:        import org.cougaar.glm.execution.common.*;
051:
052:        /**
053:         * Keeps track of the inventory report schedules and decide if/when to
054:         * generate a report.
055:         **/
056:        public class FailureConsumptionReportManager extends ManagerBase
057:                implements  ScheduleManager {
058:
059:            public FailureConsumptionReportManager(
060:                    EventGenerator anEventGenerator) {
061:                super (anEventGenerator);
062:            }
063:
064:            protected String getLogFileName(String prefix) {
065:                return prefix + "FCEvents" + LOGFILE_SUFFIX;
066:            }
067:
068:            public String getGUITitle() {
069:                return "F/C Reports";
070:            }
071:
072:            public FilterGUI createFilterGUI(EventGenerator anEventGenerator) {
073:                return new FailureConsumptionReportFilterGUI(anEventGenerator);
074:            }
075:
076:            public Object[] getHandlers() {
077:                return new Object[0];
078:            }
079:
080:            public void enqueueFailureConsumptionReport(String theSource,
081:                    FailureConsumptionReport aFailureConsumptionReport,
082:                    Object annotation) {
083:                TimedFailureConsumptionReport tfcr = new TimedFailureConsumptionReport(
084:                        theSource, aFailureConsumptionReport, this , annotation);
085:                addToSchedule(tfcr);
086:                finishScheduleUpdate();
087:            }
088:
089:            public void sendFailureConsumptionReport(String source,
090:                    FailureConsumptionReport aFailureConsumptionReport)
091:                    throws IOException {
092:                Object[] handlers = {}; // There is no response
093:                EventMonitorListener l = theEventGenerator
094:                        .createEventMonitorListener(source, handlers,
095:                                aFailureConsumptionReport);
096:                if (l != null) {
097:                    theEventGenerator.addListener(l);
098:                    theEventGenerator.startListener(l);
099:                }
100:            }
101:
102:            protected ManagerTableModel createTableModel() {
103:                return new FailureConsumptionReportTableModel();
104:            }
105:
106:            private static final int ENABLE_COLUMN = 0;
107:            private static final int CLUSTER_COLUMN = 1;
108:            private static final int RECEIVE_TIME_COLUMN = 2;
109:            private static final int REPORT_TIME_COLUMN = 3;
110:            private static final int CONSUMER_COLUMN = 4;
111:            private static final int ITEM_COLUMN = 5;
112:            private static final int QUANTITY_COLUMN = 6;
113:            private static final int ANNOTATION_COLUMN = 7;
114:            private static final int NCOLUMNS = 8;
115:
116:            private class FailureConsumptionReportTableModel extends
117:                    ManagerTableModel {
118:
119:                public FailureConsumptionReportTableModel() {
120:                    logColumns = new int[] { CLUSTER_COLUMN,
121:                            RECEIVE_TIME_COLUMN, REPORT_TIME_COLUMN,
122:                            CONSUMER_COLUMN, ITEM_COLUMN, QUANTITY_COLUMN,
123:                            ANNOTATION_COLUMN };
124:                }
125:
126:                public int getColumnCount() {
127:                    return NCOLUMNS;
128:                }
129:
130:                public int getPreferredColumnWidth(int col) {
131:                    switch (col) {
132:                    case ENABLE_COLUMN:
133:                        return SEND_WIDTH;
134:                    case CLUSTER_COLUMN:
135:                        return CLUSTER_WIDTH;
136:                    case RECEIVE_TIME_COLUMN:
137:                        return DATE_WIDTH;
138:                    case REPORT_TIME_COLUMN:
139:                        return DATE_WIDTH;
140:                    case CONSUMER_COLUMN:
141:                        return CONSUMER_WIDTH;
142:                    case ITEM_COLUMN:
143:                        return ITEM_WIDTH;
144:                    case QUANTITY_COLUMN:
145:                        return QUANTITY_WIDTH;
146:                    case ANNOTATION_COLUMN:
147:                        return ANNOTATION_WIDTH;
148:                    }
149:                    return 75;
150:                }
151:
152:                public int getMinColumnWidth(int col) {
153:                    switch (col) {
154:                    case ENABLE_COLUMN:
155:                        return SEND_WIDTH;
156:                    case CLUSTER_COLUMN:
157:                        return CLUSTER_WIDTH / 2;
158:                    case RECEIVE_TIME_COLUMN:
159:                        return DATE_WIDTH / 2;
160:                    case REPORT_TIME_COLUMN:
161:                        return DATE_WIDTH / 2;
162:                    case CONSUMER_COLUMN:
163:                        return CONSUMER_WIDTH / 2;
164:                    case ITEM_COLUMN:
165:                        return ITEM_WIDTH / 2;
166:                    case QUANTITY_COLUMN:
167:                        return QUANTITY_WIDTH / 2;
168:                    case ANNOTATION_COLUMN:
169:                        return ANNOTATION_WIDTH / 2;
170:                    }
171:                    return 75;
172:                }
173:
174:                public int getMaxColumnWidth(int col) {
175:                    switch (col) {
176:                    case ENABLE_COLUMN:
177:                        return SEND_WIDTH;
178:                    case CLUSTER_COLUMN:
179:                        return CLUSTER_WIDTH;
180:                    case RECEIVE_TIME_COLUMN:
181:                        return DATE_WIDTH;
182:                    case REPORT_TIME_COLUMN:
183:                        return DATE_WIDTH;
184:                    case CONSUMER_COLUMN:
185:                        return Integer.MAX_VALUE;
186:                    case ITEM_COLUMN:
187:                        return Integer.MAX_VALUE;
188:                    case QUANTITY_COLUMN:
189:                        return Integer.MAX_VALUE;
190:                    case ANNOTATION_COLUMN:
191:                        return Integer.MAX_VALUE;
192:                    }
193:                    return 75;
194:                }
195:
196:                public String getColumnName(int col) {
197:                    switch (col) {
198:                    case ENABLE_COLUMN:
199:                        return "Send";
200:                    case CLUSTER_COLUMN:
201:                        return "Cluster";
202:                    case RECEIVE_TIME_COLUMN:
203:                        return "Receive Time";
204:                    case REPORT_TIME_COLUMN:
205:                        return "Report Time";
206:                    case CONSUMER_COLUMN:
207:                        return "Consumer";
208:                    case ITEM_COLUMN:
209:                        return "Item";
210:                    case QUANTITY_COLUMN:
211:                        return "Quantity";
212:                    case ANNOTATION_COLUMN:
213:                        return "Comment";
214:                    }
215:                    return null;
216:                }
217:
218:                public Class getColumnClass(int col) {
219:                    switch (col) {
220:                    case ENABLE_COLUMN:
221:                        return Boolean.class;
222:                    case CLUSTER_COLUMN:
223:                        return String.class;
224:                    case RECEIVE_TIME_COLUMN:
225:                        return EGDate.class;
226:                    case REPORT_TIME_COLUMN:
227:                        return EGDate.class;
228:                    case CONSUMER_COLUMN:
229:                        return String.class;
230:                    case ITEM_COLUMN:
231:                        return String.class;
232:                    case QUANTITY_COLUMN:
233:                        return Double.class;
234:                    case ANNOTATION_COLUMN:
235:                        return Object.class;
236:                    }
237:                    return null;
238:                }
239:
240:                public boolean isCellEditable(int row, int col) {
241:                    theEventGenerator.setPaused(true);
242:                    switch (col) {
243:                    case ENABLE_COLUMN:
244:                        return true;
245:                    case CLUSTER_COLUMN:
246:                        return false;
247:                    case RECEIVE_TIME_COLUMN:
248:                        return true;
249:                    case CONSUMER_COLUMN:
250:                        return false;
251:                    case ITEM_COLUMN:
252:                        return false;
253:                    case QUANTITY_COLUMN:
254:                        return true;
255:                    }
256:                    return false;
257:                }
258:
259:                public boolean cellHasBeenEdited(int row, int col) {
260:                    TimedFailureConsumptionReport tfcr = (TimedFailureConsumptionReport) getRowObject(row);
261:                    if (tfcr == null)
262:                        return false;
263:                    if (tfcr.theOriginalFailureConsumptionReport == null)
264:                        return false;
265:                    switch (col) {
266:                    case ENABLE_COLUMN:
267:                        return false;
268:                    case RECEIVE_TIME_COLUMN:
269:                        return (tfcr.theFailureConsumptionReport.theReceivedDate != tfcr.theOriginalFailureConsumptionReport.theReceivedDate);
270:                    case REPORT_TIME_COLUMN:
271:                        return (tfcr.theFailureConsumptionReport.theReportDate != tfcr.theOriginalFailureConsumptionReport.theReportDate);
272:                    case CONSUMER_COLUMN:
273:                    case ITEM_COLUMN:
274:                        return false;
275:                    case QUANTITY_COLUMN:
276:                        return (tfcr.theFailureConsumptionReport.theQuantity != tfcr.theOriginalFailureConsumptionReport.theQuantity);
277:                    }
278:                    return false;
279:                }
280:
281:                public void setValueAt(Object newValue, int row, int col) {
282:                    TimedFailureConsumptionReport tfcr = (TimedFailureConsumptionReport) getRowObject(row);
283:                    if (tfcr == null)
284:                        return;
285:                    String stringValue = null;
286:                    if (newValue instanceof  String)
287:                        stringValue = (String) newValue;
288:                    switch (col) {
289:                    case ENABLE_COLUMN:
290:                        tfcr.setEnabled(((Boolean) newValue).booleanValue());
291:                        break;
292:                    case RECEIVE_TIME_COLUMN:
293:                        assureEditCopy(tfcr);
294:                        removeFromSchedule(tfcr);
295:                        if (stringValue.equals("")) {
296:                            tfcr.theFailureConsumptionReport.theReceivedDate = tfcr.theOriginalFailureConsumptionReport.theReceivedDate;
297:                        } else {
298:                            tfcr.theFailureConsumptionReport.theReceivedDate = new Date(
299:                                    (String) newValue).getTime();
300:                        }
301:                        addToSchedule(tfcr);
302:                        finishScheduleUpdate();
303:                        break;
304:                    case REPORT_TIME_COLUMN:
305:                        assureEditCopy(tfcr);
306:                        tfcr.theFailureConsumptionReport.theReportDate = new Date(
307:                                (String) newValue).getTime();
308:                        break;
309:                    case CONSUMER_COLUMN:
310:                    case ITEM_COLUMN:
311:                        break;
312:                    case QUANTITY_COLUMN:
313:                        assureEditCopy(tfcr);
314:                        try {
315:                            if (stringValue.equals("")) {
316:                                tfcr.theFailureConsumptionReport.theQuantity = tfcr.theOriginalFailureConsumptionReport.theQuantity;
317:                            } else {
318:                                tfcr.theFailureConsumptionReport.theQuantity = Double
319:                                        .parseDouble(((String) newValue));
320:                            }
321:                        } catch (NumberFormatException nfe) {
322:                            postErrorMessage("Value must be numeric");
323:                        }
324:                        break;
325:                    }
326:                }
327:
328:                private void assureEditCopy(TimedFailureConsumptionReport tfcr) {
329:                    if (tfcr.theOriginalFailureConsumptionReport == null) {
330:                        tfcr.theOriginalFailureConsumptionReport = new FailureConsumptionReport(
331:                                tfcr.theFailureConsumptionReport);
332:                    }
333:                }
334:
335:                public Object getValue(int col, Object rowObject) {
336:                    TimedFailureConsumptionReport tfcr = (TimedFailureConsumptionReport) rowObject;
337:                    if (tfcr == null)
338:                        return null;
339:                    switch (col) {
340:                    case ENABLE_COLUMN:
341:                        return new Boolean(tfcr.isEnabled());
342:                    case CLUSTER_COLUMN:
343:                        return tfcr.theSource;
344:                    case RECEIVE_TIME_COLUMN:
345:                        return new EGDate(
346:                                tfcr.theFailureConsumptionReport.theReceivedDate);
347:                    case REPORT_TIME_COLUMN:
348:                        return new EGDate(
349:                                tfcr.theFailureConsumptionReport.theReportDate);
350:                    case CONSUMER_COLUMN:
351:                        return tfcr.theFailureConsumptionReport.theConsumer;
352:                    case ITEM_COLUMN:
353:                        return tfcr.theFailureConsumptionReport.theItemIdentification;
354:                    case QUANTITY_COLUMN:
355:                        return new Double(
356:                                tfcr.theFailureConsumptionReport.theQuantity);
357:                    case ANNOTATION_COLUMN:
358:                        return tfcr.getAnnotation();
359:                    }
360:                    return null;
361:                }
362:            }
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.