diff --git a/src/com/bytezone/diskbrowser/applefile/BasicProgram.java b/src/com/bytezone/diskbrowser/applefile/BasicProgram.java index 6b286e5..6312c6d 100644 --- a/src/com/bytezone/diskbrowser/applefile/BasicProgram.java +++ b/src/com/bytezone/diskbrowser/applefile/BasicProgram.java @@ -91,7 +91,7 @@ public class BasicProgram extends AbstractFile { int address = subline.getAddress () + 1; // skip the REM token fullText.append (text + String.format ("REM - Inline assembler @ $%02X (%d)%n", - address, address)); + address, address)); String padding = " ".substring (0, text.length () + 2); for (String asm : subline.getAssembler ()) fullText.append (padding + asm + "\n"); @@ -590,8 +590,8 @@ public class BasicProgram extends AbstractFile } catch (NumberFormatException e) { - System.out.println ("Error parsing : GOTO " + target + " in " - + parent.lineNumber); + System.out.println ( + "Error parsing : GOTO " + target + " in " + parent.lineNumber); } break; @@ -604,8 +604,8 @@ public class BasicProgram extends AbstractFile catch (NumberFormatException e) { System.out.println (HexFormatter.format (buffer, startPtr + 1, length - 2)); - System.out.println ("Error parsing : GOSUB " + target2 + " in " - + parent.lineNumber); + System.out.println ( + "Error parsing : GOSUB " + target2 + " in " + parent.lineNumber); } break; } @@ -623,11 +623,11 @@ public class BasicProgram extends AbstractFile catch (NumberFormatException e) { System.out.printf ("b: %d, start: %d, length: %d%n", b, startPtr, - (length - 1)); + (length - 1)); System.out.println (target); System.out.println (HexFormatter.format (buffer, startPtr, length - 1)); System.out.println (e); - assert false; + // assert false; } } else if (alignAssign) @@ -638,7 +638,7 @@ public class BasicProgram extends AbstractFile private boolean isImpliedGoto () { byte b = buffer[startPtr]; - if ((b & 0x80) > 0) // token + if ((b & 0x80) > 0) // token return false; return (b >= 48 && b <= 57); } @@ -651,7 +651,7 @@ public class BasicProgram extends AbstractFile while (buffer[p] != TOKEN_EQUALS && p < max) p++; if (buffer[p] == TOKEN_EQUALS) - assignEqualPos = toString ().indexOf ('='); // use expanded line + assignEqualPos = toString ().indexOf ('='); // use expanded line } private boolean isJoinableRem () @@ -738,7 +738,7 @@ public class BasicProgram extends AbstractFile // + parent.lineNumber); } else if (b < 32) // CTRL character - line.append ("^" + (char) (b + 64)); // would be better in inverse text + line.append ("^" + (char) (b + 64)); // would be better in inverse text else line.append ((char) b); } diff --git a/src/com/bytezone/diskbrowser/duplicates/DuplicateSwingWorker.java b/src/com/bytezone/diskbrowser/duplicates/DuplicateSwingWorker.java index 2025758..17bb4f2 100644 --- a/src/com/bytezone/diskbrowser/duplicates/DuplicateSwingWorker.java +++ b/src/com/bytezone/diskbrowser/duplicates/DuplicateSwingWorker.java @@ -15,14 +15,15 @@ public class DuplicateSwingWorker extends SwingWorker { private final File rootFolder; private final int rootFolderNameLength; - private final ProgressState progressState = new ProgressState (); + // private final ProgressState progressState = new ProgressState (); private final DuplicateWindow owner; private final JDialog dialog; private final ProgressPanel progressPanel; private final boolean doChecksums; private final RootFolderData rootFolderData; - public DuplicateSwingWorker (File rootFolder, DuplicateWindow owner, boolean doChecksums) + public DuplicateSwingWorker (File rootFolder, DuplicateWindow owner, + boolean doChecksums) { this.rootFolder = rootFolder; this.owner = owner; @@ -62,16 +63,16 @@ public class DuplicateSwingWorker extends SwingWorker if (file.isDirectory ()) { - progressState.incrementFolders (); + rootFolderData.progressState.incrementFolders (); traverse (file); } else if (Utility.validFileType (fileName) && file.length () > 0) { - progressState.incrementType (file, fileName); + rootFolderData.progressState.incrementType (file, fileName); checkDuplicates (file, fileName); - if ((progressState.totalDisks % 500) == 0) - publish (progressState); + if ((rootFolderData.progressState.totalDisks % 500) == 0) + publish (rootFolderData.progressState); } } } @@ -102,7 +103,7 @@ public class DuplicateSwingWorker extends SwingWorker try { dialog.setVisible (false); - owner.setTableModel (new DiskTableModel (rootFolderData)); + owner.setTableData (rootFolderData); } catch (Exception e) { @@ -114,7 +115,7 @@ public class DuplicateSwingWorker extends SwingWorker protected Void doInBackground () throws Exception { traverse (rootFolder); - progressState.print (); + rootFolderData.progressState.print (); return null; } @@ -130,7 +131,7 @@ public class DuplicateSwingWorker extends SwingWorker protected void paintComponent (Graphics graphics) { super.paintComponent (graphics); - progressState.paintComponent (graphics); + rootFolderData.progressState.paintComponent (graphics); } } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/duplicates/DuplicateWindow.java b/src/com/bytezone/diskbrowser/duplicates/DuplicateWindow.java index 867136c..83d56ac 100644 --- a/src/com/bytezone/diskbrowser/duplicates/DuplicateWindow.java +++ b/src/com/bytezone/diskbrowser/duplicates/DuplicateWindow.java @@ -2,6 +2,8 @@ package com.bytezone.diskbrowser.duplicates; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -18,6 +20,7 @@ import javax.swing.table.TableRowSorter; import com.bytezone.diskbrowser.gui.DuplicateAction; import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener; import com.bytezone.diskbrowser.utilities.NumberRenderer; +import com.bytezone.diskbrowser.utilities.Utility; public class DuplicateWindow extends JFrame { @@ -25,6 +28,9 @@ public class DuplicateWindow extends JFrame private final JButton btnExport = new JButton ("Export"); private final JButton btnHide = new JButton ("Close"); + private final JLabel lblTotalDisks = new JLabel (); + // private final ButtonGroup grpFileType = new ButtonGroup (); + private final JPanel topPanel = new JPanel (); private final List listeners; @@ -53,6 +59,11 @@ public class DuplicateWindow extends JFrame panel.add (btnExport); add (panel, BorderLayout.SOUTH); + topPanel.setLayout (new FlowLayout (FlowLayout.LEFT, 10, 5)); + topPanel.add (new JLabel ("Total disks:")); + topPanel.add (lblTotalDisks); + add (topPanel, BorderLayout.NORTH); + btnHide.setEnabled (true); btnExport.setEnabled (false); @@ -65,15 +76,16 @@ public class DuplicateWindow extends JFrame } }); - setSize (1200, 700); - setLocationRelativeTo (null); + scrollPane.setPreferredSize (new Dimension (1200, 700)); setDefaultCloseOperation (HIDE_ON_CLOSE); } // called from DuplicateSwingWorker - public void setTableModel (DiskTableModel diskTableModel) + public void setTableData (RootFolderData rootFolderData) { + DiskTableModel diskTableModel = new DiskTableModel (rootFolderData); table.setModel (diskTableModel); + lblTotalDisks.setText (diskTableModel.getRowCount () + ""); int[] columnWidths = { 300, 300, 30, 40, 40, 40, 100 }; TableColumnModel tcm = table.getColumnModel (); @@ -112,9 +124,23 @@ public class DuplicateWindow extends JFrame } }); + for (int i = 0; i < Utility.suffixes.size (); i++) + { + int total = rootFolderData.progressState.getTotalType (i); + JCheckBox btn = + new JCheckBox (String.format ("%s (%,d)", Utility.suffixes.get (i), total)); + topPanel.add (btn); + + if (total > 0) + btn.setSelected (true); + // grpFileType.add (btn); + } + JTableHeader header = table.getTableHeader (); header.setFont (header.getFont ().deriveFont ((float) 13.0)); + pack (); + setLocationRelativeTo (null); setVisible (true); } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/duplicates/ProgressState.java b/src/com/bytezone/diskbrowser/duplicates/ProgressState.java index 2d08cd5..8900b03 100644 --- a/src/com/bytezone/diskbrowser/duplicates/ProgressState.java +++ b/src/com/bytezone/diskbrowser/duplicates/ProgressState.java @@ -20,13 +20,18 @@ public class ProgressState int totalFolders; // total files for each suffix (uncompressed, .gz, .zip) - private final int[][] typeTotals = new int[3][suffixes.size ()]; + final int[][] typeTotals = new int[3][suffixes.size ()]; public void incrementFolders () { ++totalFolders; } + public int getTotalType (int type) + { + return typeTotals[0][type] + typeTotals[1][type] + typeTotals[2][type]; + } + public void incrementType (File file, String filename) { int pos = Utility.getSuffixNo (filename); diff --git a/src/com/bytezone/diskbrowser/duplicates/RootFolderData.java b/src/com/bytezone/diskbrowser/duplicates/RootFolderData.java index 58ad0d3..5a237fb 100644 --- a/src/com/bytezone/diskbrowser/duplicates/RootFolderData.java +++ b/src/com/bytezone/diskbrowser/duplicates/RootFolderData.java @@ -12,8 +12,9 @@ public class RootFolderData // list of unique disk names -> DiskDetails public final Map fileNameMap = new TreeMap (); - public RootFolderData () - { + public final ProgressState progressState = new ProgressState (); - } + // public RootFolderData () + // { + // } } \ No newline at end of file