1 package com.quantum.wizards;
3 import org.eclipse.jface.viewers.ISelectionChangedListener;
4 import org.eclipse.jface.viewers.IStructuredSelection;
5 import org.eclipse.jface.viewers.SelectionChangedEvent;
6 import org.eclipse.jface.wizard.WizardDialog;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.events.SelectionAdapter;
9 import org.eclipse.swt.events.SelectionEvent;
10 import org.eclipse.swt.layout.GridData;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.widgets.Button;
13 import org.eclipse.swt.widgets.Composite;
15 import com.quantum.Messages;
16 import com.quantum.model.JDBCDriver;
17 import com.quantum.view.JDBCDriverTableViewer;
22 public class JDBCDriverSelectionWizardPage extends PropertyChangeWizardPage implements ISelectionChangedListener {
24 private JDBCDriverTableViewer tableViewer;
26 private JDBCDriver driver;
31 public JDBCDriverSelectionWizardPage(String pageName) {
34 setTitle(Messages.getString(getClass(), "title"));
35 setDescription(Messages.getString(getClass(), "description"));
38 public void createControl(Composite parent) {
39 setPageComplete(false);
40 Composite container = createBasicContainer(parent, 1);
41 GridLayout layout = new GridLayout(1, false);
42 container.setLayout(layout);
44 this.tableViewer = new JDBCDriverTableViewer(container);
45 GridData data = new GridData(GridData.FILL_BOTH);
46 this.tableViewer.getControl().setLayoutData(data);
47 this.tableViewer.addSelectionChangedListener(this);
49 Button newDriver = new Button(container, SWT.PUSH);
50 newDriver.setText(Messages.getString(getClass(), "addDriver"));
51 newDriver.addSelectionListener(new SelectionAdapter() {
52 public void widgetSelected(SelectionEvent e) {
53 AddDriverWizard wizard = new AddDriverWizard();
55 new WizardDialog(getShell(), wizard);
59 data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
60 newDriver.setLayoutData(data);
62 setControl(container);
67 private Composite createBasicContainer(Composite parent, int numberOfColumns) {
68 Composite container = new Composite(parent, SWT.NULL);
69 GridLayout layout = new GridLayout();
70 container.setLayout(layout);
71 layout.numColumns = numberOfColumns;
72 layout.verticalSpacing = 9;
73 GridData fullHorizontal = new GridData(GridData.FILL_BOTH);
74 container.setLayoutData(fullHorizontal);
77 public void selectionChanged(SelectionChangedEvent event) {
78 IStructuredSelection selection = (IStructuredSelection) event.getSelection();
79 setPageComplete(!selection.isEmpty());
80 if (!selection.isEmpty()) {
81 setDriver((JDBCDriver) selection.getFirstElement());
86 * @return Returns the driver.
88 public JDBCDriver getDriver() {
92 * @param driver The driver to set.
94 public void setDriver(JDBCDriver driver) {
95 if (this.driver != driver) {
96 JDBCDriver original = this.driver;
98 firePropertyChange("driver", original, driver);
101 public void dispose() {
102 this.tableViewer.dispose();