From: <ox-...@us...> - 2003-04-19 01:31:32
|
Update of /cvsroot/sheets/sheets In directory sc8-pr-cvs1:/tmp/cvs-serv28744 Modified Files: .sheetsrc Sheets.sheets todo.txt Log Message: Bugfixes/Enhancements: * Improved DocParser error reporting (so that there is less spamming on import) * Improved export management so that multi-class files are not re-exported in part or whole until one of the classes is touched * Fixed NPE on navigating with fragments currently being edited (was showing up in TextualViewer.getSaveRect) Index: .sheetsrc =================================================================== RCS file: /cvsroot/sheets/sheets/.sheetsrc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** .sheetsrc 16 Apr 2003 19:12:32 -0000 1.9 --- .sheetsrc 19 Apr 2003 01:31:22 -0000 1.10 *************** *** 3,18 **** ########################################## ! set compile-command "ant.bat compile" ! set recompile-command "ant.bat clean" # Use these instead for *nix systems ! #set compile-command "./ant compile" ! #set recompile-command "./ant clean" #set windows-task-bar-height 0 #set screen-insets 0 108 0 0 ! set web-browser "explorer.exe" # Use this instead for *nix systems: ! #set web-browser "mozilla" set sheets-documentation-url "doc/reference.html" set java-documentation-url["java.*"] "http://java.sun.com/j2se/1.4/docs/api" --- 3,18 ---- ########################################## ! #set compile-command "ant.bat compile" ! #set recompile-command "ant.bat clean" # Use these instead for *nix systems ! set compile-command "./ant compile" ! set recompile-command "./ant clean" #set windows-task-bar-height 0 #set screen-insets 0 108 0 0 ! # set web-browser "explorer.exe" # Use this instead for *nix systems: ! set web-browser "mozilla" set sheets-documentation-url "doc/reference.html" set java-documentation-url["java.*"] "http://java.sun.com/j2se/1.4/docs/api" *************** *** 71,77 **** bind graph-java-hierarchy F3 bind make-java-vtable F4 - bind commit-container-edits F10 - bind abort-container-edits ctl-F10 - bind toggle-edit-mode F9 bind wrap-paragraph ALT-W bind extend-fragment ctl-X --- 71,74 ---- Index: Sheets.sheets =================================================================== RCS file: /cvsroot/sheets/sheets/Sheets.sheets,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Sheets.sheets 16 Apr 2003 19:12:33 -0000 1.37 --- Sheets.sheets 19 Apr 2003 01:31:23 -0000 1.38 *************** *** 5065,5068 **** --- 5065,5070 ---- // If the export location is the same as the location we imported from, then mark it as clean // Do this after adding to the sheet, so that inner class additions don't ripple + ArrayList classList = new ArrayList(); + boolean clean = false; for (int i = 0, j = 0; i < contents.length; i++) { if (contents[i] == null) *************** *** 5072,5076 **** --- 5074,5080 ---- JavaClassFragment classComp = (JavaClassFragment)contents[i]; try { + classList.add(classComp.getArchivalReference()); if (classComp.getExportLocation(Project.findProject(project)).getCanonicalFile().equals(file.getCanonicalFile())) { + clean = true; classComp.classDirty = false; } *************** *** 5080,5083 **** --- 5084,5096 ---- } } + + // If multiple classes are exported to the same file, we don't want to dirty them + // until one of them has been modified. Export Buddies helps us model this + // behavior. + if (clean && classList.size() > 1) { + ArchivalReference[] classArray = new ArchivalReference[classList.size()]; + classArray = (ArchivalReference[])classList.toArray(classArray); + JavaClassFragment.createExportBuddies(classArray); + } } object nkramer:653 *************** *** 5454,5457 **** --- 5467,5473 ---- rgs:8172 wlott:2643 + schin:1240 + schin:1242 + schin:1241 wlott:2664 schin:1229 *************** *** 31283,31286 **** --- 31299,31303 ---- import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; + import org.xml.sax.*; object nkramer:30597 pkg=org.browsecode.xml *************** *** 31291,31295 **** section exports nkramer:30597 nkramer:30603 - nkramer:30753 nkramer:30605 nkramer:30606 --- 31308,31311 ---- *************** *** 31325,31331 **** inputStream.close(); ! Fragment[] comps = parseString(fileContents); ! if (comps.length == 0) ! return; // add nothing // Any top-level fragment will get assigned an id by --- 31341,31356 ---- inputStream.close(); ! Fragment[] comps; ! try { ! DocParser parser = new DocParser(fileContents, null, true); ! comps = parser.fragments; ! } catch (SAXException e) { ! Console.batchedDisplay("Parse error while reading file: " + file); ! comps = new Fragment[] { new UnknownDocFragment(State.getObjectDatabase(), fileContents, null) }; ! } catch (WrongDocumentTypeException e) { ! // Just return for now (eventually need to propogate this exception ! // up, so the next Language Expert can try parsing the XML file ! return; ! } // Any top-level fragment will get assigned an id by *************** *** 31334,31338 **** for (int i = 0; i < comps.length; i++) DocHelper.assignIdsToChildren(null, comps[i], project, null); ! Fragment result; if (comps.length == 1 && comps[0] instanceof DocDocument) { --- 31359,31363 ---- for (int i = 0; i < comps.length; i++) DocHelper.assignIdsToChildren(null, comps[i], project, null); ! Fragment result; if (comps.length == 1 && comps[0] instanceof DocDocument) { *************** *** 31487,31490 **** --- 31512,31517 ---- schin:1233 schin:177 + schin:1239 + schin:1236 nkramer:30616 nkramer:31710 *************** *** 31521,31530 **** // The instant you construct the parser, it does the parsing. Get the // results out of the fragments field. ! public DocParser (String text, FragmentList links, boolean topLevel) { ! this.text = text; ! Document doc = textToXml(text, true); ! if (doc != null && doc.getDoctype() != null && DOCUMENT_V11.equals(doc.getDoctype().getPublicId())) ! // only parse the document if it is of the right type ! fragments = retrieveSubFragments(doc.getDocumentElement(), null, links, true); } object nkramer:30618 --- 31548,31553 ---- // The instant you construct the parser, it does the parsing. Get the // results out of the fragments field. ! public DocParser (String text, FragmentList links, boolean topLevel) throws SAXException, WrongDocumentTypeException { ! initAndParse(text, links, topLevel); } object nkramer:30618 *************** *** 32028,32047 **** return insertMenu; } - object nkramer:30753 - pkg=org.browsecode.xml - type=java - section text nkramer:30753 - // Will always return some fragments, even if there's a syntax error - private static Fragment[] DocExpert.parseString (String text) { - try { - DocParser parser = new DocParser(text, null, true); - Fragment[] comps = parser.fragments; - if (comps != null) - return comps; - } catch (RuntimeException e) { - Console.internalError(e); - } - return new Fragment[] { new UnknownDocFragment(State.getObjectDatabase(), text, null) }; - } object nkramer:30757 pkg=org.browsecode.xml --- 32051,32054 ---- *************** *** 33404,33409 **** // original, rather than the stuff that has been munged by the parser. // We'll do appropriate quoting, etc. on export. ! if (DocParser.textToXml(text, false) == null && !force) return false; replaceWith(new Fragment[]{new DocSource(getArchivalReference().getDatabase(), text, new Vector(0))}, extend, container); return true; --- 33411,33421 ---- // original, rather than the stuff that has been munged by the parser. // We'll do appropriate quoting, etc. on export. ! try { ! if (DocParser.textToXml(text, false) == null && !force) ! return false; ! } catch (SAXException e) { ! // Perhaps we should do something better, like highlight the error return false; + } replaceWith(new Fragment[]{new DocSource(getArchivalReference().getDatabase(), text, new Vector(0))}, extend, container); return true; *************** *** 33475,33487 **** FragmentList container) { ! DocParser parser = new DocParser(xmlText, old.getLinks(), false); ! Fragment[] comps = parser.fragments; ! if (comps == null && !force) { ! // Parse error; parser already explained it to the user ! return false; ! } else if (comps == null && force) { ! old.replaceWith(new UnknownDocFragment(State.getObjectDatabase(), xmlText, null), container); ! return true; ! } else { Vector extensions = null; if (extend) extensions = new Vector(); --- 33487,33493 ---- FragmentList container) { ! try { ! DocParser parser = new DocParser(xmlText, old.getLinks()); ! Fragment[] comps = parser.fragments; Vector extensions = null; if (extend) extensions = new Vector(); *************** *** 33496,33499 **** --- 33502,33515 ---- ((Fragment)extensions.elementAt(i)).startEditing(null, false); return true; + } catch (SAXException e) { + if (!force) { + // Perhaps we should do something better, like highlight the error + Console.internalError(e); + return false; + } else { + // Force the replacement anyway + old.replaceWith(new UnknownDocFragment(State.getObjectDatabase(), xmlText, null), container); + return true; + } } } *************** *** 34701,34710 **** (DocFragment comp, String text, ExportedFile file, int extraIndentation) { ! Document doc = DocParser.textToXml(text, false); ! expandLinks(doc.getDocumentElement(), doc, comp); ! String[] lines = StringSplitter.split(DocParser.xmlToText(doc), '\\n'); ! ! for (int i = 0; i < lines.length; i++) ! file.println(lines[i]); } object nkramer:31528 --- 34717,34731 ---- (DocFragment comp, String text, ExportedFile file, int extraIndentation) { ! try { ! Document doc = DocParser.textToXml(text, false); ! expandLinks(doc.getDocumentElement(), doc, comp); ! String[] lines = StringSplitter.split(DocParser.xmlToText(doc), '\\n'); ! ! for (int i = 0; i < lines.length; i++) ! file.println(lines[i]); ! } catch (SAXException e) { ! // Perhaps we should do something better, like highlight the error ! Console.internalError(e); ! } } object nkramer:31528 *************** *** 35552,35556 **** // Parses XML text, and returns the structure. // Need to handle the errors better... ! static Document DocParser.textToXml (String text, boolean topLevel) { if (!topLevel) { // enclose non-toplevel tags with a dummy element --- 35573,35577 ---- // Parses XML text, and returns the structure. // Need to handle the errors better... ! static Document DocParser.textToXml (String text, boolean topLevel) throws SAXException { if (!topLevel) { // enclose non-toplevel tags with a dummy element *************** *** 35559,35564 **** try { return builder.parse(new StringBufferInputStream(text)); ! } catch (Exception e) { ! Console.internalError(new Exception("Error while trying to parse: " + text, e)); } return null; --- 35580,35585 ---- try { return builder.parse(new StringBufferInputStream(text)); ! } catch (IOException e) { ! Console.internalError(new Exception("IO Error while trying to parse: " + text, e)); } return null; *************** *** 35578,35585 **** (DocFragment comp, Hashtable anchorTable) { ! Document doc = DocParser.textToXml(((Fragment) comp).toString(Fragment.FULL), false); ! boolean changed = convertLinksHelper(doc.getDocumentElement(), doc, comp, anchorTable); ! if (changed) ! ((Fragment) comp).replaceWith(DocParser.xmlToText(doc), true, false, null); } object nkramer:31714 --- 35599,35611 ---- (DocFragment comp, Hashtable anchorTable) { ! try { ! Document doc = DocParser.textToXml(((Fragment) comp).toString(Fragment.FULL), false); ! boolean changed = convertLinksHelper(doc.getDocumentElement(), doc, comp, anchorTable); ! if (changed) ! ((Fragment) comp).replaceWith(DocParser.xmlToText(doc), true, false, null); ! } catch (SAXException e) { ! // Perhaps we should do something better, like highlight the error ! Console.internalError(e); ! } } object nkramer:31714 *************** *** 51760,51763 **** --- 51786,51790 ---- { if (isValid()) return; + if (getViewPainter() == null) return; // can't validate if we have no painter setValid(true); *************** *** 56384,56390 **** // should always be called by height, but let's be explicit. comp.validate(); - if (comp == null) { - Console.internalError("comp == null, how'd that happen?"); - } if (last == null) { int newY = TOP_MARGIN; --- 56411,56414 ---- *************** *** 61554,61558 **** private void Viewer.updateAttrFlags () { attrFlagsHeight = 0; ! if (getViewPanel() == null || getViewPanel().painter == null) return; // because we can't get lineHeight if (!hasAttributes()) return; else if (getView().equals("summary")) --- 61578,61582 ---- private void Viewer.updateAttrFlags () { attrFlagsHeight = 0; ! if (getViewPainter() == null) return; // because we can't get lineHeight if (!hasAttributes()) return; else if (getView().equals("summary")) *************** *** 65136,65139 **** --- 65160,65164 ---- public void setValue(String value) { exportLocation = value; + stateChanged(); } }); *************** *** 69869,69872 **** --- 69894,69903 ---- lastExportID = in.readReference(); exportLocation = in.readUTF(); + int numBuddies = in.readInt(); + if (numBuddies > 0) { + exportBuddies = new ArchivalReference[numBuddies]; + for (int i=0; i<numBuddies; i++) + exportBuddies[i] = in.readReference(); + } } object rgs2:128 *************** *** 69886,69889 **** --- 69917,69927 ---- out.writeReference(lastExportID); out.writeUTF(exportLocation); + if (exportBuddies == null) { + out.writeInt(0); + } else { + out.writeInt(exportBuddies.length); + for (int i=0; i<exportBuddies.length; i++) + out.writeReference(exportBuddies[i]); + } } object rgs2:131 *************** *** 74906,74909 **** --- 74944,74948 ---- { this.exportLocation = exportLocation; + stateChanged(); } object schin:528 *************** *** 82572,82575 **** --- 82611,82691 ---- SwingUtilities.updateComponentTreeUI(Sheets.getRootFrame()); } + object schin:1236 + pkg=org.browsecode.xml + type=java + section text schin:1236 + // This constructor assumes this is not a top-level document, + // and hides the extra exception + public DocParser (String text, FragmentList links) throws SAXException { + try { + initAndParse(text, links, false); + } catch (WrongDocumentTypeException e) { + // cannot occur since it is not top-level + } + } + object schin:1237 + pkg=org.browsecode.xml + type=java + section text schin:1237 + class WrongDocumentTypeException extends Exception + section exports schin:1237 + schin:1238 + object schin:1238 + pkg=org.browsecode.xml + type=java + section text schin:1238 + public WrongDocumentTypeException(String expectedType) { + super("Wrong XML document type. Expected: " + expectedType); + } + object schin:1239 + pkg=org.browsecode.xml + type=java + section text schin:1239 + public void DocParser.initAndParse (String text, FragmentList links, boolean topLevel) throws SAXException, WrongDocumentTypeException { + this.text = text; + Document doc = textToXml(text, true); + if (doc == null) return; // some sort of fatal IOException + if (topLevel && doc.getDoctype() == null || !DOCUMENT_V11.equals(doc.getDoctype().getPublicId())) + // wrong document type + throw new WrongDocumentTypeException(DOCUMENT_V11); + fragments = retrieveSubFragments(doc.getDocumentElement(), null, links, true); + } + object schin:1240 + pkg=org.browsecode.javaStuff + type=java + section text schin:1240 + // A list of classes we are sharing file space with + // This list includes ourself, and is copied by reference to everyone on the list + private ArchivalReference[] JavaClassFragment.exportBuddies; + object schin:1241 + pkg=org.browsecode.javaStuff + type=java + section text schin:1241 + // This will clear the export buddies list, and make everyone dirty so they get + // exported to separate files + void JavaClassFragment.freeExportBuddies() { + ArchivalReference[] buddies = exportBuddies; + for (int i=0; i<buddies.length; i++) { + JavaClassFragment buddy = (JavaClassFragment)buddies[i].getObject(); + buddy.classDirty = true; + buddy.exportBuddies = null; + buddy.stateChanged(); + } + } + object schin:1242 + pkg=org.browsecode.javaStuff + type=java + section text schin:1242 + // This will setup a buddy list for multiple classes sharing a single export file. + // This is only used by import, and the moment the user edits one of these classes, + // they all get dirtied and exported to separate files + static void JavaClassFragment.createExportBuddies(ArchivalReference[] buddies) { + for (int i=0; i<buddies.length; i++) { + JavaClassFragment buddy = (JavaClassFragment)buddies[i].getObject(); + buddy.classDirty = false; + buddy.exportBuddies = buddies; + buddy.stateChanged(); + } + } object sjc:1 pkg=org.browsecode.sheets.dicer *************** *** 90905,90908 **** --- 91021,91026 ---- } else if (!classDirty) { classDirty = true; + if (exportBuddies != null) + freeExportBuddies(); } stateChanged(); *************** *** 100017,100020 **** --- 100135,100141 ---- rgs:8172 wlott:2643 + schin:1240 + schin:1242 + schin:1241 wlott:2664 schin:1229 *************** *** 100334,100338 **** nkramer:30597 nkramer:30603 - nkramer:30753 nkramer:30605 nkramer:30606 --- 100455,100458 ---- *************** *** 100350,100353 **** --- 100470,100476 ---- nkramer:30886 lightWeight:separator + schin:1237 + schin:1238 + lightWeight:separator nkramer:30613 nkramer:30614 *************** *** 100357,100360 **** --- 100480,100485 ---- schin:1233 schin:177 + schin:1239 + schin:1236 nkramer:30616 nkramer:31710 Index: todo.txt =================================================================== RCS file: /cvsroot/sheets/sheets/todo.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** todo.txt 1 Apr 2003 08:26:14 -0000 1.11 --- todo.txt 19 Apr 2003 01:31:25 -0000 1.12 *************** *** 1,8 **** Fixed in this snapshot so far: ! * * Stuff for Unix: - Should change ant to build (to avoid name collision with ant program) - Redrawing across X is very slow (even with anti-aliasing turned off). May be a simple fix (since most of the slowdown is in the main window) The default monocode font is awful. See if there is a better one for unix. --- 1,18 ---- Fixed in this snapshot so far: ! - ! ! * Work Release Stuff: ! Improve file management (see below) ! error reporting with ant prefixes? ! ! annoying bugs that should be fixed: ! report full error message for javac ! npe on TextualViewer.getSaveRect ! touch all classes in the package on package-header modification ! ! * Java completion: ! list throws clauses in external prototypes * Stuff for Unix: The default monocode font is awful. See if there is a better one for unix. |