1 package com.quantum.wizards.sql;
3 import java.beans.PropertyChangeEvent;
4 import java.beans.PropertyChangeListener;
5 import java.util.ArrayList;
6 import java.util.Collections;
7 import java.util.Iterator;
10 import com.quantum.sql.parser.SQL;
11 import com.quantum.wizards.PropertyChangeWizardPage;
13 import org.eclipse.jface.wizard.Wizard;
14 import org.eclipse.jface.wizard.WizardPage;
19 public class SQLStatementWizard extends Wizard implements PropertyChangeListener {
21 private List wizardPages = Collections.synchronizedList(new ArrayList());
22 private ShowSQLStatementWizardPage finalPage;
24 public SQLStatementWizard(WizardPage[] pages, SQL sql) {
25 setWindowTitle("SQL Statement: " + sql.getCommand());
27 for (int i = 0, length = pages == null ? 0 : pages.length; i < length; i++) {
28 this.wizardPages.add(pages[i]);
30 this.finalPage = new ShowSQLStatementWizardPage("finalPage");
31 this.finalPage.setSQLStatement(sql == null ? "" : sql.toString());
34 public void addPages() {
35 for (Iterator i = this.wizardPages.iterator(); i.hasNext();) {
36 WizardPage wizardPage = (WizardPage) i.next();
38 if (wizardPage instanceof PropertyChangeWizardPage) {
39 ((PropertyChangeWizardPage) wizardPage).addPropertyChangeListener(this);
42 addPage(this.finalPage);
45 public void dispose() {
46 for (Iterator i = this.wizardPages.iterator(); i.hasNext();) {
47 WizardPage wizardPage = (WizardPage) i.next();
48 if (wizardPage instanceof PropertyChangeWizardPage) {
49 ((PropertyChangeWizardPage) wizardPage).removePropertyChangeListener(this);
55 public boolean performFinish() {
59 public void propertyChange(PropertyChangeEvent event) {
60 if ("sqlStatement".equals(event.getPropertyName())) {
61 this.finalPage.setSQLStatement((String) event.getNewValue());