Source Code Cross Referenced for SubjectConditionController.java in  » Workflow-Engines » osbl-1_0 » org » osbl » agent » gui » condition » 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 » Workflow Engines » osbl 1_0 » org.osbl.agent.gui.condition 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.osbl.agent.gui.condition;
002:
003:        import java.util.List;
004:
005:        import org.concern.ControllerLookup;
006:        import org.concern.Controller;
007:        import org.concern.model.Process;
008:        import org.osbl.agent.gui.ConditionController;
009:        import org.osbl.agent.gui.OperationController;
010:        import org.osbl.agent.model.Condition;
011:        import org.osbl.agent.model.condition.BinaryOperator;
012:        import org.osbl.agent.model.condition.Operator;
013:        import org.osbl.agent.model.condition.SubjectCondition;
014:        import org.osbl.client.wings.shell.Client;
015:        import org.wings.SComboBox;
016:        import org.wings.SComponent;
017:        import org.wings.SLabel;
018:        import org.wings.SListCellRenderer;
019:
020:        /**
021:         * The class SubjectConditionController models the SubjectCondition.
022:         * 
023:         * It presents the user with a combo-box with all available con:cern Conditions and the
024:         * possibility (also through a combo-box) to choose whether the choosen condition should
025:         * be met or not.
026:         * 
027:         * @author Sebastian Nozzi.
028:         */
029:        public class SubjectConditionController extends ConditionController {
030:
031:            /** The con:cern process. */
032:            private Process process;
033:
034:            /** The conditions combo. */
035:            private SComboBox conditionsCombo;
036:
037:            /** The operator combo. */
038:            private SComboBox operatorCombo;
039:
040:            /**
041:             * Instantiates a new SubjectConditionController.
042:             */
043:            public SubjectConditionController() {
044:                this (null);
045:            }
046:
047:            /**
048:             * Instantiates a new subject condition controller.
049:             * 
050:             * @param process the process
051:             */
052:            public SubjectConditionController(Process process) {
053:                this (process, null);
054:            }
055:
056:            /**
057:             * Instantiates a new subject condition controller.
058:             * 
059:             * @param process the con:cern process
060:             * @param condition the con:cern condition
061:             */
062:            public SubjectConditionController(Process process,
063:                    org.concern.model.Condition condition) {
064:
065:                // Create a combo-box for choosing the Operator
066:                operatorCombo = new SComboBox();
067:
068:                // There is not much that can happen to a condition...
069:                // ... either the condition is met...
070:                operatorCombo.addItem(new BinaryOperator(msg("operatorIs"),
071:                        "=="));
072:                // ... or it's not.
073:                operatorCombo.addItem(new BinaryOperator(msg("operatorIsNot"),
074:                        "!="));
075:
076:                // Here come all (concern)conditions of the Process
077:                conditionsCombo = new SComboBox();
078:
079:                this .process = process;
080:
081:                // Populate the combo-box with all conditions if the Process
082:                // is not null... (it can be null if this Controller was instantiated
083:                // when restoring an existing Rule, in which case setCondition will be
084:                // called later anyway).
085:                if (process != null) {
086:                    populateConditionsCombo(process, null);
087:                }
088:
089:            }
090:
091:            /**
092:             * Populate conditions combo.
093:             * 
094:             * @param process the process
095:             * @param selectedConditionName the selected condition
096:             */
097:            protected void populateConditionsCombo(Process process,
098:                    String selectedConditionName) {
099:
100:                // Iterate over all (concern) conditions in the Process...
101:                for (Object condObj : process.getConditions()) {
102:
103:                    // ... add each (concern) condition into the conditionsCombo...
104:                    conditionsCombo.addItem(condObj);
105:
106:                    // ... and if the condition matches the selectedCondition (which we
107:                    // get as a parameter) make it the selected item of the combo.
108:                    if (((org.concern.model.Condition) condObj).getName()
109:                            .equals(selectedConditionName)) {
110:                        conditionsCombo.setSelectedItem(condObj);
111:                    }
112:                }
113:
114:                final Process processForRenderer = process;
115:
116:                conditionsCombo.setRenderer(new SListCellRenderer() {
117:
118:                    SLabel label = new SLabel();
119:
120:                    public SComponent getListCellRendererComponent(
121:                            SComponent list, java.lang.Object value,
122:                            boolean isSelected, int index) {
123:
124:                        if (value != null && processForRenderer != null) {
125:
126:                            label
127:                                    .setText(Client
128:                                            .getInstance()
129:                                            .getResourceProvider()
130:                                            .getMessage(
131:                                                    "process."
132:                                                            + processForRenderer
133:                                                                    .getName()
134:                                                            + "."
135:                                                            + ((org.concern.model.Condition) value)
136:                                                                    .getName()));
137:                        } else {
138:                            label.setText("");
139:                        }
140:
141:                        return label;
142:                    }
143:
144:                });
145:
146:            }
147:
148:            /*
149:             * (non-Javadoc)
150:             * 
151:             * @see agent.controller.OperationController#canBeReplacedBy(agent.controller.OperationController)
152:             */
153:            public boolean canBeReplacedBy(
154:                    OperationController candidateController) {
155:
156:                // Since there is only one SubjectConditionController it's enough if the
157:                // classes match to be replaced.
158:                return (candidateController instanceof  SubjectConditionController);
159:            }
160:
161:            /*
162:             * (non-Javadoc)
163:             * 
164:             * @see agent.controller.OperationController#getComponents()
165:             */
166:            protected void populateComponentList(List<SComponent> componentList) {
167:
168:                // The operator-combo (see Operators defined by this class).
169:                componentList.add(operatorCombo);
170:                // All conditions of the Process
171:                componentList.add(conditionsCombo);
172:
173:            }
174:
175:            /*
176:             * (non-Javadoc)
177:             * 
178:             * @see org.osbl.agent.gui.condition.ConditionController#setCondition(org.osbl.agent.model.condition.Condition)
179:             */
180:            public void setCondition(Condition condition) {
181:
182:                // Update our operatorCombo to reflect the operator set in the
183:                // SubjectCondition
184:                if (((SubjectCondition) condition).getOperator().equals(
185:                        new BinaryOperator("=="))) {
186:                    operatorCombo.setSelectedIndex(0);
187:                } else
188:                    operatorCombo.setSelectedIndex(1);
189:
190:                String processName = ((SubjectCondition) condition)
191:                        .getProcessName();
192:
193:                Controller controller = ControllerLookup.getInstance()
194:                        .getController(processName);
195:                process = controller.getProcess();
196:
197:                // Remove all elements in the conditionsCombo, since...
198:                conditionsCombo.removeAllItems();
199:
200:                // ... we'll be populating the combo anyway.
201:                populateConditionsCombo(process, ((SubjectCondition) condition)
202:                        .getConcernConditionName());
203:            }
204:
205:            /*
206:             * (non-Javadoc)
207:             * 
208:             * @see java.lang.Object#toString()
209:             */
210:            public String toString() {
211:                // For our string version return the name of the Process
212:
213:                return Client.getInstance().getResourceProvider().getMessage(
214:                        "process." + process.getName());
215:            }
216:
217:            /*
218:             * (non-Javadoc)
219:             * 
220:             * @see org.osbl.agent.gui.ConditionController#populateCondition(org.osbl.agent.model.Condition)
221:             */
222:            protected void populateCondition(Condition condition) {
223:
224:                // In order to evaluate correctly, the SubjectCondition needs some
225:                // information...
226:
227:                // ... a Process (not really, see explanation below)
228:                ((SubjectCondition) condition)
229:                        .setProcessName(process.getName());
230:                // ... a org.concern.model.Condition (which is not the same as a
231:                // org.osbl.agent.model.Condition)
232:                ((SubjectCondition) condition)
233:                        .setConcernConditionName(((org.concern.model.Condition) conditionsCombo
234:                                .getSelectedItem()).getName());
235:                // ... and an Operator (which is one of those defined by this class, see
236:                // above)
237:                ((SubjectCondition) condition)
238:                        .setOperator((Operator) operatorCombo.getSelectedItem());
239:
240:                /*
241:                 * The Process is not really needed for the evaluation, but is needed
242:                 * for the inverse process: when a SubjectConditionController is
243:                 * instantiated from a SubjectCondition.
244:                 * 
245:                 * The information about the Process is needed in order to later
246:                 * retrieve the concernConditions and show them in the combo-box. This
247:                 * is necessary because a org.concern.model.Condition doesn't know about
248:                 * the Process it belongs to.
249:                 * 
250:                 */
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.