package isorat;

import java.awt.*;
import javax.swing.*;
import java.io.*;


/** Invokes an XML parser on an XML document and displays
 *  the document in a JTree. Both the parser and the
 *  document can be specified by the user. The parser
 *  is specified by invoking the program with
 *  java -Djavax.xml.parsers.DocumentBuilderFactory=xxx XMLFrame
 *  If no parser is specified, the Apache Xerces parser is used.
 *  The XML document can be supplied on the command
 *  line, but if it is not given, a JFileChooser is used
 *  to interactively select the file of interest.
 */

public class ISOFrame extends JFrame {
  public static void main(String[] args) {
    /*String jaxpPropertyName =
      "javax.xml.parsers.DocumentBuilderFactory";
    // Pass the parser factory in on the command line with
    // -D to override the use of the Apache parser.
    if (System.getProperty(jaxpPropertyName) == null) {
      String apacheXercesPropertyValue =
        "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
      System.setProperty(jaxpPropertyName,
                         apacheXercesPropertyValue);
    }*/
    String filename;
    if (args.length > 0) {
      filename = args[0];
    } else {
      String[] extensions = { "xml", "tld" };
     // WindowUtilities.setNativeLookAndFeel();
      filename = ExtensionFileFilter.getFileName(".","XML Files",extensions);
      if (filename == null) {
        filename = "/home/ricard/Ricard.xml";
      }
    }
    new ISOFrame(filename);
  }

  public ISOFrame(String filename) {
  
      try {
      //WindowUtilities.setNativeLookAndFeel();
  
        
        
        JTree tree = new XMLTree(filename);
      JTabbedPane tabbedPane = new JTabbedPane();
                    
        
      JFrame frame = new JFrame("ISO 17799 Risk Analisys Tool");
      JPanel configuration_mainpanel= new JPanel();
      JPanel configuration_rightpanel= new JPanel();
      JPanel reportpanel= new JPanel();
      JTextPane configuration_rightpanel_text=new JTextPane();
 
     configuration_rightpanel.add(new JTextPane());
      configuration_rightpanel.add(new JButton("Guardar"));
    
     
      
         
    //  frame.addWindowListener(new ExitListener());
      
    Container content = frame.getContentPane();
    configuration_mainpanel.add(new JScrollPane(tree));
    configuration_mainpanel.add(configuration_rightpanel);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setLeftComponent(configuration_mainpanel);
        splitPane.setRightComponent(configuration_rightpanel);
    
    tabbedPane.addTab("Configuración", null,splitPane); //tooltip text
     tabbedPane.addTab("Informe", null,reportpanel); //tooltip text
    
    
    
    content.add(tabbedPane);
      
     // content.add(new JPanel());
// content.add(label);

   
    // content.add(new JSCrollPane());
      //content.add(frame);
     // content.add(label);
      frame.pack();
      frame.setVisible(true);
    } catch(IOException ioe) {
      System.out.println("Error creating tree: " + ioe);
    }
  }
  
  
  
}