From: <ox-...@us...> - 2002-08-10 01:13:05
|
Update of /cvsroot/sheets/sheets In directory usw-pr-cvs1:/tmp/cvs-serv8310 Modified Files: Sheets.sheets Log Message: Partially completed the current_directory export feature, and a more dirty/clean file check. Also fixed some random bugs. Index: Sheets.sheets =================================================================== RCS file: /cvsroot/sheets/sheets/Sheets.sheets,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Sheets.sheets 23 Jul 2002 02:05:21 -0000 1.14 --- Sheets.sheets 10 Aug 2002 01:12:59 -0000 1.15 *************** *** 5094,5100 **** comp.packageName = pkg; if (comp instanceof JavaClassFragment && comp.trueName.length == 1) { beforeClass = false; extraFrags++; ! classes.addElement(comp); } else if (comp instanceof JavaFileHeaderFragment) { String newPkg = comp.trueNameString(); --- 5094,5128 ---- comp.packageName = pkg; if (comp instanceof JavaClassFragment && comp.trueName.length == 1) { + JavaClassFragment classComp = (JavaClassFragment)comp; beforeClass = false; extraFrags++; ! classes.addElement(classComp); ! // Fix export location of classes that are exported to fixed locations ! if (exportOptions == ImportTask.EXPORT_CURRENT_LOCATION) { ! String path = classComp.reverseMap(file.getAbsolutePath()); ! if (path == null) { ! Console.batchedDisplay("Cannot export " + file + " to its current location due to the existing filename or directory structure. This file will be exported relative to the project directory."); ! } else { ! // make path relative to project if possible ! try { ! path = new File(path).getCanonicalPath(); ! String root = Project.findProject(project).getRootFrag().getRoot(); ! root = new File(root).getCanonicalPath(); ! if (path.startsWith(root)) ! path = path.substring(root.length(), path.length()); ! } catch (IOException e) { ! // leave path unmodified ! } ! classComp.setExportLocation(path); ! } ! } ! // Don't bother exporting imported classes if the location is the same ! try { ! if (classComp.getExportLocation(Project.findProject(project)).getCanonicalFile().equals(file.getCanonicalFile())) { ! classComp.classDirty = false; ! } ! } catch (IOException e) { ! // guess the class is dirty... ! } } else if (comp instanceof JavaFileHeaderFragment) { String newPkg = comp.trueNameString(); *************** *** 5493,5496 **** --- 5521,5528 ---- wlott:2628 rgs:7510 + schin:526 + schin:529 + schin:528 + schin:527 nkramer:698 rgs:13254 *************** *** 5564,5580 **** return; ! StringBuffer fileName = new StringBuffer(); ! if (!getProject().getRootFrag().getRoot().equals("")) { ! fileName.append(getProject().getRootFrag().getRoot()); ! fileName.append(File.separatorChar); ! } ! if (!packageName.equals(ANONYMOUS_PACKAGE)) { ! fileName.append(StringSplitter.join(StringSplitter.split(packageName, '.'), File.separatorChar)); ! fileName.append(File.separatorChar); ! } ! fileName.append(trueNameString()); ! fileName.append(".java"); ! ! ExportedFile file = new ExportedFile(this, new File(fileName.toString())); boolean packageWritten = false; --- 5596,5600 ---- return; ! ExportedFile file = new ExportedFile(this, getExportLocation(getProject())); boolean packageWritten = false; *************** *** 7711,7715 **** oldWindow.update(); } else if (window != oldWindow) { ! Console.error("Multi-window move not implemented"); } else if (window.getSelection() != null) { doFragmentMove(window, loc, doCopy); --- 7731,7737 ---- oldWindow.update(); } else if (window != oldWindow) { ! // This message comes up way too frequently and has been getting annoying ! // The entire drag-and-drop support needs to be revisited anyway... ! // Console.error("Multi-window move not implemented"); } else if (window.getSelection() != null) { doFragmentMove(window, loc, doCopy); *************** *** 56772,56776 **** } } ! comp.setClassDirty(); if (comp.trueName.length == 1) ExportMgr.registerExportable(comp); } --- 56794,56800 ---- } } ! // This is getting called too often. However, are there cases where we really ! // want to force the class to be dirty? ! // comp.setClassDirty(); if (comp.trueName.length == 1) ExportMgr.registerExportable(comp); } *************** *** 59059,59063 **** // True if the class or its members has changed since it was last saved. // (This is an export dirty bit, not a database dirty bit) ! private boolean JavaClassFragment.classDirty = true; object rgs:8173 pkg=org.browsecode.javaStuff --- 59083,59087 ---- // True if the class or its members has changed since it was last saved. // (This is an export dirty bit, not a database dirty bit) ! boolean JavaClassFragment.classDirty = true; object rgs:8173 pkg=org.browsecode.javaStuff *************** *** 71016,71019 **** --- 71040,71051 ---- public String defaultView () { return "full"; } }); + result.addElement(new ScalarAttribute("export-location", this) { + public String getValue() { + return exportLocation; + } + public void setValue(String value) { + exportLocation = value; + } + }); return result; } *************** *** 71169,71172 **** --- 71201,71206 ---- inheritListAttribute(old, "exports"); inheritListAttribute(old, "file-headers"); + if (old instanceof JavaClassFragment) + exportLocation = ((JavaClassFragment)old).exportLocation; } } *************** *** 75637,75640 **** --- 75671,75675 ---- if ((flags & 2) != 0) lastExportID = in.readReference(); + exportLocation = in.readUTF(); } object rgs2:128 *************** *** 75653,75656 **** --- 75688,75692 ---- if (!lastExportID.isNull()) out.writeReference(lastExportID); + out.writeUTF(exportLocation); } object rgs2:131 *************** *** 79465,79477 **** section text schin:399 public String FileImportCard.ImportItem.toString() { ! String filePath = file.getAbsolutePath(); ! if (rootImportItem != null) { ! String rootPath = rootImportItem.file.getAbsolutePath(); ! if (this == rootImportItem || filePath.equals(rootPath)) ! return "[Project Root] " + rootPath; ! if (filePath.startsWith(rootPath)) ! return filePath.substring(rootPath.length() + 1, filePath.length()); } - return filePath; } object schin:400 --- 79501,79518 ---- section text schin:399 public String FileImportCard.ImportItem.toString() { ! try { ! String filePath = file.getCanonicalPath(); ! if (rootImportItem != null) { ! String rootPath = rootImportItem.file.getCanonicalPath(); ! if (this == rootImportItem || filePath.equals(rootPath)) ! return "[Project Root] " + rootPath; ! if (filePath.startsWith(rootPath)) ! return filePath.substring(rootPath.length() + 1, filePath.length()); ! } ! return filePath; ! } catch (IOException e) { ! // possible exception from getCanonicalPath... default to getAbsolutePath ! return file.getAbsolutePath(); } } object schin:400 *************** *** 79618,79622 **** for (int i = 0; i < comps.length; i++) SentinelMgr.brandNewFragment(comps[i], project); ! Sheet sheet = new Sheet(State.getObjectDatabase(), file.getName(), "Fragments imported from " + file, exportOptions != NO_EXPORT ? ">classes" : null, comps); SentinelMgr.brandNewFragment(sheet, project); sheet.getContents().makeInteresting(); --- 79659,79663 ---- for (int i = 0; i < comps.length; i++) SentinelMgr.brandNewFragment(comps[i], project); ! Sheet sheet = new Sheet(State.getObjectDatabase(), file.getName(), "Fragments imported from " + file, exportOptions == NO_EXPORT ? null : ">classes", comps); SentinelMgr.brandNewFragment(sheet, project); sheet.getContents().makeInteresting(); *************** *** 80867,80870 **** --- 80908,80974 ---- } } + object schin:526 + pkg=org.browsecode.javaStuff + type=java + section text schin:526 + private String JavaClassFragment.exportLocation = ""; + object schin:527 + pkg=org.browsecode.javaStuff + type=java + section text schin:527 + // This routine can be used to programatically set the export location attribute + // When using this routine be careful to update the GUI display of the attribute + public void JavaClassFragment.setExportLocation (String exportLocation) + { + this.exportLocation = exportLocation; + } + object schin:528 + pkg=org.browsecode.javaStuff + type=java + section text schin:528 + // The location this exportable object will be exported to + // when the export routine is called + // We explicitly pass in the project so this method can be called before this object + // is added to a project. + public File JavaClassFragment.getExportLocation (Project project) + { + StringBuffer fileName = new StringBuffer(); + File basePath = new File(exportLocation); + if (basePath.isAbsolute()) { + fileName.append(exportLocation); + fileName.append(File.separatorChar); + } else if (!project.getRootFrag().getRoot().equals("")) { + basePath = new File(project.getRootFrag().getRoot(), exportLocation); + fileName.append(basePath.getPath()); + fileName.append(File.separatorChar); + } + + if (!packageName.equals(ANONYMOUS_PACKAGE)) { + fileName.append(StringSplitter.join(StringSplitter.split(packageName, '.'), File.separatorChar)); + fileName.append(File.separatorChar); + } + fileName.append(trueNameString()); + fileName.append(".java"); + return new File(fileName.toString()); + } + object schin:529 + pkg=org.browsecode.javaStuff + type=java + section text schin:529 + // This routine attempts to take a path string referring to this Java class, and + // strip off the package directories and file name. If there is not a match, this + // routine will return null; + public String JavaClassFragment.reverseMap(String path) { + StringBuffer fileName = new StringBuffer(); + if (!packageName.equals(ANONYMOUS_PACKAGE)) { + fileName.append(StringSplitter.join(StringSplitter.split(packageName, '.'), File.separatorChar)); + fileName.append(File.separatorChar); + } + fileName.append(trueNameString()); + if (path.endsWith(fileName.toString())) + return path.substring(path.length() - fileName.length()); + else + return null; + } object sjc:1 pkg=org.browsecode.sheets.dicer *************** *** 89247,89250 **** --- 89351,89355 ---- void JavaClassFragment.setClassDirty () { if (trueName.length > 1) { + // handle inner classes JavaClassFragment cls = JavaSentinel.getClass(ownersName(), this, false); if (cls != null) cls.setClassDirty(); *************** *** 98403,98406 **** --- 98508,98515 ---- wlott:2628 rgs:7510 + schin:526 + schin:529 + schin:528 + schin:527 nkramer:698 rgs:13254 |