mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-16 10:29:29 +00:00
unidos
This commit is contained in:
parent
d46564577b
commit
ad8af22186
|
@ -6,29 +6,41 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface AppleFileSource
|
public interface AppleFileSource
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Returns a name that uniquely identifies this object within the disk.
|
* Returns a name that uniquely identifies this object within the disk.
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getUniqueName ();
|
public String getUniqueName ();
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DataSource is implemented by AbstractSector and AbstractFile, and provides
|
* DataSource is implemented by AbstractSector and AbstractFile, and provides
|
||||||
* routines to display the data in various formats (text, hex, assembler and
|
* routines to display the data in various formats (text, hex, assembler and
|
||||||
* image).
|
* image).
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DataSource getDataSource ();
|
public DataSource getDataSource ();
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a list of sectors used by this object.
|
* Returns a list of sectors used by this object.
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public List<DiskAddress> getSectors ();
|
public List<DiskAddress> getSectors ();
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the actual FormattedDisk that owns this object.
|
* Returns the actual FormattedDisk that owns this object.
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public FormattedDisk getFormattedDisk ();
|
public FormattedDisk getFormattedDisk ();
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean contains (DiskAddress diskAddress);
|
public boolean contains (DiskAddress diskAddress);
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
}
|
|
@ -27,8 +27,6 @@ public class DualDosDisk implements FormattedDisk
|
||||||
public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1)
|
public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// System.out.printf ("Disk0:%n %s%n", disk0);
|
|
||||||
// System.out.printf ("Disk1:%n %s%n", disk1);
|
|
||||||
assert disk0 != disk1;
|
assert disk0 != disk1;
|
||||||
String diskName = disk0.getDisk ().getFile ().getName ();
|
String diskName = disk0.getDisk ().getFile ().getName ();
|
||||||
String text = "This disk contains files from DOS and another OS\n\n"
|
String text = "This disk contains files from DOS and another OS\n\n"
|
||||||
|
@ -134,11 +132,10 @@ public class DualDosDisk implements FormattedDisk
|
||||||
public void setCurrentDisk (FormattedDisk fd)
|
public void setCurrentDisk (FormattedDisk fd)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (disks[0] == fd && currentDisk != 0)
|
if (disks[0] == fd)
|
||||||
currentDisk = 0;
|
currentDisk = 0;
|
||||||
else if (disks[1] == fd && currentDisk != 1)
|
else if (disks[1] == fd)
|
||||||
currentDisk = 1;
|
currentDisk = 1;
|
||||||
System.out.printf ("1. Setting disk: %d%n", currentDisk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -146,7 +143,6 @@ public class DualDosDisk implements FormattedDisk
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
currentDisk = n;
|
currentDisk = n;
|
||||||
System.out.printf ("2. Setting disk: %d%n", currentDisk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -17,6 +17,7 @@ import javax.swing.tree.TreeNode;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.DiskFactory;
|
import com.bytezone.diskbrowser.disk.DiskFactory;
|
||||||
|
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ class AppleDiskTab extends AbstractTab
|
||||||
RedoHandler redoHandler, Font font, String lastFileUsed)
|
RedoHandler redoHandler, Font font, String lastFileUsed)
|
||||||
{
|
{
|
||||||
super (redoHandler, selector, font);
|
super (redoHandler, selector, font);
|
||||||
System.out.println ("******************");
|
System.out.println ("****************** File not found");
|
||||||
create (disk);
|
create (disk);
|
||||||
// System.out.println ("ooh - couldn't find the previous file");
|
// System.out.println ("ooh - couldn't find the previous file");
|
||||||
DefaultMutableTreeNode node = findNode (lastFileUsed);
|
DefaultMutableTreeNode node = findNode (lastFileUsed);
|
||||||
|
@ -68,7 +69,8 @@ class AppleDiskTab extends AbstractTab
|
||||||
super (redoHandler, selector, font);
|
super (redoHandler, selector, font);
|
||||||
create (disk);
|
create (disk);
|
||||||
|
|
||||||
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject (); // select Catalog
|
// select Catalog
|
||||||
|
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject ();
|
||||||
if (afs == null)
|
if (afs == null)
|
||||||
afs = (AppleFileSource) findNode (1).getUserObject (); // select Disk
|
afs = (AppleFileSource) findNode (1).getUserObject (); // select Disk
|
||||||
redoHandler.fileSelected (new FileSelectedEvent (this, afs));
|
redoHandler.fileSelected (new FileSelectedEvent (this, afs));
|
||||||
|
@ -88,7 +90,7 @@ class AppleDiskTab extends AbstractTab
|
||||||
eventHandler.redo = true;
|
eventHandler.redo = true;
|
||||||
eventHandler.fireDiskSelectionEvent (disk);
|
eventHandler.fireDiskSelectionEvent (disk);
|
||||||
eventHandler.redo = false;
|
eventHandler.redo = false;
|
||||||
tree.setSelectionPath (null); // turn off any current selection to force an event
|
tree.setSelectionPath (null); // turn off any current selection to force an event
|
||||||
redoHandler.setCurrentData (redoData);
|
redoHandler.setCurrentData (redoData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +120,22 @@ class AppleDiskTab extends AbstractTab
|
||||||
|
|
||||||
void redoEvent (RedoEvent event)
|
void redoEvent (RedoEvent event)
|
||||||
{
|
{
|
||||||
|
AppleFileSource afs = ((FileSelectedEvent) event.value).appleFileSource;
|
||||||
selectNode (((FileSelectedEvent) event.value).appleFileSource.getUniqueName ());
|
selectNode (((FileSelectedEvent) event.value).appleFileSource.getUniqueName ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefaultMutableTreeNode findNode (String nodeName)
|
private DefaultMutableTreeNode findNode (String nodeName)
|
||||||
{
|
{
|
||||||
DefaultMutableTreeNode rootNode = getRootNode ();
|
DefaultMutableTreeNode rootNode = getRootNode ();
|
||||||
|
|
||||||
|
// check for multi-volume disk
|
||||||
|
FormattedDisk fd = ((AppleFileSource) rootNode.getUserObject ()).getFormattedDisk ();
|
||||||
|
if (fd instanceof DualDosDisk)
|
||||||
|
{
|
||||||
|
int volume = ((DualDosDisk) fd).getCurrentDiskNo ();
|
||||||
|
rootNode = (DefaultMutableTreeNode) rootNode.getChildAt (volume);
|
||||||
|
}
|
||||||
|
|
||||||
Enumeration<TreeNode> children = rootNode.breadthFirstEnumeration ();
|
Enumeration<TreeNode> children = rootNode.breadthFirstEnumeration ();
|
||||||
while (children.hasMoreElements ())
|
while (children.hasMoreElements ())
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,7 +137,7 @@ class CatalogPanel extends JTabbedPane
|
||||||
setSelectedIndex (diskTabs.size ());
|
setSelectedIndex (diskTabs.size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from RefreshTreeAction
|
// called from RefreshTreeAction
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public void refreshTree ()
|
public void refreshTree ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -150,7 +150,7 @@ class CatalogPanel extends JTabbedPane
|
||||||
fileTab.replaceDisk (((AppleDiskTab) tab).disk);
|
fileTab.replaceDisk (((AppleDiskTab) tab).disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from CloseTabAction
|
// called from CloseTabAction
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public void closeCurrentTab ()
|
public void closeCurrentTab ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -244,13 +244,12 @@ class CatalogPanel extends JTabbedPane
|
||||||
public void restore (Preferences prefs)
|
public void restore (Preferences prefs)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("Started CatalogPanel restore");
|
|
||||||
String lastDiskUsed = prefs.get (prefsLastDiskUsed, "");
|
String lastDiskUsed = prefs.get (prefsLastDiskUsed, "");
|
||||||
int lastDosUsed = prefs.getInt (prefsLastDosUsed, -1);
|
int lastDosUsed = prefs.getInt (prefsLastDosUsed, -1);
|
||||||
String lastFileUsed = prefs.get (prefsLastFileUsed, "");
|
String lastFileUsed = prefs.get (prefsLastFileUsed, "");
|
||||||
String lastSectorsUsed = prefs.get (prefsLastSectorsUsed, "");
|
String lastSectorsUsed = prefs.get (prefsLastSectorsUsed, "");
|
||||||
|
|
||||||
if (true)
|
if (false)
|
||||||
{
|
{
|
||||||
System.out.println ("Last disk : " + lastDiskUsed);
|
System.out.println ("Last disk : " + lastDiskUsed);
|
||||||
System.out.println ("Last dos : " + lastDosUsed);
|
System.out.println ("Last dos : " + lastDosUsed);
|
||||||
|
@ -258,15 +257,16 @@ class CatalogPanel extends JTabbedPane
|
||||||
System.out.println ("Last sectors : " + lastSectorsUsed);
|
System.out.println ("Last sectors : " + lastSectorsUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormattedDisk fd1 = null;
|
||||||
DiskSelectedEvent diskEvent = null;
|
DiskSelectedEvent diskEvent = null;
|
||||||
if (!lastDiskUsed.isEmpty ())
|
if (!lastDiskUsed.isEmpty ())
|
||||||
{
|
{
|
||||||
diskEvent = DiskSelectedEvent.create (this, lastDiskUsed);
|
diskEvent = DiskSelectedEvent.create (this, lastDiskUsed);
|
||||||
if (diskEvent != null)
|
if (diskEvent != null)
|
||||||
{
|
{
|
||||||
FormattedDisk fd = diskEvent.getFormattedDisk ();
|
fd1 = diskEvent.getFormattedDisk ();
|
||||||
if (lastDosUsed >= 0 && fd instanceof DualDosDisk)
|
if (lastDosUsed >= 0 && fd1 instanceof DualDosDisk)
|
||||||
((DualDosDisk) fd).setCurrentDiskNo (lastDosUsed);
|
((DualDosDisk) fd1).setCurrentDiskNo (lastDosUsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -279,14 +279,14 @@ class CatalogPanel extends JTabbedPane
|
||||||
{
|
{
|
||||||
AppleDiskTab tab = null;
|
AppleDiskTab tab = null;
|
||||||
FormattedDisk fd = diskEvent.getFormattedDisk ();
|
FormattedDisk fd = diskEvent.getFormattedDisk ();
|
||||||
|
assert fd == fd1;
|
||||||
|
|
||||||
if (!lastFileUsed.isEmpty ())
|
if (!lastFileUsed.isEmpty ())
|
||||||
{
|
{
|
||||||
AppleFileSource afs = fd.getFile (lastFileUsed);
|
AppleFileSource afs = fd.getFile (lastFileUsed);
|
||||||
System.out.println (afs);
|
|
||||||
if (afs != null)
|
if (afs != null)
|
||||||
{
|
{
|
||||||
FileSelectedEvent fileEvent = FileSelectedEvent.create (this, afs);
|
FileSelectedEvent fileEvent = new FileSelectedEvent (this, afs);
|
||||||
tab = new AppleDiskTab (fd, selector, redoHandler, font, fileEvent);
|
tab = new AppleDiskTab (fd, selector, redoHandler, font, fileEvent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -311,7 +311,6 @@ class CatalogPanel extends JTabbedPane
|
||||||
}
|
}
|
||||||
addChangeListener (new TabChangeListener ());
|
addChangeListener (new TabChangeListener ());
|
||||||
restored = true;
|
restored = true;
|
||||||
System.out.println ("Finished CatalogPanel restore");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass through to DiskSelector
|
// Pass through to DiskSelector
|
||||||
|
@ -361,7 +360,6 @@ class CatalogPanel extends JTabbedPane
|
||||||
public void redo (RedoEvent event)
|
public void redo (RedoEvent event)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("Started redo: " + event.type);
|
|
||||||
Tab tab = (Tab) getSelectedComponent ();
|
Tab tab = (Tab) getSelectedComponent ();
|
||||||
selector.redo = true;
|
selector.redo = true;
|
||||||
|
|
||||||
|
@ -387,7 +385,6 @@ class CatalogPanel extends JTabbedPane
|
||||||
}
|
}
|
||||||
|
|
||||||
selector.redo = false;
|
selector.redo = false;
|
||||||
System.out.println ("Finished redo");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class DiskSelectedEvent extends EventObject
|
||||||
public static DiskSelectedEvent create (Object source, String path)
|
public static DiskSelectedEvent create (Object source, String path)
|
||||||
{
|
{
|
||||||
FormattedDisk formattedDisk = DiskFactory.createDisk (path);
|
FormattedDisk formattedDisk = DiskFactory.createDisk (path);
|
||||||
System.out.println (formattedDisk);
|
|
||||||
return formattedDisk == null ? null : new DiskSelectedEvent (source, formattedDisk);
|
return formattedDisk == null ? null : new DiskSelectedEvent (source, formattedDisk);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import java.util.EventObject;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
||||||
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
|
|
||||||
public class FileSelectedEvent extends EventObject
|
public class FileSelectedEvent extends EventObject
|
||||||
{
|
{
|
||||||
|
@ -17,24 +18,20 @@ public class FileSelectedEvent extends EventObject
|
||||||
|
|
||||||
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
|
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
|
||||||
// must be told so that it can ensure its internal currentDisk is set correctly
|
// must be told so that it can ensure its internal currentDisk is set correctly
|
||||||
DualDosDisk ddd = (DualDosDisk) appleFileSource.getFormattedDisk ().getParent ();
|
FormattedDisk fd = appleFileSource.getFormattedDisk ();
|
||||||
|
DualDosDisk ddd = (DualDosDisk) fd.getParent ();
|
||||||
if (ddd != null)
|
if (ddd != null)
|
||||||
ddd.setCurrentDisk (appleFileSource.getFormattedDisk ());
|
ddd.setCurrentDisk (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return appleFileSource.getUniqueName ();
|
return appleFileSource.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toText ()
|
public String toText ()
|
||||||
{
|
{
|
||||||
return appleFileSource.getUniqueName ();
|
return appleFileSource.getUniqueName ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileSelectedEvent create (Object source, AppleFileSource afs)
|
|
||||||
{
|
|
||||||
return new FileSelectedEvent (source, afs);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ class RedoHandler
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
RedoData data = new RedoData (leftAction, rightAction);
|
RedoData data = new RedoData (leftAction, rightAction);
|
||||||
this.redoData = data; // doesn't fire an event this way
|
this.redoData = data; // doesn't fire an event this way
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ class RedoHandler
|
||||||
class RedoData
|
class RedoData
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<RedoEvent> events = new ArrayList<RedoEvent> ();
|
List<RedoEvent> events = new ArrayList<> ();
|
||||||
int currentEvent = -1;
|
int currentEvent = -1;
|
||||||
Action leftAction;
|
Action leftAction;
|
||||||
Action rightAction;
|
Action rightAction;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user