mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-08 02:30:30 +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.gui.DataSource;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface AppleFileSource
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
/*
|
||||
* Returns a name that uniquely identifies this object within the disk.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String getUniqueName ();
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
||||
/*
|
||||
* DataSource is implemented by AbstractSector and AbstractFile, and provides
|
||||
* routines to display the data in various formats (text, hex, assembler and
|
||||
* image).
|
||||
*/
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DataSource getDataSource ();
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
||||
/*
|
||||
* Returns a list of sectors used by this object.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<DiskAddress> getSectors ();
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
||||
/*
|
||||
* Returns the actual FormattedDisk that owns this object.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FormattedDisk getFormattedDisk ();
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean contains (DiskAddress diskAddress);
|
||||
// ---------------------------------------------------------------------------------//
|
||||
}
|
@ -27,8 +27,6 @@ public class DualDosDisk implements FormattedDisk
|
||||
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;
|
||||
String diskName = disk0.getDisk ().getFile ().getName ();
|
||||
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)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (disks[0] == fd && currentDisk != 0)
|
||||
if (disks[0] == fd)
|
||||
currentDisk = 0;
|
||||
else if (disks[1] == fd && currentDisk != 1)
|
||||
else if (disks[1] == fd)
|
||||
currentDisk = 1;
|
||||
System.out.printf ("1. Setting disk: %d%n", currentDisk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -146,7 +143,6 @@ public class DualDosDisk implements FormattedDisk
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
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.disk.DiskFactory;
|
||||
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||
|
||||
@ -49,7 +50,7 @@ class AppleDiskTab extends AbstractTab
|
||||
RedoHandler redoHandler, Font font, String lastFileUsed)
|
||||
{
|
||||
super (redoHandler, selector, font);
|
||||
System.out.println ("******************");
|
||||
System.out.println ("****************** File not found");
|
||||
create (disk);
|
||||
// System.out.println ("ooh - couldn't find the previous file");
|
||||
DefaultMutableTreeNode node = findNode (lastFileUsed);
|
||||
@ -68,7 +69,8 @@ class AppleDiskTab extends AbstractTab
|
||||
super (redoHandler, selector, font);
|
||||
create (disk);
|
||||
|
||||
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject (); // select Catalog
|
||||
// select Catalog
|
||||
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject ();
|
||||
if (afs == null)
|
||||
afs = (AppleFileSource) findNode (1).getUserObject (); // select Disk
|
||||
redoHandler.fileSelected (new FileSelectedEvent (this, afs));
|
||||
@ -88,7 +90,7 @@ class AppleDiskTab extends AbstractTab
|
||||
eventHandler.redo = true;
|
||||
eventHandler.fireDiskSelectionEvent (disk);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -118,12 +120,22 @@ class AppleDiskTab extends AbstractTab
|
||||
|
||||
void redoEvent (RedoEvent event)
|
||||
{
|
||||
AppleFileSource afs = ((FileSelectedEvent) event.value).appleFileSource;
|
||||
selectNode (((FileSelectedEvent) event.value).appleFileSource.getUniqueName ());
|
||||
}
|
||||
|
||||
private DefaultMutableTreeNode findNode (String nodeName)
|
||||
{
|
||||
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 ();
|
||||
while (children.hasMoreElements ())
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ class CatalogPanel extends JTabbedPane
|
||||
setSelectedIndex (diskTabs.size ());
|
||||
}
|
||||
|
||||
// Called from RefreshTreeAction
|
||||
// called from RefreshTreeAction
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void refreshTree ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -150,7 +150,7 @@ class CatalogPanel extends JTabbedPane
|
||||
fileTab.replaceDisk (((AppleDiskTab) tab).disk);
|
||||
}
|
||||
|
||||
// Called from CloseTabAction
|
||||
// called from CloseTabAction
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void closeCurrentTab ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -244,13 +244,12 @@ class CatalogPanel extends JTabbedPane
|
||||
public void restore (Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
System.out.println ("Started CatalogPanel restore");
|
||||
String lastDiskUsed = prefs.get (prefsLastDiskUsed, "");
|
||||
int lastDosUsed = prefs.getInt (prefsLastDosUsed, -1);
|
||||
String lastFileUsed = prefs.get (prefsLastFileUsed, "");
|
||||
String lastSectorsUsed = prefs.get (prefsLastSectorsUsed, "");
|
||||
|
||||
if (true)
|
||||
if (false)
|
||||
{
|
||||
System.out.println ("Last disk : " + lastDiskUsed);
|
||||
System.out.println ("Last dos : " + lastDosUsed);
|
||||
@ -258,15 +257,16 @@ class CatalogPanel extends JTabbedPane
|
||||
System.out.println ("Last sectors : " + lastSectorsUsed);
|
||||
}
|
||||
|
||||
FormattedDisk fd1 = null;
|
||||
DiskSelectedEvent diskEvent = null;
|
||||
if (!lastDiskUsed.isEmpty ())
|
||||
{
|
||||
diskEvent = DiskSelectedEvent.create (this, lastDiskUsed);
|
||||
if (diskEvent != null)
|
||||
{
|
||||
FormattedDisk fd = diskEvent.getFormattedDisk ();
|
||||
if (lastDosUsed >= 0 && fd instanceof DualDosDisk)
|
||||
((DualDosDisk) fd).setCurrentDiskNo (lastDosUsed);
|
||||
fd1 = diskEvent.getFormattedDisk ();
|
||||
if (lastDosUsed >= 0 && fd1 instanceof DualDosDisk)
|
||||
((DualDosDisk) fd1).setCurrentDiskNo (lastDosUsed);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -279,14 +279,14 @@ class CatalogPanel extends JTabbedPane
|
||||
{
|
||||
AppleDiskTab tab = null;
|
||||
FormattedDisk fd = diskEvent.getFormattedDisk ();
|
||||
assert fd == fd1;
|
||||
|
||||
if (!lastFileUsed.isEmpty ())
|
||||
{
|
||||
AppleFileSource afs = fd.getFile (lastFileUsed);
|
||||
System.out.println (afs);
|
||||
if (afs != null)
|
||||
{
|
||||
FileSelectedEvent fileEvent = FileSelectedEvent.create (this, afs);
|
||||
FileSelectedEvent fileEvent = new FileSelectedEvent (this, afs);
|
||||
tab = new AppleDiskTab (fd, selector, redoHandler, font, fileEvent);
|
||||
}
|
||||
else
|
||||
@ -311,7 +311,6 @@ class CatalogPanel extends JTabbedPane
|
||||
}
|
||||
addChangeListener (new TabChangeListener ());
|
||||
restored = true;
|
||||
System.out.println ("Finished CatalogPanel restore");
|
||||
}
|
||||
|
||||
// Pass through to DiskSelector
|
||||
@ -361,7 +360,6 @@ class CatalogPanel extends JTabbedPane
|
||||
public void redo (RedoEvent event)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
System.out.println ("Started redo: " + event.type);
|
||||
Tab tab = (Tab) getSelectedComponent ();
|
||||
selector.redo = true;
|
||||
|
||||
@ -387,7 +385,6 @@ class CatalogPanel extends JTabbedPane
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
FormattedDisk formattedDisk = DiskFactory.createDisk (path);
|
||||
System.out.println (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.disk.DualDosDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
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
|
||||
// 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)
|
||||
ddd.setCurrentDisk (appleFileSource.getFormattedDisk ());
|
||||
ddd.setCurrentDisk (fd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return appleFileSource.getUniqueName ();
|
||||
return appleFileSource.toString ();
|
||||
}
|
||||
|
||||
public String toText ()
|
||||
{
|
||||
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);
|
||||
this.redoData = data; // doesn't fire an event this way
|
||||
this.redoData = data; // doesn't fire an event this way
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ class RedoHandler
|
||||
class RedoData
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
List<RedoEvent> events = new ArrayList<RedoEvent> ();
|
||||
List<RedoEvent> events = new ArrayList<> ();
|
||||
int currentEvent = -1;
|
||||
Action leftAction;
|
||||
Action rightAction;
|
||||
|
Loading…
x
Reference in New Issue
Block a user