mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
tidying
This commit is contained in:
parent
1b27ea02e7
commit
ae1188ae27
@ -174,10 +174,7 @@ class CatalogPanel extends JTabbedPane
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Tab tab = (Tab) getSelectedComponent ();
|
||||
if (diskTabs.size () > 1 && tab instanceof AppleDiskTab)
|
||||
closeTabAction.setEnabled (true);
|
||||
else
|
||||
closeTabAction.setEnabled (false);
|
||||
closeTabAction.setEnabled (diskTabs.size () > 1 && tab instanceof AppleDiskTab);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -37,6 +37,7 @@ import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
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.FontChangeListener;
|
||||
|
||||
@ -44,7 +45,7 @@ import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
|
||||
public class DataPanel extends JTabbedPane
|
||||
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
||||
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
|
||||
AssemblerPreferencesListener, TextPreferencesListener
|
||||
AssemblerPreferencesListener, TextPreferencesListener, DebugListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int TEXT_WIDTH = 65;
|
||||
@ -158,7 +159,10 @@ public class DataPanel extends JTabbedPane
|
||||
|
||||
menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (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
|
||||
List<Palette> palettes = HiResImage.getPalettes ();
|
||||
@ -256,6 +260,7 @@ public class DataPanel extends JTabbedPane
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void setDebug (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -11,16 +13,15 @@ import javax.swing.KeyStroke;
|
||||
public class DebuggingAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
List<DebugListener> listeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DebuggingAction (DataPanel owner)
|
||||
public DebuggingAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Debugging");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Show debugging information");
|
||||
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)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -124,8 +124,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
|
||||
// set the MenuItem Actions
|
||||
menuHandler.printItem.setAction (print);
|
||||
// menuHandler.addHelpMenuAction (preferencesAction, "prefs");
|
||||
// menuHandler.addHelpMenuAction (aboutAction, "about");
|
||||
menuHandler.refreshTreeItem.setAction (refreshTreeAction);
|
||||
menuHandler.rootItem.setAction (rootDirectoryAction);
|
||||
menuHandler.showCatalogItem.setAction (hideCatalogAction);
|
||||
@ -153,9 +151,9 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
e -> JOptionPane.showMessageDialog (null, "Preferences dialog"));
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER))
|
||||
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ());
|
||||
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ()); // needed for cmd-Q
|
||||
// else
|
||||
setQuitHandler ();
|
||||
setQuitHandler (); // needed for the close button
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -199,7 +197,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
fireQuitEvent ();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -157,6 +157,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
|
||||
for (DiskAddress selection : highlights)
|
||||
if (selection != null && da.matches (selection))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ package com.bytezone.diskbrowser.gui;
|
||||
import java.util.EventObject;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.HybridDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.disk.HybridDisk;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class FileSelectedEvent extends EventObject
|
||||
@ -21,8 +21,8 @@ class FileSelectedEvent extends EventObject
|
||||
super (source);
|
||||
this.appleFileSource = appleFileSource;
|
||||
|
||||
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
|
||||
// must be told so that it can ensure its internal currentDisk is set correctly
|
||||
// If a file is selected from a disk which is part of a hybrid disk, then the
|
||||
// parent must be told so that it can ensure its internal currentDisk is set correctly
|
||||
FormattedDisk fd = appleFileSource.getFormattedDisk ();
|
||||
HybridDisk ddd = (HybridDisk) fd.getParent ();
|
||||
if (ddd != null)
|
||||
|
@ -47,6 +47,7 @@ public class FontFrame extends JFrame
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Font Selection");
|
||||
|
||||
this.fontAction = fontAction;
|
||||
buildLayout ();
|
||||
getFonts ();
|
||||
@ -96,8 +97,7 @@ public class FontFrame extends JFrame
|
||||
public String getSelectedValue ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String fontName = fontList.getSelectedValue ();
|
||||
return fontName;
|
||||
return fontList.getSelectedValue ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -112,8 +112,7 @@ public class FontFrame extends JFrame
|
||||
public String getSelectedSize ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String fontSize = fontSizePanel.getSelectedText ();
|
||||
return fontSize;
|
||||
return fontSizePanel.getSelectedText ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -146,7 +145,6 @@ public class FontFrame extends JFrame
|
||||
|
||||
int ptr = 0;
|
||||
for (String fontName : fonts)
|
||||
{
|
||||
while (ptr < pf.length)
|
||||
{
|
||||
int result = fontName.compareToIgnoreCase (pf[ptr]);
|
||||
@ -159,7 +157,6 @@ public class FontFrame extends JFrame
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fontList.setSelectedValue (initialFont, true);
|
||||
}
|
||||
@ -254,13 +251,14 @@ public class FontFrame extends JFrame
|
||||
private Font getCurrentFont ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String fontName = getSelectedValue ();
|
||||
String fontSize = getSelectedSize ();
|
||||
if (fontSize.isEmpty ())
|
||||
return null;
|
||||
|
||||
int pos = fontSize.indexOf (' ');
|
||||
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 ();
|
||||
initialSize = getSelectedSize ();
|
||||
|
||||
int pos = initialSize.indexOf (' ');
|
||||
int size = Integer.parseInt (initialSize.substring (0, pos));
|
||||
|
||||
Font font = new Font (initialFont, Font.PLAIN, size);
|
||||
fontAction.fireFontChangeEvent (font);
|
||||
}
|
||||
|
@ -347,6 +347,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
showAllFormatItem.addActionListener (basicPreferencesAction);
|
||||
showAllXrefItem.addActionListener (basicPreferencesAction);
|
||||
appleLineWrapItem.addActionListener (basicPreferencesAction);
|
||||
|
||||
for (JMenuItem item : applesoftFormatItems)
|
||||
item.addActionListener (basicPreferencesAction);
|
||||
for (JMenuItem item : applesoftXrefItems)
|
||||
@ -374,10 +375,12 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
|
||||
sectorGroup.add (sector256Item);
|
||||
sectorGroup.add (sector512Item);
|
||||
|
||||
interleaveGroup.add (interleave0Item);
|
||||
interleaveGroup.add (interleave1Item);
|
||||
interleaveGroup.add (interleave2Item);
|
||||
interleaveGroup.add (interleave3Item);
|
||||
|
||||
scaleGroup.add (scale1Item);
|
||||
scaleGroup.add (scale2Item);
|
||||
scaleGroup.add (scale3Item);
|
||||
@ -546,6 +549,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
openSupported = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!openSupported)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user