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


001:        package org.osbl.agent.gui;
002:
003:        import java.util.ArrayList;
004:        import java.util.List;
005:
006:        import org.concern.Controller;
007:        import org.concern.ControllerLookup;
008:        import org.concern.Subject;
009:        import org.conform.BeanMeta;
010:        import org.conform.PropertyMeta;
011:        import org.osbl.agent.gui.action.BeanShellActionController;
012:        import org.osbl.agent.gui.action.SetCurrentTimeActionController;
013:        import org.osbl.agent.gui.action.SetEnumActionController;
014:        import org.osbl.agent.gui.action.SetPropertyActionController;
015:        import org.osbl.agent.gui.action.SetValueActionController;
016:        import org.osbl.agent.gui.condition.BeanShellConditionController;
017:        import org.osbl.agent.gui.condition.EnumConditionController;
018:        import org.osbl.agent.gui.condition.FieldConditionController;
019:        import org.osbl.agent.gui.condition.NumberConditionController;
020:        import org.osbl.agent.gui.condition.OgnlConditionController;
021:        import org.osbl.agent.gui.condition.PropertyConditionController;
022:        import org.osbl.agent.gui.condition.StringConditionController;
023:        import org.osbl.agent.logic.ObjectRuntimeContext;
024:        import org.osbl.agent.logic.RuntimeContext;
025:        import org.osbl.agent.model.Rule;
026:        import org.osbl.agent.model.action.SetCurrentTimeAction;
027:        import org.osbl.client.wings.form.GenericObjectList;
028:        import org.osbl.client.wings.form.ObjectEditor;
029:        import org.osbl.client.wings.form.ObjectForm;
030:        import org.osbl.client.wings.shell.Client;
031:
032:        /**
033:         * The Class ObjectDesignContext.
034:         * 
035:         * @author Sebastian Nozzi.
036:         */
037:        public class ObjectDesignContext extends DesignContext {
038:
039:            /** The bean meta. */
040:            protected BeanMeta beanMeta;
041:
042:            /**
043:             * Instantiates a new object design context.
044:             * 
045:             * @param objectEditor the object editor
046:             */
047:            public ObjectDesignContext(ObjectEditor objectEditor) {
048:                super (objectEditor);
049:                beanMeta = Client.getInstance().getBeanMetaProvider()
050:                        .getBeanMeta(getRuntimeObjectClass());
051:            }
052:
053:            /* (non-Javadoc)
054:             * @see org.osbl.agent.gui.DesignContext#addSideFilters(org.osbl.agent.gui.SidePanel)
055:             */
056:            public void addSideFilters(SidePanel targetPanel) {
057:                // No filters
058:            }
059:
060:            /* (non-Javadoc)
061:             * @see org.osbl.agent.gui.DesignContext#addSpecifierComponents(org.osbl.agent.gui.RuleEditorPanel)
062:             */
063:            public void addSpecifierComponents(RuleEditorPanel targetPanel) {
064:                // No specifiers
065:            }
066:
067:            /* (non-Javadoc)
068:             * @see org.osbl.agent.gui.DesignContext#changeSpecifiers(org.osbl.agent.model.Rule)
069:             */
070:            public void changeSpecifiers(Rule rule) {
071:                // Since no specifiers, nothing to do
072:            }
073:
074:            /* (non-Javadoc)
075:             * @see org.osbl.agent.gui.DesignContext#enableSpecifierComponents(boolean)
076:             */
077:            public void enableSpecifierComponents(boolean enabled) {
078:                // Since no specifiers, nothing to do
079:            }
080:
081:            /* (non-Javadoc)
082:             * @see org.osbl.agent.gui.DesignContext#getActionControllers()
083:             */
084:            public List<OperationController> getActionControllers() {
085:
086:                // We'll be returning a List of OperationControllers (actually
087:                // ActionControllers)
088:                List<OperationController> result = new ArrayList<OperationController>();
089:
090:                // Now we'll process all properties of the Subject we are working with
091:                // and add a suitable ActionController for each of them so that the user
092:                // can set some field values.
093:
094:                // We get the properties from the beanMeta, which contains (meta)
095:                // information
096:                // about the subject type we are dealing with. This information can be
097:                // very
098:                // easily retrieved (easier than using java-reflection).
099:                PropertyMeta[] properties = beanMeta.getProperties();
100:
101:                // Iterate over all properties of the subject class
102:                for (PropertyMeta prop : properties) {
103:
104:                    SetPropertyActionController newController;
105:
106:                    if (prop.getType().isEnum()) {
107:                        newController = new SetEnumActionController();
108:                        // If the type is one of the supported time classes (see class
109:                        // documentation)
110:                    } else if (SetCurrentTimeAction.isSupportedTimeClass(prop
111:                            .getType()))
112:                        // The controller will be an automatic time-setter...
113:                        newController = new SetCurrentTimeActionController();
114:                    else
115:                        // ...otherwise it will be a normal value setter (via input
116:                        // field).
117:                        newController = new SetValueActionController();
118:
119:                    // Setting the propertyMeta is vital when later the ActionController
120:                    // is
121:                    // asked to generate the corresponding Action
122:                    newController.setPropertyMeta(prop);
123:
124:                    // Add our new controller for the property in turn to the list of
125:                    // choices
126:                    result.add(newController);
127:                }
128:
129:                // Add one (and only one) BeanShellActionController to the choices
130:                BeanShellActionController beanShellActionController = new BeanShellActionController();
131:                result.add(beanShellActionController);
132:
133:                // Return our list of ActionControllers
134:                return result;
135:            }
136:
137:            /* (non-Javadoc)
138:             * @see org.osbl.agent.gui.DesignContext#getConditionControllers()
139:             */
140:            public List<OperationController> getConditionControllers() {
141:
142:                // We'll be returning a List of OperationControllers (actually
143:                // ConditionControllers)
144:                List<OperationController> result = new ArrayList<OperationController>();
145:
146:                // These Controllers let you test a property of the Subject against some
147:                // user
148:                // provided value.
149:
150:                // Get the properties of the subject and for each of them...
151:                for (PropertyMeta propertyMeta : beanMeta.getProperties()) {
152:
153:                    PropertyConditionController newController = null;
154:
155:                    // ... according to the type of the property find and instantiate
156:                    // the corresponding PropertyConditionController...
157:
158:                    // ... either a special version of it
159:                    if (propertyMeta.getType().isEnum()) {
160:                        newController = new EnumConditionController();
161:                    } else if (Number.class.isAssignableFrom(propertyMeta
162:                            .getType())) {
163:                        newController = new NumberConditionController();
164:                    } else if (String.class.isAssignableFrom(propertyMeta
165:                            .getType())) {
166:                        newController = new StringConditionController();
167:                    } else {
168:                        // ... or a generic form...
169:                        newController = new FieldConditionController();
170:                    }
171:
172:                    // Setting the propertyMeta is vital when later the ConditionController
173:                    // is asked to generate the corresponding Condition
174:                    newController.setPropertyMeta(propertyMeta);
175:
176:                    // Add our new controller for the property in turn to the list of
177:                    // choices
178:                    result.add(newController);
179:                }
180:
181:                // Add an OgnlConditionController (only one)
182:                OgnlConditionController ognlConditionController = new OgnlConditionController();
183:                result.add(ognlConditionController);
184:
185:                // Add an BeanShellConditionController (only one)
186:                BeanShellConditionController beanShellConditionController = new BeanShellConditionController();
187:                result.add(beanShellConditionController);
188:
189:                return result;
190:            }
191:
192:            /* (non-Javadoc)
193:             * @see org.osbl.agent.gui.DesignContext#recomputeCurrentRules()
194:             */
195:            public void recomputeCurrentRules() {
196:
197:                currentRules.clear();
198:
199:                currentRules.addAll(agentSystem
200:                        .getRulesForUser(getCurrentUser()));
201:
202:                currentRules.addAll(agentSystem
203:                        .getPublicRulesOfOthers(getCurrentUser()));
204:
205:                List<Rule> deleteThese = new ArrayList<Rule>();
206:
207:                for (Rule rule : currentRules) {
208:                    if (belongsToDesignContext(rule) == false)
209:                        deleteThese.add(rule);
210:                }
211:
212:                currentRules.removeAll(deleteThese);
213:            }
214:
215:            /* (non-Javadoc)
216:             * @see org.osbl.agent.gui.DesignContext#getRuntimeObjectClass()
217:             */
218:            public Class getRuntimeObjectClass() {
219:                return getObjectEditor().getType();
220:            }
221:
222:            /* (non-Javadoc)
223:             * @see org.osbl.agent.gui.DesignContext#getRuntimeContext()
224:             */
225:            public RuntimeContext getRuntimeContext() {
226:                return new ObjectRuntimeContext();
227:            }
228:
229:            /* (non-Javadoc)
230:             * @see org.osbl.agent.gui.DesignContext#getPreviewControllerInstance()
231:             */
232:            public PreviewController getPreviewControllerInstance() {
233:
234:                PreviewController result = new PreviewController(this ) {
235:
236:                    ObjectForm form;
237:
238:                    public ObjectForm getObjectForm() {
239:                        if (form == null) {
240:                            try {
241:                                Class type = designContext.getObjectEditor()
242:                                        .getForm().getClass();
243:                                form = (ObjectForm) type.newInstance();
244:                            } catch (Exception e) {
245:                                throw new RuntimeException(e);
246:                            }
247:                        }
248:                        return form;
249:                    }
250:
251:                    public Object getListObject(int rowIdx) {
252:                        return ((GenericObjectList) designContext
253:                                .getObjectEditor().getList()).getRow(rowIdx);
254:                    }
255:
256:                    public void populateForm(Object targetObject) {
257:                        form.getEnvironment().setActive(true);
258:                        form.setObject(targetObject);
259:                    }
260:
261:                    protected void postUpdateActions(Object targetObject) {
262:                    }
263:
264:                    protected Controller getController(Object targetObject) {
265:                        Subject subject = (Subject) targetObject;
266:                        return ControllerLookup.getInstance().getController(
267:                                subject.getProcess());
268:                    }
269:
270:                    public Object getSubjectInstance(Object targetObject) {
271:                        return ((Subject) targetObject).getSubject();
272:                    }
273:
274:                };
275:
276:                return result;
277:            }
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.