DiskInfo tab is now updated whenever it is displayed. Up until this

point, the information was static - so file imports or deletes never
updated the information.
This commit is contained in:
Robert Greene 2003-03-01 22:58:56 +00:00
parent ca9a3236c8
commit 257836c4a0

View File

@ -28,6 +28,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -43,20 +45,33 @@ import org.eclipse.swt.widgets.TableItem;
* @author: Rob Greene * @author: Rob Greene
*/ */
public class DiskInfoTab { public class DiskInfoTab {
private Table infoTable;
private Composite composite;
private FormattedDisk[] formattedDisks;
/** /**
* Create the DISK INFO tab. * Create the DISK INFO tab.
*/ */
public DiskInfoTab(CTabFolder tabFolder, FormattedDisk[] disks) { public DiskInfoTab(CTabFolder tabFolder, FormattedDisk[] disks) {
this.formattedDisks = disks;
CTabItem ctabitem = new CTabItem(tabFolder, SWT.NULL); CTabItem ctabitem = new CTabItem(tabFolder, SWT.NULL);
ctabitem.setText("Disk Info"); ctabitem.setText("Disk Info");
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
infoTable.removeAll();
buildDiskInfoTable(formattedDisks[0]); // FIXME!
}
});
ScrolledComposite scrolledComposite = new ScrolledComposite( ScrolledComposite scrolledComposite = new ScrolledComposite(
tabFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); tabFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true); scrolledComposite.setExpandVertical(true);
ctabitem.setControl(scrolledComposite); ctabitem.setControl(scrolledComposite);
Composite composite = new Composite(scrolledComposite, SWT.NONE); composite = new Composite(scrolledComposite, SWT.NONE);
createDiskInfoTable();
if (disks.length > 1) { if (disks.length > 1) {
RowLayout layout = new RowLayout(SWT.VERTICAL); RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.wrap = false; layout.wrap = false;
@ -64,11 +79,11 @@ public class DiskInfoTab {
for (int i=0; i<disks.length; i++) { for (int i=0; i<disks.length; i++) {
Label label = new Label(composite, SWT.NULL); Label label = new Label(composite, SWT.NULL);
label.setText(disks[i].getDiskName()); label.setText(disks[i].getDiskName());
buildDiskInfoTable(disks[i], composite); buildDiskInfoTable(disks[i]);
} }
} else { } else {
composite.setLayout(new FillLayout()); composite.setLayout(new FillLayout());
buildDiskInfoTable(disks[0], composite); buildDiskInfoTable(disks[0]);
} }
composite.pack(); composite.pack();
scrolledComposite.setContent(composite); scrolledComposite.setContent(composite);
@ -76,32 +91,37 @@ public class DiskInfoTab {
composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
} }
/** /**
* Build the table describing the given disk. * Create the table describing the given disk.
*/ */
public Table buildDiskInfoTable(FormattedDisk disk, Composite composite) { public void createDiskInfoTable() {
Table table = new Table(composite, SWT.FULL_SELECTION); infoTable = new Table(composite, SWT.FULL_SELECTION);
table.setHeaderVisible(true); infoTable.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.LEFT); TableColumn column = new TableColumn(infoTable, SWT.LEFT);
column.setResizable(true); column.setResizable(true);
column.setText("Label"); column.setText("Label");
column.setWidth(200); column.setWidth(200);
column = new TableColumn(table, SWT.LEFT); column = new TableColumn(infoTable, SWT.LEFT);
column.setResizable(true); column.setResizable(true);
column.setText("Value"); column.setText("Value");
column.setWidth(400); column.setWidth(400);
}
/**
* Build the table describing the given disk.
*/
public void buildDiskInfoTable(FormattedDisk disk) {
Iterator iterator = disk.getDiskInformation().iterator(); Iterator iterator = disk.getDiskInformation().iterator();
TableItem item = null; TableItem item = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
DiskInformation diskinfo = (DiskInformation) iterator.next(); DiskInformation diskinfo = (DiskInformation) iterator.next();
item = new TableItem(table, SWT.NULL); item = new TableItem(infoTable, SWT.NULL);
item.setText(new String[] { diskinfo.getLabel(), diskinfo.getValue() }); item.setText(new String[] { diskinfo.getLabel(), diskinfo.getValue() });
} }
return table;
} }
/** /**
* Dispose of resources. * Dispose of resources.
*/ */
public void dispose() { public void dispose() {
infoTable.dispose();
composite.dispose();
} }
} }