package com.webcodepro.applecommander.ui.swt; import com.webcodepro.applecommander.ui.ImportSpecification; import com.webcodepro.applecommander.util.AppleUtil; import java.io.File; import java.util.Iterator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; /** * Allow the used to choose the files to import into the disk image. *
* Created on Jan 17, 2003. * @author Rob Greene */ public class ImportSelectFilesWizardPane extends WizardPane { private ImportWizard wizard; private Composite control; private Composite parent; private Button removeButton; private Button editButton; private Table fileTable; private Text addressText; /** * Constructor for ImportSelectFilesWizardPane. */ public ImportSelectFilesWizardPane(Composite parent, ImportWizard 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(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 files to be imported:"); fileTable = new Table(control, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL); fileTable.setLayoutData(new RowData(330, 100)); fileTable.setHeaderVisible(true); fileTable.addSelectionListener(new SelectionAdapter() { /** * Single click. */ public void widgetSelected(SelectionEvent event) { removeButton.setEnabled(true); editButton.setEnabled(true); } /** * Double-click. */ public void widgetDefaultSelected(SelectionEvent event) { editSelection(); } }); TableColumn column = new TableColumn(fileTable, SWT.LEFT); column.setText("Source"); column.setWidth(130); column = new TableColumn(fileTable, SWT.LEFT); column.setText("Target"); column.setWidth(130); column = new TableColumn(fileTable, SWT.LEFT); column.setText("Type"); column.setWidth(70); Composite buttonPanel = new Composite(control, SWT.NULL); buttonPanel.setLayout(new FillLayout()); Button chooseButton = new Button(buttonPanel, SWT.PUSH); chooseButton.setText("Choose..."); chooseButton.setFocus(); chooseButton.addSelectionListener(new SelectionAdapter() { /** * Single click. */ public void widgetSelected(SelectionEvent event) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.OPEN | SWT.MULTI); String filename = dialog.open(); if (filename != null) { setFilenames(dialog.getFilterPath(), dialog.getFileNames()); } } }); removeButton = new Button(buttonPanel, SWT.PUSH); removeButton.setText("Remove"); removeButton.setEnabled(false); removeButton.addSelectionListener(new SelectionAdapter() { /** * Single click. */ public void widgetSelected(SelectionEvent event) { TableItem[] items = fileTable.getSelection(); for (int i=0; i