mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-05-28 23:41:28 +00:00
member header lines
This commit is contained in:
parent
343e5da6d9
commit
ed872ce87e
|
@ -12,35 +12,45 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
|
|||
import com.bytezone.diskbrowser.disk.SectorType;
|
||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class DiskLegendPanel extends DiskPanel
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int LEFT = 3;
|
||||
private static final int TOP = 10;
|
||||
|
||||
private final Font font;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DiskLegendPanel ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
font = Platform.getFont (FontType.SANS_SERIF, FontSize.BASE);
|
||||
setBackground (Color.WHITE);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super.setDisk (disk, details);
|
||||
|
||||
repaint ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Dimension getPreferredSize ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return new Dimension (0, 160); // width/height
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
protected void paintComponent (Graphics g)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super.paintComponent (g);
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ import javax.swing.JPanel;
|
|||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class DiskPanel extends JPanel
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
FormattedDisk formattedDisk;
|
||||
LayoutDetails layoutDetails;
|
||||
|
@ -17,7 +19,9 @@ public class DiskPanel extends JPanel
|
|||
|
||||
Color backgroundColor = new Color (0xE0, 0xE0, 0xE0);
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
formattedDisk = disk;
|
||||
layoutDetails = details;
|
||||
|
|
|
@ -5,34 +5,46 @@ import java.util.EventObject;
|
|||
import com.bytezone.diskbrowser.disk.DiskFactory;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
public class DiskSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class DiskSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final FormattedDisk owner;
|
||||
boolean redo;
|
||||
|
||||
public DiskSelectedEvent (Object source, FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
DiskSelectedEvent (Object source, FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (source);
|
||||
this.owner = disk;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FormattedDisk getFormattedDisk ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return owner.getDisk ().getFile ().getAbsolutePath ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return owner.getAbsolutePath ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static DiskSelectedEvent create (Object source, String path)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
FormattedDisk formattedDisk = DiskFactory.createDisk (path);
|
||||
return formattedDisk == null ? null : new DiskSelectedEvent (source, formattedDisk);
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface DiskSelectionListener extends EventListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void diskSelected (DiskSelectedEvent event);
|
||||
}
|
|
@ -13,11 +13,15 @@ import com.bytezone.common.DefaultAction;
|
|||
import com.bytezone.diskbrowser.duplicates.DiskDetails;
|
||||
import com.bytezone.diskbrowser.duplicates.RootFolderData;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class DuplicateAction extends DefaultAction implements RootDirectoryChangeListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
RootFolderData rootFolderData;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public DuplicateAction (RootFolderData rootFolderData)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("List disks...", "Display a sortable list of disks",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
|
@ -31,15 +35,19 @@ public class DuplicateAction extends DefaultAction implements RootDirectoryChang
|
|||
setEnabled (rootFolderData.getRootFolder () != null);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
assert rootFolderData.getRootFolder () == newRootFolder;
|
||||
setEnabled (rootFolderData.getRootFolder () != null);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent arg0)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (rootFolderData.disksWindow == null)
|
||||
{
|
||||
|
@ -58,13 +66,17 @@ public class DuplicateAction extends DefaultAction implements RootDirectoryChang
|
|||
rootFolderData.disksWindow.setVisible (true);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addTableSelectionListener (DiskTableSelectionListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!rootFolderData.listeners.contains (listener))
|
||||
rootFolderData.listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public interface DiskTableSelectionListener
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
public void diskSelected (DiskDetails diskDetails);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,16 @@ import javax.swing.Action;
|
|||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ExecuteDiskAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// should replace this by making the action a listener
|
||||
MenuHandler owner;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public ExecuteDiskAction (MenuHandler owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Run current disk");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Same as double-clicking on the disk");
|
||||
|
@ -22,7 +26,10 @@ class ExecuteDiskAction extends AbstractAction
|
|||
this.owner = owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -31,8 +38,9 @@ class ExecuteDiskAction extends AbstractAction
|
|||
catch (IOException e1)
|
||||
{
|
||||
e1.printStackTrace ();
|
||||
JOptionPane.showMessageDialog (null, "Error opening disk : "
|
||||
+ owner.currentDisk.getDisk ().getFile (), "Bugger", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog (null,
|
||||
"Error opening disk : " + owner.currentDisk.getDisk ().getFile (), "Bugger",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,11 +3,14 @@ package com.bytezone.diskbrowser.gui;
|
|||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class FileComparator implements Comparator<File>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int compare (File thisFile, File thatFile)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
boolean thisFileIsDirectory = thisFile.isDirectory ();
|
||||
boolean thatFileIsDirectory = thatFile.isDirectory ();
|
||||
|
|
|
@ -5,14 +5,14 @@ import java.util.EventObject;
|
|||
import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class FileNodeSelectedEvent extends EventObject
|
||||
class FileNodeSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final FileNode node;
|
||||
boolean redo;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FileNodeSelectedEvent (Object source, FileNode node)
|
||||
FileNodeSelectedEvent (Object source, FileNode node)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (source);
|
||||
|
@ -20,12 +20,19 @@ public class FileNodeSelectedEvent extends EventObject
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FileNode getFileNode ()
|
||||
FileNode getFileNode ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return node.file.getAbsolutePath ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
|
@ -33,11 +40,4 @@ public class FileNodeSelectedEvent extends EventObject
|
|||
{
|
||||
return node.file.getAbsolutePath ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return node.file.getAbsolutePath ();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface FileNodeSelectionListener extends EventListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void fileNodeSelected (FileNodeSelectedEvent event);
|
||||
}
|
|
@ -6,13 +6,17 @@ import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
|||
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
public class FileSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class FileSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public final AppleFileSource appleFileSource;
|
||||
boolean redo;
|
||||
int volumeNo = -1;
|
||||
|
||||
public FileSelectedEvent (Object source, AppleFileSource appleFileSource)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
FileSelectedEvent (Object source, AppleFileSource appleFileSource)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (source);
|
||||
this.appleFileSource = appleFileSource;
|
||||
|
@ -28,14 +32,18 @@ public class FileSelectedEvent extends EventObject
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return appleFileSource.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return appleFileSource.getUniqueName ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return appleFileSource.toString ();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface FileSelectionListener extends EventListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void fileSelected (FileSelectedEvent event);
|
||||
}
|
|
@ -11,12 +11,16 @@ import javax.swing.JMenuItem;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class HideCatalogAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
JFrame owner;
|
||||
JPanel catalogPanel;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public HideCatalogAction (JFrame owner, JPanel catalogPanel)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Show catalog panel");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Show/hide the catalog panel");
|
||||
|
@ -26,12 +30,17 @@ class HideCatalogAction extends AbstractAction
|
|||
this.catalogPanel = catalogPanel;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
set (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void set (boolean show)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
|
|
|
@ -11,12 +11,16 @@ import javax.swing.JMenuItem;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class HideLayoutAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
JFrame owner;
|
||||
JPanel layoutPanel;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public HideLayoutAction (JFrame owner, JPanel layoutPanel)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Show disk layout panel");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Show/hide the disk layout panel");
|
||||
|
@ -26,12 +30,17 @@ class HideLayoutAction extends AbstractAction
|
|||
this.layoutPanel = layoutPanel;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
set (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void set (boolean show)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
|
|
|
@ -8,26 +8,34 @@ import javax.swing.KeyStroke;
|
|||
import com.bytezone.common.DefaultAction;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
public class InterleaveAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class InterleaveAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
int interleave;
|
||||
FormattedDisk currentDisk;
|
||||
static String[] names = { "No Interleave", "Prodos/Pascal", "Infocom", "CPM" };
|
||||
|
||||
public InterleaveAction (int interleave)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
InterleaveAction (int interleave)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (names[interleave], "Alter interleave");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt " + interleave));
|
||||
this.interleave = interleave;
|
||||
}
|
||||
|
||||
public void setDisk (FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setDisk (FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
currentDisk = disk;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
currentDisk.getDisk ().setInterleave (interleave);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,15 @@ import javax.swing.JMenuItem;
|
|||
import javax.swing.JTextArea;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class LineWrapAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
List<JTextArea> listeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public LineWrapAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Line wrap");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Print the contents of the output panel");
|
||||
|
@ -23,14 +27,18 @@ class LineWrapAction extends AbstractAction
|
|||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_W);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addListener (JTextArea listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!listeners.contains (listener))
|
||||
listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (JTextArea listener : listeners)
|
||||
listener.setLineWrap (((JMenuItem) e.getSource ()).isSelected ());
|
||||
|
|
|
@ -28,8 +28,10 @@ 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, SectorSelectionListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitListener,
|
||||
SectorSelectionListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final String PREFS_LINE_WRAP = "line wrap";
|
||||
private static final String PREFS_SHOW_CATALOG = "show catalog";
|
||||
|
@ -128,7 +130,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
|
||||
ButtonGroup paletteGroup = new ButtonGroup ();
|
||||
|
||||
public MenuHandler ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
MenuHandler ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
menuBar.add (fileMenu);
|
||||
menuBar.add (formatMenu);
|
||||
|
@ -270,7 +274,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
saveSectorsItem.setAction (saveSectorsAction);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setBasicPreferences ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
basicPreferences.splitRem = splitRemarkItem.isSelected ();
|
||||
basicPreferences.alignAssign = alignAssignItem.isSelected ();
|
||||
|
@ -281,7 +287,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
BasicProgram.setBasicPreferences (basicPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addBasicPreferencesListener (BasicPreferencesListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!basicPreferencesListeners.contains (listener))
|
||||
{
|
||||
|
@ -290,13 +298,17 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void notifyBasicPreferencesListeners ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (BasicPreferencesListener listener : basicPreferencesListeners)
|
||||
listener.setBasicPreferences (basicPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setAssemblerPreferences ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
assemblerPreferences.showTargets = showAssemblerTargetsItem.isSelected ();
|
||||
assemblerPreferences.showStrings = showAssemblerStringsItem.isSelected ();
|
||||
|
@ -304,7 +316,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
AssemblerProgram.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addAssemblerPreferencesListener (AssemblerPreferencesListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!assemblerPreferencesListeners.contains (listener))
|
||||
{
|
||||
|
@ -313,19 +327,25 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void notifyAssemblerPreferencesListeners ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (AssemblerPreferencesListener listener : assemblerPreferencesListeners)
|
||||
listener.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setProdosPreferences ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
prodosPreferences.sortDirectories = prodosSortDirectoriesItem.isSelected ();
|
||||
ProdosDisk.setProdosPreferences (prodosPreferences);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addProdosPreferencesListener (ProdosPreferencesListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!prodosPreferencesListeners.contains (listener))
|
||||
{
|
||||
|
@ -334,7 +354,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void notifyProdosPreferencesListeners ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (ProdosPreferencesListener listener : prodosPreferencesListeners)
|
||||
listener.setProdosPreferences (prodosPreferences);
|
||||
|
@ -345,7 +367,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
// helpMenu.add (new JMenuItem (action));
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addLauncherMenu ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!Desktop.isDesktopSupported ())
|
||||
return;
|
||||
|
@ -365,8 +389,10 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
fileMenu.addSeparator ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void quit (Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
prefs.putBoolean (PREFS_LINE_WRAP, lineWrapItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_LAYOUT, showLayoutItem.isSelected ());
|
||||
|
@ -396,8 +422,10 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
prodosSortDirectoriesItem.isSelected ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void restore (Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
lineWrapItem.setSelected (prefs.getBoolean (PREFS_LINE_WRAP, true));
|
||||
showLayoutItem.setSelected (prefs.getBoolean (PREFS_SHOW_LAYOUT, true));
|
||||
|
@ -452,15 +480,19 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
fontAction.restore (prefs);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void diskSelected (DiskSelectedEvent event)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
currentDisk = event.getFormattedDisk ();
|
||||
adjustMenus (currentDisk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void fileSelected (FileSelectedEvent event)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// This can happen if a file is selected from a dual-dos disk
|
||||
if (event.appleFileSource.getFormattedDisk () != currentDisk)
|
||||
|
@ -470,7 +502,9 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void adjustMenus (final FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (disk != null)
|
||||
{
|
||||
|
@ -517,8 +551,10 @@ public class MenuHandler implements DiskSelectionListener, FileSelectionListener
|
|||
saveTempFileAction.setDisk (disk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void sectorSelected (SectorSelectedEvent event)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// List<DiskAddress> sectors = event.getSectors ();
|
||||
}
|
||||
|
|
|
@ -8,11 +8,15 @@ import javax.swing.Action;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
public class MonochromeAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MonochromeAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
|
||||
public MonochromeAction (DataPanel owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
MonochromeAction (DataPanel owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Monochrome");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Display image in monochrome or color");
|
||||
|
@ -21,8 +25,10 @@ public class MonochromeAction extends AbstractAction
|
|||
this.owner = owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
owner.setMonochrome (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
|
|
|
@ -3,17 +3,26 @@ package com.bytezone.diskbrowser.gui;
|
|||
import java.awt.event.ActionEvent;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
|
||||
public class NextPaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class NextPaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
private final ButtonGroup buttonGroup;
|
||||
|
||||
public NextPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
NextPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Next Palette");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select next color palette");
|
||||
|
@ -22,8 +31,10 @@ public class NextPaletteAction extends AbstractAction
|
|||
this.buttonGroup = buttonGroup;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Palette palette = owner.cyclePalette (CycleDirection.FORWARDS);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class NoDisksFoundException extends Exception
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
|
||||
// is this used?
|
||||
}
|
|
@ -7,12 +7,16 @@ import javax.swing.Action;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
|
||||
public class PaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final Palette palette;
|
||||
private final DataPanel owner;
|
||||
|
||||
public PaletteAction (DataPanel owner, Palette palette)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PaletteAction (DataPanel owner, Palette palette)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (palette.getName ());
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select color palette: " + palette.getName ());
|
||||
|
@ -20,8 +24,10 @@ public class PaletteAction extends AbstractAction
|
|||
this.palette = palette;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
owner.selectPalette (palette);
|
||||
}
|
||||
|
|
|
@ -12,12 +12,16 @@ import com.bytezone.common.DefaultAction;
|
|||
|
||||
// ********** not currently used ***********
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PreferencesAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
JFrame owner;
|
||||
Preferences prefs;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PreferencesAction (JFrame owner, Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Preferences...", "Set preferences", "/com/bytezone/diskbrowser/icons/");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt P"));
|
||||
|
@ -28,13 +32,17 @@ public class PreferencesAction extends DefaultAction
|
|||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
prefs ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void prefs ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
new PreferencesDialog (owner, prefs);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,25 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.bytezone.common.FontTester;
|
||||
import com.bytezone.input.SpringUtilities;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PreferencesDialog extends JDialog
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final String prefsCatalogFont = "CatalogFont";
|
||||
static final String prefsDataFont = "DataFont";
|
||||
|
@ -38,7 +50,9 @@ class PreferencesDialog extends JDialog
|
|||
private int catalogFontSize;
|
||||
private int dataFontSize;
|
||||
|
||||
public PreferencesDialog (JFrame owner, Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PreferencesDialog (JFrame owner, Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (owner, "Set Preferences", false);
|
||||
|
||||
|
@ -96,7 +110,9 @@ class PreferencesDialog extends JDialog
|
|||
setVisible (true);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private JComponent getCommandPanel ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
JButton cancel = new JButton ("Cancel");
|
||||
cancel.addActionListener (new ActionListener ()
|
||||
|
@ -139,7 +155,9 @@ class PreferencesDialog extends JDialog
|
|||
return commandPanel;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void updatePreferences ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String newFontName = (String) catalogFontList.getSelectedItem ();
|
||||
if (!newFontName.equals (catalogFontName))
|
||||
|
@ -170,7 +188,9 @@ class PreferencesDialog extends JDialog
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addCancelByEscapeKey ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY";
|
||||
int noModifiers = 0;
|
||||
|
@ -189,12 +209,16 @@ class PreferencesDialog extends JDialog
|
|||
getRootPane ().getActionMap ().put (CANCEL_ACTION_KEY, cancelAction);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void closeDialog ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
dispose ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Listener implements ActionListener
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
|
|
|
@ -3,17 +3,26 @@ package com.bytezone.diskbrowser.gui;
|
|||
import java.awt.event.ActionEvent;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
|
||||
public class PreviousPaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PreviousPaletteAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
private final ButtonGroup buttonGroup;
|
||||
|
||||
public PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Previous Palette");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select previous color palette");
|
||||
|
@ -22,8 +31,10 @@ public class PreviousPaletteAction extends AbstractAction
|
|||
this.buttonGroup = buttonGroup;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
|
||||
|
||||
|
|
|
@ -12,11 +12,15 @@ import javax.swing.KeyStroke;
|
|||
|
||||
import com.bytezone.common.DefaultAction;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PrintAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
DataPanel owner;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PrintAction (DataPanel owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Print...", "Print the contents of the output panel",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
|
@ -30,8 +34,10 @@ class PrintAction extends DefaultAction
|
|||
setIcon (Action.LARGE_ICON_KEY, "printer_32.png");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Runnable runner = new Runnable ()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,9 @@ import java.awt.print.Printable;
|
|||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PrintDocument extends Component implements Printable
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
String lines[];
|
||||
int lineHeight;
|
||||
|
@ -22,12 +24,17 @@ class PrintDocument extends Component implements Printable
|
|||
int x = 50;
|
||||
int y = 20;
|
||||
|
||||
public PrintDocument (String text)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PrintDocument (String text)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
lines = wrapText (text, 112);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int print (Graphics g, PageFormat pageFormat, int page)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
if (lineHeight == 0)
|
||||
|
@ -58,8 +65,11 @@ class PrintDocument extends Component implements Printable
|
|||
return (PAGE_EXISTS);
|
||||
}
|
||||
|
||||
// Routine copied from http://progcookbook.blogspot.com/2006/02/text-wrapping-function-for-java.html
|
||||
// Routine copied from http://progcookbook.blogspot.com/
|
||||
// 2006/02/text-wrapping-function-for-java.html
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static String[] wrapText (String text, int len)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// return empty array for null text
|
||||
if (text == null)
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
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));
|
||||
text.append (String.format ("Sort directories ...... %s%n", sortDirectories));
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface ProdosPreferencesListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void setProdosPreferences (ProdosPreferences prodosPreferences);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface QuitListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void quit (Preferences preferences);
|
||||
|
||||
|
|
|
@ -8,11 +8,15 @@ import javax.swing.KeyStroke;
|
|||
|
||||
import com.bytezone.common.DefaultAction;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class RefreshTreeAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
CatalogPanel owner;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public RefreshTreeAction (CatalogPanel owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Refresh current tree", "Makes newly added/modified disks available",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
|
@ -26,8 +30,10 @@ class RefreshTreeAction extends DefaultAction
|
|||
setIcon (Action.LARGE_ICON_KEY, "arrow_refresh_32.png");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
owner.refreshTree ();
|
||||
}
|
||||
|
|
|
@ -14,13 +14,17 @@ import javax.swing.KeyStroke;
|
|||
import com.bytezone.common.DefaultAction;
|
||||
import com.bytezone.common.Platform;
|
||||
|
||||
public class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final String prefsRootDirectory = "Root directory";
|
||||
private final List<RootDirectoryChangeListener> listeners = new ArrayList<> ();
|
||||
private File rootFolder;
|
||||
|
||||
public RootDirectoryAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
RootDirectoryAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Set HOME folder...", "Defines root folder where the disk images are kept",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
|
@ -31,8 +35,10 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
|||
setIcon (Action.LARGE_ICON_KEY, "folder_explore_32.png");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
JFileChooser chooser = new JFileChooser (Platform.userHome);
|
||||
chooser.setDialogTitle ("Select FOLDER containing disk images");
|
||||
|
@ -51,21 +57,27 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addListener (RootDirectoryChangeListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!listeners.contains (listener))
|
||||
listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void quit (Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
prefs.put (prefsRootDirectory,
|
||||
rootFolder == null ? "" : rootFolder.getAbsolutePath ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void restore (Preferences prefs)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String rootDirectory = prefs.get (prefsRootDirectory, "");
|
||||
|
||||
|
@ -79,7 +91,9 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
|||
notifyListeners (rootDirectoryFile);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void notifyListeners (File newRootFolder)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
File oldRootFolder = rootFolder;
|
||||
rootFolder = newRootFolder;
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface RootDirectoryChangeListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder);
|
||||
}
|
||||
|
|
|
@ -11,18 +11,24 @@ import javax.swing.JOptionPane;
|
|||
|
||||
import com.bytezone.common.DefaultAction;
|
||||
|
||||
public class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
SectorSelectedEvent event;
|
||||
|
||||
public SaveSectorsAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SaveSectorsAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Save sectors...", "Save sectors");
|
||||
this.setEnabled (false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent evt)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (event == null)
|
||||
{
|
||||
|
@ -50,8 +56,10 @@ public class SaveSectorsAction extends DefaultAction implements SectorSelectionL
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void sectorSelected (SectorSelectedEvent event)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.event = event;
|
||||
this.setEnabled (true);
|
||||
|
|
|
@ -11,17 +11,23 @@ import javax.swing.JOptionPane;
|
|||
import com.bytezone.common.DefaultAction;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
public class SaveTempFileAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class SaveTempFileAction extends DefaultAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
FormattedDisk disk;
|
||||
|
||||
public SaveTempFileAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SaveTempFileAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Save converted disk...", "Save converted disk");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent evt)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (disk == null)
|
||||
{
|
||||
|
@ -48,7 +54,9 @@ public class SaveTempFileAction extends DefaultAction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setDisk (FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.disk = disk;
|
||||
this.setEnabled (true);
|
||||
|
|
|
@ -13,7 +13,9 @@ import com.bytezone.common.Platform.FontSize;
|
|||
import com.bytezone.common.Platform.FontType;
|
||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ScrollRuler extends JComponent
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// dimensions of the ruler
|
||||
public static final int HEIGHT = 20;
|
||||
|
@ -29,7 +31,9 @@ class ScrollRuler extends JComponent
|
|||
private LayoutDetails layoutDetails;
|
||||
private final JComponent image;
|
||||
|
||||
public ScrollRuler (JComponent image, int orientation)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ScrollRuler (JComponent image, int orientation)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.orientation = orientation;
|
||||
this.image = image;
|
||||
|
@ -41,7 +45,9 @@ class ScrollRuler extends JComponent
|
|||
setPreferredSize (new Dimension (WIDTH, 0));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setLayout (LayoutDetails layout)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.layoutDetails = layout;
|
||||
|
||||
|
@ -56,20 +62,26 @@ class ScrollRuler extends JComponent
|
|||
setTrackMode (layout.grid.width == 16 || layout.grid.width == 13);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setTrackMode (boolean trackMode)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
isTrackMode = trackMode;
|
||||
repaint ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setHex (boolean hex)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
isHex = hex;
|
||||
repaint ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
protected void paintComponent (Graphics g)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Rectangle clipRect = g.getClipBounds ();
|
||||
g.setColor (Color.WHITE);
|
||||
|
@ -87,7 +99,9 @@ class ScrollRuler extends JComponent
|
|||
drawVertical (g, clipRect, layoutDetails.block.height);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void drawHorizontal (Graphics g, Rectangle clipRect, int width)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int start = (clipRect.x / width);
|
||||
int end = start + clipRect.width / width;
|
||||
|
@ -111,7 +125,9 @@ class ScrollRuler extends JComponent
|
|||
g.drawString (String.format (format, i), i * width + offset, 15);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void drawVertical (Graphics g, Rectangle clipRect, int height)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int start = (clipRect.y / height);
|
||||
int end = start + clipRect.height / height;
|
||||
|
|
|
@ -7,13 +7,17 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
|
|||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.disk.SectorListConverter;
|
||||
|
||||
public class SectorSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class SectorSelectedEvent extends EventObject
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<DiskAddress> sectors;
|
||||
private final FormattedDisk owner;
|
||||
boolean redo;
|
||||
|
||||
public SectorSelectedEvent (Object source, List<DiskAddress> sectors, FormattedDisk owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
SectorSelectedEvent (Object source, List<DiskAddress> sectors, FormattedDisk owner)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (source);
|
||||
this.sectors = sectors;
|
||||
|
@ -21,17 +25,23 @@ public class SectorSelectedEvent extends EventObject
|
|||
this.owner = owner.getParent () == null ? owner : owner.getParent ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<DiskAddress> getSectors ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return sectors;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FormattedDisk getFormattedDisk ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
SectorListConverter slc = new SectorListConverter (sectors);
|
||||
|
@ -39,7 +49,10 @@ public class SectorSelectedEvent extends EventObject
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
public static SectorSelectedEvent create (Object source, FormattedDisk owner, String sectorsText)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static SectorSelectedEvent create (Object source, FormattedDisk owner,
|
||||
String sectorsText)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (sectorsText.startsWith ("$"))
|
||||
sectorsText = sectorsText.substring (3); // only for old records
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface SectorSelectionListener extends EventListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void sectorSelected (SectorSelectedEvent event);
|
||||
}
|
|
@ -7,12 +7,16 @@ import javax.swing.AbstractAction;
|
|||
import javax.swing.Action;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ShowFreeSectorsAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
DiskLayoutPanel panel;
|
||||
MenuHandler mh;
|
||||
|
||||
public ShowFreeSectorsAction (MenuHandler mh, DiskLayoutPanel panel)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ShowFreeSectorsAction (MenuHandler mh, DiskLayoutPanel panel)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Show free sectors");
|
||||
putValue (Action.SHORT_DESCRIPTION,
|
||||
|
@ -23,8 +27,10 @@ class ShowFreeSectorsAction extends AbstractAction
|
|||
this.mh = mh;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
panel.setFree (mh.showFreeSectorsItem.isSelected ());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ package com.bytezone.diskbrowser.gui;
|
|||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
interface Tab
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
public void refresh ();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.bytezone.diskbrowser.utilities.FileFormatException;
|
|||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class TreeBuilder
|
||||
class TreeBuilder
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat ("dd MMM yyyy");
|
||||
|
@ -29,7 +29,7 @@ public class TreeBuilder
|
|||
private final JTree tree;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public TreeBuilder (File rootFolder)
|
||||
TreeBuilder (File rootFolder)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
assert (rootFolder.exists ());
|
||||
|
@ -48,7 +48,7 @@ public class TreeBuilder
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public JTree getTree ()
|
||||
JTree getTree ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return tree;
|
||||
|
@ -111,7 +111,7 @@ public class TreeBuilder
|
|||
* Class used to control the text displayed by the JTree.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public class FileNode implements DataSource // why does it implement DataSource?
|
||||
class FileNode implements DataSource // why does it implement DataSource?
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DefaultMutableTreeNode parentNode;
|
||||
|
@ -124,28 +124,28 @@ public class TreeBuilder
|
|||
boolean showDisks;
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public FileNode (File file)
|
||||
FileNode (File file)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public void setTreeNode (DefaultMutableTreeNode node)
|
||||
void setTreeNode (DefaultMutableTreeNode node)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
this.parentNode = node;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public void readFiles ()
|
||||
void readFiles ()
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
addFiles (parentNode, file);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public FormattedDisk getFormattedDisk ()
|
||||
FormattedDisk getFormattedDisk ()
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
if (formattedDisk == null)
|
||||
|
@ -163,7 +163,7 @@ public class TreeBuilder
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------------//
|
||||
public boolean replaceDisk (FormattedDisk disk)
|
||||
boolean replaceDisk (FormattedDisk disk)
|
||||
// -------------------------------------------------------------------------------//
|
||||
{
|
||||
String path = disk.getDisk ().getFile ().getAbsolutePath ();
|
||||
|
|
|
@ -5,20 +5,26 @@ import java.util.prefs.Preferences;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class WindowSaver
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class WindowSaver
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final Preferences prefs;
|
||||
private final JFrame frame;
|
||||
private final String key;
|
||||
|
||||
public WindowSaver (Preferences prefs, JFrame frame, String key)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
WindowSaver (Preferences prefs, JFrame frame, String key)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.prefs = prefs;
|
||||
this.frame = frame;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void saveWindow ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void saveWindow ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
prefs.putInt (key + "X", frame.getX ());
|
||||
prefs.putInt (key + "Y", frame.getY ());
|
||||
|
@ -26,7 +32,9 @@ public class WindowSaver
|
|||
prefs.putInt (key + "Width", frame.getWidth ());
|
||||
}
|
||||
|
||||
public boolean restoreWindow ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean restoreWindow ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int x = prefs.getInt (key + "X", -1);
|
||||
int y = prefs.getInt (key + "Y", -1);
|
||||
|
|
|
@ -6,7 +6,9 @@ import java.util.prefs.Preferences;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class WindowState
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final String PREF_WINDOW_WIDTH = "WindowWidth";
|
||||
private static final String PREF_WINDOW_HEIGHT = "WindowHeight";
|
||||
|
@ -14,12 +16,16 @@ class WindowState
|
|||
|
||||
public Preferences preferences;
|
||||
|
||||
public WindowState (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
WindowState (Preferences preferences)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
public void clear ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void clear ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -32,19 +38,25 @@ class WindowState
|
|||
}
|
||||
}
|
||||
|
||||
public Dimension getWindowSize (int defaultWidth, int defaultHeight)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Dimension getWindowSize (int defaultWidth, int defaultHeight)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int width = preferences.getInt (PREF_WINDOW_WIDTH, defaultWidth);
|
||||
int height = preferences.getInt (PREF_WINDOW_HEIGHT, defaultHeight);
|
||||
return new Dimension (width, height);
|
||||
}
|
||||
|
||||
public int getExtendedState (int defaultState)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getExtendedState (int defaultState)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return preferences.getInt (PREF_WINDOW_STATE, defaultState);
|
||||
}
|
||||
|
||||
public void save (JFrame window)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void save (JFrame window)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
preferences.putInt (PREF_WINDOW_WIDTH, window.getWidth ());
|
||||
preferences.putInt (PREF_WINDOW_HEIGHT, window.getHeight ());
|
||||
|
|
Loading…
Reference in New Issue
Block a user