[21919] | 1 | package org.greenstone.admin.guiext;
|
---|
| 2 |
|
---|
| 3 | import java.awt.*;
|
---|
| 4 | import java.awt.event.*;
|
---|
| 5 | import java.io.*;
|
---|
| 6 | import java.lang.reflect.Constructor;
|
---|
| 7 | import java.lang.reflect.Method;
|
---|
| 8 | import java.util.*;
|
---|
| 9 |
|
---|
| 10 | import java.net.URLClassLoader;
|
---|
| 11 | import java.net.URL;
|
---|
| 12 |
|
---|
| 13 | import javax.swing.*;
|
---|
| 14 | import javax.swing.event.*;
|
---|
| 15 | import javax.swing.tree.*;
|
---|
| 16 | import javax.swing.table.TableCellRenderer;
|
---|
| 17 |
|
---|
| 18 | import javax.xml.parsers.DocumentBuilder;
|
---|
| 19 | import javax.xml.parsers.DocumentBuilderFactory;
|
---|
| 20 | import javax.xml.transform.OutputKeys;
|
---|
| 21 | import javax.xml.transform.Transformer;
|
---|
| 22 | import javax.xml.transform.TransformerFactory;
|
---|
| 23 | import javax.xml.transform.dom.DOMSource;
|
---|
| 24 | import javax.xml.transform.stream.StreamResult;
|
---|
| 25 |
|
---|
| 26 | import org.greenstone.admin.GAIManager;
|
---|
| 27 | import org.greenstone.admin.GAI;
|
---|
| 28 | import org.greenstone.admin.Configuration;
|
---|
| 29 | import org.greenstone.gsdl3.util.GSPath;
|
---|
| 30 | import org.greenstone.gsdl3.util.GlobalProperties;
|
---|
| 31 |
|
---|
| 32 | import org.w3c.dom.Document;
|
---|
| 33 | import org.w3c.dom.Element;
|
---|
| 34 | import org.w3c.dom.Node;
|
---|
| 35 | import org.w3c.dom.NodeList;
|
---|
| 36 | import org.w3c.dom.Text;
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | public class ExtPane extends JPanel {
|
---|
| 40 |
|
---|
| 41 | /* The pane to demonstrate extension information*/
|
---|
| 42 |
|
---|
| 43 | protected JSplitPane main_ext_pane = null;
|
---|
| 44 |
|
---|
| 45 | /** The panel that contains a log_list */
|
---|
| 46 | private JPanel extensionList_pane = null;
|
---|
| 47 |
|
---|
| 48 | /** The panel that contains the log content. */
|
---|
| 49 | protected static JPanel extensionContent_pane = null;
|
---|
| 50 |
|
---|
| 51 | /** The List showing all the log files concerned. */
|
---|
| 52 | //protected JList extension_list=null;
|
---|
| 53 |
|
---|
| 54 | /** The label at the top of the logList_pane. */
|
---|
| 55 | protected JLabel extensionList_label = null;
|
---|
| 56 |
|
---|
| 57 | /** The label shown at the top of the logContent Pane. */
|
---|
| 58 | protected JLabel extensionContent_label = null;
|
---|
| 59 |
|
---|
| 60 | /** The scrollable area into which the log content is placed. */
|
---|
| 61 | protected JScrollPane description_content = null;
|
---|
| 62 |
|
---|
| 63 | /* Log TEXT AREA*/
|
---|
| 64 | protected JTextArea description_textarea = null;
|
---|
| 65 |
|
---|
| 66 | protected JScrollPane message_content = null;
|
---|
| 67 |
|
---|
| 68 | /* Log TEXT AREA*/
|
---|
| 69 | public static JTextArea message_textarea = null;
|
---|
| 70 |
|
---|
| 71 | protected static JPanel current_description_pane = null;
|
---|
| 72 |
|
---|
| 73 | protected JPanel button_pane = null;
|
---|
| 74 |
|
---|
| 75 | /** Buttons */
|
---|
| 76 | //protected JButton download_button = null;
|
---|
| 77 | //protected static JButton pre_configure_button = null;
|
---|
| 78 | //protected JButton install_button = null;
|
---|
| 79 | //protected JButton post_configure_button = null;
|
---|
| 80 | //protected JButton uninstall_button = null;
|
---|
| 81 | //protected JButton switch_button = null;
|
---|
| 82 |
|
---|
| 83 | protected static JPanel control_pane = null;
|
---|
| 84 |
|
---|
| 85 | protected JPanel main_content_pane = null;
|
---|
| 86 |
|
---|
| 87 | protected JTree extensionTreeList = null;
|
---|
| 88 |
|
---|
| 89 | protected DefaultMutableTreeNode top = new DefaultMutableTreeNode("Extension List");
|
---|
| 90 |
|
---|
| 91 | protected HashMap extensionInformation = null;
|
---|
| 92 |
|
---|
| 93 | protected JPanel extensionContentHeaderPane = null;
|
---|
| 94 |
|
---|
| 95 | protected String file_location;
|
---|
| 96 |
|
---|
| 97 | protected final String extension_status_root = "Configuration";
|
---|
| 98 | protected File extension_status_file = null;
|
---|
| 99 | protected String extension_file = null;
|
---|
| 100 |
|
---|
| 101 | /** The various sizes for the screen layout*/
|
---|
| 102 | static protected Dimension MIN_SIZE = new Dimension( 90, 90);
|
---|
| 103 | static protected Dimension LIST_SIZE = new Dimension(200, 450);
|
---|
| 104 | static protected Dimension LOGPANE_SIZE = new Dimension (800,450);
|
---|
| 105 | static public int left_padding = 5;
|
---|
| 106 | public String fileSeparator = File.separator;
|
---|
| 107 |
|
---|
| 108 | protected Element extFileRootElement = null;
|
---|
| 109 | protected HashMap extensions = null;
|
---|
| 110 | protected HashMap extClasses = null;
|
---|
| 111 | protected Properties dependencies = new Properties();
|
---|
| 112 | protected JPanel extPanel = new JPanel();
|
---|
| 113 | protected JSplitPane extensionListContainer = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
---|
| 114 |
|
---|
| 115 | public ExtPane() {
|
---|
| 116 |
|
---|
| 117 | String gsdl3Home = GAI.getGSDL3Home();
|
---|
| 118 |
|
---|
| 119 | file_location = gsdl3Home+fileSeparator+"ext"+fileSeparator+"extension_project_list.xml";
|
---|
| 120 |
|
---|
| 121 | extFileRootElement = getRootElement();
|
---|
| 122 |
|
---|
| 123 | //Load the steps that have already been performed (used for dependencies)
|
---|
| 124 | loadExtensionInformation();
|
---|
| 125 |
|
---|
| 126 | // create all the necessary panes
|
---|
| 127 | control_pane = new JPanel();
|
---|
| 128 | button_pane = new JPanel();
|
---|
| 129 | current_description_pane = new JPanel();
|
---|
| 130 | extensionContentHeaderPane = new JPanel();
|
---|
| 131 | extensionInformation = new HashMap();
|
---|
| 132 |
|
---|
| 133 | // Extension_Pane
|
---|
| 134 | main_ext_pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
---|
| 135 | main_ext_pane.setPreferredSize(LOGPANE_SIZE);
|
---|
| 136 |
|
---|
| 137 | // Extension_TextArea
|
---|
| 138 | description_textarea = new JTextArea();
|
---|
| 139 | description_textarea.setEditable(false);
|
---|
| 140 | description_textarea.setLineWrap(true);
|
---|
| 141 | description_textarea.setWrapStyleWord(true);
|
---|
| 142 | description_textarea.setMargin(new Insets(0,left_padding,0,0));
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | public void loadExtensionInformation()
|
---|
| 146 | {
|
---|
| 147 | Element[] extensionElements = ExtXMLHelper.getMultipleChildElements(extFileRootElement, ExtXMLHelper.EXTENSION, true);
|
---|
| 148 | if(extensionElements != null){
|
---|
| 149 | extensions = new HashMap();
|
---|
| 150 |
|
---|
| 151 | for(int i = 0; i < extensionElements.length; i++){
|
---|
| 152 | ExtensionInformation ei = new ExtensionInformation(extensionElements[i], extFileRootElement.getAttribute("baseURL"));
|
---|
| 153 | extensions.put(ei.getName(), ei);
|
---|
| 154 | }
|
---|
| 155 | }
|
---|
| 156 | else{
|
---|
| 157 | System.err.println("There are no <" + ExtXMLHelper.EXTENSION + "> elements in the extension_project_list.xml file in the extension directory");
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | /** This method is callsed to actually layout the components.*/
|
---|
| 162 | public void display() {
|
---|
| 163 |
|
---|
| 164 | load_Admin_UI();
|
---|
| 165 | HashMap projectNameMap = getProjectList();
|
---|
| 166 | Set s = projectNameMap.keySet();
|
---|
| 167 | Iterator it = s.iterator();
|
---|
| 168 | int i = 0;
|
---|
| 169 |
|
---|
| 170 | while(it.hasNext()){
|
---|
| 171 | String projectNameGroup = (String)it.next();
|
---|
| 172 | ArrayList alist = (ArrayList)projectNameMap.get(projectNameGroup);
|
---|
| 173 | DefaultMutableTreeNode projecti = new DefaultMutableTreeNode (projectNameGroup);
|
---|
| 174 |
|
---|
| 175 | for (int j = 0; j< alist.size(); j++){
|
---|
| 176 | String projectName = (String)alist.get(j);
|
---|
| 177 | DefaultMutableTreeNode projectNameGroupj = new DefaultMutableTreeNode (projectName);
|
---|
| 178 | projecti.add(projectNameGroupj);
|
---|
| 179 | }
|
---|
| 180 | top.add(projecti);
|
---|
| 181 | i++;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | extensionTreeList = new JTree(top);
|
---|
| 185 | extensionTreeList.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
---|
| 186 | extensionTreeList.addTreeSelectionListener(new ConfTreeListener());
|
---|
| 187 | extensionTreeList.addMouseListener(new ConfTreeMouseListener());
|
---|
| 188 |
|
---|
| 189 | // extensionList_Pane
|
---|
| 190 | extensionList_pane = new JPanel();
|
---|
| 191 | extensionList_pane.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
| 192 | extensionList_label = new JLabel();
|
---|
| 193 | extensionList_label.setOpaque(true);
|
---|
| 194 | extensionList_label.setBackground(Configuration.getColor("coloring.workspace_heading_background"));
|
---|
| 195 | extensionList_label.setForeground(Configuration.getColor("coloring.workspace_heading_foreground"));
|
---|
| 196 | extensionList_label.setText("Available Extensions");
|
---|
| 197 | extensionList_label.setBorder(BorderFactory.createEmptyBorder(0, left_padding, 0, 0));
|
---|
| 198 | // extensionContent_Pane
|
---|
| 199 | extensionContent_pane = new JPanel();
|
---|
| 200 | extensionContent_pane.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
| 201 | extensionContent_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
|
---|
| 202 | extensionContent_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
|
---|
| 203 |
|
---|
| 204 | extensionContent_label = new JLabel();
|
---|
| 205 | extensionContent_label.setBorder(BorderFactory.createEmptyBorder(0, left_padding, 0, 0));
|
---|
| 206 | extensionContent_label.setOpaque(false);
|
---|
| 207 | extensionContent_label.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
|
---|
| 208 | extensionContent_label.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
|
---|
| 209 | extensionContent_label.setText("Extension Content");
|
---|
| 210 |
|
---|
| 211 | // Layout Components
|
---|
| 212 | extensionList_pane.setLayout(new BorderLayout());
|
---|
| 213 | extensionList_pane.add(extensionTreeList, BorderLayout.CENTER);
|
---|
| 214 | extensionList_pane.add(extensionList_label, BorderLayout.NORTH);
|
---|
| 215 | extensionListContainer.add(extensionList_pane, JSplitPane.TOP);
|
---|
| 216 | extensionListContainer.setDividerLocation(600);
|
---|
| 217 |
|
---|
| 218 | extPanel.setLayout(new BorderLayout());
|
---|
| 219 | ExtensionInformation.setExtPane(extPanel);
|
---|
| 220 |
|
---|
| 221 | JScrollPane extScrollPane = new JScrollPane(extPanel);
|
---|
| 222 |
|
---|
| 223 | extensionContent_pane.setLayout(new BorderLayout());
|
---|
| 224 | //extensionContent_pane.add(main_content_pane,BorderLayout.SOUTH);
|
---|
| 225 | extensionContent_pane.add(extensionContent_label, BorderLayout.NORTH);
|
---|
| 226 | extensionContent_pane.add(extScrollPane, BorderLayout.CENTER);
|
---|
| 227 |
|
---|
| 228 | main_ext_pane.add(extensionListContainer, JSplitPane.LEFT);
|
---|
| 229 | main_ext_pane.add(extensionContent_pane, JSplitPane.RIGHT);
|
---|
| 230 | main_ext_pane.setDividerLocation(LIST_SIZE.width);
|
---|
| 231 |
|
---|
| 232 | this.setLayout(new BorderLayout());
|
---|
| 233 | this.add(main_ext_pane, BorderLayout.CENTER);
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 |
|
---|
| 237 | protected Element getRootElement(){
|
---|
| 238 |
|
---|
| 239 | Element rootNode = null;
|
---|
| 240 |
|
---|
| 241 | try{
|
---|
| 242 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
|
---|
| 243 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
|
---|
| 244 | Document doc = docBuilder.newDocument();
|
---|
| 245 | doc = docBuilder.parse (new File(file_location));
|
---|
| 246 | rootNode = doc.getDocumentElement();
|
---|
| 247 | return rootNode;
|
---|
| 248 |
|
---|
| 249 | }catch (Exception e) {
|
---|
| 250 | e.printStackTrace();
|
---|
| 251 | return null;
|
---|
| 252 | }
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | protected HashMap getProjectList(){
|
---|
| 256 |
|
---|
| 257 | HashMap projectGroupMap = new HashMap();
|
---|
| 258 | Element rootNode = extFileRootElement;
|
---|
| 259 | NodeList projectList = rootNode.getElementsByTagName(ExtXMLHelper.EXTENSION);
|
---|
| 260 |
|
---|
| 261 | for(int i = 0; i<projectList.getLength(); i++){
|
---|
| 262 |
|
---|
| 263 | Element projectNode = (Element)projectList.item(i);
|
---|
| 264 | NodeList nameList = projectNode.getElementsByTagName(ExtXMLHelper.NAME);
|
---|
| 265 | String name = nameList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 266 |
|
---|
| 267 | NodeList groupList = projectNode.getElementsByTagName(ExtXMLHelper.GROUP);
|
---|
| 268 | String group = groupList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 269 |
|
---|
| 270 | if(projectGroupMap.containsKey(group)){
|
---|
| 271 | ArrayList alist = (ArrayList)projectGroupMap.get(group);
|
---|
| 272 | alist.add(name);
|
---|
| 273 | projectGroupMap.put(group, alist);
|
---|
| 274 | }
|
---|
| 275 | else{
|
---|
| 276 | ArrayList alist = new ArrayList();
|
---|
| 277 | alist.add(name);
|
---|
| 278 | projectGroupMap.put(group, alist);
|
---|
| 279 | }
|
---|
| 280 | }
|
---|
| 281 | return projectGroupMap;
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 | protected class ConfTreeMouseListener implements MouseListener
|
---|
| 285 | {
|
---|
| 286 | public void mouseClicked(MouseEvent e)
|
---|
| 287 | {
|
---|
| 288 | Object comp = extensionTreeList.getLastSelectedPathComponent();
|
---|
| 289 | if(comp == null){
|
---|
| 290 | return;
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | String option = comp.toString();
|
---|
| 294 | if(option == null){
|
---|
| 295 | return;
|
---|
| 296 | }
|
---|
| 297 |
|
---|
| 298 | ExtensionInformation info = (ExtensionInformation)extensions.get(option);
|
---|
| 299 |
|
---|
| 300 | if(info != null){
|
---|
| 301 | extPanel.removeAll();
|
---|
| 302 |
|
---|
| 303 | JTextArea descArea = new JTextArea();
|
---|
| 304 | descArea.setText(info.getDescription());
|
---|
| 305 | descArea.setEditable(false);
|
---|
| 306 | descArea.setLineWrap(true);
|
---|
| 307 | descArea.setWrapStyleWord(true);
|
---|
| 308 |
|
---|
| 309 | //JEditorPane descArea = new JEditorPane("text/plain" info.getDescription());
|
---|
| 310 | //descArea.setEditable(false);
|
---|
| 311 |
|
---|
| 312 | extPanel.add(descArea, BorderLayout.CENTER);
|
---|
| 313 | extPanel.revalidate();
|
---|
| 314 | extPanel.repaint();
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | public void mouseEntered(MouseEvent e){}
|
---|
| 319 | public void mouseExited(MouseEvent e){}
|
---|
| 320 | public void mousePressed(MouseEvent e){}
|
---|
| 321 | public void mouseReleased(MouseEvent e){}
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | protected class ConfTreeListener implements TreeSelectionListener{
|
---|
| 325 |
|
---|
| 326 | public void valueChanged (TreeSelectionEvent e){
|
---|
| 327 |
|
---|
| 328 | String option = new String();
|
---|
| 329 |
|
---|
| 330 | try{
|
---|
| 331 | option = extensionTreeList.getLastSelectedPathComponent().toString();
|
---|
| 332 | }catch(Exception ex){
|
---|
| 333 |
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | if(extensionInformation.containsKey(option)){
|
---|
| 337 |
|
---|
| 338 | try{
|
---|
| 339 | extensionListContainer.setBottomComponent(getProjectButtonPane(option));
|
---|
| 340 | extensionListContainer.setDividerLocation(250);
|
---|
| 341 |
|
---|
| 342 | extensionContent_label.setText(option);
|
---|
| 343 | }
|
---|
| 344 | catch(Exception ex){
|
---|
| 345 | ex.printStackTrace();
|
---|
| 346 | description_textarea.setText("");
|
---|
| 347 | description_textarea.append("Sorry, this extension is not available!");
|
---|
| 348 | extensionContent_pane.add(description_content, BorderLayout.CENTER);
|
---|
| 349 | extensionContent_pane.validate();
|
---|
| 350 | extensionContent_pane.repaint();
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
| 353 | else{
|
---|
| 354 | if(control_pane.getComponentCount()>0){
|
---|
| 355 | //System.out.println("remove");
|
---|
| 356 | control_pane.remove(0);
|
---|
| 357 | control_pane.revalidate();
|
---|
| 358 | control_pane.repaint();
|
---|
| 359 | control_pane.add(new JPanel());
|
---|
| 360 | control_pane.revalidate();
|
---|
| 361 | control_pane.repaint();
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | if(extensionContent_pane.getComponentCount()>0){
|
---|
| 365 |
|
---|
| 366 | extensionContent_label.setText("Extension Content");
|
---|
| 367 | //extensionContent_pane.remove(2);
|
---|
| 368 | //extensionContent_pane.revalidate();
|
---|
| 369 | //extensionContent_pane.repaint();
|
---|
| 370 |
|
---|
| 371 |
|
---|
| 372 | //JTextArea ja= new JTextArea();
|
---|
| 373 | //JScrollPane jp = new JScrollPane(ja);
|
---|
| 374 | //extensionContent_pane.add(jp);
|
---|
| 375 | //extensionContent_pane.revalidate();
|
---|
| 376 | //extensionContent_pane.repaint();
|
---|
| 377 | //xxxxx
|
---|
| 378 | }
|
---|
| 379 | }
|
---|
| 380 | }
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | public String loadDescription(String className){
|
---|
| 384 |
|
---|
| 385 | String description = "";
|
---|
| 386 | Element rootNode = extFileRootElement;
|
---|
| 387 | NodeList projectNodeList = rootNode.getElementsByTagName(ExtXMLHelper.EXTENSION);
|
---|
| 388 |
|
---|
| 389 | for(int i = 0; i < projectNodeList.getLength(); i++){
|
---|
| 390 |
|
---|
| 391 | Element projectNode = (Element)projectNodeList.item(i);
|
---|
| 392 | NodeList nameNodeList = projectNode.getElementsByTagName(ExtXMLHelper.NAME);
|
---|
| 393 | String name = nameNodeList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 394 |
|
---|
| 395 | if(name.equals(className)){
|
---|
| 396 | NodeList descriptionNodeList = projectNode.getElementsByTagName(ExtXMLHelper.DESCRIPTION);
|
---|
| 397 | description = descriptionNodeList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 398 | }
|
---|
| 399 | }
|
---|
| 400 | return description;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | public void load_Admin_UI(){
|
---|
| 404 |
|
---|
| 405 | Element rootNode = extFileRootElement;
|
---|
| 406 |
|
---|
| 407 | NodeList projectList = rootNode.getElementsByTagName(ExtXMLHelper.EXTENSION);
|
---|
| 408 |
|
---|
| 409 | for(int i = 0; i < projectList.getLength(); i++){
|
---|
| 410 |
|
---|
| 411 | Element projectNode = (Element)projectList.item(i);
|
---|
| 412 | ArrayList alist = new ArrayList();
|
---|
| 413 | NodeList nameList = projectNode.getElementsByTagName(ExtXMLHelper.NAME);
|
---|
| 414 | String name = nameList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 415 |
|
---|
| 416 | NodeList uiList = projectNode.getElementsByTagName(ExtXMLHelper.BASE_EXT);
|
---|
| 417 | String admin_ui = uiList.item(0).getChildNodes().item(0).getNodeValue();
|
---|
| 418 |
|
---|
| 419 | //Maybe recode this? //xxxxx
|
---|
| 420 | try{
|
---|
| 421 | extensionInformation.put(name, alist);
|
---|
| 422 | }catch (Exception ex){
|
---|
| 423 | ex.printStackTrace();
|
---|
| 424 | }
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 |
|
---|
| 428 | public static void updateButtonPane(JPanel pane){
|
---|
| 429 | control_pane.remove(0);
|
---|
| 430 | control_pane.revalidate();
|
---|
| 431 | control_pane.repaint();
|
---|
| 432 | control_pane.add(pane);
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | public static void updateExtensionContentPane(){
|
---|
| 436 | CardLayout cl = (CardLayout)( current_description_pane.getLayout());
|
---|
| 437 | cl.next(current_description_pane);
|
---|
| 438 |
|
---|
| 439 | }
|
---|
| 440 |
|
---|
| 441 | public static boolean deleteDir(File dir) {
|
---|
| 442 |
|
---|
| 443 | if (dir.isDirectory()) {
|
---|
| 444 | String[] children = dir.list();
|
---|
| 445 | for (int i=0; i<children.length; i++) {
|
---|
| 446 | boolean success = deleteDir(new File(dir, children[i]));
|
---|
| 447 | if (!success) {
|
---|
| 448 | return false;
|
---|
| 449 | }
|
---|
| 450 | }
|
---|
| 451 | }
|
---|
| 452 | return dir.delete();
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 |
|
---|
| 456 |
|
---|
| 457 | /*
|
---|
| 458 | private void updateStatus(String project_name, String action){
|
---|
| 459 |
|
---|
| 460 | try{
|
---|
| 461 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
|
---|
| 462 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
|
---|
| 463 | Document doc = docBuilder.newDocument();
|
---|
| 464 | Element root = doc.createElement(extension_status_root);
|
---|
| 465 |
|
---|
| 466 | boolean fileExist = extension_status_file.exists();
|
---|
| 467 |
|
---|
| 468 | if(!fileExist){
|
---|
| 469 | extension_status_file = new File (extension_file);
|
---|
| 470 | root = doc.createElement(extension_status_root);
|
---|
| 471 | }
|
---|
| 472 | else{
|
---|
| 473 | doc = docBuilder.parse (extension_status_file);
|
---|
| 474 | root = doc.getDocumentElement();
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 |
|
---|
| 478 | TransformerFactory tf = TransformerFactory.newInstance();
|
---|
| 479 | Transformer transformer= tf.newTransformer();
|
---|
| 480 | DOMSource source= new DOMSource(root);
|
---|
| 481 | transformer.setOutputProperty(OutputKeys.INDENT,"yes");
|
---|
| 482 |
|
---|
| 483 | Writer pwx= new BufferedWriter(new OutputStreamWriter(new FileOutputStream(extension_status_file),"UTF-8"));
|
---|
| 484 | StreamResult result= new StreamResult(pwx);
|
---|
| 485 | transformer.transform(source,result);
|
---|
| 486 | pwx.close();
|
---|
| 487 |
|
---|
| 488 | root = null;
|
---|
| 489 | docBuilderFactory = null;
|
---|
| 490 | docBuilder = null;
|
---|
| 491 | doc = null;
|
---|
| 492 |
|
---|
| 493 | }catch (Exception e) {
|
---|
| 494 | System.out.println(e);
|
---|
| 495 | }
|
---|
| 496 | }*/
|
---|
| 497 |
|
---|
| 498 | public JPanel getProjectButtonPane(String projectName){
|
---|
| 499 |
|
---|
| 500 | String option = extensionTreeList.getLastSelectedPathComponent().toString();
|
---|
| 501 | JPanel buttonPane = new JPanel();
|
---|
| 502 |
|
---|
| 503 | ExtensionInformation extension = (ExtensionInformation)extensions.get(projectName);
|
---|
| 504 |
|
---|
| 505 | String gsdl3ExtHome = GAI.getGSDL3ExtensionHome();
|
---|
| 506 |
|
---|
| 507 | JButton[] buttons = extension.getSequenceList().getButtons();
|
---|
| 508 |
|
---|
| 509 | GridLayout gl = new GridLayout(buttons.length, 1);
|
---|
| 510 | gl.setVgap(5);
|
---|
| 511 | buttonPane.setLayout(gl);
|
---|
| 512 |
|
---|
| 513 | for(int j = 0; j < buttons.length; j++){
|
---|
| 514 | buttonPane.add(buttons[j]);
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | extension.getSequenceList().updateButtons();
|
---|
| 518 |
|
---|
| 519 | return buttonPane;
|
---|
| 520 | }
|
---|
| 521 | } |
---|