1 | package org.greenstone.admin.guiext;
|
---|
2 |
|
---|
3 | import org.w3c.dom.Element;
|
---|
4 |
|
---|
5 | import javax.swing.JButton;
|
---|
6 | import javax.swing.JPanel;
|
---|
7 |
|
---|
8 | import java.awt.event.ActionListener;
|
---|
9 | import java.awt.event.ActionEvent;
|
---|
10 |
|
---|
11 | import java.lang.reflect.Constructor;
|
---|
12 |
|
---|
13 | public class PanelStep extends Step
|
---|
14 | {
|
---|
15 | String _controlPanelClass = null;
|
---|
16 |
|
---|
17 | public PanelStep(Element panelStepElement, SequenceList parent)
|
---|
18 | {
|
---|
19 | super(panelStepElement, parent);
|
---|
20 |
|
---|
21 | if(panelStepElement != null){
|
---|
22 |
|
---|
23 | _controlPanelClass = ExtXMLHelper.getValueFromSingleElement(panelStepElement, ExtXMLHelper.CLASS, true);
|
---|
24 |
|
---|
25 | if(_controlPanelClass == null || _controlPanelClass.equals("")){
|
---|
26 | System.err.println("The <" + ExtXMLHelper.CLASS + "> element inside this panel <" + ExtXMLHelper.STEP + "> either does not exist or is empty");
|
---|
27 | }
|
---|
28 |
|
---|
29 | _button.addActionListener(new PanelButtonListener());
|
---|
30 | }
|
---|
31 | else{
|
---|
32 | System.err.println("This panel <" + ExtXMLHelper.STEP + "> element is null");
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | public class PanelButtonListener implements ActionListener
|
---|
37 | {
|
---|
38 | public void actionPerformed(ActionEvent e)
|
---|
39 | {
|
---|
40 | _parent.getParent().loadGuiExtFile();
|
---|
41 |
|
---|
42 | Class controlPanelClass = null;
|
---|
43 | try{
|
---|
44 | controlPanelClass = Class.forName(_controlPanelClass);
|
---|
45 | }
|
---|
46 | catch(Exception ex){
|
---|
47 | ex.printStackTrace();
|
---|
48 | return;
|
---|
49 | }
|
---|
50 |
|
---|
51 | Object classObj = null;
|
---|
52 | try{
|
---|
53 | Constructor classConstructor = controlPanelClass.getConstructor(new Class[0]);
|
---|
54 | classObj = classConstructor.newInstance(new Object[0]);
|
---|
55 | }
|
---|
56 | catch(Exception ex){
|
---|
57 | System.err.println("Could not create the control panel class, either the class name is incorrect or the class does not exist inside the guiext.jar file");
|
---|
58 | return;
|
---|
59 | }
|
---|
60 |
|
---|
61 | _parent.getParent().changeExtPane(((BasePanel)(classObj)).getControlPanel());
|
---|
62 |
|
---|
63 | _parent.registerStepCompletion(PanelStep.this);
|
---|
64 | }
|
---|
65 | }
|
---|
66 | } |
---|