From 591924ce533487a2b6a9cb7191c4b104553ba1dd Mon Sep 17 00:00:00 2001 From: Robert Greene Date: Sun, 11 Jul 2004 15:07:56 +0000 Subject: [PATCH] Preparing for internationalization as well as responding to the tighter Eclipse 3.0 code checks. --- .../applecommander/storage/Disk.java | 72 +++---- .../storage/FileEntryComparator.java | 3 +- .../applecommander/storage/FormattedDisk.java | 51 ++--- .../filters/AppleWorksDataBaseFileFilter.java | 38 ++-- .../AppleWorksSpreadSheetFileFilter.java | 30 +-- .../AppleWorksWordProcessorFileFilter.java | 182 +++++++++--------- .../storage/filters/ApplesoftFileFilter.java | 6 +- .../filters/AssemblySourceFileFilter.java | 12 +- .../storage/filters/BinaryFileFilter.java | 6 +- .../storage/filters/GraphicsFileFilter.java | 7 +- .../storage/filters/HexDumpFileFilter.java | 6 +- .../filters/IntegerBasicFileFilter.java | 42 ++-- .../storage/filters/PascalTextFileFilter.java | 4 +- .../storage/filters/TextFileFilter.java | 4 +- .../storage/os/cpm/CpmFileEntry.java | 15 +- .../storage/os/cpm/CpmFormatDisk.java | 43 +++-- .../storage/os/dos33/DosFileEntry.java | 82 ++++---- .../storage/os/dos33/DosFormatDisk.java | 90 +++++---- .../storage/os/dos33/OzDosFormatDisk.java | 9 +- .../storage/os/dos33/UniDosFormatDisk.java | 9 +- .../storage/os/pascal/PascalFileEntry.java | 22 ++- .../storage/os/pascal/PascalFormatDisk.java | 108 ++++++----- .../prodos/ProdosCommonDirectoryHeader.java | 1 - .../storage/os/prodos/ProdosFileEntry.java | 74 ++++--- .../storage/os/prodos/ProdosFormatDisk.java | 170 +++++++++------- .../os/prodos/ProdosSubdirectoryHeader.java | 1 - .../prodos/ProdosVolumeDirectoryHeader.java | 1 - .../storage/os/rdos/RdosFileEntry.java | 21 +- .../storage/os/rdos/RdosFormatDisk.java | 61 +++--- .../storage/physical/DosOrder.java | 13 +- .../storage/physical/NibbleOrder.java | 15 +- .../applecommander/ui/AppleCommander.java | 4 +- .../applecommander/ui/UserPreferences.java | 2 +- src/com/webcodepro/applecommander/ui/ac.java | 3 +- .../ui/swt/DiskExplorerTab.java | 39 ++-- .../applecommander/ui/swt/DiskInfoTab.java | 19 +- .../applecommander/ui/swt/DiskMapTab.java | 51 +++-- .../applecommander/ui/swt/DiskWindow.java | 10 +- .../ui/swt/FileViewerWindow.java | 94 +++++---- .../ui/swt/SwtAppleCommander.java | 59 +++--- .../filteradapter/ApplesoftFilterAdapter.java | 6 +- .../ui/swt/filteradapter/FilterAdapter.java | 16 +- .../filteradapter/GraphicsFilterAdapter.java | 4 +- .../applecommander/ui/swt/util/SwtUtil.java | 5 +- .../applecommander/ui/swt/wizard/Wizard.java | 5 +- .../comparedisks/CompareDisksResultsPane.java | 5 +- .../comparedisks/CompareDisksStartPane.java | 5 +- .../comparedisks/CompareDisksWizard.java | 4 +- .../compilefile/CompileFileStartPane.java | 7 +- .../swt/wizard/compilefile/CompileWizard.java | 4 +- .../wizard/diskimage/DiskImageFormatPane.java | 5 +- .../wizard/diskimage/DiskImageNamePane.java | 5 +- .../wizard/diskimage/DiskImageOrderPane.java | 5 +- .../wizard/diskimage/DiskImageSizePane.java | 5 +- .../swt/wizard/diskimage/DiskImageWizard.java | 4 +- .../AppleWorksWordProcessorPane.java | 5 +- .../exportfile/ExportFileDestinationPane.java | 7 +- .../exportfile/ExportFileStartPane.java | 5 +- .../exportfile/ExportGraphicsTypePane.java | 5 +- .../swt/wizard/exportfile/ExportWizard.java | 4 +- .../ImportSelectFilesWizardPane.java | 5 +- .../swt/wizard/importfile/ImportWizard.java | 4 +- .../applecommander/util/AppleUtil.java | 19 +- 63 files changed, 883 insertions(+), 735 deletions(-) diff --git a/src/com/webcodepro/applecommander/storage/Disk.java b/src/com/webcodepro/applecommander/storage/Disk.java index 555c2c5..b9be2ec 100644 --- a/src/com/webcodepro/applecommander/storage/Disk.java +++ b/src/com/webcodepro/applecommander/storage/Disk.java @@ -45,6 +45,7 @@ import com.webcodepro.applecommander.storage.physical.ProdosOrder; import com.webcodepro.applecommander.storage.physical.UniversalDiskImageLayout; import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.StreamUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Abstract representation of an Apple2 disk (floppy, 800k, hard disk). @@ -86,6 +87,7 @@ public class Disk { public static final int APPLE_32MB_HARDDISK = 33553920; // short one block! private static FilenameFilter[] filenameFilters; + private TextBundle textBundle = StorageBundle.getInstance(); private String filename; private boolean newImage = false; private ByteArrayImageLayout diskImageManager; @@ -108,22 +110,22 @@ public class Disk { */ private Disk() { filenameFilters = new FilenameFilter[] { - new FilenameFilter("All Emulator Images", - "*.do; *.dsk; *.po; *.nib; *.2mg; *.2img; *.hdv; *.do.gz; *.dsk.gz; *.po.gz; *.nib.gz; *.2mg.gz; *.2img.gz"), - new FilenameFilter("140K DOS Ordered Images (*.do, *.dsk)", - "*.do; *.dsk; *.do.gz; *.dsk.gz"), - new FilenameFilter("140K Nibbilized Images (*.nib)", - "*.nib; *.nib.gz"), - new FilenameFilter("140K ProDOS Ordered Images (*.po)", - "*.po; *.po.gz"), - new FilenameFilter("800K ProDOS Ordered Images (*.2mg, *.2img)", - "*.2mg; *.2img; *.2mg.gz, *.2img.gz"), - new FilenameFilter("ApplePC Hard Disk Images (*.hdv)", - "*.hdv"), - new FilenameFilter("All Compressed Images", - "*.do.gz; *.dsk.gz; *.po.gz; *.2mg.gz; *.2img.gz"), - new FilenameFilter("All Files", - "*.*") + new FilenameFilter(textBundle.get("Disk.AllImages"), //$NON-NLS-1$ + "*.do; *.dsk; *.po; *.nib; *.2mg; *.2img; *.hdv; *.do.gz; *.dsk.gz; *.po.gz; *.nib.gz; *.2mg.gz; *.2img.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.140kDosImages"), //$NON-NLS-1$ + "*.do; *.dsk; *.do.gz; *.dsk.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.140kNibbleImages"), //$NON-NLS-1$ + "*.nib; *.nib.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.140kProdosImages"), //$NON-NLS-1$ + "*.po; *.po.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.800kProdosImages"), //$NON-NLS-1$ + "*.2mg; *.2img; *.2mg.gz, *.2img.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.ApplePcImages"), //$NON-NLS-1$ + "*.hdv"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.CompressedImages"), //$NON-NLS-1$ + "*.do.gz; *.dsk.gz; *.po.gz; *.2mg.gz; *.2img.gz"), //$NON-NLS-1$ + new FilenameFilter(textBundle.get("Disk.AllFiles"), //$NON-NLS-1$ + "*.*") //$NON-NLS-1$ }; } @@ -237,9 +239,8 @@ public class Disk { public ByteArrayImageLayout getDiskImageManager() { if (imageOrder != null) { return imageOrder.getDiskImageManager(); - } else { - return diskImageManager; } + return diskImageManager; } /** @@ -261,17 +262,17 @@ public class Disk { * Indicate if this disk is GZIP compressed. */ public boolean isCompressed() { - return filename.toLowerCase().endsWith(".gz"); + return filename.toLowerCase().endsWith(".gz"); //$NON-NLS-1$ } /** * Indicate if this disk is ProDOS ordered (beginning with block 0). */ public boolean isProdosOrder() { - return filename.toLowerCase().endsWith(".po") - || filename.toLowerCase().endsWith(".po.gz") + return filename.toLowerCase().endsWith(".po") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".po.gz") //$NON-NLS-1$ || is2ImgOrder() - || filename.toLowerCase().endsWith(".hdv") + || filename.toLowerCase().endsWith(".hdv") //$NON-NLS-1$ || getPhysicalSize() >= APPLE_800KB_2IMG_DISK; } @@ -279,10 +280,10 @@ public class Disk { * Indicate if this disk is DOS ordered (T0,S0 - T35,S15). */ public boolean isDosOrder() { - return filename.toLowerCase().endsWith(".do") - || filename.toLowerCase().endsWith(".do.gz") - || filename.toLowerCase().endsWith(".dsk") - || filename.toLowerCase().endsWith(".dsk.gz"); + return filename.toLowerCase().endsWith(".do") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".do.gz") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".dsk") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".dsk.gz"); //$NON-NLS-1$ } /** @@ -290,18 +291,18 @@ public class Disk { * This is ProDOS ordered, but with a header on the disk. */ public boolean is2ImgOrder() { - return filename.toLowerCase().endsWith(".2img") - || filename.toLowerCase().endsWith(".2img.gz") - || filename.toLowerCase().endsWith(".2mg") - || filename.toLowerCase().endsWith(".2mg.gz"); + return filename.toLowerCase().endsWith(".2img") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".2img.gz") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".2mg") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".2mg.gz"); //$NON-NLS-1$ } /** * Indicate if this disk is a nibbilized disk.. */ public boolean isNibbleOrder() { - return filename.toLowerCase().endsWith(".nib") - || filename.toLowerCase().endsWith(".nib.gz"); + return filename.toLowerCase().endsWith(".nib") //$NON-NLS-1$ + || filename.toLowerCase().endsWith(".nib.gz"); //$NON-NLS-1$ } /** @@ -310,9 +311,8 @@ public class Disk { public int getPhysicalSize() { if (getDiskImageManager() != null) { return getDiskImageManager().getPhysicalSize(); - } else { - return getImageOrder().getPhysicalSize(); } + return getImageOrder().getPhysicalSize(); } /** @@ -325,7 +325,7 @@ public class Disk { protected void resizeDiskImage(int newSize) { if (newSize < getPhysicalSize()) { throw new IllegalArgumentException( - "Cannot resize a disk to be smaller than the current size!"); + textBundle.get("Disk.ResizeDiskError")); //$NON-NLS-1$ } byte[] newDiskImage = new byte[newSize]; byte[] oldDiskImage = imageOrder.getDiskImageManager().getDiskImage(); @@ -525,7 +525,7 @@ public class Disk { if (!is140KbDisk()) return false; byte[] block = readSector(0, 0x0d); String id = AppleUtil.getString(block, 0xe0, 4); - return "RDOS".equals(id); + return "RDOS".equals(id); //$NON-NLS-1$ } /** diff --git a/src/com/webcodepro/applecommander/storage/FileEntryComparator.java b/src/com/webcodepro/applecommander/storage/FileEntryComparator.java index 79852ec..66beddc 100644 --- a/src/com/webcodepro/applecommander/storage/FileEntryComparator.java +++ b/src/com/webcodepro/applecommander/storage/FileEntryComparator.java @@ -64,9 +64,8 @@ public class FileEntryComparator implements Comparator { int int1 = toInt(column1); int int2 = toInt(column2); return int1 - int2; - } else { - return column1.compareTo(column2); } + return column1.compareTo(column2); } /** diff --git a/src/com/webcodepro/applecommander/storage/FormattedDisk.java b/src/com/webcodepro/applecommander/storage/FormattedDisk.java index 591ba9d..756669a 100644 --- a/src/com/webcodepro/applecommander/storage/FormattedDisk.java +++ b/src/com/webcodepro/applecommander/storage/FormattedDisk.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.List; import com.webcodepro.applecommander.storage.physical.ImageOrder; +import com.webcodepro.applecommander.util.TextBundle; /** * Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk). @@ -35,6 +36,7 @@ import com.webcodepro.applecommander.storage.physical.ImageOrder; * @author Rob Greene */ public abstract class FormattedDisk extends Disk implements DirectoryEntry { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Use this inner class for label/value mappings in the disk info page. */ @@ -50,12 +52,14 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry { this.value = Integer.toString(value); } public DiskInformation(String label, Date value) { - SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + SimpleDateFormat dateFormat = new SimpleDateFormat( + StorageBundle.getInstance().get("DateFormat")); //$NON-NLS-1$ this.label = label; if (value != null) { this.value = dateFormat.format(value); } else { - this.value = "-None-"; + this.value = StorageBundle.getInstance() + .get("FormattedDisk.NullDate"); //$NON-NLS-1$ } } public String getLabel() { @@ -121,8 +125,6 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry { /** * Constructor for FormattedDisk. - * @param filename - * @param diskImage */ public FormattedDisk(String filename, ImageOrder imageOrder) { super(filename, imageOrder); @@ -180,19 +182,19 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry { */ public List getDiskInformation() { List list = new ArrayList(); - list.add(new DiskInformation("File Name", getFilename())); - list.add(new DiskInformation("Disk Name", getDiskName())); - list.add(new DiskInformation("Physical Size (bytes)", getPhysicalSize())); - list.add(new DiskInformation("Free Space (bytes)", getFreeSpace())); - list.add(new DiskInformation("Used Space (bytes)", getUsedSpace())); - list.add(new DiskInformation("Physical Size (KB)", getPhysicalSize() / 1024)); - list.add(new DiskInformation("Free Space (KB)", getFreeSpace() / 1024)); - list.add(new DiskInformation("Used Space (KB)", getUsedSpace() / 1024)); - list.add(new DiskInformation("Archive Order", - is2ImgOrder() ? "2IMG" : - isDosOrder() ? "DOS 3.3" : - isProdosOrder() ? "ProDOS" : "Unknown")); - list.add(new DiskInformation("Disk Format", getFormat())); + list.add(new DiskInformation(textBundle.get("FormattedDisk.FileName"), getFilename())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.DiskName"), getDiskName())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.PhysicalSizeInBytes"), getPhysicalSize())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.FreeSpaceInBytes"), getFreeSpace())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.UsedSpaceInBytes"), getUsedSpace())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.PhysicalSizeInKb"), getPhysicalSize() / 1024)); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.FreeSpaceInKb"), getFreeSpace() / 1024)); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.UsedSpaceInKb"), getUsedSpace() / 1024)); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.ArchiveOrder"), //$NON-NLS-1$ + is2ImgOrder() ? textBundle.get("FormattedDisk.2Img") : //$NON-NLS-1$ + isDosOrder() ? textBundle.get("Dos33") : //$NON-NLS-1$ + isProdosOrder() ? textBundle.get("Prodos") : textBundle.get("FormattedDisk.Unknown"))); //$NON-NLS-1$ //$NON-NLS-2$ + list.add(new DiskInformation(textBundle.get("FormattedDisk.DiskFormat"), getFormat())); //$NON-NLS-1$ return list; } @@ -202,10 +204,14 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry { */ public List getFileColumnHeaders(int displayMode) { List list = new ArrayList(); - list.add(new FileColumnHeader("Name", 30, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Type", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Size (bytes)", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Locked?", 6, FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle + .get("Name"), 30, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle + .get("Type"), 8, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle + .get("SizeInBytes"), 6, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle + .get("LockedQ"), 6, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ return list; } @@ -303,13 +309,14 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry { */ protected void writeBootCode() { InputStream inputStream = getClass(). - getResourceAsStream("AppleCommander-boot.dump"); + getResourceAsStream("AppleCommander-boot.dump"); //$NON-NLS-1$ if (inputStream != null) { byte[] bootCode = new byte[SECTOR_SIZE]; try { inputStream.read(bootCode, 0, bootCode.length); writeSector(0, 0, bootCode); } catch (IOException ignored) { + // Ignored } } } diff --git a/src/com/webcodepro/applecommander/storage/filters/AppleWorksDataBaseFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/AppleWorksDataBaseFileFilter.java index 7838386..8d491f5 100644 --- a/src/com/webcodepro/applecommander/storage/filters/AppleWorksDataBaseFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/AppleWorksDataBaseFileFilter.java @@ -24,7 +24,9 @@ import java.io.PrintWriter; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Export an AppleWorks database file to a text file. @@ -45,6 +47,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class AppleWorksDataBaseFileFilter implements FileFilter { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The number of bytes in the remainder of the header record. */ @@ -91,7 +94,7 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { * Count of the number of bytes in the remainder of the * data record. */ - private static final int DATA_LENGTH_WORD = 0; +// private static final int DATA_LENGTH_WORD = 0; /** * Data control record indicating that a number of * categories need to be skipped. This (minus $80) @@ -120,9 +123,18 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { * List of months used for date conversion. */ private static final String[] months = { - "January", "February", "March", "April", - "May", "June", "July", "August", "September", - "October", "November", "December" + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.January"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.February"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.March"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.April"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.May"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.June"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.July"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.August"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.September"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.October"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.November"), //$NON-NLS-1$ + StorageBundle.getInstance().get("AppleWorksDataBaseFileFilter.December") //$NON-NLS-1$ }; /** * ASCII day of the month, like "31" ($33 $31). @@ -179,7 +191,7 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { int offset = HEADER_CATEGORY_STRING; for (int i=0; i 0) printWriter.print(","); + if (i > 0) printWriter.print(","); //$NON-NLS-1$ printWriter.print('"'); printWriter.print(name); printWriter.print('"'); @@ -188,7 +200,7 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { printWriter.println(); if (offset != headerLength) { throw new IndexOutOfBoundsException( - "AppleWorks Data Base file header lenth does not check. Aborting."); + textBundle.get("AppleWorksDataBaseFileFilter.InvalidHeaderLengthError")); //$NON-NLS-1$ } // skip reports: offset+= (reportCount * REPORT_LENGTH); @@ -221,7 +233,7 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { } else { int repeats = controlByte - DATA_CONTROL_SKIP; while (repeats > 0) { - printWriter.print("\",\""); + printWriter.print("\",\""); //$NON-NLS-1$ repeats--; } } @@ -238,16 +250,15 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { * @see com.webcodepro.applecommander.storage.FileFilter#getSuggestedFileName(FileEntry) */ public String getSuggestedFileName(FileEntry fileEntry) { - return fileEntry.getFilename() + ".csv"; + return fileEntry.getFilename() + ".csv"; //$NON-NLS-1$ } /** * Convert the date entry. */ protected void convertDate(PrintWriter printWriter, String date) { if (date.length() != DATE_LENGTH) { - printWriter.print("[Invalid Date="); - printWriter.print(date); - printWriter.print("]"); + printWriter.print(textBundle. + format("AppleWorksDataBaseFileFilter.InvalidDate", date)); //$NON-NLS-1$ } printWriter.print((char)('0' + (date.charAt(DATE_YEAR_OFFSET) - 0x30))); @@ -263,9 +274,8 @@ public class AppleWorksDataBaseFileFilter implements FileFilter { */ protected void convertTime(PrintWriter printWriter, String time) { if (time.length() != TIME_LENGTH) { - printWriter.print("[Invalid Time="); - printWriter.print(time); - printWriter.print("]"); + printWriter.print(textBundle. + format("AppleWorksDataBaseFileFilter.InvalidTime", time)); //$NON-NLS-1$ } printWriter.print(time.charAt(TIME_HOUR_OFFSET) - 'A'); diff --git a/src/com/webcodepro/applecommander/storage/filters/AppleWorksSpreadSheetFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/AppleWorksSpreadSheetFileFilter.java index 0f1f051..8392982 100644 --- a/src/com/webcodepro/applecommander/storage/filters/AppleWorksSpreadSheetFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/AppleWorksSpreadSheetFileFilter.java @@ -94,14 +94,14 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { * These are the formulas starting at FORMULA_OFFSET. */ private static final String[] formulaText = { - "@Deg", "@Rad", "@Pi", "@True", "@False", "@Not", "@IsBlank", - "@IsNA", "@IsError", "@Exp", "@Ln", "@Log", "@Cos", "@Sin", - "@Tan", "@ACos", "@ASin", "@ATan2", "@ATan", "@Mod", "@FV", - "@PV", "@PMT", "@Term", "@Rate", "@Round", "@Or", "@And", - "@Sum", "@Avg", "@Choose", "@Count", "@Error", "@IRR", "@If", - "@Int", "@Lookup", "@Max", "@Min", "@NA", "@NPV", "@Sqrt", - "@Abs", null, "<>", ">=", "<=", "=", ">", "<", ",", "^", - ")", "-", "+", "/", "*", "(", "-", "+", "..", null, null, + "@Deg", "@Rad", "@Pi", "@True", "@False", "@Not", "@IsBlank", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@IsNA", "@IsError", "@Exp", "@Ln", "@Log", "@Cos", "@Sin", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@Tan", "@ACos", "@ASin", "@ATan2", "@ATan", "@Mod", "@FV", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@PV", "@PMT", "@Term", "@Rate", "@Round", "@Or", "@And", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@Sum", "@Avg", "@Choose", "@Count", "@Error", "@IRR", "@If", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@Int", "@Lookup", "@Max", "@Min", "@NA", "@NPV", "@Sqrt", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "@Abs", null, "<>", ">=", "<=", "=", ">", "<", ",", "^", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + ")", "-", "+", "/", "*", "(", "-", "+", "..", null, null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ null }; /** @@ -153,7 +153,7 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { * @see com.webcodepro.applecommander.storage.FileFilter#getSuggestedFileName(FileEntry) */ public String getSuggestedFileName(FileEntry fileEntry) { - return fileEntry.getFilename() + ".csv"; + return fileEntry.getFilename() + ".csv"; //$NON-NLS-1$ } /** * Process an entire row. @@ -163,12 +163,12 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { while (true) { int rowControl = AppleUtil.getUnsignedByte(fileData[offset]); if (rowControl <= 0x7f) { // process row - if (column > 0) printWriter.print(","); + if (column > 0) printWriter.print(","); //$NON-NLS-1$ processCell(printWriter, fileData, offset+1, rowControl, rowNumber, column); offset+= rowControl; } else if (rowControl < 0xff) { // skip rows - if (column > 0) printWriter.print(","); + if (column > 0) printWriter.print(","); //$NON-NLS-1$ int columns = rowControl - 0x80; skipColumns(column, printWriter, columns); column+= columns; @@ -185,8 +185,8 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { */ protected void skipColumns(int column, PrintWriter printWriter, int columns) { while (columns > 0) { - if (column > 0) printWriter.print(","); - printWriter.print("\",\""); + if (column > 0) printWriter.print(","); //$NON-NLS-1$ + printWriter.print("\",\""); //$NON-NLS-1$ columns--; column++; } @@ -253,7 +253,7 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { printWriter.print(string); printWriter.print('"'); } else { - printWriter.print("\"Unknown Cell Contents!\""); + printWriter.print("\"Unknown Cell Contents!\""); //$NON-NLS-1$ } } /** @@ -264,7 +264,7 @@ public class AppleWorksSpreadSheetFileFilter implements FileFilter { int pos2 = column % 26; StringBuffer buf = new StringBuffer(); if (pos1 > 0) { - buf.append((char) '@' + pos1); + buf.append((char)('@' + pos1)); } buf.append((char)('@' + pos2)); return buf.toString(); diff --git a/src/com/webcodepro/applecommander/storage/filters/AppleWorksWordProcessorFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/AppleWorksWordProcessorFileFilter.java index 34d91b0..74d6621 100644 --- a/src/com/webcodepro/applecommander/storage/filters/AppleWorksWordProcessorFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/AppleWorksWordProcessorFileFilter.java @@ -79,60 +79,60 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { private static final int CODE_UNDERLINE_ON = 0x07; private static final int CODE_UNDERLINE_OFF = 0x08; private static final int CODE_PAGE_NUMBER = 0x09; - private static final int CODE_ENTER_KEYBOARD = 0x0a; +// private static final int CODE_ENTER_KEYBOARD = 0x0a; private static final int CODE_STICKY_SPACE = 0x0b; - private static final int CODE_MAILMERGE_BEGIN = 0x0c; - private static final int CODE_RESERVED1 = 0x0d; +// private static final int CODE_MAILMERGE_BEGIN = 0x0c; +// private static final int CODE_RESERVED1 = 0x0d; private static final int CODE_DATE = 0x0e; private static final int CODE_TIME = 0x0f; - private static final int CODE_SPECIAL_1 = 0x10; - private static final int CODE_SPECIAL_2 = 0x11; - private static final int CODE_SPECIAL_3 = 0x12; - private static final int CODE_SPECIAL_4 = 0x13; - private static final int CODE_SPECIAL_5 = 0x14; - private static final int CODE_SPECIAL_6 = 0x15; - private static final int CODE_TAB = 0x16; - private static final int CODE_TAB_FILL = 0x17; - private static final int CODE_RESERVED2 = 0x18; +// private static final int CODE_SPECIAL_1 = 0x10; +// private static final int CODE_SPECIAL_2 = 0x11; +// private static final int CODE_SPECIAL_3 = 0x12; +// private static final int CODE_SPECIAL_4 = 0x13; +// private static final int CODE_SPECIAL_5 = 0x14; +// private static final int CODE_SPECIAL_6 = 0x15; +// private static final int CODE_TAB = 0x16; +// private static final int CODE_TAB_FILL = 0x17; +// private static final int CODE_RESERVED2 = 0x18; /* * Identifies the commands embedded in the AppleWorks file. */ - private static final int COMMAND_RESERVED = 0xd4; +// private static final int COMMAND_RESERVED = 0xd4; private static final int COMMAND_PAGEHEADER_END = 0xd5; private static final int COMMAND_PAGEFOOTER_END = 0xd6; private static final int COMMAND_RIGHT = 0xd7; private static final int COMMAND_PLATEN_WIDTH = 0xd8; // 10ths of an inch private static final int COMMAND_MARGIN_LEFT = 0xd9; // 10ths of an inch private static final int COMMAND_MARGIN_RIGHT = 0xda; // 10ths of an inch - private static final int COMMAND_CHARS_PER_INCH = 0xdb; - private static final int COMMAND_PROPORTIONAL_1 = 0xdc; - private static final int COMMAND_PROPORTIONAL_2 = 0xdd; - private static final int COMMAND_INDENT = 0xde; // in characters +// private static final int COMMAND_CHARS_PER_INCH = 0xdb; +// private static final int COMMAND_PROPORTIONAL_1 = 0xdc; +// private static final int COMMAND_PROPORTIONAL_2 = 0xdd; +// private static final int COMMAND_INDENT = 0xde; // in characters private static final int COMMAND_JUSTIFY = 0xdf; private static final int COMMAND_LEFT = 0xe0; private static final int COMMAND_CENTER = 0xe1; private static final int COMMAND_PAPER_LENGTH = 0xe2; // 10ths of an inch private static final int COMMAND_MARGIN_TOP = 0xe3; // 10ths of an inch private static final int COMMAND_MARGIN_BOTTOM = 0xe4; // 10ths of an inch - private static final int COMMAND_LINES_PER_INCH = 0xe5; - private static final int COMMAND_SINGLE_SPACE = 0xe6; - private static final int COMMAND_DOUBLE_SPACE = 0xe7; - private static final int COMMAND_TRIPLE_SPACE = 0xe8; +// private static final int COMMAND_LINES_PER_INCH = 0xe5; +// private static final int COMMAND_SINGLE_SPACE = 0xe6; +// private static final int COMMAND_DOUBLE_SPACE = 0xe7; +// private static final int COMMAND_TRIPLE_SPACE = 0xe8; private static final int COMMAND_NEW_PAGE = 0xe9; - private static final int COMMAND_GROUP_BEGIN = 0xea; - private static final int COMMAND_GROUP_END = 0xeb; +// private static final int COMMAND_GROUP_BEGIN = 0xea; +// private static final int COMMAND_GROUP_END = 0xeb; private static final int COMMAND_PAGEHEADER = 0xed; // may be mixed up private static final int COMMAND_PAGEFOOTER = 0xec; // with this... private static final int COMMAND_SKIP_LINES = 0xee; - private static final int COMMAND_PAGE_NUMBER = 0xef; - private static final int COMMAND_PAUSE_EACH_PAGE = 0xf0; - private static final int COMMAND_PAUSE_HERE = 0xf1; - private static final int COMMAND_SET_MARKER = 0xf2; - private static final int COMMAND_PAGE_NUMBER_256 = 0xf3; // add 256 +// private static final int COMMAND_PAGE_NUMBER = 0xef; +// private static final int COMMAND_PAUSE_EACH_PAGE = 0xf0; +// private static final int COMMAND_PAUSE_HERE = 0xf1; +// private static final int COMMAND_SET_MARKER = 0xf2; +// private static final int COMMAND_PAGE_NUMBER_256 = 0xf3; // add 256 private static final int COMMAND_PAGE_BREAK = 0xf4; // byte page# private static final int COMMAND_PAGE_BREAK_256 = 0xf5; // byte page# + 256 - private static final int COMMAND_PP_PAGE_BREAK = 0xf6; // break in midl/par. - private static final int COMMAND_PP_PAGE_BREAK_256 = 0xf7; // +256 ?? +// private static final int COMMAND_PP_PAGE_BREAK = 0xf6; // break in midl/par. +// private static final int COMMAND_PP_PAGE_BREAK_256 = 0xf7; // +256 ?? private static final int COMMAND_EOF = 0xff; // END OF FILE /** @@ -151,14 +151,14 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { ByteArrayOutputStream byteArray = new ByteArrayOutputStream(fileData.length); PrintWriter printWriter = new PrintWriter(byteArray, true); if (isHtmlRendering()) { - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ } else if (isRtfRendering()) { - printWriter.print("{\\rtf1"); - printWriter.print("{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 Courier New;}}"); - printWriter.print("{\\*\\generator AppleCommander "); + printWriter.print("{\\rtf1"); //$NON-NLS-1$ + printWriter.print("{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 Courier New;}}"); //$NON-NLS-1$ + printWriter.print("{\\*\\generator AppleCommander "); //$NON-NLS-1$ printWriter.print(AppleCommander.VERSION); - printWriter.println(";}"); - printWriter.print("\\f0 "); + printWriter.println(";}"); //$NON-NLS-1$ + printWriter.print("\\f0 "); //$NON-NLS-1$ } boolean version3 = (fileData[183] != 0); int offset = 300 + (version3 ? 2 : 0); // version 3.0's first line record is invalid @@ -183,9 +183,9 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { } } if (isHtmlRendering()) { - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ } else if (isRtfRendering()) { - printWriter.println("}"); + printWriter.println("}"); //$NON-NLS-1$ } return byteArray.toByteArray(); } @@ -211,11 +211,11 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { extraSpaces++; } if (extraSpaces > 0) { - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ while (fileData[offset] == ' ') { offset++; length--; - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ } } else { printWriter.print((char)ch); @@ -232,8 +232,8 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { * Deal with carriage-return. */ protected void handleReturn(PrintWriter printWriter) { - if (isHtmlRendering()) printWriter.println("
"); - else if (isRtfRendering()) printWriter.println("\\par"); + if (isHtmlRendering()) printWriter.println("
"); //$NON-NLS-1$ + else if (isRtfRendering()) printWriter.println("\\par"); //$NON-NLS-1$ else printWriter.println(); } /** @@ -242,31 +242,31 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { protected void handleSpecialCodesAsHtml(PrintWriter printWriter, byte ch) { switch (ch) { case CODE_BOLD_ON: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_BOLD_OFF: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_SUPERSCRIPT_ON: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_SUPERSCRIPT_OFF: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_SUBSCRIPT_ON: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_SUBSCRIPT_OFF: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_UNDERLINE_ON: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_UNDERLINE_OFF: - printWriter.print(""); + printWriter.print(""); //$NON-NLS-1$ break; case CODE_STICKY_SPACE: - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; default: handleSpecialCodesAsText(printWriter, ch); break; @@ -278,32 +278,32 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { protected void handleSpecialCodesAsRtf(PrintWriter printWriter, byte ch) { switch (ch) { case CODE_PAGE_NUMBER: - printWriter.print("{\\chpgn}"); + printWriter.print("{\\chpgn}"); //$NON-NLS-1$ break; case CODE_BOLD_ON: - printWriter.print("\\b "); + printWriter.print("\\b "); //$NON-NLS-1$ break; case CODE_BOLD_OFF: - printWriter.print("\\b0 "); + printWriter.print("\\b0 "); //$NON-NLS-1$ break; case CODE_UNDERLINE_ON: - printWriter.print("\\ul "); + printWriter.print("\\ul "); //$NON-NLS-1$ break; case CODE_UNDERLINE_OFF: - printWriter.print("\\ulnone"); + printWriter.print("\\ulnone"); //$NON-NLS-1$ break; case CODE_SUPERSCRIPT_ON: - printWriter.print("\\super "); + printWriter.print("\\super "); //$NON-NLS-1$ break; case CODE_SUBSCRIPT_ON: - printWriter.print("\\sub "); + printWriter.print("\\sub "); //$NON-NLS-1$ break; case CODE_SUPERSCRIPT_OFF: case CODE_SUBSCRIPT_OFF: - printWriter.print("\\nosupersub "); + printWriter.print("\\nosupersub "); //$NON-NLS-1$ break; case CODE_STICKY_SPACE: - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; default: handleSpecialCodesAsText(printWriter, ch); break; @@ -315,14 +315,14 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { protected void handleSpecialCodesAsText(PrintWriter printWriter, byte ch) { switch (ch) { case CODE_PAGE_NUMBER: - printWriter.print("[Page#]"); + printWriter.print("[Page#]"); //$NON-NLS-1$ break; case CODE_DATE: - SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); + SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); //$NON-NLS-1$ printWriter.print(dateFormat.format(new Date())); break; case CODE_TIME: - SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); + SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$ printWriter.print(timeFormat.format(new Date())); break; } @@ -335,16 +335,16 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { switch (byte1) { case COMMAND_RIGHT: - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ break; case COMMAND_JUSTIFY: - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ break; case COMMAND_LEFT: - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ break; case COMMAND_CENTER: - printWriter.println(""); + printWriter.println(""); //$NON-NLS-1$ break; default: offset = handleCommandRecordAsText(byte0, byte1, printWriter, offset); @@ -359,69 +359,69 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { PrintWriter printWriter, int offset) { if (inHeaderOrFooter) { - printWriter.print("}\\f0 "); + printWriter.print("}\\f0 "); //$NON-NLS-1$ inHeaderOrFooter = false; } int twipDistance = byte0 * TWIPS_PER_INCH / 10; switch (byte1) { case COMMAND_PAGEHEADER: - printWriter.print("{\\header "); + printWriter.print("{\\header "); //$NON-NLS-1$ inHeaderOrFooter = true; break; case COMMAND_PAGEFOOTER: - printWriter.print("{\\footer "); + printWriter.print("{\\footer "); //$NON-NLS-1$ inHeaderOrFooter = true; break; case COMMAND_PAGEHEADER_END: case COMMAND_PAGEFOOTER_END: - printWriter.print("}"); + printWriter.print("}"); //$NON-NLS-1$ break; case COMMAND_RIGHT: - printWriter.println("\\pard\\qr "); + printWriter.println("\\pard\\qr "); //$NON-NLS-1$ break; case COMMAND_LEFT: - printWriter.println("\\pard "); + printWriter.println("\\pard "); //$NON-NLS-1$ break; case COMMAND_CENTER: - printWriter.println("\\pard\\qc "); + printWriter.println("\\pard\\qc "); //$NON-NLS-1$ break; case COMMAND_JUSTIFY: - printWriter.print("\\qj "); + printWriter.print("\\qj "); //$NON-NLS-1$ break; case COMMAND_PAGE_BREAK: case COMMAND_PAGE_BREAK_256: case COMMAND_NEW_PAGE: - printWriter.print("\\page "); + printWriter.print("\\page "); //$NON-NLS-1$ break; case COMMAND_PLATEN_WIDTH: - printWriter.print("\\paperw"); + printWriter.print("\\paperw"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; case COMMAND_PAPER_LENGTH: - printWriter.print("\\paperl"); + printWriter.print("\\paperl"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; case COMMAND_MARGIN_LEFT: - printWriter.print("\\margl"); + printWriter.print("\\margl"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; case COMMAND_MARGIN_RIGHT: - printWriter.print("\\margr"); + printWriter.print("\\margr"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; case COMMAND_MARGIN_TOP: - printWriter.print("\\margt"); + printWriter.print("\\margt"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; case COMMAND_MARGIN_BOTTOM: - printWriter.print("\\margb"); + printWriter.print("\\margb"); //$NON-NLS-1$ printWriter.print(twipDistance); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ break; default: offset = handleCommandRecordAsText(byte0, byte1, printWriter, offset); @@ -450,9 +450,9 @@ public class AppleWorksWordProcessorFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - String extension = ".txt"; - if (isHtmlRendering()) extension = ".html"; - else if (isRtfRendering()) extension = ".rtf"; + String extension = ".txt"; //$NON-NLS-1$ + if (isHtmlRendering()) extension = ".html"; //$NON-NLS-1$ + else if (isRtfRendering()) extension = ".rtf"; //$NON-NLS-1$ if (!fileName.toLowerCase().endsWith(extension)) { fileName = fileName + extension; diff --git a/src/com/webcodepro/applecommander/storage/filters/ApplesoftFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/ApplesoftFileFilter.java index bbc74c6..c2d6c70 100644 --- a/src/com/webcodepro/applecommander/storage/filters/ApplesoftFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/ApplesoftFileFilter.java @@ -61,7 +61,7 @@ public class ApplesoftFileFilter implements FileFilter { printWriter.println(); } printWriter.print(token.getLineNumber()); - printWriter.print(" "); + printWriter.print(" "); //$NON-NLS-1$ } else if (token.isToken()) { printWriter.print(token.getTokenString()); } else { @@ -77,8 +77,8 @@ public class ApplesoftFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".bas")) { - fileName = fileName + ".bas"; + if (!fileName.toLowerCase().endsWith(".bas")) { //$NON-NLS-1$ + fileName = fileName + ".bas"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/AssemblySourceFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/AssemblySourceFileFilter.java index 362d84c..493e1e0 100644 --- a/src/com/webcodepro/applecommander/storage/filters/AssemblySourceFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/AssemblySourceFileFilter.java @@ -31,11 +31,11 @@ import com.webcodepro.applecommander.storage.FileFilter; * @author Rob Greene */ public class AssemblySourceFileFilter implements FileFilter { - private int[] tabStops = new int[] { 10, 15 };; + private int[] tabStops = new int[] { 10, 15 }; private int commentTabStop = 25; - private String tabChars = "\t "; - private String commentTabChars = ";"; - private String commentNoTabChars = "*"; + private String tabChars = "\t "; //$NON-NLS-1$ + private String commentTabChars = ";"; //$NON-NLS-1$ + private String commentNoTabChars = "*"; //$NON-NLS-1$ /** * Process the given FileEntry and return a byte array @@ -103,8 +103,8 @@ public class AssemblySourceFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".s")) { - fileName += ".s"; + if (!fileName.toLowerCase().endsWith(".s")) { //$NON-NLS-1$ + fileName += ".s"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/BinaryFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/BinaryFileFilter.java index 3d19b16..cf45242 100644 --- a/src/com/webcodepro/applecommander/storage/filters/BinaryFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/BinaryFileFilter.java @@ -38,7 +38,7 @@ public class BinaryFileFilter implements FileFilter { /** * Process the given FileEntry and return a byte array with filtered data. - * @see com.webcodepro.applecommander.storage.FileFilter#filter(byte[]) + * @see com.webcodepro.applecommander.storage.FileFilter#filter(FileEntry) */ public byte[] filter(FileEntry fileEntry) { return fileEntry.getFileData(); // should be nothing to do @@ -49,8 +49,8 @@ public class BinaryFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".dump")) { - fileName = fileName + ".dump"; + if (!fileName.toLowerCase().endsWith(".dump")) { //$NON-NLS-1$ + fileName = fileName + ".dump"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/GraphicsFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/GraphicsFileFilter.java index 922fe4c..52a8608 100644 --- a/src/com/webcodepro/applecommander/storage/filters/GraphicsFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/GraphicsFileFilter.java @@ -410,7 +410,8 @@ public class GraphicsFileFilter implements FileFilter { * Construct a series of icons based on the QuickDraw II Icon file format. * In ProDOS, this is the ICN ($Ca) file format. *

- * @see http://www.gno.org/pub/apple2/doc/apple/filetypes/ftn.ca.xxxx + * See this + * page for details. */ public AppleImage[] buildQuickDraw2Icons(FileEntry fileEntry) { List icons = new ArrayList(); @@ -509,8 +510,8 @@ public class GraphicsFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith("." + getExtension())) { - fileName = fileName + "." + getExtension(); + if (!fileName.toLowerCase().endsWith("." + getExtension())) { //$NON-NLS-1$ + fileName = fileName + "." + getExtension(); //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/HexDumpFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/HexDumpFileFilter.java index 8b852f7..e87542b 100644 --- a/src/com/webcodepro/applecommander/storage/filters/HexDumpFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/HexDumpFileFilter.java @@ -39,7 +39,7 @@ public class HexDumpFileFilter implements FileFilter { /** * Create the hex dump format. - * @see com.webcodepro.applecommander.storage.FileFilter#filter(byte[]) + * @see com.webcodepro.applecommander.storage.FileFilter#filter(FileEntry) */ public byte[] filter(FileEntry fileEntry) { return AppleUtil.getHexDump(fileEntry.getFileData()).getBytes(); @@ -50,8 +50,8 @@ public class HexDumpFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".txt")) { - fileName = fileName + ".txt"; + if (!fileName.toLowerCase().endsWith(".txt")) { //$NON-NLS-1$ + fileName = fileName + ".txt"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/IntegerBasicFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/IntegerBasicFileFilter.java index 70a650f..a8aea8d 100644 --- a/src/com/webcodepro/applecommander/storage/filters/IntegerBasicFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/IntegerBasicFileFilter.java @@ -47,22 +47,22 @@ import com.webcodepro.applecommander.util.AppleUtil; */ public class IntegerBasicFileFilter implements FileFilter { private static String[] tokens = { - null, null, null, ": ", "LOAD ", "SAVE ", null, "RUN ", // $00-$07 - null, "DEL ", ", ", "NEW ", "CLR ", "AUTO ", null, "MAN ", // $08-$0F - "HIMEM: ", "LOMEM: ", "+", "-", "*", "/", "=", "#", // $10-$17 - ">=", ">", "<=", "<>", "<", " AND ", " OR ", " MOD ",// $18-$1F - "^", null, "(", ",", " THEN ", " THEN ", ",", ",", // $20-$27 - "\"", "\"", "(", null, null, "(", " PEEK ", "RND ", // $28-$2F - "SGN ", "ABS ", "PDL ", null, "(", "+", "-", "NOT ", // $30-$37 - "(", "=", "#", " LEN(", " ASC(", " SCRN(", ",", " (", // $38-$3F - "$", null, "(", ",", ",", ";", ";", ";", // $40-$47 - ",", ",", ",", "TEXT ", "GR ", "CALL ", "DIM ", "DIM ", // $48-$4F - "TAB ", "END ", "INPUT ", "INPUT ", "INPUT ", "FOR ", "=", " TO ", // $50-$57 - " STEP ", "NEXT ", ",", "RETURN ", "GOSUB ", "REM ", "LET ", "GOTO ",// $58-$5F - "IF ", "PRINT ", "PRINT ", "PRINT ", " POKE ", ",", "COLOR= ", "PLOT ",// $60-$67 - ",", "HLIN ", ",", " AT ", "VLIN ", ",", " AT ", "VTAB ",// $68-$6F - "=", "=", ")", null, "LIST ", ",", null, "POP ", // $70-$77 - null, "NO DSP ", "NO TRACE ", "DSP ", "DSP ", "TRACE ", "PR # ", "IN # " // $78-$7F + null, null, null, ": ", "LOAD ", "SAVE ", null, "RUN ", // $00-$07 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + null, "DEL ", ", ", "NEW ", "CLR ", "AUTO ", null, "MAN ", // $08-$0F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + "HIMEM: ", "LOMEM: ", "+", "-", "*", "/", "=", "#", // $10-$17 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + ">=", ">", "<=", "<>", "<", " AND ", " OR ", " MOD ",// $18-$1F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + "^", null, "(", ",", " THEN ", " THEN ", ",", ",", // $20-$27 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "\"", "\"", "(", null, null, "(", " PEEK ", "RND ", // $28-$2F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + "SGN ", "ABS ", "PDL ", null, "(", "+", "-", "NOT ", // $30-$37 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + "(", "=", "#", " LEN(", " ASC(", " SCRN(", ",", " (", // $38-$3F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + "$", null, "(", ",", ",", ";", ";", ";", // $40-$47 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + ",", ",", ",", "TEXT ", "GR ", "CALL ", "DIM ", "DIM ", // $48-$4F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + "TAB ", "END ", "INPUT ", "INPUT ", "INPUT ", "FOR ", "=", " TO ", // $50-$57 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + " STEP ", "NEXT ", ",", "RETURN ", "GOSUB ", "REM ", "LET ", "GOTO ",// $58-$5F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + "IF ", "PRINT ", "PRINT ", "PRINT ", " POKE ", ",", "COLOR= ", "PLOT ",// $60-$67 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + ",", "HLIN ", ",", " AT ", "VLIN ", ",", " AT ", "VTAB ",// $68-$6F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + "=", "=", ")", null, "LIST ", ",", null, "POP ", // $70-$77 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + null, "NO DSP ", "NO TRACE ", "DSP ", "DSP ", "TRACE ", "PR # ", "IN # " // $78-$7F //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ }; /** @@ -99,15 +99,15 @@ public class IntegerBasicFileFilter implements FileFilter { } else { char ch = (char)(byt&0x7f); if (ch < 0x20) { // handle control characters - printWriter.print(""); + printWriter.print(">"); //$NON-NLS-1$ } else { printWriter.print(ch); } } } else { - String token = tokens[(int)byt]; + String token = tokens[byt]; if (token != null) { printWriter.print(token); inComment = (byt == 0x5d); // REM statement @@ -128,8 +128,8 @@ public class IntegerBasicFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".int")) { - fileName = fileName + ".int"; + if (!fileName.toLowerCase().endsWith(".int")) { //$NON-NLS-1$ + fileName = fileName + ".int"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/PascalTextFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/PascalTextFileFilter.java index 0af6c9a..fdb89d7 100644 --- a/src/com/webcodepro/applecommander/storage/filters/PascalTextFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/PascalTextFileFilter.java @@ -114,8 +114,8 @@ public class PascalTextFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".txt")) { - fileName = fileName + ".txt"; + if (!fileName.toLowerCase().endsWith(".txt")) { //$NON-NLS-1$ + fileName = fileName + ".txt"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/filters/TextFileFilter.java b/src/com/webcodepro/applecommander/storage/filters/TextFileFilter.java index 5a8431c..e344335 100644 --- a/src/com/webcodepro/applecommander/storage/filters/TextFileFilter.java +++ b/src/com/webcodepro/applecommander/storage/filters/TextFileFilter.java @@ -70,8 +70,8 @@ public class TextFileFilter implements FileFilter { */ public String getSuggestedFileName(FileEntry fileEntry) { String fileName = fileEntry.getFilename().trim(); - if (!fileName.toLowerCase().endsWith(".txt")) { - fileName = fileName + ".txt"; + if (!fileName.toLowerCase().endsWith(".txt")) { //$NON-NLS-1$ + fileName = fileName + ".txt"; //$NON-NLS-1$ } return fileName; } diff --git a/src/com/webcodepro/applecommander/storage/os/cpm/CpmFileEntry.java b/src/com/webcodepro/applecommander/storage/os/cpm/CpmFileEntry.java index 60c5a0b..960c46e 100644 --- a/src/com/webcodepro/applecommander/storage/os/cpm/CpmFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/cpm/CpmFileEntry.java @@ -8,9 +8,11 @@ import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Support the CP/M file entry. Note that this may actually contain references @@ -19,6 +21,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class CpmFileEntry implements FileEntry { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The standard CP/M file entry length. */ @@ -84,7 +87,9 @@ public class CpmFileEntry implements FileEntry { * A short collection of known text-type files. */ public static final String[] TEXT_FILETYPES = { - "TXT", "ASM", "MAC", "DOC", "PRN", "PAS", "ME", "INC", "HLP" + "TXT", "ASM", "MAC", "DOC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "PRN", "PAS", "ME", "INC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "HLP" //$NON-NLS-1$ }; /** * Reference to the disk this FileEntry is attached to. @@ -382,15 +387,15 @@ public class CpmFileEntry implements FileEntry { list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add("0x" + AppleUtil.getFormattedByte(getUserNumber(0))); - list.add(isDeleted() ? "Deleted" : ""); - list.add(isLocked() ? "Locked" : ""); + list.add("0x" + AppleUtil.getFormattedByte(getUserNumber(0))); //$NON-NLS-1$ + list.add(isDeleted() ? textBundle.get("Deleted") : ""); //$NON-NLS-1$//$NON-NLS-2$ + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; default: // FILE_DISPLAY_STANDARD list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add(isLocked() ? "Locked" : ""); + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; } return list; diff --git a/src/com/webcodepro/applecommander/storage/os/cpm/CpmFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/cpm/CpmFormatDisk.java index bbeb882..5ffcd73 100644 --- a/src/com/webcodepro/applecommander/storage/os/cpm/CpmFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/cpm/CpmFormatDisk.java @@ -28,8 +28,10 @@ import java.util.StringTokenizer; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in the Apple CP/M format. @@ -37,6 +39,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class CpmFormatDisk extends FormattedDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The size of the CP/M sector. Assumed to be 128. */ @@ -115,7 +118,7 @@ public class CpmFormatDisk extends FormattedDisk { * @see com.webcodepro.applecommander.storage.FormattedDisk#getDiskName() */ public String getDiskName() { - return "CP/M Volume"; + return textBundle.get("CpmFormatDisk.DiskName"); //$NON-NLS-1$ } /** @@ -123,7 +126,7 @@ public class CpmFormatDisk extends FormattedDisk { * @see com.webcodepro.applecommander.storage.FormattedDisk#getFormat() */ public String getFormat() { - return "CP/M"; + return textBundle.get("CpmFormatDisk.Cpm"); //$NON-NLS-1$ } /** @@ -205,7 +208,7 @@ public class CpmFormatDisk extends FormattedDisk { * @see com.webcodepro.applecommander.storage.FormattedDisk#getBitmapLabels() */ public String[] getBitmapLabels() { - return new String[] { "CP/M 1K BLOCK" }; + return new String[] { textBundle.get("CpmFormatDisk.BitmapLabel") }; //$NON-NLS-1$ } /** @@ -308,7 +311,7 @@ public class CpmFormatDisk extends FormattedDisk { * @see com.webcodepro.applecommander.storage.FormattedDisk#getSuggestedFilename(java.lang.String) */ public String getSuggestedFilename(String filename) { - StringTokenizer tokenizer = new StringTokenizer(filename, "."); + StringTokenizer tokenizer = new StringTokenizer(filename, "."); //$NON-NLS-1$ filename = tokenizer.nextToken(); // grab just the first part of the name.. StringBuffer newName = new StringBuffer(); if (!Character.isLetter(filename.charAt(0))) { @@ -332,9 +335,9 @@ public class CpmFormatDisk extends FormattedDisk { * @see com.webcodepro.applecommander.storage.FormattedDisk#getSuggestedFiletype(java.lang.String) */ public String getSuggestedFiletype(String filetype) { - StringTokenizer tokenizer = new StringTokenizer(filetype, "."); + StringTokenizer tokenizer = new StringTokenizer(filetype, "."); //$NON-NLS-1$ tokenizer.nextToken(); - filetype = ""; + filetype = ""; //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { filetype = tokenizer.nextToken(); // grab just the last part of the name... } @@ -383,8 +386,8 @@ public class CpmFormatDisk extends FormattedDisk { CpmFileEntry fileEntry = new CpmFileEntry(this, offset); if (!fileEntry.isEmpty()) { // Files are unique by name, type, and user number. - String key = fileEntry.getFilename().trim() + "." - + fileEntry.getFiletype().trim() + ":" + String key = fileEntry.getFilename().trim() + "." //$NON-NLS-1$ + + fileEntry.getFiletype().trim() + ":" //$NON-NLS-1$ + fileEntry.getUserNumber(0); if (index.containsKey(key)) { fileEntry = (CpmFileEntry) index.get(key); @@ -473,16 +476,24 @@ public class CpmFormatDisk extends FormattedDisk { List list = new ArrayList(); switch (displayMode) { case FILE_DISPLAY_NATIVE: - list.add(new FileColumnHeader("Name", 8, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Type", 3, FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("Name"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("Type"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); break; case FILE_DISPLAY_DETAIL: - list.add(new FileColumnHeader("Name", 8, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Type", 3, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Size (bytes)", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("User#", 4, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Deleted?", 7, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Locked?", 6, FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Name"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("Type"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("SizeInBytes"), 6, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("CpmFormatDisk.UserNumber"), 4, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("DeletedQ"), 7, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("LockedQ"), 6, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); break; default: // FILE_DISPLAY_STANDARD list.addAll(super.getFileColumnHeaders(displayMode)); diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java b/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java index 0de703c..e178aef 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java @@ -28,6 +28,7 @@ import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.ApplesoftFileFilter; import com.webcodepro.applecommander.storage.filters.AssemblySourceFileFilter; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; @@ -35,6 +36,7 @@ import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Represents a DOS file entry on disk. @@ -43,6 +45,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class DosFileEntry implements FileEntry { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Indicates the length in bytes of the DOS file entry field. */ @@ -95,9 +98,9 @@ public class DosFileEntry implements FileEntry { */ protected void writeFileEntry(byte[] fileEntry) { if (fileEntry.length != FILE_DESCRIPTIVE_ENTRY_LENGTH) { - throw new IllegalArgumentException( - "A DOS 3.3 file entry must be " + FILE_DESCRIPTIVE_ENTRY_LENGTH - + " bytes long!"); + throw new IllegalArgumentException(textBundle. + format("DosFileEntry.DosFileEntryLengthError", //$NON-NLS-1$ + FILE_DESCRIPTIVE_ENTRY_LENGTH)); } byte[] sectorData = disk.readSector(track, sector); System.arraycopy(fileEntry, 0, sectorData, offset, fileEntry.length); @@ -134,18 +137,18 @@ public class DosFileEntry implements FileEntry { */ public String getFiletype() { int filetype = (AppleUtil.getUnsignedByte(readFileEntry()[2]) & 0x7f); - if (filetype == 0x00) return "T"; + if (filetype == 0x00) return "T"; //$NON-NLS-1$ // the "^" operator is exclusive or - used to ensure only that // bit was turned on. if others are turned on, fall through and // return a "?" as the file type - if ((filetype ^ 0x01) == 0) return "I"; - if ((filetype ^ 0x02) == 0) return "A"; - if ((filetype ^ 0x04) == 0) return "B"; - if ((filetype ^ 0x08) == 0) return "S"; - if ((filetype ^ 0x10) == 0) return "R"; - if ((filetype ^ 0x20) == 0) return "a"; - if ((filetype ^ 0x40) == 0) return "b"; - return "?"; // should never occur (read the code!) + if ((filetype ^ 0x01) == 0) return "I"; //$NON-NLS-1$ + if ((filetype ^ 0x02) == 0) return "A"; //$NON-NLS-1$ + if ((filetype ^ 0x04) == 0) return "B"; //$NON-NLS-1$ + if ((filetype ^ 0x08) == 0) return "S"; //$NON-NLS-1$ + if ((filetype ^ 0x10) == 0) return "R"; //$NON-NLS-1$ + if ((filetype ^ 0x20) == 0) return "a"; //$NON-NLS-1$ + if ((filetype ^ 0x40) == 0) return "b"; //$NON-NLS-1$ + return "?"; // should never occur (read the code!) //$NON-NLS-1$ } /** @@ -154,14 +157,14 @@ public class DosFileEntry implements FileEntry { public void setFiletype(String filetype) { byte[] data = readFileEntry(); int type = 0x04; // assume binary - if ("T".equals(filetype)) type = 0x00; - if ("I".equals(filetype)) type = 0x01; - if ("A".equals(filetype)) type = 0x02; - if ("B".equals(filetype)) type = 0x04; - if ("S".equals(filetype)) type = 0x08; - if ("R".equals(filetype)) type = 0x10; - if ("a".equals(filetype)) type = 0x20; - if ("b".equals(filetype)) type = 0x40; + if ("T".equals(filetype)) type = 0x00; //$NON-NLS-1$ + if ("I".equals(filetype)) type = 0x01; //$NON-NLS-1$ + if ("A".equals(filetype)) type = 0x02; //$NON-NLS-1$ + if ("B".equals(filetype)) type = 0x04; //$NON-NLS-1$ + if ("S".equals(filetype)) type = 0x08; //$NON-NLS-1$ + if ("R".equals(filetype)) type = 0x10; //$NON-NLS-1$ + if ("a".equals(filetype)) type = 0x20; //$NON-NLS-1$ + if ("b".equals(filetype)) type = 0x40; //$NON-NLS-1$ type = (type | (data[2] & 0x80)); data[2] = (byte) type; writeFileEntry(data); @@ -201,10 +204,10 @@ public class DosFileEntry implements FileEntry { int size = (getSectorsUsed()-1) * Disk.SECTOR_SIZE; if (size < 1) size = 0; // we assume a T/S block is included (may not be) if (rawdata != null) { - if ("B".equals(getFiletype())) { + if ("B".equals(getFiletype())) { //$NON-NLS-1$ // binary return AppleUtil.getWordValue(rawdata, 2); - } else if ("A".equals(getFiletype()) || "I".equals(getFiletype())) { + } else if ("A".equals(getFiletype()) || "I".equals(getFiletype())) { //$NON-NLS-1$ //$NON-NLS-2$ // applesoft, integer basic return AppleUtil.getWordValue(rawdata, 0); } @@ -236,15 +239,6 @@ public class DosFileEntry implements FileEntry { return false; } - /** - * Retrieve the list of files in this directory. - * Always returns null for DOS. - * @see com.webcodepro.applecommander.storage.FileEntry#getFiles() - */ - public List getFiles() { - return null; - } - /** * Identify if this file has been deleted. * @see com.webcodepro.applecommander.storage.FileEntry#isDeleted() @@ -275,27 +269,27 @@ public class DosFileEntry implements FileEntry { List list = new ArrayList(); switch (displayMode) { case FormattedDisk.FILE_DISPLAY_NATIVE: - list.add(isLocked() ? "*" : " "); + list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$ list.add(getFiletype()); numberFormat.setMinimumIntegerDigits(3); list.add(numberFormat.format(getSectorsUsed())); list.add(getFilename()); break; case FormattedDisk.FILE_DISPLAY_DETAIL: - list.add(isLocked() ? "*" : " "); + list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$ list.add(getFiletype()); list.add(getFilename()); list.add(numberFormat.format(getSize())); numberFormat.setMinimumIntegerDigits(3); list.add(numberFormat.format(getSectorsUsed())); - list.add(isDeleted() ? "Deleted" : ""); - list.add("T" + getTrack() + " S" + getSector()); + list.add(isDeleted() ? textBundle.get("Deleted") : ""); //$NON-NLS-1$//$NON-NLS-2$ + list.add("T" + getTrack() + " S" + getSector()); //$NON-NLS-1$ //$NON-NLS-2$ break; default: // FILE_DISPLAY_STANDARD list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add(isLocked() ? "Locked" : ""); + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; } return list; @@ -428,8 +422,8 @@ public class DosFileEntry implements FileEntry { */ public boolean isAssemblySourceFile() { boolean rightFiletype = isTextFile() || isBinaryFile(); - if (rightFiletype && getFilename().endsWith(".S")) return true; - if (rightFiletype && getFilename().startsWith("T.")) return true; + if (rightFiletype && getFilename().endsWith(".S")) return true; //$NON-NLS-1$ + if (rightFiletype && getFilename().startsWith("T.")) return true; //$NON-NLS-1$ return false; } @@ -437,28 +431,28 @@ public class DosFileEntry implements FileEntry { * Determine if this is a text file. */ public boolean isTextFile() { - return "T".equals(getFiletype()); + return "T".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is an Applesoft BASIC file. */ public boolean isApplesoftBasicFile() { - return "A".equals(getFiletype()); + return "A".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is an Integer BASIC file. */ public boolean isIntegerBasicFile() { - return "I".equals(getFiletype()); + return "I".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is a binary file. */ public boolean isBinaryFile() { - return "B".equals(getFiletype()); + return "B".equals(getFiletype()); //$NON-NLS-1$ } /** @@ -494,8 +488,8 @@ public class DosFileEntry implements FileEntry { } } catch (DiskFullException e) { // Should not be possible when the file isn't being modified!! - throw new IllegalStateException("Unable to set address for DosFileEntry [" - + getFilename() + "]"); + throw new IllegalStateException(textBundle. + format("DosFileEntry.UnableToSetAddressError", getFilename())); //$NON-NLS-1$ } } diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java index 9f899df..1fb40d1 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java @@ -25,8 +25,10 @@ import java.util.List; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in Apple DOS 3.3 format. @@ -35,6 +37,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class DosFormatDisk extends FormattedDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Indicates the index of the track in the location array. */ @@ -59,7 +62,8 @@ public class DosFormatDisk extends FormattedDisk { * The list of filetypes available. */ private static final String[] filetypes = { - "T", "A", "I", "B", "S", "R", "a", "b" + "T", "A", "I", "B", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "S", "R", "a", "b" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ }; /** @@ -89,7 +93,8 @@ public class DosFormatDisk extends FormattedDisk { */ public boolean isFree() { if (location == null || location.length != 2) { - throw new IllegalArgumentException("Invalid dimension for isFree! Did you call next first?"); + throw new IllegalArgumentException(StorageBundle.getInstance() + .get("DosFormatDisk.InvalidDimensionError")); //$NON-NLS-1$ } return isSectorFree(location[TRACK_LOCATION_INDEX], location[SECTOR_LOCATION_INDEX], readVtoc()); @@ -101,9 +106,6 @@ public class DosFormatDisk extends FormattedDisk { /** * Constructor for DosFormatDisk. - * @param filename - * @param diskImage - * @param order */ public DosFormatDisk(String filename, ImageOrder imageOrder) { super(filename, imageOrder); @@ -121,15 +123,15 @@ public class DosFormatDisk extends FormattedDisk { /** * Identify the operating system format of this disk as DOS 3.3. - * @see com.webcodepro.applecommander.storage.Disk#getFormat() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFormat() */ public String getFormat() { - return "DOS 3.3"; + return textBundle.get("Dos33"); //$NON-NLS-1$ } /** * Retrieve a list of files. - * @see com.webcodepro.applecommander.storage.Disk#getFiles() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles() */ public List getFiles() { List list = new ArrayList(); @@ -171,7 +173,7 @@ public class DosFormatDisk extends FormattedDisk { track = catalogSector[1]; sector = catalogSector[2]; } - throw new DiskFullException("Unable to allocate more space for another file!"); + throw new DiskFullException(textBundle.get("DosFormatDisk.NoMoreSpaceError")); //$NON-NLS-1$ } /** @@ -197,7 +199,7 @@ public class DosFormatDisk extends FormattedDisk { * Compute the amount of freespace available on the disk. * This algorithm completely ignores tracks and sectors by * running through the entire bitmap stored on the VTOC. - * @see com.webcodepro.applecommander.storage.Disk#getFreeSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFreeSpace() */ public int getFreeSpace() { return getFreeSectors() * SECTOR_SIZE; @@ -218,7 +220,7 @@ public class DosFormatDisk extends FormattedDisk { /** * Return the amount of used space in bytes. - * @see com.webcodepro.applecommander.storage.Disk#getUsedSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getUsedSpace() */ public int getUsedSpace() { return getUsedSectors() * SECTOR_SIZE; @@ -244,11 +246,11 @@ public class DosFormatDisk extends FormattedDisk { * Return the DOS disk name. Basically, the DISK VOLUME #xxx * that a CATALOG command would show. Note that Java bytes are * signed, so a little mojo is in order. - * @see com.webcodepro.applecommander.storage.Disk#getDiskName() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getDiskName() */ public String getDiskName() { int volumeNumber = AppleUtil.getUnsignedByte(readVtoc()[0x06]); - return "DISK VOLUME #" + volumeNumber; + return textBundle.get("DosFormatDisk.DiskVolume") + volumeNumber; //$NON-NLS-1$ } /** @@ -310,7 +312,7 @@ public class DosFormatDisk extends FormattedDisk { * Get the labels to use in the bitmap. */ public String[] getBitmapLabels() { - return new String[] { "Track", "Sector" }; + return new String[] { textBundle.get("DosFormatDisk.Track"), textBundle.get("DosFormatDisk.Sector") }; //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -318,11 +320,11 @@ public class DosFormatDisk extends FormattedDisk { */ public List getDiskInformation() { List list = super.getDiskInformation(); - list.add(new DiskInformation("Total Sectors", getTotalSectors())); - list.add(new DiskInformation("Free Sectors", getFreeSectors())); - list.add(new DiskInformation("Used Sectors", getUsedSectors())); - list.add(new DiskInformation("Tracks On Disk", getTracks())); - list.add(new DiskInformation("Sectors On Disk", getSectors())); + list.add(new DiskInformation(textBundle.get("DosFormatDisk.TotalSectors"), getTotalSectors())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("DosFormatDisk.FreeSectors"), getFreeSectors())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("DosFormatDisk.UsedSectors"), getUsedSectors())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("DosFormatDisk.TracksOnDisk"), getTracks())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("DosFormatDisk.SectorsOnDisk"), getSectors())); //$NON-NLS-1$ return list; } @@ -334,19 +336,23 @@ public class DosFormatDisk extends FormattedDisk { List list = new ArrayList(); switch (displayMode) { case FILE_DISPLAY_NATIVE: - list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Type", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Size (sectors)", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Name", 30, FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("DosFormatDisk.Type"), 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("DosFormatDisk.SizeInSectors"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 30, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); break; case FILE_DISPLAY_DETAIL: - list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Type", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Name", 30, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Size (bytes)", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Size (sectors)", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Deleted?", 7, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Track/Sector List", 7, FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("DosFormatDisk.Type"), 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 30, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("SizeInBytes"), 6, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("DosFormatDisk.SizeInSectors"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("DeletedQ"), 7, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("DosFormatDisk.TrackAndSectorList"), 7, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ break; default: // FILE_DISPLAY_STANDARD list.addAll(super.getFileColumnHeaders(displayMode)); @@ -378,7 +384,7 @@ public class DosFormatDisk extends FormattedDisk { /** * Identify if this disk format as not capable of having directories. - * @see com.webcodepro.applecommander.storage.Disk#hasDirectories() + * @see com.webcodepro.applecommander.storage.FormattedDisk#canHaveDirectories() */ public boolean canHaveDirectories() { return false; @@ -396,7 +402,7 @@ public class DosFormatDisk extends FormattedDisk { */ public byte[] getFileData(FileEntry fileEntry) { if ( !(fileEntry instanceof DosFileEntry)) { - throw new IllegalArgumentException("Most have a DOS 3.3 file entry!"); + throw new IllegalArgumentException(textBundle.get("DosFormatDisk.InvalidFileEntryError")); //$NON-NLS-1$ } DosFileEntry dosEntry = (DosFileEntry) fileEntry; // Size is calculated by sectors used - not actual size - as size varies @@ -448,9 +454,9 @@ public class DosFormatDisk extends FormattedDisk { int numberOfSectors = numberOfDataSectors + (numberOfDataSectors + TRACK_SECTOR_PAIRS - 1) / TRACK_SECTOR_PAIRS; if (numberOfSectors > getFreeSectors() + fileEntry.getSectorsUsed()) { - throw new DiskFullException("This file requires " + numberOfSectors - + " sectors but there are only " + getFreeSectors() + " sectors" - + " available on the disk."); + throw new DiskFullException( + textBundle.format("DosFormatDisk.NotEnoughSectorsError", //$NON-NLS-1$ + numberOfSectors, getFreeSectors())); } // free "old" data and just rewrite stuff... freeSectors(fileEntry); @@ -658,8 +664,8 @@ public class DosFormatDisk extends FormattedDisk { protected void checkRange(int track, int sector) { if (track > 50 || sector > 32) { throw new IllegalArgumentException( - "Invalid track (" + track + "), sector (" + sector - + ") combination."); + textBundle.format("DosFormatDisk.InvalidTrackAndSectorCombinationError", //$NON-NLS-1$ + track, sector)); } } @@ -687,12 +693,12 @@ public class DosFormatDisk extends FormattedDisk { * as to the filetype. */ public String getSuggestedFiletype(String filename) { - String filetype = "B"; - int pos = filename.lastIndexOf("."); + String filetype = "B"; //$NON-NLS-1$ + int pos = filename.lastIndexOf("."); //$NON-NLS-1$ if (pos > 0) { String what = filename.substring(pos+1); - if ("txt".equalsIgnoreCase(what)) { - filetype = "T"; + if ("txt".equalsIgnoreCase(what)) { //$NON-NLS-1$ + filetype = "T"; //$NON-NLS-1$ } } return filetype; @@ -711,7 +717,7 @@ public class DosFormatDisk extends FormattedDisk { * For DOS, only the Binary type needs an address. */ public boolean needsAddress(String filetype) { - return "B".equals(filetype); + return "B".equals(filetype); //$NON-NLS-1$ } /** diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/OzDosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/dos33/OzDosFormatDisk.java index c9902ca..03e071f 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/OzDosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/OzDosFormatDisk.java @@ -19,7 +19,9 @@ */ package com.webcodepro.applecommander.storage.os.dos33; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in OzDOS format. @@ -32,6 +34,7 @@ import com.webcodepro.applecommander.storage.physical.ImageOrder; * @author Rob Greene */ public class OzDosFormatDisk extends DosFormatDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Use this indicator to work with logical disk #1. * It is essentially the offset into the block. @@ -49,8 +52,6 @@ public class OzDosFormatDisk extends DosFormatDisk { private int logicalOffset; /** * Constructor for OzDosFormatDisk. - * @param filename - * @param diskImage */ public OzDosFormatDisk(String filename, ImageOrder imageOrder, int logicalOffset) { super(filename, imageOrder); @@ -72,9 +73,9 @@ public class OzDosFormatDisk extends DosFormatDisk { */ public String getDiskName() { if (logicalOffset == OZDOS_DISK_1) { - return super.getDiskName() + " (Disk 1)"; + return textBundle.format("DiskNameN", super.getDiskName(), 1); //$NON-NLS-1$ } else if (logicalOffset == OZDOS_DISK_2) { - return super.getDiskName() + " (Disk 2)"; + return textBundle.format("DiskNameN", super.getDiskName(), 2); //$NON-NLS-1$ } else { return super.getDiskName(); } diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/UniDosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/dos33/UniDosFormatDisk.java index feb9851..9d462c4 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/UniDosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/UniDosFormatDisk.java @@ -19,7 +19,9 @@ */ package com.webcodepro.applecommander.storage.os.dos33; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in UniDOS format. @@ -30,6 +32,7 @@ import com.webcodepro.applecommander.storage.physical.ImageOrder; * @author Rob */ public class UniDosFormatDisk extends DosFormatDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Use this indicator to work with logical disk #1. * It is essentially the track offset into the disk image. @@ -47,8 +50,6 @@ public class UniDosFormatDisk extends DosFormatDisk { private int logicalOffset; /** * Constructor for UniDosFormatDisk. - * @param filename - * @param diskImage */ public UniDosFormatDisk(String filename, ImageOrder imageOrder, int logicalOffset) { super(filename, imageOrder); @@ -70,9 +71,9 @@ public class UniDosFormatDisk extends DosFormatDisk { */ public String getDiskName() { if (logicalOffset == UNIDOS_DISK_1) { - return super.getDiskName() + " (Disk 1)"; + return textBundle.format("DiskNameN", super.getDiskName(), 1); //$NON-NLS-1$ } else if (logicalOffset == UNIDOS_DISK_2) { - return super.getDiskName() + " (Disk 2)"; + return textBundle.format("DiskNameN", super.getDiskName(), 2); //$NON-NLS-1$ } else { return super.getDiskName(); } diff --git a/src/com/webcodepro/applecommander/storage/os/pascal/PascalFileEntry.java b/src/com/webcodepro/applecommander/storage/os/pascal/PascalFileEntry.java index 7bbed88..c9e868e 100644 --- a/src/com/webcodepro/applecommander/storage/os/pascal/PascalFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/pascal/PascalFileEntry.java @@ -30,11 +30,13 @@ import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.PascalTextFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Represents a Pascal file entry on disk. @@ -43,6 +45,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class PascalFileEntry implements FileEntry { + private TextBundle textBundle = StorageBundle.getInstance(); private byte[] fileEntry; private PascalFormatDisk disk; @@ -97,10 +100,9 @@ public class PascalFileEntry implements FileEntry { String[] filetypes = disk.getFiletypes(); int filetype = fileEntry[4] & 0x0f; if (filetype == 0 || filetype > filetypes.length) { - return "unknown (" + filetype + ")"; - } else { - return filetypes[filetype-1]; + return textBundle.format("PascalFileEntry.UnknownFiletype", filetype); //$NON-NLS-1$ } + return filetypes[filetype-1]; } /** @@ -190,7 +192,8 @@ public class PascalFileEntry implements FileEntry { */ public List getFileColumnData(int displayMode) { NumberFormat numberFormat = NumberFormat.getNumberInstance(); - SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy"); + SimpleDateFormat dateFormat = new SimpleDateFormat( + textBundle.get("PascalFileEntry.PascalDateFormat")); //$NON-NLS-1$ List list = new ArrayList(); switch (displayMode) { @@ -218,7 +221,7 @@ public class PascalFileEntry implements FileEntry { list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add(isLocked() ? "Locked" : ""); + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; } return list; @@ -246,13 +249,12 @@ public class PascalFileEntry implements FileEntry { * of guessing the appropriate filter. */ public FileFilter getSuggestedFilter() { - if ("textfile".equals(getFiletype())) { - if (getFilename().toLowerCase().endsWith(".text")) { + if ("textfile".equals(getFiletype())) { //$NON-NLS-1$ + if (getFilename().toLowerCase().endsWith(".text")) { //$NON-NLS-1$ return new PascalTextFileFilter(); - } else { - return new TextFileFilter(); } - } else if ("datafile".equals(getFiletype()) && getSize() >= 8184 && getSize() <= 8192) { + return new TextFileFilter(); + } else if ("datafile".equals(getFiletype()) && getSize() >= 8184 && getSize() <= 8192) { //$NON-NLS-1$ GraphicsFileFilter filter = new GraphicsFileFilter(); filter.setMode(GraphicsFileFilter.MODE_HGR_COLOR); return filter; diff --git a/src/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java index a0298d3..35655c7 100644 --- a/src/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java @@ -28,8 +28,10 @@ import java.util.List; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in the Pascal format. @@ -38,6 +40,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class PascalFormatDisk extends FormattedDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The size of the Pascal file entry. */ @@ -48,22 +51,22 @@ public class PascalFormatDisk extends FormattedDisk { public static final int PASCAL_BLOCKS_ON_140K_DISK = 280; // filetypes used elsewhere in the code: - private static final String TEXTFILE = "textfile"; - private static final String CODEFILE = "codefile"; - private static final String DATAFILE = "datafile"; + private static final String TEXTFILE = "textfile"; //$NON-NLS-1$ + private static final String CODEFILE = "codefile"; //$NON-NLS-1$ + private static final String DATAFILE = "datafile"; //$NON-NLS-1$ /** * The know filetypes for a Pascal disk. */ private static final String[] filetypes = { - "xdskfile", + "xdskfile", //$NON-NLS-1$ CODEFILE, TEXTFILE, - "infofile", + "infofile", //$NON-NLS-1$ DATAFILE, - "graffile", - "fotofile", - "securedir" }; + "graffile", //$NON-NLS-1$ + "fotofile", //$NON-NLS-1$ + "securedir" }; //$NON-NLS-1$ /** * Use this inner interface for managing the disk usage data. @@ -109,8 +112,6 @@ public class PascalFormatDisk extends FormattedDisk { /** * Constructor for PascalFormatDisk. - * @param filename - * @param diskImage */ public PascalFormatDisk(String filename, ImageOrder imageOrder) { super(filename, imageOrder); @@ -128,15 +129,15 @@ public class PascalFormatDisk extends FormattedDisk { /** * Identify the operating system format of this disk. - * @see com.webcodepro.applecommander.storage.Disk#getFormat() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFormat() */ public String getFormat() { - return "Pascal"; + return textBundle.get("PascalFormatDisk.Pascal"); //$NON-NLS-1$ } /** * Retrieve a list of files. - * @see com.webcodepro.applecommander.storage.Disk#getFiles() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles() */ public List getFiles() { List list = new ArrayList(); @@ -158,7 +159,7 @@ public class PascalFormatDisk extends FormattedDisk { * Create a new FileEntry. */ public FileEntry createFile() throws DiskFullException { - throw new DiskFullException("Unable to create files (yet)."); + throw new DiskFullException(textBundle.get("FileCreationNotSupported")); //$NON-NLS-1$ } /** @@ -197,7 +198,7 @@ public class PascalFormatDisk extends FormattedDisk { */ public void writeDirectory(byte[] directory) { if (directory == null || directory.length != 2048) { - throw new IllegalArgumentException("Invalid Pascal directory."); + throw new IllegalArgumentException(textBundle.get("PascalFormatDisk.InvalidPascalDirectory")); //$NON-NLS-1$ } for (int i=0; i<4; i++) { byte[] block = new byte[BLOCK_SIZE]; @@ -208,7 +209,7 @@ public class PascalFormatDisk extends FormattedDisk { /** * Identify if this disk format is capable of having directories. - * @see com.webcodepro.applecommander.storage.Disk#canHaveDirectories() + * @see com.webcodepro.applecommander.storage.FormattedDisk#canHaveDirectories() */ public boolean canHaveDirectories() { return false; @@ -216,7 +217,7 @@ public class PascalFormatDisk extends FormattedDisk { /** * Return the amount of free space in bytes. - * @see com.webcodepro.applecommander.storage.Disk#getFreeSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFreeSpace() */ public int getFreeSpace() { return getFreeBlocks() * BLOCK_SIZE; @@ -277,7 +278,7 @@ public class PascalFormatDisk extends FormattedDisk { /** * Return the amount of used space in bytes. - * @see com.webcodepro.applecommander.storage.Disk#getUsedSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getUsedSpace() */ public int getUsedSpace() { return getUsedBlocks() * BLOCK_SIZE; @@ -301,10 +302,10 @@ public class PascalFormatDisk extends FormattedDisk { /** * Return the name of the disk. This is stored on block #2 * offset +6 (string[7]). - * @see com.webcodepro.applecommander.storage.Disk#getDiskName() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getDiskName() */ public String getDiskName() { - return AppleUtil.getPascalString(readBlock(2), 6) + ":"; + return AppleUtil.getPascalString(readBlock(2), 6) + ":"; //$NON-NLS-1$ } /** @@ -343,7 +344,7 @@ public class PascalFormatDisk extends FormattedDisk { * Get the labels to use in the bitmap. */ public String[] getBitmapLabels() { - return new String[] { "Block" }; + return new String[] { textBundle.get("Block") }; //$NON-NLS-1$ } /** @@ -351,12 +352,15 @@ public class PascalFormatDisk extends FormattedDisk { */ public List getDiskInformation() { List list = super.getDiskInformation(); - list.add(new DiskInformation("Total Blocks", getBlocksOnDisk())); - list.add(new DiskInformation("Free Blocks", getFreeBlocks())); - list.add(new DiskInformation("Used Blocks", getUsedBlocks())); - list.add(new DiskInformation("Files On Disk", getFilesOnDisk())); - list.add(new DiskInformation("Last Access Date", getLastAccessDate())); - list.add(new DiskInformation("Most Recent Date Setting", getMostRecentDateSetting())); + list.add(new DiskInformation(textBundle.get("TotalBlocks"), getBlocksOnDisk())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FreeBlocks"), getFreeBlocks())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("UsedBlocks"), getUsedBlocks())); //$NON-NLS-1$ + list.add(new DiskInformation( + textBundle.get("PascalFormatDisk.FilesOnDisk"), getFilesOnDisk())); //$NON-NLS-1$ + list.add(new DiskInformation( + textBundle.get("PascalFormatDisk.LastAccessDate"), getLastAccessDate())); //$NON-NLS-1$ + list.add(new DiskInformation( + textBundle.get("PascalFormatDisk.MostRecentDateSetting"), getMostRecentDateSetting())); //$NON-NLS-1$ return list; } @@ -368,20 +372,35 @@ public class PascalFormatDisk extends FormattedDisk { List list = new ArrayList(); switch (displayMode) { case FILE_DISPLAY_NATIVE: - list.add(new FileColumnHeader("Modified", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Filetype", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Name", 15, FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("Modified"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Filetype"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Name"), 15, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); break; case FILE_DISPLAY_DETAIL: - list.add(new FileColumnHeader("Modified", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Bytes in last block", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Size (bytes)", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Filetype", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Name", 15, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("First Block", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Last Block", 3, FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Modified"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader( + textBundle.get("PascalFormatDisk.BytesInLastBlock"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("SizeInBytes"), 6, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Filetype"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Name"), 15, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader( + textBundle.get("PascalFormatDisk.FirstBlock"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader( + textBundle.get("PascalFormatDisk.LastBlock"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); break; default: // FILE_DISPLAY_STANDARD list.addAll(super.getFileColumnHeaders(displayMode)); @@ -423,7 +442,7 @@ public class PascalFormatDisk extends FormattedDisk { */ public byte[] getFileData(FileEntry fileEntry) { if ( !(fileEntry instanceof PascalFileEntry)) { - throw new IllegalArgumentException("Most have a Pascal file entry!"); + throw new IllegalArgumentException(textBundle.get("PascalFormatDisk.IncorrectFileEntryError")); //$NON-NLS-1$ } PascalFileEntry pascalEntry = (PascalFileEntry) fileEntry; int firstBlock = pascalEntry.getFirstBlock(); @@ -433,7 +452,8 @@ public class PascalFormatDisk extends FormattedDisk { for (int block = firstBlock; block < lastBlock; block++) { byte[] blockData = readBlock(block); if (block == lastBlock-1) { - System.arraycopy(blockData, 0, fileData, offset, pascalEntry.getBytesUsedInLastBlock()); + System.arraycopy(blockData, 0, fileData, offset, + pascalEntry.getBytesUsedInLastBlock()); } else { System.arraycopy(blockData, 0, fileData, offset, blockData.length); } @@ -498,12 +518,12 @@ public class PascalFormatDisk extends FormattedDisk { */ public String getSuggestedFiletype(String filename) { String filetype = DATAFILE; - int pos = filename.lastIndexOf("."); + int pos = filename.lastIndexOf("."); //$NON-NLS-1$ if (pos > 0) { String what = filename.substring(pos+1); - if ("txt".equalsIgnoreCase(what)) { + if ("txt".equalsIgnoreCase(what)) { //$NON-NLS-1$ filetype = TEXTFILE; - } else if ("pas".equalsIgnoreCase(what)) { + } else if ("pas".equalsIgnoreCase(what)) { //$NON-NLS-1$ filetype = CODEFILE; } } diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosCommonDirectoryHeader.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosCommonDirectoryHeader.java index 66ff3ee..3a8336e 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosCommonDirectoryHeader.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosCommonDirectoryHeader.java @@ -31,7 +31,6 @@ public class ProdosCommonDirectoryHeader extends ProdosCommonEntry { /** * Constructor for ProdosCommonDirectoryHeader. - * @param fileEntry */ public ProdosCommonDirectoryHeader(ProdosFormatDisk disk, int block) { super(disk, block, 4); // directory entries are always offset 4, right? diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFileEntry.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFileEntry.java index 9ff3ec3..f128232 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFileEntry.java @@ -29,6 +29,7 @@ import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.AppleWorksDataBaseFileFilter; import com.webcodepro.applecommander.storage.filters.AppleWorksSpreadSheetFileFilter; import com.webcodepro.applecommander.storage.filters.AppleWorksWordProcessorFileFilter; @@ -39,6 +40,7 @@ import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Represents a ProDOS file entry on disk. @@ -47,6 +49,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Constructor for ProdosFileEntry. */ @@ -344,68 +347,75 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry { */ public List getFileColumnData(int displayMode) { NumberFormat numberFormat = NumberFormat.getNumberInstance(); - SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + SimpleDateFormat dateFormat = new SimpleDateFormat( + textBundle.get("DateFormat")); //$NON-NLS-1$ List list = new ArrayList(); switch (displayMode) { case FormattedDisk.FILE_DISPLAY_NATIVE: - list.add(isLocked() ? "*" : " "); + list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$ list.add(getFilename()); list.add(getFiletype()); numberFormat.setMinimumIntegerDigits(3); list.add(numberFormat.format(getBlocksUsed())); - list.add(getLastModificationDate() == null ? " " : + list.add(getLastModificationDate() == null ? + textBundle.get("ProdosFileEntry.NullDate") : //$NON-NLS-1$ dateFormat.format(getLastModificationDate())); - list.add(getCreationDate() == null ? " " : + list.add(getCreationDate() == null ? + textBundle.get("ProdosFileEntry.NullDate") : //$NON-NLS-1$ dateFormat.format(getCreationDate())); numberFormat.setMinimumIntegerDigits(1); list.add(numberFormat.format(getEofPosition())); - if ("TXT".equals(getFiletype()) && getAuxiliaryType() > 0) { + if ("TXT".equals(getFiletype()) && getAuxiliaryType() > 0) { //$NON-NLS-1$ numberFormat.setMinimumIntegerDigits(1); - list.add("L=" + numberFormat.format(getAuxiliaryType()).trim()); - } else if (("BIN".equals(getFiletype()) || "BAS".equals(getFiletype()) - || "VAR".equals(getFiletype()) || "SYS".equals(getFiletype())) + list.add("L=" + numberFormat.format(getAuxiliaryType()).trim()); //$NON-NLS-1$ + } else if (("BIN".equals(getFiletype()) || "BAS".equals(getFiletype()) //$NON-NLS-1$ //$NON-NLS-2$ + || "VAR".equals(getFiletype()) || "SYS".equals(getFiletype())) //$NON-NLS-1$ //$NON-NLS-2$ && getAuxiliaryType() > 0) { - list.add("A=$" + AppleUtil.getFormattedWord(getAuxiliaryType())); + list.add("A=$" + AppleUtil.getFormattedWord(getAuxiliaryType())); //$NON-NLS-1$ } else { - list.add(""); + list.add(""); //$NON-NLS-1$ } break; case FormattedDisk.FILE_DISPLAY_DETAIL: - list.add(isLocked() ? "*" : " "); + list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$ list.add(getFilename()); - list.add(isDeleted() ? "Deleted" : ""); - String permissions = ""; - if (canDestroy()) permissions+= "Destroy "; - if (canRead()) permissions+= "Read "; - if (canRename()) permissions+= "Rename "; - if (canWrite()) permissions+= "Write "; + list.add(isDeleted() ? textBundle.get("Deleted") : ""); //$NON-NLS-1$//$NON-NLS-2$ + String permissions = ""; //$NON-NLS-1$ + if (canDestroy()) permissions+= textBundle.get("Destroy"); //$NON-NLS-1$ + if (canRead()) permissions+= textBundle.get("Read"); //$NON-NLS-1$ + if (canRename()) permissions+= textBundle.get("Rename"); //$NON-NLS-1$ + if (canWrite()) permissions+= textBundle.get("Write"); //$NON-NLS-1$ list.add(permissions); list.add(getFiletype()); - list.add(isDirectory() ? "Directory" : ""); + list.add(isDirectory() ? textBundle.get("ProdosFileEntry.Directory") : ""); //$NON-NLS-1$//$NON-NLS-2$ numberFormat.setMinimumIntegerDigits(3); list.add(numberFormat.format(getBlocksUsed())); - list.add(getLastModificationDate() == null ? " " : + list.add(getLastModificationDate() == null ? + textBundle.get("ProdosFileEntry.NullDate") : //$NON-NLS-1$ dateFormat.format(getLastModificationDate())); - list.add(getCreationDate() == null ? " " : + list.add(getCreationDate() == null ? textBundle.get("ProdosFileEntry.NullDate") : //$NON-NLS-1$ dateFormat.format(getCreationDate())); numberFormat.setMinimumIntegerDigits(1); list.add(numberFormat.format(getEofPosition())); - if ("TXT".equals(getFiletype()) && getAuxiliaryType() > 0) { + if ("TXT".equals(getFiletype()) && getAuxiliaryType() > 0) { //$NON-NLS-1$ numberFormat.setMinimumIntegerDigits(1); - list.add("L=" + numberFormat.format(getAuxiliaryType()).trim()); - } else if (("BIN".equals(getFiletype()) || "BAS".equals(getFiletype()) - || "VAR".equals(getFiletype()) || "SYS".equals(getFiletype())) + list.add("L=" + numberFormat.format(getAuxiliaryType()).trim()); //$NON-NLS-1$ + } else if (("BIN".equals(getFiletype()) || "BAS".equals(getFiletype()) //$NON-NLS-1$ //$NON-NLS-2$ + || "VAR".equals(getFiletype()) || "SYS".equals(getFiletype())) //$NON-NLS-1$ //$NON-NLS-2$ && getAuxiliaryType() > 0) { - list.add("A=$" + AppleUtil.getFormattedWord(getAuxiliaryType())); + list.add("A=$" + AppleUtil.getFormattedWord(getAuxiliaryType())); //$NON-NLS-1$ } else { - list.add("$" + AppleUtil.getFormattedWord(getAuxiliaryType())); + list.add("$" + AppleUtil.getFormattedWord(getAuxiliaryType())); //$NON-NLS-1$ } list.add(AppleUtil.getFormattedWord(getHeaderPointer())); list.add(AppleUtil.getFormattedWord(getKeyPointer())); - list.add(isSaplingFile() ? "Sapling" : isSeedlingFile() ? "Seedling" : - isTreeFile() ? "Tree" : "Unknown (" + getFileTypeString() + ")"); - list.add(hasChanged() ? "Changed" : ""); + list.add(isSaplingFile() ? textBundle.get("ProdosFileEntry.Sapling") : //$NON-NLS-1$ + isSeedlingFile() ? textBundle.get("ProdosFileEntry.Seedling") : //$NON-NLS-1$ + isTreeFile() ? textBundle.get("ProdosFileEntry.Tree") : //$NON-NLS-1$ + textBundle.format("ProdosFileEntry.UnknownFileType", getFileTypeString())); //$NON-NLS-1$ + list.add(hasChanged() ? + textBundle.get("ProdosFileEntry.Changed") : ""); //$NON-NLS-1$//$NON-NLS-2$ numberFormat.setMinimumIntegerDigits(1); list.add(numberFormat.format(getMinimumProdosVersion())); list.add(numberFormat.format(getProdosVersion())); @@ -414,7 +424,7 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry { list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add(isLocked() ? "Locked" : ""); + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; } return list; @@ -424,7 +434,7 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry { * Return the ProDOS file type as a hex string. */ public String getFileTypeString() { - return "$" + AppleUtil.getFormattedByte(getStorageType()); + return "$" + AppleUtil.getFormattedByte(getStorageType()); //$NON-NLS-1$ } /** @@ -457,7 +467,7 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry { switch (filetype) { case 0x04: // TXT - if (getFilename().endsWith(".S")) { + if (getFilename().endsWith(".S")) { //$NON-NLS-1$ return new AssemblySourceFileFilter(); } return new TextFileFilter(); diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java index e5cd768..353dd69 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java @@ -29,8 +29,10 @@ import java.util.Properties; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in the ProDOS format. @@ -39,6 +41,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class ProdosFormatDisk extends FormattedDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The location of the "next block" pointer in a directory entry. * This is a 2-byte word (lo/hi) format. $0000 is end of directory. @@ -107,7 +110,7 @@ public class ProdosFormatDisk extends FormattedDisk { private int location = -1; private transient byte[] data = null; public boolean hasNext() { - return location == -1 || location < volumeHeader.getTotalBlocks() - 1; + return location == -1 || location < getVolumeHeader().getTotalBlocks() - 1; } public void next() { location++; @@ -117,7 +120,8 @@ public class ProdosFormatDisk extends FormattedDisk { */ public boolean isFree() { if (location == -1) { - throw new IllegalArgumentException("Invalid dimension for isFree! Did you call next first?"); + throw new IllegalArgumentException(StorageBundle.getInstance() + .get("ProdosFormatDisk.InvalidDimensionError")); //$NON-NLS-1$ } if (data == null) { data = readVolumeBitMap(); @@ -132,7 +136,6 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Constructor for ProdosFormatDisk. * @param filename - * @param diskImage */ public ProdosFormatDisk(String filename, ImageOrder imageOrder) { super(filename, imageOrder); @@ -148,23 +151,24 @@ public class ProdosFormatDisk extends FormattedDisk { fileTypes = new ProdosFileType[256]; InputStream inputStream = - getClass().getResourceAsStream("ProdosFileTypes.properties"); + getClass().getResourceAsStream("ProdosFileTypes.properties"); //$NON-NLS-1$ Properties properties = new Properties(); try { properties.load(inputStream); for (int i=0; i<256; i++) { String byt = AppleUtil.getFormattedByte(i).toLowerCase(); - String string = (String) properties.get("filetype." + byt); + String string = (String) properties.get("filetype." + byt); //$NON-NLS-1$ if (string == null || string.length() == 0) { - string = "$" + byt.toUpperCase(); + string = "$" + byt.toUpperCase(); //$NON-NLS-1$ } boolean addressRequired = Boolean.valueOf((String) properties.get( - "filetype." + byt + ".address")).booleanValue(); + "filetype." + byt + ".address")).booleanValue(); //$NON-NLS-1$ //$NON-NLS-2$ boolean canCompile = Boolean.valueOf((String) properties.get( - "filetype." + byt + ".compile")).booleanValue(); + "filetype." + byt + ".compile")).booleanValue(); //$NON-NLS-1$ //$NON-NLS-2$ fileTypes[i] = new ProdosFileType((byte)i, string, addressRequired, canCompile); } } catch (IOException ignored) { + // Ignored } } @@ -180,10 +184,10 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Identify the operating system format of this disk. - * @see com.webcodepro.applecommander.storage.Disk#getFormat() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFormat() */ public String getFormat() { - return "ProDOS"; + return textBundle.get("Prodos"); //$NON-NLS-1$ } /** @@ -219,7 +223,7 @@ public class ProdosFormatDisk extends FormattedDisk { fileEntry.setCanWrite(true); fileEntry.setSeedlingFile(); fileEntry.setHeaderPointer(headerBlock); - fileEntry.setFilename("BLANK"); + fileEntry.setFilename(textBundle.get("ProdosFormatDisk.Blank")); //$NON-NLS-1$ directory.incrementFileCount(); return fileEntry; } @@ -245,12 +249,12 @@ public class ProdosFormatDisk extends FormattedDisk { } blockNumber = nextBlockNumber; } - throw new DiskFullException("Unable to allocate more space for another file!"); + throw new DiskFullException(textBundle.get("ProdosFormatDisk.UnableToAllocateSpaceError")); //$NON-NLS-1$ } /** * Retrieve a list of files. - * @see com.webcodepro.applecommander.storage.Disk#getFiles() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles() */ public List getFiles() { return getFiles(VOLUME_DIRECTORY_BLOCK); @@ -292,7 +296,7 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Return the amount of free space in bytes. - * @see com.webcodepro.applecommander.storage.Disk#getFreeSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getFreeSpace() */ public int getFreeSpace() { return getFreeBlocks() * BLOCK_SIZE; @@ -316,7 +320,7 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Return the amount of used space in bytes. - * @see com.webcodepro.applecommander.storage.Disk#getUsedSpace() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getUsedSpace() */ public int getUsedSpace() { return getUsedBlocks() * BLOCK_SIZE; @@ -350,10 +354,10 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Return the name of the disk. - * @see com.webcodepro.applecommander.storage.Disk#getDiskName() + * @see com.webcodepro.applecommander.storage.FormattedDisk#getDiskName() */ public String getDiskName() { - return "/" + volumeHeader.getVolumeName() + "/"; + return "/" + volumeHeader.getVolumeName() + "/"; //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -389,7 +393,7 @@ public class ProdosFormatDisk extends FormattedDisk { * Get the labels to use in the bitmap. */ public String[] getBitmapLabels() { - return new String[] { "Block" }; + return new String[] { textBundle.get("Block") }; //$NON-NLS-1$ } /** @@ -397,23 +401,26 @@ public class ProdosFormatDisk extends FormattedDisk { */ public List getDiskInformation() { List list = super.getDiskInformation(); - list.add(new DiskInformation("Total Blocks", volumeHeader.getTotalBlocks())); - list.add(new DiskInformation("Free Blocks", getFreeBlocks())); - list.add(new DiskInformation("Used Blocks", getUsedBlocks())); - list.add(new DiskInformation("Volume Access", - (volumeHeader.canDestroy() ? "Destroy " : "") + - (volumeHeader.canRead() ? "Read " : "") + - (volumeHeader.canRename() ? "Rename " : "") + - (volumeHeader.canWrite() ? "Write" : ""))); - list.add(new DiskInformation("Block Number of Bitmap", volumeHeader.getBitMapPointer())); - list.add(new DiskInformation("Creation Date", volumeHeader.getCreationDate())); - list.add(new DiskInformation("File Entries Per Block", volumeHeader.getEntriesPerBlock())); - list.add(new DiskInformation("File Entry Length (bytes)", volumeHeader.getEntryLength())); - list.add(new DiskInformation("Active Files in Root Directory", volumeHeader.getFileCount())); - list.add(new DiskInformation("Minimum ProDOS Version Required", + list.add(new DiskInformation(textBundle.get("TotalBlocks"), //$NON-NLS-1$ + volumeHeader.getTotalBlocks())); + list.add(new DiskInformation(textBundle.get("FreeBlocks"), //$NON-NLS-1$ + getFreeBlocks())); + list.add(new DiskInformation(textBundle.get("UsedBlocks"), //$NON-NLS-1$ + getUsedBlocks())); + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.VolumeAccess"), //$NON-NLS-1$ + (volumeHeader.canDestroy() ? textBundle.get("Destroy") : "") + //$NON-NLS-1$//$NON-NLS-2$ + (volumeHeader.canRead() ? textBundle.get("Read") : "") + //$NON-NLS-1$//$NON-NLS-2$ + (volumeHeader.canRename() ? textBundle.get("Rename") : "") + //$NON-NLS-1$//$NON-NLS-2$ + (volumeHeader.canWrite() ? textBundle.get("Write") : ""))); //$NON-NLS-1$//$NON-NLS-2$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.BitmapBlockNumber"), volumeHeader.getBitMapPointer())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.CreationDate"), volumeHeader.getCreationDate())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.FileEntriesPerBlock"), volumeHeader.getEntriesPerBlock())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.FileEntryLength"), volumeHeader.getEntryLength())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.ActiveFilesInRootDirectory"), volumeHeader.getFileCount())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.MinimumVersionProdos"), //$NON-NLS-1$ volumeHeader.getMinimumProdosVersion())); - list.add(new DiskInformation("Volume Created By ProDOS Version", volumeHeader.getProdosVersion())); - list.add(new DiskInformation("Volume Name", volumeHeader.getVolumeName())); + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.CreationVersionProdos"), volumeHeader.getProdosVersion())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("ProdosFormatDisk.VolumeName"), volumeHeader.getVolumeName())); //$NON-NLS-1$ return list; } @@ -425,33 +432,46 @@ public class ProdosFormatDisk extends FormattedDisk { List list = new ArrayList(); switch (displayMode) { case FILE_DISPLAY_NATIVE: - list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Name", 15, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Filetype", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Modified", 10, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Created", 10, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Length", 10, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Aux. Type", 8, FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 15, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("Filetype"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Modified"), 10, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader( + textBundle.get("ProdosFormatDisk.Created"), 10, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader( + textBundle.get("ProdosFormatDisk.Length"), 10, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader( + textBundle.get("ProdosFormatDisk.AuxType"), 8, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); break; case FILE_DISPLAY_DETAIL: - list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Name", 15, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Deleted?", 7, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Permissions", 8, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Filetype", 8, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Directory?", 9, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Modified", 10, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Created", 10, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Length", 10, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Aux. Type", 8, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Dir. Header", 5, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Key Block", 5, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Key Type", 8, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Changed", 5, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Min. ProDOS Ver.", 2, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("ProDOS Ver.", 2, FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(" ", 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 15, //$NON-NLS-1$ + FileColumnHeader.ALIGN_LEFT)); + list.add(new FileColumnHeader(textBundle.get("DeletedQ"), 7, //$NON-NLS-1$ + FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.Permissions"), 8, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Filetype"), 8, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.DirectoryQ"), 9, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, //$NON-NLS-1$ + FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Modified"), 10, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.Created"), 10, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.Length"), 10, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.AuxType"), 8, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.DirectoryHeader"), 5, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.KeyBlock"), 5, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.KeyType"), 8, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.Changed"), 5, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.MinimumProdosVersion"), 2, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("ProdosFormatDisk.ProdosVersion"), 2, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ break; default: // FILE_DISPLAY_STANDARD list.addAll(super.getFileColumnHeaders(displayMode)); @@ -476,7 +496,7 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Identify if this disk format is capable of having directories. - * @see com.webcodepro.applecommander.storage.Disk#canHaveDirectories() + * @see com.webcodepro.applecommander.storage.FormattedDisk#canHaveDirectories() */ public boolean canHaveDirectories() { return true; @@ -502,7 +522,7 @@ public class ProdosFormatDisk extends FormattedDisk { */ public byte[] getFileData(FileEntry fileEntry) { if ( !(fileEntry instanceof ProdosFileEntry)) { - throw new IllegalArgumentException("Most have a ProDOS file entry!"); + throw new IllegalArgumentException(textBundle.get("ProdosFormatDisk.MustHaveEntry")); //$NON-NLS-1$ } ProdosFileEntry prodosEntry = (ProdosFileEntry) fileEntry; byte[] fileData = new byte[prodosEntry.getEofPosition()]; @@ -524,7 +544,7 @@ public class ProdosFormatDisk extends FormattedDisk { } } } else { - throw new IllegalArgumentException("Unknown ProDOS storage type!"); + throw new IllegalArgumentException(textBundle.get("ProdosFormatDisk.UnknownStorageType")); //$NON-NLS-1$ } return fileData; } @@ -565,7 +585,6 @@ public class ProdosFormatDisk extends FormattedDisk { /** * Read file data from the given index block. * Note that block number 0 is an unused block. - * @see #getFileData() */ protected int getIndexBlockData(byte[] fileData, byte[] indexBlock, int offset) { for (int i=0; i<0x100; i++) { @@ -576,10 +595,9 @@ public class ProdosFormatDisk extends FormattedDisk { if (blockNumber != 0) System.arraycopy(blockData, 0, fileData, offset, bytesToCopy); offset+= bytesToCopy; break; - } else { - if (blockNumber != 0) System.arraycopy(blockData, 0, fileData, offset, blockData.length); - offset+= blockData.length; } + if (blockNumber != 0) System.arraycopy(blockData, 0, fileData, offset, blockData.length); + offset+= blockData.length; } return offset; } @@ -601,9 +619,9 @@ public class ProdosFormatDisk extends FormattedDisk { } } if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) { - throw new DiskFullException("This file requires " + numberOfBlocks - + " blocks but there are only " + getFreeBlocks() + " blocks" - + " available on the disk."); + throw new DiskFullException(textBundle. + format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$ + numberOfBlocks, getFreeBlocks())); } // free "old" data and just rewrite stuff... freeBlocks(fileEntry); @@ -691,12 +709,12 @@ public class ProdosFormatDisk extends FormattedDisk { return block; } throw new ProdosDiskSizeDoesNotMatchException( - "The ProDOS physical disk size does not match the formatted size."); + textBundle.get("ProdosFormatDisk.ProdosDiskSizeDoesNotMatchError")); //$NON-NLS-1$ } block++; } throw new DiskFullException( - "Unable to locate a free block in the Volume Bitmap!"); + textBundle.get("ProdosFormatDisk.NoFreeBlockAvailableError")); //$NON-NLS-1$ } /** @@ -723,7 +741,7 @@ public class ProdosFormatDisk extends FormattedDisk { int blocksToWrite = (volumeBitmapBlocks / 4096) + 1; if (data.length != blocksToWrite * BLOCK_SIZE) { throw new IllegalArgumentException( - "The ProDOS Volume Bit Map is not the correct size."); + textBundle.get("ProdosFormatDisk.UnexpectedVolumeBitMapSizeError")); //$NON-NLS-1$ } byte[] dataBlock = new byte[BLOCK_SIZE]; for (int i=0; i 0) { String what = filename.substring(pos+1); ProdosFileType type = findFileType(what); @@ -957,4 +975,8 @@ public class ProdosFormatDisk extends FormattedDisk { public void setFileData(FileEntry fileEntry, byte[] fileData) throws DiskFullException { setFileData((ProdosFileEntry)fileEntry, fileData); } + + protected ProdosVolumeDirectoryHeader getVolumeHeader() { + return volumeHeader; + } } diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosSubdirectoryHeader.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosSubdirectoryHeader.java index ce08a60..bbe20b3 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosSubdirectoryHeader.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosSubdirectoryHeader.java @@ -32,7 +32,6 @@ public class ProdosSubdirectoryHeader extends ProdosCommonDirectoryHeader { /** * Constructor for ProdosSubdirectoryHeader. - * @param fileEntry */ public ProdosSubdirectoryHeader(ProdosFormatDisk disk, int block) { super(disk, block); diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosVolumeDirectoryHeader.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosVolumeDirectoryHeader.java index c555567..33bfea9 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosVolumeDirectoryHeader.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosVolumeDirectoryHeader.java @@ -31,7 +31,6 @@ public class ProdosVolumeDirectoryHeader extends ProdosCommonDirectoryHeader { /** * Constructor for ProdosVolumeDirectoryHeaderEntry. - * @param fileEntry */ public ProdosVolumeDirectoryHeader(ProdosFormatDisk disk) { super(disk, 2); diff --git a/src/com/webcodepro/applecommander/storage/os/rdos/RdosFileEntry.java b/src/com/webcodepro/applecommander/storage/os/rdos/RdosFileEntry.java index 3729f8e..18cd502 100644 --- a/src/com/webcodepro/applecommander/storage/os/rdos/RdosFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/rdos/RdosFileEntry.java @@ -27,12 +27,14 @@ import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.ApplesoftFileFilter; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Handle RDOS file entry format. @@ -54,6 +56,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class RdosFileEntry implements FileEntry { + private TextBundle textBundle = StorageBundle.getInstance(); private byte[] fileEntry; private RdosFormatDisk disk; @@ -91,7 +94,7 @@ public class RdosFileEntry implements FileEntry { * Return the name of this file. */ public String getFilename() { - return isDeleted() ? " " : AppleUtil.getString(fileEntry, 0, 24); + return isDeleted() ? textBundle.get("RdosFileEntry.NotInUse") : AppleUtil.getString(fileEntry, 0, 24); //$NON-NLS-1$ } /** @@ -112,7 +115,7 @@ public class RdosFileEntry implements FileEntry { * Return the filetype of this file. */ public String getFiletype() { - return isDeleted() ? " " : AppleUtil.getString(fileEntry, 0x18, 1); + return isDeleted() ? " " : AppleUtil.getString(fileEntry, 0x18, 1); //$NON-NLS-1$ } /** @@ -201,14 +204,14 @@ public class RdosFileEntry implements FileEntry { list.add(numberFormat.format(getSize())); numberFormat.setMinimumIntegerDigits(3); list.add(numberFormat.format(getStartingBlock())); - list.add("$" + AppleUtil.getFormattedWord(getAddress())); - list.add(isDeleted() ? "Deleted" : ""); + list.add("$" + AppleUtil.getFormattedWord(getAddress())); //$NON-NLS-1$ + list.add(isDeleted() ? textBundle.get("Deleted") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; default: // FILE_DISPLAY_STANDARD list.add(getFilename()); list.add(getFiletype()); list.add(numberFormat.format(getSize())); - list.add(isLocked() ? "Locked" : ""); + list.add(isLocked() ? textBundle.get("Locked") : ""); //$NON-NLS-1$//$NON-NLS-2$ break; } return list; @@ -267,28 +270,28 @@ public class RdosFileEntry implements FileEntry { * Determine if this is a text file. */ public boolean isTextFile() { - return "T".equals(getFiletype()); + return "T".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is an Applesoft BASIC file. */ public boolean isApplesoftBasicFile() { - return "A".equals(getFiletype()); + return "A".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is an Integer BASIC file. */ public boolean isIntegerBasicFile() { - return "I".equals(getFiletype()); + return "I".equals(getFiletype()); //$NON-NLS-1$ } /** * Determine if this is a binary file. */ public boolean isBinaryFile() { - return "B".equals(getFiletype()); + return "B".equals(getFiletype()); //$NON-NLS-1$ } /** diff --git a/src/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java index a0638c9..280729f 100644 --- a/src/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java @@ -27,8 +27,10 @@ import java.util.List; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Manages a disk that is in the RDOS format. @@ -47,6 +49,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene */ public class RdosFormatDisk extends FormattedDisk { + private TextBundle textBundle = StorageBundle.getInstance(); /** * The RDOS disks are structured in a different order than DOS 3.3. * This table interpolates between the RDOS ordering and the DOS @@ -69,7 +72,7 @@ public class RdosFormatDisk extends FormattedDisk { /** * The known filetypes for a RDOS disk. */ - public static final String[] filetypes = { "B", "A", "T" }; + public static final String[] filetypes = { "B", "A", "T" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /** * Use this inner interface for managing the disk usage data. @@ -123,8 +126,6 @@ public class RdosFormatDisk extends FormattedDisk { /** * Constructor for RdosFormatDisk. - * @param filename - * @param diskImage */ public RdosFormatDisk(String filename, ImageOrder imageOrder) { super(filename, imageOrder); @@ -200,7 +201,7 @@ public class RdosFormatDisk extends FormattedDisk { * Create a new FileEntry. */ public FileEntry createFile() throws DiskFullException { - throw new DiskFullException("Cannot create a file (yet)."); + throw new DiskFullException(textBundle.get("FileCreationNotSupported")); //$NON-NLS-1$ } /** @@ -226,7 +227,7 @@ public class RdosFormatDisk extends FormattedDisk { * Identify the operating system format of this disk. */ public String getFormat() { - return "RDOS 2.1"; + return textBundle.get("RdosFormatDisk.Rdos21"); //$NON-NLS-1$ } /** @@ -289,7 +290,7 @@ public class RdosFormatDisk extends FormattedDisk { * Get the labels to use in the bitmap. */ public String[] getBitmapLabels() { - return new String[] { "Block" }; + return new String[] { textBundle.get("Block") }; //$NON-NLS-1$ } /** @@ -297,9 +298,9 @@ public class RdosFormatDisk extends FormattedDisk { */ public List getDiskInformation() { List list = super.getDiskInformation(); - list.add(new DiskInformation("Total Blocks", BLOCKS_ON_DISK)); - list.add(new DiskInformation("Free Blocks", getFreeBlocks())); - list.add(new DiskInformation("Used Blocks", getUsedBlocks())); + list.add(new DiskInformation(textBundle.get("TotalBlocks"), BLOCKS_ON_DISK)); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("FreeBlocks"), getFreeBlocks())); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("UsedBlocks"), getUsedBlocks())); //$NON-NLS-1$ return list; } @@ -311,20 +312,20 @@ public class RdosFormatDisk extends FormattedDisk { List list = new ArrayList(); switch (displayMode) { case FILE_DISPLAY_NATIVE: - list.add(new FileColumnHeader("Type", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Name", 24, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Size", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Starting Block", 3, FileColumnHeader.ALIGN_RIGHT)); + list.add(new FileColumnHeader(textBundle.get("Type"), 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 24, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("RdosFormatDisk.Size"), 6, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("RdosFormatDisk.StartingBlock"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ break; case FILE_DISPLAY_DETAIL: - list.add(new FileColumnHeader("Type", 1, FileColumnHeader.ALIGN_CENTER)); - list.add(new FileColumnHeader("Blocks", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Name", 24, FileColumnHeader.ALIGN_LEFT)); - list.add(new FileColumnHeader("Size", 6, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Starting Block", 3, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Address", 5, FileColumnHeader.ALIGN_RIGHT)); - list.add(new FileColumnHeader("Deleted?", 7, FileColumnHeader.ALIGN_CENTER)); + list.add(new FileColumnHeader(textBundle.get("Type"), 1, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Blocks"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("Name"), 24, FileColumnHeader.ALIGN_LEFT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("RdosFormatDisk.Size"), 6, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("RdosFormatDisk.StartingBlock"), 3, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("RdosFormatDisk.Address"), 5, FileColumnHeader.ALIGN_RIGHT)); //$NON-NLS-1$ + list.add(new FileColumnHeader(textBundle.get("DeletedQ"), 7, FileColumnHeader.ALIGN_CENTER)); //$NON-NLS-1$ break; default: // FILE_DISPLAY_STANDARD list.addAll(super.getFileColumnHeaders(displayMode)); @@ -373,7 +374,7 @@ public class RdosFormatDisk extends FormattedDisk { */ public byte[] getFileData(FileEntry fileEntry) { if ( !(fileEntry instanceof RdosFileEntry)) { - throw new IllegalArgumentException("Most have a RDOS file entry!"); + throw new IllegalArgumentException(textBundle.get("RdosFormatDisk.IncorrectFileEntryError")); //$NON-NLS-1$ } RdosFileEntry rdosEntry = (RdosFileEntry) fileEntry; int startingBlock = rdosEntry.getStartingBlock(); @@ -403,7 +404,7 @@ public class RdosFormatDisk extends FormattedDisk { // minor hack - ensure that AppleCommander itself recognizes the // RDOS disk! byte[] block = readSector(0, 0x0d); - AppleUtil.setString(block, 0xe0, "RDOS FORMATTED BY APPLECOMMANDER", 0x20); + AppleUtil.setString(block, 0xe0, textBundle.get("RdosFormatDisk.IdentifierText"), 0x20); //$NON-NLS-1$ writeSector(0, 0x0d, block); // a hack - until real code goes here. block = new byte[256]; @@ -412,8 +413,8 @@ public class RdosFormatDisk extends FormattedDisk { // write the first directory entry // FIXME - this should use FileEntry! byte[] data = readRdosBlock(13); - AppleUtil.setString(data, 0x00, "RDOS 2.1 FORMAT NOBOOT", 0x18); - AppleUtil.setString(data, 0x18, "B", 0x01); + AppleUtil.setString(data, 0x00, textBundle.get("RdosFormatDisk.InitialSystemFile"), 0x18); //$NON-NLS-1$ + AppleUtil.setString(data, 0x18, "B", 0x01); //$NON-NLS-1$ data[0x19] = 26; AppleUtil.setWordValue(data, 0x1a, 0x1000); AppleUtil.setWordValue(data, 0x1c, 6656); @@ -445,12 +446,12 @@ public class RdosFormatDisk extends FormattedDisk { * as to the filetype. */ public String getSuggestedFiletype(String filename) { - String filetype = "B"; - int pos = filename.lastIndexOf("."); + String filetype = "B"; //$NON-NLS-1$ + int pos = filename.lastIndexOf("."); //$NON-NLS-1$ if (pos > 0) { String what = filename.substring(pos+1); - if ("txt".equalsIgnoreCase(what)) { - filetype = "T"; + if ("txt".equalsIgnoreCase(what)) { //$NON-NLS-1$ + filetype = "T"; //$NON-NLS-1$ } } return filetype; @@ -470,7 +471,7 @@ public class RdosFormatDisk extends FormattedDisk { * address. */ public boolean needsAddress(String filetype) { - return "B".equals(filetype); + return "B".equals(filetype); //$NON-NLS-1$ } /** diff --git a/src/com/webcodepro/applecommander/storage/physical/DosOrder.java b/src/com/webcodepro/applecommander/storage/physical/DosOrder.java index baf664c..7a3d3aa 100644 --- a/src/com/webcodepro/applecommander/storage/physical/DosOrder.java +++ b/src/com/webcodepro/applecommander/storage/physical/DosOrder.java @@ -20,6 +20,8 @@ package com.webcodepro.applecommander.storage.physical; import com.webcodepro.applecommander.storage.Disk; +import com.webcodepro.applecommander.storage.StorageBundle; +import com.webcodepro.applecommander.util.TextBundle; /** * Supports disk images stored in DOS physical order. @@ -27,6 +29,7 @@ import com.webcodepro.applecommander.storage.Disk; * @author Rob Greene (RobGreene@users.sourceforge.net) */ public class DosOrder extends ImageOrder { + private TextBundle textBundle = StorageBundle.getInstance(); /** * Construct a DosOrder. */ @@ -73,16 +76,16 @@ public class DosOrder extends ImageOrder { && !isSizeApprox(Disk.APPLE_800KB_DISK) && !isSizeApprox(Disk.APPLE_800KB_2IMG_DISK) && track != 0 && sector != 0) { // HACK: Allows boot sector writing - throw new IllegalArgumentException("Unrecognized DOS format!"); + throw new IllegalArgumentException( + textBundle.get("DosOrder.UnrecognizedFormatError")); //$NON-NLS-1$ } int offset = (track * getSectorsPerTrack() + sector) * Disk.SECTOR_SIZE; if (offset > getPhysicalSize()) { throw new IllegalArgumentException( - "The track (" + track + ") and sector (" + sector - + ") do not match the disk image size."); - } else { - return offset; + textBundle.format("DosOrder.InvalidSizeError", //$NON-NLS-1$ + track, sector)); } + return offset; } /** diff --git a/src/com/webcodepro/applecommander/storage/physical/NibbleOrder.java b/src/com/webcodepro/applecommander/storage/physical/NibbleOrder.java index 2d1af28..109a035 100644 --- a/src/com/webcodepro/applecommander/storage/physical/NibbleOrder.java +++ b/src/com/webcodepro/applecommander/storage/physical/NibbleOrder.java @@ -21,7 +21,9 @@ package com.webcodepro.applecommander.storage.physical; import java.util.Arrays; +import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.util.AppleUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Supports disk images stored in nibbilized DOS physical order. @@ -29,6 +31,7 @@ import com.webcodepro.applecommander.util.AppleUtil; * @author Rob Greene (RobGreene@users.sourceforge.net) */ public class NibbleOrder extends DosOrder { + private TextBundle textBundle = StorageBundle.getInstance(); /** * This is the 6 and 2 write translate table, as given in Beneath * Apple DOS, pg 3-21. @@ -111,8 +114,8 @@ public class NibbleOrder extends DosOrder { found = (t == track && s == sector); } if (!found) { - throw new IllegalArgumentException("Unable to locate physical sector " - + sector + " on track " + track + "(#2)"); + throw new IllegalArgumentException(textBundle + .format("NibbleOrder.InvalidPhysicalSectorError", sector, track, 1)); //$NON-NLS-1$ } // 3. read data field that immediately follows the address field byte[] dataField = new byte[349]; @@ -218,8 +221,8 @@ public class NibbleOrder extends DosOrder { while (!found && offset < trackData.length) { int nextOffset = locateField(0xd5, 0xaa, 0x96, trackData, addressField, offset); if (nextOffset < offset) { // we wrapped! - throw new IllegalArgumentException("Unable to locate physical sector " - + sector + " on track " + track); + throw new IllegalArgumentException(textBundle + .format("NibbleOrder.InvalidPhysicalSectorError", sector, track, 2)); //$NON-NLS-1$ } offset = nextOffset; int t = decodeOddEven(addressField, 5); @@ -227,8 +230,8 @@ public class NibbleOrder extends DosOrder { found = (t == track && s == sector); } if (!found) { - throw new IllegalArgumentException("Unable to locate physical sector " - + sector + " on track " + track + "(#2)"); + throw new IllegalArgumentException(textBundle + .format("NibbleOrder.InvalidPhysicalSectorError", sector, track, 2)); //$NON-NLS-1$ } // 3. PRENIBBLE: This is Java translated from assembly @ $B800 diff --git a/src/com/webcodepro/applecommander/ui/AppleCommander.java b/src/com/webcodepro/applecommander/ui/AppleCommander.java index 0838c32..c1043dc 100644 --- a/src/com/webcodepro/applecommander/ui/AppleCommander.java +++ b/src/com/webcodepro/applecommander/ui/AppleCommander.java @@ -22,6 +22,8 @@ package com.webcodepro.applecommander.ui; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.webcodepro.applecommander.util.TextBundle; + /** * Launch AppleCommander. * This application attempts to identify which type of user-interface to @@ -39,7 +41,7 @@ import java.lang.reflect.Method; */ public class AppleCommander { public static final String VERSION = "1.3.4pre"; //$NON-NLS-1$ - private static TextBundle textBundle = TextBundle.getInstance(); + private static TextBundle textBundle = UiBundle.getInstance(); /** * Launch AppleCommander. */ diff --git a/src/com/webcodepro/applecommander/ui/UserPreferences.java b/src/com/webcodepro/applecommander/ui/UserPreferences.java index c83c4cf..825bafc 100644 --- a/src/com/webcodepro/applecommander/ui/UserPreferences.java +++ b/src/com/webcodepro/applecommander/ui/UserPreferences.java @@ -73,7 +73,7 @@ public class UserPreferences { public void save() { try { FileOutputStream outputStream = new FileOutputStream(FILENAME); - properties.store(outputStream, TextBundle.getInstance(). + properties.store(outputStream, UiBundle.getInstance(). get("UserPreferencesComment")); //$NON-NLS-1$ outputStream.close(); } catch (Exception ignored) { diff --git a/src/com/webcodepro/applecommander/ui/ac.java b/src/com/webcodepro/applecommander/ui/ac.java index 5226a43..bc675fa 100644 --- a/src/com/webcodepro/applecommander/ui/ac.java +++ b/src/com/webcodepro/applecommander/ui/ac.java @@ -34,9 +34,10 @@ import com.webcodepro.applecommander.storage.os.prodos.ProdosFormatDisk; import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ProdosOrder; +import com.webcodepro.applecommander.util.TextBundle; public class ac { - private static TextBundle textBundle = TextBundle.getInstance(); + private static TextBundle textBundle = UiBundle.getInstance(); public static void main(String[] args) { try { diff --git a/src/com/webcodepro/applecommander/ui/swt/DiskExplorerTab.java b/src/com/webcodepro/applecommander/ui/swt/DiskExplorerTab.java index bee3806..8d0ceeb 100644 --- a/src/com/webcodepro/applecommander/ui/swt/DiskExplorerTab.java +++ b/src/com/webcodepro/applecommander/ui/swt/DiskExplorerTab.java @@ -94,7 +94,7 @@ import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.NibbleOrder; import com.webcodepro.applecommander.storage.physical.ProdosOrder; import com.webcodepro.applecommander.ui.ImportSpecification; -import com.webcodepro.applecommander.ui.TextBundle; +import com.webcodepro.applecommander.ui.UiBundle; import com.webcodepro.applecommander.ui.UserPreferences; import com.webcodepro.applecommander.ui.swt.util.DropDownSelectionListener; import com.webcodepro.applecommander.ui.swt.util.ImageManager; @@ -104,6 +104,7 @@ import com.webcodepro.applecommander.ui.swt.wizard.exportfile.ExportWizard; import com.webcodepro.applecommander.ui.swt.wizard.importfile.ImportWizard; import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.StreamUtil; +import com.webcodepro.applecommander.util.TextBundle; /** * Build the Disk File tab for the Disk Window. @@ -146,7 +147,7 @@ public class DiskExplorerTab { private Menu changeImageOrderMenu; private UserPreferences userPreferences = UserPreferences.getInstance(); - private TextBundle textBundle = TextBundle.getInstance(); + private TextBundle textBundle = UiBundle.getInstance(); private FileFilter fileFilter; private GraphicsFileFilter graphicsFilter = new GraphicsFileFilter(); private AppleWorksWordProcessorFileFilter awpFilter = new AppleWorksWordProcessorFileFilter(); @@ -591,7 +592,7 @@ public class DiskExplorerTab { item = new MenuItem(menu, SWT.NONE); item.setText(textBundle.get("ExportAsGraphicsMenuItem")); //$NON-NLS-1$ - item.setEnabled(graphicsFilter.isCodecAvailable()); + item.setEnabled(GraphicsFileFilter.isCodecAvailable()); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { setFileFilter(getGraphicsFilter()); @@ -602,7 +603,7 @@ public class DiskExplorerTab { // Add graphics mode item = new MenuItem(menu, SWT.CASCADE); item.setText(textBundle.get("ExportGraphicsModeMenuItem")); //$NON-NLS-1$ - item.setEnabled(graphicsFilter.isCodecAvailable()); + item.setEnabled(GraphicsFileFilter.isCodecAvailable()); subMenu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(subMenu); subMenu.addMenuListener(new MenuAdapter() { @@ -694,11 +695,11 @@ public class DiskExplorerTab { }); // Add graphics formats, if any are defined. - String[] formats = graphicsFilter.getFileExtensions(); + String[] formats = GraphicsFileFilter.getFileExtensions(); if (formats != null && formats.length > 0) { item = new MenuItem(menu, SWT.CASCADE); item.setText(textBundle.get("ExportGraphicsFormatMenuItem")); //$NON-NLS-1$ - item.setEnabled(graphicsFilter.isCodecAvailable()); + item.setEnabled(GraphicsFileFilter.isCodecAvailable()); subMenu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(subMenu); subMenu.addMenuListener(new MenuAdapter() { @@ -1255,7 +1256,7 @@ public class DiskExplorerTab { }); printToolItem = new ToolItem(toolBar, SWT.PUSH); printToolItem.setImage(imageManager.get(ImageManager.ICON_PRINT_FILE)); - printToolItem.setText(textBundle.get("PrintDirectoryToolItem")); //$NON-NLS-1$ + printToolItem.setText(textBundle.get("PrintButton")); //$NON-NLS-1$ printToolItem.setToolTipText(textBundle.get("PrintDirectoryHoverText")); //$NON-NLS-1$ printToolItem.setEnabled(true); printToolItem.addSelectionListener(new SelectionAdapter () { @@ -1616,8 +1617,8 @@ public class DiskExplorerTab { private Rectangle clientArea; private GC gc; private List fileHeaders; - private int[] columnWidths; - private int[] columnPosition; + private int[] printColumnWidths; + private int[] printColumnPosition; private Font normalFont; private Font headerFont; private String filename; @@ -1677,13 +1678,13 @@ public class DiskExplorerTab { header.getMaximumWidth() : header.getTitle().length(); totalWidth+= widths[i]; } - columnWidths = new int[fileHeaders.size()]; - columnPosition = new int[fileHeaders.size()]; + printColumnWidths = new int[fileHeaders.size()]; + printColumnPosition = new int[fileHeaders.size()]; int position = clientArea.x; for (int i=0; i 0) { - item.setText("Disk Map #" + disk.getLogicalDiskNumber()); + item.setText(textBundle.get("DiskMapTab.MultipleTabsTitle") + disk.getLogicalDiskNumber()); //$NON-NLS-1$ } else { - item.setText("Disk Map"); + item.setText(textBundle.get("DiskMapTab.SingleTabTitle")); //$NON-NLS-1$ } Canvas canvas = new Canvas(tabFolder, SWT.NULL); @@ -91,19 +94,13 @@ public class DiskMapTab { Label title = new Label(canvas, SWT.LEFT); StringBuffer buf = new StringBuffer(); if (labels.length == 1) { - buf.append("This disk is organized by the "); - buf.append(labels[0].toLowerCase()); - buf.append(". Therefore, no organization has been forced on the "); - buf.append(labels[0].toLowerCase()); - buf.append(" layout."); + buf.append(textBundle.format("DiskMapTab.BlockDecriptiveLabel", //$NON-NLS-1$ + labels[0].toLowerCase())); } else { - buf.append("This disk is organized by "); - for (int i=0; i 0) buf.append(" and "); - buf.append(labels[i].toLowerCase()); - } - buf.append(", and this implies a rigid layout to the disk. "); - buf.append("This will be reflected in the disk map."); + buf.append(textBundle.format("DiskMapTab.TrackAndSectorDecriptiveLabel", //$NON-NLS-1$ + new Object[] { + labels[0].toLowerCase(), + labels[1].toLowerCase() })); } title.setText(buf.toString()); title.setLayoutData(data); @@ -169,8 +166,9 @@ public class DiskMapTab { /** * Handle paint requests for horizontal ruler. */ - private void paintHorizontalRuler(PaintEvent event) { - String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); + protected void paintHorizontalRuler(PaintEvent event) { + // FIXME - not i18n safe!! + String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$ Canvas canvas = (Canvas) event.widget; Rectangle area = canvas.getClientArea(); event.gc.drawLine(area.x, area.y + area.height/2, area.x + area.width, area.y + area.height/2); @@ -180,14 +178,15 @@ public class DiskMapTab { /** * Handle paint requests for vertical ruler. */ - private void paintVerticalRuler(PaintEvent event) { - String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); + protected void paintVerticalRuler(PaintEvent event) { + // FIXME - not i18n safe!! + String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$ if (disk.getBitmapLabels().length == 2) { - label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); + label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$ } StringBuffer buf = new StringBuffer(); for (int i=0; i0) buf.append("\n"); + if (i>0) buf.append("\n"); //$NON-NLS-1$ buf.append(label.charAt(i)); } label = buf.toString(); @@ -200,7 +199,7 @@ public class DiskMapTab { /** * Handle paint requests for disk map. */ - private void paintMap(PaintEvent event) { + protected void paintMap(PaintEvent event) { if (disk.getDiskUsage() == null) { paintNoMap(event); } else if (disk.getBitmapDimensions() == null) { @@ -212,13 +211,13 @@ public class DiskMapTab { /** * Handle paint requests for legend. */ - private void paintLegend(PaintEvent event) { + protected void paintLegend(PaintEvent event) { Color background = event.gc.getBackground(); Canvas canvas = (Canvas) event.widget; int height = event.gc.getFontMetrics().getHeight(); - String freeText = " = Free"; - String usedText = " = Used"; + String freeText = textBundle.get("DiskMapTab.FreeLegend"); //$NON-NLS-1$ + String usedText = textBundle.get("DiskMapTab.UsedLegend"); //$NON-NLS-1$ int padding = 50; // space between items int totalWidth = @@ -240,13 +239,13 @@ public class DiskMapTab { drawBox(box, event.gc, usedFill, black, gray); offset+= height; event.gc.setBackground(background); - event.gc.drawText(" = Used", offset, 0); + event.gc.drawText(usedText, offset, 0); } /** * Display message to user regarding no disk map being available. */ private void paintNoMap(PaintEvent event) { - event.gc.drawString("A disk map is unavailable.", 0, 0); + event.gc.drawString(textBundle.get("DiskMapTab.DiskMapUnavailableMessage"), 0, 0); //$NON-NLS-1$ } /** * Paint a track/sector map. diff --git a/src/com/webcodepro/applecommander/ui/swt/DiskWindow.java b/src/com/webcodepro/applecommander/ui/swt/DiskWindow.java index ca68181..6142bfa 100644 --- a/src/com/webcodepro/applecommander/ui/swt/DiskWindow.java +++ b/src/com/webcodepro/applecommander/ui/swt/DiskWindow.java @@ -27,6 +27,7 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Shell; import com.webcodepro.applecommander.storage.FormattedDisk; +import com.webcodepro.applecommander.ui.UiBundle; import com.webcodepro.applecommander.ui.swt.util.ImageManager; /** @@ -44,7 +45,6 @@ public class DiskWindow { private DiskInfoTab diskInfoTab; private DiskMapTab[] diskMapTabs; - private DiskExplorerTab diskExplorerTab; /** * Construct the disk window. @@ -70,8 +70,7 @@ public class DiskWindow { }); CTabFolder tabFolder = new CTabFolder(shell, SWT.BOTTOM); - diskExplorerTab = new DiskExplorerTab(tabFolder, disks, - imageManager, this); + new DiskExplorerTab(tabFolder, disks, imageManager, this); diskMapTabs = new DiskMapTab[disks.length]; for (int i=0; i