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.disk.SectorType;
|
||||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class DiskLegendPanel extends DiskPanel
|
class DiskLegendPanel extends DiskPanel
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final int LEFT = 3;
|
private static final int LEFT = 3;
|
||||||
private static final int TOP = 10;
|
private static final int TOP = 10;
|
||||||
|
|
||||||
private final Font font;
|
private final Font font;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DiskLegendPanel ()
|
public DiskLegendPanel ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
font = Platform.getFont (FontType.SANS_SERIF, FontSize.BASE);
|
font = Platform.getFont (FontType.SANS_SERIF, FontSize.BASE);
|
||||||
setBackground (Color.WHITE);
|
setBackground (Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super.setDisk (disk, details);
|
super.setDisk (disk, details);
|
||||||
|
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize ()
|
public Dimension getPreferredSize ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new Dimension (0, 160); // width/height
|
return new Dimension (0, 160); // width/height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent (Graphics g)
|
protected void paintComponent (Graphics g)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super.paintComponent (g);
|
super.paintComponent (g);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ import javax.swing.JPanel;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DiskPanel extends JPanel
|
public class DiskPanel extends JPanel
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
FormattedDisk formattedDisk;
|
FormattedDisk formattedDisk;
|
||||||
LayoutDetails layoutDetails;
|
LayoutDetails layoutDetails;
|
||||||
|
@ -17,7 +19,9 @@ public class DiskPanel extends JPanel
|
||||||
|
|
||||||
Color backgroundColor = new Color (0xE0, 0xE0, 0xE0);
|
Color backgroundColor = new Color (0xE0, 0xE0, 0xE0);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
public void setDisk (FormattedDisk disk, LayoutDetails details)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
formattedDisk = disk;
|
formattedDisk = disk;
|
||||||
layoutDetails = details;
|
layoutDetails = details;
|
||||||
|
|
|
@ -1,40 +1,52 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.DiskFactory;
|
import com.bytezone.diskbrowser.disk.DiskFactory;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
|
|
||||||
public class DiskSelectedEvent extends EventObject
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class DiskSelectedEvent extends EventObject
|
||||||
private final FormattedDisk owner;
|
// -----------------------------------------------------------------------------------//
|
||||||
boolean redo;
|
{
|
||||||
|
private final FormattedDisk owner;
|
||||||
public DiskSelectedEvent (Object source, FormattedDisk disk)
|
boolean redo;
|
||||||
{
|
|
||||||
super (source);
|
// ---------------------------------------------------------------------------------//
|
||||||
this.owner = disk;
|
DiskSelectedEvent (Object source, FormattedDisk disk)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public FormattedDisk getFormattedDisk ()
|
super (source);
|
||||||
{
|
this.owner = disk;
|
||||||
return owner;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
public FormattedDisk getFormattedDisk ()
|
||||||
public String toString ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return owner.getDisk ().getFile ().getAbsolutePath ();
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toText ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
return owner.getAbsolutePath ();
|
public String toString ()
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public static DiskSelectedEvent create (Object source, String path)
|
return owner.getDisk ().getFile ().getAbsolutePath ();
|
||||||
{
|
}
|
||||||
FormattedDisk formattedDisk = DiskFactory.createDisk (path);
|
|
||||||
return formattedDisk == null ? null : new DiskSelectedEvent (source, formattedDisk);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
public interface DiskSelectionListener extends EventListener
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
public interface DiskSelectionListener extends EventListener
|
||||||
public void diskSelected (DiskSelectedEvent event);
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
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.DiskDetails;
|
||||||
import com.bytezone.diskbrowser.duplicates.RootFolderData;
|
import com.bytezone.diskbrowser.duplicates.RootFolderData;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DuplicateAction extends DefaultAction implements RootDirectoryChangeListener
|
public class DuplicateAction extends DefaultAction implements RootDirectoryChangeListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
RootFolderData rootFolderData;
|
RootFolderData rootFolderData;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DuplicateAction (RootFolderData rootFolderData)
|
public DuplicateAction (RootFolderData rootFolderData)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("List disks...", "Display a sortable list of disks",
|
super ("List disks...", "Display a sortable list of disks",
|
||||||
"/com/bytezone/diskbrowser/icons/");
|
"/com/bytezone/diskbrowser/icons/");
|
||||||
|
@ -31,15 +35,19 @@ public class DuplicateAction extends DefaultAction implements RootDirectoryChang
|
||||||
setEnabled (rootFolderData.getRootFolder () != null);
|
setEnabled (rootFolderData.getRootFolder () != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder)
|
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert rootFolderData.getRootFolder () == newRootFolder;
|
assert rootFolderData.getRootFolder () == newRootFolder;
|
||||||
setEnabled (rootFolderData.getRootFolder () != null);
|
setEnabled (rootFolderData.getRootFolder () != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent arg0)
|
public void actionPerformed (ActionEvent arg0)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (rootFolderData.disksWindow == null)
|
if (rootFolderData.disksWindow == null)
|
||||||
{
|
{
|
||||||
|
@ -58,13 +66,17 @@ public class DuplicateAction extends DefaultAction implements RootDirectoryChang
|
||||||
rootFolderData.disksWindow.setVisible (true);
|
rootFolderData.disksWindow.setVisible (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addTableSelectionListener (DiskTableSelectionListener listener)
|
public void addTableSelectionListener (DiskTableSelectionListener listener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (!rootFolderData.listeners.contains (listener))
|
if (!rootFolderData.listeners.contains (listener))
|
||||||
rootFolderData.listeners.add (listener);
|
rootFolderData.listeners.add (listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public interface DiskTableSelectionListener
|
public interface DiskTableSelectionListener
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void diskSelected (DiskDetails diskDetails);
|
public void diskSelected (DiskDetails diskDetails);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,46 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
class ExecuteDiskAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class ExecuteDiskAction extends AbstractAction
|
||||||
// should replace this by making the action a listener
|
// -----------------------------------------------------------------------------------//
|
||||||
MenuHandler owner;
|
{
|
||||||
|
// should replace this by making the action a listener
|
||||||
public ExecuteDiskAction (MenuHandler owner)
|
MenuHandler owner;
|
||||||
{
|
|
||||||
super ("Run current disk");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Same as double-clicking on the disk");
|
public ExecuteDiskAction (MenuHandler owner)
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt X"));
|
// ---------------------------------------------------------------------------------//
|
||||||
this.owner = owner;
|
{
|
||||||
}
|
super ("Run current disk");
|
||||||
|
putValue (Action.SHORT_DESCRIPTION, "Same as double-clicking on the disk");
|
||||||
public void actionPerformed (ActionEvent e)
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt X"));
|
||||||
{
|
this.owner = owner;
|
||||||
try
|
}
|
||||||
{
|
|
||||||
Desktop.getDesktop ().open (owner.currentDisk.getDisk ().getFile ());
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
@Override
|
||||||
catch (IOException e1)
|
public void actionPerformed (ActionEvent e)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
e1.printStackTrace ();
|
{
|
||||||
JOptionPane.showMessageDialog (null, "Error opening disk : "
|
try
|
||||||
+ owner.currentDisk.getDisk ().getFile (), "Bugger", JOptionPane.INFORMATION_MESSAGE);
|
{
|
||||||
}
|
Desktop.getDesktop ().open (owner.currentDisk.getDisk ().getFile ());
|
||||||
}
|
}
|
||||||
|
catch (IOException e1)
|
||||||
|
{
|
||||||
|
e1.printStackTrace ();
|
||||||
|
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.io.File;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class FileComparator implements Comparator<File>
|
public class FileComparator implements Comparator<File>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int compare (File thisFile, File thatFile)
|
public int compare (File thisFile, File thatFile)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
boolean thisFileIsDirectory = thisFile.isDirectory ();
|
boolean thisFileIsDirectory = thisFile.isDirectory ();
|
||||||
boolean thatFileIsDirectory = thatFile.isDirectory ();
|
boolean thatFileIsDirectory = thatFile.isDirectory ();
|
||||||
|
|
|
@ -5,14 +5,14 @@ import java.util.EventObject;
|
||||||
import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode;
|
import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class FileNodeSelectedEvent extends EventObject
|
class FileNodeSelectedEvent extends EventObject
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final FileNode node;
|
private final FileNode node;
|
||||||
boolean redo;
|
boolean redo;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public FileNodeSelectedEvent (Object source, FileNode node)
|
FileNodeSelectedEvent (Object source, FileNode node)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (source);
|
super (source);
|
||||||
|
@ -20,12 +20,19 @@ public class FileNodeSelectedEvent extends EventObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public FileNode getFileNode ()
|
FileNode getFileNode ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
String toText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return node.file.getAbsolutePath ();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
@ -33,11 +40,4 @@ public class FileNodeSelectedEvent extends EventObject
|
||||||
{
|
{
|
||||||
return node.file.getAbsolutePath ();
|
return node.file.getAbsolutePath ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String toText ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
return node.file.getAbsolutePath ();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface FileNodeSelectionListener extends EventListener
|
public interface FileNodeSelectionListener extends EventListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void fileNodeSelected (FileNodeSelectedEvent event);
|
public void fileNodeSelected (FileNodeSelectedEvent event);
|
||||||
}
|
}
|
|
@ -1,41 +1,49 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
import com.bytezone.diskbrowser.disk.DualDosDisk;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
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 final AppleFileSource appleFileSource;
|
||||||
|
boolean redo;
|
||||||
public FileSelectedEvent (Object source, AppleFileSource appleFileSource)
|
int volumeNo = -1;
|
||||||
{
|
|
||||||
super (source);
|
// ---------------------------------------------------------------------------------//
|
||||||
this.appleFileSource = appleFileSource;
|
FileSelectedEvent (Object source, AppleFileSource appleFileSource)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
|
{
|
||||||
// must be told so that it can ensure its internal currentDisk is set correctly
|
super (source);
|
||||||
FormattedDisk fd = appleFileSource.getFormattedDisk ();
|
this.appleFileSource = appleFileSource;
|
||||||
DualDosDisk ddd = (DualDosDisk) fd.getParent ();
|
|
||||||
if (ddd != null)
|
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
|
||||||
{
|
// must be told so that it can ensure its internal currentDisk is set correctly
|
||||||
ddd.setCurrentDisk (fd);
|
FormattedDisk fd = appleFileSource.getFormattedDisk ();
|
||||||
volumeNo = ddd.getCurrentDiskNo ();
|
DualDosDisk ddd = (DualDosDisk) fd.getParent ();
|
||||||
}
|
if (ddd != null)
|
||||||
}
|
{
|
||||||
|
ddd.setCurrentDisk (fd);
|
||||||
@Override
|
volumeNo = ddd.getCurrentDiskNo ();
|
||||||
public String toString ()
|
}
|
||||||
{
|
}
|
||||||
return appleFileSource.toString ();
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String toText ()
|
||||||
public String toText ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return appleFileSource.getUniqueName ();
|
return appleFileSource.getUniqueName ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return appleFileSource.toString ();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
public interface FileSelectionListener extends EventListener
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
public interface FileSelectionListener extends EventListener
|
||||||
public void fileSelected (FileSelectedEvent event);
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public void fileSelected (FileSelectedEvent event);
|
||||||
}
|
}
|
|
@ -1,47 +1,56 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
class HideCatalogAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class HideCatalogAction extends AbstractAction
|
||||||
JFrame owner;
|
// -----------------------------------------------------------------------------------//
|
||||||
JPanel catalogPanel;
|
{
|
||||||
|
JFrame owner;
|
||||||
public HideCatalogAction (JFrame owner, JPanel catalogPanel)
|
JPanel catalogPanel;
|
||||||
{
|
|
||||||
super ("Show catalog panel");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Show/hide the catalog panel");
|
public HideCatalogAction (JFrame owner, JPanel catalogPanel)
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt C"));
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_C);
|
{
|
||||||
this.owner = owner;
|
super ("Show catalog panel");
|
||||||
this.catalogPanel = catalogPanel;
|
putValue (Action.SHORT_DESCRIPTION, "Show/hide the catalog panel");
|
||||||
}
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt C"));
|
||||||
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_C);
|
||||||
public void actionPerformed (ActionEvent e)
|
this.owner = owner;
|
||||||
{
|
this.catalogPanel = catalogPanel;
|
||||||
set (((JMenuItem) e.getSource ()).isSelected ());
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void set (boolean show)
|
@Override
|
||||||
{
|
public void actionPerformed (ActionEvent e)
|
||||||
if (show)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.add (catalogPanel, BorderLayout.WEST);
|
set (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
owner.validate ();
|
}
|
||||||
}
|
|
||||||
else
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public void set (boolean show)
|
||||||
owner.remove (catalogPanel);
|
// ---------------------------------------------------------------------------------//
|
||||||
owner.validate ();
|
{
|
||||||
}
|
if (show)
|
||||||
}
|
{
|
||||||
|
owner.add (catalogPanel, BorderLayout.WEST);
|
||||||
|
owner.validate ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
owner.remove (catalogPanel);
|
||||||
|
owner.validate ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,47 +1,56 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
class HideLayoutAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class HideLayoutAction extends AbstractAction
|
||||||
JFrame owner;
|
// -----------------------------------------------------------------------------------//
|
||||||
JPanel layoutPanel;
|
{
|
||||||
|
JFrame owner;
|
||||||
public HideLayoutAction (JFrame owner, JPanel layoutPanel)
|
JPanel layoutPanel;
|
||||||
{
|
|
||||||
super ("Show disk layout panel");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Show/hide the disk layout panel");
|
public HideLayoutAction (JFrame owner, JPanel layoutPanel)
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt D"));
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_D);
|
{
|
||||||
this.owner = owner;
|
super ("Show disk layout panel");
|
||||||
this.layoutPanel = layoutPanel;
|
putValue (Action.SHORT_DESCRIPTION, "Show/hide the disk layout panel");
|
||||||
}
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt D"));
|
||||||
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_D);
|
||||||
public void actionPerformed (ActionEvent e)
|
this.owner = owner;
|
||||||
{
|
this.layoutPanel = layoutPanel;
|
||||||
set (((JMenuItem) e.getSource ()).isSelected ());
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void set (boolean show)
|
@Override
|
||||||
{
|
public void actionPerformed (ActionEvent e)
|
||||||
if (show)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.add (layoutPanel, BorderLayout.EAST);
|
set (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
owner.validate ();
|
}
|
||||||
}
|
|
||||||
else
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public void set (boolean show)
|
||||||
owner.remove (layoutPanel);
|
// ---------------------------------------------------------------------------------//
|
||||||
owner.validate ();
|
{
|
||||||
}
|
if (show)
|
||||||
}
|
{
|
||||||
|
owner.add (layoutPanel, BorderLayout.EAST);
|
||||||
|
owner.validate ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
owner.remove (layoutPanel);
|
||||||
|
owner.validate ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,34 +1,42 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
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" };
|
int interleave;
|
||||||
|
FormattedDisk currentDisk;
|
||||||
public InterleaveAction (int interleave)
|
static String[] names = { "No Interleave", "Prodos/Pascal", "Infocom", "CPM" };
|
||||||
{
|
|
||||||
super (names[interleave], "Alter interleave");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt " + interleave));
|
InterleaveAction (int interleave)
|
||||||
this.interleave = interleave;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
super (names[interleave], "Alter interleave");
|
||||||
public void setDisk (FormattedDisk disk)
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt " + interleave));
|
||||||
{
|
this.interleave = interleave;
|
||||||
currentDisk = disk;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
void setDisk (FormattedDisk disk)
|
||||||
public void actionPerformed (ActionEvent e)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
currentDisk.getDisk ().setInterleave (interleave);
|
currentDisk = disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
currentDisk.getDisk ().setInterleave (interleave);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,38 +1,46 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
class LineWrapAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class LineWrapAction extends AbstractAction
|
||||||
List<JTextArea> listeners = new ArrayList<> ();
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public LineWrapAction ()
|
List<JTextArea> listeners = new ArrayList<> ();
|
||||||
{
|
|
||||||
super ("Line wrap");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Print the contents of the output panel");
|
public LineWrapAction ()
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt W"));
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_W);
|
{
|
||||||
}
|
super ("Line wrap");
|
||||||
|
putValue (Action.SHORT_DESCRIPTION, "Print the contents of the output panel");
|
||||||
public void addListener (JTextArea listener)
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt W"));
|
||||||
{
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_W);
|
||||||
if (!listeners.contains (listener))
|
}
|
||||||
listeners.add (listener);
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public void addListener (JTextArea listener)
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public void actionPerformed (ActionEvent e)
|
{
|
||||||
{
|
if (!listeners.contains (listener))
|
||||||
for (JTextArea listener : listeners)
|
listeners.add (listener);
|
||||||
listener.setLineWrap (((JMenuItem) e.getSource ()).isSelected ());
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
for (JTextArea listener : listeners)
|
||||||
|
listener.setLineWrap (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -8,11 +8,15 @@ import javax.swing.Action;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
public class MonochromeAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class MonochromeAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
|
|
||||||
public MonochromeAction (DataPanel owner)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
MonochromeAction (DataPanel owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Monochrome");
|
super ("Monochrome");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Display image in monochrome or color");
|
putValue (Action.SHORT_DESCRIPTION, "Display image in monochrome or color");
|
||||||
|
@ -21,8 +25,10 @@ public class MonochromeAction extends AbstractAction
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.setMonochrome (((JMenuItem) e.getSource ()).isSelected ());
|
owner.setMonochrome (((JMenuItem) e.getSource ()).isSelected ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,26 @@ package com.bytezone.diskbrowser.gui;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.Enumeration;
|
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.Palette;
|
||||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||||
|
|
||||||
public class NextPaletteAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class NextPaletteAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
private final ButtonGroup buttonGroup;
|
private final ButtonGroup buttonGroup;
|
||||||
|
|
||||||
public NextPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
NextPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Next Palette");
|
super ("Next Palette");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Select next color palette");
|
putValue (Action.SHORT_DESCRIPTION, "Select next color palette");
|
||||||
|
@ -22,8 +31,10 @@ public class NextPaletteAction extends AbstractAction
|
||||||
this.buttonGroup = buttonGroup;
|
this.buttonGroup = buttonGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Palette palette = owner.cyclePalette (CycleDirection.FORWARDS);
|
Palette palette = owner.cyclePalette (CycleDirection.FORWARDS);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class NoDisksFoundException extends Exception
|
class NoDisksFoundException extends Exception
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// is this used?
|
||||||
}
|
}
|
|
@ -7,12 +7,16 @@ import javax.swing.Action;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.Palette;
|
import com.bytezone.diskbrowser.applefile.Palette;
|
||||||
|
|
||||||
public class PaletteAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class PaletteAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final Palette palette;
|
private final Palette palette;
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
|
|
||||||
public PaletteAction (DataPanel owner, Palette palette)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
PaletteAction (DataPanel owner, Palette palette)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (palette.getName ());
|
super (palette.getName ());
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Select color palette: " + palette.getName ());
|
putValue (Action.SHORT_DESCRIPTION, "Select color palette: " + palette.getName ());
|
||||||
|
@ -20,8 +24,10 @@ public class PaletteAction extends AbstractAction
|
||||||
this.palette = palette;
|
this.palette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
owner.selectPalette (palette);
|
owner.selectPalette (palette);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,16 @@ import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
// ********** not currently used ***********
|
// ********** not currently used ***********
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class PreferencesAction extends DefaultAction
|
public class PreferencesAction extends DefaultAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
JFrame owner;
|
JFrame owner;
|
||||||
Preferences prefs;
|
Preferences prefs;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public PreferencesAction (JFrame owner, Preferences prefs)
|
public PreferencesAction (JFrame owner, Preferences prefs)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Preferences...", "Set preferences", "/com/bytezone/diskbrowser/icons/");
|
super ("Preferences...", "Set preferences", "/com/bytezone/diskbrowser/icons/");
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt P"));
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt P"));
|
||||||
|
@ -28,13 +32,17 @@ public class PreferencesAction extends DefaultAction
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
prefs ();
|
prefs ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void prefs ()
|
public void prefs ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
new PreferencesDialog (owner, prefs);
|
new PreferencesDialog (owner, prefs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,25 @@ import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.prefs.Preferences;
|
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 javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import com.bytezone.common.FontTester;
|
import com.bytezone.common.FontTester;
|
||||||
import com.bytezone.input.SpringUtilities;
|
import com.bytezone.input.SpringUtilities;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class PreferencesDialog extends JDialog
|
class PreferencesDialog extends JDialog
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final String prefsCatalogFont = "CatalogFont";
|
static final String prefsCatalogFont = "CatalogFont";
|
||||||
static final String prefsDataFont = "DataFont";
|
static final String prefsDataFont = "DataFont";
|
||||||
|
@ -38,7 +50,9 @@ class PreferencesDialog extends JDialog
|
||||||
private int catalogFontSize;
|
private int catalogFontSize;
|
||||||
private int dataFontSize;
|
private int dataFontSize;
|
||||||
|
|
||||||
public PreferencesDialog (JFrame owner, Preferences prefs)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
PreferencesDialog (JFrame owner, Preferences prefs)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (owner, "Set Preferences", false);
|
super (owner, "Set Preferences", false);
|
||||||
|
|
||||||
|
@ -96,7 +110,9 @@ class PreferencesDialog extends JDialog
|
||||||
setVisible (true);
|
setVisible (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private JComponent getCommandPanel ()
|
private JComponent getCommandPanel ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
JButton cancel = new JButton ("Cancel");
|
JButton cancel = new JButton ("Cancel");
|
||||||
cancel.addActionListener (new ActionListener ()
|
cancel.addActionListener (new ActionListener ()
|
||||||
|
@ -139,7 +155,9 @@ class PreferencesDialog extends JDialog
|
||||||
return commandPanel;
|
return commandPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void updatePreferences ()
|
private void updatePreferences ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String newFontName = (String) catalogFontList.getSelectedItem ();
|
String newFontName = (String) catalogFontList.getSelectedItem ();
|
||||||
if (!newFontName.equals (catalogFontName))
|
if (!newFontName.equals (catalogFontName))
|
||||||
|
@ -170,7 +188,9 @@ class PreferencesDialog extends JDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addCancelByEscapeKey ()
|
private void addCancelByEscapeKey ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY";
|
String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY";
|
||||||
int noModifiers = 0;
|
int noModifiers = 0;
|
||||||
|
@ -189,12 +209,16 @@ class PreferencesDialog extends JDialog
|
||||||
getRootPane ().getActionMap ().put (CANCEL_ACTION_KEY, cancelAction);
|
getRootPane ().getActionMap ().put (CANCEL_ACTION_KEY, cancelAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void closeDialog ()
|
private void closeDialog ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
dispose ();
|
dispose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
class Listener implements ActionListener
|
class Listener implements ActionListener
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
|
|
@ -3,17 +3,26 @@ package com.bytezone.diskbrowser.gui;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.Enumeration;
|
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.Palette;
|
||||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||||
|
|
||||||
public class PreviousPaletteAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class PreviousPaletteAction extends AbstractAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final DataPanel owner;
|
private final DataPanel owner;
|
||||||
private final ButtonGroup buttonGroup;
|
private final ButtonGroup buttonGroup;
|
||||||
|
|
||||||
public PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Previous Palette");
|
super ("Previous Palette");
|
||||||
putValue (Action.SHORT_DESCRIPTION, "Select previous color palette");
|
putValue (Action.SHORT_DESCRIPTION, "Select previous color palette");
|
||||||
|
@ -22,8 +31,10 @@ public class PreviousPaletteAction extends AbstractAction
|
||||||
this.buttonGroup = buttonGroup;
|
this.buttonGroup = buttonGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent e)
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
|
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,62 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.print.PrinterException;
|
import java.awt.print.PrinterException;
|
||||||
import java.awt.print.PrinterJob;
|
import java.awt.print.PrinterJob;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
class PrintAction extends DefaultAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class PrintAction extends DefaultAction
|
||||||
DataPanel owner;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public PrintAction (DataPanel owner)
|
DataPanel owner;
|
||||||
{
|
|
||||||
super ("Print...", "Print the contents of the output panel",
|
// ---------------------------------------------------------------------------------//
|
||||||
"/com/bytezone/diskbrowser/icons/");
|
public PrintAction (DataPanel owner)
|
||||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_P, mask));
|
{
|
||||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_P);
|
super ("Print...", "Print the contents of the output panel",
|
||||||
|
"/com/bytezone/diskbrowser/icons/");
|
||||||
this.owner = owner;
|
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||||
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_P, mask));
|
||||||
setIcon (Action.SMALL_ICON, "printer_16.png");
|
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_P);
|
||||||
setIcon (Action.LARGE_ICON_KEY, "printer_32.png");
|
|
||||||
}
|
this.owner = owner;
|
||||||
|
|
||||||
@Override
|
setIcon (Action.SMALL_ICON, "printer_16.png");
|
||||||
public void actionPerformed (ActionEvent e)
|
setIcon (Action.LARGE_ICON_KEY, "printer_32.png");
|
||||||
{
|
}
|
||||||
Runnable runner = new Runnable ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void run ()
|
public void actionPerformed (ActionEvent e)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
try
|
{
|
||||||
{
|
Runnable runner = new Runnable ()
|
||||||
PrinterJob job = PrinterJob.getPrinterJob ();
|
{
|
||||||
job.setPrintable (new PrintDocument (owner.getCurrentText ()));
|
@Override
|
||||||
if (job.printDialog ())
|
public void run ()
|
||||||
job.print ();
|
{
|
||||||
}
|
try
|
||||||
catch (PrinterException e)
|
{
|
||||||
{
|
PrinterJob job = PrinterJob.getPrinterJob ();
|
||||||
System.out.println ("printer error");
|
job.setPrintable (new PrintDocument (owner.getCurrentText ()));
|
||||||
}
|
if (job.printDialog ())
|
||||||
}
|
job.print ();
|
||||||
};
|
}
|
||||||
EventQueue.invokeLater (runner);
|
catch (PrinterException e)
|
||||||
}
|
{
|
||||||
|
System.out.println ("printer error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
EventQueue.invokeLater (runner);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,129 +1,139 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.font.LineMetrics;
|
import java.awt.font.LineMetrics;
|
||||||
import java.awt.print.PageFormat;
|
import java.awt.print.PageFormat;
|
||||||
import java.awt.print.Printable;
|
import java.awt.print.Printable;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
class PrintDocument extends Component implements Printable
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class PrintDocument extends Component implements Printable
|
||||||
String lines[];
|
// -----------------------------------------------------------------------------------//
|
||||||
int lineHeight;
|
{
|
||||||
int pages;
|
String lines[];
|
||||||
Font font = new Font ("Lucida Sans Typewriter", Font.PLAIN, 7);
|
int lineHeight;
|
||||||
int linesPerPage;
|
int pages;
|
||||||
int x = 50;
|
Font font = new Font ("Lucida Sans Typewriter", Font.PLAIN, 7);
|
||||||
int y = 20;
|
int linesPerPage;
|
||||||
|
int x = 50;
|
||||||
public PrintDocument (String text)
|
int y = 20;
|
||||||
{
|
|
||||||
lines = wrapText (text, 112);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
PrintDocument (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int print (Graphics g, PageFormat pageFormat, int page)
|
{
|
||||||
{
|
lines = wrapText (text, 112);
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
}
|
||||||
if (lineHeight == 0)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
LineMetrics lm = font.getLineMetrics ("0", g2.getFontRenderContext ());
|
@Override
|
||||||
lineHeight = (int) lm.getHeight ();
|
public int print (Graphics g, PageFormat pageFormat, int page)
|
||||||
linesPerPage = (int) pageFormat.getImageableHeight () / lineHeight - 5;
|
// ---------------------------------------------------------------------------------//
|
||||||
pages = (lines.length - 1) / linesPerPage;
|
{
|
||||||
}
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
if (lineHeight == 0)
|
||||||
if (pages < page)
|
{
|
||||||
return Printable.NO_SUCH_PAGE;
|
LineMetrics lm = font.getLineMetrics ("0", g2.getFontRenderContext ());
|
||||||
|
lineHeight = (int) lm.getHeight ();
|
||||||
g2.translate (pageFormat.getImageableX (), pageFormat.getImageableY ());
|
linesPerPage = (int) pageFormat.getImageableHeight () / lineHeight - 5;
|
||||||
g2.setPaint (Color.black);
|
pages = (lines.length - 1) / linesPerPage;
|
||||||
g2.setStroke (new BasicStroke (2));
|
}
|
||||||
|
|
||||||
g2.setFont (font);
|
if (pages < page)
|
||||||
|
return Printable.NO_SUCH_PAGE;
|
||||||
int first = page * linesPerPage;
|
|
||||||
int last = first + linesPerPage;
|
g2.translate (pageFormat.getImageableX (), pageFormat.getImageableY ());
|
||||||
if (last > lines.length)
|
g2.setPaint (Color.black);
|
||||||
last = lines.length;
|
g2.setStroke (new BasicStroke (2));
|
||||||
|
|
||||||
for (int line = first; line < last; line++)
|
g2.setFont (font);
|
||||||
g2.drawString (lines[line], x, y + (line % linesPerPage + 2) * lineHeight);
|
|
||||||
|
int first = page * linesPerPage;
|
||||||
return (PAGE_EXISTS);
|
int last = first + linesPerPage;
|
||||||
}
|
if (last > lines.length)
|
||||||
|
last = lines.length;
|
||||||
// Routine copied from http://progcookbook.blogspot.com/2006/02/text-wrapping-function-for-java.html
|
|
||||||
static String[] wrapText (String text, int len)
|
for (int line = first; line < last; line++)
|
||||||
{
|
g2.drawString (lines[line], x, y + (line % linesPerPage + 2) * lineHeight);
|
||||||
// return empty array for null text
|
|
||||||
if (text == null)
|
return (PAGE_EXISTS);
|
||||||
return new String[] {};
|
}
|
||||||
|
|
||||||
// return text if len is zero or less
|
// Routine copied from http://progcookbook.blogspot.com/
|
||||||
if (len <= 0)
|
// 2006/02/text-wrapping-function-for-java.html
|
||||||
return new String[] { text };
|
// ---------------------------------------------------------------------------------//
|
||||||
|
static String[] wrapText (String text, int len)
|
||||||
// return text if less than length
|
// ---------------------------------------------------------------------------------//
|
||||||
if (text.length () <= len)
|
{
|
||||||
return new String[] { text };
|
// return empty array for null text
|
||||||
|
if (text == null)
|
||||||
char[] chars = text.toCharArray ();
|
return new String[] {};
|
||||||
Vector<String> lines = new Vector<String> ();
|
|
||||||
StringBuilder line = new StringBuilder ();
|
// return text if len is zero or less
|
||||||
StringBuilder word = new StringBuilder ();
|
if (len <= 0)
|
||||||
|
return new String[] { text };
|
||||||
for (int i = 0; i < chars.length; i++)
|
|
||||||
{
|
// return text if less than length
|
||||||
if (chars[i] == 10)
|
if (text.length () <= len)
|
||||||
{
|
return new String[] { text };
|
||||||
line.append (word);
|
|
||||||
word.delete (0, word.length ());
|
char[] chars = text.toCharArray ();
|
||||||
lines.add (line.toString ());
|
Vector<String> lines = new Vector<String> ();
|
||||||
line.delete (0, line.length ());
|
StringBuilder line = new StringBuilder ();
|
||||||
continue;
|
StringBuilder word = new StringBuilder ();
|
||||||
}
|
|
||||||
|
for (int i = 0; i < chars.length; i++)
|
||||||
word.append (chars[i]);
|
{
|
||||||
|
if (chars[i] == 10)
|
||||||
if (chars[i] == ' ')
|
{
|
||||||
{
|
line.append (word);
|
||||||
if ((line.length () + word.length ()) > len)
|
word.delete (0, word.length ());
|
||||||
{
|
lines.add (line.toString ());
|
||||||
lines.add (line.toString ());
|
line.delete (0, line.length ());
|
||||||
line.delete (0, line.length ());
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
line.append (word);
|
word.append (chars[i]);
|
||||||
word.delete (0, word.length ());
|
|
||||||
}
|
if (chars[i] == ' ')
|
||||||
}
|
{
|
||||||
|
if ((line.length () + word.length ()) > len)
|
||||||
// handle any extra chars in current word
|
{
|
||||||
if (word.length () > 0)
|
lines.add (line.toString ());
|
||||||
{
|
line.delete (0, line.length ());
|
||||||
if ((line.length () + word.length ()) > len)
|
}
|
||||||
{
|
|
||||||
lines.add (line.toString ());
|
line.append (word);
|
||||||
line.delete (0, line.length ());
|
word.delete (0, word.length ());
|
||||||
}
|
}
|
||||||
line.append (word);
|
}
|
||||||
}
|
|
||||||
|
// handle any extra chars in current word
|
||||||
// handle extra line
|
if (word.length () > 0)
|
||||||
if (line.length () > 0)
|
{
|
||||||
lines.add (line.toString ());
|
if ((line.length () + word.length ()) > len)
|
||||||
|
{
|
||||||
String[] ret = new String[lines.size ()];
|
lines.add (line.toString ());
|
||||||
int c = 0; // counter
|
line.delete (0, line.length ());
|
||||||
for (Enumeration<String> e = lines.elements (); e.hasMoreElements (); c++)
|
}
|
||||||
ret[c] = e.nextElement ();
|
line.append (word);
|
||||||
|
}
|
||||||
return ret;
|
|
||||||
}
|
// handle extra line
|
||||||
|
if (line.length () > 0)
|
||||||
|
lines.add (line.toString ());
|
||||||
|
|
||||||
|
String[] ret = new String[lines.size ()];
|
||||||
|
int c = 0; // counter
|
||||||
|
for (Enumeration<String> e = lines.elements (); e.hasMoreElements (); c++)
|
||||||
|
ret[c] = e.nextElement ();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,15 +1,19 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class ProdosPreferences
|
public class ProdosPreferences
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public boolean sortDirectories;
|
public boolean sortDirectories;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
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 ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface ProdosPreferencesListener
|
public interface ProdosPreferencesListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void setProdosPreferences (ProdosPreferences prodosPreferences);
|
public void setProdosPreferences (ProdosPreferences prodosPreferences);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface QuitListener
|
public interface QuitListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void quit (Preferences preferences);
|
public void quit (Preferences preferences);
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,40 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
class RefreshTreeAction extends DefaultAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class RefreshTreeAction extends DefaultAction
|
||||||
CatalogPanel owner;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public RefreshTreeAction (CatalogPanel owner)
|
CatalogPanel owner;
|
||||||
{
|
|
||||||
super ("Refresh current tree", "Makes newly added/modified disks available",
|
// ---------------------------------------------------------------------------------//
|
||||||
"/com/bytezone/diskbrowser/icons/");
|
public RefreshTreeAction (CatalogPanel owner)
|
||||||
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt R"));
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F5, 0));
|
{
|
||||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_R);
|
super ("Refresh current tree", "Makes newly added/modified disks available",
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F5);
|
"/com/bytezone/diskbrowser/icons/");
|
||||||
this.owner = owner;
|
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt R"));
|
||||||
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F5, 0));
|
||||||
setIcon (Action.SMALL_ICON, "arrow_refresh.png");
|
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_R);
|
||||||
setIcon (Action.LARGE_ICON_KEY, "arrow_refresh_32.png");
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F5);
|
||||||
}
|
this.owner = owner;
|
||||||
|
|
||||||
@Override
|
setIcon (Action.SMALL_ICON, "arrow_refresh.png");
|
||||||
public void actionPerformed (ActionEvent e)
|
setIcon (Action.LARGE_ICON_KEY, "arrow_refresh_32.png");
|
||||||
{
|
}
|
||||||
owner.refreshTree ();
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
owner.refreshTree ();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,89 +1,103 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
import com.bytezone.common.Platform;
|
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;
|
private static final String prefsRootDirectory = "Root directory";
|
||||||
|
private final List<RootDirectoryChangeListener> listeners = new ArrayList<> ();
|
||||||
public RootDirectoryAction ()
|
private File rootFolder;
|
||||||
{
|
|
||||||
super ("Set HOME folder...", "Defines root folder where the disk images are kept",
|
// ---------------------------------------------------------------------------------//
|
||||||
"/com/bytezone/diskbrowser/icons/");
|
RootDirectoryAction ()
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt H"));
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_H);
|
{
|
||||||
|
super ("Set HOME folder...", "Defines root folder where the disk images are kept",
|
||||||
setIcon (Action.SMALL_ICON, "folder_explore_16.png");
|
"/com/bytezone/diskbrowser/icons/");
|
||||||
setIcon (Action.LARGE_ICON_KEY, "folder_explore_32.png");
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt H"));
|
||||||
}
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_H);
|
||||||
|
|
||||||
@Override
|
setIcon (Action.SMALL_ICON, "folder_explore_16.png");
|
||||||
public void actionPerformed (ActionEvent e)
|
setIcon (Action.LARGE_ICON_KEY, "folder_explore_32.png");
|
||||||
{
|
}
|
||||||
JFileChooser chooser = new JFileChooser (Platform.userHome);
|
|
||||||
chooser.setDialogTitle ("Select FOLDER containing disk images");
|
// ---------------------------------------------------------------------------------//
|
||||||
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
|
@Override
|
||||||
if (rootFolder != null)
|
public void actionPerformed (ActionEvent e)
|
||||||
chooser.setSelectedFile (rootFolder);
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
int result = chooser.showDialog (null, "Accept");
|
JFileChooser chooser = new JFileChooser (Platform.userHome);
|
||||||
if (result == JFileChooser.APPROVE_OPTION)
|
chooser.setDialogTitle ("Select FOLDER containing disk images");
|
||||||
{
|
chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
|
||||||
File rootDirectoryFile = chooser.getSelectedFile ();
|
if (rootFolder != null)
|
||||||
if (!rootDirectoryFile.isDirectory ())
|
chooser.setSelectedFile (rootFolder);
|
||||||
rootDirectoryFile = rootDirectoryFile.getParentFile ();
|
|
||||||
if (rootDirectoryFile != null)
|
int result = chooser.showDialog (null, "Accept");
|
||||||
notifyListeners (rootDirectoryFile);
|
if (result == JFileChooser.APPROVE_OPTION)
|
||||||
}
|
{
|
||||||
}
|
File rootDirectoryFile = chooser.getSelectedFile ();
|
||||||
|
if (!rootDirectoryFile.isDirectory ())
|
||||||
public void addListener (RootDirectoryChangeListener listener)
|
rootDirectoryFile = rootDirectoryFile.getParentFile ();
|
||||||
{
|
if (rootDirectoryFile != null)
|
||||||
if (!listeners.contains (listener))
|
notifyListeners (rootDirectoryFile);
|
||||||
listeners.add (listener);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public void quit (Preferences prefs)
|
public void addListener (RootDirectoryChangeListener listener)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
prefs.put (prefsRootDirectory,
|
{
|
||||||
rootFolder == null ? "" : rootFolder.getAbsolutePath ());
|
if (!listeners.contains (listener))
|
||||||
}
|
listeners.add (listener);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void restore (Preferences prefs)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
String rootDirectory = prefs.get (prefsRootDirectory, "");
|
public void quit (Preferences prefs)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
File rootDirectoryFile = new File (rootDirectory);
|
{
|
||||||
|
prefs.put (prefsRootDirectory,
|
||||||
if (!rootDirectoryFile.exists () || !rootDirectoryFile.isDirectory ())
|
rootFolder == null ? "" : rootFolder.getAbsolutePath ());
|
||||||
{
|
}
|
||||||
System.out.println ("No root directory");
|
|
||||||
return;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
@Override
|
||||||
notifyListeners (rootDirectoryFile);
|
public void restore (Preferences prefs)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
private void notifyListeners (File newRootFolder)
|
String rootDirectory = prefs.get (prefsRootDirectory, "");
|
||||||
{
|
|
||||||
File oldRootFolder = rootFolder;
|
File rootDirectoryFile = new File (rootDirectory);
|
||||||
rootFolder = newRootFolder;
|
|
||||||
for (RootDirectoryChangeListener listener : listeners)
|
if (!rootDirectoryFile.exists () || !rootDirectoryFile.isDirectory ())
|
||||||
listener.rootDirectoryChanged (oldRootFolder, newRootFolder);
|
{
|
||||||
}
|
System.out.println ("No root directory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
notifyListeners (rootDirectoryFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private void notifyListeners (File newRootFolder)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
File oldRootFolder = rootFolder;
|
||||||
|
rootFolder = newRootFolder;
|
||||||
|
for (RootDirectoryChangeListener listener : listeners)
|
||||||
|
listener.rootDirectoryChanged (oldRootFolder, newRootFolder);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface RootDirectoryChangeListener
|
public interface RootDirectoryChangeListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder);
|
public void rootDirectoryChanged (File oldRootFolder, File newRootFolder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,24 @@ import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
|
|
||||||
public class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
SectorSelectedEvent event;
|
SectorSelectedEvent event;
|
||||||
|
|
||||||
public SaveSectorsAction ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
SaveSectorsAction ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Save sectors...", "Save sectors");
|
super ("Save sectors...", "Save sectors");
|
||||||
this.setEnabled (false);
|
this.setEnabled (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent evt)
|
public void actionPerformed (ActionEvent evt)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (event == null)
|
if (event == null)
|
||||||
{
|
{
|
||||||
|
@ -50,8 +56,10 @@ public class SaveSectorsAction extends DefaultAction implements SectorSelectionL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void sectorSelected (SectorSelectedEvent event)
|
public void sectorSelected (SectorSelectedEvent event)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this.setEnabled (true);
|
this.setEnabled (true);
|
||||||
|
|
|
@ -11,17 +11,23 @@ import javax.swing.JOptionPane;
|
||||||
import com.bytezone.common.DefaultAction;
|
import com.bytezone.common.DefaultAction;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
|
|
||||||
public class SaveTempFileAction extends DefaultAction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class SaveTempFileAction extends DefaultAction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
FormattedDisk disk;
|
FormattedDisk disk;
|
||||||
|
|
||||||
public SaveTempFileAction ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
SaveTempFileAction ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Save converted disk...", "Save converted disk");
|
super ("Save converted disk...", "Save converted disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed (ActionEvent evt)
|
public void actionPerformed (ActionEvent evt)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (disk == null)
|
if (disk == null)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +54,9 @@ public class SaveTempFileAction extends DefaultAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void setDisk (FormattedDisk disk)
|
void setDisk (FormattedDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
this.setEnabled (true);
|
this.setEnabled (true);
|
||||||
|
|
|
@ -13,7 +13,9 @@ import com.bytezone.common.Platform.FontSize;
|
||||||
import com.bytezone.common.Platform.FontType;
|
import com.bytezone.common.Platform.FontType;
|
||||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class ScrollRuler extends JComponent
|
class ScrollRuler extends JComponent
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// dimensions of the ruler
|
// dimensions of the ruler
|
||||||
public static final int HEIGHT = 20;
|
public static final int HEIGHT = 20;
|
||||||
|
@ -29,7 +31,9 @@ class ScrollRuler extends JComponent
|
||||||
private LayoutDetails layoutDetails;
|
private LayoutDetails layoutDetails;
|
||||||
private final JComponent image;
|
private final JComponent image;
|
||||||
|
|
||||||
public ScrollRuler (JComponent image, int orientation)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
ScrollRuler (JComponent image, int orientation)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.image = image;
|
this.image = image;
|
||||||
|
@ -41,7 +45,9 @@ class ScrollRuler extends JComponent
|
||||||
setPreferredSize (new Dimension (WIDTH, 0));
|
setPreferredSize (new Dimension (WIDTH, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setLayout (LayoutDetails layout)
|
public void setLayout (LayoutDetails layout)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.layoutDetails = layout;
|
this.layoutDetails = layout;
|
||||||
|
|
||||||
|
@ -56,20 +62,26 @@ class ScrollRuler extends JComponent
|
||||||
setTrackMode (layout.grid.width == 16 || layout.grid.width == 13);
|
setTrackMode (layout.grid.width == 16 || layout.grid.width == 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setTrackMode (boolean trackMode)
|
public void setTrackMode (boolean trackMode)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
isTrackMode = trackMode;
|
isTrackMode = trackMode;
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setHex (boolean hex)
|
public void setHex (boolean hex)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
isHex = hex;
|
isHex = hex;
|
||||||
repaint ();
|
repaint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent (Graphics g)
|
protected void paintComponent (Graphics g)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Rectangle clipRect = g.getClipBounds ();
|
Rectangle clipRect = g.getClipBounds ();
|
||||||
g.setColor (Color.WHITE);
|
g.setColor (Color.WHITE);
|
||||||
|
@ -87,7 +99,9 @@ class ScrollRuler extends JComponent
|
||||||
drawVertical (g, clipRect, layoutDetails.block.height);
|
drawVertical (g, clipRect, layoutDetails.block.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void drawHorizontal (Graphics g, Rectangle clipRect, int width)
|
private void drawHorizontal (Graphics g, Rectangle clipRect, int width)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int start = (clipRect.x / width);
|
int start = (clipRect.x / width);
|
||||||
int end = start + clipRect.width / 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);
|
g.drawString (String.format (format, i), i * width + offset, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void drawVertical (Graphics g, Rectangle clipRect, int height)
|
private void drawVertical (Graphics g, Rectangle clipRect, int height)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int start = (clipRect.y / height);
|
int start = (clipRect.y / height);
|
||||||
int end = start + clipRect.height / height;
|
int end = start + clipRect.height / height;
|
||||||
|
|
|
@ -1,50 +1,63 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.disk.SectorListConverter;
|
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;
|
private final List<DiskAddress> sectors;
|
||||||
|
private final FormattedDisk owner;
|
||||||
public SectorSelectedEvent (Object source, List<DiskAddress> sectors, FormattedDisk owner)
|
boolean redo;
|
||||||
{
|
|
||||||
super (source);
|
// ---------------------------------------------------------------------------------//
|
||||||
this.sectors = sectors;
|
SectorSelectedEvent (Object source, List<DiskAddress> sectors, FormattedDisk owner)
|
||||||
// always store the parent if this disk is part of a dual-dos disk
|
// ---------------------------------------------------------------------------------//
|
||||||
this.owner = owner.getParent () == null ? owner : owner.getParent ();
|
{
|
||||||
}
|
super (source);
|
||||||
|
this.sectors = sectors;
|
||||||
public List<DiskAddress> getSectors ()
|
// always store the parent if this disk is part of a dual-dos disk
|
||||||
{
|
this.owner = owner.getParent () == null ? owner : owner.getParent ();
|
||||||
return sectors;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public FormattedDisk getFormattedDisk ()
|
public List<DiskAddress> getSectors ()
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
return owner;
|
{
|
||||||
}
|
return sectors;
|
||||||
|
}
|
||||||
public String toText ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
StringBuilder text = new StringBuilder ();
|
public FormattedDisk getFormattedDisk ()
|
||||||
SectorListConverter slc = new SectorListConverter (sectors);
|
// ---------------------------------------------------------------------------------//
|
||||||
text.append (slc.sectorText);
|
{
|
||||||
return text.toString ();
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SectorSelectedEvent create (Object source, FormattedDisk owner, String sectorsText)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public String toText ()
|
||||||
if (sectorsText.startsWith ("$"))
|
// ---------------------------------------------------------------------------------//
|
||||||
sectorsText = sectorsText.substring (3); // only for old records
|
{
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
SectorListConverter slc = new SectorListConverter (sectorsText, owner.getDisk ());
|
SectorListConverter slc = new SectorListConverter (sectors);
|
||||||
return new SectorSelectedEvent (source, slc.sectors, owner);
|
text.append (slc.sectorText);
|
||||||
}
|
return text.toString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public static SectorSelectedEvent create (Object source, FormattedDisk owner,
|
||||||
|
String sectorsText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (sectorsText.startsWith ("$"))
|
||||||
|
sectorsText = sectorsText.substring (3); // only for old records
|
||||||
|
|
||||||
|
SectorListConverter slc = new SectorListConverter (sectorsText, owner.getDisk ());
|
||||||
|
return new SectorSelectedEvent (source, slc.sectors, owner);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
public interface SectorSelectionListener extends EventListener
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
public interface SectorSelectionListener extends EventListener
|
||||||
public void sectorSelected (SectorSelectedEvent event);
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
public void sectorSelected (SectorSelectedEvent event);
|
||||||
}
|
}
|
|
@ -1,31 +1,37 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
class ShowFreeSectorsAction extends AbstractAction
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
class ShowFreeSectorsAction extends AbstractAction
|
||||||
DiskLayoutPanel panel;
|
// -----------------------------------------------------------------------------------//
|
||||||
MenuHandler mh;
|
{
|
||||||
|
DiskLayoutPanel panel;
|
||||||
public ShowFreeSectorsAction (MenuHandler mh, DiskLayoutPanel panel)
|
MenuHandler mh;
|
||||||
{
|
|
||||||
super ("Show free sectors");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.SHORT_DESCRIPTION,
|
ShowFreeSectorsAction (MenuHandler mh, DiskLayoutPanel panel)
|
||||||
"Display which sectors are marked free in the disk layout panel");
|
// ---------------------------------------------------------------------------------//
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt F"));
|
{
|
||||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F);
|
super ("Show free sectors");
|
||||||
this.panel = panel;
|
putValue (Action.SHORT_DESCRIPTION,
|
||||||
this.mh = mh;
|
"Display which sectors are marked free in the disk layout panel");
|
||||||
}
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt F"));
|
||||||
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F);
|
||||||
@Override
|
this.panel = panel;
|
||||||
public void actionPerformed (ActionEvent e)
|
this.mh = mh;
|
||||||
{
|
}
|
||||||
panel.setFree (mh.showFreeSectorsItem.isSelected ());
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
panel.setFree (mh.showFreeSectorsItem.isSelected ());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,18 +1,20 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
/***********************************************************************************************
|
/***********************************************************************************************
|
||||||
* Interface implemented by AbstractTab, and in turn FileSystemTab and AppleDiskTab.
|
* Interface implemented by AbstractTab, and in turn FileSystemTab and AppleDiskTab.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
***********************************************************************************************/
|
***********************************************************************************************/
|
||||||
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
interface Tab
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
interface Tab
|
||||||
public void refresh ();
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public void activate ();
|
public void refresh ();
|
||||||
|
|
||||||
public DefaultMutableTreeNode getRootNode ();
|
public void activate ();
|
||||||
}
|
|
||||||
|
public DefaultMutableTreeNode getRootNode ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,266 +1,266 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.DiskFactory;
|
import com.bytezone.diskbrowser.disk.DiskFactory;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class TreeBuilder
|
class TreeBuilder
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static SimpleDateFormat sdf = new SimpleDateFormat ("dd MMM yyyy");
|
private static SimpleDateFormat sdf = new SimpleDateFormat ("dd MMM yyyy");
|
||||||
|
|
||||||
private final FileComparator fileComparator = new FileComparator ();
|
private final FileComparator fileComparator = new FileComparator ();
|
||||||
private final JTree tree;
|
private final JTree tree;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public TreeBuilder (File rootFolder)
|
TreeBuilder (File rootFolder)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert (rootFolder.exists ());
|
assert (rootFolder.exists ());
|
||||||
assert (rootFolder.isDirectory ());
|
assert (rootFolder.isDirectory ());
|
||||||
|
|
||||||
FileNode fileNode = new FileNode (rootFolder);
|
FileNode fileNode = new FileNode (rootFolder);
|
||||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode (fileNode);
|
DefaultMutableTreeNode root = new DefaultMutableTreeNode (fileNode);
|
||||||
fileNode.setTreeNode (root);
|
fileNode.setTreeNode (root);
|
||||||
|
|
||||||
addFiles (root, rootFolder);
|
addFiles (root, rootFolder);
|
||||||
DefaultTreeModel treeModel = new DefaultTreeModel (root);
|
DefaultTreeModel treeModel = new DefaultTreeModel (root);
|
||||||
tree = new JTree (treeModel);
|
tree = new JTree (treeModel);
|
||||||
|
|
||||||
treeModel.setAsksAllowsChildren (true); // allows empty nodes to appear as folders
|
treeModel.setAsksAllowsChildren (true); // allows empty nodes to appear as folders
|
||||||
setDiskIcon ("/com/bytezone/diskbrowser/icons/disk.png");
|
setDiskIcon ("/com/bytezone/diskbrowser/icons/disk.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public JTree getTree ()
|
JTree getTree ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addFiles (DefaultMutableTreeNode parentNode, File directory)
|
private void addFiles (DefaultMutableTreeNode parentNode, File directory)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
File[] files = directory.listFiles ();
|
File[] files = directory.listFiles ();
|
||||||
if (files == null || files.length == 0)
|
if (files == null || files.length == 0)
|
||||||
{
|
{
|
||||||
System.out.println ("Empty folder : " + directory.getAbsolutePath ());
|
System.out.println ("Empty folder : " + directory.getAbsolutePath ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrays.sort (files, fileComparator);
|
Arrays.sort (files, fileComparator);
|
||||||
|
|
||||||
for (File file : files)
|
for (File file : files)
|
||||||
{
|
{
|
||||||
if (file.isHidden ())
|
if (file.isHidden ())
|
||||||
continue;
|
continue;
|
||||||
if (file.isDirectory ())
|
if (file.isDirectory ())
|
||||||
parentNode.add (createNode (file, true));
|
parentNode.add (createNode (file, true));
|
||||||
else if (Utility.validFileType (file.getName ()) && file.length () > 0)
|
else if (Utility.validFileType (file.getName ()) && file.length () > 0)
|
||||||
parentNode.add (createNode (file, false));
|
parentNode.add (createNode (file, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private DefaultMutableTreeNode createNode (File file, boolean allowsChildren)
|
private DefaultMutableTreeNode createNode (File file, boolean allowsChildren)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
FileNode fileNode = new FileNode (file);
|
FileNode fileNode = new FileNode (file);
|
||||||
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode);
|
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode);
|
||||||
fileNode.setTreeNode (newNode);
|
fileNode.setTreeNode (newNode);
|
||||||
newNode.setAllowsChildren (allowsChildren);
|
newNode.setAllowsChildren (allowsChildren);
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setDiskIcon (String iconName)
|
private void setDiskIcon (String iconName)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
URL url = this.getClass ().getResource (iconName);
|
URL url = this.getClass ().getResource (iconName);
|
||||||
if (url != null)
|
if (url != null)
|
||||||
{
|
{
|
||||||
ImageIcon icon = new ImageIcon (url);
|
ImageIcon icon = new ImageIcon (url);
|
||||||
DefaultTreeCellRenderer renderer =
|
DefaultTreeCellRenderer renderer =
|
||||||
(DefaultTreeCellRenderer) tree.getCellRenderer ();
|
(DefaultTreeCellRenderer) tree.getCellRenderer ();
|
||||||
renderer.setLeafIcon (icon);
|
renderer.setLeafIcon (icon);
|
||||||
tree.setCellRenderer (renderer);
|
tree.setCellRenderer (renderer);
|
||||||
tree.setRowHeight (18);
|
tree.setRowHeight (18);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
System.out.println ("Failed to set the disk icon : " + iconName);
|
System.out.println ("Failed to set the disk icon : " + iconName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class used to control the text displayed by the JTree.
|
* 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;
|
DefaultMutableTreeNode parentNode;
|
||||||
public final File file;
|
public final File file;
|
||||||
private static final int MAX_NAME_LENGTH = 36;
|
private static final int MAX_NAME_LENGTH = 36;
|
||||||
private static final int SUFFIX_LENGTH = 12;
|
private static final int SUFFIX_LENGTH = 12;
|
||||||
private static final int PREFIX_LENGTH = MAX_NAME_LENGTH - SUFFIX_LENGTH - 3;
|
private static final int PREFIX_LENGTH = MAX_NAME_LENGTH - SUFFIX_LENGTH - 3;
|
||||||
private FormattedDisk formattedDisk;
|
private FormattedDisk formattedDisk;
|
||||||
int disks;
|
int disks;
|
||||||
boolean showDisks;
|
boolean showDisks;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
public FileNode (File file)
|
FileNode (File file)
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
public void setTreeNode (DefaultMutableTreeNode node)
|
void setTreeNode (DefaultMutableTreeNode node)
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.parentNode = node;
|
this.parentNode = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
public void readFiles ()
|
void readFiles ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
addFiles (parentNode, file);
|
addFiles (parentNode, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
public FormattedDisk getFormattedDisk ()
|
FormattedDisk getFormattedDisk ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (formattedDisk == null)
|
if (formattedDisk == null)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formattedDisk = DiskFactory.createDisk (file);
|
formattedDisk = DiskFactory.createDisk (file);
|
||||||
}
|
}
|
||||||
catch (FileFormatException e)
|
catch (FileFormatException e)
|
||||||
{
|
{
|
||||||
System.out.println ("Swallowing a FileFormatException in TreeBuilder");
|
System.out.println ("Swallowing a FileFormatException in TreeBuilder");
|
||||||
System.out.println (e.getMessage ());
|
System.out.println (e.getMessage ());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return formattedDisk;
|
return formattedDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
public boolean replaceDisk (FormattedDisk disk)
|
boolean replaceDisk (FormattedDisk disk)
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String path = disk.getDisk ().getFile ().getAbsolutePath ();
|
String path = disk.getDisk ().getFile ().getAbsolutePath ();
|
||||||
if (formattedDisk != null && path.equals (file.getAbsolutePath ()))
|
if (formattedDisk != null && path.equals (file.getAbsolutePath ()))
|
||||||
{
|
{
|
||||||
formattedDisk = disk;
|
formattedDisk = disk;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String name = file.getName ();
|
String name = file.getName ();
|
||||||
if (name.length () > MAX_NAME_LENGTH)
|
if (name.length () > MAX_NAME_LENGTH)
|
||||||
name = name.substring (0, PREFIX_LENGTH) + "..."
|
name = name.substring (0, PREFIX_LENGTH) + "..."
|
||||||
+ name.substring (name.length () - SUFFIX_LENGTH);
|
+ name.substring (name.length () - SUFFIX_LENGTH);
|
||||||
if (showDisks && disks > 0)
|
if (showDisks && disks > 0)
|
||||||
return String.format ("%s (%,d)", name, disks);
|
return String.format ("%s (%,d)", name, disks);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
String home = System.getProperty ("user.home");
|
String home = System.getProperty ("user.home");
|
||||||
String path = file.getAbsolutePath ();
|
String path = file.getAbsolutePath ();
|
||||||
if (path.startsWith (home))
|
if (path.startsWith (home))
|
||||||
path = "~" + path.substring (home.length ());
|
path = "~" + path.substring (home.length ());
|
||||||
text.append ("Directory : " + path + "\n\n");
|
text.append ("Directory : " + path + "\n\n");
|
||||||
text.append ("D File names "
|
text.append ("D File names "
|
||||||
+ " Date Size Type\n");
|
+ " Date Size Type\n");
|
||||||
text.append ("- ----------------------------------------"
|
text.append ("- ----------------------------------------"
|
||||||
+ " ----------- -------------- ---------\n");
|
+ " ----------- -------------- ---------\n");
|
||||||
|
|
||||||
File[] files = file.listFiles ();
|
File[] files = file.listFiles ();
|
||||||
if (files != null)
|
if (files != null)
|
||||||
{
|
{
|
||||||
Arrays.sort (files, fileComparator);
|
Arrays.sort (files, fileComparator);
|
||||||
for (File f : files)
|
for (File f : files)
|
||||||
{
|
{
|
||||||
if (f.isHidden ())
|
if (f.isHidden ())
|
||||||
continue;
|
continue;
|
||||||
String name = f.getName ();
|
String name = f.getName ();
|
||||||
|
|
||||||
Date d = new Date (f.lastModified ());
|
Date d = new Date (f.lastModified ());
|
||||||
int pos = name.lastIndexOf ('.');
|
int pos = name.lastIndexOf ('.');
|
||||||
String type = pos > 0 && !f.isDirectory () ? name.substring (pos) : "";
|
String type = pos > 0 && !f.isDirectory () ? name.substring (pos) : "";
|
||||||
String size = f.isDirectory () ? "" : String.format ("%,14d", f.length ());
|
String size = f.isDirectory () ? "" : String.format ("%,14d", f.length ());
|
||||||
text.append (String.format ("%s %-40.40s %s %-14s %s%n",
|
text.append (String.format ("%s %-40.40s %s %-14s %s%n",
|
||||||
f.isDirectory () ? "D" : " ", name, sdf.format (d).replace (".", ""), size,
|
f.isDirectory () ? "D" : " ", name, sdf.format (d).replace (".", ""), size,
|
||||||
type));
|
type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.length () > 0)
|
if (text.length () > 0)
|
||||||
text.deleteCharAt (text.length () - 1);
|
text.deleteCharAt (text.length () - 1);
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getAssembler ()
|
public String getAssembler ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getHexDump ()
|
public String getHexDump ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public BufferedImage getImage ()
|
public BufferedImage getImage ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public JComponent getComponent ()
|
public JComponent getComponent ()
|
||||||
// -------------------------------------------------------------------------------//
|
// -------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,20 +5,26 @@ import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
public class WindowSaver
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class WindowSaver
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final Preferences prefs;
|
private final Preferences prefs;
|
||||||
private final JFrame frame;
|
private final JFrame frame;
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
public WindowSaver (Preferences prefs, JFrame frame, String key)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
WindowSaver (Preferences prefs, JFrame frame, String key)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveWindow ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void saveWindow ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
prefs.putInt (key + "X", frame.getX ());
|
prefs.putInt (key + "X", frame.getX ());
|
||||||
prefs.putInt (key + "Y", frame.getY ());
|
prefs.putInt (key + "Y", frame.getY ());
|
||||||
|
@ -26,7 +32,9 @@ public class WindowSaver
|
||||||
prefs.putInt (key + "Width", frame.getWidth ());
|
prefs.putInt (key + "Width", frame.getWidth ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean restoreWindow ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
boolean restoreWindow ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int x = prefs.getInt (key + "X", -1);
|
int x = prefs.getInt (key + "X", -1);
|
||||||
int y = prefs.getInt (key + "Y", -1);
|
int y = prefs.getInt (key + "Y", -1);
|
||||||
|
|
|
@ -6,7 +6,9 @@ import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class WindowState
|
class WindowState
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String PREF_WINDOW_WIDTH = "WindowWidth";
|
private static final String PREF_WINDOW_WIDTH = "WindowWidth";
|
||||||
private static final String PREF_WINDOW_HEIGHT = "WindowHeight";
|
private static final String PREF_WINDOW_HEIGHT = "WindowHeight";
|
||||||
|
@ -14,12 +16,16 @@ class WindowState
|
||||||
|
|
||||||
public Preferences preferences;
|
public Preferences preferences;
|
||||||
|
|
||||||
public WindowState (Preferences preferences)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
WindowState (Preferences preferences)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void clear ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
try
|
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 width = preferences.getInt (PREF_WINDOW_WIDTH, defaultWidth);
|
||||||
int height = preferences.getInt (PREF_WINDOW_HEIGHT, defaultHeight);
|
int height = preferences.getInt (PREF_WINDOW_HEIGHT, defaultHeight);
|
||||||
return new Dimension (width, height);
|
return new Dimension (width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExtendedState (int defaultState)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
int getExtendedState (int defaultState)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return preferences.getInt (PREF_WINDOW_STATE, 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_WIDTH, window.getWidth ());
|
||||||
preferences.putInt (PREF_WINDOW_HEIGHT, window.getHeight ());
|
preferences.putInt (PREF_WINDOW_HEIGHT, window.getHeight ());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user