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


001:        package org.osbl.client.wings.control;
002:
003:        import org.concern.*;
004:        import org.concern.controller.LoaderFactory;
005:        import org.conform.hibernate.HibernateEnvironment;
006:        import org.osbl.client.action.*;
007:        import org.osbl.client.wings.*;
008:        import org.osbl.client.wings.concern.SubjectList;
009:        import org.osbl.client.wings.concern.SubjectForm;
010:        import org.osbl.client.wings.form.DelegateEnvironment;
011:        import org.osbl.client.wings.form.editor.FormWindow;
012:        import org.osbl.client.wings.shell.*;
013:        import org.osbl.client.wings.shell.Window;
014:        import org.wings.*;
015:        import org.wings.event.SParentFrameEvent;
016:        import org.wings.event.SParentFrameListener;
017:        import org.wingx.XScrollPane;
018:
019:        import javax.swing.*;
020:        import javax.swing.event.ChangeEvent;
021:        import javax.swing.event.ChangeListener;
022:        import java.awt.*;
023:        import java.awt.event.ActionEvent;
024:        import java.awt.event.ActionListener;
025:        import java.util.*;
026:        import java.util.List;
027:
028:        /**
029:         * @author hengels
030:         */
031:        public class ProcessMonitor extends SPanel implements  Application,
032:                SParentFrameListener {
033:            protected Environment environment = new DelegateEnvironment(true);
034:
035:            private SComboBox stateComboBox = new SComboBox();
036:            SubjectList subjects = new SubjectList();
037:            XTabbedPane tabs = new XTabbedPane();
038:
039:            LogTable logTable = new LogTable();
040:            StateTable stateTable = new StateTable();
041:            EnlistmentsTable enlistmentsTable = new EnlistmentsTable();
042:
043:            SubjectPanel subjectPanel = new SubjectPanel();
044:            protected XScrollPane subjectsScrollPane;
045:            protected CreateSubjectAction createSubjectAction = new CreateSubjectAction();
046:            //protected ParameterizeAction parameterizeAction = new ParameterizeAction();
047:
048:            protected ReviveAction reviveAction = new ReviveAction();
049:            protected SuspendAction suspendAction = new SuspendAction();
050:            protected ResumeAction resumeAction = new ResumeAction();
051:            protected DestroyAction destroyAction = new DestroyAction();
052:            protected TouchAction touchAction = new TouchAction();
053:            protected EditAction editAction = new EditAction();
054:
055:            private final List<AbstractAction> runningActions = Arrays.asList(
056:                    touchAction, suspendAction, destroyAction, editAction);
057:            private final List<AbstractAction> suspendActions = Arrays.asList(
058:                    resumeAction, destroyAction, editAction);
059:            private final List<AbstractAction> stalledActions = Arrays.asList(
060:                    touchAction, suspendAction, destroyAction, editAction);
061:            private final List<AbstractAction> terminatedActions = Arrays
062:                    .asList(reviveAction, editAction);
063:            protected List<AbstractAction> actions = runningActions;
064:
065:            private String[] processes;
066:            private String[] processesAndAll;
067:            private boolean initialized;
068:
069:            public ProcessMonitor() {
070:                super (new SGridBagLayout());
071:                setStyle("XForm");
072:                String[] processes = ControllerLookup.getInstance()
073:                        .getControllerNames();
074:                this .processes = processes;
075:                this .processesAndAll = new String[processes.length + 1];
076:                this .processesAndAll[0] = Client
077:                        .getInstance()
078:                        .getResourceProvider()
079:                        .getMessage(
080:                                "org.concern.model.Process.messages.allDeployed");
081:                System.arraycopy(processes, 0, this .processesAndAll, 1,
082:                        processes.length);
083:                addParentFrameListener(this );
084:
085:                environment.setContentPane(this );
086:                environment.setTitle("org.concern.model.Process.monitor.title");
087:                updateControls();
088:            }
089:
090:            public Environment getEnvironment() {
091:                return environment;
092:            }
093:
094:            public void parentFrameAdded(SParentFrameEvent sParentFrameEvent) {
095:                if (initialized)
096:                    return;
097:                initialized = true;
098:
099:                stateComboBox.setModel(new DefaultComboBoxModel(new Object[] {
100:                        Client.getInstance().getResourceProvider().getMessage(
101:                                "org.concern.Subject.state.0"),
102:                        Client.getInstance().getResourceProvider().getMessage(
103:                                "org.concern.Subject.state.1"),
104:                        Client.getInstance().getResourceProvider().getMessage(
105:                                "org.concern.Subject.state.2"),
106:                        Client.getInstance().getResourceProvider().getMessage(
107:                                "org.concern.Subject.state.3"), }));
108:                stateComboBox.addActionListener(new ActionListener() {
109:                    public void actionPerformed(ActionEvent e) {
110:                        int state = stateComboBox.getSelectedIndex();
111:                        subjects.setState(state);
112:                        refresh();
113:                        selectSubject(null);
114:                        update();
115:                        switch (state) {
116:                        case Controller.STATE_RUNNING:
117:                            actions = runningActions;
118:                            break;
119:                        case Controller.STATE_STALLED:
120:                            actions = stalledActions;
121:                            break;
122:                        case Controller.STATE_SUSPENDED:
123:                            actions = suspendActions;
124:                            break;
125:                        case Controller.STATE_DESTROYED:
126:                            actions = terminatedActions;
127:                            break;
128:                        }
129:                        updateControls();
130:                        logTable
131:                                .setArchive(state == Controller.STATE_DESTROYED);
132:                    }
133:                });
134:                stateComboBox.setHorizontalAlignment(SConstants.LEFT_ALIGN);
135:
136:                subjects
137:                        .setSelectionMode(SListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
138:                subjects.setLinkAction("subjectLine",
139:                        new AbstractObjectAction() {
140:                            public void actionPerformed(ObjectActionEvent event) {
141:                                Subject subject = (Subject) event.getTargets()[0];
142:                                subjects.setCurrent(subject);
143:
144:                                Controller controller = ControllerLookup
145:                                        .getInstance().getController(
146:                                                subject.getProcess());
147:                                if (controller == null) {
148:                                    XOptionPane
149:                                            .showMessageDialog(
150:                                                    ProcessMonitor.this ,
151:                                                    Client
152:                                                            .getInstance()
153:                                                            .getResourceProvider()
154:                                                            .getMessage(
155:                                                                    "org.concern.model.Process.messages.notDeployed",
156:                                                                    subject
157:                                                                            .getProcess()));
158:                                    return;
159:                                }
160:
161:                                selectController(controller);
162:                                selectSubject(subject);
163:                                update();
164:                            }
165:                        });
166:
167:                tabs.addChangeListener(new ChangeListener() {
168:                    public void stateChanged(ChangeEvent e) {
169:                        update();
170:                    }
171:                });
172:
173:                stateComboBox.setSelectedIndex(0);
174:
175:                tabs.add("Log", logTable);
176:                tabs.add("State", stateTable);
177:                tabs.add("Enlistments", enlistmentsTable);
178:                tabs.add("Subject", subjectPanel);
179:
180:                subjectsScrollPane = new XScrollPane(subjects);
181:                subjectsScrollPane.setPreferredSize(SDimension.FULLAREA);
182:                subjectsScrollPane.setVerticalExtent(8);
183:
184:                GridBagConstraints c = new GridBagConstraints();
185:                c.gridwidth = GridBagConstraints.REMAINDER;
186:                c.weighty = .05;
187:                add(stateComboBox, c);
188:                c.weighty = .40;
189:                add(subjectsScrollPane, c);
190:                c.weighty = .55;
191:                add(tabs, c);
192:
193:                refresh();
194:                subjects.setPreferredSize(SDimension.FULLWIDTH);
195:            }
196:
197:            private void updateControls() {
198:                List<SComponent> controls = new ArrayList(actions.size());
199:                for (Action action : actions) {
200:                    controls.add(new XButton(action));
201:                }
202:                environment.setControls(controls);
203:            }
204:
205:            private void refresh() {
206:                subjects.refresh();
207:            }
208:
209:            public void parentFrameRemoved(SParentFrameEvent sParentFrameEvent) {
210:            }
211:
212:            void selectController(Controller controller) {
213:                int tabCount = tabs.getTabCount();
214:                for (int i = 0; i < tabCount; i++) {
215:                    ((Plugin) tabs.getComponentAt(i)).setController(controller);
216:                }
217:            }
218:
219:            void selectSubject(Subject subject) {
220:                int tabCount = tabs.getTabCount();
221:                for (int i = 0; i < tabCount; i++) {
222:                    ((Plugin) tabs.getComponentAt(i)).setSubject(subject);
223:                }
224:            }
225:
226:            private List<Subject> getSelectedSubjects() {
227:                List<Subject> selection = (List<Subject>) subjects
228:                        .getSelectedObjects();
229:                if (selection == null || selection.size() == 0) {
230:                    Subject subject = (Subject) subjects.getCurrent();
231:                    if (subject == null)
232:                        selection = Collections.EMPTY_LIST;
233:                    else
234:                        selection = Collections.singletonList(subject);
235:                }
236:                return selection;
237:            }
238:
239:            private void update() {
240:                try {
241:                    HibernateEnvironment.getInstance().beginTransaction();
242:                    ((Plugin) tabs.getSelectedComponent()).update();
243:                } finally {
244:                    HibernateEnvironment.getInstance().endTransaction();
245:                }
246:            }
247:
248:            private class ReviveAction extends AbstractAction {
249:                public ReviveAction() {
250:                    putValue(Action.NAME, "Revive");
251:                }
252:
253:                public void actionPerformed(ActionEvent event) {
254:                    List<Subject> selection = getSelectedSubjects();
255:                    if (selection.isEmpty())
256:                        return;
257:
258:                    for (Subject subject : selection) {
259:                        Controller controller = ControllerLookup.getInstance()
260:                                .getController(subject.getProcess());
261:                        if (controller == null) {
262:                            XOptionPane
263:                                    .showMessageDialog(
264:                                            ProcessMonitor.this ,
265:                                            Client
266:                                                    .getInstance()
267:                                                    .getResourceProvider()
268:                                                    .getMessage(
269:                                                            "org.concern.model.Process.messages.notDeployed",
270:                                                            subject
271:                                                                    .getProcess()));
272:                            return;
273:                        }
274:
275:                        try {
276:                            HibernateEnvironment.getInstance()
277:                                    .beginTransaction();
278:                            controller.reviveSubject(subject.getSubjectId());
279:                        } catch (UnknownSubjectException e) {
280:                            e.printStackTrace();
281:                        } finally {
282:                            HibernateEnvironment.getInstance().endTransaction();
283:                        }
284:                        try {
285:                            controller.process(subject.getSubjectId());
286:                        } catch (UnknownSubjectException e) {
287:                            e.printStackTrace();
288:                        }
289:                    }
290:                    refresh();
291:                    selectSubject(null);
292:                    update();
293:                }
294:            }
295:
296:            private class TouchAction extends AbstractAction {
297:                public TouchAction() {
298:                    putValue(Action.NAME, "Touch");
299:                }
300:
301:                public void actionPerformed(ActionEvent event) {
302:                    List<Subject> selection = getSelectedSubjects();
303:                    if (selection.isEmpty())
304:                        return;
305:
306:                    for (Subject subject : selection) {
307:                        Controller controller = ControllerLookup.getInstance()
308:                                .getController(subject.getProcess());
309:                        if (controller == null) {
310:                            XOptionPane
311:                                    .showMessageDialog(
312:                                            ProcessMonitor.this ,
313:                                            Client
314:                                                    .getInstance()
315:                                                    .getResourceProvider()
316:                                                    .getMessage(
317:                                                            "org.concern.model.Process.messages.notDeployed",
318:                                                            subject
319:                                                                    .getProcess()));
320:                            return;
321:                        }
322:
323:                        try {
324:                            controller.process(subject.getSubjectId());
325:                        } catch (UnknownSubjectException e) {
326:                            e.printStackTrace();
327:                        }
328:                    }
329:                    refresh();
330:                    update();
331:                }
332:            }
333:
334:            private class SuspendAction extends AbstractAction {
335:                public SuspendAction() {
336:                    putValue(Action.NAME, "Suspend");
337:                }
338:
339:                public void actionPerformed(ActionEvent event) {
340:                    List<Subject> selection = getSelectedSubjects();
341:                    if (selection.isEmpty())
342:                        return;
343:
344:                    for (Subject subject : selection) {
345:                        Controller controller = ControllerLookup.getInstance()
346:                                .getController(subject.getProcess());
347:                        if (controller == null) {
348:                            XOptionPane
349:                                    .showMessageDialog(
350:                                            ProcessMonitor.this ,
351:                                            Client
352:                                                    .getInstance()
353:                                                    .getResourceProvider()
354:                                                    .getMessage(
355:                                                            "org.concern.model.Process.messages.notDeployed",
356:                                                            subject
357:                                                                    .getProcess()));
358:                            return;
359:                        }
360:
361:                        try {
362:                            HibernateEnvironment.getInstance()
363:                                    .beginTransaction();
364:                            controller.suspendSubject(subject.getSubjectId());
365:                            HibernateEnvironment.getInstance().endTransaction();
366:                        } catch (UnknownSubjectException e) {
367:                            e.printStackTrace();
368:                        }
369:                    }
370:                    refresh();
371:                    selectSubject(null);
372:                    update();
373:                }
374:            }
375:
376:            private class ResumeAction extends AbstractAction {
377:                public ResumeAction() {
378:                    putValue(Action.NAME, "Resume");
379:                }
380:
381:                public void actionPerformed(ActionEvent event) {
382:                    List<Subject> selection = getSelectedSubjects();
383:                    if (selection.isEmpty())
384:                        return;
385:
386:                    for (Subject subject : selection) {
387:                        Controller controller = ControllerLookup.getInstance()
388:                                .getController(subject.getProcess());
389:                        if (controller == null) {
390:                            XOptionPane
391:                                    .showMessageDialog(
392:                                            ProcessMonitor.this ,
393:                                            Client
394:                                                    .getInstance()
395:                                                    .getResourceProvider()
396:                                                    .getMessage(
397:                                                            "org.concern.model.Process.messages.notDeployed",
398:                                                            subject
399:                                                                    .getProcess()));
400:                            return;
401:                        }
402:
403:                        try {
404:                            HibernateEnvironment.getInstance()
405:                                    .beginTransaction();
406:                            controller.resumeSubject(subject.getSubjectId());
407:                        } catch (UnknownSubjectException e) {
408:                            e.printStackTrace();
409:                        } finally {
410:                            HibernateEnvironment.getInstance().endTransaction();
411:                        }
412:                        try {
413:                            controller.process(subject.getSubjectId());
414:                        } catch (UnknownSubjectException e) {
415:                            e.printStackTrace();
416:                        }
417:                    }
418:                    refresh();
419:                    selectSubject(null);
420:                    update();
421:                }
422:            }
423:
424:            private class DestroyAction extends AbstractAction {
425:                public DestroyAction() {
426:                    putValue(Action.NAME, "Destroy");
427:                }
428:
429:                public void actionPerformed(ActionEvent event) {
430:                    List<Subject> selection = getSelectedSubjects();
431:                    if (selection.isEmpty())
432:                        return;
433:
434:                    for (Subject subject : selection) {
435:                        Controller controller = ControllerLookup.getInstance()
436:                                .getController(subject.getProcess());
437:                        if (controller == null) {
438:                            XOptionPane
439:                                    .showMessageDialog(
440:                                            ProcessMonitor.this ,
441:                                            Client
442:                                                    .getInstance()
443:                                                    .getResourceProvider()
444:                                                    .getMessage(
445:                                                            "org.concern.model.Process.messages.notDeployed",
446:                                                            subject
447:                                                                    .getProcess()));
448:                            return;
449:                        }
450:
451:                        try {
452:                            HibernateEnvironment.getInstance()
453:                                    .beginTransaction();
454:                            controller.destroySubject(subject.getSubjectId());
455:                        } catch (UnknownSubjectException e) {
456:                            e.printStackTrace();
457:                        } finally {
458:                            HibernateEnvironment.getInstance().endTransaction();
459:                        }
460:                        try {
461:                            controller.process(subject.getSubjectId());
462:                        } catch (UnknownSubjectException e) {
463:                            e.printStackTrace();
464:                        }
465:                    }
466:                    refresh();
467:                    selectSubject(null);
468:                    update();
469:                }
470:            }
471:
472:            private class EditAction extends AbstractAction {
473:                private FormWindow window;
474:                private SubjectForm subjectForm;
475:
476:                public EditAction() {
477:                    putValue(Action.NAME, "Edit");
478:                }
479:
480:                public void actionPerformed(ActionEvent event) {
481:                    Subject subject = (Subject) subjects.getCurrent();
482:                    if (subject == null)
483:                        return;
484:
485:                    if (window == null) {
486:                        subjectForm = new SubjectForm(true);
487:                        subjectForm.getEnvironment().addControl(
488:                                new XButton(new SaveAction()));
489:                        window = new FormWindow(subjectForm);
490:                        window.addPopAction(new PopAction());
491:                    }
492:                    subjectForm.setSubject(subject);
493:                    subjectForm.setObject(subject);
494:                    Window parent = Window.currentWindow(getEnvironment());
495:                    Client.getInstance().pushWindow(parent, window);
496:                }
497:
498:                protected void saveObject(Object object) {
499:                    try {
500:                        HibernateEnvironment.getInstance().beginTransaction();
501:                        Subject subject = (Subject) object;
502:                        Controller controller = ControllerLookup.getInstance()
503:                                .getController(subject.getProcess());
504:                        Loader loader = new LoaderFactory()
505:                                .getLoader(controller);
506:                        if (loader instanceof  Persister) {
507:                            Persister persister = (Persister) loader;
508:                            persister.update(subject.getSubject());
509:                        }
510:                        subjectForm.setObject(subject);
511:                        selectSubject(subject);
512:                        update();
513:                    } finally {
514:                        HibernateEnvironment.getInstance().endTransaction();
515:                    }
516:                }
517:
518:                private class SaveAction extends AbstractAction {
519:                    public SaveAction() {
520:                        putValue(Action.ACTION_COMMAND_KEY, ".buttons.save");
521:                        putValue(AuthorizedAction.PERMISSION_KEY,
522:                                "org.concern.actions.monitor[x]");
523:                    }
524:
525:                    public void actionPerformed(ActionEvent event) {
526:                        if (!subjectForm.hasValidationIssues())
527:                            saveObject(subjectForm.getObject());
528:                    }
529:                }
530:
531:                private class PopAction extends AbstractObjectAction {
532:                    public PopAction() {
533:                        putValue(Action.ACTION_COMMAND_KEY, ".buttons.back");
534:                        putValue(AuthorizedAction.PERMISSION_KEY,
535:                                "org.concern.actions.monitor[x]");
536:                    }
537:
538:                    public void actionPerformed(ObjectActionEvent event) {
539:                    }
540:                }
541:            }
542:
543:            private class CreateSubjectAction extends AbstractAction {
544:                public CreateSubjectAction() {
545:                    putValue(NAME, Client.getInstance().getResourceProvider()
546:                            .getMessage("org.concern.actions.createSubject"));
547:                }
548:
549:                public void actionPerformed(ActionEvent e) {
550:                    SPanel panel = new SPanel(new SGridLayout(2));
551:                    panel.add(new SLabel(Client.getInstance()
552:                            .getResourceProvider().getMessage(
553:                                    "org.concern.Subject.process")));
554:                    final SComboBox process = new SComboBox(
555:                            new DefaultComboBoxModel(processes));
556:                    panel.add(process);
557:                    panel.add(new SLabel(Client.getInstance()
558:                            .getResourceProvider().getMessage(
559:                                    "org.concern.Subject.subject")));
560:                    final STextField subject = new STextField();
561:                    panel.add(subject);
562:                    panel.add(new SLabel(Client.getInstance()
563:                            .getResourceProvider().getMessage(
564:                                    "org.concern.buttons.announceSubject")));
565:                    final SCheckBox announce = new SCheckBox();
566:                    panel.add(announce);
567:                    XOptionPane.showInputDialog(ProcessMonitor.this , Client
568:                            .getInstance().getResourceProvider().getMessage(
569:                                    "org.concern.Subject"), Client
570:                            .getInstance().getResourceProvider().getMessage(
571:                                    "org.concern.Controller.actions.create"),
572:                            panel, new ActionListener() {
573:                                public void actionPerformed(ActionEvent e) {
574:                                    if (XOptionPane.OK_ACTION.equals(e
575:                                            .getActionCommand())) {
576:                                        Controller controller = ControllerLookup
577:                                                .getInstance()
578:                                                .getController(
579:                                                        (String) process
580:                                                                .getSelectedItem());
581:                                        if (controller == null) {
582:                                            XOptionPane
583:                                                    .showMessageDialog(
584:                                                            ProcessMonitor.this ,
585:                                                            Client
586:                                                                    .getInstance()
587:                                                                    .getResourceProvider()
588:                                                                    .getMessage(
589:                                                                            "org.concern.model.Process.messages.notDeployed",
590:                                                                            process
591:                                                                                    .getSelectedItem()));
592:                                            return;
593:                                        }
594:                                        try {
595:                                            HibernateEnvironment.getInstance()
596:                                                    .beginTransaction();
597:                                            if (!controller
598:                                                    .isKnownSubject(subject
599:                                                            .getText()))
600:                                                controller
601:                                                        .createSubject(subject
602:                                                                .getText());
603:                                            if (announce.isSelected())
604:                                                controller
605:                                                        .announceSubject(subject
606:                                                                .getText());
607:                                            HibernateEnvironment.getInstance()
608:                                                    .endTransaction();
609:                                        } catch (SubjectCreationException e1) {
610:                                            XOptionPane.showMessageDialog(
611:                                                    ProcessMonitor.this ,
612:                                                    "Exception: "
613:                                                            + e1.getMessage());
614:                                        } catch (UnknownSubjectException e1) {
615:                                            XOptionPane.showMessageDialog(
616:                                                    ProcessMonitor.this ,
617:                                                    "Exception: "
618:                                                            + e1.getMessage());
619:                                        }
620:                                    }
621:                                }
622:                            });
623:                }
624:            }
625:
626:            /*
627:            private class ParameterizeAction
628:                extends AbstractAction
629:            {
630:                public ParameterizeAction() {
631:                    putValue(NAME, Client.getInstance().getResourceProvider().getMessage("org.concern.model.Process.buttons.parameterize"));
632:                    setEnabled(false);
633:                }
634:
635:                public void actionPerformed(ActionEvent e) {
636:                    final String process = (String)controllerComboBox.getSelectedItem();
637:                    if ("< all >".equals(process))
638:                        return;
639:
640:                    final Properties properties = CoreParameterResolver.INSTANCE.getProperties(process);
641:                    final Controller controller = (Controller)ControllerLookup.getInstance().getController(process);
642:                    Process processDescription = controller.getProcess();
643:
644:                    final List<ParameterSpec> parameterSpecs = buildParameterSpecs(processDescription);
645:                    SPanel panel = new SPanel(new SGridLayout(2));
646:                    for (ParameterSpec parameterSpec : parameterSpecs) {
647:                        SLabel label = new SLabel(parameterSpec.name);
648:                        label.setToolTipText(parameterSpec.description != null
649:                            ? parameterSpec.description
650:                            : parameterSpec.elementType + " " + parameterSpec.elementName);
651:                        panel.add(label);
652:
653:                        parameterSpec.component = new STextField();
654:                        parameterSpec.component.setText((String)properties.get(parameterSpec.name));
655:                        panel.add(parameterSpec.component);
656:                    }
657:
658:                    XOptionPane.showInputDialog(ProcessMonitor.this, process, Client.getInstance().getResourceProvider().getMessage("org.concern.model.Process.buttons.parameterize"), panel, new ActionListener() {
659:                        public void actionPerformed(ActionEvent e) {
660:                            if (XOptionPane.OK_ACTION.equals(e.getActionCommand())) {
661:                                for (ParameterSpec parameterSpec : parameterSpecs) {
662:                                    properties.put(parameterSpec.name, parameterSpec.component.getText());
663:                                }
664:
665:                                CoreParameterResolver.INSTANCE.setProperties(process, properties);
666:                                controller.reload();
667:                            }
668:                        }
669:                    });
670:                }
671:
672:                private List<ParameterSpec> buildParameterSpecs(Process processDescription) {
673:                    List<ParameterSpec> parameterSpecs = new LinkedList<ParameterSpec>();
674:
675:                    List<Element> elements = new LinkedList<Element>();
676:                    elements.add(processDescription);
677:                    elements.add(processDescription.getLoader());
678:                    elements.addAll(processDescription.getConditions());
679:                    elements.addAll(processDescription.getEvents());
680:                    elements.addAll(processDescription.getActivities());
681:                    elements.addAll(processDescription.getListeners());
682:                    elements.addAll(processDescription.getActors());
683:
684:                    for (Element element : elements) {
685:                        for (Iterator iterator = element.getEnvironment().iterator(); iterator.hasNext();) {
686:                            EnvironmentEntry entry = (EnvironmentEntry)iterator.next();
687:                            String value = entry.getValue();
688:                            if (value.startsWith("parameter:")) {
689:                                value = value.substring("parameter:".length());
690:                                parameterSpecs.add(new ParameterSpec(
691:                                    element.getName(),
692:                                    element.getClass().getSimpleName(),
693:                                    entry.getName(),
694:                                    entry.getType(),
695:                                    entry.getDescription()));
696:                            }
697:                        }
698:                    }
699:                    return parameterSpecs;
700:                }
701:            }
702:
703:            static class ParameterSpec
704:            {
705:                public String elementName;
706:                public String elementType;
707:                public String name;
708:                public String type;
709:                public String description;
710:                public STextField component;
711:
712:                public ParameterSpec(String elementName, String elementType, String name, String type, String description) {
713:                    this.elementName = elementName;
714:                    this.elementType = elementType;
715:                    this.name = name;
716:                    this.type = type;
717:                    this.description = description;
718:                }
719:            }
720:             */
721:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.