Refactory: remove unused classes, imports, fields and methods.
[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.ImageStore;
9 import com.quantum.Messages;
10 import com.quantum.model.Bookmark;
11 import com.quantum.model.BookmarkCollection;
12 import com.quantum.model.JDBCDriver;
13 import com.quantum.model.Schema;
14
15 public class BookmarkWizard extends Wizard implements PropertyChangeListener {
16         private JDBCDriverSelectionWizardPage page1;
17         private BookmarkConnectionWizardPage page2;
18         private BookmarkNameWizardPage page3;
19         private SchemaSelectionWizardPage page4;
20
21         private Bookmark bookmark;
22         
23         public void init() {
24                 setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
25                 setDefaultPageImageDescriptor(ImageStore.getImageDescriptor(ImageStore.NEW_BOOKMARK_WIZARD));
26                 this.bookmark = new Bookmark();
27         }
28         public boolean performFinish() {
29                 BookmarkCollection.getInstance().addBookmark(this.bookmark);
30                 
31                 return true;
32         }
33         public void addPages() {
34                 this.page1 = new JDBCDriverSelectionWizardPage("page1"); //$NON-NLS-1$
35                 this.page1.addPropertyChangeListener(this);
36                 addPage(this.page1);
37                 this.page2 = new BookmarkConnectionWizardPage("page2"); //$NON-NLS-1$
38                 this.page2.addPropertyChangeListener(this);
39                 addPage(this.page2);
40                 this.page3 = new BookmarkNameWizardPage("page3"); //$NON-NLS-1$
41                 this.page3.addPropertyChangeListener(this);
42                 addPage(this.page3);
43                 this.page4 = new SchemaSelectionWizardPage("page4", this.bookmark); //$NON-NLS-1$
44                 this.page4.addPropertyChangeListener(this);
45                 addPage(this.page4);
46         }
47         public void propertyChange(PropertyChangeEvent event) {
48                 
49                 if ("driver".equals(event.getPropertyName())) {
50                         JDBCDriver driver = (JDBCDriver) event.getNewValue();
51                         this.bookmark.setJDBCDriver(driver);
52                         this.page2.setDriver(driver);
53                 } else if ("name".equals(event.getPropertyName())) {
54                         this.bookmark.setName((String) event.getNewValue());
55                 } else if ("userid".equals(event.getPropertyName())) {
56                         this.bookmark.setUsername((String) event.getNewValue());
57                 } else if ("password".equals(event.getPropertyName())) {
58                         this.bookmark.setPassword((String) event.getNewValue());
59                 } else if ("connectionURL".equals(event.getPropertyName())) {
60                         this.bookmark.setConnect((String) event.getNewValue());
61                 } else if ("prompt".equals(event.getPropertyName())) {
62                         this.bookmark.setPromptForPassword(Boolean.TRUE.equals(event.getNewValue()));
63                 } else if ("schemaRule".equals(event.getPropertyName())) {
64                         this.bookmark.setSchemaRule(((Integer) event.getNewValue()).intValue());
65                 } else if ("schemas".equals(event.getPropertyName())) {
66                         this.bookmark.setSchemaSelections((Schema[]) event.getNewValue());
67                 }
68                 
69         }
70         public void dispose() {
71                 this.page1.removePropertyChangeListener(this);
72                 this.page2.removePropertyChangeListener(this);
73                 this.page3.removePropertyChangeListener(this);
74                 this.page4.removePropertyChangeListener(this);
75                 super.dispose();
76         }
77 }
78