Source Code Cross Referenced for GraphControllerPanel.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » components » graph » 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 » JaWE » org.enhydra.jawe.components.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.components.graph;
002:
003:        import java.awt.BorderLayout;
004:        import java.util.List;
005:
006:        import javax.swing.BorderFactory;
007:        import javax.swing.ImageIcon;
008:        import javax.swing.JButton;
009:        import javax.swing.JComponent;
010:        import javax.swing.JPanel;
011:        import javax.swing.JScrollPane;
012:        import javax.swing.JToolBar;
013:        import javax.swing.JViewport;
014:        import javax.swing.SwingConstants;
015:
016:        import org.enhydra.jawe.ActionBase;
017:        import org.enhydra.jawe.BarFactory;
018:        import org.enhydra.jawe.JaWEAction;
019:        import org.enhydra.jawe.JaWEComponent;
020:        import org.enhydra.jawe.JaWEComponentView;
021:        import org.enhydra.jawe.JaWEManager;
022:        import org.enhydra.jawe.Utils;
023:        import org.enhydra.jawe.XMLElementChoiceButton;
024:        import org.enhydra.jawe.base.controller.JaWEType;
025:        import org.enhydra.jawe.base.controller.JaWETypes;
026:        import org.enhydra.jawe.components.graph.actions.SetActivityMode;
027:        import org.enhydra.jawe.components.graph.actions.SetEndMode;
028:        import org.enhydra.jawe.components.graph.actions.SetParticipantMode;
029:        import org.enhydra.jawe.components.graph.actions.SetParticipantModeFreeTextExpression;
030:        import org.enhydra.jawe.components.graph.actions.SetSelectMode;
031:        import org.enhydra.jawe.components.graph.actions.SetStartMode;
032:        import org.enhydra.jawe.components.graph.actions.SetTransitionMode;
033:        import org.enhydra.shark.xpdl.XMLUtil;
034:        import org.enhydra.shark.xpdl.elements.Activity;
035:        import org.enhydra.shark.xpdl.elements.ActivitySet;
036:        import org.enhydra.shark.xpdl.elements.Participant;
037:        import org.enhydra.shark.xpdl.elements.Transition;
038:
039:        /**
040:         *  Container for displaying menubar, toolbar, process graphs ...
041:         *
042:         *  @author Sasa Bojanic
043:         */
044:        public class GraphControllerPanel extends JPanel implements 
045:                JaWEComponentView {
046:
047:            protected GraphController controller;
048:
049:            // various things needed for initializing and further work
050:            protected JScrollPane graphScrollPane;
051:            protected JToolBar toolbar;
052:            protected XMLElementChoiceButton showParticipantChoiceButton;
053:            protected XMLElementChoiceButton asChoiceButton;
054:
055:            public GraphControllerPanel(GraphController controller) {
056:                this .controller = controller;
057:            }
058:
059:            public void configure() {
060:            }
061:
062:            public void init() {
063:                setBorder(BorderFactory.createEtchedBorder());
064:                setLayout(new BorderLayout());
065:                JPanel toolbars = new JPanel();
066:                toolbars.setLayout(new BorderLayout());
067:                // creating toolbars
068:                toolbar = BarFactory
069:                        .createToolbar("defaultToolbar", controller);
070:                toolbar.setFloatable(false);
071:                // creating button panel
072:                ImageIcon curIc = controller.getGraphSettings()
073:                        .getParticipantsIcon();
074:                showParticipantChoiceButton = new XMLElementChoiceButton(
075:                        Participant.class, controller, curIc, true,
076:                        new String[] { "Id", "Name", "ParticipantType",
077:                                "Description" });
078:                showParticipantChoiceButton.setToolTipText(controller
079:                        .getSettings().getLanguageDependentString(
080:                                "InsertExistingParticipant"
081:                                        + BarFactory.TOOLTIP_POSTFIX));
082:                curIc = controller.getGraphSettings()
083:                        .getActivitySetSelectIcon();
084:                asChoiceButton = new XMLElementChoiceButton(ActivitySet.class,
085:                        controller, curIc, true, new String[] { "Id" });
086:                asChoiceButton.setToolTipText(controller.getSettings()
087:                        .getLanguageDependentString(
088:                                "SelectActivitySet"
089:                                        + BarFactory.TOOLTIP_POSTFIX));
090:                JToolBar part = new JToolBar();
091:
092:                if (controller.getGraphSettings().useParticipantChoiceButton())
093:                    part.add(showParticipantChoiceButton);
094:
095:                if (controller.getGraphSettings().useActivitySetChoiceButton())
096:                    part.add(asChoiceButton);
097:
098:                if (controller.getGraphSettings().useParticipantChoiceButton()
099:                        || controller.getGraphSettings()
100:                                .useActivitySetChoiceButton()) {
101:                    toolbar.addSeparator();
102:                    toolbar.add(part);
103:                }
104:                // creating working component
105:                graphScrollPane = createWorkingComponent();
106:
107:                //      JPanel wp=new JPanel();
108:                //      wp.setLayout(new BorderLayout());
109:                //      JToolBar toolbox = BarFactory.createToolbar("toolbox", controller);
110:                JToolBar toolbox = createToolbox();
111:                toolbox.setOrientation(SwingConstants.HORIZONTAL);
112:                toolbars.add(toolbar, BorderLayout.NORTH);
113:                toolbars.add(toolbox, BorderLayout.CENTER);
114:                //      wp.add(toolbox, BorderLayout.WEST);
115:                //      wp.add(graphScrollPane,BorderLayout.CENTER);
116:                add(toolbars, BorderLayout.NORTH);
117:                //      add(wp,BorderLayout.CENTER);
118:                add(graphScrollPane, BorderLayout.CENTER);
119:            }
120:
121:            public JaWEComponent getJaWEComponent() {
122:                return controller;
123:            }
124:
125:            public JComponent getDisplay() {
126:                return this ;
127:            }
128:
129:            protected JToolBar createToolbox() {
130:                String toolbarName = "toolbox";
131:                String actionOrder = controller.getSettings()
132:                        .getToolbarActionOrder(toolbarName);
133:
134:                JaWETypes jts = JaWEManager.getInstance().getJaWEController()
135:                        .getJaWETypes();
136:
137:                JToolBar toolbar = new JToolBar();
138:                toolbar.setRollover(true);
139:                String[] act = Utils.tokenize(actionOrder,
140:                        BarFactory.ACTION_DELIMITER);
141:
142:                for (int j = 0; j < act.length; j++) {
143:                    if (act[j].equals(BarFactory.ACTION_SEPARATOR)) {
144:                        toolbar.addSeparator();
145:                    } else if (act[j].equals("SetSelectMode")) {
146:                        JaWEAction ja = new JaWEAction();
147:                        ja.setAction(new SetSelectMode(controller));
148:                        ja.setIcon(((GraphSettings) controller.getSettings())
149:                                .getSelectionIcon());
150:                        ja.setLangDepName(controller.getSettings()
151:                                .getLanguageDependentString("SelectionKey"));
152:                        JButton b = BarFactory.createToolbarButton(ja,
153:                                controller);
154:                        b.setToolTipText(ja.getLangDepName());
155:                        toolbar.add(b);
156:                        controller.getSettings().addAction("SetSelectMode", ja);
157:                    } else if (act[j]
158:                            .equals("SetParticipantModeCommonExpression")) {
159:                        JaWEAction ja = new JaWEAction();
160:                        try {
161:                            String clsName = "org.enhydra.jawe.components.graph.actions.SetParticipantModeCommonExpression";
162:                            ActionBase action = (ActionBase) Class.forName(
163:                                    clsName).getConstructor(
164:                                    new Class[] { GraphController.class })
165:                                    .newInstance(new Object[] { controller });
166:                            ja.setAction(action);
167:                        } catch (Exception ex) {
168:                        }
169:                        ja.setIcon(((GraphSettings) controller.getSettings())
170:                                .getCommonExpresionParticipantIcon());
171:                        ja.setLangDepName(controller.getSettings()
172:                                .getLanguageDependentString(
173:                                        "CommonExpressionParticipantKey"));
174:                        JButton b = BarFactory.createToolbarButton(ja,
175:                                controller);
176:                        b.setToolTipText(ja.getLangDepName());
177:                        toolbar.add(b);
178:                        controller.getSettings().addAction(
179:                                "SetParticipantModeCommonExpression", ja);
180:                    } else if (act[j]
181:                            .equals("SetParticipantModeFreeTextExpression")) {
182:                        JaWEAction ja = new JaWEAction();
183:                        ja.setAction(new SetParticipantModeFreeTextExpression(
184:                                controller));
185:                        ja.setIcon(((GraphSettings) controller.getSettings())
186:                                .getFreeTextParticipantIcon());
187:                        ja.setLangDepName(controller.getSettings()
188:                                .getLanguageDependentString(
189:                                        "FreeTextExpressionParticipantKey"));
190:                        JButton b = BarFactory.createToolbarButton(ja,
191:                                controller);
192:                        b.setToolTipText(ja.getLangDepName());
193:                        toolbar.add(b);
194:                        controller.getSettings().addAction(
195:                                "SetParticipantModeFreeTextExpression", ja);
196:                    } else if (act[j].equals("SetStartMode")) {
197:                        JaWEAction ja = new JaWEAction();
198:                        ja.setAction(new SetStartMode(controller));
199:                        ja.setIcon(((GraphSettings) controller.getSettings())
200:                                .getBubbleStartIcon());
201:                        ja.setLangDepName(controller.getSettings()
202:                                .getLanguageDependentString("StartBubbleKey"));
203:                        JButton b = BarFactory.createToolbarButton(ja,
204:                                controller);
205:                        b.setToolTipText(ja.getLangDepName());
206:                        toolbar.add(b);
207:                        controller.getSettings().addAction("SetStartMode", ja);
208:                    } else if (act[j].equals("SetEndMode")) {
209:                        JaWEAction ja = new JaWEAction();
210:                        ja.setAction(new SetEndMode(controller));
211:                        ja.setIcon(((GraphSettings) controller.getSettings())
212:                                .getBubbleEndIcon());
213:                        ja.setLangDepName(controller.getSettings()
214:                                .getLanguageDependentString("EndBubbleKey"));
215:                        JButton b = BarFactory.createToolbarButton(ja,
216:                                controller);
217:                        b.setToolTipText(ja.getLangDepName());
218:                        toolbar.add(b);
219:                        controller.getSettings().addAction("SetEndMode", ja);
220:                    } else if (act[j].startsWith("SetParticipantMode")) {
221:                        String type = act[j].substring("SetParticipantMode"
222:                                .length());
223:                        if (type.equals("*")) {
224:                            List parTypes = jts.getTypes(Participant.class);
225:                            for (int i = 0; i < parTypes.size(); i++) {
226:                                JaWEType jt = (JaWEType) parTypes.get(i);
227:                                JaWEAction ja = new JaWEAction();
228:                                ja.setAction(new SetParticipantMode(controller,
229:                                        jt.getTypeId()));
230:                                ja.setIcon(jt.getIcon());
231:                                ja.setLangDepName(jt.getDisplayName());
232:                                JButton b = BarFactory.createToolbarButton(ja,
233:                                        controller);
234:                                b.setToolTipText(ja.getLangDepName());
235:                                toolbar.add(b);
236:                                controller.getSettings().addAction(
237:                                        jt.getTypeId(), ja);
238:                            }
239:                        } else if (!(type
240:                                .equals("SetParticipantModeCommonExpression") || type
241:                                .equals("SetParticipantModeFreeTextExpression"))) {
242:                            JaWEType jt = jts.getType(type);
243:                            if (jt == null)
244:                                continue;
245:                            JaWEAction ja = new JaWEAction();
246:                            ja.setAction(new SetParticipantMode(controller, jt
247:                                    .getTypeId()));
248:                            ja.setIcon(jt.getIcon());
249:                            ja.setLangDepName(jt.getDisplayName());
250:                            JButton b = BarFactory.createToolbarButton(ja,
251:                                    controller);
252:                            b.setToolTipText(ja.getLangDepName());
253:                            toolbar.add(b);
254:                            controller.getSettings().addAction(jt.getTypeId(),
255:                                    ja);
256:                        }
257:                    } else if (act[j].startsWith("SetActivityMode")) {
258:                        String type = act[j].substring("SetActivityMode"
259:                                .length());
260:                        if (type.equals("*")) {
261:                            List actTypes = jts.getTypes(Activity.class);
262:                            for (int i = 0; i < actTypes.size(); i++) {
263:                                JaWEType jt = (JaWEType) actTypes.get(i);
264:                                JaWEAction ja = new JaWEAction();
265:                                ja.setAction(new SetActivityMode(controller, jt
266:                                        .getTypeId()));
267:                                ja.setIcon(jt.getIcon());
268:                                ja.setLangDepName(jt.getDisplayName());
269:                                JButton b = BarFactory.createToolbarButton(ja,
270:                                        controller);
271:                                b.setToolTipText(ja.getLangDepName());
272:                                toolbar.add(b);
273:                                controller.getSettings().addAction(
274:                                        jt.getTypeId(), ja);
275:                            }
276:                        } else {
277:                            JaWEType jt = jts.getType(type);
278:                            if (jt == null)
279:                                continue;
280:                            JaWEAction ja = new JaWEAction();
281:                            ja.setAction(new SetActivityMode(controller, jt
282:                                    .getTypeId()));
283:                            ja.setIcon(jt.getIcon());
284:                            ja.setLangDepName(jt.getDisplayName());
285:                            JButton b = BarFactory.createToolbarButton(ja,
286:                                    controller);
287:                            b.setToolTipText(ja.getLangDepName());
288:                            toolbar.add(b);
289:                            controller.getSettings().addAction(jt.getTypeId(),
290:                                    ja);
291:                        }
292:                    } else if (act[j].startsWith("SetTransitionMode")) {
293:                        String type = act[j].substring("SetTransitionMode"
294:                                .length());
295:                        if (type.equals("*")) {
296:                            List traTypes = jts.getTypes(Transition.class);
297:                            for (int i = 0; i < traTypes.size(); i++) {
298:                                JaWEType jt = (JaWEType) traTypes.get(i);
299:                                JaWEAction ja = new JaWEAction();
300:                                ja.setAction(new SetTransitionMode(controller,
301:                                        jt.getTypeId()));
302:                                ja.setIcon(jt.getIcon());
303:                                ja.setLangDepName(jt.getDisplayName());
304:                                JButton b = BarFactory.createToolbarButton(ja,
305:                                        controller);
306:                                b.setToolTipText(ja.getLangDepName());
307:                                toolbar.add(b);
308:                                controller.getSettings().addAction(
309:                                        jt.getTypeId(), ja);
310:                            }
311:                        } else {
312:                            JaWEType jt = jts.getType(type);
313:                            if (jt == null)
314:                                continue;
315:                            JaWEAction ja = new JaWEAction();
316:                            ja.setAction(new SetTransitionMode(controller, jt
317:                                    .getTypeId()));
318:                            ja.setIcon(jt.getIcon());
319:                            ja.setLangDepName(jt.getDisplayName());
320:                            JButton b = BarFactory.createToolbarButton(ja,
321:                                    controller);
322:                            b.setToolTipText(ja.getLangDepName());
323:                            toolbar.add(b);
324:                            controller.getSettings().addAction(jt.getTypeId(),
325:                                    ja);
326:                        }
327:                    }
328:                }
329:
330:                toolbar.setName(controller.getSettings()
331:                        .getLanguageDependentString(
332:                                toolbarName + BarFactory.LABEL_POSTFIX));
333:
334:                return toolbar;
335:
336:            }
337:
338:            protected JScrollPane createWorkingComponent() {
339:                JScrollPane lGraphScrollPane = new JScrollPane();
340:                JViewport port = lGraphScrollPane.getViewport();
341:                port.setScrollMode(JViewport.BLIT_SCROLL_MODE);
342:
343:                // Harald Meister: set bigger scroll-amounts, especially useful for
344:                // mouse-wheel-scolling in large workflows
345:                lGraphScrollPane.getVerticalScrollBar().setUnitIncrement(20);
346:                lGraphScrollPane.getHorizontalScrollBar().setUnitIncrement(40);
347:
348:                return lGraphScrollPane;
349:            }
350:
351:            public void graphSelected(Graph graph) {
352:                graphScrollPane.setViewportView(graph);
353:            }
354:
355:            public void enableDisableButtons() {
356:                if (controller.getSelectedGraph() != null) {
357:                    if (XMLUtil.getPackage(controller.getSelectedGraph()
358:                            .getXPDLObject()) == JaWEManager.getInstance()
359:                            .getJaWEController().getMainPackage())
360:                        if (controller.getChoices(showParticipantChoiceButton)
361:                                .size() != 0)
362:                            showParticipantChoiceButton.setEnabled(true);
363:                        else
364:                            showParticipantChoiceButton.setEnabled(false);
365:                    else
366:                        showParticipantChoiceButton.setEnabled(false);
367:                } else {
368:                    showParticipantChoiceButton.setEnabled(false);
369:                }
370:
371:                if (controller.getChoices(asChoiceButton).size() != 0)
372:                    asChoiceButton.setEnabled(true);
373:                else
374:                    asChoiceButton.setEnabled(false);
375:            }
376:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.