Thread: [Bojangles-cvs] cvs: bojangles /xml XmlHandler.java
Status: Alpha
Brought to you by:
nehresma
From: nehresma <boj...@li...> - 2002-08-11 23:40:49
|
nehresma Sun Aug 11 16:40:48 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: fixed a bug when changing the name of a widget. i was using the wrong path in the XML document. Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.4 bojangles/xml/XmlHandler.java:1.5 --- bojangles/xml/XmlHandler.java:1.4 Thu Aug 8 18:00:53 2002 +++ bojangles/xml/XmlHandler.java Sun Aug 11 16:40:48 2002 @@ -104,7 +104,11 @@ n.setName(name); if (null != text) n.setText(text); - notifyListeners(MODIFY, path); + + if (newPath.equals(path)) + notifyListeners(MODIFY, path); + else + notifyListeners(MODIFY, newPath); } return newPath; } |
From: kai5263499 <boj...@li...> - 2002-08-14 14:51:18
|
kai5263499 Wed Aug 14 07:51:17 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: Added saveXML function that does just that (and requires a filename in a string to be passed to it). Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.5 bojangles/xml/XmlHandler.java:1.6 --- bojangles/xml/XmlHandler.java:1.5 Sun Aug 11 16:40:48 2002 +++ bojangles/xml/XmlHandler.java Wed Aug 14 07:51:16 2002 @@ -10,6 +10,7 @@ */ import java.lang.*; +import java.io.*; import java.util.*; import java.util.regex.*; import java.awt.event.*; @@ -171,6 +172,16 @@ List l = doc.selectNodes(path); if (null == l) return 0; return l.size(); + } + + public void saveXML(String of) { + try { + //File sfile = new File(of); + FileOutputStream outfile = new FileOutputStream(of); + XMLWriter saver = new XMLWriter(outfile); + saver.write(this.doc); + System.out.println("Slected file: \n" + of); + } catch (Exception e) { e.printStackTrace(); } } public void printXML() { |
From: kai5263499 <boj...@li...> - 2002-08-14 21:09:03
|
kai5263499 Wed Aug 14 14:09:02 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: Added overwrite prevention-checking... Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.6 bojangles/xml/XmlHandler.java:1.7 --- bojangles/xml/XmlHandler.java:1.6 Wed Aug 14 07:51:16 2002 +++ bojangles/xml/XmlHandler.java Wed Aug 14 14:09:02 2002 @@ -9,6 +9,7 @@ * @version 1.0 */ +import javax.swing.*; import java.lang.*; import java.io.*; import java.util.*; @@ -176,11 +177,21 @@ public void saveXML(String of) { try { - //File sfile = new File(of); + // Lets do some error checking, keep the user from hurting themselves. + File ckfile = new File(of); + if(ckfile.exists()) { + String suremsg = "Are you sure you want to overwrite " + of + " ?"; + int choice = JOptionPane.showConfirmDialog(null,"File will be overwritten.",suremsg,JOptionPane.YES_NO_OPTION); + if(choice == JOptionPane.NO_OPTION) { + JOptionPane.showMessageDialog(null,"Save aborted","Save status",JOptionPane.PLAIN_MESSAGE); + return; + } + } FileOutputStream outfile = new FileOutputStream(of); XMLWriter saver = new XMLWriter(outfile); saver.write(this.doc); - System.out.println("Slected file: \n" + of); + //String savemsg = "Saved " + of,"Save status"; + //JOptionPane.showMessageDialog(this, savemsg, JOptionPane.PLAIN_MESSAGE); } catch (Exception e) { e.printStackTrace(); } } |
From: nehresma <boj...@li...> - 2002-08-15 01:49:51
Attachments:
nehresma-20020814184950.txt
|
nehresma Wed Aug 14 18:49:50 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: * fix a bunch of formatting problems that i made a long time ago and never bothered to fix * removed some debugging code that is no longer needed |
From: nehresma <boj...@li...> - 2002-08-15 03:13:05
|
nehresma Wed Aug 14 20:13:03 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: removed legacy regex requirement (thanks dman for finding this) Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.9 bojangles/xml/XmlHandler.java:1.10 --- bojangles/xml/XmlHandler.java:1.9 Wed Aug 14 18:49:50 2002 +++ bojangles/xml/XmlHandler.java Wed Aug 14 20:13:03 2002 @@ -4,7 +4,6 @@ import java.lang.*; import java.io.*; import java.util.*; -import java.util.regex.*; import java.awt.event.*; import org.dom4j.*; import org.dom4j.io.*; |
From: kai5263499 <boj...@li...> - 2002-08-19 20:54:13
|
kai5263499 Mon Aug 19 13:54:11 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: Made printXML prettier and made a function out of saveXML (so it can be used in other things. Also laied the groundwork for opening premade XML files and started a prefrences system. Oh, and made saveXML remember the last dir you saved in (but only keeps it while you have the app open, hence the prefrences file...) -Wes Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.10 bojangles/xml/XmlHandler.java:1.11 --- bojangles/xml/XmlHandler.java:1.10 Wed Aug 14 20:13:03 2002 +++ bojangles/xml/XmlHandler.java Mon Aug 19 13:54:11 2002 @@ -21,6 +21,9 @@ doc = DocumentHelper.createDocument(); } + public void loadXML(File file) { + } + public void addProperty(String path, String name, String text) { if (null == path || path.equals("/")) { // need to actually throw and exception here and catch it up above @@ -166,7 +169,8 @@ public void saveXML(File of) { try { FileOutputStream outfile = new FileOutputStream(of); - XMLWriter saver = new XMLWriter(outfile); + OutputFormat format = OutputFormat.createPrettyPrint(); + XMLWriter saver = new XMLWriter(outfile, format); saver.write(this.doc); } catch (Exception e) { e.printStackTrace(); @@ -175,7 +179,8 @@ public void printXML() { try { - XMLWriter writer = new XMLWriter(System.out); + OutputFormat format = OutputFormat.createPrettyPrint(); + XMLWriter writer = new XMLWriter(System.out, format); writer.write(doc); } catch (Exception e) { e.printStackTrace(); |
From: nehresma <boj...@li...> - 2002-08-22 02:38:56
|
nehresma Wed Aug 21 19:38:55 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: removed the import of the swing classes. gui stuff should not go in the XmlHandler class. Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.11 bojangles/xml/XmlHandler.java:1.12 --- bojangles/xml/XmlHandler.java:1.11 Mon Aug 19 13:54:11 2002 +++ bojangles/xml/XmlHandler.java Wed Aug 21 19:38:54 2002 @@ -1,6 +1,5 @@ package bojangles.xml; -import javax.swing.*; import java.lang.*; import java.io.*; import java.util.*; |
From: kai5263499 <boj...@li...> - 2002-08-22 21:07:11
|
kai5263499 Thu Aug 22 14:07:10 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: Finished gzip saveing option, now i just need to let the user decide when and when not to use it. It also automagically adds a .gz to the end of a gzipped doc. Now to work on opening a document... Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.13 bojangles/xml/XmlHandler.java:1.14 --- bojangles/xml/XmlHandler.java:1.13 Thu Aug 22 06:43:27 2002 +++ bojangles/xml/XmlHandler.java Thu Aug 22 14:07:10 2002 @@ -176,22 +176,24 @@ public void saveXML(File of, boolean wantCompressed) { try { OutputFormat format = OutputFormat.createPrettyPrint(); - OutputStream outfileOrig = new FileOutputStream(of); - - if(wantCompressed) { - File nf = new File(of.getAbsolutePath() + of.getName() + ".gz"); + if(true) { + File nof = new File(of.getAbsolutePath() + ".gz"); + System.out.println(of.getAbsolutePath() + ".gz"); FileOutputStream newStream = new FileOutputStream(of); OutputStream outfile = new GZIPOutputStream(newStream); XMLWriter saver = new XMLWriter(outfile, format); saver.write(this.doc); - System.out.println("Compressed to: " + of.getAbsolutePath() + of.getName() + ".gz"); + // Must flush buffers + outfile.close(); } + else { - XMLWriter saverOrig = new XMLWriter(outfileOrig, format); - saverOrig.write(this.doc); + FileOutputStream outfile = new FileOutputStream(of); + XMLWriter saver = new XMLWriter(outfile, format); + saver.write(this.doc); + outfile.close(); } - - } + } catch (Exception e) { e.printStackTrace(); } |
From: kai5263499 <boj...@li...> - 2002-08-24 18:06:11
|
kai5263499 Sat Aug 24 11:06:11 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: Stuff I didn't commit Friday. It includes GZIP support and updated prefrences (although its still somewhat broken...). Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.14 bojangles/xml/XmlHandler.java:1.15 --- bojangles/xml/XmlHandler.java:1.14 Thu Aug 22 14:07:10 2002 +++ bojangles/xml/XmlHandler.java Sat Aug 24 11:06:10 2002 @@ -28,7 +28,9 @@ doc = DocumentHelper.createDocument(); } - public void loadXML(File file) { + public void loadXML(File file) { + doc = SAXReader().read(); + // OK, the XML is right, now we just need to update the GUI } public void addProperty(String path, String name, String text) { |
From: nehresma <boj...@li...> - 2002-08-25 00:35:09
|
nehresma Sat Aug 24 17:35:09 2002 EDT Modified files: /bojangles/xml XmlHandler.java Log: fix for SAXReader instantiation Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.16 bojangles/xml/XmlHandler.java:1.17 --- bojangles/xml/XmlHandler.java:1.16 Sat Aug 24 17:26:31 2002 +++ bojangles/xml/XmlHandler.java Sat Aug 24 17:35:08 2002 @@ -29,7 +29,11 @@ } public void loadXML(File file) { - //doc = new SAXReader().read(); + try { + doc = new SAXReader().read(file.getPath()); + } catch (DocumentException e) { + e.printStackTrace(); + } // OK, the XML is right, now we just need to update the GUI } |