1 | package org.greenstone.admin.guiext;
|
---|
2 |
|
---|
3 | import org.w3c.dom.Element;
|
---|
4 |
|
---|
5 | import java.awt.BorderLayout;
|
---|
6 | import java.awt.Insets;
|
---|
7 |
|
---|
8 | import javax.swing.JButton;
|
---|
9 | import javax.swing.JTextArea;
|
---|
10 | import javax.swing.JPanel;
|
---|
11 |
|
---|
12 | public class Step
|
---|
13 | {
|
---|
14 | protected SequenceList _parent = null;
|
---|
15 | protected String _id = null;
|
---|
16 | protected String _action = null;
|
---|
17 | protected String _label = null;
|
---|
18 | protected String _dependsOn = null;
|
---|
19 | protected String _rollbacks = null;
|
---|
20 | protected JButton _button = null;
|
---|
21 | protected static JTextArea _commonMessageArea = new JTextArea();
|
---|
22 |
|
---|
23 | public Step(String id, String label, String dependsOn, String rollbacks, SequenceList parent)
|
---|
24 | {
|
---|
25 | _parent = parent;
|
---|
26 | _id = id;
|
---|
27 | _label = label;
|
---|
28 | _dependsOn = dependsOn;
|
---|
29 | _rollbacks = rollbacks;
|
---|
30 |
|
---|
31 | _button = new JButton(_label);
|
---|
32 | _button.setEnabled(false);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Step(Element stepElement, SequenceList parent)
|
---|
36 | {
|
---|
37 | _parent = parent;
|
---|
38 | if(stepElement != null){
|
---|
39 | _id = stepElement.getAttribute("id");
|
---|
40 | if(_id.equals("")){
|
---|
41 | System.err.println("This <" + ExtXMLHelper.STEP + "> element has no id attribute or the id attribute is empty");
|
---|
42 | }
|
---|
43 |
|
---|
44 | _label = stepElement.getAttribute("label");
|
---|
45 | if(_label.equals("")){
|
---|
46 | System.err.println("This <" + ExtXMLHelper.STEP + "> element has no label attribute or the label attribute is empty");
|
---|
47 | }
|
---|
48 |
|
---|
49 | _action = stepElement.getAttribute("action");
|
---|
50 | if(_action.equals("")){
|
---|
51 | System.err.println("This <" + ExtXMLHelper.STEP + "> element has no action attribute or the action attribute is empty");
|
---|
52 | }
|
---|
53 |
|
---|
54 | _dependsOn = stepElement.getAttribute("dependsOn");
|
---|
55 | String[] dependencies = _dependsOn.split(",");
|
---|
56 | for(int i = 0; i < dependencies.length; i++){
|
---|
57 | if(dependencies[i].equals(_id)){
|
---|
58 | System.err.println("The " + _id + " step depends on itself which is not allowed");
|
---|
59 | _dependsOn = "";
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | _rollbacks = stepElement.getAttribute("rollbackTo");
|
---|
64 |
|
---|
65 | _button = new JButton(_label);
|
---|
66 | _button.setEnabled(false);
|
---|
67 | }
|
---|
68 | else{
|
---|
69 | System.err.println("This <" + ExtXMLHelper.STEP + "> element is null");
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | public JButton getButton()
|
---|
74 | {
|
---|
75 | return _button;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public String getId()
|
---|
79 | {
|
---|
80 | return _id;
|
---|
81 | }
|
---|
82 |
|
---|
83 | public String getAction()
|
---|
84 | {
|
---|
85 | return _action;
|
---|
86 | }
|
---|
87 |
|
---|
88 | public String getLabel()
|
---|
89 | {
|
---|
90 | return _label;
|
---|
91 | }
|
---|
92 |
|
---|
93 | public String getDependsOn()
|
---|
94 | {
|
---|
95 | return _dependsOn;
|
---|
96 | }
|
---|
97 |
|
---|
98 | public String getRollbacks()
|
---|
99 | {
|
---|
100 | return _rollbacks;
|
---|
101 | }
|
---|
102 |
|
---|
103 | public SequenceList getParent()
|
---|
104 | {
|
---|
105 | return _parent;
|
---|
106 | }
|
---|
107 |
|
---|
108 | public JTextArea getCommonMessageArea()
|
---|
109 | {
|
---|
110 | return _commonMessageArea;
|
---|
111 | }
|
---|
112 | } |
---|