This commit is contained in:
Denis Molony 2021-06-01 20:21:21 +10:00
parent 1b27ea02e7
commit ae1188ae27
8 changed files with 47 additions and 26 deletions

View File

@ -174,10 +174,7 @@ class CatalogPanel extends JTabbedPane
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
Tab tab = (Tab) getSelectedComponent (); Tab tab = (Tab) getSelectedComponent ();
if (diskTabs.size () > 1 && tab instanceof AppleDiskTab) closeTabAction.setEnabled (diskTabs.size () > 1 && tab instanceof AppleDiskTab);
closeTabAction.setEnabled (true);
else
closeTabAction.setEnabled (false);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -37,6 +37,7 @@ import com.bytezone.diskbrowser.applefile.QuickDrawFont;
import com.bytezone.diskbrowser.applefile.SHRPictureFile2; import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
import com.bytezone.diskbrowser.disk.DiskAddress; import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.SectorList; import com.bytezone.diskbrowser.disk.SectorList;
import com.bytezone.diskbrowser.gui.DebuggingAction.DebugListener;
import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent; import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent;
import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener; import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
@ -44,7 +45,7 @@ import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
public class DataPanel extends JTabbedPane public class DataPanel extends JTabbedPane
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener, implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener, FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
AssemblerPreferencesListener, TextPreferencesListener AssemblerPreferencesListener, TextPreferencesListener, DebugListener
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private static final int TEXT_WIDTH = 65; private static final int TEXT_WIDTH = 65;
@ -158,7 +159,10 @@ public class DataPanel extends JTabbedPane
menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this)); menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this));
menuHandler.monochromeItem.setAction (new MonochromeAction (this)); menuHandler.monochromeItem.setAction (new MonochromeAction (this));
menuHandler.debuggingItem.setAction (new DebuggingAction (this));
DebuggingAction debuggingAction = new DebuggingAction ();
debuggingAction.addDebugListener (this);
menuHandler.debuggingItem.setAction (debuggingAction);
// fill in the placeholders created by the MenuHandler // fill in the placeholders created by the MenuHandler
List<Palette> palettes = HiResImage.getPalettes (); List<Palette> palettes = HiResImage.getPalettes ();
@ -256,6 +260,7 @@ public class DataPanel extends JTabbedPane
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override
public void setDebug (boolean value) public void setDebug (boolean value)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {

View File

@ -1,6 +1,8 @@
package com.bytezone.diskbrowser.gui; package com.bytezone.diskbrowser.gui;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
@ -11,16 +13,15 @@ import javax.swing.KeyStroke;
public class DebuggingAction extends AbstractAction public class DebuggingAction extends AbstractAction
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private final DataPanel owner; List<DebugListener> listeners = new ArrayList<> ();
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public DebuggingAction (DataPanel owner) public DebuggingAction ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
super ("Debugging"); super ("Debugging");
putValue (Action.SHORT_DESCRIPTION, "Show debugging information"); putValue (Action.SHORT_DESCRIPTION, "Show debugging information");
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("meta D")); putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("meta D"));
this.owner = owner;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -28,6 +29,22 @@ public class DebuggingAction extends AbstractAction
public void actionPerformed (ActionEvent e) public void actionPerformed (ActionEvent e)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
owner.setDebug (((JMenuItem) e.getSource ()).isSelected ()); for (DebugListener listener : listeners)
listener.setDebug (((JMenuItem) e.getSource ()).isSelected ());
}
// ---------------------------------------------------------------------------------//
public void addDebugListener (DebugListener listener)
// ---------------------------------------------------------------------------------//
{
if (!listeners.contains (listener))
listeners.add (listener);
}
// ---------------------------------------------------------------------------------//
public interface DebugListener
// ---------------------------------------------------------------------------------//
{
public void setDebug (boolean value);
} }
} }

View File

@ -124,8 +124,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
// set the MenuItem Actions // set the MenuItem Actions
menuHandler.printItem.setAction (print); menuHandler.printItem.setAction (print);
// menuHandler.addHelpMenuAction (preferencesAction, "prefs");
// menuHandler.addHelpMenuAction (aboutAction, "about");
menuHandler.refreshTreeItem.setAction (refreshTreeAction); menuHandler.refreshTreeItem.setAction (refreshTreeAction);
menuHandler.rootItem.setAction (rootDirectoryAction); menuHandler.rootItem.setAction (rootDirectoryAction);
menuHandler.showCatalogItem.setAction (hideCatalogAction); menuHandler.showCatalogItem.setAction (hideCatalogAction);
@ -153,9 +151,9 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
e -> JOptionPane.showMessageDialog (null, "Preferences dialog")); e -> JOptionPane.showMessageDialog (null, "Preferences dialog"));
if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER)) if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER))
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ()); desktop.setQuitHandler ( (e, r) -> fireQuitEvent ()); // needed for cmd-Q
// else // else
setQuitHandler (); setQuitHandler (); // needed for the close button
} }
else else
{ {
@ -199,7 +197,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
fireQuitEvent (); fireQuitEvent ();
} }
}); });
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -157,6 +157,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
for (DiskAddress selection : highlights) for (DiskAddress selection : highlights)
if (selection != null && da.matches (selection)) if (selection != null && da.matches (selection))
return true; return true;
return false; return false;
} }

View File

