mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-05 14:30:10 +00:00
method header lines
This commit is contained in:
parent
add2b8f946
commit
1043b8964f
|
@ -7,9 +7,13 @@ import java.io.IOException;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
public class CSVFileWriter
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class CSVFileWriter
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public static void write (DiskTableModel diskTableModel, JTable table)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
static void write (DiskTableModel diskTableModel, JTable table)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String csvFile =
|
String csvFile =
|
||||||
System.getProperty ("user.home") + File.separator + "DiskBrowser.csv";
|
System.getProperty ("user.home") + File.separator + "DiskBrowser.csv";
|
||||||
|
|
|
@ -20,7 +20,9 @@ import javax.swing.table.TableColumnModel;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
|
import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DeleteWindow extends JFrame implements DiskTableSelectionListener
|
public class DeleteWindow extends JFrame implements DiskTableSelectionListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private List<DiskDetails> lines = new ArrayList<> ();
|
private List<DiskDetails> lines = new ArrayList<> ();
|
||||||
private final JButton btnHide = new JButton ("Close");
|
private final JButton btnHide = new JButton ("Close");
|
||||||
|
@ -29,7 +31,9 @@ public class DeleteWindow extends JFrame implements DiskTableSelectionListener
|
||||||
private final DeleteTableModel deleteTableModel = new DeleteTableModel ();
|
private final DeleteTableModel deleteTableModel = new DeleteTableModel ();
|
||||||
private final JTable table = new JTable (deleteTableModel);
|
private final JTable table = new JTable (deleteTableModel);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DeleteWindow (RootFolderData rootFolderData)
|
public DeleteWindow (RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Duplicate Disks");
|
super ("Duplicate Disks");
|
||||||
|
|
||||||
|
@ -72,14 +76,18 @@ public class DeleteWindow extends JFrame implements DiskTableSelectionListener
|
||||||
setLocationRelativeTo (null);
|
setLocationRelativeTo (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void diskSelected (DiskDetails diskDetails)
|
public void diskSelected (DiskDetails diskDetails)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
lines = rootFolderData.listDuplicates (diskDetails.getChecksum ());
|
lines = rootFolderData.listDuplicates (diskDetails.getChecksum ());
|
||||||
deleteTableModel.fireTableDataChanged ();
|
deleteTableModel.fireTableDataChanged ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class DeleteTableModel extends AbstractTableModel
|
class DeleteTableModel extends AbstractTableModel
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
final String[] headers = { "Name", "Type", "Size", "Checksum", };
|
final String[] headers = { "Name", "Type", "Size", "Checksum", };
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ import java.util.List;
|
||||||
import com.bytezone.common.ComputeCRC32;
|
import com.bytezone.common.ComputeCRC32;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DiskDetails
|
public class DiskDetails
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final File file;
|
private final File file;
|
||||||
private long checksum;
|
private long checksum;
|
||||||
|
@ -22,7 +24,9 @@ public class DiskDetails
|
||||||
private boolean isDuplicateName;
|
private boolean isDuplicateName;
|
||||||
private boolean isDuplicateChecksum;
|
private boolean isDuplicateChecksum;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DiskDetails (File file, String rootName, String shortName, boolean doChecksum)
|
public DiskDetails (File file, String rootName, String shortName, boolean doChecksum)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.rootName = rootName;
|
this.rootName = rootName;
|
||||||
|
@ -36,12 +40,16 @@ public class DiskDetails
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public File getFile ()
|
public File getFile ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addDuplicateChecksum (DiskDetails diskDetails)
|
public void addDuplicateChecksum (DiskDetails diskDetails)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (this.checksum == diskDetails.checksum)
|
if (this.checksum == diskDetails.checksum)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +58,9 @@ public class DiskDetails
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addDuplicateName (DiskDetails diskDetails)
|
public void addDuplicateName (DiskDetails diskDetails)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (this.shortName.equals (diskDetails.shortName))
|
if (this.shortName.equals (diskDetails.shortName))
|
||||||
{
|
{
|
||||||
|
@ -59,64 +69,88 @@ public class DiskDetails
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public List<DiskDetails> getDuplicateChecksums ()
|
public List<DiskDetails> getDuplicateChecksums ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return duplicateChecksums;
|
return duplicateChecksums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public List<DiskDetails> getDuplicateNames ()
|
public List<DiskDetails> getDuplicateNames ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return duplicateNames;
|
return duplicateNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean isDuplicateChecksum ()
|
public boolean isDuplicateChecksum ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return isDuplicateChecksum;
|
return isDuplicateChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean isDuplicateName ()
|
public boolean isDuplicateName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return isDuplicateName;
|
return isDuplicateName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getRootName ()
|
public String getRootName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rootName;
|
return rootName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public long getSize ()
|
public long getSize ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getShortName ()
|
public String getShortName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getFileName ()
|
public String getFileName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return file.getName ();
|
return file.getName ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public long calculateChecksum ()
|
public long calculateChecksum ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
checksum = ComputeCRC32.getChecksumValue (file);
|
checksum = ComputeCRC32.getChecksumValue (file);
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public long getChecksum ()
|
public long getChecksum ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format ("%3d %1.1s %3d %1.1s %-40s ", duplicateChecksums.size (),
|
return String.format ("%3d %1.1s %3d %1.1s %-40s ", duplicateChecksums.size (),
|
||||||
isDuplicateChecksum, duplicateNames.size (), isDuplicateName, rootName);
|
isDuplicateChecksum, duplicateNames.size (), isDuplicateName, rootName);
|
||||||
|
|
|
@ -5,7 +5,9 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
public class DiskTableModel extends AbstractTableModel
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class DiskTableModel extends AbstractTableModel
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final String[] headers =
|
static final String[] headers =
|
||||||
{ "Path", "Name", "Type", "Size", "# names", "Checksum", "# checksums" };
|
{ "Path", "Name", "Type", "Size", "# names", "Checksum", "# checksums" };
|
||||||
|
@ -13,7 +15,9 @@ public class DiskTableModel extends AbstractTableModel
|
||||||
private final List<TableLine> lines = new ArrayList<> ();
|
private final List<TableLine> lines = new ArrayList<> ();
|
||||||
private final RootFolderData rootFolderData;
|
private final RootFolderData rootFolderData;
|
||||||
|
|
||||||
public DiskTableModel (RootFolderData rootFolderData)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
DiskTableModel (RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.rootFolderData = rootFolderData;
|
this.rootFolderData = rootFolderData;
|
||||||
|
|
||||||
|
@ -27,25 +31,33 @@ public class DiskTableModel extends AbstractTableModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DiskDetails getDiskDetails (int rowIndex)
|
public DiskDetails getDiskDetails (int rowIndex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return lines.get (rowIndex).diskDetails;
|
return lines.get (rowIndex).diskDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName (int column)
|
public String getColumnName (int column)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return headers[column];
|
return headers[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount ()
|
public int getRowCount ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return lines.size ();
|
return lines.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount ()
|
public int getColumnCount ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (rootFolderData.doChecksums)
|
if (rootFolderData.doChecksums)
|
||||||
return headers.length;
|
return headers.length;
|
||||||
|
@ -53,14 +65,18 @@ public class DiskTableModel extends AbstractTableModel
|
||||||
return headers.length - 1;
|
return headers.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass (int columnIndex)
|
public Class<?> getColumnClass (int columnIndex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return lines.isEmpty () ? Object.class : getValueAt (0, columnIndex).getClass ();
|
return lines.isEmpty () ? Object.class : getValueAt (0, columnIndex).getClass ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt (int rowIndex, int columnIndex)
|
public Object getValueAt (int rowIndex, int columnIndex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
TableLine line = lines.get (rowIndex);
|
TableLine line = lines.get (rowIndex);
|
||||||
switch (columnIndex)
|
switch (columnIndex)
|
||||||
|
@ -84,7 +100,9 @@ public class DiskTableModel extends AbstractTableModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getCSV (int rowIndex)
|
public String getCSV (int rowIndex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
TableLine line = lines.get (rowIndex);
|
TableLine line = lines.get (rowIndex);
|
||||||
return String.format ("\"%s\",\"%s\",%s,%d,%s,%s,%d%n", line.path, line.shortName,
|
return String.format ("\"%s\",\"%s\",%s,%d,%s,%s,%d%n", line.path, line.shortName,
|
||||||
|
@ -92,14 +110,18 @@ public class DiskTableModel extends AbstractTableModel
|
||||||
line.checksum);
|
line.checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void updateChecksum (int rowIndex)
|
void updateChecksum (int rowIndex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
TableLine line = lines.get (rowIndex);
|
TableLine line = lines.get (rowIndex);
|
||||||
line.checksum = line.diskDetails.calculateChecksum ();
|
line.checksum = line.diskDetails.calculateChecksum ();
|
||||||
fireTableCellUpdated (rowIndex, 5);
|
fireTableCellUpdated (rowIndex, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class TableLine
|
class TableLine
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final String shortName;
|
private final String shortName;
|
||||||
private final String fileName;
|
private final String fileName;
|
||||||
|
|
|
@ -31,7 +31,9 @@ import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
|
||||||
import com.bytezone.diskbrowser.utilities.NumberRenderer;
|
import com.bytezone.diskbrowser.utilities.NumberRenderer;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DisksWindow extends JFrame
|
public class DisksWindow extends JFrame
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final JTable table;
|
private final JTable table;
|
||||||
|
|
||||||
|
@ -50,7 +52,9 @@ public class DisksWindow extends JFrame
|
||||||
private final RootFolderData rootFolderData;
|
private final RootFolderData rootFolderData;
|
||||||
private final DeleteWindow deleteWindow;
|
private final DeleteWindow deleteWindow;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DisksWindow (RootFolderData rootFolderData)
|
public DisksWindow (RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (rootFolderData.getRootFolderPathText ());
|
super (rootFolderData.getRootFolderPathText ());
|
||||||
this.rootFolderData = rootFolderData;
|
this.rootFolderData = rootFolderData;
|
||||||
|
@ -123,7 +127,9 @@ public class DisksWindow extends JFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from DuplicateSwingWorker
|
// called from DuplicateSwingWorker
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setTableData (final RootFolderData rootFolderData)
|
public void setTableData (final RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
diskTableModel = new DiskTableModel (rootFolderData);
|
diskTableModel = new DiskTableModel (rootFolderData);
|
||||||
table.setModel (diskTableModel);
|
table.setModel (diskTableModel);
|
||||||
|
@ -209,7 +215,9 @@ public class DisksWindow extends JFrame
|
||||||
setVisible (true);
|
setVisible (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getFilterText ()
|
private String getFilterText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder filterText = new StringBuilder ();
|
StringBuilder filterText = new StringBuilder ();
|
||||||
|
|
||||||
|
@ -227,7 +235,9 @@ public class DisksWindow extends JFrame
|
||||||
return filterText.toString ();
|
return filterText.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class CheckBoxActionListener implements ActionListener
|
class CheckBoxActionListener implements ActionListener
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
|
|
@ -7,35 +7,47 @@ import javax.swing.SwingWorker;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
public class DuplicateSwingWorker extends SwingWorker<Void, RootFolderData>
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class DuplicateSwingWorker extends SwingWorker<Void, RootFolderData>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final RootFolderData rootFolderData;
|
private final RootFolderData rootFolderData;
|
||||||
|
|
||||||
public DuplicateSwingWorker (RootFolderData rootFolderData)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
DuplicateSwingWorker (RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.rootFolderData = rootFolderData;
|
this.rootFolderData = rootFolderData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground () throws Exception
|
protected Void doInBackground () throws Exception
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
traverse (rootFolderData.getRootFolder ());
|
traverse (rootFolderData.getRootFolder ());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected void done ()
|
protected void done ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
rootFolderData.done ();
|
rootFolderData.done ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected void process (List<RootFolderData> chunks)
|
protected void process (List<RootFolderData> chunks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
rootFolderData.progressPanel.repaint ();
|
rootFolderData.progressPanel.repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void traverse (File directory)
|
private void traverse (File directory)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (rootFolderData.progressPanel.cancelled)
|
if (rootFolderData.progressPanel.cancelled)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,7 +23,9 @@ import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
|
||||||
import com.bytezone.diskbrowser.gui.RootDirectoryChangeListener;
|
import com.bytezone.diskbrowser.gui.RootDirectoryChangeListener;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class RootFolderData implements RootDirectoryChangeListener
|
public class RootFolderData implements RootDirectoryChangeListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String header =
|
private static final String header =
|
||||||
" type uncmp .gz .zip total";
|
" type uncmp .gz .zip total";
|
||||||
|
@ -55,7 +57,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
JButton btnCancel;
|
JButton btnCancel;
|
||||||
JButton btnOK;
|
JButton btnOK;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void createWindows ()
|
private void createWindows ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
southPanel = new JPanel ();
|
southPanel = new JPanel ();
|
||||||
btnCancel = new JButton ("Cancel");
|
btnCancel = new JButton ("Cancel");
|
||||||
|
@ -91,7 +95,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void count (boolean doChecksums)
|
public void count (boolean doChecksums)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (dialogTotals == null)
|
if (dialogTotals == null)
|
||||||
createWindows ();
|
createWindows ();
|
||||||
|
@ -106,7 +112,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
new DuplicateSwingWorker (this).execute (); // start SwingWorker
|
new DuplicateSwingWorker (this).execute (); // start SwingWorker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void done () // SwingWorker has completed
|
public void done () // SwingWorker has completed
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
print ();
|
print ();
|
||||||
dialogTotals.repaint ();
|
dialogTotals.repaint ();
|
||||||
|
@ -121,7 +129,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setButton (JButton button)
|
private void setButton (JButton button)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
southPanel.removeAll ();
|
southPanel.removeAll ();
|
||||||
southPanel.add (button);
|
southPanel.add (button);
|
||||||
|
@ -129,7 +139,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
dialogTotals.repaint ();
|
dialogTotals.repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
String getRootFolderPathText ()
|
String getRootFolderPathText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String text = rootFolder.getAbsolutePath ();
|
String text = rootFolder.getAbsolutePath ();
|
||||||
String homeDir = System.getProperty ("user.home");
|
String homeDir = System.getProperty ("user.home");
|
||||||
|
@ -138,7 +150,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void clear ()
|
private void clear ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
typeTotals = new int[4][Utility.suffixes.size ()];
|
typeTotals = new int[4][Utility.suffixes.size ()];
|
||||||
totalDisks = 0;
|
totalDisks = 0;
|
||||||
|
@ -148,17 +162,23 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
fileNameMap.clear ();
|
fileNameMap.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public File getRootFolder ()
|
public File getRootFolder ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void incrementFolders ()
|
public void incrementFolders ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
++totalFolders;
|
++totalFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void incrementType (File file, String filename)
|
public void incrementType (File file, String filename)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int pos = Utility.getSuffixNo (filename);
|
int pos = Utility.getSuffixNo (filename);
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
|
@ -178,7 +198,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
checkDuplicates (file, filename);
|
checkDuplicates (file, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void checkDuplicates (File file, String filename)
|
private void checkDuplicates (File file, String filename)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String rootName = file.getAbsolutePath ().substring (rootFolderNameLength);
|
String rootName = file.getAbsolutePath ().substring (rootFolderNameLength);
|
||||||
DiskDetails diskDetails = new DiskDetails (file, rootName, filename, doChecksums);
|
DiskDetails diskDetails = new DiskDetails (file, rootName, filename, doChecksums);
|
||||||
|
@ -198,7 +220,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public List<DiskDetails> listDuplicates (long checksum)
|
public List<DiskDetails> listDuplicates (long checksum)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<DiskDetails> list = new ArrayList<> ();
|
List<DiskDetails> list = new ArrayList<> ();
|
||||||
DiskDetails original = checksumMap.get (checksum);
|
DiskDetails original = checksumMap.get (checksum);
|
||||||
|
@ -212,12 +236,16 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int getTotalType (int type)
|
public int getTotalType (int type)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return typeTotals[0][type] + typeTotals[1][type] + typeTotals[2][type];
|
return typeTotals[0][type] + typeTotals[1][type] + typeTotals[2][type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void print ()
|
public void print ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.printf ("%nFolders ...... %,7d%n", totalFolders);
|
System.out.printf ("%nFolders ...... %,7d%n", totalFolders);
|
||||||
System.out.printf ("Disks ........ %,7d%n%n", totalDisks);
|
System.out.printf ("Disks ........ %,7d%n%n", totalDisks);
|
||||||
|
@ -248,8 +276,20 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
rootFolder = newRootFolder;
|
||||||
|
rootFolderNameLength = rootFolder.getAbsolutePath ().length ();
|
||||||
|
disksWindow = null; // force a recount
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
@ -260,7 +300,9 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class ProgressPanel extends JPanel
|
class ProgressPanel extends JPanel
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public volatile boolean cancelled;
|
public volatile boolean cancelled;
|
||||||
|
|
||||||
|
@ -309,12 +351,4 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder)
|
|
||||||
{
|
|
||||||
rootFolder = newRootFolder;
|
|
||||||
rootFolderNameLength = rootFolder.getAbsolutePath ().length ();
|
|
||||||
disksWindow = null; // force a recount
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user