Source Code Cross Referenced for PropertyConditionController.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.ArrayList;
004:        import java.util.List;
005:
006:        import org.conform.BeanMeta;
007:        import org.conform.PropertyMeta;
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.action.SetCurrentTimeAction;
012:        import org.osbl.agent.model.condition.BinaryOperator;
013:        import org.osbl.agent.model.condition.Operator;
014:        import org.osbl.agent.model.condition.PropertyCondition;
015:        import org.osbl.client.wings.shell.Client;
016:        import org.wings.SComboBox;
017:        import org.wings.SComponent;
018:
019:        /**
020:         * The class PropertyConditionController models the PropertyCondition.
021:         * 
022:         * It serves as a superclass for ConditionControllers that want to offer the comparison
023:         * of a property against a value.
024:         * 
025:         * It presents the user with an operator combo-box. Anything beyond that element is 
026:         * provided by the subclasses. Subclasses can also choose not to include the operator
027:         * combo at all (as in {@link SetCurrentTimeAction}), although this is rare.
028:         * 
029:         * @author Sebastian Nozzi.
030:         */
031:        public abstract class PropertyConditionController extends
032:                ConditionController {
033:
034:            /** The operator combo. */
035:            private SComboBox operatorCombo;
036:
037:            /** The property meta. */
038:            protected PropertyMeta propertyMeta;
039:
040:            /**
041:             * Instantiates a new PropertyConditionController.
042:             */
043:            public PropertyConditionController() {
044:
045:                // Combo for the Operators that apply to the selected property
046:                // and the value entered by the user in the inputField.
047:                operatorCombo = new SComboBox();
048:
049:                // Get the Operators from getOperators (overriden by subclasses)...
050:                for (Operator relationalOperator : getOperators()) {
051:                    // ...and add each Operator to the operatorCombo.
052:                    operatorCombo.addItem(relationalOperator);
053:                }
054:
055:            }
056:
057:            /**
058:             * Gets the property meta.
059:             * 
060:             * @return the property meta
061:             */
062:            public PropertyMeta getPropertyMeta() {
063:                return propertyMeta;
064:            }
065:
066:            /**
067:             * Sets the property meta.
068:             * 
069:             * @param propertyMeta the new property meta
070:             */
071:            public void setPropertyMeta(PropertyMeta propertyMeta) {
072:                this .propertyMeta = propertyMeta;
073:            }
074:
075:            /**
076:             * Gets the value to compare to.
077:             * 
078:             * @return the value to compare to
079:             */
080:            public abstract Object getValueToCompareTo();
081:
082:            /**
083:             * Sets the value to compare to.
084:             * 
085:             * @param condition the new value to compare to
086:             */
087:            public abstract void setValueToCompareTo(PropertyCondition condition);
088:
089:            /**
090:             * Sets the operator.
091:             * 
092:             * @param operatorToBeSelected the new operator
093:             */
094:            public void setOperator(Operator operatorToBeSelected) {
095:                // iterate over all operators in the combo-box...
096:                for (int i = 0; i < operatorCombo.getItemCount(); i++) {
097:                    Operator controllerOp = (Operator) operatorCombo
098:                            .getItemAt(i);
099:
100:                    // ...until we find the one that matches...
101:                    if (controllerOp.equals(operatorToBeSelected))
102:                        // ...and make it the selected item in the combo-box.
103:                        operatorCombo.setSelectedIndex(i);
104:                }
105:            }
106:
107:            /*
108:             * (non-Javadoc)
109:             * 
110:             * @see org.osbl.agent.gui.condition.RelationalConditionController#canBeReplacedBy(agent.controller.OperationController)
111:             */
112:            public boolean canBeReplacedBy(
113:                    OperationController candidateController) {
114:
115:                // There are many PropertyConditions in the UI, one for each property...
116:
117:                // So, a replacement is found only if the class matches ...
118:                if (candidateController instanceof  PropertyConditionController) {
119:                    PropertyConditionController otherControlller = (PropertyConditionController) candidateController;
120:                    // and they represent the same property...
121:                    return ((PropertyCondition) otherControlller.getCondition())
122:                            .getPropertyMetaName().equals(
123:                                    propertyMeta.getName());
124:                    // Otherwise no match is found.
125:                } else
126:                    return false;
127:            }
128:
129:            /* (non-Javadoc)
130:             * @see org.osbl.agent.gui.ConditionController#populateCondition(org.osbl.agent.model.Condition)
131:             */
132:            protected void populateCondition(Condition condition) {
133:
134:                // Set the operation in the condition to whatever is selected in the UI
135:                ((PropertyCondition) condition)
136:                        .setOperator((Operator) operatorCombo.getSelectedItem());
137:
138:                ((PropertyCondition) condition)
139:                        .setBeanMetaClassName(propertyMeta.getBeanMeta()
140:                                .getName());
141:
142:                // Set the propertyMeta to the one set in this class.
143:                ((PropertyCondition) condition)
144:                        .setPropertyMetaName(propertyMeta.getName());
145:
146:                // Set the valueToCompareTo to whatever the user entered or selected in the UI.
147:                // (subclasses of this controller let the user enter/choose this information in
148:                // different ways).
149:                ((PropertyCondition) condition)
150:                        .setValueToCompareTo(getValueToCompareTo());
151:            }
152:
153:            /*
154:             * (non-Javadoc)
155:             * 
156:             * @see org.osbl.agent.gui.condition.RelationalConditionController#getOperators()
157:             */
158:            /**
159:             * Gets the operators.
160:             * 
161:             * @return the operators
162:             */
163:            public List<Operator> getOperators() {
164:
165:                List<Operator> result = new ArrayList<Operator>();
166:
167:                // Since we are dealing with fields in a generic way we can
168:                // only define operators we can be sure apply to all fields...
169:
170:                result.add(new BinaryOperator(msg("operatorIs"), "=="));
171:                result.add(new BinaryOperator(msg("operatorIsNot"), "!="));
172:
173:                // Subclasses of this class will add more specific Operators
174:                // on their own, depending of the type they represent.
175:
176:                return result;
177:            }
178:
179:            /*
180:             * (non-Javadoc)
181:             * 
182:             * @see org.osbl.agent.gui.condition.RelationalConditionController#setCondition(org.osbl.agent.model.condition.Condition)
183:             */
184:            public void setCondition(Condition condition) {
185:
186:                // Get the operator that is set in the PropertyCondition given...
187:                Operator conditionOp = ((PropertyCondition) condition)
188:                        .getOperator();
189:
190:                setOperator(conditionOp);
191:
192:                // Attemp to find and set the propertyMeta according to the data
193:                // stored in the Condition.
194:
195:                String className = ((PropertyCondition) condition)
196:                        .getBeanMetaClassName();
197:                String propertyName = ((PropertyCondition) condition)
198:                        .getPropertyMetaName();
199:
200:                try {
201:                    BeanMeta beanMeta = Client.getInstance()
202:                            .getBeanMetaProvider().getBeanMeta(
203:                                    Class.forName(className));
204:                    setPropertyMeta(beanMeta.getProperty(propertyName));
205:                } catch (ClassNotFoundException e) {
206:                    // TODO Auto-generated catch block
207:                    e.printStackTrace();
208:                }
209:
210:                // Let subclasses modify the input/choice component to reflect the comparison
211:                // value stored in the condition.
212:                setValueToCompareTo((PropertyCondition) condition);
213:            }
214:
215:            /* (non-Javadoc)
216:             * @see org.osbl.agent.gui.OperationController#populateComponentList(java.util.List)
217:             */
218:            protected void populateComponentList(List<SComponent> componentList) {
219:                componentList.add(operatorCombo);
220:            }
221:
222:            /*
223:             * (non-Javadoc)
224:             * 
225:             * @see java.lang.Object#toString()
226:             */
227:            public String toString() {
228:
229:                return "  " + propertyMeta.getLabel() + "   ("
230:                        + propertyMeta.getName() + ")";
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.