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


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2000-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.tools.csmart.ui.experiment;
028:
029:        import org.cougaar.tools.csmart.core.db.CMT;
030:        import org.cougaar.tools.csmart.core.db.DBUtils;
031:        import org.cougaar.tools.csmart.core.db.ExperimentDB;
032:        import org.cougaar.tools.csmart.experiment.DBExperiment;
033:        import org.cougaar.tools.csmart.experiment.Experiment;
034:
035:        import javax.swing.*;
036:        import java.awt.*;
037:        import java.util.ArrayList;
038:        import java.util.Map;
039:        import java.util.Set;
040:
041:        public class ThreadBuilder extends JPanel {
042:            // thread names displayed for user
043:            private static final String[] ULThreads = {
044:                    "Subsistence (Class 1)", "Fuel (Class 3)",
045:                    "Construction Material (Class 4)", "Ammunition (Class 5)",
046:                    "Spare Parts (Class 9)" };
047:            // thread names passed to database will be CMT.ULDBThreads
048:            private String[] groupNames;
049:            private ArrayList groupCheckBoxes = new ArrayList();
050:            private ArrayList ULThreadCheckBoxes = new ArrayList();
051:            private ArrayList multiplierFields = new ArrayList();
052:            private ArrayList originalThreadSelected = new ArrayList();
053:            private ArrayList originalGroupSelected = new ArrayList();
054:            private ArrayList originalGroupMultiplier = new ArrayList();
055:            private Experiment experiment;
056:            private boolean needUpdate = true; // need to update display
057:
058:            public ThreadBuilder(Experiment experiment) {
059:                this .experiment = experiment;
060:                updateDisplay();
061:                needUpdate = false;
062:            }
063:
064:            /**
065:             * Called when this panel is first displayed after having been
066:             * created or re-initialized to display a new experiment.
067:             * Initially, this panel is used only for viewing, so all the controls
068:             * are disabled; eventually this can be used for configuring the experiment.
069:             */
070:
071:            private void updateDisplay() {
072:                removeAll(); // remove previous components
073:                if (experiment == null
074:                        || !DBUtils.dbMode
075:                        || !ExperimentDB.isExperimentNameInDatabase(experiment
076:                                .getExperimentName())) {
077:                    setLayout(new BorderLayout());
078:                    add(
079:                            new JLabel(
080:                                    "Experiment is not in database or otherwise has no thread information available.",
081:                                    SwingConstants.CENTER), BorderLayout.CENTER);
082:                    return;
083:                }
084:                String experimentId = experiment.getExperimentID();
085:                String trialId = experiment.getTrialID();
086:                setLayout(new GridBagLayout());
087:                int x = 0;
088:                int y = 0;
089:                int leftIndent = 0;
090:                add(new JLabel("Threads:"), new GridBagConstraints(x, y++, 1,
091:                        1, 0.0, 0.0, GridBagConstraints.WEST,
092:                        GridBagConstraints.NONE,
093:                        new Insets(0, leftIndent, 5, 0), 0, 0));
094:                leftIndent = leftIndent + 5;
095:                for (int i = 0; i < ULThreads.length; i++) {
096:                    JCheckBox cb = new JCheckBox(ULThreads[i]);
097:                    boolean sel = ExperimentDB.isULThreadSelected(trialId,
098:                            CMT.ULDBThreads[i]);
099:                    ULThreadCheckBoxes.add(cb);
100:                    cb.setSelected(sel);
101:                    originalThreadSelected.add(new Boolean(sel));
102:                    cb.setEnabled(false);
103:                    add(cb, new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,
104:                            GridBagConstraints.WEST, GridBagConstraints.NONE,
105:                            new Insets(0, leftIndent, 5, 0), 0, 0));
106:                }
107:
108:                ////////////////////////////
109:                // Now the OrgGroups
110:
111:                Map groupNameToId = ExperimentDB
112:                        .getOrganizationGroups(experimentId);
113:                Set groups = groupNameToId.keySet();
114:                groupNames = (String[]) groups
115:                        .toArray(new String[groups.size()]);
116:                int nGroupNames = groupNames.length;
117:
118:                // Show the groups stuff only if we have some
119:                if (nGroupNames > 0) {
120:                    leftIndent = leftIndent - 5;
121:                    add(new JLabel("Organization Groups:"),
122:                            new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,
123:                                    GridBagConstraints.WEST,
124:                                    GridBagConstraints.NONE, new Insets(0,
125:                                            leftIndent, 0, 0), 0, 0));
126:                    leftIndent = leftIndent + 5;
127:                    for (int i = 0; i < nGroupNames; i++) {
128:                        String groupName = (String) groupNames[i];
129:                        JCheckBox groupCB = new JCheckBox(groupName);
130:                        boolean sel = ExperimentDB.isGroupSelected(trialId,
131:                                groupName);
132:                        groupCheckBoxes.add(groupCB);
133:                        originalGroupSelected.add(new Boolean(sel));
134:                        groupCB.setSelected(sel);
135:                        groupCB.setEnabled(false);
136:                        add(groupCB, new GridBagConstraints(x++, y, 1, 1, 0.0,
137:                                0.0, GridBagConstraints.WEST,
138:                                GridBagConstraints.NONE, new Insets(0,
139:                                        leftIndent, 5, 0), 0, 0));
140:                        add(new JLabel("Number of Copies:"),
141:                                new GridBagConstraints(x++, y, 1, 1, 0.0, 0.0,
142:                                        GridBagConstraints.WEST,
143:                                        GridBagConstraints.NONE, new Insets(0,
144:                                                0, 5, 5), 0, 0));
145:                        JTextField multiplierField = new JTextField(4);
146:                        multiplierFields.add(multiplierField);
147:                        int multiplier = ExperimentDB.getMultiplier(trialId,
148:                                groupName);
149:                        multiplierField.setText(String.valueOf(multiplier));
150:                        multiplierField.setEnabled(false);
151:                        originalGroupMultiplier.add(new Integer(multiplier));
152:                        add(multiplierField, new GridBagConstraints(x++, y, 1,
153:                                1, 0.0, 0.0, GridBagConstraints.WEST,
154:                                GridBagConstraints.NONE,
155:                                new Insets(0, 0, 5, 5), 0, 0));
156:                        add(new JLabel("Members:"), new GridBagConstraints(x++,
157:                                y, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
158:                                GridBagConstraints.NONE,
159:                                new Insets(0, 0, 5, 5), 0, 0));
160:                        Set members = ExperimentDB.getOrganizationsInGroup(
161:                                experimentId, (String) groupNameToId
162:                                        .get(groupName));
163:                        JList membersList = new JList(members.toArray());
164:                        membersList.setVisibleRowCount(4);
165:                        membersList.setEnabled(false);
166:                        add(new JScrollPane(membersList),
167:                                new GridBagConstraints(x++, y++, 1, 1, 0.0,
168:                                        0.0, GridBagConstraints.WEST,
169:                                        GridBagConstraints.NONE, new Insets(0,
170:                                                0, 5, 5), 0, 0));
171:                    } // loop over group names
172:                } // end of block to show groups if have some
173:            }
174:
175:            /**
176:             * Set experiment to display.  Display is actually updated
177:             * when this panel is made visible.
178:             * TODO: why does this have to reset the editable and runnable
179:             * flags -- this is done by the caller (ExperimentBuilder)
180:             */
181:
182:            public void reinit(Experiment newExperiment) {
183:                if (this .experiment != null
184:                        && this .experiment.equals(newExperiment))
185:                    return; // no change
186:                experiment = newExperiment;
187:                if (isShowing())
188:                    updateDisplay();
189:                else
190:                    needUpdate = true;
191:            }
192:
193:            /**
194:             * Ensure that display is up-to-date before showing it.
195:             */
196:
197:            public void setVisible(boolean visible) {
198:                if (visible && needUpdate)
199:                    updateDisplay();
200:                super.setVisible(visible);
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.