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


001:        package org.osbl.client.wings.concern;
002:
003:        import org.concern.*;
004:        import org.osbl.client.action.AbstractObjectAction;
005:        import org.osbl.client.action.ObjectActionEvent;
006:        import org.osbl.client.wings.form.*;
007:        import org.osbl.client.wings.*;
008:        import org.osbl.client.wings.shell.Environment;
009:        import org.osbl.client.wings.shell.Client;
010:        import org.osbl.client.ClientServiceProvider;
011:        import org.osbl.plugin.*;
012:        import org.concern.controller.LoaderFactory;
013:        import org.conform.hibernate.HibernateEnvironment;
014:        import org.wings.session.SessionManager;
015:
016:        import javax.swing.*;
017:        import java.awt.event.ActionEvent;
018:        import java.awt.event.ActionListener;
019:        import java.util.*;
020:        import java.sql.Timestamp;
021:
022:        public class TaskEditor extends GenericObjectEditor {
023:            protected ForwardAction forwardAction = new ForwardAction(base());
024:            protected BackwardAction backwardAction = new BackwardAction(base());
025:            protected CompleteAction completeAction = new CompleteAction(base());
026:            protected ListAction listAction = new ListAction(base());
027:
028:            protected void initializeTools() {
029:                PluginManager pluginManager = (PluginManager) ClientServiceProvider
030:                        .getInstance().getService("ClientPluginManager");
031:                final ExtensionPoint extensionPoint = new ExtensionPoint(
032:                        "org.osbl.client.wings.form.taskEditorTools",
033:                        EditorTool.class);
034:                final List<Extension> list = pluginManager
035:                        .getExtensions(extensionPoint);
036:
037:                for (Extension extension : list) {
038:                    final Class<EditorTool> toolClass = (Class<EditorTool>) extension
039:                            .getImplementation();
040:                    try {
041:                        EditorTool tool = toolClass.newInstance();
042:                        tool.setEditor(this );
043:                        tools.add(tool);
044:                    } catch (Exception e) {
045:                        throw new RuntimeException(e);
046:                    }
047:                }
048:            }
049:
050:            protected void initializeEditor() {
051:                editAction = new TaskEditor.TaskAction(base());
052:            }
053:
054:            protected ObjectForm initializeForm() {
055:                return new TaskForm();
056:            }
057:
058:            protected void formControls(Environment environment) {
059:                environment.addControl(new XButton(listAction));
060:                //environment.addControl(new XButton(previousAction));
061:                //environment.addControl(new XButton(nextAction));
062:                environment.addControl(new XButton(forwardAction));
063:                environment.addControl(new XButton(backwardAction));
064:                environment.addControl(new XButton(completeAction));
065:            }
066:
067:            protected void listControls(Environment environment) {
068:            }
069:
070:            protected ObjectList initializeList() {
071:                final TaskList taskList = new TaskList();
072:                /*
073:                taskList.setLinkAction("subjectLine", new AbstractObjectAction() {
074:                    public void actionPerformed(ObjectActionEvent e) {
075:                        Object object = e.getTargets()[0];
076:                        taskList.setCurrent(object);
077:                        setObject(object);
078:
079:                        if (editAction.isEnabled())
080:                            editAction.actionPerformed(new ActionEvent(TaskEditor.this, 0, "edit"));
081:                    }
082:                });
083:                 */
084:                return taskList;
085:            }
086:
087:            protected String linkPropertyName() {
088:                return "subjectLine";
089:            }
090:
091:            public Class getType() {
092:                return Work.class;
093:            }
094:
095:            protected String base() {
096:                return "org.concern";
097:            }
098:
099:            public void showForm() {
100:                ((TaskForm) getForm()).setTask((Work) getObject());
101:                super .showForm();
102:            }
103:
104:            public void saveObject(Object object) {
105:                Work task = (Work) object;
106:                Controller controller = ControllerLookup.getInstance()
107:                        .getController(task.getProcess());
108:                Loader loader = new LoaderFactory().getLoader(controller);
109:                if (loader instanceof  Persister) {
110:                    Persister persister = (Persister) loader;
111:                    persister.update(task.getSubject());
112:                }
113:            }
114:
115:            public void deleteObject(Object object) {
116:            }
117:
118:            public void revertObject(Object object) {
119:            }
120:
121:            protected boolean complete() {
122:                if (!objectForm.hasValidationIssues()) {
123:                    saveObject(objectForm.getObject());
124:                    return true;
125:                } else
126:                    return false;
127:            }
128:
129:            protected boolean forward() {
130:                if (!objectForm.hasValidationIssues()) {
131:                    saveObject(objectForm.getObject());
132:                    return true;
133:                } else
134:                    return false;
135:            }
136:
137:            protected boolean backward() {
138:                if (!objectForm.hasValidationIssues()) {
139:                    saveObject(objectForm.getObject());
140:                    return true;
141:                } else
142:                    return false;
143:            }
144:
145:            private Timestamp fiveMinutes() {
146:                return new Timestamp(System.currentTimeMillis() + 1000 * 60 * 5);
147:            }
148:
149:            protected class TaskAction extends EditAction {
150:                public TaskAction(String base) {
151:                    super (base);
152:                }
153:
154:                public void actionPerformed(ActionEvent event) {
155:                    Work task = (Work) getObject();
156:                    Controller controller = ControllerLookup.getInstance()
157:                            .getController(task.getProcess());
158:                    if (controller == null) {
159:                        XOptionPane.showMessageDialog(null, "Controller "
160:                                + task.getProcess() + " is not deployed",
161:                                new ActionListener() {
162:                                    public void actionPerformed(
163:                                            ActionEvent event) {
164:                                    }
165:                                });
166:                    } else {
167:                        try {
168:                            if (!ControllerLookup.getInstance().getWorklist()
169:                                    .lock(
170:                                            task,
171:                                            SessionManager.getSession()
172:                                                    .getServletRequest()
173:                                                    .getUserPrincipal()
174:                                                    .getName(), fiveMinutes())) {
175:                                environment
176:                                        .setStatusMessage(new Client.Message(
177:                                                Client.Message.TYPE_WARNING,
178:                                                Client
179:                                                        .getInstance()
180:                                                        .getResourceProvider()
181:                                                        .getMessage(
182:                                                                "businessobject.messages.locked")));
183:                                return;
184:                            }
185:                            environment.setStatusMessage(null);
186:                            System.out.println("lock");
187:                        } catch (UnknownSubjectException e) {
188:                            throw new RuntimeException(e);
189:                        }
190:
191:                        showForm();
192:
193:                        // TODO: check level
194:
195:                        boolean forwardable = Boolean.TRUE.equals(controller
196:                                .getProcess().getActivity(task.getActivity())
197:                                .getEnvironmentEntry("forwardable"));
198:                        try {
199:                            forwardAction.setEnabled(forwardable
200:                                    && controller
201:                                            .isForwardPossible(task
202:                                                    .getSubjectId(), task
203:                                                    .getActivity()));
204:                            backwardAction.setEnabled(forwardable
205:                                    && controller
206:                                            .isBackwardPossible(task
207:                                                    .getSubjectId(), task
208:                                                    .getActivity()));
209:                        } catch (UnknownSubjectException e) {
210:                            throw new RuntimeException(e);
211:                        }
212:                    }
213:                    previousAction.setEnabled(objectList.hasPrevious());
214:                    nextAction.setEnabled(objectList.hasNext());
215:                }
216:            }
217:
218:            protected class CompleteAction extends AbstractAction {
219:                public CompleteAction(String base) {
220:                    putValue(Action.ACTION_COMMAND_KEY, base
221:                            + ".buttons.complete");
222:                }
223:
224:                public void actionPerformed(ActionEvent event) {
225:                    if (objectForm.hasValidationIssues())
226:                        return;
227:
228:                    Work work = (Work) getObject();
229:                    Controller controller = ControllerLookup.getInstance()
230:                            .getController(work.getProcess());
231:
232:                    try {
233:                        HibernateEnvironment.getInstance().beginTransaction();
234:
235:                        if (complete()) {
236:                            Map annotations = new HashMap();
237:                            annotations.put("user", SessionManager.getSession()
238:                                    .getServletRequest().getUserPrincipal()
239:                                    .getName());
240:                            controller.complete(work.getSubjectId(), work
241:                                    .getActivity(), annotations);
242:                        }
243:                        controller.announceSubject(work.getSubjectId());
244:
245:                        System.out.println("unlock");
246:                        ControllerLookup.getInstance().getWorklist().unlock(
247:                                work,
248:                                SessionManager.getSession().getServletRequest()
249:                                        .getUserPrincipal().getName());
250:                    } catch (Exception e) {
251:                        e.printStackTrace();
252:                    } finally {
253:                        HibernateEnvironment.getInstance().endTransaction();
254:                    }
255:
256:                    showList();
257:                }
258:
259:                public void setEnabled(boolean newValue) {
260:                }
261:            }
262:
263:            protected class ForwardAction extends AbstractAction {
264:                public ForwardAction(String base) {
265:                    putValue(Action.ACTION_COMMAND_KEY, base
266:                            + ".buttons.forward");
267:                }
268:
269:                public void actionPerformed(ActionEvent event) {
270:                    if (objectForm.hasValidationIssues())
271:                        return;
272:
273:                    Work work = (Work) getObject();
274:                    Controller controller = ControllerLookup.getInstance()
275:                            .getController(work.getProcess());
276:
277:                    try {
278:                        HibernateEnvironment.getInstance().beginTransaction();
279:
280:                        if (forward()) {
281:                            Map annotations = new HashMap();
282:                            annotations.put("user", SessionManager.getSession()
283:                                    .getServletRequest().getUserPrincipal()
284:                                    .getName());
285:                            try {
286:                                controller.forward(work.getSubjectId(), work
287:                                        .getActivity(), annotations);
288:                            } catch (Exception e) {
289:                                e.printStackTrace();
290:                            }
291:
292:                            showList();
293:                        }
294:
295:                        System.out.println("unlock");
296:                        ControllerLookup.getInstance().getWorklist().unlock(
297:                                work,
298:                                SessionManager.getSession().getServletRequest()
299:                                        .getUserPrincipal().getName());
300:                    } catch (UnknownSubjectException e) {
301:                        throw new RuntimeException(e);
302:                    } finally {
303:                        HibernateEnvironment.getInstance().endTransaction();
304:                    }
305:                }
306:
307:                public void setEnabled(boolean newValue) {
308:                }
309:            }
310:
311:            protected class BackwardAction extends AbstractAction {
312:                public BackwardAction(String base) {
313:                    putValue(Action.ACTION_COMMAND_KEY, base
314:                            + ".buttons.backward");
315:                }
316:
317:                public void actionPerformed(ActionEvent event) {
318:                    if (objectForm.hasValidationIssues())
319:                        return;
320:
321:                    Work work = (Work) getObject();
322:                    Controller controller = ControllerLookup.getInstance()
323:                            .getController(work.getProcess());
324:                    try {
325:                        HibernateEnvironment.getInstance().beginTransaction();
326:
327:                        if (backward()) {
328:                            Map annotations = new HashMap();
329:                            annotations.put("user", SessionManager.getSession()
330:                                    .getServletRequest().getUserPrincipal()
331:                                    .getName());
332:                            try {
333:                                controller.backward(work.getSubjectId(), work
334:                                        .getActivity(), annotations);
335:                            } catch (Exception e) {
336:                                e.printStackTrace();
337:                            }
338:
339:                            showList();
340:                        }
341:
342:                        System.out.println("unlock");
343:                        ControllerLookup.getInstance().getWorklist().unlock(
344:                                work,
345:                                SessionManager.getSession().getServletRequest()
346:                                        .getUserPrincipal().getName());
347:                    } catch (UnknownSubjectException e) {
348:                        throw new RuntimeException(e);
349:                    } finally {
350:                        HibernateEnvironment.getInstance().endTransaction();
351:                    }
352:                }
353:
354:                public void setEnabled(boolean newValue) {
355:                }
356:            }
357:
358:            protected class ListAction extends AbstractAction {
359:                public ListAction(String base) {
360:                    putValue(Action.ACTION_COMMAND_KEY, base + ".buttons.list");
361:                }
362:
363:                public void actionPerformed(ActionEvent event) {
364:                    if (objectForm.hasChanges()) {
365:                        String name = Client.getInstance()
366:                                .getResourceProvider().getMessage(
367:                                        getType().getName());
368:                        String message = unsavedChangesMessage(name);
369:                        XOptionPane.showConfirmDialog(null, message, name,
370:                                new ActionListener() {
371:                                    public void actionPerformed(
372:                                            ActionEvent event) {
373:                                        if (XOptionPane.YES_ACTION == event
374:                                                .getActionCommand())
375:                                            showList();
376:
377:                                        try {
378:                                            System.out.println("unlock");
379:                                            ControllerLookup
380:                                                    .getInstance()
381:                                                    .getWorklist()
382:                                                    .unlock(
383:                                                            (Work) getObject(),
384:                                                            SessionManager
385:                                                                    .getSession()
386:                                                                    .getServletRequest()
387:                                                                    .getUserPrincipal()
388:                                                                    .getName());
389:                                        } catch (UnknownSubjectException e) {
390:                                            throw new RuntimeException(e);
391:                                        }
392:                                    }
393:                                });
394:                    } else {
395:                        showList();
396:
397:                        try {
398:                            System.out.println("unlock");
399:                            ControllerLookup.getInstance().getWorklist()
400:                                    .unlock(
401:                                            (Work) getObject(),
402:                                            SessionManager.getSession()
403:                                                    .getServletRequest()
404:                                                    .getUserPrincipal()
405:                                                    .getName());
406:                        } catch (UnknownSubjectException e) {
407:                            throw new RuntimeException(e);
408:                        }
409:                    }
410:                }
411:
412:                public void setEnabled(boolean newValue) {
413:                }
414:            }
415:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.