mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-05-28 08:41:29 +00:00
method header lines
This commit is contained in:
parent
1043b8964f
commit
343e5da6d9
|
@ -1,57 +1,65 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
public class AboutAction extends DefaultAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class AboutAction extends DefaultAction
|
||||||
public AboutAction ()
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("About...", "Display build information", "/com/bytezone/diskbrowser/icons/");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt A"));
|
AboutAction ()
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_A);
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
setIcon (Action.SMALL_ICON, "information_16.png");
|
super ("About...", "Display build information", "/com/bytezone/diskbrowser/icons/");
|
||||||
setIcon (Action.LARGE_ICON_KEY, "information_32.png");
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt A"));
|
||||||
}
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_A);
|
||||||
|
|
||||||
@Override
|
setIcon (Action.SMALL_ICON, "information_16.png");
|
||||||
public void actionPerformed (ActionEvent e)
|
setIcon (Action.LARGE_ICON_KEY, "information_32.png");
|
||||||
{
|
}
|
||||||
about ();
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public void about ()
|
public void actionPerformed (ActionEvent e)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
// int build = 0;
|
{
|
||||||
// String buildDate = "<no date>";
|
about ();
|
||||||
// Properties props = new Properties ();
|
}
|
||||||
// InputStream in = this.getClass ().getResourceAsStream ("build.properties");
|
|
||||||
// if (in != null)
|
// ---------------------------------------------------------------------------------//
|
||||||
// {
|
public void about ()
|
||||||
// try
|
// ---------------------------------------------------------------------------------//
|
||||||
// {
|
{
|
||||||
// props.load (in);
|
// int build = 0;
|
||||||
// in.close ();
|
// String buildDate = "<no date>";
|
||||||
// build = Integer.parseInt (props.getProperty ("build.number"));
|
// Properties props = new Properties ();
|
||||||
// buildDate = props.getProperty ("build.date");
|
// InputStream in = this.getClass ().getResourceAsStream ("build.properties");
|
||||||
// }
|
// if (in != null)
|
||||||
// catch (IOException e1)
|
// {
|
||||||
// {
|
// try
|
||||||
// System.out.println ("Properties file not found");
|
// {
|
||||||
// }
|
// props.load (in);
|
||||||
// }
|
// in.close ();
|
||||||
|
// build = Integer.parseInt (props.getProperty ("build.number"));
|
||||||
JOptionPane.showMessageDialog (null, "Author - Denis Molony" //
|
// buildDate = props.getProperty ("build.date");
|
||||||
// + "\nBuild #" + String.format ("%d", build) + " - " + buildDate + "\n" //
|
// }
|
||||||
+ "\nGitHub - https://github.com/dmolony/DiskBrowser", //
|
// catch (IOException e1)
|
||||||
// + "\nContact - dmolony@iinet.net.au", //
|
// {
|
||||||
"About DiskBrowser", JOptionPane.INFORMATION_MESSAGE);
|
// System.out.println ("Properties file not found");
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
JOptionPane.showMessageDialog (null, "Author - Denis Molony" //
|
||||||
|
// + "\nBuild #" + String.format ("%d", build) + " - " + buildDate + "\n" //
|
||||||
|
+ "\nGitHub - https://github.com/dmolony/DiskBrowser", //
|
||||||
|
// + "\nContact - dmolony@iinet.net.au", //
|
||||||
|
"About DiskBrowser", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,180 +1,206 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
* JPanel used to display a scrolling JTree containing details of a single disk. The JTree
|
* JPanel used to display a scrolling JTree containing details of a single disk. The JTree
|
||||||
* consists entirely of AppleFileSource objects. Any number of these objects are contained
|
* consists entirely of AppleFileSource objects. Any number of these objects are contained
|
||||||
* in Catalog Panel, along with a single FileSystemTab.
|
* in Catalog Panel, along with a single FileSystemTab.
|
||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.event.TreeSelectionListener;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.TreeNode;
|
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.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;
|
||||||
|
|
||||||
class AppleDiskTab extends AbstractTab
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class AppleDiskTab extends AbstractTab
|
||||||
FormattedDisk disk;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
// restoring from a file selection
|
FormattedDisk disk;
|
||||||
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
|
||||||
RedoHandler redoHandler, Font font, FileSelectedEvent event)
|
// restoring from a file selection
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
super (redoHandler, selector, font);
|
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
||||||
create (disk);
|
RedoHandler redoHandler, Font font, FileSelectedEvent event)
|
||||||
redoHandler.fileSelected (event);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
super (redoHandler, selector, font);
|
||||||
// restoring from a sector selection
|
create (disk);
|
||||||
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
redoHandler.fileSelected (event);
|
||||||
RedoHandler redoHandler, Font font, SectorSelectedEvent event)
|
}
|
||||||
{
|
|
||||||
super (redoHandler, selector, font);
|
// restoring from a sector selection
|
||||||
create (disk);
|
// ---------------------------------------------------------------------------------//
|
||||||
redoHandler.sectorSelected (event);
|
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
||||||
}
|
RedoHandler redoHandler, Font font, SectorSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
// This constructor is only called when lastFileUsed is not null, but the disk
|
{
|
||||||
// couldn't find the file entry. Either the file has been deleted, or it is a disk
|
super (redoHandler, selector, font);
|
||||||
// with redefined files (Wizardry, Infocom etc).
|
create (disk);
|
||||||
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
redoHandler.sectorSelected (event);
|
||||||
RedoHandler redoHandler, Font font, String lastFileUsed)
|
}
|
||||||
{
|
|
||||||
super (redoHandler, selector, font);
|
// This constructor is only called when lastFileUsed is not null, but the disk
|
||||||
System.out.println ("****************** File not found");
|
// couldn't find the file entry. Either the file has been deleted, or it is a disk
|
||||||
create (disk);
|
// with redefined files (Wizardry, Infocom etc).
|
||||||
// System.out.println ("ooh - couldn't find the previous file");
|
// ---------------------------------------------------------------------------------//
|
||||||
DefaultMutableTreeNode node = findNode (lastFileUsed);
|
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
||||||
if (node != null)
|
RedoHandler redoHandler, Font font, String lastFileUsed)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
AppleFileSource afs = (AppleFileSource) node.getUserObject ();
|
{
|
||||||
FileSelectedEvent event = new FileSelectedEvent (this, afs);
|
super (redoHandler, selector, font);
|
||||||
redoHandler.fileSelected (event);
|
System.out.println ("****************** File not found");
|
||||||
}
|
create (disk);
|
||||||
}
|
// System.out.println ("ooh - couldn't find the previous file");
|
||||||
|
DefaultMutableTreeNode node = findNode (lastFileUsed);
|
||||||
// User is selecting a new disk from the catalog
|
if (node != null)
|
||||||
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
{
|
||||||
RedoHandler redoHandler, Font font)
|
AppleFileSource afs = (AppleFileSource) node.getUserObject ();
|
||||||
{
|
FileSelectedEvent event = new FileSelectedEvent (this, afs);
|
||||||
super (redoHandler, selector, font);
|
redoHandler.fileSelected (event);
|
||||||
create (disk);
|
}
|
||||||
|
}
|
||||||
// select Catalog
|
|
||||||
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject ();
|
// User is selecting a new disk from the catalog
|
||||||
if (afs == null)
|
// ---------------------------------------------------------------------------------//
|
||||||
afs = (AppleFileSource) findNode (1).getUserObject (); // select Disk
|
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
|
||||||
redoHandler.fileSelected (new FileSelectedEvent (this, afs));
|
RedoHandler redoHandler, Font font)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
private void create (FormattedDisk disk)
|
super (redoHandler, selector, font);
|
||||||
{
|
create (disk);
|
||||||
this.disk = disk;
|
|
||||||
setTree (disk.getCatalogTree ());
|
// select Catalog
|
||||||
setSelectionListener (tree);
|
AppleFileSource afs = (AppleFileSource) findNode (2).getUserObject ();
|
||||||
}
|
if (afs == null)
|
||||||
|
afs = (AppleFileSource) findNode (1).getUserObject (); // select Disk
|
||||||
@Override
|
redoHandler.fileSelected (new FileSelectedEvent (this, afs));
|
||||||
public void activate ()
|
}
|
||||||
{
|
|
||||||
// System.out.println ("=========== Activating AppleDiskTab =============");
|
// ---------------------------------------------------------------------------------//
|
||||||
eventHandler.redo = true;
|
private void create (FormattedDisk disk)
|
||||||
eventHandler.fireDiskSelectionEvent (disk);
|
// ---------------------------------------------------------------------------------//
|
||||||
eventHandler.redo = false;
|
{
|
||||||
tree.setSelectionPath (null); // turn off any current selection to force an event
|
this.disk = disk;
|
||||||
redoHandler.setCurrentData (redoData);
|
setTree (disk.getCatalogTree ());
|
||||||
}
|
setSelectionListener (tree);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void refresh () // called when the user gives ALT-R command
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
Object o = getSelectedObject ();
|
public void activate ()
|
||||||
String currentFile = (o == null) ? null : ((AppleFileSource) o).getUniqueName ();
|
// ---------------------------------------------------------------------------------//
|
||||||
disk = DiskFactory.createDisk (disk.getAbsolutePath ());
|
{
|
||||||
setTree (disk.getCatalogTree ());
|
// System.out.println ("=========== Activating AppleDiskTab =============");
|
||||||
setSelectionListener (tree);
|
eventHandler.redo = true;
|
||||||
selectNode (currentFile);
|
eventHandler.fireDiskSelectionEvent (disk);
|
||||||
}
|
eventHandler.redo = false;
|
||||||
|
tree.setSelectionPath (null); // turn off any current selection to force an event
|
||||||
private void selectNode (String nodeName)
|
redoHandler.setCurrentData (redoData);
|
||||||
{
|
}
|
||||||
DefaultMutableTreeNode selectNode = null;
|
|
||||||
if (nodeName != null)
|
// ---------------------------------------------------------------------------------//
|
||||||
selectNode = findNode (nodeName);
|
@Override
|
||||||
if (selectNode == null)
|
public void refresh () // called when the user gives ALT-R command
|
||||||
selectNode = findNode (2);
|
// ---------------------------------------------------------------------------------//
|
||||||
if (selectNode != null)
|
{
|
||||||
showNode (selectNode);
|
Object o = getSelectedObject ();
|
||||||
else
|
String currentFile = (o == null) ? null : ((AppleFileSource) o).getUniqueName ();
|
||||||
System.out.println ("First node not found");
|
disk = DiskFactory.createDisk (disk.getAbsolutePath ());
|
||||||
}
|
setTree (disk.getCatalogTree ());
|
||||||
|
setSelectionListener (tree);
|
||||||
void redoEvent (RedoEvent event)
|
selectNode (currentFile);
|
||||||
{
|
}
|
||||||
AppleFileSource afs = ((FileSelectedEvent) event.value).appleFileSource;
|
|
||||||
FileSelectedEvent fileSelectedEvent = (FileSelectedEvent) event.value;
|
// ---------------------------------------------------------------------------------//
|
||||||
if (fileSelectedEvent.volumeNo >= 0)
|
private void selectNode (String nodeName)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
DualDosDisk ddd = (DualDosDisk) afs.getFormattedDisk ().getParent ();
|
{
|
||||||
ddd.setCurrentDiskNo (fileSelectedEvent.volumeNo);
|
DefaultMutableTreeNode selectNode = null;
|
||||||
}
|
if (nodeName != null)
|
||||||
selectNode (fileSelectedEvent.appleFileSource.getUniqueName ());
|
selectNode = findNode (nodeName);
|
||||||
}
|
if (selectNode == null)
|
||||||
|
selectNode = findNode (2);
|
||||||
private DefaultMutableTreeNode findNode (String nodeName)
|
if (selectNode != null)
|
||||||
{
|
showNode (selectNode);
|
||||||
DefaultMutableTreeNode rootNode = getRootNode ();
|
else
|
||||||
|
System.out.println ("First node not found");
|
||||||
// check for multi-volume disk (only search the current branch)
|
}
|
||||||
FormattedDisk fd = ((AppleFileSource) rootNode.getUserObject ()).getFormattedDisk ();
|
|
||||||
if (fd instanceof DualDosDisk)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
void redoEvent (RedoEvent event)
|
||||||
int volume = ((DualDosDisk) fd).getCurrentDiskNo ();
|
// ---------------------------------------------------------------------------------//
|
||||||
rootNode = (DefaultMutableTreeNode) rootNode.getChildAt (volume);
|
{
|
||||||
}
|
AppleFileSource afs = ((FileSelectedEvent) event.value).appleFileSource;
|
||||||
|
FileSelectedEvent fileSelectedEvent = (FileSelectedEvent) event.value;
|
||||||
Enumeration<TreeNode> children = rootNode.breadthFirstEnumeration ();
|
if (fileSelectedEvent.volumeNo >= 0)
|
||||||
while (children.hasMoreElements ())
|
{
|
||||||
{
|
DualDosDisk ddd = (DualDosDisk) afs.getFormattedDisk ().getParent ();
|
||||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement ();
|
ddd.setCurrentDiskNo (fileSelectedEvent.volumeNo);
|
||||||
Object userObject = node.getUserObject ();
|
}
|
||||||
if (userObject instanceof AppleFileSource
|
selectNode (fileSelectedEvent.appleFileSource.getUniqueName ());
|
||||||
&& nodeName.equals (((AppleFileSource) userObject).getUniqueName ()))
|
}
|
||||||
return node;
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
return null;
|
private DefaultMutableTreeNode findNode (String nodeName)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public boolean contains (FormattedDisk disk)
|
DefaultMutableTreeNode rootNode = getRootNode ();
|
||||||
{
|
|
||||||
return this.disk.getAbsolutePath ().equals (disk.getAbsolutePath ());
|
// check for multi-volume disk (only search the current branch)
|
||||||
}
|
FormattedDisk fd = ((AppleFileSource) rootNode.getUserObject ()).getFormattedDisk ();
|
||||||
|
if (fd instanceof DualDosDisk)
|
||||||
// This action is triggered by AppleDiskTab.selectNode (String), which calls
|
{
|
||||||
// AbstractTab.showNode (DefaultMutableTreeNode). That will trigger this listener
|
int volume = ((DualDosDisk) fd).getCurrentDiskNo ();
|
||||||
// ONLY if the value is different, so it is set to null first to force the event.
|
rootNode = (DefaultMutableTreeNode) rootNode.getChildAt (volume);
|
||||||
private void setSelectionListener (JTree tree)
|
}
|
||||||
{
|
|
||||||
tree.addTreeSelectionListener (new TreeSelectionListener ()
|
Enumeration<TreeNode> children = rootNode.breadthFirstEnumeration ();
|
||||||
{
|
while (children.hasMoreElements ())
|
||||||
@Override
|
{
|
||||||
public void valueChanged (TreeSelectionEvent e)
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement ();
|
||||||
{
|
Object userObject = node.getUserObject ();
|
||||||
// A null happens when there is a click in the DiskLayoutPanel, in order
|
if (userObject instanceof AppleFileSource
|
||||||
// to turn off the currently selected file
|
&& nodeName.equals (((AppleFileSource) userObject).getUniqueName ()))
|
||||||
AppleFileSource afs = (AppleFileSource) getSelectedObject ();
|
return node;
|
||||||
if (afs != null)
|
}
|
||||||
eventHandler.fireFileSelectionEvent (afs);
|
return null;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public boolean contains (FormattedDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return this.disk.getAbsolutePath ().equals (disk.getAbsolutePath ());
|
||||||
|
}
|
||||||
|
|
||||||
|
// This action is triggered by AppleDiskTab.selectNode (String), which calls
|
||||||
|
// AbstractTab.showNode (DefaultMutableTreeNode). That will trigger this listener
|
||||||
|
// ONLY if the value is different, so it is set to null first to force the event.
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private void setSelectionListener (JTree tree)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
tree.addTreeSelectionListener (new TreeSelectionListener ()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void valueChanged (TreeSelectionEvent e)
|
||||||
|
{
|
||||||
|
// A null happens when there is a click in the DiskLayoutPanel, in order
|
||||||
|
// to turn off the currently selected file
|
||||||
|
AppleFileSource afs = (AppleFileSource) getSelectedObject ();
|
||||||
|
if (afs != null)
|
||||||
|
eventHandler.fireFileSelectionEvent (afs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,18 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class AssemblerPreferences
|
public class AssemblerPreferences
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public boolean showTargets = true;
|
public boolean showTargets = true;
|
||||||
public boolean showStrings = true;
|
public boolean showStrings = true;
|
||||||
public boolean offsetFromZero = false;
|
public boolean offsetFromZero = false;
|
||||||
public boolean showHeader = true;
|
public boolean showHeader = true;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface AssemblerPreferencesListener
|
public interface AssemblerPreferencesListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences);
|
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences);
|
||||||
}
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class BasicPreferences
|
public class BasicPreferences
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public boolean splitRem = false;
|
public boolean splitRem = false;
|
||||||
public boolean alignAssign = true;
|
public boolean alignAssign = true;
|
||||||
|
@ -11,8 +13,10 @@ public class BasicPreferences
|
||||||
public int wrapPrintAt = 40;
|
public int wrapPrintAt = 40;
|
||||||
public int wrapRemAt = 60;
|
public int wrapRemAt = 60;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface BasicPreferencesListener
|
public interface BasicPreferencesListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void setBasicPreferences (BasicPreferences basicPreferences);
|
public void setBasicPreferences (BasicPreferences basicPreferences);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,15 @@ import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class CloseTabAction extends AbstractAction
|
public class CloseTabAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
CatalogPanel catalogPanel;
|
CatalogPanel catalogPanel;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public CloseTabAction (CatalogPanel catalogPanel)
|
public CloseTabAction (CatalogPanel catalogPanel)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Close Tab");
|
super ("Close Tab");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Close the current disk tab");
|
putValue (Action.SHORT_DESCRIPTION, "Close the current disk tab");
|
||||||
|
@ -23,8 +27,10 @@ public class CloseTabAction extends AbstractAction
|
||||||
this.catalogPanel = catalogPanel;
|
this.catalogPanel = catalogPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
catalogPanel.closeCurrentTab ();
|
catalogPanel.closeCurrentTab ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,15 @@ import javax.swing.Action;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class ColourQuirksAction extends AbstractAction
|
public class ColourQuirksAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public ColourQuirksAction (DataPanel owner)
|
public ColourQuirksAction (DataPanel owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Smear HGR");
|
super ("Smear HGR");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Display pixels like a TV screen");
|
putValue (Action.SHORT_DESCRIPTION, "Display pixels like a TV screen");
|
||||||
|
@ -21,8 +25,10 @@ public class ColourQuirksAction extends AbstractAction
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.setColourQuirks (((JMenuItem) e.getSource ()).isSelected ());
|
owner.setColourQuirks (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,25 @@ import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class CreateDatabaseAction extends DefaultAction
|
class CreateDatabaseAction extends DefaultAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public CreateDatabaseAction ()
|
public CreateDatabaseAction ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Create Database", "Not working yet", null);
|
super ("Create Database", "Not working yet", null);
|
||||||
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt A"));
|
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt A"));
|
||||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_A);
|
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog (null, "Coming soon...", "Database",
|
JOptionPane.showMessageDialog (null, "Coming soon...", "Database",
|
||||||
JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,442 +1,504 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.Dimension;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.Font;
|
||||||
import java.util.Enumeration;
|
import java.awt.Graphics;
|
||||||
import java.util.List;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Insets;
|
||||||
import javax.swing.*;
|
import java.awt.RenderingHints;
|
||||||
import javax.swing.event.ChangeEvent;
|
import java.awt.geom.AffineTransform;
|
||||||
import javax.swing.event.ChangeListener;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Enumeration;
|
||||||
import com.bytezone.common.FontAction.FontChangeEvent;
|
import java.util.List;
|
||||||
import com.bytezone.common.FontAction.FontChangeListener;
|
|
||||||
import com.bytezone.diskbrowser.applefile.*;
|
import javax.swing.AbstractButton;
|
||||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
import javax.swing.ButtonGroup;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
import com.bytezone.diskbrowser.disk.SectorList;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
class DataPanel extends JTabbedPane
|
import javax.swing.JTabbedPane;
|
||||||
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
import javax.swing.JTextArea;
|
||||||
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
|
import javax.swing.ScrollPaneConstants;
|
||||||
AssemblerPreferencesListener
|
import javax.swing.SwingConstants;
|
||||||
{
|
import javax.swing.event.ChangeEvent;
|
||||||
private static final int TEXT_WIDTH = 65;
|
import javax.swing.event.ChangeListener;
|
||||||
private static final int BACKGROUND = 245;
|
|
||||||
|
import com.bytezone.common.FontAction.FontChangeEvent;
|
||||||
private final JTextArea formattedText;
|
import com.bytezone.common.FontAction.FontChangeListener;
|
||||||
private final JTextArea hexText;
|
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
|
||||||
private final JTextArea disassemblyText;
|
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
||||||
|
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||||
// these two panes are interchangeable
|
import com.bytezone.diskbrowser.applefile.Palette;
|
||||||
private final JScrollPane formattedPane;
|
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||||
private final JScrollPane imagePane;
|
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||||
|
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||||
private final ImagePanel imagePanel; // internal class
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
private boolean debugMode;
|
import com.bytezone.diskbrowser.disk.SectorList;
|
||||||
|
|
||||||
private boolean imageVisible = false;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
||||||
// used to determine whether the text has been set
|
FileSelectionListener, SectorSelectionListener, FileNodeSelectionListener,
|
||||||
boolean formattedTextValid;
|
FontChangeListener, BasicPreferencesListener, AssemblerPreferencesListener
|
||||||
boolean hexTextValid;
|
// -----------------------------------------------------------------------------------//
|
||||||
boolean assemblerTextValid;
|
{
|
||||||
DataSource currentDataSource;
|
private static final int TEXT_WIDTH = 65;
|
||||||
|
private static final int BACKGROUND = 245;
|
||||||
final MenuHandler menuHandler;
|
|
||||||
|
private final JTextArea formattedText;
|
||||||
public DataPanel (MenuHandler mh)
|
private final JTextArea hexText;
|
||||||
{
|
private final JTextArea disassemblyText;
|
||||||
this.menuHandler = mh;
|
|
||||||
setTabPlacement (SwingConstants.BOTTOM);
|
// these two panes are interchangeable
|
||||||
|
private final JScrollPane formattedPane;
|
||||||
formattedText = new JTextArea (10, TEXT_WIDTH);
|
private final JScrollPane imagePane;
|
||||||
formattedPane = setPanel (formattedText, "Formatted");
|
|
||||||
// formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true));
|
private final ImagePanel imagePanel; // internal class
|
||||||
formattedText.setText ("Please use the 'File->Set HOME folder...' command to "
|
private boolean debugMode;
|
||||||
+ "\ntell DiskBrowser where your Apple disks are located."
|
|
||||||
+ "\n\nTo see the contents of a disk in more detail, double-click"
|
private boolean imageVisible = false;
|
||||||
+ "\nthe disk. You will then be able to select individual files to "
|
|
||||||
+ "view completely.");
|
// used to determine whether the text has been set
|
||||||
|
boolean formattedTextValid;
|
||||||
hexText = new JTextArea (10, TEXT_WIDTH);
|
boolean hexTextValid;
|
||||||
setPanel (hexText, "Hex dump");
|
boolean assemblerTextValid;
|
||||||
|
DataSource currentDataSource;
|
||||||
disassemblyText = new JTextArea (10, TEXT_WIDTH);
|
|
||||||
setPanel (disassemblyText, "Disassembly");
|
final MenuHandler menuHandler;
|
||||||
|
|
||||||
imagePanel = new ImagePanel ();
|
// ---------------------------------------------------------------------------------//
|
||||||
imagePane =
|
public DataPanel (MenuHandler mh)
|
||||||
new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
// ---------------------------------------------------------------------------------//
|
||||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
{
|
||||||
|
this.menuHandler = mh;
|
||||||
imagePane.setBorder (null);
|
setTabPlacement (SwingConstants.BOTTOM);
|
||||||
|
|
||||||
imagePane.getVerticalScrollBar ().setUnitIncrement (50);
|
formattedText = new JTextArea (10, TEXT_WIDTH);
|
||||||
imagePane.getHorizontalScrollBar ().setUnitIncrement (25);
|
formattedPane = setPanel (formattedText, "Formatted");
|
||||||
|
// formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true));
|
||||||
addChangeListener (new ChangeListener ()
|
formattedText.setText ("Please use the 'File->Set HOME folder...' command to "
|
||||||
{
|
+ "\ntell DiskBrowser where your Apple disks are located."
|
||||||
@Override
|
+ "\n\nTo see the contents of a disk in more detail, double-click"
|
||||||
public void stateChanged (ChangeEvent e)
|
+ "\nthe disk. You will then be able to select individual files to "
|
||||||
{
|
+ "view completely.");
|
||||||
switch (getSelectedIndex ())
|
|
||||||
{
|
hexText = new JTextArea (10, TEXT_WIDTH);
|
||||||
case 0:
|
setPanel (hexText, "Hex dump");
|
||||||
if (!formattedTextValid)
|
|
||||||
{
|
disassemblyText = new JTextArea (10, TEXT_WIDTH);
|
||||||
if (currentDataSource == null)
|
setPanel (disassemblyText, "Disassembly");
|
||||||
formattedText.setText ("");
|
|
||||||
else
|
imagePanel = new ImagePanel ();
|
||||||
setText (formattedText, currentDataSource.getText ());
|
imagePane =
|
||||||
formattedTextValid = true;
|
new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
}
|
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
break;
|
|
||||||
case 1:
|
imagePane.setBorder (null);
|
||||||
if (!hexTextValid)
|
|
||||||
{
|
imagePane.getVerticalScrollBar ().setUnitIncrement (50);
|
||||||
if (currentDataSource == null)
|
imagePane.getHorizontalScrollBar ().setUnitIncrement (25);
|
||||||
hexText.setText ("");
|
|
||||||
else
|
addChangeListener (new ChangeListener ()
|
||||||
setText (hexText, currentDataSource.getHexDump ());
|
{
|
||||||
hexTextValid = true;
|
@Override
|
||||||
}
|
public void stateChanged (ChangeEvent e)
|
||||||
break;
|
{
|
||||||
case 2:
|
switch (getSelectedIndex ())
|
||||||
if (!assemblerTextValid)
|
{
|
||||||
{
|
case 0:
|
||||||
if (currentDataSource == null)
|
if (!formattedTextValid)
|
||||||
disassemblyText.setText ("");
|
{
|
||||||
else
|
if (currentDataSource == null)
|
||||||
setText (disassemblyText, currentDataSource.getAssembler ());
|
formattedText.setText ("");
|
||||||
assemblerTextValid = true;
|
else
|
||||||
}
|
setText (formattedText, currentDataSource.getText ());
|
||||||
break;
|
formattedTextValid = true;
|
||||||
default:
|
}
|
||||||
System.out.println ("Invalid index selected in DataPanel");
|
break;
|
||||||
}
|
case 1:
|
||||||
}
|
if (!hexTextValid)
|
||||||
});
|
{
|
||||||
|
if (currentDataSource == null)
|
||||||
LineWrapAction lineWrapAction = new LineWrapAction ();
|
hexText.setText ("");
|
||||||
menuHandler.lineWrapItem.setAction (lineWrapAction);
|
else
|
||||||
lineWrapAction.addListener (formattedText);
|
setText (hexText, currentDataSource.getHexDump ());
|
||||||
|
hexTextValid = true;
|
||||||
menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this));
|
}
|
||||||
menuHandler.monochromeItem.setAction (new MonochromeAction (this));
|
break;
|
||||||
menuHandler.debuggingItem.setAction (new DebuggingAction (this));
|
case 2:
|
||||||
|
if (!assemblerTextValid)
|
||||||
// fill in the placeholders created by the MenuHandler
|
{
|
||||||
List<Palette> palettes = HiResImage.getPalettes ();
|
if (currentDataSource == null)
|
||||||
ButtonGroup buttonGroup = menuHandler.paletteGroup;
|
disassemblyText.setText ("");
|
||||||
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
|
else
|
||||||
int ndx = 0;
|
setText (disassemblyText, currentDataSource.getAssembler ());
|
||||||
while (enumeration.hasMoreElements ())
|
assemblerTextValid = true;
|
||||||
{
|
}
|
||||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
break;
|
||||||
item.setAction (new PaletteAction (this, palettes.get (ndx++)));
|
default:
|
||||||
}
|
System.out.println ("Invalid index selected in DataPanel");
|
||||||
menuHandler.nextPaletteItem.setAction (new NextPaletteAction (this, buttonGroup));
|
}
|
||||||
menuHandler.prevPaletteItem.setAction (new PreviousPaletteAction (this, buttonGroup));
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
public void selectPalette (Palette palette)
|
LineWrapAction lineWrapAction = new LineWrapAction ();
|
||||||
{
|
menuHandler.lineWrapItem.setAction (lineWrapAction);
|
||||||
HiResImage.getPaletteFactory ().setCurrentPalette (palette);
|
lineWrapAction.addListener (formattedText);
|
||||||
if (currentDataSource instanceof HiResImage)
|
|
||||||
{
|
menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this));
|
||||||
HiResImage image = (HiResImage) currentDataSource;
|
menuHandler.monochromeItem.setAction (new MonochromeAction (this));
|
||||||
image.setPalette ();
|
menuHandler.debuggingItem.setAction (new DebuggingAction (this));
|
||||||
imagePanel.setImage (image.getImage ());
|
|
||||||
}
|
// fill in the placeholders created by the MenuHandler
|
||||||
}
|
List<Palette> palettes = HiResImage.getPalettes ();
|
||||||
|
ButtonGroup buttonGroup = menuHandler.paletteGroup;
|
||||||
public Palette cyclePalette (CycleDirection direction)
|
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
|
||||||
{
|
int ndx = 0;
|
||||||
Palette palette = HiResImage.getPaletteFactory ().cyclePalette (direction);
|
while (enumeration.hasMoreElements ())
|
||||||
if (currentDataSource instanceof HiResImage)
|
{
|
||||||
{
|
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
||||||
HiResImage image = (HiResImage) currentDataSource;
|
item.setAction (new PaletteAction (this, palettes.get (ndx++)));
|
||||||
image.setPalette ();
|
}
|
||||||
imagePanel.setImage (image.getImage ());
|
menuHandler.nextPaletteItem.setAction (new NextPaletteAction (this, buttonGroup));
|
||||||
}
|
menuHandler.prevPaletteItem.setAction (new PreviousPaletteAction (this, buttonGroup));
|
||||||
return palette;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void setLineWrap (boolean lineWrap)
|
public void selectPalette (Palette palette)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
formattedText.setLineWrap (lineWrap);
|
{
|
||||||
}
|
HiResImage.getPaletteFactory ().setCurrentPalette (palette);
|
||||||
|
if (currentDataSource instanceof HiResImage)
|
||||||
public void setColourQuirks (boolean value)
|
{
|
||||||
{
|
HiResImage image = (HiResImage) currentDataSource;
|
||||||
if (currentDataSource instanceof HiResImage)
|
image.setPalette ();
|
||||||
{
|
imagePanel.setImage (image.getImage ());
|
||||||
HiResImage image = (HiResImage) currentDataSource;
|
}
|
||||||
image.setColourQuirks (value);
|
}
|
||||||
imagePanel.setImage (image.getImage ());
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public Palette cyclePalette (CycleDirection direction)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setMonochrome (boolean value)
|
{
|
||||||
{
|
Palette palette = HiResImage.getPaletteFactory ().cyclePalette (direction);
|
||||||
if (currentDataSource instanceof HiResImage)
|
if (currentDataSource instanceof HiResImage)
|
||||||
{
|
{
|
||||||
HiResImage image = (HiResImage) currentDataSource;
|
HiResImage image = (HiResImage) currentDataSource;
|
||||||
image.setMonochrome (value);
|
image.setPalette ();
|
||||||
imagePanel.setImage (image.getImage ());
|
imagePanel.setImage (image.getImage ());
|
||||||
}
|
}
|
||||||
}
|
return palette;
|
||||||
|
}
|
||||||
public void setDebug (boolean value)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
debugMode = value;
|
void setLineWrap (boolean lineWrap)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
if (currentDataSource instanceof VisicalcFile)
|
{
|
||||||
{
|
formattedText.setLineWrap (lineWrap);
|
||||||
VisicalcFile visicalcFile = (VisicalcFile) currentDataSource;
|
}
|
||||||
VisicalcFile.setDebug (value);
|
|
||||||
setText (formattedText, visicalcFile.getText ());
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public void setColourQuirks (boolean value)
|
||||||
// should implement an interface for this
|
// ---------------------------------------------------------------------------------//
|
||||||
else if (currentDataSource instanceof HiResImage
|
{
|
||||||
|| currentDataSource instanceof QuickDrawFont)
|
if (currentDataSource instanceof HiResImage)
|
||||||
{
|
{
|
||||||
setDataSource (currentDataSource); // toggles text/image
|
HiResImage image = (HiResImage) currentDataSource;
|
||||||
}
|
image.setColourQuirks (value);
|
||||||
}
|
imagePanel.setImage (image.getImage ());
|
||||||
|
}
|
||||||
private void setTabsFont (Font font)
|
}
|
||||||
{
|
|
||||||
formattedText.setFont (font);
|
// ---------------------------------------------------------------------------------//
|
||||||
hexText.setFont (font);
|
public void setMonochrome (boolean value)
|
||||||
disassemblyText.setFont (font);
|
// ---------------------------------------------------------------------------------//
|
||||||
imagePane.getVerticalScrollBar ().setUnitIncrement (font.getSize ());
|
{
|
||||||
}
|
if (currentDataSource instanceof HiResImage)
|
||||||
|
{
|
||||||
public String getCurrentText ()
|
HiResImage image = (HiResImage) currentDataSource;
|
||||||
{
|
image.setMonochrome (value);
|
||||||
int index = getSelectedIndex ();
|
imagePanel.setImage (image.getImage ());
|
||||||
return index == 0 ? formattedText.getText ()
|
}
|
||||||
: index == 1 ? hexText.getText () : disassemblyText.getText ();
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private JScrollPane setPanel (JTextArea outputPanel, String tabName)
|
public void setDebug (boolean value)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
outputPanel.setEditable (false);
|
{
|
||||||
outputPanel.setMargin (new Insets (5, 5, 5, 5));
|
debugMode = value;
|
||||||
|
|
||||||
JScrollPane outputScrollPane =
|
if (currentDataSource instanceof VisicalcFile)
|
||||||
new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
{
|
||||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
VisicalcFile visicalcFile = (VisicalcFile) currentDataSource;
|
||||||
outputScrollPane.setBorder (null); // remove the ugly default border
|
VisicalcFile.setDebug (value);
|
||||||
add (outputScrollPane, tabName);
|
setText (formattedText, visicalcFile.getText ());
|
||||||
return outputScrollPane;
|
}
|
||||||
}
|
// should implement an interface for this
|
||||||
|
else if (currentDataSource instanceof HiResImage
|
||||||
private void setDataSource (DataSource dataSource)
|
|| currentDataSource instanceof QuickDrawFont)
|
||||||
{
|
{
|
||||||
currentDataSource = dataSource;
|
setDataSource (currentDataSource); // toggles text/image
|
||||||
|
}
|
||||||
if (dataSource == null)
|
}
|
||||||
{
|
|
||||||
formattedText.setText ("");
|
// ---------------------------------------------------------------------------------//
|
||||||
hexText.setText ("");
|
private void setTabsFont (Font font)
|
||||||
disassemblyText.setText ("");
|
// ---------------------------------------------------------------------------------//
|
||||||
removeImage ();
|
{
|
||||||
return;
|
formattedText.setFont (font);
|
||||||
}
|
hexText.setFont (font);
|
||||||
|
disassemblyText.setFont (font);
|
||||||
switch (getSelectedIndex ())
|
imagePane.getVerticalScrollBar ().setUnitIncrement (font.getSize ());
|
||||||
{
|
}
|
||||||
case 0: // Formatted/Image
|
|
||||||
try
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public String getCurrentText ()
|
||||||
setText (formattedText, dataSource.getText ());
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
catch (Exception e)
|
int index = getSelectedIndex ();
|
||||||
{
|
return index == 0 ? formattedText.getText () : index == 1 ? hexText.getText ()
|
||||||
setText (formattedText, e.toString ());
|
: disassemblyText.getText ();
|
||||||
e.printStackTrace ();
|
}
|
||||||
}
|
|
||||||
hexTextValid = false;
|
// ---------------------------------------------------------------------------------//
|
||||||
assemblerTextValid = false;
|
private JScrollPane setPanel (JTextArea outputPanel, String tabName)
|
||||||
break;
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
case 1: // Hex Dump
|
outputPanel.setEditable (false);
|
||||||
setText (hexText, dataSource.getHexDump ());
|
outputPanel.setMargin (new Insets (5, 5, 5, 5));
|
||||||
formattedTextValid = false;
|
|
||||||
assemblerTextValid = false;
|
JScrollPane outputScrollPane =
|
||||||
break;
|
new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
|
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
case 2: // Disassembly
|
outputScrollPane.setBorder (null); // remove the ugly default border
|
||||||
setText (disassemblyText, dataSource.getAssembler ());
|
add (outputScrollPane, tabName);
|
||||||
hexTextValid = false;
|
return outputScrollPane;
|
||||||
formattedTextValid = false;
|
}
|
||||||
break;
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
default:
|
private void setDataSource (DataSource dataSource)
|
||||||
System.out.println ("Invalid index selected in DataPanel");
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
currentDataSource = dataSource;
|
||||||
BufferedImage image = dataSource.getImage ();
|
|
||||||
if (image == null || debugMode)
|
if (dataSource == null)
|
||||||
removeImage ();
|
{
|
||||||
else
|
formattedText.setText ("");
|
||||||
{
|
hexText.setText ("");
|
||||||
if (dataSource instanceof HiResImage)
|
disassemblyText.setText ("");
|
||||||
{
|
removeImage ();
|
||||||
((HiResImage) dataSource).checkPalette ();
|
return;
|
||||||
image = dataSource.getImage ();
|
}
|
||||||
}
|
|
||||||
imagePanel.setImage (image);
|
switch (getSelectedIndex ())
|
||||||
imagePane.setViewportView (imagePanel);
|
{
|
||||||
|
case 0: // Formatted/Image
|
||||||
if (!imageVisible)
|
try
|
||||||
{
|
{
|
||||||
int selected = getSelectedIndex ();
|
setText (formattedText, dataSource.getText ());
|
||||||
remove (formattedPane);
|
}
|
||||||
add (imagePane, "Formatted", 0);
|
catch (Exception e)
|
||||||
setSelectedIndex (selected);
|
{
|
||||||
imageVisible = true;
|
setText (formattedText, e.toString ());
|
||||||
}
|
e.printStackTrace ();
|
||||||
}
|
}
|
||||||
}
|
hexTextValid = false;
|
||||||
|
assemblerTextValid = false;
|
||||||
private void removeImage ()
|
break;
|
||||||
{
|
|
||||||
if (imageVisible)
|
case 1: // Hex Dump
|
||||||
{
|
setText (hexText, dataSource.getHexDump ());
|
||||||
int selected = getSelectedIndex ();
|
formattedTextValid = false;
|
||||||
remove (imagePane);
|
assemblerTextValid = false;
|
||||||
add (formattedPane, "Formatted", 0);
|
break;
|
||||||
setSelectedIndex (selected);
|
|
||||||
imageVisible = false;
|
case 2: // Disassembly
|
||||||
}
|
setText (disassemblyText, dataSource.getAssembler ());
|
||||||
}
|
hexTextValid = false;
|
||||||
|
formattedTextValid = false;
|
||||||
private void setText (JTextArea textArea, String text)
|
break;
|
||||||
{
|
|
||||||
textArea.setText (text);
|
default:
|
||||||
textArea.setCaretPosition (0);
|
System.out.println ("Invalid index selected in DataPanel");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ImagePanel extends JPanel
|
BufferedImage image = dataSource.getImage ();
|
||||||
{
|
if (image == null || debugMode)
|
||||||
private BufferedImage image;
|
removeImage ();
|
||||||
private int scale = 1;
|
else
|
||||||
|
{
|
||||||
public ImagePanel ()
|
if (dataSource instanceof HiResImage)
|
||||||
{
|
{
|
||||||
this.setBackground (new Color (BACKGROUND, BACKGROUND, BACKGROUND));
|
((HiResImage) dataSource).checkPalette ();
|
||||||
}
|
image = dataSource.getImage ();
|
||||||
|
}
|
||||||
private void setImage (BufferedImage image)
|
imagePanel.setImage (image);
|
||||||
{
|
imagePane.setViewportView (imagePanel);
|
||||||
this.image = image;
|
|
||||||
int width, height;
|
if (!imageVisible)
|
||||||
|
{
|
||||||
if (image != null)
|
int selected = getSelectedIndex ();
|
||||||
{
|
remove (formattedPane);
|
||||||
Graphics2D g2 = image.createGraphics ();
|
add (imagePane, "Formatted", 0);
|
||||||
g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING,
|
setSelectedIndex (selected);
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
imageVisible = true;
|
||||||
width = image.getWidth ();
|
}
|
||||||
height = image.getHeight ();
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
width = height = 0;
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private void removeImage ()
|
||||||
if (true)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (width < 400 && width > 0)
|
if (imageVisible)
|
||||||
scale = (400 - 1) / width + 1;
|
{
|
||||||
else
|
int selected = getSelectedIndex ();
|
||||||
scale = 1;
|
remove (imagePane);
|
||||||
if (scale > 4)
|
add (formattedPane, "Formatted", 0);
|
||||||
scale = 4;
|
setSelectedIndex (selected);
|
||||||
}
|
imageVisible = false;
|
||||||
|
}
|
||||||
setPreferredSize (new Dimension (width * scale, height * scale));
|
}
|
||||||
repaint ();
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private void setText (JTextArea textArea, String text)
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public void paintComponent (Graphics g)
|
{
|
||||||
{
|
textArea.setText (text);
|
||||||
super.paintComponent (g);
|
textArea.setCaretPosition (0);
|
||||||
|
}
|
||||||
if (image != null)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
Graphics2D g2 = ((Graphics2D) g);
|
private class ImagePanel extends JPanel
|
||||||
g2.transform (AffineTransform.getScaleInstance (scale, scale));
|
// ---------------------------------------------------------------------------------//
|
||||||
g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4,
|
{
|
||||||
this);
|
private BufferedImage image;
|
||||||
}
|
private int scale = 1;
|
||||||
}
|
|
||||||
}
|
public ImagePanel ()
|
||||||
|
{
|
||||||
@Override
|
this.setBackground (new Color (BACKGROUND, BACKGROUND, BACKGROUND));
|
||||||
public void diskSelected (DiskSelectedEvent event)
|
}
|
||||||
{
|
|
||||||
setSelectedIndex (0);
|
private void setImage (BufferedImage image)
|
||||||
setDataSource (null);
|
{
|
||||||
if (event.getFormattedDisk () != null)
|
this.image = image;
|
||||||
setDataSource (event.getFormattedDisk ().getCatalog ().getDataSource ());
|
int width, height;
|
||||||
else
|
|
||||||
System.out.println ("bollocks in diskSelected()");
|
if (image != null)
|
||||||
}
|
{
|
||||||
|
Graphics2D g2 = image.createGraphics ();
|
||||||
@Override
|
g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING,
|
||||||
public void fileSelected (FileSelectedEvent event)
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
{
|
width = image.getWidth ();
|
||||||
DataSource dataSource = event.appleFileSource.getDataSource ();
|
height = image.getHeight ();
|
||||||
setDataSource (dataSource);
|
}
|
||||||
}
|
else
|
||||||
|
width = height = 0;
|
||||||
@Override
|
|
||||||
public void sectorSelected (SectorSelectedEvent event)
|
if (true)
|
||||||
{
|
{
|
||||||
List<DiskAddress> sectors = event.getSectors ();
|
if (width < 400 && width > 0)
|
||||||
if (sectors == null || sectors.size () == 0)
|
scale = (400 - 1) / width + 1;
|
||||||
return;
|
else
|
||||||
|
scale = 1;
|
||||||
if (sectors.size () == 1)
|
if (scale > 4)
|
||||||
{
|
scale = 4;
|
||||||
DiskAddress da = sectors.get (0);
|
}
|
||||||
if (da != null)
|
|
||||||
setDataSource (event.getFormattedDisk ().getFormattedSector (da));
|
setPreferredSize (new Dimension (width * scale, height * scale));
|
||||||
}
|
repaint ();
|
||||||
else
|
}
|
||||||
setDataSource (new SectorList (event.getFormattedDisk (), sectors));
|
|
||||||
}
|
@Override
|
||||||
|
public void paintComponent (Graphics g)
|
||||||
@Override
|
{
|
||||||
public void fileNodeSelected (FileNodeSelectedEvent event)
|
super.paintComponent (g);
|
||||||
{
|
|
||||||
setSelectedIndex (0);
|
if (image != null)
|
||||||
setDataSource (event.getFileNode ());
|
{
|
||||||
// FileNode node = event.getFileNode ();
|
Graphics2D g2 = ((Graphics2D) g);
|
||||||
}
|
g2.transform (AffineTransform.getScaleInstance (scale, scale));
|
||||||
|
g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4,
|
||||||
@Override
|
this);
|
||||||
public void changeFont (FontChangeEvent fontChangeEvent)
|
}
|
||||||
{
|
}
|
||||||
setTabsFont (fontChangeEvent.font);
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setBasicPreferences (BasicPreferences basicPreferences)
|
public void diskSelected (DiskSelectedEvent event)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
if (currentDataSource instanceof ApplesoftBasicProgram)
|
{
|
||||||
setDataSource (currentDataSource);
|
setSelectedIndex (0);
|
||||||
}
|
setDataSource (null);
|
||||||
|
if (event.getFormattedDisk () != null)
|
||||||
@Override
|
setDataSource (event.getFormattedDisk ().getCatalog ().getDataSource ());
|
||||||
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
|
else
|
||||||
{
|
System.out.println ("bollocks in diskSelected()");
|
||||||
if (currentDataSource instanceof AssemblerProgram)
|
}
|
||||||
setDataSource (currentDataSource);
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void fileSelected (FileSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
DataSource dataSource = event.appleFileSource.getDataSource ();
|
||||||
|
setDataSource (dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void sectorSelected (SectorSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
List<DiskAddress> sectors = event.getSectors ();
|
||||||
|
if (sectors == null || sectors.size () == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sectors.size () == 1)
|
||||||
|
{
|
||||||
|
DiskAddress da = sectors.get (0);
|
||||||
|
if (da != null)
|
||||||
|
setDataSource (event.getFormattedDisk ().getFormattedSector (da));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setDataSource (new SectorList (event.getFormattedDisk (), sectors));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void fileNodeSelected (FileNodeSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
setSelectedIndex (0);
|
||||||
|
setDataSource (event.getFileNode ());
|
||||||
|
// FileNode node = event.getFileNode ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void changeFont (FontChangeEvent fontChangeEvent)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
setTabsFont (fontChangeEvent.font);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void setBasicPreferences (BasicPreferences basicPreferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (currentDataSource instanceof ApplesoftBasicProgram)
|
||||||
|
setDataSource (currentDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (currentDataSource instanceof AssemblerProgram)
|
||||||
|
setDataSource (currentDataSource);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,18 +1,20 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
public interface DataSource
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
public interface DataSource
|
||||||
public String getText ();
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public String getAssembler ();
|
public String getText ();
|
||||||
|
|
||||||
public String getHexDump ();
|
public String getAssembler ();
|
||||||
|
|
||||||
public BufferedImage getImage ();
|
public String getHexDump ();
|
||||||
|
|
||||||
public JComponent getComponent ();
|
public BufferedImage getImage ();
|
||||||
|
|
||||||
|
public JComponent getComponent ();
|
||||||
}
|
}
|
|
@ -7,11 +7,15 @@ import javax.swing.Action;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DebuggingAction extends AbstractAction
|
public class DebuggingAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DebuggingAction (DataPanel owner)
|
public DebuggingAction (DataPanel owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Debugging");
|
super ("Debugging");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Show debugging information");
|
putValue (Action.SHORT_DESCRIPTION, "Show debugging information");
|
||||||
|
@ -19,8 +23,10 @@ public class DebuggingAction extends AbstractAction
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.setDebug (((JMenuItem) e.getSource ()).isSelected ());
|
owner.setDebug (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,138 +1,156 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.event.EventListenerList;
|
import javax.swing.event.EventListenerList;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode;
|
import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode;
|
||||||
|
|
||||||
class DiskAndFileSelector
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class DiskAndFileSelector
|
||||||
EventListenerList listenerList = new EventListenerList ();
|
// -----------------------------------------------------------------------------------//
|
||||||
FormattedDisk currentDisk;
|
{
|
||||||
boolean redo;
|
EventListenerList listenerList = new EventListenerList ();
|
||||||
|
FormattedDisk currentDisk;
|
||||||
/*
|
boolean redo;
|
||||||
* Apple DiskSelection routines
|
|
||||||
*/
|
/*
|
||||||
public void addDiskSelectionListener (DiskSelectionListener listener)
|
* Apple DiskSelection routines
|
||||||
{
|
*/
|
||||||
listenerList.add (DiskSelectionListener.class, listener);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public void addDiskSelectionListener (DiskSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void removeDiskSelectionListener (DiskSelectionListener listener)
|
{
|
||||||
{
|
listenerList.add (DiskSelectionListener.class, listener);
|
||||||
listenerList.remove (DiskSelectionListener.class, listener);
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addFileNodeSelectionListener (FileNodeSelectionListener listener)
|
public void removeDiskSelectionListener (DiskSelectionListener listener)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
listenerList.add (FileNodeSelectionListener.class, listener);
|
{
|
||||||
}
|
listenerList.remove (DiskSelectionListener.class, listener);
|
||||||
|
}
|
||||||
public void removeFileNodeSelectionListener (FileNodeSelectionListener listener)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
listenerList.remove (FileNodeSelectionListener.class, listener);
|
public void addFileNodeSelectionListener (FileNodeSelectionListener listener)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
// public void fireDiskSelectionEvent (File file)
|
listenerList.add (FileNodeSelectionListener.class, listener);
|
||||||
// {
|
}
|
||||||
// if (file.isDirectory ())
|
|
||||||
// {
|
// ---------------------------------------------------------------------------------//
|
||||||
// System.out.println ("Directory received : " + file.getAbsolutePath ());
|
public void removeFileNodeSelectionListener (FileNodeSelectionListener listener)
|
||||||
// return;
|
// ---------------------------------------------------------------------------------//
|
||||||
// }
|
{
|
||||||
//
|
listenerList.remove (FileNodeSelectionListener.class, listener);
|
||||||
// if (currentDisk != null) // will this screw up the refresh command?
|
}
|
||||||
// {
|
|
||||||
// System.out.println (currentDisk.getDisk ().getFile ().getAbsolutePath ());
|
// public void fireDiskSelectionEvent (File file)
|
||||||
// System.out.println (file.getAbsolutePath ());
|
// {
|
||||||
// }
|
// if (file.isDirectory ())
|
||||||
// if (currentDisk != null
|
// {
|
||||||
// && currentDisk.getDisk ().getFile ().getAbsolutePath ().equals (file.getAbsolutePath ()))
|
// System.out.println ("Directory received : " + file.getAbsolutePath ());
|
||||||
// fireDiskSelectionEvent (currentDisk);
|
// return;
|
||||||
// else
|
// }
|
||||||
// {
|
//
|
||||||
// System.out.println (" creating disk from a file");
|
// if (currentDisk != null) // will this screw up the refresh command?
|
||||||
// fireDiskSelectionEvent (DiskFactory.createDisk (file.getAbsolutePath ()));
|
// {
|
||||||
// }
|
// System.out.println (currentDisk.getDisk ().getFile ().getAbsolutePath ());
|
||||||
// }
|
// System.out.println (file.getAbsolutePath ());
|
||||||
|
// }
|
||||||
void fireDiskSelectionEvent (FileNode node)
|
// if (currentDisk != null
|
||||||
{
|
// && currentDisk.getDisk ().getFile ().getAbsolutePath ().equals (file.getAbsolutePath ()))
|
||||||
if (node.file.isDirectory ())
|
// fireDiskSelectionEvent (currentDisk);
|
||||||
{
|
// else
|
||||||
fireFileNodeSelectionEvent (node);
|
// {
|
||||||
currentDisk = null;
|
// System.out.println (" creating disk from a file");
|
||||||
}
|
// fireDiskSelectionEvent (DiskFactory.createDisk (file.getAbsolutePath ()));
|
||||||
else
|
// }
|
||||||
{
|
// }
|
||||||
FormattedDisk fd = node.getFormattedDisk ();
|
|
||||||
if (fd == null)
|
// ---------------------------------------------------------------------------------//
|
||||||
JOptionPane.showMessageDialog (null, "Unrecognised file format", "Format error",
|
void fireDiskSelectionEvent (FileNode node)
|
||||||
JOptionPane.ERROR_MESSAGE);
|
// ---------------------------------------------------------------------------------//
|
||||||
else
|
{
|
||||||
fireDiskSelectionEvent (fd);
|
if (node.file.isDirectory ())
|
||||||
}
|
{
|
||||||
}
|
fireFileNodeSelectionEvent (node);
|
||||||
|
currentDisk = null;
|
||||||
void fireFileNodeSelectionEvent (FileNode node)
|
}
|
||||||
{
|
else
|
||||||
FileNodeSelectedEvent e = new FileNodeSelectedEvent (this, node);
|
{
|
||||||
e.redo = redo;
|
FormattedDisk fd = node.getFormattedDisk ();
|
||||||
FileNodeSelectionListener[] listeners =
|
if (fd == null)
|
||||||
(listenerList.getListeners (FileNodeSelectionListener.class));
|
JOptionPane.showMessageDialog (null, "Unrecognised file format", "Format error",
|
||||||
for (FileNodeSelectionListener listener : listeners)
|
JOptionPane.ERROR_MESSAGE);
|
||||||
listener.fileNodeSelected (e);
|
else
|
||||||
}
|
fireDiskSelectionEvent (fd);
|
||||||
|
}
|
||||||
void fireDiskSelectionEvent (FormattedDisk disk)
|
}
|
||||||
{
|
|
||||||
if (disk == currentDisk)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
void fireFileNodeSelectionEvent (FileNode node)
|
||||||
// System.out.println ("Disk event duplicated");
|
// ---------------------------------------------------------------------------------//
|
||||||
return;
|
{
|
||||||
}
|
FileNodeSelectedEvent e = new FileNodeSelectedEvent (this, node);
|
||||||
|
e.redo = redo;
|
||||||
if (disk == null)
|
FileNodeSelectionListener[] listeners =
|
||||||
{
|
(listenerList.getListeners (FileNodeSelectionListener.class));
|
||||||
System.out.println ("Null disk in fireDiskSelectionEvent()");
|
for (FileNodeSelectionListener listener : listeners)
|
||||||
return;
|
listener.fileNodeSelected (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskSelectedEvent e = new DiskSelectedEvent (this, disk);
|
// ---------------------------------------------------------------------------------//
|
||||||
e.redo = redo;
|
void fireDiskSelectionEvent (FormattedDisk disk)
|
||||||
DiskSelectionListener[] listeners =
|
// ---------------------------------------------------------------------------------//
|
||||||
(listenerList.getListeners (DiskSelectionListener.class));
|
{
|
||||||
for (DiskSelectionListener listener : listeners)
|
if (disk == currentDisk)
|
||||||
listener.diskSelected (e);
|
{
|
||||||
currentDisk = disk;
|
// System.out.println ("Disk event duplicated");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
/*
|
|
||||||
* Apple FileSelection routines
|
if (disk == null)
|
||||||
*/
|
{
|
||||||
|
System.out.println ("Null disk in fireDiskSelectionEvent()");
|
||||||
public void addFileSelectionListener (FileSelectionListener listener)
|
return;
|
||||||
{
|
}
|
||||||
listenerList.add (FileSelectionListener.class, listener);
|
|
||||||
}
|
DiskSelectedEvent e = new DiskSelectedEvent (this, disk);
|
||||||
|
e.redo = redo;
|
||||||
public void removeFileSelectionListener (FileSelectionListener listener)
|
DiskSelectionListener[] listeners =
|
||||||
{
|
(listenerList.getListeners (DiskSelectionListener.class));
|
||||||
listenerList.remove (FileSelectionListener.class, listener);
|
for (DiskSelectionListener listener : listeners)
|
||||||
}
|
listener.diskSelected (e);
|
||||||
|
currentDisk = disk;
|
||||||
void fireFileSelectionEvent (AppleFileSource file)
|
}
|
||||||
{
|
|
||||||
assert file != null;
|
// ---------------------------------------------------------------------------------//
|
||||||
currentDisk = null;
|
public void addFileSelectionListener (FileSelectionListener listener)
|
||||||
FileSelectedEvent e = new FileSelectedEvent (this, file);
|
// ---------------------------------------------------------------------------------//
|
||||||
e.redo = redo;
|
{
|
||||||
FileSelectionListener[] listeners =
|
listenerList.add (FileSelectionListener.class, listener);
|
||||||
(listenerList.getListeners (FileSelectionListener.class));
|
}
|
||||||
for (FileSelectionListener listener : listeners)
|
|
||||||
listener.fileSelected (e);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public void removeFileSelectionListener (FileSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
listenerList.remove (FileSelectionListener.class, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void fireFileSelectionEvent (AppleFileSource file)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
assert file != null;
|
||||||
|
currentDisk = null;
|
||||||
|
FileSelectedEvent e = new FileSelectedEvent (this, file);
|
||||||
|
e.redo = redo;
|
||||||
|
FileSelectionListener[] listeners =
|
||||||
|
(listenerList.getListeners (FileSelectionListener.class));
|
||||||
|
for (FileSelectionListener listener : listeners)
|
||||||
|
listener.fileSelected (e);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,12 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
@ -19,7 +25,9 @@ import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
|
private static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
|
||||||
private static final Color[] lightColors =
|
private static final Color[] lightColors =
|
||||||
|
@ -33,7 +41,9 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
private int gridWidth = 8;
|
private int gridWidth = 8;
|
||||||
private int gridHeight = 35;
|
private int gridHeight = 35;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DiskLayoutImage ()
|
public DiskLayoutImage ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
setPreferredSize (new Dimension (240 + 1, 525 + 1));
|
setPreferredSize (new Dimension (240 + 1, 525 + 1));
|
||||||
addMouseListener (new MyMouseListener ());
|
addMouseListener (new MyMouseListener ());
|
||||||
|
@ -45,8 +55,10 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
addKeyListener (new MyKeyListener ());
|
addKeyListener (new MyKeyListener ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super.setDisk (disk, details);
|
super.setDisk (disk, details);
|
||||||
|
|
||||||
|
@ -60,12 +72,16 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public FormattedDisk getDisk ()
|
public FormattedDisk getDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return formattedDisk;
|
return formattedDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setShowFreeSectors (boolean showFree)
|
public void setShowFreeSectors (boolean showFree)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (showFree != showFreeSectors)
|
if (showFree != showFreeSectors)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +90,9 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void setSelection (List<DiskAddress> sectors)
|
void setSelection (List<DiskAddress> sectors)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
selectionHandler.setSelection (sectors);
|
selectionHandler.setSelection (sectors);
|
||||||
if (sectors != null && sectors.size () > 0)
|
if (sectors != null && sectors.size () > 0)
|
||||||
|
@ -86,8 +104,10 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent (Graphics g)
|
protected void paintComponent (Graphics g)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super.paintComponent (g);
|
super.paintComponent (g);
|
||||||
|
|
||||||
|
@ -130,8 +150,10 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void drawBlock (Graphics2D g, SectorType type, int x, int y, boolean flagFree,
|
private void drawBlock (Graphics2D g, SectorType type, int x, int y, boolean flagFree,
|
||||||
boolean selected)
|
boolean selected)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
g.setColor (type.colour);
|
g.setColor (type.colour);
|
||||||
g.fillRect (x + 1, y + 1, blockWidth - 1, blockHeight - 1);
|
g.fillRect (x + 1, y + 1, blockWidth - 1, blockHeight - 1);
|
||||||
|
@ -148,7 +170,9 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private Color getContrastColor (SectorType type)
|
private Color getContrastColor (SectorType type)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (Color color : lightColors)
|
for (Color color : lightColors)
|
||||||
if (type.colour == color)
|
if (type.colour == color)
|
||||||
|
@ -156,40 +180,52 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
return Color.WHITE;
|
return Color.WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredScrollableViewportSize ()
|
public Dimension getPreferredScrollableViewportSize ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new Dimension (240 + 1, 525 + 1); // floppy disk size
|
return new Dimension (240 + 1, 525 + 1); // floppy disk size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation,
|
public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation,
|
||||||
int direction)
|
int direction)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return orientation == SwingConstants.HORIZONTAL ? blockWidth : blockHeight;
|
return orientation == SwingConstants.HORIZONTAL ? blockWidth : blockHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getScrollableBlockIncrement (Rectangle visibleRect, int orientation,
|
public int getScrollableBlockIncrement (Rectangle visibleRect, int orientation,
|
||||||
int direction)
|
int direction)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return orientation == SwingConstants.HORIZONTAL ? blockWidth * 4 : blockHeight * 10;
|
return orientation == SwingConstants.HORIZONTAL ? blockWidth * 4 : blockHeight * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean getScrollableTracksViewportHeight ()
|
public boolean getScrollableTracksViewportHeight ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean getScrollableTracksViewportWidth ()
|
public boolean getScrollableTracksViewportWidth ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void redo (RedoEvent redoEvent)
|
public void redo (RedoEvent redoEvent)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
redo = true;
|
redo = true;
|
||||||
SectorSelectedEvent event = (SectorSelectedEvent) redoEvent.value;
|
SectorSelectedEvent event = (SectorSelectedEvent) redoEvent.value;
|
||||||
|
@ -200,14 +236,18 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
requestFocusInWindow ();
|
requestFocusInWindow ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void fireSectorSelectionEvent ()
|
private void fireSectorSelectionEvent ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
SectorSelectedEvent event =
|
SectorSelectedEvent event =
|
||||||
new SectorSelectedEvent (this, selectionHandler.getHighlights (), formattedDisk);
|
new SectorSelectedEvent (this, selectionHandler.getHighlights (), formattedDisk);
|
||||||
fireSectorSelectionEvent (event);
|
fireSectorSelectionEvent (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void fireSectorSelectionEvent (SectorSelectedEvent event)
|
private void fireSectorSelectionEvent (SectorSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
event.redo = redo;
|
event.redo = redo;
|
||||||
SectorSelectionListener[] listeners =
|
SectorSelectionListener[] listeners =
|
||||||
|
@ -216,17 +256,23 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
listener.sectorSelected (event);
|
listener.sectorSelected (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addSectorSelectionListener (SectorSelectionListener listener)
|
public void addSectorSelectionListener (SectorSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
listenerList.add (SectorSelectionListener.class, listener);
|
listenerList.add (SectorSelectionListener.class, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void removeSectorSelectionListener (SectorSelectionListener listener)
|
public void removeSectorSelectionListener (SectorSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
listenerList.remove (SectorSelectionListener.class, listener);
|
listenerList.remove (SectorSelectionListener.class, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class MyKeyListener extends KeyAdapter
|
class MyKeyListener extends KeyAdapter
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed (KeyEvent e)
|
public void keyPressed (KeyEvent e)
|
||||||
|
@ -244,7 +290,9 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class MyMouseListener extends MouseAdapter
|
class MyMouseListener extends MouseAdapter
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private Cursor currentCursor;
|
private Cursor currentCursor;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,10 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class DiskLayoutPanel extends JPanel
|
class DiskLayoutPanel extends JPanel
|
||||||
implements DiskSelectionListener, FileSelectionListener, RedoListener
|
implements DiskSelectionListener, FileSelectionListener, RedoListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final int SIZE = 15; // basic unit of a display block
|
private static final int SIZE = 15; // basic unit of a display block
|
||||||
|
|
||||||
|
@ -36,7 +38,9 @@ class DiskLayoutPanel extends JPanel
|
||||||
private final JScrollPane sp;
|
private final JScrollPane sp;
|
||||||
private LayoutDetails layout;
|
private LayoutDetails layout;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DiskLayoutPanel ()
|
public DiskLayoutPanel ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (new BorderLayout ());
|
super (new BorderLayout ());
|
||||||
|
|
||||||
|
@ -63,7 +67,9 @@ class DiskLayoutPanel extends JPanel
|
||||||
add (legendPanel, BorderLayout.SOUTH);
|
add (legendPanel, BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setDisk (final FormattedDisk disk)
|
public void setDisk (final FormattedDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
layout = new LayoutDetails (disk);
|
layout = new LayoutDetails (disk);
|
||||||
diskLayoutImage.setDisk (disk, layout);
|
diskLayoutImage.setDisk (disk, layout);
|
||||||
|
@ -105,41 +111,55 @@ class DiskLayoutPanel extends JPanel
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setHex (boolean hex)
|
public void setHex (boolean hex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
verticalRuler.setHex (hex);
|
verticalRuler.setHex (hex);
|
||||||
horizontalRuler.setHex (hex);
|
horizontalRuler.setHex (hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setBlock (boolean block)
|
public void setBlock (boolean block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
verticalRuler.setTrackMode (block);
|
verticalRuler.setTrackMode (block);
|
||||||
horizontalRuler.setTrackMode (block);
|
horizontalRuler.setTrackMode (block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setFree (boolean free)
|
public void setFree (boolean free)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
diskLayoutImage.setShowFreeSectors (free);
|
diskLayoutImage.setShowFreeSectors (free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addSectorSelectionListener (SectorSelectionListener listener)
|
public void addSectorSelectionListener (SectorSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
diskLayoutImage.addSectorSelectionListener (listener);
|
diskLayoutImage.addSectorSelectionListener (listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void removeSectorSelectionListener (SectorSelectionListener listener)
|
public void removeSectorSelectionListener (SectorSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
diskLayoutImage.removeSectorSelectionListener (listener);
|
diskLayoutImage.removeSectorSelectionListener (listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void diskSelected (DiskSelectedEvent event)
|
public void diskSelected (DiskSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
setDisk (event.getFormattedDisk ());
|
setDisk (event.getFormattedDisk ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void fileSelected (FileSelectedEvent event)
|
public void fileSelected (FileSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// This can happen if a file is selected from a dual-dos disk
|
// This can happen if a file is selected from a dual-dos disk
|
||||||
checkCorrectDisk (event.appleFileSource.getFormattedDisk ());
|
checkCorrectDisk (event.appleFileSource.getFormattedDisk ());
|
||||||
|
@ -147,7 +167,9 @@ class DiskLayoutPanel extends JPanel
|
||||||
diskLayoutImage.setSelection (event.appleFileSource.getSectors ());
|
diskLayoutImage.setSelection (event.appleFileSource.getSectors ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class LayoutDetails
|
class LayoutDetails
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Dimension block;
|
Dimension block;
|
||||||
Dimension grid;
|
Dimension grid;
|
||||||
|
@ -178,7 +200,9 @@ class DiskLayoutPanel extends JPanel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class Corner extends JComponent
|
class Corner extends JComponent
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Color backgroundColor = Color.WHITE;
|
Color backgroundColor = Color.WHITE;
|
||||||
boolean showHex = true;
|
boolean showHex = true;
|
||||||
|
|
|
@ -1,201 +1,223 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
|
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
|
|
||||||
class DiskLayoutSelection implements Iterable<DiskAddress>
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class DiskLayoutSelection implements Iterable<DiskAddress>
|
||||||
private final List<DiskAddress> highlights;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public DiskLayoutSelection ()
|
private final List<DiskAddress> highlights;
|
||||||
{
|
|
||||||
highlights = new ArrayList<> ();
|
public DiskLayoutSelection ()
|
||||||
}
|
{
|
||||||
|
highlights = new ArrayList<> ();
|
||||||
public void doClick (Disk disk, DiskAddress da, boolean extend, boolean append)
|
}
|
||||||
{
|
|
||||||
/*
|
// ---------------------------------------------------------------------------------//
|
||||||
* Single click without modifiers - just replace previous highlights with the new
|
public void doClick (Disk disk, DiskAddress da, boolean extend, boolean append)
|
||||||
* sector. If there are no current highlights then even modifiers have the same
|
// ---------------------------------------------------------------------------------//
|
||||||
* effect.
|
{
|
||||||
*/
|
/*
|
||||||
if ((!extend && !append) || highlights.size () == 0)
|
* Single click without modifiers - just replace previous highlights with the new
|
||||||
{
|
* sector. If there are no current highlights then even modifiers have the same
|
||||||
highlights.clear ();
|
* effect.
|
||||||
addHighlight (da);
|
*/
|
||||||
return;
|
if ((!extend && !append) || highlights.size () == 0)
|
||||||
}
|
{
|
||||||
|
highlights.clear ();
|
||||||
/*
|
addHighlight (da);
|
||||||
* If the click was on an existing highlight, just remove it (regardless of modifiers)
|
return;
|
||||||
*/
|
}
|
||||||
for (DiskAddress setDA : highlights)
|
|
||||||
if (da.matches (setDA))
|
/*
|
||||||
{
|
* If the click was on an existing highlight, just remove it (regardless of modifiers)
|
||||||
highlights.remove (setDA);
|
*/
|
||||||
return;
|
for (DiskAddress setDA : highlights)
|
||||||
}
|
if (da.matches (setDA))
|
||||||
|
{
|
||||||
/*
|
highlights.remove (setDA);
|
||||||
* Appending - just add the sector to the existing highlights
|
return;
|
||||||
*/
|
}
|
||||||
if (append)
|
|
||||||
{
|
/*
|
||||||
addHighlight (da);
|
* Appending - just add the sector to the existing highlights
|
||||||
Collections.sort (highlights);
|
*/
|
||||||
return;
|
if (append)
|
||||||
}
|
{
|
||||||
|
addHighlight (da);
|
||||||
/*
|
Collections.sort (highlights);
|
||||||
* Extending - if the existing selection is contiguous then just extend it. If not
|
return;
|
||||||
* then things get a bit trickier.
|
}
|
||||||
*/
|
|
||||||
if (checkContiguous ())
|
/*
|
||||||
extendHighlights (disk, da);
|
* Extending - if the existing selection is contiguous then just extend it. If not
|
||||||
else
|
* then things get a bit trickier.
|
||||||
adjustHighlights (disk, da);
|
*/
|
||||||
|
if (checkContiguous ())
|
||||||
Collections.sort (highlights);
|
extendHighlights (disk, da);
|
||||||
}
|
else
|
||||||
|
adjustHighlights (disk, da);
|
||||||
void cursorMove (FormattedDisk formattedDisk, KeyEvent e)
|
|
||||||
{
|
Collections.sort (highlights);
|
||||||
if (highlights.size () == 0)
|
}
|
||||||
{
|
|
||||||
System.out.println ("Nothing to move");
|
// ---------------------------------------------------------------------------------//
|
||||||
return;
|
void cursorMove (FormattedDisk formattedDisk, KeyEvent e)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
Disk disk = formattedDisk.getDisk ();
|
if (highlights.size () == 0)
|
||||||
|
{
|
||||||
DiskAddress first = highlights.get (0);
|
System.out.println ("Nothing to move");
|
||||||
DiskAddress last = highlights.get (highlights.size () - 1);
|
return;
|
||||||
|
}
|
||||||
if (!e.isShiftDown ())
|
|
||||||
highlights.clear ();
|
Disk disk = formattedDisk.getDisk ();
|
||||||
|
|
||||||
int totalBlocks = disk.getTotalBlocks ();
|
DiskAddress first = highlights.get (0);
|
||||||
// int rowSize = disk.getTrackSize () / disk.getBlockSize ();
|
DiskAddress last = highlights.get (highlights.size () - 1);
|
||||||
Dimension gridLayout = formattedDisk.getGridLayout ();
|
|
||||||
int rowSize = gridLayout.width;
|
if (!e.isShiftDown ())
|
||||||
|
highlights.clear ();
|
||||||
switch (e.getKeyCode ())
|
|
||||||
{
|
int totalBlocks = disk.getTotalBlocks ();
|
||||||
case KeyEvent.VK_LEFT:
|
// int rowSize = disk.getTrackSize () / disk.getBlockSize ();
|
||||||
int block = first.getBlock () - 1;
|
Dimension gridLayout = formattedDisk.getGridLayout ();
|
||||||
if (block < 0)
|
int rowSize = gridLayout.width;
|
||||||
block = totalBlocks - 1;
|
|
||||||
addHighlight (disk.getDiskAddress (block));
|
switch (e.getKeyCode ())
|
||||||
break;
|
{
|
||||||
|
case KeyEvent.VK_LEFT:
|
||||||
case KeyEvent.VK_RIGHT:
|
int block = first.getBlock () - 1;
|
||||||
block = last.getBlock () + 1;
|
if (block < 0)
|
||||||
if (block >= totalBlocks)
|
block = totalBlocks - 1;
|
||||||
block = 0;
|
addHighlight (disk.getDiskAddress (block));
|
||||||
addHighlight (disk.getDiskAddress (block));
|
break;
|
||||||
break;
|
|
||||||
|
case KeyEvent.VK_RIGHT:
|
||||||
case KeyEvent.VK_UP:
|
block = last.getBlock () + 1;
|
||||||
block = first.getBlock () - rowSize;
|
if (block >= totalBlocks)
|
||||||
if (block < 0)
|
block = 0;
|
||||||
block += totalBlocks;
|
addHighlight (disk.getDiskAddress (block));
|
||||||
addHighlight (disk.getDiskAddress (block));
|
break;
|
||||||
break;
|
|
||||||
|
case KeyEvent.VK_UP:
|
||||||
case KeyEvent.VK_DOWN:
|
block = first.getBlock () - rowSize;
|
||||||
block = last.getBlock () + rowSize;
|
if (block < 0)
|
||||||
if (block >= totalBlocks)
|
block += totalBlocks;
|
||||||
block -= totalBlocks;
|
addHighlight (disk.getDiskAddress (block));
|
||||||
addHighlight (disk.getDiskAddress (block));
|
break;
|
||||||
break;
|
|
||||||
}
|
case KeyEvent.VK_DOWN:
|
||||||
Collections.sort (highlights);
|
block = last.getBlock () + rowSize;
|
||||||
}
|
if (block >= totalBlocks)
|
||||||
|
block -= totalBlocks;
|
||||||
private void addHighlight (DiskAddress da)
|
addHighlight (disk.getDiskAddress (block));
|
||||||
{
|
break;
|
||||||
assert da != null;
|
}
|
||||||
highlights.add (da);
|
Collections.sort (highlights);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public Iterator<DiskAddress> iterator ()
|
private void addHighlight (DiskAddress da)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
return highlights.iterator ();
|
{
|
||||||
}
|
assert da != null;
|
||||||
|
highlights.add (da);
|
||||||
// This must return a copy, or the redo function will get very confused
|
}
|
||||||
public List<DiskAddress> getHighlights ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
return new ArrayList<> (highlights);
|
@Override
|
||||||
}
|
public Iterator<DiskAddress> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean isSelected (DiskAddress da)
|
{
|
||||||
{
|
return highlights.iterator ();
|
||||||
for (DiskAddress selection : highlights)
|
}
|
||||||
if (selection != null && da.matches (selection))
|
|
||||||
return true;
|
// This must return a copy, or the redo function will get very confused
|
||||||
return false;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public List<DiskAddress> getHighlights ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setSelection (List<DiskAddress> list)
|
{
|
||||||
{
|
return new ArrayList<> (highlights);
|
||||||
// sparse files contain empty blocks
|
}
|
||||||
highlights.clear ();
|
|
||||||
if (list != null)
|
// ---------------------------------------------------------------------------------//
|
||||||
for (DiskAddress da : list)
|
public boolean isSelected (DiskAddress da)
|
||||||
if (da != null && (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
|
// ---------------------------------------------------------------------------------//
|
||||||
highlights.add (da);
|
{
|
||||||
}
|
for (DiskAddress selection : highlights)
|
||||||
|
if (selection != null && da.matches (selection))
|
||||||
private boolean checkContiguous ()
|
return true;
|
||||||
{
|
return false;
|
||||||
int range = highlights.get (highlights.size () - 1).getBlock ()
|
}
|
||||||
- highlights.get (0).getBlock () + 1;
|
|
||||||
return (range == highlights.size ());
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public void setSelection (List<DiskAddress> list)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void extendHighlights (Disk disk, DiskAddress da)
|
{
|
||||||
{
|
// sparse files contain empty blocks
|
||||||
int lo, hi;
|
highlights.clear ();
|
||||||
|
if (list != null)
|
||||||
// Are we extending in front of the current block?
|
for (DiskAddress da : list)
|
||||||
if (highlights.get (0).getBlock () > da.getBlock ())
|
if (da != null && (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
|
||||||
{
|
highlights.add (da);
|
||||||
lo = da.getBlock ();
|
}
|
||||||
hi = highlights.get (0).getBlock () - 1;
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
else
|
private boolean checkContiguous ()
|
||||||
// No, must be extending at the end
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
lo = highlights.get (highlights.size () - 1).getBlock () + 1;
|
int range = highlights.get (highlights.size () - 1).getBlock ()
|
||||||
hi = da.getBlock ();
|
- highlights.get (0).getBlock () + 1;
|
||||||
}
|
return (range == highlights.size ());
|
||||||
|
}
|
||||||
for (int i = lo; i <= hi; i++)
|
|
||||||
addHighlight (disk.getDiskAddress (i));
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
private void extendHighlights (Disk disk, DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void adjustHighlights (Disk disk, DiskAddress da)
|
{
|
||||||
{
|
int lo, hi;
|
||||||
// If we are outside the discontiguous range, just extend as usual
|
|
||||||
if (da.getBlock () < highlights.get (0).getBlock ()
|
// Are we extending in front of the current block?
|
||||||
|| da.getBlock () > highlights.get (highlights.size () - 1).getBlock ())
|
if (highlights.get (0).getBlock () > da.getBlock ())
|
||||||
{
|
{
|
||||||
extendHighlights (disk, da);
|
lo = da.getBlock ();
|
||||||
return;
|
hi = highlights.get (0).getBlock () - 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// just treat it like a ctrl-click (hack!!)
|
// No, must be extending at the end
|
||||||
addHighlight (da);
|
{
|
||||||
}
|
lo = highlights.get (highlights.size () - 1).getBlock () + 1;
|
||||||
|
hi = da.getBlock ();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = lo; i <= hi; i++)
|
||||||
|
addHighlight (disk.getDiskAddress (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private void adjustHighlights (Disk disk, DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
// If we are outside the discontiguous range, just extend as usual
|
||||||
|
if (da.getBlock () < highlights.get (0).getBlock ()
|
||||||
|
|| da.getBlock () > highlights.get (highlights.size () - 1).getBlock ())
|
||||||
|
{
|
||||||
|
extendHighlights (disk, da);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// just treat it like a ctrl-click (hack!!)
|
||||||
|
addHighlight (da);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user