source: greenstone3/trunk/src/java/org/greenstone/admin/gui/adminUI_Pane.java@ 18545

Last change on this file since 18545 was 18545, checked in by cc108, 15 years ago

make some classes be abstract

File size: 4.1 KB
Line 
1package org.greenstone.admin.gui;
2
3import java.awt.Insets;
4import java.io.File;
5
6import javax.swing.JPanel;
7import javax.swing.JScrollPane;
8import javax.swing.JTextArea;
9import javax.xml.parsers.DocumentBuilder;
10import javax.xml.parsers.DocumentBuilderFactory;
11
12import org.greenstone.gsdl3.util.GSPath;
13import org.greenstone.gsdl3.util.GlobalProperties;
14import org.w3c.dom.*;
15
16public abstract class adminUI_Pane {
17
18 static JScrollPane description_pane;
19 static JPanel main_pane;
20 static JPanel control_pane;
21 static JTextArea descriptionTextArea;
22 static String description;
23
24 JPanel button_pane;
25 String extension_name;
26 String destination_folder;
27 String url;
28 String group;
29 String download_type;
30 Boolean configurable;
31
32 static final String EXTENSION = "extension";
33 static final String GROUP = "group";
34 static final String ADMIN_UI = "admin_ui";
35 static final String NAME = "name";
36 static final String DOWNLOAD = "download";
37 static final String INSTALL = "install";
38 static final String UNINSTALL = "uninstall";
39 static final String ENABLE = "enable";
40 static final String DISABLE = "disable";
41 static final String DESTINATION = "destination";
42 static final String DESCRIPTION = "description";
43 static final String PROPERTY = "property";
44 static final String STEP ="step";
45
46 GlobalProperties globalProperty = null;
47 String fileSeparator = File.separator;
48 GSPath gspath = null;
49
50 public adminUI_Pane(){
51
52 }
53
54 public void setup(){
55
56 descriptionTextArea.setText("");
57 description = loadDescription(extension_name);
58 descriptionTextArea = new JTextArea();
59 descriptionTextArea.setText("");
60 descriptionTextArea.append(description);
61 descriptionTextArea.setEditable(false);
62 descriptionTextArea.setLineWrap(true);
63 descriptionTextArea.setWrapStyleWord(true);
64 descriptionTextArea.setMargin(new Insets(0,ExtPane.left_padding,0,0));
65
66 description_pane = new JScrollPane(descriptionTextArea);
67 description_pane.setAutoscrolls(true);
68 }
69
70 abstract JPanel getControlPane();
71
72 abstract JPanel getDescriptionPane();
73
74 abstract boolean getCommandStatus(String Command);
75
76 public String get_GSDL3HOME(){
77
78 String gsdl3Home = globalProperty.getGSDL3Home();
79 String os = "linux";
80
81 if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){
82 gsdl3Home = gsdl3Home.replaceAll("\\\\", "/");
83 os = "windows";
84
85 }
86
87 gsdl3Home = gspath.removeLastLink(gsdl3Home);
88
89 if(os.equals("windows")){
90 gsdl3Home = gsdl3Home.replaceAll("/", "\\\\");
91 }
92
93 return gsdl3Home;
94 }
95
96 public String loadDescription(String className){
97
98 String gsdl3Home = get_GSDL3HOME();
99 Element rootNode = getRootElement(gsdl3Home+fileSeparator+"ext"+fileSeparator+"extension_project_list.xml");
100 NodeList projectNodeList = rootNode.getElementsByTagName(EXTENSION);
101
102 for(int i = 0; i < projectNodeList.getLength(); i++){
103
104 Element projectNode = (Element)projectNodeList.item(i);
105 NodeList nameNodeList = projectNode.getElementsByTagName(NAME);
106 String name = nameNodeList.item(0).getChildNodes().item(0).getNodeValue();
107
108 if(name.equals(className)){
109 NodeList descriptionNodeList = projectNode.getElementsByTagName(DESCRIPTION);
110 description = descriptionNodeList.item(0).getChildNodes().item(0).getNodeValue();
111 }
112 }
113 return description;
114 }
115
116 protected Element getRootElement(String url){
117
118 Element rootNode = null;
119 try{
120 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
121 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
122 Document doc = docBuilder.newDocument();
123 doc = docBuilder.parse (new File(url));
124 rootNode = doc.getDocumentElement();
125 return rootNode;
126 }catch (Exception e) {
127 e.printStackTrace();
128 return null;
129 }
130 }
131
132 protected abstract Object[][] getConfigureContent();
133
134 //protected abstract Boolean isConfigurable();
135
136 abstract JPanel getButtonPane();
137}
Note: See TracBrowser for help on using the repository browser.