@ -3,8 +3,8 @@ package com.bytezone.diskbrowser.gui;
import java.util.EventObject; import java.util.EventObject;
import com.bytezone.diskbrowser.applefile.AppleFileSource; import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.disk.HybridDisk;
import com.bytezone.diskbrowser.disk.FormattedDisk; import com.bytezone.diskbrowser.disk.FormattedDisk;
import com.bytezone.diskbrowser.disk.HybridDisk;
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
class FileSelectedEvent extends EventObject class FileSelectedEvent extends EventObject
@ -21,8 +21,8 @@ class FileSelectedEvent extends EventObject
super (source); super (source);
this.appleFileSource = appleFileSource; this.appleFileSource = appleFileSource;
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS // If a file is selected from a disk which is part of a hybrid disk, then the
// must be told so that it can ensure its internal currentDisk is set correctly // parent must be told so that it can ensure its internal currentDisk is set correctly
FormattedDisk fd = appleFileSource.getFormattedDisk (); FormattedDisk fd = appleFileSource.getFormattedDisk ();
HybridDisk ddd = (HybridDisk) fd.getParent (); HybridDisk ddd = (HybridDisk) fd.getParent ();
if (ddd != null) if (ddd != null)

View File

@ -47,6 +47,7 @@ public class FontFrame extends JFrame
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
super ("Font Selection"); super ("Font Selection");
this.fontAction = fontAction; this.fontAction = fontAction;
buildLayout (); buildLayout ();
getFonts (); getFonts ();
@ -96,8 +97,7 @@ public class FontFrame extends JFrame
public String getSelectedValue () public String getSelectedValue ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
String fontName = fontList.getSelectedValue (); return fontList.getSelectedValue ();
return fontName;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -112,8 +112,7 @@ public class FontFrame extends JFrame
public String getSelectedSize () public String getSelectedSize ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
String fontSize = fontSizePanel.getSelectedText (); return fontSizePanel.getSelectedText ();
return fontSize;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -146,7 +145,6 @@ public class FontFrame extends JFrame
int ptr = 0; int ptr = 0;
for (String fontName : fonts) for (String fontName : fonts)
{
while (ptr < pf.length) while (ptr < pf.length)
{ {
int result = fontName.compareToIgnoreCase (pf[ptr]); int result = fontName.compareToIgnoreCase (pf[ptr]);
@ -159,7 +157,6 @@ public class FontFrame extends JFrame
} }
break; break;
} }
}
fontList.setSelectedValue (initialFont, true); fontList.setSelectedValue (initialFont, true);
} }
@ -254,13 +251,14 @@ public class FontFrame extends JFrame
private Font getCurrentFont () private Font getCurrentFont ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
String fontName = getSelectedValue ();
String fontSize = getSelectedSize (); String fontSize = getSelectedSize ();
if (fontSize.isEmpty ()) if (fontSize.isEmpty ())
return null; return null;
int pos = fontSize.indexOf (' '); int pos = fontSize.indexOf (' ');
int size = Integer.parseInt (fontSize.substring (0, pos)); int size = Integer.parseInt (fontSize.substring (0, pos));
return new Font (fontName, Font.PLAIN, size);
return new Font (getSelectedValue (), Font.PLAIN, size);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -269,8 +267,10 @@ public class FontFrame extends JFrame
{ {
initialFont = getSelectedValue (); initialFont = getSelectedValue ();
initialSize = getSelectedSize (); initialSize = getSelectedSize ();
int pos = initialSize.indexOf (' '); int pos = initialSize.indexOf (' ');
int size = Integer.parseInt (initialSize.substring (0, pos)); int size = Integer.parseInt (initialSize.substring (0, pos));
Font font = new Font (initialFont, Font.PLAIN, size); Font font = new Font (initialFont, Font.PLAIN, size);
fontAction.fireFontChangeEvent (font); fontAction.fireFontChangeEvent (font);
} }

View File

@ -347,6 +347,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
showAllFormatItem.addActionListener (basicPreferencesAction); showAllFormatItem.addActionListener (basicPreferencesAction);
showAllXrefItem.addActionListener (basicPreferencesAction); showAllXrefItem.addActionListener (basicPreferencesAction);
appleLineWrapItem.addActionListener (basicPreferencesAction); appleLineWrapItem.addActionListener (basicPreferencesAction);
for (JMenuItem item : applesoftFormatItems) for (JMenuItem item : applesoftFormatItems)
item.addActionListener (basicPreferencesAction); item.addActionListener (basicPreferencesAction);
for (JMenuItem item : applesoftXrefItems) for (JMenuItem item : applesoftXrefItems)
@ -374,10 +375,12 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
sectorGroup.add (sector256Item); sectorGroup.add (sector256Item);
sectorGroup.add (sector512Item); sectorGroup.add (sector512Item);
interleaveGroup.add (interleave0Item); interleaveGroup.add (interleave0Item);
interleaveGroup.add (interleave1Item); interleaveGroup.add (interleave1Item);
interleaveGroup.add (interleave2Item); interleaveGroup.add (interleave2Item);
interleaveGroup.add (interleave3Item); interleaveGroup.add (interleave3Item);
scaleGroup.add (scale1Item); scaleGroup.add (scale1Item);
scaleGroup.add (scale2Item); scaleGroup.add (scale2Item);
scaleGroup.add (scale3Item); scaleGroup.add (scale3Item);
@ -546,6 +549,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
openSupported = true; openSupported = true;
break; break;
} }
if (!openSupported) if (!openSupported)
return; return;