mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-02 22:32:45 +00:00
tidying
This commit is contained in:
parent
c2f2277717
commit
1b27ea02e7
@ -47,8 +47,8 @@ public class UserBasicFormatter extends BasicFormatter
|
||||
{
|
||||
StringBuilder text = new StringBuilder (String.format ("%5d", (line.lineNumber)));
|
||||
|
||||
int indentLevel = loopVariables.size (); // each full line starts at the loop indent
|
||||
int ifIndent = 0; // IF statement(s) limit back indentation by NEXT
|
||||
int indentLevel = loopVariables.size (); // each full line starts at the loop indent
|
||||
int ifIndent = 0; // IF statement(s) limit back indentation by NEXT
|
||||
|
||||
for (SubLine subline : line.sublines)
|
||||
{
|
||||
@ -107,7 +107,7 @@ public class UserBasicFormatter extends BasicFormatter
|
||||
String lineText = alignment.getAlignedText (subline);
|
||||
|
||||
if (subline.is (TOKEN_DATA) && basicPreferences.deleteExtraDataSpace)
|
||||
lineText = lineText.replaceFirst ("DATA ", "DATA ");
|
||||
lineText = lineText.replaceFirst ("DATA +", "DATA "); // regex
|
||||
|
||||
// Check for a wrappable REM/DATA/DIM statement
|
||||
// (see SEA BATTLE on DISK283.DSK)
|
||||
|
@ -177,38 +177,35 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
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)
|
||||
{
|
||||
int cmp = 0;
|
||||
if (filename.endsWith (".gz"))
|
||||
cmp = 1;
|
||||
else if (filename.endsWith (".zip"))
|
||||
cmp = 2;
|
||||
int cmp = fileName.endsWith (".zip") ? 2 : fileName.endsWith (".gz") ? 1 : 0;
|
||||
|
||||
typeTotals[cmp][pos]++;
|
||||
typeTotals[3][pos]++;
|
||||
++totalDisks;
|
||||
}
|
||||
else
|
||||
System.out.println ("no suffix: " + filename);
|
||||
System.out.println ("no suffix: " + fileName);
|
||||
|
||||
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);
|
||||
DiskDetails diskDetails = new DiskDetails (file, rootName, filename, doChecksums);
|
||||
DiskDetails diskDetails = new DiskDetails (file, rootName, fileName, doChecksums);
|
||||
|
||||
if (fileNameMap.containsKey (filename))
|
||||
fileNameMap.get (filename).addDuplicateName (diskDetails);
|
||||
if (fileNameMap.containsKey (fileName))
|
||||
fileNameMap.get (fileName).addDuplicateName (diskDetails);
|
||||
else
|
||||
fileNameMap.put (filename, diskDetails);
|
||||
fileNameMap.put (fileName, diskDetails);
|
||||
|
||||
if (doChecksums)
|
||||
{
|
||||
@ -326,16 +323,16 @@ public class RootFolderData implements RootDirectoryChangeListener
|
||||
int grandTotal[] = new int[4];
|
||||
|
||||
for (int i = 0; i < typeTotals[0].length; i++)
|
||||
{
|
||||
line = String.format ("%14.14s %,7d %,7d %,7d %,7d",
|
||||
Utility.getSuffix (i) + " ...........", typeTotals[0][i], typeTotals[1][i],
|
||||
typeTotals[2][i], typeTotals[3][i]);
|
||||
g.drawString (line, x, y);
|
||||
for (int j = 0; j < typeTotals.length; j++)
|
||||
grandTotal[j] += typeTotals[j][i];
|
||||
|
||||
y += lineHeight;
|
||||
}
|
||||
if (typeTotals[3][i] > 0)
|
||||
{
|
||||
line = String.format ("%14.14s %,7d %,7d %,7d %,7d",
|
||||
Utility.getSuffix (i) + " ...........", typeTotals[0][i], typeTotals[1][i],
|
||||
typeTotals[2][i], typeTotals[3][i]);
|
||||
g.drawString (line, x, y);
|
||||
for (int j = 0; j < typeTotals.length; j++)
|
||||
grandTotal[j] += typeTotals[j][i];
|
||||
y += lineHeight;
|
||||
}
|
||||
|
||||
line = String.format ("Total %,7d %,7d %,7d %,7d%n%n", grandTotal[0],
|
||||
grandTotal[1], grandTotal[2], grandTotal[3]);
|
||||
|
@ -321,6 +321,14 @@ class CatalogPanel extends JTabbedPane
|
||||
selector.addDiskSelectionListener (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addDiskSelectionListener (DiskSelectionListener... listeners)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (DiskSelectionListener diskSelectionListener : listeners)
|
||||
selector.addDiskSelectionListener (diskSelectionListener);
|
||||
}
|
||||
|
||||
// Pass through to DiskSelector
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addFileSelectionListener (FileSelectionListener listener)
|
||||
@ -329,6 +337,14 @@ class CatalogPanel extends JTabbedPane
|
||||
selector.addFileSelectionListener (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addFileSelectionListener (FileSelectionListener... listeners)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (FileSelectionListener fileSelectionListener : listeners)
|
||||
selector.addFileSelectionListener (fileSelectionListener);
|
||||
}
|
||||
|
||||
// Pass through to DiskSelector
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addFileNodeSelectionListener (FileNodeSelectionListener listener)
|
||||
@ -337,6 +353,14 @@ class CatalogPanel extends JTabbedPane
|
||||
selector.addFileNodeSelectionListener (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addFileNodeSelectionListener (FileNodeSelectionListener... listeners)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (FileNodeSelectionListener fileNodeSelectionListener : listeners)
|
||||
selector.addFileNodeSelectionListener (fileNodeSelectionListener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class TabChangeListener implements ChangeListener
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -35,6 +35,8 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
|
||||
private final RootFolderData rootFolderData = new RootFolderData ();
|
||||
|
||||
private final List<QuitListener> quitListeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DiskBrowser ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -94,30 +96,18 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
// toolBar.add (aboutAction);
|
||||
|
||||
// set the listeners
|
||||
rootDirectoryAction.addListener (rootFolderData);
|
||||
rootDirectoryAction.addListener (catalogPanel);
|
||||
rootDirectoryAction.addListener (duplicateAction);
|
||||
rootDirectoryAction.addListener (rootFolderData, catalogPanel, duplicateAction);
|
||||
|
||||
catalogPanel.addDiskSelectionListener (this);
|
||||
catalogPanel.addDiskSelectionListener (dataPanel);
|
||||
catalogPanel.addDiskSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addDiskSelectionListener (redoHandler);
|
||||
catalogPanel.addDiskSelectionListener (menuHandler);
|
||||
catalogPanel.addDiskSelectionListener (menuHandler.saveDiskAction);
|
||||
catalogPanel.addDiskSelectionListener (this, dataPanel, diskLayoutPanel, redoHandler,
|
||||
menuHandler, menuHandler.saveDiskAction);
|
||||
|
||||
catalogPanel.addFileSelectionListener (dataPanel);
|
||||
catalogPanel.addFileSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addFileSelectionListener (redoHandler);
|
||||
catalogPanel.addFileSelectionListener (menuHandler);
|
||||
catalogPanel.addFileSelectionListener (menuHandler.saveFileAction);
|
||||
catalogPanel.addFileSelectionListener (dataPanel, diskLayoutPanel, redoHandler,
|
||||
menuHandler, menuHandler.saveFileAction);
|
||||
|
||||
catalogPanel.addFileNodeSelectionListener (dataPanel);
|
||||
catalogPanel.addFileNodeSelectionListener (redoHandler);
|
||||
catalogPanel.addFileNodeSelectionListener (dataPanel, redoHandler);
|
||||
|
||||
diskLayoutPanel.addSectorSelectionListener (dataPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (redoHandler);
|
||||
diskLayoutPanel.addSectorSelectionListener (catalogPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (menuHandler.saveSectorsAction);
|
||||
diskLayoutPanel.addSectorSelectionListener (dataPanel, redoHandler, catalogPanel,
|
||||
menuHandler.saveSectorsAction);
|
||||
|
||||
duplicateAction.addTableSelectionListener (catalogPanel);
|
||||
|
||||
@ -144,10 +134,10 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
menuHandler.duplicateItem.setAction (duplicateAction);
|
||||
menuHandler.closeTabItem.setAction (closeTabAction);
|
||||
|
||||
addQuitListener (rootDirectoryAction);
|
||||
addQuitListener (menuHandler);
|
||||
addQuitListener (catalogPanel);
|
||||
addQuitListener (this);
|
||||
quitListeners.add (rootDirectoryAction);
|
||||
quitListeners.add (menuHandler);
|
||||
quitListeners.add (catalogPanel);
|
||||
quitListeners.add (this);
|
||||
|
||||
if (Desktop.isDesktopSupported ())
|
||||
{
|
||||
@ -250,22 +240,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
windowSaver.restoreWindow ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void main (String[] args)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskBrowser.args = args;
|
||||
EventQueue.invokeLater (new Runnable ()
|
||||
{
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
setLookAndFeel ();
|
||||
new DiskBrowser ().setVisible (true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private static void setLookAndFeel ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -284,22 +258,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
}
|
||||
}
|
||||
|
||||
List<QuitListener> quitListeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void removeQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.remove (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fireQuitEvent ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -317,4 +275,20 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
for (QuitListener listener : quitListeners)
|
||||
listener.restore (prefs);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void main (String[] args)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskBrowser.args = args;
|
||||
EventQueue.invokeLater (new Runnable ()
|
||||
{
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
setLookAndFeel ();
|
||||
new DiskBrowser ().setVisible (true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -19,8 +19,8 @@ import javax.swing.JScrollPane;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.HybridDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.disk.HybridDisk;
|
||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
|
||||
|
||||
@ -141,6 +141,14 @@ class DiskLayoutPanel extends JPanel
|
||||
diskLayoutImage.addSectorSelectionListener (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addSectorSelectionListener (SectorSelectionListener... listeners)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (SectorSelectionListener sectorSelectionListener : listeners)
|
||||
diskLayoutImage.addSectorSelectionListener (sectorSelectionListener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void removeSectorSelectionListener (SectorSelectionListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -64,6 +64,15 @@ class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addListener (RootDirectoryChangeListener... listenerList)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (RootDirectoryChangeListener rootDirectoryChangeListener : listenerList)
|
||||
if (!listeners.contains (rootDirectoryChangeListener))
|
||||
listeners.add (rootDirectoryChangeListener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void quit (Preferences prefs)
|
||||
|
Loading…
Reference in New Issue
Block a user