commented out code responsible for exceptions. now showing correct suite names and...
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / sql / SQLStatementWizard.java
1 package com.quantum.wizards.sql;
2
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;
8 import java.util.List;
9
10 import com.quantum.sql.parser.SQL;
11 import com.quantum.wizards.PropertyChangeWizardPage;
12
13 import org.eclipse.jface.wizard.Wizard;
14 import org.eclipse.jface.wizard.WizardPage;
15
16 /**
17  * @author BC Holmes
18  */
19 public class SQLStatementWizard extends Wizard implements PropertyChangeListener {
20         
21         private List wizardPages = Collections.synchronizedList(new ArrayList());
22         private ShowSQLStatementWizardPage finalPage;
23         
24         public SQLStatementWizard(WizardPage[] pages, SQL sql) {
25                 setWindowTitle("SQL Statement: " + sql.getCommand());
26                 
27                 for (int i = 0, length = pages == null ? 0 : pages.length; i < length; i++) {
28                         this.wizardPages.add(pages[i]);
29                 }
30                 this.finalPage = new ShowSQLStatementWizardPage("finalPage");
31                 this.finalPage.setSQLStatement(sql == null ? "" : sql.toString());
32         }
33         
34         public void addPages() {
35                 for (Iterator i = this.wizardPages.iterator(); i.hasNext();) {
36                         WizardPage wizardPage = (WizardPage) i.next();
37                         addPage(wizardPage);
38                         if (wizardPage instanceof PropertyChangeWizardPage) {
39                                 ((PropertyChangeWizardPage) wizardPage).addPropertyChangeListener(this);
40                         }
41                 }
42                 addPage(this.finalPage);
43         }
44         
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);
50                         }
51                 }
52                 super.dispose();
53         }
54         
55         public boolean performFinish() {
56                 return true;
57         }
58
59         public void propertyChange(PropertyChangeEvent event) {
60                 if ("sqlStatement".equals(event.getPropertyName())) {
61                         this.finalPage.setSQLStatement((String) event.getNewValue());
62                 }
63         }
64 }