The new Disk Image Wizard and it's individual wizard panes.

This commit is contained in:
Robert Greene 2002-12-17 05:28:19 +00:00
parent 698e991399
commit 9d72613286
5 changed files with 719 additions and 0 deletions

View File

@ -0,0 +1,150 @@
/*
* AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene
* robgreene at users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.webcodepro.applecommander.ui.swt;
import com.webcodepro.applecommander.storage.FormattedDisk;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
/**
* Allow the user to choose the which operating system to format the
* disk with.
* <br>
* Created on Dec 15, 2002.
* @author Rob Greene
*/
public class DiskImageFormatPane extends WizardPane {
private DiskImageWizard wizard;
private Composite control;
private Composite parent;
/**
* Constructor for DiskImageFormatPane.
*/
public DiskImageFormatPane(Composite parent, DiskImageWizard wizard) {
super();
this.parent = parent;
this.wizard = wizard;
}
/**
* Get the next WizardPane.
* Note that the order and size are set, or defaults are
* chosen.
*/
public WizardPane getNextPane() {
switch (wizard.getFormat()) {
case DiskImageWizard.FORMAT_DOS33:
case DiskImageWizard.FORMAT_RDOS:
wizard.setOrder(DiskImageWizard.ORDER_DOS);
wizard.setSize(FormattedDisk.APPLE_140KB_DISK);
return new DiskImageNamePane(parent, wizard);
case DiskImageWizard.FORMAT_UNIDOS:
wizard.setOrder(DiskImageWizard.ORDER_DOS);
wizard.setSize(FormattedDisk.APPLE_800KB_2IMG_DISK);
return new DiskImageNamePane(parent, wizard);
case DiskImageWizard.FORMAT_OZDOS:
wizard.setOrder(DiskImageWizard.ORDER_PRODOS);
wizard.setSize(FormattedDisk.APPLE_800KB_2IMG_DISK);
return new DiskImageNamePane(parent, wizard);
case DiskImageWizard.FORMAT_PASCAL:
case DiskImageWizard.FORMAT_PRODOS:
wizard.setOrder(DiskImageWizard.ORDER_PRODOS);
return new DiskImageSizePane(parent, wizard);
}
return null;
}
/**
* Create and display the wizard pane.
*/
public void open() {
control = new Composite(parent, SWT.NULL);
wizard.enableNextButton(true);
wizard.enableFinishButton(false);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.justify = true;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.marginTop = 5;
layout.spacing = 3;
control.setLayout(layout);
Label label = new Label(control, SWT.WRAP);
label.setText(
"Please choose the operating system with which to format\nthe disk image:");
RowLayout subpanelLayout = new RowLayout(SWT.VERTICAL);
subpanelLayout.justify = true;
subpanelLayout.spacing = 3;
Composite buttonSubpanel = new Composite(control, SWT.NULL);
buttonSubpanel.setLayout(subpanelLayout);
createRadioButton(buttonSubpanel, "DOS 3.3", DiskImageWizard.FORMAT_DOS33,
"This is Apple's DOS 3.3 format. The disk will automatically be\n"
+ "sized at 140K.");
createRadioButton(buttonSubpanel, "UniDOS", DiskImageWizard.FORMAT_UNIDOS,
"UniDOS was created to allow DOS 3.3 to operate with 800K disk\n"
+ "drives. The disk will default to 800K.");
createRadioButton(buttonSubpanel, "OzDOS", DiskImageWizard.FORMAT_OZDOS,
"OzDOS was created to allow DOS 3.3 to operate with 800K disk\n"
+ "drives. The disk will default to 800K.");
createRadioButton(buttonSubpanel, "ProDOS", DiskImageWizard.FORMAT_PRODOS,
"ProDOS was (is?) Apple's professional DOS for the Apple ][ series\n"
+ "of computers. ProDOS allows subdirectories and can use devices\n"
+ "up to 32MB in size. You will be presented with image sizing\n"
+ "options from the 140K disk to a 32MB hard disk.");
createRadioButton(buttonSubpanel, "Pascal", DiskImageWizard.FORMAT_PASCAL,
"Apple Pascal formatted disks are part of the Pascal environment.\n"
+ "Early implementations of Pascal only allowed 140K volumes, but\n"
+ "later versions allowed 800K volumes (and possibly more). You\n"
+ "will be presented with options for 140K or 800K.");
createRadioButton(buttonSubpanel, "RDOS 2.1", DiskImageWizard.FORMAT_RDOS,
"RDOS was created by (or for) SSI to protected their games. The\n"
+ "original format appears to be a 13 sector disk. Most disk images\n"
+ "that I've seen have been mapped onto a 16 sector disk (leaving 3\n"
+ "sectors of each disk unused. The only image size RDOS supports\n"
+ "is 140K.");
control.pack();
}
/**
* Create a radio button for the disk image format list.
*/
protected void createRadioButton(Composite composite, String label,
final int format, String helpText) {
Button button = new Button(composite, SWT.RADIO);
button.setText(label);
button.setSelection(wizard.getFormat() == format);
button.setToolTipText(helpText);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
wizard.setFormat(format);
}
});
}
/**
* Dispose of any resources.
*/
public void dispose() {
control.dispose();
}
}

