Source Code Cross Referenced for JActivityList.java in  » Workflow-Engines » bonita-v3.1 » hero » client » manager » 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 » bonita v3.1 » hero.client.manager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package hero.client.manager;
002:
003:        /*
004:         *
005:         * JActivityList.java - 
006:         * Copyright (C) 2003 Ecoo Team
007:         * valdes@loria.fr
008:         * 
009:         *
010:         * This program is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public License
012:         * as published by the Free Software Foundation; either version 2
013:         * of the License, or (at your option) any later version.
014:         *
015:         * This program is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018:         * GNU Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public License
021:         * along with this program; if not, write to the Free Software
022:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
023:         */
024:
025:        import hero.interfaces.Constants;
026:        import hero.util.BonitaClient;
027:
028:        import java.awt.BorderLayout;
029:        import java.awt.Color;
030:        import java.awt.Dimension;
031:        import java.awt.Toolkit;
032:        import java.awt.event.ActionEvent;
033:        import java.awt.event.ActionListener;
034:        import java.awt.event.MouseEvent;
035:        import java.awt.event.MouseListener;
036:        import java.beans.PropertyChangeEvent;
037:        import java.beans.PropertyChangeListener;
038:        import java.util.Iterator;
039:        import java.util.Collection;
040:
041:        import javax.swing.DefaultListModel;
042:        import javax.swing.JLabel;
043:        import javax.swing.JList;
044:        import javax.swing.JMenuItem;
045:        import javax.swing.JOptionPane;
046:        import javax.swing.JPanel;
047:        import javax.swing.JPopupMenu;
048:        import javax.swing.JScrollPane;
049:        import javax.swing.ImageIcon;
050:
051:        public class JActivityList extends JPanel implements 
052:                PropertyChangeListener, MouseListener, Constants.Nd {
053:
054:            static java.util.ResourceBundle resource = java.util.ResourceBundle
055:                    .getBundle("resources.Traduction")/*#BundleType=List*/;
056:
057:            private BonitaClient soapclient;
058:            private JList activityList = null;
059:            private DefaultListModel model;
060:            String project = null;
061:            public final static String imageBase = "images/";
062:            public final static ImageIcon icon = new ImageIcon(Thread
063:                    .currentThread().getContextClassLoader().getResource(
064:                            imageBase + "icon.png"));
065:
066:            public JActivityList(BonitaClient soapclient, MListener ml) {
067:                try {
068:                    this .soapclient = soapclient;
069:                    ml.addEventActivityListener(this );
070:
071:                    model = new DefaultListModel();
072:                    activityList = new JList(model);
073:                    activityList.setCellRenderer(new ManagerCellRenderer());
074:
075:                    JScrollPane jspact = new JScrollPane(activityList);
076:                    jspact.setBackground(new Color(177, 177, 251));
077:                    this .setBackground(new Color(177, 177, 251));
078:                    this .setLayout(new BorderLayout());
079:                    this .add(new JLabel(resource
080:                            .getString("jactivitylist.activity")),
081:                            BorderLayout.NORTH);
082:                    this .add(jspact, BorderLayout.CENTER);
083:                    activityList.addMouseListener(this );
084:                } catch (Exception e) {
085:                    JOptionPane.showMessageDialog(null, resource
086:                            .getString("jactivitylist.error"), resource
087:                            .getString("jactivitylist.interror"),
088:                            JOptionPane.INFORMATION_MESSAGE, icon);
089:                }
090:            }
091:
092:            public void mouseReleased(MouseEvent e) {
093:                try {
094:                    // Popup Menu
095:                    if ((e.getModifiers() & java.awt.event.InputEvent.BUTTON3_MASK) != 0) {
096:                        if (activityList.getSelectedValue() != null) {
097:                            JPopupMenu menu = new JPopupMenu();
098:                            PopupMenu(menu);
099:                            Dimension screen = Toolkit.getDefaultToolkit()
100:                                    .getScreenSize();
101:                            Dimension size = menu.getPreferredSize();
102:
103:                            // Flip along screen
104:                            int x = e.getX();
105:                            int y = e.getY();
106:
107:                            menu.show(this , x, y);
108:                        }
109:                    } else if (e.getClickCount() == 2)
110:                        BrowserControl.displayURL(java.lang.System
111:                                .getProperty("bonita.host")
112:                                + "/bonita/protected/Action.jsp?projectname="
113:                                + project
114:                                + "&nodename="
115:                                + ((ListItem) activityList.getSelectedValue())
116:                                        .getValue());
117:
118:                } catch (Exception ex) {
119:                }
120:                ;
121:            }
122:
123:            public void PopupMenu(JPopupMenu menu) {
124:                JMenuItem mi;
125:                ClassLoader cl = this .getClass().getClassLoader();
126:
127:                mi = (JMenuItem) menu.add(new JMenuItem(resource
128:                        .getString("jactivitylist.terminate")));
129:                mi.addActionListener(new ActionListener() {
130:                    public void actionPerformed(ActionEvent e) {
131:                        terminate();
132:                    }
133:                });
134:
135:                mi = (JMenuItem) menu.add(new JMenuItem(resource
136:                        .getString("jactivitylist.cancel")));
137:                mi.addActionListener(new ActionListener() {
138:                    public void actionPerformed(ActionEvent e) {
139:                        cancel();
140:                    }
141:                });
142:
143:                mi = (JMenuItem) menu.add(new JMenuItem(resource
144:                        .getString("jactivitylist.details")));
145:                mi.addActionListener(new ActionListener() {
146:                    public void actionPerformed(ActionEvent e) {
147:                        BrowserControl.displayURL(java.lang.System
148:                                .getProperty("bonita.host")
149:                                + "/bonita/protected/Action.jsp?projectname="
150:                                + project
151:                                + "&nodename="
152:                                + ((ListItem) activityList.getSelectedValue())
153:                                        .getValue());
154:                    }
155:                });
156:            }
157:
158:            void terminate() {
159:                try {
160:                    if (project != null)
161:                        soapclient.terminateActivity(project,
162:                                ((ListItem) activityList.getSelectedValue())
163:                                        .getValue());
164:                } catch (Exception term) {
165:                    if (term.getMessage().matches(
166:                            "(?i).*You have to terminate subProcess.*"))
167:                        JOptionPane.showMessageDialog(null, resource
168:                                .getString("jactivitylist.subnofinish"),
169:                                resource.getString("jactivitylist.terminate"),
170:                                JOptionPane.INFORMATION_MESSAGE, icon);
171:                    else
172:                        JOptionPane.showMessageDialog(null, resource
173:                                .getString("jactivitylist.terminateerror")
174:                                + term.getMessage(), resource
175:                                .getString("jactivitylist.terminate"),
176:                                JOptionPane.INFORMATION_MESSAGE, icon);
177:                }
178:            }
179:
180:            void cancel() {
181:                try {
182:                    if (project != null)
183:                        soapclient.cancelActivity(project,
184:                                ((ListItem) activityList.getSelectedValue())
185:                                        .getValue());
186:
187:                } catch (Exception cancel) {
188:                    JOptionPane.showMessageDialog(null, resource
189:                            .getString("jactivitylist.acterror")
190:                            + cancel.getMessage(), "Cancel Activity",
191:                            JOptionPane.INFORMATION_MESSAGE, icon);
192:                }
193:            }
194:
195:            public void propertyChange(PropertyChangeEvent e) {
196:                try {
197:                    if (e.getPropertyName().equals(JProjectList.SELECTED)) {
198:                        model.clear();
199:                        project = (String) e.getNewValue();
200:
201:                        Collection activity = soapclient
202:                                .getActivityList(project);
203:                        Iterator i = activity.iterator();
204:
205:                        while (i.hasNext()) {
206:                            String node = (String) i.next();
207:                            ListItem li = new ListItem(getColor(node), node);
208:                            model.addElement(li);
209:                        }
210:                    }
211:                } catch (Exception e1) {
212:                }
213:            }
214:
215:            public Color getColor(String name) throws Exception {
216:                soapclient.openProject(project);
217:                int state = soapclient.getNodeState(name);
218:                switch (state) {
219:                case EXECUTING:
220:                    return (Color.red);
221:                case ANTICIPATING:
222:                    return (Color.magenta);
223:                }
224:                return (Color.white);
225:            }
226:
227:            public void changeEvent(Object[] e, String projectName) {
228:                try {
229:                    if (projectName.equals(project)) {
230:                        model.clear();
231:                        int i = 0;
232:                        for (i = 0; i < e.length; i++) {
233:                            ListItem li = new ListItem(
234:                                    getColor(e[i].toString()), e[i].toString());
235:                            model.add(i, li);
236:                        }
237:                    }
238:                } catch (Exception e1) {
239:                }
240:            }
241:
242:            // Rest of mouse listener is empty
243:            public void mousePressed(MouseEvent e) {
244:            }
245:
246:            public void mouseEntered(MouseEvent e) {
247:            }
248:
249:            public void mouseExited(MouseEvent e) {
250:            }
251:
252:            public void mouseClicked(MouseEvent e) {
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.