mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-03 13:31:44 +00:00
Added Prodos preferences menu
This commit is contained in:
parent
1c53b291dd
commit
a2f6839aac
@ -55,7 +55,7 @@ class CatalogPanel extends JTabbedPane
|
||||
private CloseTabAction closeTabAction;
|
||||
private final RootFolderData rootFolderData = new RootFolderData ();
|
||||
|
||||
public CatalogPanel (MenuHandler mh, RedoHandler redoHandler, Preferences prefs)
|
||||
public CatalogPanel (RedoHandler redoHandler, Preferences prefs)
|
||||
{
|
||||
this.redoHandler = redoHandler;
|
||||
|
||||
|
@ -34,7 +34,8 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
}
|
||||
|
||||
JToolBar toolBar = new JToolBar ("Toolbar", JToolBar.HORIZONTAL);
|
||||
MenuHandler menuHandler = new MenuHandler ();
|
||||
MenuHandler menuHandler = new MenuHandler (prefs);
|
||||
// menuHandler.restore (prefs); // early !!
|
||||
|
||||
setJMenuBar (menuHandler.menuBar);
|
||||
setLayout (new BorderLayout ());
|
||||
@ -45,7 +46,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
toolBar.addSeparator ();
|
||||
|
||||
// create and add the left-hand catalog panel
|
||||
CatalogPanel catalogPanel = new CatalogPanel (menuHandler, redoHandler, prefs);
|
||||
CatalogPanel catalogPanel = new CatalogPanel (redoHandler, prefs);
|
||||
JPanel catalogBorderPanel = addPanel (catalogPanel, "Catalog", BorderLayout.WEST);
|
||||
|
||||
// create and add the centre output panel
|
||||
|
@ -15,6 +15,7 @@ import com.bytezone.common.FontAction;
|
||||
import com.bytezone.diskbrowser.applefile.*;
|
||||
import com.bytezone.diskbrowser.disk.DataDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.prodos.ProdosDisk;
|
||||
|
||||
public class MenuHandler
|
||||
implements DiskSelectionListener, FileSelectionListener, QuitListener
|
||||
@ -37,6 +38,8 @@ public class MenuHandler
|
||||
private static final String PREFS_SHOW_ASSEMBLER_STRINGS = "showAssemblerStrings";
|
||||
private static final String PREFS_SHOW_ASSEMBLER_HEADER = "showAssemblerHeader";
|
||||
|
||||
private static final String PREFS_PRODOS_SORT_DIRECTORIES = "prodosSortDirectories";
|
||||
|
||||
// private static final String PREFS_DEBUGGING = "debugging";
|
||||
private static final String PREFS_PALETTE = "palette";
|
||||
|
||||
@ -51,12 +54,17 @@ public class MenuHandler
|
||||
private final List<AssemblerPreferencesListener> assemblerPreferencesListeners =
|
||||
new ArrayList<> ();
|
||||
|
||||
private final ProdosPreferences prodosPreferences = new ProdosPreferences ();
|
||||
private final List<ProdosPreferencesListener> prodosPreferencesListeners =
|
||||
new ArrayList<> ();
|
||||
|
||||
JMenuBar menuBar = new JMenuBar ();
|
||||
JMenu fileMenu = new JMenu ("File");
|
||||
JMenu formatMenu = new JMenu ("Format");
|
||||
JMenu colourMenu = new JMenu ("Colours");
|
||||
JMenu applesoftMenu = new JMenu ("Applesoft");
|
||||
JMenu assemblerMenu = new JMenu ("Assembler");
|
||||
JMenu prodosMenu = new JMenu ("Prodos");
|
||||
JMenu helpMenu = new JMenu ("Help");
|
||||
|
||||
// File menu items
|
||||
@ -102,15 +110,19 @@ public class MenuHandler
|
||||
final JMenuItem showAssemblerStringsItem = new JCheckBoxMenuItem ("Show strings");
|
||||
final JMenuItem showAssemblerHeaderItem = new JCheckBoxMenuItem ("Show header");
|
||||
|
||||
// Prodos menu items
|
||||
final JMenuItem prodosSortDirectoriesItem = new JCheckBoxMenuItem ("Sort directories");
|
||||
|
||||
ButtonGroup paletteGroup = new ButtonGroup ();
|
||||
|
||||
public MenuHandler ()
|
||||
public MenuHandler (Preferences prefs)
|
||||
{
|
||||
menuBar.add (fileMenu);
|
||||
menuBar.add (formatMenu);
|
||||
menuBar.add (colourMenu);
|
||||
menuBar.add (applesoftMenu);
|
||||
menuBar.add (assemblerMenu);
|
||||
menuBar.add (prodosMenu);
|
||||
menuBar.add (helpMenu);
|
||||
|
||||
fileMenu.add (rootItem);
|
||||
@ -178,6 +190,8 @@ public class MenuHandler
|
||||
assemblerMenu.add (showAssemblerStringsItem);
|
||||
assemblerMenu.add (showAssemblerHeaderItem);
|
||||
|
||||
prodosMenu.add (prodosSortDirectoriesItem);
|
||||
|
||||
ActionListener basicPreferencesAction = new ActionListener ()
|
||||
{
|
||||
@Override
|
||||
@ -198,6 +212,16 @@ public class MenuHandler
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener prodosPreferencesAction = new ActionListener ()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
setProdosPreferences ();
|
||||
notifyProdosPreferencesListeners ();
|
||||
}
|
||||
};
|
||||
|
||||
splitRemarkItem.addActionListener (basicPreferencesAction);
|
||||
alignAssignItem.addActionListener (basicPreferencesAction);
|
||||
showBasicTargetsItem.addActionListener (basicPreferencesAction);
|
||||
@ -209,6 +233,8 @@ public class MenuHandler
|
||||
showAssemblerStringsItem.addActionListener (assemblerPreferencesAction);
|
||||
showAssemblerHeaderItem.addActionListener (assemblerPreferencesAction);
|
||||
|
||||
prodosSortDirectoriesItem.addActionListener (prodosPreferencesAction);
|
||||
|
||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
|
||||
sector256Item.setActionCommand ("256");
|
||||
@ -227,6 +253,15 @@ public class MenuHandler
|
||||
interleaveGroup.add (interleave3Item);
|
||||
|
||||
saveDiskItem.setAction (saveTempFileAction);
|
||||
|
||||
// this is done early because the CatalogPanel creates the previous disk used
|
||||
// before restore() is called
|
||||
prodosSortDirectoriesItem
|
||||
.setSelected (prefs.getBoolean (PREFS_PRODOS_SORT_DIRECTORIES, true));
|
||||
|
||||
setBasicPreferences ();
|
||||
setAssemblerPreferences ();
|
||||
setProdosPreferences ();
|
||||
}
|
||||
|
||||
private void setBasicPreferences ()
|
||||
@ -278,6 +313,27 @@ public class MenuHandler
|
||||
listener.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
|
||||
private void setProdosPreferences ()
|
||||
{
|
||||
prodosPreferences.sortDirectories = prodosSortDirectoriesItem.isSelected ();
|
||||
ProdosDisk.setProdosPreferences (prodosPreferences);
|
||||
}
|
||||
|
||||
void addProdosPreferencesListener (ProdosPreferencesListener listener)
|
||||
{
|
||||
if (!prodosPreferencesListeners.contains (listener))
|
||||
{
|
||||
prodosPreferencesListeners.add (listener);
|
||||
listener.setProdosPreferences (prodosPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
void notifyProdosPreferencesListeners ()
|
||||
{
|
||||
for (ProdosPreferencesListener listener : prodosPreferencesListeners)
|
||||
listener.setProdosPreferences (prodosPreferences);
|
||||
}
|
||||
|
||||
void addHelpMenuAction (Action action, String functionName)
|
||||
{
|
||||
helpMenu.add (new JMenuItem (action));
|
||||
@ -329,6 +385,9 @@ public class MenuHandler
|
||||
prefs.putBoolean (PREFS_SHOW_ASSEMBLER_STRINGS,
|
||||
showAssemblerStringsItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_ASSEMBLER_HEADER, showAssemblerHeaderItem.isSelected ());
|
||||
|
||||
prefs.putBoolean (PREFS_PRODOS_SORT_DIRECTORIES,
|
||||
prodosSortDirectoriesItem.isSelected ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -358,8 +417,12 @@ public class MenuHandler
|
||||
showAssemblerHeaderItem
|
||||
.setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_HEADER, true));
|
||||
|
||||
setBasicPreferences ();
|
||||
setAssemblerPreferences ();
|
||||
// prodosSortDirectoriesItem
|
||||
// .setSelected (prefs.getBoolean (PREFS_PRODOS_SORT_DIRECTORIES, true));
|
||||
|
||||
// setBasicPreferences ();
|
||||
// setAssemblerPreferences ();
|
||||
// setProdosPreferences ();
|
||||
|
||||
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
|
||||
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();
|
||||
|
16
src/com/bytezone/diskbrowser/gui/ProdosPreferences.java
Normal file
16
src/com/bytezone/diskbrowser/gui/ProdosPreferences.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
public class ProdosPreferences
|
||||
{
|
||||
public boolean sortDirectories;
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Sort directies ........ %s%n", sortDirectories));
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
public interface ProdosPreferencesListener
|
||||
{
|
||||
public void setProdosPreferences (ProdosPreferences prodosPreferences);
|
||||
}
|
@ -13,10 +13,13 @@ import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
import com.bytezone.diskbrowser.applefile.BootSector;
|
||||
import com.bytezone.diskbrowser.disk.*;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.gui.ProdosPreferences;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class ProdosDisk extends AbstractFormattedDisk
|
||||
{
|
||||
static ProdosPreferences prodosPreferences; // set by MenuHandler
|
||||
|
||||
protected final DateFormat df = DateFormat.getInstance ();
|
||||
protected final SimpleDateFormat sdf = new SimpleDateFormat ("d-MMM-yy");
|
||||
protected final SimpleDateFormat stf = new SimpleDateFormat ("H:mm");
|
||||
@ -36,6 +39,11 @@ public class ProdosDisk extends AbstractFormattedDisk
|
||||
|
||||
private static final boolean debug = false;
|
||||
|
||||
public static void setProdosPreferences (ProdosPreferences prodosPreferences)
|
||||
{
|
||||
ProdosDisk.prodosPreferences = prodosPreferences;
|
||||
}
|
||||
|
||||
public ProdosDisk (Disk disk)
|
||||
{
|
||||
super (disk);
|
||||
@ -76,8 +84,11 @@ public class ProdosDisk extends AbstractFormattedDisk
|
||||
falseNegatives++;
|
||||
}
|
||||
|
||||
sort (volumeNode);
|
||||
((DefaultTreeModel) catalogTree.getModel ()).reload ();
|
||||
if (ProdosDisk.prodosPreferences.sortDirectories)
|
||||
{
|
||||
sort (volumeNode);
|
||||
((DefaultTreeModel) catalogTree.getModel ()).reload ();
|
||||
}
|
||||
}
|
||||
|
||||
public void sort (DefaultMutableTreeNode node)
|
||||
|
Loading…
Reference in New Issue
Block a user