View File

@ -0,0 +1,129 @@
/*
* AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene
* robgreene at users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.webcodepro.applecommander.ui.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* Allow the user to choose the names of the disk image, as well as the
* volume name, if appropriate.
* <br>
* Created on Dec 16, 2002.
* @author Rob Greene
*/
public class DiskImageNamePane extends WizardPane {
private DiskImageWizard wizard;
private Composite control;
private Composite parent;
/**
* Constructor for DiskImageNamePane.
*/
public DiskImageNamePane(Composite parent, DiskImageWizard wizard) {
super();
this.parent = parent;
this.wizard = wizard;
}
/**
* Get the next visible pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#getNextPane()
*/
public WizardPane getNextPane() {
return new DiskImageOrderPane(parent, wizard);
}
/**
* Create the wizard pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#open()
*/
public void open() {
control = new Composite(parent, SWT.NULL);
wizard.enableNextButton(false);
wizard.enableFinishButton(false);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.justify = true;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.marginTop = 5;
layout.spacing = 3;
control.setLayout(layout);
Label label = new Label(control, SWT.WRAP);
label.setText(
"Please choose a name for your disk image.\n"
+ "Do not enter any file extensions, as the wizard\n"
+ "will do that for you.");
final Text filename = new Text(control, SWT.BORDER);
filename.setFocus();
RowData rowData = new RowData();
rowData.width = parent.getClientArea().width - 50;
filename.setLayoutData(rowData);
filename.setText(wizard.getFileName());
filename.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
wizard.setFileName(filename.getText());
setButtonStatus();
}
});
if (wizard.isFormatProdos() || wizard.isFormatPascal()) {
int maxLength = wizard.isFormatProdos() ? 15 : 7;
label = new Label(control, SWT.WRAP);
label.setText(
(wizard.isFormatProdos() ? "ProDOS" : "Pascal")
+ " requires a volume name.\nThe maximum length"
+ " of the name is " + maxLength + " characters.");
final Text volumename = new Text(control, SWT.BORDER);
volumename.setText(wizard.getVolumeName());
volumename.setTextLimit(maxLength);
volumename.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
wizard.setVolumeName(volumename.getText().toUpperCase());
setButtonStatus();
}
});
}
}
/**
* Enable the Next button when data has been entered into all fields.
*/
protected void setButtonStatus() {
String volumeName = wizard.getVolumeName();
String fileName = wizard.getFileName();
if (wizard.isFormatProdos() || wizard.isFormatPascal()) {
wizard.enableNextButton(
fileName != null && fileName.length() > 0
&& volumeName != null && volumeName.length() > 0);
} else {
wizard.enableNextButton(fileName != null && fileName.length() > 0);
}
}
/**
* Dispose of all resources.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#dispose()
*/
public void dispose() {
control.dispose();
}
}

View File

