AppleCommander/src/com/webcodepro/applecommander/ui/swt/DiskInfoTab.java

108 lines
3.5 KiB
Java

/*
* 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 com.webcodepro.applecommander.storage.FormattedDisk.DiskInformation;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
/**
* Build the Disk Info tab for the Disk Window.
* <p>
* Date created: Nov 17, 2002 9:15:29 PM
* @author: Rob Greene
*/
public class DiskInfoTab {
/**
* Create the DISK INFO tab.
*/
public DiskInfoTab(CTabFolder tabFolder, FormattedDisk[] disks) {
CTabItem ctabitem = new CTabItem(tabFolder, SWT.NULL);
ctabitem.setText("Disk Info");
ScrolledComposite scrolledComposite = new ScrolledComposite(
tabFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
ctabitem.setControl(scrolledComposite);
Composite composite = new Composite(scrolledComposite, SWT.NONE);
if (disks.length > 1) {
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.wrap = false;
composite.setLayout(layout);
for (int i=0; i<disks.length; i++) {
Label label = new Label(composite, SWT.NULL);
label.setText(disks[i].getDiskName());
buildDiskInfoTable(disks[i], composite);
}
} else {
composite.setLayout(new FillLayout());
buildDiskInfoTable(disks[0], composite);
}
composite.pack();
scrolledComposite.setContent(composite);
scrolledComposite.setMinSize(
composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
/**
* Build the table describing the given disk.
*/
public Table buildDiskInfoTable(FormattedDisk disk, Composite composite) {
Table table = new Table(composite, SWT.FULL_SELECTION);
table.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.LEFT);
column.setResizable(true);
column.setText("Label");
column.setWidth(200);
column = new TableColumn(table, SWT.LEFT);
column.setResizable(true);
column.setText("Value");
column.setWidth(400);
Iterator iterator = disk.getDiskInformation().iterator();
TableItem item = null;
while (iterator.hasNext()) {
DiskInformation diskinfo = (DiskInformation) iterator.next();
item = new TableItem(table, SWT.NULL);
item.setText(new String[] { diskinfo.getLabel(), diskinfo.getValue() });
}
return table;
}
/**
* Dispose of resources.
*/
public void dispose() {
}
}