mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-25 06:28:56 +00:00
restored help menu
This commit is contained in:
parent
ebeea4706d
commit
fe1f038087
src/com/bytezone/diskbrowser/gui
@ -9,6 +9,7 @@ import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.common.DefaultAction;
|
||||
|
||||
// this is not being used
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class AboutAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
@ -37,27 +38,7 @@ class AboutAction extends DefaultAction
|
||||
public void about ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// int build = 0;
|
||||
// String buildDate = "<no date>";
|
||||
// Properties props = new Properties ();
|
||||
// InputStream in = this.getClass ().getResourceAsStream ("build.properties");
|
||||
// if (in != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// props.load (in);
|
||||
// in.close ();
|
||||
// build = Integer.parseInt (props.getProperty ("build.number"));
|
||||
// buildDate = props.getProperty ("build.date");
|
||||
// }
|
||||
// catch (IOException e1)
|
||||
// {
|
||||
// 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,297 +1,310 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.bytezone.diskbrowser.duplicates.RootFolderData;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] args;
|
||||
private static final String windowTitle = "Apple ][ Disk Browser";
|
||||
private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
|
||||
private WindowSaver windowSaver;
|
||||
|
||||
private static final String OS = System.getProperty ("os.name").toLowerCase ();
|
||||
private static final boolean MAC = OS.startsWith ("mac os");
|
||||
|
||||
private final RootFolderData rootFolderData = new RootFolderData ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DiskBrowser ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (windowTitle);
|
||||
|
||||
if (args.length > 0 && "-reset".equals (args[0]))
|
||||
new WindowState (prefs).clear ();
|
||||
|
||||
JToolBar toolBar = new JToolBar ("Toolbar", JToolBar.HORIZONTAL);
|
||||
MenuHandler menuHandler = new MenuHandler ();
|
||||
|
||||
setJMenuBar (menuHandler.menuBar);
|
||||
setLayout (new BorderLayout ());
|
||||
add (toolBar, BorderLayout.NORTH);
|
||||
|
||||
// add navigation buttons
|
||||
RedoHandler redoHandler = new RedoHandler (getRootPane (), toolBar);
|
||||
toolBar.addSeparator ();
|
||||
|
||||
// create and add the left-hand catalog panel
|
||||
CatalogPanel catalogPanel = new CatalogPanel (redoHandler);
|
||||
JPanel catalogBorderPanel = addPanel (catalogPanel, "Catalog", BorderLayout.WEST);
|
||||
|
||||
// create and add the centre output panel
|
||||
DataPanel dataPanel = new DataPanel (menuHandler);
|
||||
addPanel (dataPanel, "Output", BorderLayout.CENTER);
|
||||
|
||||
// create and add the right-hand disk layout panel
|
||||
DiskLayoutPanel diskLayoutPanel = new DiskLayoutPanel ();
|
||||
JPanel layoutBorderPanel =
|
||||
addPanel (diskLayoutPanel, "Disk layout", BorderLayout.EAST);
|
||||
|
||||
// create actions
|
||||
DuplicateAction duplicateAction = new DuplicateAction (rootFolderData);
|
||||
RootDirectoryAction rootDirectoryAction = new RootDirectoryAction ();
|
||||
|
||||
RefreshTreeAction refreshTreeAction = new RefreshTreeAction (catalogPanel);
|
||||
// PreferencesAction preferencesAction = new PreferencesAction (this, prefs);
|
||||
AbstractAction print = new PrintAction (dataPanel);
|
||||
// AboutAction aboutAction = new AboutAction ();
|
||||
HideCatalogAction hideCatalogAction =
|
||||
new HideCatalogAction (this, catalogBorderPanel);
|
||||
HideLayoutAction hideLayoutAction = new HideLayoutAction (this, layoutBorderPanel);
|
||||
ShowFreeSectorsAction showFreeAction =
|
||||
new ShowFreeSectorsAction (menuHandler, diskLayoutPanel);
|
||||
CloseTabAction closeTabAction = new CloseTabAction (catalogPanel);
|
||||
|
||||
// add action buttons to toolbar
|
||||
toolBar.add (rootDirectoryAction);
|
||||
toolBar.add (refreshTreeAction);
|
||||
// toolBar.add (preferencesAction);
|
||||
toolBar.add (duplicateAction);
|
||||
toolBar.add (print);
|
||||
// toolBar.add (aboutAction);
|
||||
|
||||
// set the listeners
|
||||
rootDirectoryAction.addListener (rootFolderData);
|
||||
rootDirectoryAction.addListener (catalogPanel);
|
||||
rootDirectoryAction.addListener (duplicateAction);
|
||||
|
||||
catalogPanel.addDiskSelectionListener (this);
|
||||
catalogPanel.addDiskSelectionListener (dataPanel);
|
||||
catalogPanel.addDiskSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addDiskSelectionListener (redoHandler);
|
||||
catalogPanel.addDiskSelectionListener (menuHandler);
|
||||
|
||||
catalogPanel.addFileSelectionListener (dataPanel);
|
||||
catalogPanel.addFileSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addFileSelectionListener (redoHandler);
|
||||
catalogPanel.addFileSelectionListener (menuHandler);
|
||||
|
||||
catalogPanel.addFileNodeSelectionListener (dataPanel);
|
||||
catalogPanel.addFileNodeSelectionListener (redoHandler);
|
||||
|
||||
diskLayoutPanel.addSectorSelectionListener (dataPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (redoHandler);
|
||||
diskLayoutPanel.addSectorSelectionListener (catalogPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (menuHandler);
|
||||
diskLayoutPanel.addSectorSelectionListener (menuHandler.saveSectorsAction);
|
||||
|
||||
duplicateAction.addTableSelectionListener (catalogPanel);
|
||||
|
||||
redoHandler.addRedoListener (catalogPanel);
|
||||
redoHandler.addRedoListener (diskLayoutPanel);
|
||||
|
||||
menuHandler.fontAction.addFontChangeListener (dataPanel);
|
||||
menuHandler.fontAction.addFontChangeListener (catalogPanel);
|
||||
// menuHandler.fontAction.addFontChangeListener (diskLayoutPanel);
|
||||
|
||||
// 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);
|
||||
menuHandler.showLayoutItem.setAction (hideLayoutAction);
|
||||
menuHandler.showFreeSectorsItem.setAction (showFreeAction);
|
||||
menuHandler.duplicateItem.setAction (duplicateAction);
|
||||
menuHandler.closeTabItem.setAction (closeTabAction);
|
||||
|
||||
addQuitListener (rootDirectoryAction);
|
||||
addQuitListener (menuHandler);
|
||||
addQuitListener (catalogPanel);
|
||||
addQuitListener (this);
|
||||
|
||||
if (Desktop.isDesktopSupported ())
|
||||
{
|
||||
Desktop desktop = Desktop.getDesktop ();
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_ABOUT))
|
||||
desktop.setAboutHandler (e -> JOptionPane.showMessageDialog (null,
|
||||
"Author - Denis Molony\nGitHub - https://github.com/dmolony/DiskBrowser",
|
||||
"About DiskBrowser", JOptionPane.INFORMATION_MESSAGE));
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER))
|
||||
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ());
|
||||
else
|
||||
{
|
||||
addWindowListener (new WindowAdapter ()
|
||||
{
|
||||
@Override
|
||||
public void windowClosing (WindowEvent e)
|
||||
{
|
||||
fireQuitEvent ();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
System.out.println ("Desktop not supported");
|
||||
|
||||
catalogPanel.setCloseTabAction (closeTabAction);
|
||||
|
||||
pack ();
|
||||
|
||||
// restore the menuHandler items before they are referenced
|
||||
fireRestoreEvent ();
|
||||
|
||||
diskLayoutPanel.setFree (menuHandler.showFreeSectorsItem.isSelected ());
|
||||
dataPanel.setLineWrap (menuHandler.lineWrapItem.isSelected ());
|
||||
|
||||
// Remove the two optional panels if they were previously hidden
|
||||
if (!menuHandler.showLayoutItem.isSelected ())
|
||||
hideLayoutAction.set (false);
|
||||
if (!menuHandler.showCatalogItem.isSelected ())
|
||||
hideCatalogAction.set (false);
|
||||
|
||||
menuHandler.addBasicPreferencesListener (dataPanel);
|
||||
menuHandler.addAssemblerPreferencesListener (dataPanel);
|
||||
|
||||
// activate the highest panel now that the listeners are ready
|
||||
catalogPanel.activate ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private JPanel addPanel (JComponent pane, String title, String location)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
JPanel panel = new JPanel (new BorderLayout ());
|
||||
panel.setBackground (Color.WHITE);
|
||||
panel.setBorder (BorderFactory.createTitledBorder (title));
|
||||
panel.add (pane);
|
||||
add (panel, location);
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void diskSelected (DiskSelectedEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
setTitle (windowTitle + e.getFormattedDisk () == null ? ""
|
||||
: e.getFormattedDisk ().getName ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void quit (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
windowSaver.saveWindow ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void restore (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
|
||||
windowSaver.restoreWindow ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void main (String[] args)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskBrowser.args = args;
|
||||
EventQueue.invokeLater (new Runnable ()
|
||||
{
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
setLookAndFeel ();
|
||||
new DiskBrowser ().setVisible (true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private static void setLookAndFeel ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
try
|
||||
{
|
||||
UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ());
|
||||
if (MAC)
|
||||
System.setProperty ("apple.laf.useScreenMenuBar", "true");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
|
||||
List<QuitListener> quitListeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void removeQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.remove (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fireQuitEvent ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (QuitListener listener : quitListeners)
|
||||
listener.quit (prefs);
|
||||
|
||||
System.exit (0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fireRestoreEvent ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (QuitListener listener : quitListeners)
|
||||
listener.restore (prefs);
|
||||
}
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.bytezone.diskbrowser.duplicates.RootFolderData;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] args;
|
||||
private static final String windowTitle = "Apple ][ Disk Browser";
|
||||
private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
|
||||
private WindowSaver windowSaver;
|
||||
|
||||
private static final String OS = System.getProperty ("os.name").toLowerCase ();
|
||||
private static final boolean MAC = OS.startsWith ("mac os");
|
||||
|
||||
private final RootFolderData rootFolderData = new RootFolderData ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DiskBrowser ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (windowTitle);
|
||||
|
||||
if (args.length > 0 && "-reset".equals (args[0]))
|
||||
new WindowState (prefs).clear ();
|
||||
|
||||
JToolBar toolBar = new JToolBar ("Toolbar", JToolBar.HORIZONTAL);
|
||||
MenuHandler menuHandler = new MenuHandler ();
|
||||
|
||||
setJMenuBar (menuHandler.menuBar);
|
||||
setLayout (new BorderLayout ());
|
||||
add (toolBar, BorderLayout.NORTH);
|
||||
|
||||
// add navigation buttons
|
||||
RedoHandler redoHandler = new RedoHandler (getRootPane (), toolBar);
|
||||
toolBar.addSeparator ();
|
||||
|
||||
// create and add the left-hand catalog panel
|
||||
CatalogPanel catalogPanel = new CatalogPanel (redoHandler);
|
||||
JPanel catalogBorderPanel = addPanel (catalogPanel, "Catalog", BorderLayout.WEST);
|
||||
|
||||
// create and add the centre output panel
|
||||
DataPanel dataPanel = new DataPanel (menuHandler);
|
||||
addPanel (dataPanel, "Output", BorderLayout.CENTER);
|
||||
|
||||
// create and add the right-hand disk layout panel
|
||||
DiskLayoutPanel diskLayoutPanel = new DiskLayoutPanel ();
|
||||
JPanel layoutBorderPanel =
|
||||
addPanel (diskLayoutPanel, "Disk layout", BorderLayout.EAST);
|
||||
|
||||
// create actions
|
||||
DuplicateAction duplicateAction = new DuplicateAction (rootFolderData);
|
||||
RootDirectoryAction rootDirectoryAction = new RootDirectoryAction ();
|
||||
|
||||
RefreshTreeAction refreshTreeAction = new RefreshTreeAction (catalogPanel);
|
||||
// PreferencesAction preferencesAction = new PreferencesAction (this, prefs);
|
||||
AbstractAction print = new PrintAction (dataPanel);
|
||||
// AboutAction aboutAction = new AboutAction ();
|
||||
HideCatalogAction hideCatalogAction =
|
||||
new HideCatalogAction (this, catalogBorderPanel);
|
||||
HideLayoutAction hideLayoutAction = new HideLayoutAction (this, layoutBorderPanel);
|
||||
ShowFreeSectorsAction showFreeAction =
|
||||
new ShowFreeSectorsAction (menuHandler, diskLayoutPanel);
|
||||
CloseTabAction closeTabAction = new CloseTabAction (catalogPanel);
|
||||
|
||||
// add action buttons to toolbar
|
||||
toolBar.add (rootDirectoryAction);
|
||||
toolBar.add (refreshTreeAction);
|
||||
// toolBar.add (preferencesAction);
|
||||
toolBar.add (duplicateAction);
|
||||
toolBar.add (print);
|
||||
// toolBar.add (aboutAction);
|
||||
|
||||
// set the listeners
|
||||
rootDirectoryAction.addListener (rootFolderData);
|
||||
rootDirectoryAction.addListener (catalogPanel);
|
||||
rootDirectoryAction.addListener (duplicateAction);
|
||||
|
||||
catalogPanel.addDiskSelectionListener (this);
|
||||
catalogPanel.addDiskSelectionListener (dataPanel);
|
||||
catalogPanel.addDiskSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addDiskSelectionListener (redoHandler);
|
||||
catalogPanel.addDiskSelectionListener (menuHandler);
|
||||
|
||||
catalogPanel.addFileSelectionListener (dataPanel);
|
||||
catalogPanel.addFileSelectionListener (diskLayoutPanel);
|
||||
catalogPanel.addFileSelectionListener (redoHandler);
|
||||
catalogPanel.addFileSelectionListener (menuHandler);
|
||||
|
||||
catalogPanel.addFileNodeSelectionListener (dataPanel);
|
||||
catalogPanel.addFileNodeSelectionListener (redoHandler);
|
||||
|
||||
diskLayoutPanel.addSectorSelectionListener (dataPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (redoHandler);
|
||||
diskLayoutPanel.addSectorSelectionListener (catalogPanel);
|
||||
diskLayoutPanel.addSectorSelectionListener (menuHandler);
|
||||
diskLayoutPanel.addSectorSelectionListener (menuHandler.saveSectorsAction);
|
||||
|
||||
duplicateAction.addTableSelectionListener (catalogPanel);
|
||||
|
||||
redoHandler.addRedoListener (catalogPanel);
|
||||
redoHandler.addRedoListener (diskLayoutPanel);
|
||||
|
||||
menuHandler.fontAction.addFontChangeListener (dataPanel);
|
||||
menuHandler.fontAction.addFontChangeListener (catalogPanel);
|
||||
// menuHandler.fontAction.addFontChangeListener (diskLayoutPanel);
|
||||
|
||||
// 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);
|
||||
menuHandler.showLayoutItem.setAction (hideLayoutAction);
|
||||
menuHandler.showFreeSectorsItem.setAction (showFreeAction);
|
||||
menuHandler.duplicateItem.setAction (duplicateAction);
|
||||
menuHandler.closeTabItem.setAction (closeTabAction);
|
||||
|
||||
addQuitListener (rootDirectoryAction);
|
||||
addQuitListener (menuHandler);
|
||||
addQuitListener (catalogPanel);
|
||||
addQuitListener (this);
|
||||
|
||||
if (Desktop.isDesktopSupported ())
|
||||
{
|
||||
Desktop desktop = Desktop.getDesktop ();
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_ABOUT))
|
||||
desktop.setAboutHandler (e -> JOptionPane.showMessageDialog (null,
|
||||
"Author - Denis Molony\nGitHub - https://github.com/dmolony/DiskBrowser",
|
||||
"About DiskBrowser", JOptionPane.INFORMATION_MESSAGE));
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_PREFERENCES) && false)
|
||||
desktop.setPreferencesHandler (
|
||||
e -> JOptionPane.showMessageDialog (null, "Preferences dialog"));
|
||||
|
||||
if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER))
|
||||
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ());
|
||||
else
|
||||
setQuitHandler ();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println ("Desktop not supported");
|
||||
setQuitHandler ();
|
||||
}
|
||||
|
||||
catalogPanel.setCloseTabAction (closeTabAction);
|
||||
|
||||
pack ();
|
||||
|
||||
// restore the menuHandler items before they are referenced
|
||||
fireRestoreEvent ();
|
||||
|
||||
diskLayoutPanel.setFree (menuHandler.showFreeSectorsItem.isSelected ());
|
||||
dataPanel.setLineWrap (menuHandler.lineWrapItem.isSelected ());
|
||||
|
||||
// Remove the two optional panels if they were previously hidden
|
||||
if (!menuHandler.showLayoutItem.isSelected ())
|
||||
hideLayoutAction.set (false);
|
||||
if (!menuHandler.showCatalogItem.isSelected ())
|
||||
hideCatalogAction.set (false);
|
||||
|
||||
menuHandler.addBasicPreferencesListener (dataPanel);
|
||||
menuHandler.addAssemblerPreferencesListener (dataPanel);
|
||||
|
||||
// activate the highest panel now that the listeners are ready
|
||||
catalogPanel.activate ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setQuitHandler ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
addWindowListener (new WindowAdapter ()
|
||||
{
|
||||
@Override
|
||||
public void windowClosing (WindowEvent e)
|
||||
{
|
||||
fireQuitEvent ();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private JPanel addPanel (JComponent pane, String title, String location)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
JPanel panel = new JPanel (new BorderLayout ());
|
||||
panel.setBackground (Color.WHITE);
|
||||
panel.setBorder (BorderFactory.createTitledBorder (title));
|
||||
panel.add (pane);
|
||||
add (panel, location);
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void diskSelected (DiskSelectedEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
setTitle (windowTitle + e.getFormattedDisk () == null ? ""
|
||||
: e.getFormattedDisk ().getName ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void quit (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
windowSaver.saveWindow ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void restore (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
|
||||
windowSaver.restoreWindow ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void main (String[] args)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskBrowser.args = args;
|
||||
EventQueue.invokeLater (new Runnable ()
|
||||
{
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
setLookAndFeel ();
|
||||
new DiskBrowser ().setVisible (true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private static void setLookAndFeel ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
try
|
||||
{
|
||||
UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ());
|
||||
if (MAC)
|
||||
System.setProperty ("apple.laf.useScreenMenuBar", "true");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
|
||||
List<QuitListener> quitListeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void removeQuitListener (QuitListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
quitListeners.remove (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fireQuitEvent ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (QuitListener listener : quitListeners)
|
||||
listener.quit (prefs);
|
||||
|
||||
System.exit (0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fireRestoreEvent ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (QuitListener listener : quitListeners)
|
||||
listener.restore (prefs);
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.common.EnvironmentAction;
|
||||
import com.bytezone.common.FontAction;
|
||||
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
||||
import com.bytezone.diskbrowser.applefile.BasicProgram;
|
||||
@ -79,7 +80,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
JMenu applesoftMenu = new JMenu ("Applesoft");
|
||||
JMenu assemblerMenu = new JMenu ("Assembler");
|
||||
JMenu prodosMenu = new JMenu ("Prodos");
|
||||
// JMenu helpMenu = new JMenu ("Help");
|
||||
JMenu helpMenu = new JMenu ("Help");
|
||||
|
||||
// File menu items
|
||||
final JMenuItem rootItem = new JMenuItem ("Set root folder...");
|
||||
@ -140,7 +141,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
menuBar.add (applesoftMenu);
|
||||
menuBar.add (assemblerMenu);
|
||||
menuBar.add (prodosMenu);
|
||||
// menuBar.add (helpMenu);
|
||||
menuBar.add (helpMenu);
|
||||
|
||||
fileMenu.add (rootItem);
|
||||
fileMenu.addSeparator ();
|
||||
@ -253,7 +254,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
|
||||
prodosSortDirectoriesItem.addActionListener (prodosPreferencesAction);
|
||||
|
||||
// helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
|
||||
sector256Item.setActionCommand ("256");
|
||||
sector256Item.setAccelerator (KeyStroke.getKeyStroke ("alt 4"));
|
||||
|
@ -22,6 +22,7 @@ import javax.swing.border.EmptyBorder;
|
||||
import com.bytezone.common.FontTester;
|
||||
import com.bytezone.input.SpringUtilities;
|
||||
|
||||
// not currently used
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PreferencesDialog extends JDialog
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
Loading…
x
Reference in New Issue
Block a user