@ -0,0 +1,132 @@
/*
* AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene
* robgreene at users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.webcodepro.applecommander.ui.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
/**
* Allow the user to choose the order of the disk image, as well as
* compression.
* <br>
* Created on Dec 16, 2002.
* @author Rob Greene
*/
public class DiskImageOrderPane extends WizardPane {
private DiskImageWizard wizard;
private Composite control;
private Composite parent;
/**
* Constructor for DiskImageNamePane.
*/
public DiskImageOrderPane(Composite parent, DiskImageWizard wizard) {
super();
this.parent = parent;
this.wizard = wizard;
}
/**
* Get the next visible pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#getNextPane()
*/
public WizardPane getNextPane() {
return null;
}
/**
* Create the wizard pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#open()
*/
public void open() {
control = new Composite(parent, SWT.NULL);
wizard.enableNextButton(false);
wizard.enableFinishButton(true);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.justify = true;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.marginTop = 5;
layout.spacing = 3;
control.setLayout(layout);
Label label = new Label(control, SWT.WRAP);
if (wizard.isHardDisk()) {
label.setText("You have chosen a hard disk volume. The only\n"
+ "order allowed is ProDOS.");
} else {
label.setText("Please choose the order to use in this disk image:");
}
RowLayout subpanelLayout = new RowLayout(SWT.VERTICAL);
subpanelLayout.justify = true;
subpanelLayout.spacing = 3;
Composite buttonSubpanel = new Composite(control, SWT.NULL);
buttonSubpanel.setLayout(subpanelLayout);
createRadioButton(buttonSubpanel, "DOS ordered",
DiskImageWizard.ORDER_DOS,
"Indicates that image data should be stored by track and sector.");
createRadioButton(buttonSubpanel, "ProDOS ordered",
DiskImageWizard.ORDER_PRODOS,
"Indicates that image data should be stored by block.");
label = new Label(control, SWT.WRAP);
if (wizard.isHardDisk()) {
label.setText("Compression is not available for hard disk images.");
} else {
label.setText("Indicate if this disk image should be GZIP compressed:");
}
final Button button = new Button(control, SWT.CHECK);
button.setText("GZip compression");
button.setToolTipText("Compresses the disk image (*.gz).");
button.setSelection(wizard.isCompressed());
button.setEnabled(!wizard.isHardDisk());
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
wizard.setCompressed(!wizard.isCompressed());
}
});
}
/**
* Create a radio button for the disk image size list.
*/
protected void createRadioButton(Composite composite, String label,
final int order, String helpText) {
Button button = new Button(composite, SWT.RADIO);
button.setText(label);
button.setToolTipText(helpText);
button.setSelection(wizard.getOrder() == order);
button.setEnabled(!wizard.isHardDisk());
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
wizard.setOrder(order);
}
});
}
/**
* Dispose of all resources.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#dispose()
*/
public void dispose() {
control.dispose();
}
}

View File

@ -0,0 +1,119 @@
/*
* AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene
* robgreene at users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.webcodepro.applecommander.ui.swt;
import com.webcodepro.applecommander.storage.FormattedDisk;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
/**
* Allow the user to choose the size of the disk image, as appropriate.
* <br>
* Created on Dec 15, 2002.
* @author Rob Greene
*/
public class DiskImageSizePane extends WizardPane {
private DiskImageWizard wizard;
private Composite control;
private Composite parent;
/**
* Constructor for DiskImageSizePane.
*/
public DiskImageSizePane(Composite parent, DiskImageWizard wizard) {
super();
this.parent = parent;
this.wizard = wizard;
}
/**
* Get the next visible pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#getNextPane()
*/
public WizardPane getNextPane() {
return new DiskImageNamePane(parent, wizard);
}
/**
* Create the wizard pane.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#open()
*/
public void open() {
control = new Composite(parent, SWT.NULL);
wizard.enableNextButton(true);
wizard.enableFinishButton(false);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.justify = true;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.marginTop = 5;
layout.spacing = 3;
control.setLayout(layout);
Label label = new Label(control, SWT.WRAP);
label.setText(
"Please choose the disk image size:");
RowLayout subpanelLayout = new RowLayout(SWT.VERTICAL);
subpanelLayout.justify = true;
subpanelLayout.spacing = 3;
Composite buttonSubpanel = new Composite(control, SWT.NULL);
buttonSubpanel.setLayout(subpanelLayout);
createRadioButton(buttonSubpanel, "140KB", FormattedDisk.APPLE_140KB_DISK,
"The Disk II 5.25\" floppy drive.");
createRadioButton(buttonSubpanel, "800KB", FormattedDisk.APPLE_800KB_2IMG_DISK,
"The Apple UniDisk 3.5\" drive.");
if (wizard.getFormat() == DiskImageWizard.FORMAT_PRODOS) {
createRadioButton(buttonSubpanel, "5MB", FormattedDisk.APPLE_5MB_HARDDISK,
"A 5MB hard disk.");
createRadioButton(buttonSubpanel, "10MB", FormattedDisk.APPLE_10MB_HARDDISK,
"A 10MB hard disk.");
createRadioButton(buttonSubpanel, "20MB", FormattedDisk.APPLE_20MB_HARDDISK,
"A 20MB hard disk.");
createRadioButton(buttonSubpanel, "32MB", FormattedDisk.APPLE_32MB_HARDDISK,
"A 32MB hard disk.");
}
}
/**
* Create a radio button for the disk image size list.
*/
protected void createRadioButton(Composite composite, String label,
final int size, String helpText) {
Button button = new Button(composite, SWT.RADIO);
button.setText(label);
button.setToolTipText(helpText);
button.setSelection(wizard.getSize() == size);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
wizard.setSize(size);
}
});
}
/**
* Dispose of all resources.
* @see com.webcodepro.applecommander.ui.swt.WizardPane#dispose()
*/
public void dispose() {
control.dispose();
}
}

