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