show HTML files as local resources (no 'http://' url prefix)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / BookmarkWizard.java
1 package com.quantum.wizards;
2
3 import java.beans.PropertyChangeEvent;
4 import java.beans.PropertyChangeListener;
5
6 import org.eclipse.jface.wizard.Wizard;
7
8 import com.quantum.Messages;
9 import com.quantum.model.Bookmark;
10 import com.quantum.model.BookmarkCollection;
11 import com.quantum.model.JDBCDriver;
12 import com.quantum.model.Schema;
13
14 public class BookmarkWizard extends Wizard implements PropertyChangeListener {
15         private JDBCDriverSelectionWizardPage page1;
16         private BookmarkConnectionWizardPage page2;
17         private BookmarkNameWizardPage page3;
18         private SchemaSelectionWizardPage page4;
19
20         private Bookmark bookmark;
21         
22         public void init() {
23                 setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
24                 this.bookmark = new Bookmark();
25         }
26         public boolean performFinish() {
27                 BookmarkCollection.getInstance().addBookmark(this.bookmark);
28                 
29                 return true;
30         }
31         public void addPages() {
32                 this.page1 = new JDBCDriverSelectionWizardPage("page1"); //$NON-NLS-1$
33                 this.page1.addPropertyChangeListener(this);
34                 addPage(this.page1);
35                 this.page2 = new BookmarkConnectionWizardPage("page2"); //$NON-NLS-1$
36                 this.page2.addPropertyChangeListener(this);
37                 addPage(this.page2);
38                 this.page3 = new BookmarkNameWizardPage("page3"); //$NON-NLS-1$
39                 this.page3.addPropertyChangeListener(this);
40                 addPage(this.page3);
41                 this.page4 = new SchemaSelectionWizardPage("page4", this.bookmark); //$NON-NLS-1$
42                 this.page4.addPropertyChangeListener(this);
43                 addPage(this.page4);
44         }
45         public void propertyChange(PropertyChangeEvent event) {
46                 
47                 if ("driver".equals(event.getPropertyName())) {
48                         JDBCDriver driver = (JDBCDriver) event.getNewValue();
49                         this.bookmark.setJDBCDriver(driver);
50                         this.page2.setDriver(driver);
51                 } else if ("name".equals(event.getPropertyName())) {
52                         this.bookmark.setName((String) event.getNewValue());
53                 } else if ("userid".equals(event.getPropertyName())) {
54                         this.bookmark.setUsername((String) event.getNewValue());
55                 } else if ("password".equals(event.getPropertyName())) {
56                         this.bookmark.setPassword((String) event.getNewValue());
57                 } else if ("connectionURL".equals(event.getPropertyName())) {
58                         this.bookmark.setConnect((String) event.getNewValue());
59                 } else if ("prompt".equals(event.getPropertyName())) {
60                         this.bookmark.setPromptForPassword(Boolean.TRUE.equals(event.getNewValue()));
61                 } else if ("schemaRule".equals(event.getPropertyName())) {
62                         this.bookmark.setSchemaRule(((Integer) event.getNewValue()).intValue());
63                 } else if ("schemas".equals(event.getPropertyName())) {
64                         this.bookmark.setSchemaSelections((Schema[]) event.getNewValue());
65                 }
66                 
67         }
68         public void dispose() {
69                 this.page1.removePropertyChangeListener(this);
70                 this.page2.removePropertyChangeListener(this);
71                 this.page3.removePropertyChangeListener(this);
72                 this.page4.removePropertyChangeListener(this);
73                 super.dispose();
74         }
75 }
76