2002-12-01 02:21:00 +00:00
|
|
|
/*
|
|
|
|
* 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.custom.CTabFolder;
|
|
|
|
import org.eclipse.swt.events.DisposeEvent;
|
|
|
|
import org.eclipse.swt.events.DisposeListener;
|
|
|
|
import org.eclipse.swt.layout.FillLayout;
|
|
|
|
import org.eclipse.swt.widgets.Shell;
|
|
|
|
|
2004-06-09 03:58:00 +00:00
|
|
|
import com.webcodepro.applecommander.storage.FormattedDisk;
|
|
|
|
import com.webcodepro.applecommander.ui.swt.util.ImageManager;
|
|
|
|
|
2002-12-01 02:21:00 +00:00
|
|
|
/**
|
|
|
|
* Displays disk information on the screen.
|
|
|
|
* <p>
|
|
|
|
* Date created: Oct 12, 2002 3:28:41 PM
|
2004-06-18 05:15:33 +00:00
|
|
|
* @author Rob Greene
|
2002-12-01 02:21:00 +00:00
|
|
|
*/
|
|
|
|
public class DiskWindow {
|
|
|
|
private Shell parentShell;
|
|
|
|
private ImageManager imageManager;
|
|
|
|
|
|
|
|
private Shell shell;
|
2002-12-14 05:49:04 +00:00
|
|
|
private FormattedDisk[] disks;
|
2002-12-01 02:21:00 +00:00
|
|
|
|
2002-12-16 02:20:32 +00:00
|
|
|
private DiskInfoTab diskInfoTab;
|
2002-12-14 05:49:04 +00:00
|
|
|
private DiskMapTab[] diskMapTabs;
|
2002-12-16 02:20:32 +00:00
|
|
|
private DiskExplorerTab diskExplorerTab;
|
2002-12-01 02:21:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct the disk window.
|
|
|
|
*/
|
2002-12-14 05:49:04 +00:00
|
|
|
public DiskWindow(Shell parentShell, FormattedDisk[] disks, ImageManager imageManager) {
|
2002-12-01 02:21:00 +00:00
|
|
|
this.parentShell = shell;
|
2002-12-14 05:49:04 +00:00
|
|
|
this.disks = disks;
|
2002-12-01 02:21:00 +00:00
|
|
|
this.imageManager = imageManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the Disk window and display (open) it.
|
|
|
|
*/
|
|
|
|
public void open() {
|
|
|
|
shell = new Shell(parentShell, SWT.SHELL_TRIM);
|
|
|
|
shell.setLayout(new FillLayout());
|
2003-12-10 04:46:32 +00:00
|
|
|
shell.setImage(imageManager.get(ImageManager.ICON_DISK));
|
2003-12-08 00:53:08 +00:00
|
|
|
setStandardWindowTitle();
|
2002-12-01 02:21:00 +00:00
|
|
|
shell.addDisposeListener(new DisposeListener() {
|
|
|
|
public void widgetDisposed(DisposeEvent event) {
|
|
|
|
dispose(event);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
CTabFolder tabFolder = new CTabFolder(shell, SWT.BOTTOM);
|
2002-12-16 02:20:32 +00:00
|
|
|
diskExplorerTab = new DiskExplorerTab(tabFolder, disks,
|
2003-12-08 00:53:08 +00:00
|
|
|
imageManager, this);
|
2002-12-14 05:49:04 +00:00
|
|
|
diskMapTabs = new DiskMapTab[disks.length];
|
|
|
|
for (int i=0; i<disks.length; i++) {
|
2003-12-22 07:12:12 +00:00
|
|
|
if (disks[i].supportsDiskMap()) {
|
|
|
|
diskMapTabs[i] = new DiskMapTab(tabFolder, disks[i]);
|
|
|
|
}
|
2002-12-14 05:49:04 +00:00
|
|
|
}
|
2002-12-16 02:20:32 +00:00
|
|
|
diskInfoTab = new DiskInfoTab(tabFolder, disks);
|
2002-12-01 02:21:00 +00:00
|
|
|
tabFolder.setSelection(tabFolder.getItems()[0]);
|
|
|
|
|
2002-12-16 02:20:32 +00:00
|
|
|
|
2002-12-01 02:21:00 +00:00
|
|
|
shell.open();
|
|
|
|
}
|
|
|
|
|
2003-12-08 00:53:08 +00:00
|
|
|
/**
|
|
|
|
* Set the standard AppleCommander disk window title.
|
|
|
|
* This is referenced in DiskWindow as well as DiskExplorerTab.
|
|
|
|
*/
|
|
|
|
public void setStandardWindowTitle() {
|
|
|
|
shell.setText("AppleCommander - " + disks[0].getFilename());
|
|
|
|
}
|
|
|
|
|
2002-12-01 02:21:00 +00:00
|
|
|
/**
|
|
|
|
* Dispose of all shared resources.
|
|
|
|
*/
|
|
|
|
private void dispose(DisposeEvent event) {
|
2003-12-22 07:12:12 +00:00
|
|
|
for (int i=0; i<diskMapTabs.length; i++) {
|
|
|
|
if (diskMapTabs[i] != null) diskMapTabs[i].dispose();
|
2002-12-14 05:49:04 +00:00
|
|
|
}
|
2002-12-16 02:20:32 +00:00
|
|
|
diskInfoTab.dispose();
|
2002-12-01 02:21:00 +00:00
|
|
|
|
2002-12-14 05:49:04 +00:00
|
|
|
disks = null;
|
|
|
|
diskMapTabs = null;
|
2002-12-16 02:20:32 +00:00
|
|
|
diskInfoTab = null;
|
2002-12-01 02:21:00 +00:00
|
|
|
System.gc();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|