[Bojangles-cvs] cvs: bojangles / MainWindow.java
Status: Alpha
Brought to you by:
nehresma
From: kai5263499 <boj...@li...> - 2002-10-04 21:05:11
|
kai5263499 Fri Oct 4 14:05:08 2002 EDT Modified files: /bojangles MainWindow.java Log: Cleaned up some things and started work on the file->open stuff... Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.36 bojangles/MainWindow.java:1.37 --- bojangles/MainWindow.java:1.36 Wed Oct 2 11:59:02 2002 +++ bojangles/MainWindow.java Fri Oct 4 14:05:06 2002 @@ -909,26 +909,40 @@ } private void loadXML() { - - JFileChooser fc = new JFileChooser(); - if(sdir != null) fc.setCurrentDirectory(sdir); - - int returnVal = fc.showSaveDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - sdir = file.getAbsoluteFile(); - - if (!file.exists()) { - String alertmsg = "File doesn't exist!"; - int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getName() + "\" does not exist!.",alertmsg,JOptionPane.OK_OPTION); - return; - } - xmlHandler.loadXML(file); - } else { - System.out.println("Load canceled"); - return; + try{ + JFileChooser fc = new JFileChooser(); + if(sdir != null) fc.setCurrentDirectory(sdir); + int returnVal = fc.showSaveDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + sdir = file.getAbsoluteFile(); + + if (!file.exists()) { + String alertmsg = "File doesn't exist!"; + int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getAbsolutePath() + "\" does not exist!.",alertmsg,JOptionPane.OK_OPTION); + return; + } + // Make a psudo document to create our main document from + Document tempdoc = new SAXReader().read(file.getAbsolutePath()); + List list = tempdoc.selectNodes("/"); + ListIterator li = list.listIterator(); + while (li.hasNext()) { + Node thinge = (Node)li.next(); + if(thingie.SelectSingleNode("/widget/class") == "container") { + //DIG! + } + else { + //add it... + } + } + } else { + System.out.println("Load canceled"); + return; + } + } + catch (Exception e) { + e.printStackTrace(); } - } public void initGUI() { |