View File

@ -0,0 +1,189 @@
/*
* AppleCommander - An Apple ][ image utility.
* Copyright (C) 2002 by Robert Greene
* robgreene at users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.webcodepro.applecommander.ui.swt;
import com.webcodepro.applecommander.storage.Disk;
import com.webcodepro.applecommander.storage.DosFormatDisk;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.OzDosFormatDisk;
import com.webcodepro.applecommander.storage.PascalFormatDisk;
import com.webcodepro.applecommander.storage.ProdosFormatDisk;
import com.webcodepro.applecommander.storage.RdosFormatDisk;
import com.webcodepro.applecommander.storage.UniDosFormatDisk;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
/**
* Disk Image Wizard.
* <br>
* Created on Dec 15, 2002.
* @author Rob Greene
*/
public class DiskImageWizard extends Wizard {
public static final int FORMAT_DOS33 = 1;
public static final int FORMAT_UNIDOS = 2;
public static final int FORMAT_PRODOS = 3;
public static final int FORMAT_PASCAL = 4;
public static final int FORMAT_RDOS = 5;
public static final int FORMAT_OZDOS = 6;
public static final int ORDER_DOS = 1;
public static final int ORDER_PRODOS = 2;
private int format = FORMAT_DOS33;
private int size = FormattedDisk.APPLE_140KB_DISK;
private String fileName = "";
private String volumeName = "";
private int order = ORDER_PRODOS;
private boolean compressed = false;
/**
* Constructor for ExportWizard.
*/
public DiskImageWizard(Shell parent, Image logo) {
super(parent, logo, "Disk Image Wizard");
}
/**
* Create the initial display used in the wizard.
* @see com.webcodepro.applecommander.ui.swt.Wizard#createInitialWizardPane()
*/
public WizardPane createInitialWizardPane() {
return new DiskImageFormatPane(getContentPane(), this);
}
/**
* Get the FormattedDisk as specified.
*/
public FormattedDisk[] getFormattedDisks() {
StringBuffer name = new StringBuffer(fileName);
if (isHardDisk()) {
name.append(".hdv");
} else if (order == ORDER_DOS) {
name.append(".dsk");
} else {
name.append(".po");
}
if (isCompressed()) {
name.append(".gz");
}
switch (format) {
case FORMAT_DOS33:
return DosFormatDisk.create(name.toString());
case FORMAT_OZDOS:
return OzDosFormatDisk.create(name.toString());
case FORMAT_PASCAL:
return PascalFormatDisk.create(name.toString(), volumeName, size);
case FORMAT_PRODOS:
return ProdosFormatDisk.create(name.toString(), volumeName, size);
case FORMAT_RDOS:
return RdosFormatDisk.create(name.toString());
case FORMAT_UNIDOS:
return UniDosFormatDisk.create(name.toString());
}
return null;
}
/**
* Returns the image format.
*/
public int getFormat() {
return format;
}
/**
* Sets the image format.
*/
public void setFormat(int format) {
this.format = format;
}
/**
* Returns the size.
*/
public int getSize() {
return size;
}
/**
* Sets the size.
*/
public void setSize(int size) {
this.size = size;
}
/**
* Returns the fileName.
*/
public String getFileName() {
return fileName;
}
/**
* Returns the volumeName.
*/
public String getVolumeName() {
return volumeName;
}
/**
* Sets the fileName.
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* Sets the volumeName.
*/
public void setVolumeName(String volumeName) {
this.volumeName = volumeName;
}
/**
* Indicates if the format is ProDOS.
*/
public boolean isFormatProdos() {
return format == FORMAT_PRODOS;
}
/**
* Indicates if the format is Pascal.
*/
public boolean isFormatPascal() {
return format == FORMAT_PASCAL;
}
/**
* Returns the order.
*/
public int getOrder() {
return order;
}
/**
* Sets the order.
*/
public void setOrder(int order) {
this.order = order;
}
/**
* Returns the compressed.
*/
public boolean isCompressed() {
return compressed;
}
/**
* Sets the compressed.
*/
public void setCompressed(boolean compressed) {
this.compressed = compressed;
}
/**
* Indicates if this image is a hard disk.
*/
public boolean isHardDisk() {
return size > Disk.APPLE_800KB_2IMG_DISK;
}
}