1
2
3
4
5
6 package net.kwfgrid.gwui.gui;
7
8 import net.kwfgrid.gworkflowdl.protocol.structure.ProtocolTransition;
9 import net.kwfgrid.gworkflowdl.protocol.structure.ProtocolWorkflow;
10 import net.kwfgrid.gworkflowdl.structure.*;
11
12 import org.glassbox.executor.Executor;
13 import org.glassbox.gui.TitledComboBoxModel;
14
15 import java.awt.*;
16 import java.awt.event.*;
17 import javax.swing.*;
18 import javax.swing.border.TitledBorder;
19
20 public class NullClassOperationEditor extends AbstractWorkflowElementEditor implements ActionListener {
21 private static final String ADD_COMMAND = "add";
22 private static final String REMOVE_COMMAND = "remove";
23 private static final String WEBSERVICE = "Webservice invocation";
24 private static final String PROGRAM = "Program execution";
25 private static final String GENERIC = "Genric operation";
26 private static final String[] CLASS_OPERATIONS = { WEBSERVICE, PROGRAM, GENERIC };
27
28 private JPanel _view;
29 private JComboBox _addbox;
30 private JButton _removebutton;
31
32 public NullClassOperationEditor(Executor executor, ProtocolWorkflow workflow, ProtocolTransition transition) {
33 super(executor, workflow, transition);
34 _view = null;
35 _addbox = null;
36 _removebutton = null;
37 }
38
39 public void actionPerformed(ActionEvent e) {
40 final Transition transition = (Transition)getElement();
41 if (ADD_COMMAND.equals(e.getActionCommand())) {
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 } else {
63 getExecutor().execute(new GUIMethodCallTask("Removing operation from transition "+transition.getID()+" ...", getExecutor(), this) {
64 protected void execute() {
65 transition.setOperation(null);
66 }
67 });
68 }
69 }
70
71 protected void updateState() {
72 _addbox.setEnabled(isEnabled() && isEditable() && !isPerformingTask());
73 _removebutton.setEnabled(isEnabled() && isEditable() && !isPerformingTask());
74 }
75
76 protected void updateView() {
77 updateState();
78 }
79
80 public JComponent getView() {
81 if (_view == null) {
82 _addbox = new JComboBox(new TitledComboBoxModel("concretise to ...", CLASS_OPERATIONS));
83 _addbox.addActionListener(this);
84 _addbox.setActionCommand(ADD_COMMAND);
85 _addbox.setEditable(false);
86 _removebutton = new JButton("revert to control transition");
87 _removebutton.addActionListener(this);
88 _removebutton.setActionCommand(REMOVE_COMMAND);
89 _view = new JPanel();
90 _view.setBorder(createBorder("Abstract Operation"));
91 _view.setLayout(new GridBagLayout());
92
93 GridBagConstraints c = new GridBagConstraints();
94
95 c.insets = new Insets(5, 0, 0, 0);
96 c.weightx = 0.5;
97 c.weighty = 1.0;
98 c.gridx = 0;
99 c.gridy = 0;
100 c.anchor = GridBagConstraints.WEST;
101 c.fill = GridBagConstraints.NONE;
102 c.gridwidth = 1;
103
104 _view.add(_removebutton, c);
105
106 c.gridx = 1;
107 c.anchor = GridBagConstraints.EAST;
108 c.gridwidth = GridBagConstraints.REMAINDER;
109
110 _view.add(_addbox, c);
111 }
112 return _view;
113 }
114 }