1
2
3
4
5
6
7 package net.kwfgrid.gwui.taskframework;
8
9 import java.awt.Graphics;
10 import java.awt.Component;
11 import java.awt.event.ActionEvent;
12 import java.util.Iterator;
13 import java.util.List;
14 import javax.swing.*;
15
16 import org.glassbox.graphview.NodeButtonSet;
17
18 import de.fzi.wim.guibase.graphview.graph.Node;
19
20 import net.kwfgrid.gwui.graphview.TransitionNode;
21 import net.kwfgrid.gworkflowdl.structure.Transition;
22 import net.kwfgrid.gworkflowdl.structure.GenericProperties;
23
24 public class NodeButton4WCTRefinementFailed implements NodeButtonSet.Button {
25 private Action ACTION = new AbstractAction() {
26 public void actionPerformed(ActionEvent e) {
27 TransitionNode tnode = (TransitionNode)e.getSource();
28 Transition t = tnode.getTransition();
29 List tasks = _producer.getValidTasks(t);
30 if (tasks.size()>0) {
31 UserTask task = (UserTask)tasks.get(0);
32 task.execute();
33 }
34 }
35 };
36
37 private InputTaskProducer4WCTRefinementFailed _producer;
38
39 public NodeButton4WCTRefinementFailed(InputTaskProducer4WCTRefinementFailed producer) {
40 _producer = producer;
41 }
42
43 public Action getAction() {
44 return ACTION;
45 }
46
47 public int getIconWidth() {
48 return InputTaskProducer4WCTRefinementFailed.TASK_ICON.getIconWidth();
49 }
50
51 public int getIconHeight() {
52 return InputTaskProducer4WCTRefinementFailed.TASK_ICON.getIconHeight();
53 }
54
55 public void paintIcon(Component c, Graphics g, int x, int y) {
56 InputTaskProducer4WCTRefinementFailed.TASK_ICON.paintIcon(c, g, x, y);
57 }
58
59 public void paintPressedIcon(Component c, Graphics g, int x, int y) {
60 paintIcon(c, g, x, y);
61 }
62
63 public void paintRolloverIcon(Component c, Graphics g, int x, int y) {
64 paintIcon(c, g, x, y);
65 }
66
67 public boolean affectsNode(Node node) {
68 if (node instanceof TransitionNode) {
69 TransitionNode tnode = (TransitionNode)node;
70 Transition t = tnode.getTransition();
71 return _producer.hasValidTask(t);
72 }
73 return false;
74 }
75
76 public String getToolTipText(Node node) {
77 TransitionNode tnode = (TransitionNode)node;
78 Transition t = tnode.getTransition();
79 StringBuffer tt = new StringBuffer("<html>");
80 Iterator tasks = _producer.getValidTasks(t).iterator(); while (tasks.hasNext()) {
81 UserTask task = (UserTask)tasks.next();
82 tt.append(task.getTitle()).append(tasks.hasNext()?"<br>":"");
83 }
84 return tt.toString();
85 }
86 }