Source Code Cross Referenced for FailureConsumptionRateManager.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 java.awt.GridBagLayout;
029:        import java.awt.GridBagConstraints;
030:        import java.awt.event.ActionListener;
031:        import java.awt.event.ActionEvent;
032:        import java.io.IOException;
033:        import java.util.ArrayList;
034:        import java.util.Arrays;
035:        import java.util.Calendar;
036:        import java.util.Collection;
037:        import java.util.Date;
038:        import java.util.Enumeration;
039:        import java.util.GregorianCalendar;
040:        import java.util.Iterator;
041:        import java.util.List;
042:        import java.util.Properties;
043:        import java.util.SortedSet;
044:        import java.util.TreeSet;
045:        import javax.swing.JCheckBox;
046:        import javax.swing.JComponent;
047:        import javax.swing.JButton;
048:        import javax.swing.JPanel;
049:        import org.cougaar.glm.execution.common.*;
050:
051:        /**
052:         * Keeps track of the inventory report schedules and decide if/when to
053:         * generate a report.
054:         **/
055:        public class FailureConsumptionRateManager extends ManagerBase
056:                implements  ScheduleManager {
057:            private FailureConsumptionReportManager theFailureConsumptionReportManager;
058:
059:            public FailureConsumptionRateManager(
060:                    EventGenerator anEventGenerator,
061:                    FailureConsumptionReportManager aFailureConsumptionReportManager) {
062:                super (anEventGenerator);
063:                theFailureConsumptionReportManager = aFailureConsumptionReportManager;
064:            }
065:
066:            protected String getLogFileName(String prefix) {
067:                return prefix + "FCRates" + LOGFILE_SUFFIX;
068:            }
069:
070:            public String getGUITitle() {
071:                return "F/C Rates";
072:            }
073:
074:            public FilterGUI createFilterGUI(EventGenerator anEventGenerator) {
075:                return new FailureConsumptionRateFilterGUI(anEventGenerator);
076:            }
077:
078:            public Object[] getHandlers() {
079:                return new Object[] { new EGFailureConsumptionRateHandler(this ), };
080:            }
081:
082:            public void enqueueFailureConsumptionReport(String theSource,
083:                    FailureConsumptionReport aFailureConsumptionReport,
084:                    Object annotation) {
085:                theFailureConsumptionReportManager
086:                        .enqueueFailureConsumptionReport(theSource,
087:                                aFailureConsumptionReport, annotation);
088:            }
089:
090:            protected Class getPluginInterface() {
091:                return FailureConsumptionPlugin.class;
092:            }
093:
094:            protected Class getDefaultPluginClass() {
095:                return FailureConsumptionDefaultPlugin.class;
096:            }
097:
098:            public FailureConsumptionPluginItem getPluginItem(
099:                    FailureConsumptionRate theFailureConsumptionRate,
100:                    FailureConsumptionSegment theFailureConsumptionSegment,
101:                    FailureConsumptionPluginItem aFailureConsumptionPluginItem) {
102:                long theExecutionTime = theEventGenerator.getExecutionTime();
103:                for (Iterator i = getEnabledPlugins(); i.hasNext();) {
104:                    FailureConsumptionPlugin thePlugin = (FailureConsumptionPlugin) i
105:                            .next();
106:                    FailureConsumptionPluginItem item = thePlugin
107:                            .createFailureConsumptionItem(
108:                                    theFailureConsumptionRate,
109:                                    theFailureConsumptionSegment,
110:                                    theExecutionTime,
111:                                    aFailureConsumptionPluginItem);
112:                    if (item != null)
113:                        return item;
114:                }
115:                return null;
116:            }
117:
118:            public void firePluginChanged() {
119:                synchronized (schedule) {
120:                    for (Iterator i = schedule.iterator(); i.hasNext();) {
121:                        FailureConsumptionSegment fcs = (FailureConsumptionSegment) i
122:                                .next();
123:                        fcs.setPluginItem(getPluginItem(
124:                                fcs.theFailureConsumptionRate, fcs,
125:                                fcs.thePluginItem));
126:                    }
127:                }
128:            }
129:
130:            public void receiveFailureConsumptionRates(String source,
131:                    FailureConsumptionRate[] failureConsumptionRates) {
132:                long executionTime = theEventGenerator.getExecutionTime();
133:                for (int i = 0; i < failureConsumptionRates.length; i++) {
134:                    FailureConsumptionRate fcr = failureConsumptionRates[i];
135:                    //        System.out.println("Receive : " + fcr.theRateValue + fcr.theRateUnits);
136:
137:                    FailureConsumptionSegment fcs = (FailureConsumptionSegment) map
138:                            .get(FailureConsumptionSegment.getKey(fcr));
139:                    if (fcs != null) {
140:                        removeFromSchedule(fcs);
141:                    }
142:                    if (!fcr.isRescind()) {
143:                        fcr.theStartTime = Math.max(executionTime,
144:                                fcr.theStartTime);
145:                        if (fcr.theStartTime < fcr.theEndTime) {
146:                            fcs = new FailureConsumptionSegment(source, fcr,
147:                                    this );
148:                            addToSchedule(fcs);
149:                        }
150:                    }
151:                }
152:                finishScheduleUpdate();
153:            }
154:
155:            protected ManagerTableModel createTableModel() {
156:                return new FailureConsumptionRateTableModel();
157:            }
158:
159:            private static final int ENABLE_COLUMN = 0;
160:            private static final int CLUSTER_COLUMN = 1;
161:            private static final int START_TIME_COLUMN = 2;
162:            private static final int END_TIME_COLUMN = 3;
163:            private static final int ITEM_COLUMN = 4;
164:            private static final int CONSUMER_COLUMN = 5;
165:            private static final int CONSUMER_ID_COLUMN = 6;
166:            private static final int RATE_COLUMN = 7;
167:            private static final int RATE_MULT_COLUMN = 8;
168:            private static final int UNITS_COLUMN = 9;
169:            private static final int ANNOTATION_COLUMN = 10;
170:            private static final int NCOLUMNS = 11;
171:            private static final int UNITS_WIDTH = EGTableModelBase
172:                    .getCellWidth("gallons / minute");
173:
174:            private class FailureConsumptionRateTableModel extends
175:                    ManagerTableModel {
176:
177:                public FailureConsumptionRateTableModel() {
178:                    logColumns = new int[] { CLUSTER_COLUMN, START_TIME_COLUMN,
179:                            END_TIME_COLUMN, ITEM_COLUMN, CONSUMER_COLUMN,
180:                            CONSUMER_ID_COLUMN, RATE_COLUMN, RATE_MULT_COLUMN,
181:                            UNITS_COLUMN, ANNOTATION_COLUMN };
182:                }
183:
184:                public int getColumnCount() {
185:                    return NCOLUMNS;
186:                }
187:
188:                public int getPreferredColumnWidth(int col) {
189:                    switch (col) {
190:                    case ENABLE_COLUMN:
191:                        return SEND_WIDTH;
192:                    case CLUSTER_COLUMN:
193:                        return CLUSTER_WIDTH;
194:                    case START_TIME_COLUMN:
195:                        return DATE_WIDTH;
196:                    case END_TIME_COLUMN:
197:                        return DATE_WIDTH;
198:                    case CONSUMER_COLUMN:
199:                        return CONSUMER_WIDTH;
200:                    case CONSUMER_ID_COLUMN:
201:                        return ITEM_WIDTH;
202:                    case ITEM_COLUMN:
203:                        return ITEM_WIDTH;
204:                    case RATE_COLUMN:
205:                        return QUANTITY_WIDTH;
206:                    case RATE_MULT_COLUMN:
207:                        return QUANTITY_WIDTH;
208:                    case UNITS_COLUMN:
209:                        return UNITS_WIDTH;
210:                    case ANNOTATION_COLUMN:
211:                        return ANNOTATION_WIDTH;
212:                    }
213:                    return 75;
214:                }
215:
216:                public int getMinColumnWidth(int col) {
217:                    switch (col) {
218:                    case ENABLE_COLUMN:
219:                        return SEND_WIDTH;
220:                    case CLUSTER_COLUMN:
221:                        return CLUSTER_WIDTH / 2;
222:                    case START_TIME_COLUMN:
223:                        return DATE_WIDTH / 2;
224:                    case END_TIME_COLUMN:
225:                        return DATE_WIDTH / 2;
226:                    case CONSUMER_COLUMN:
227:                        return CONSUMER_WIDTH / 2;
228:                    case CONSUMER_ID_COLUMN:
229:                        return ITEM_WIDTH / 2;
230:                    case ITEM_COLUMN:
231:                        return ITEM_WIDTH / 2;
232:                    case RATE_COLUMN:
233:                        return QUANTITY_WIDTH / 2;
234:                    case RATE_MULT_COLUMN:
235:                        return QUANTITY_WIDTH / 2;
236:                    case UNITS_COLUMN:
237:                        return UNITS_WIDTH / 2;
238:                    case ANNOTATION_COLUMN:
239:                        return ANNOTATION_WIDTH / 2;
240:                    }
241:                    return 75;
242:                }
243:
244:                public int getMaxColumnWidth(int col) {
245:                    switch (col) {
246:                    case ENABLE_COLUMN:
247:                        return SEND_WIDTH;
248:                    case CLUSTER_COLUMN:
249:                        return CLUSTER_WIDTH;
250:                    case START_TIME_COLUMN:
251:                        return DATE_WIDTH;
252:                    case END_TIME_COLUMN:
253:                        return DATE_WIDTH;
254:                    case CONSUMER_COLUMN:
255:                        return Integer.MAX_VALUE;
256:                    case CONSUMER_ID_COLUMN:
257:                        return Integer.MAX_VALUE;
258:                    case ITEM_COLUMN:
259:                        return Integer.MAX_VALUE;
260:                    case RATE_COLUMN:
261:                        return Integer.MAX_VALUE;
262:                    case RATE_MULT_COLUMN:
263:                        return Integer.MAX_VALUE;
264:                    case UNITS_COLUMN:
265:                        return Integer.MAX_VALUE;
266:                    case ANNOTATION_COLUMN:
267:                        return Integer.MAX_VALUE;
268:                    }
269:                    return 75;
270:                }
271:
272:                public String getColumnName(int col) {
273:                    switch (col) {
274:                    case ENABLE_COLUMN:
275:                        return "Send";
276:                    case CLUSTER_COLUMN:
277:                        return "Cluster";
278:                    case START_TIME_COLUMN:
279:                        return "Start Time";
280:                    case END_TIME_COLUMN:
281:                        return "End Time";
282:                    case CONSUMER_COLUMN:
283:                        return "Consumer";
284:                    case CONSUMER_ID_COLUMN:
285:                        return "Consumer Id";
286:                    case ITEM_COLUMN:
287:                        return "Item";
288:                    case RATE_COLUMN:
289:                        return "Rate";
290:                    case RATE_MULT_COLUMN:
291:                        return "Rate Multiplier";
292:                    case UNITS_COLUMN:
293:                        return "Units";
294:                    case ANNOTATION_COLUMN:
295:                        return "Comment";
296:                    }
297:                    return null;
298:                }
299:
300:                public Class getColumnClass(int col) {
301:                    switch (col) {
302:                    case ENABLE_COLUMN:
303:                        return Boolean.class;
304:                    case CLUSTER_COLUMN:
305:                        return String.class;
306:                    case START_TIME_COLUMN:
307:                        return EGDate.class;
308:                    case END_TIME_COLUMN:
309:                        return EGDate.class;
310:                    case CONSUMER_COLUMN:
311:                        return String.class;
312:                    case CONSUMER_ID_COLUMN:
313:                        return String.class;
314:                    case ITEM_COLUMN:
315:                        return String.class;
316:                    case RATE_COLUMN:
317:                        return Double.class;
318:                    case RATE_MULT_COLUMN:
319:                        return Double.class;
320:                    case UNITS_COLUMN:
321:                        return String.class;
322:                    case ANNOTATION_COLUMN:
323:                        return Object.class;
324:                    }
325:                    return null;
326:                }
327:
328:                public boolean isCellEditable(int row, int col) {
329:                    theEventGenerator.setPaused(true);
330:                    switch (col) {
331:                    case ENABLE_COLUMN:
332:                        return true;
333:                    case CLUSTER_COLUMN:
334:                        return false;
335:                    case START_TIME_COLUMN:
336:                        return false;
337:                    case CONSUMER_COLUMN:
338:                        return false;
339:                    case CONSUMER_ID_COLUMN:
340:                        return false;
341:                    case ITEM_COLUMN:
342:                        return false;
343:                    case RATE_COLUMN:
344:                        return true;
345:                    case RATE_MULT_COLUMN:
346:                        return false; // Erika - should this be "true"?
347:                    case UNITS_COLUMN:
348:                        return false;
349:                    case ANNOTATION_COLUMN:
350:                        return false;
351:                    }
352:                    return false;
353:                }
354:
355:                public boolean cellHasBeenEdited(int row, int col) {
356:                    FailureConsumptionSegment fcs = (FailureConsumptionSegment) getRowObject(row);
357:                    if (fcs == null)
358:                        return false;
359:                    if (fcs.theOriginalFailureConsumptionRate == null)
360:                        return false;
361:                    switch (col) {
362:                    case ENABLE_COLUMN:
363:                        return false;
364:                    case START_TIME_COLUMN:
365:                        return false;
366:                    case END_TIME_COLUMN:
367:                        return false;
368:                    case CONSUMER_COLUMN:
369:                        return false;
370:                    case CONSUMER_ID_COLUMN:
371:                        return false;
372:                    case ITEM_COLUMN:
373:                        return false;
374:                    case RATE_COLUMN:
375:                        return (fcs.theFailureConsumptionRate.theRateValue != fcs.theOriginalFailureConsumptionRate.theRateValue);
376:                    case RATE_MULT_COLUMN:
377:                        return false; // Erika: should this be "true"?
378:                    }
379:                    return false;
380:                }
381:
382:                public void setValueAt(Object newValue, int row, int col) {
383:                    FailureConsumptionSegment fcs = (FailureConsumptionSegment) getRowObject(row);
384:                    if (fcs == null)
385:                        return;
386:                    switch (col) {
387:                    case ENABLE_COLUMN:
388:                        fcs.setEnabled(((Boolean) newValue).booleanValue());
389:                        break;
390:                    case START_TIME_COLUMN:
391:                        break;
392:                    case END_TIME_COLUMN:
393:                        break;
394:                    case CONSUMER_COLUMN:
395:                        break;
396:                    case CONSUMER_ID_COLUMN:
397:                        break;
398:                    case ITEM_COLUMN:
399:                        break;
400:                    case RATE_COLUMN:
401:                        assureEditCopy(fcs);
402:                        try {
403:                            fcs.theFailureConsumptionRate.theRateValue = Double
404:                                    .parseDouble(((String) newValue));
405:                        } catch (NumberFormatException nfe) {
406:                            postErrorMessage("Value must be numeric");
407:                        }
408:                        break;
409:                    case RATE_MULT_COLUMN:
410:                        break; // Erika: should this be "true"?
411:                    }
412:                }
413:
414:                private void assureEditCopy(FailureConsumptionSegment fcs) {
415:                    if (fcs.theOriginalFailureConsumptionRate == null) {
416:                        fcs.theOriginalFailureConsumptionRate = new FailureConsumptionRate(
417:                                fcs.theFailureConsumptionRate);
418:                    }
419:                }
420:
421:                public Object getValue(int col, Object rowObject) {
422:                    FailureConsumptionSegment fcs = (FailureConsumptionSegment) rowObject;
423:                    if (fcs == null)
424:                        return null;
425:                    switch (col) {
426:                    case ENABLE_COLUMN:
427:                        return new Boolean(fcs.isEnabled());
428:                    case CLUSTER_COLUMN:
429:                        return fcs.theSource;
430:                    case START_TIME_COLUMN:
431:                        return new EGDate(
432:                                fcs.theFailureConsumptionRate.theStartTime);
433:                    case END_TIME_COLUMN:
434:                        return new EGDate(
435:                                fcs.theFailureConsumptionRate.theEndTime);
436:                    case CONSUMER_COLUMN:
437:                        return fcs.theFailureConsumptionRate.theConsumer;
438:                    case CONSUMER_ID_COLUMN:
439:                        return fcs.theFailureConsumptionRate.theConsumerId;
440:                    case ITEM_COLUMN:
441:                        return fcs.theFailureConsumptionRate.theItemIdentification;
442:                    case RATE_COLUMN: {
443:                        int units = fcs.getUnits();
444:                        return new Double(
445:                                fcs.theFailureConsumptionRate.theRateValue);
446:                    }
447:                    case RATE_MULT_COLUMN: {
448:                        int units = fcs.getUnits();
449:                        return new Double(
450:                                fcs.theFailureConsumptionRate.theRateMultiplier);
451:                    }
452:                    case UNITS_COLUMN:
453:                        return fcs.theFailureConsumptionRate.theRateUnits;
454:                    case ANNOTATION_COLUMN:
455:                        return fcs.getAnnotation();
456:                    }
457:                    return null;
458:                }
459:            }
460:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.