synchronized from quantum plugin
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / BookmarkWizard.java
index da768ff..84750ba 100644 (file)
@@ -1,13 +1,5 @@
 package com.quantum.wizards;
 
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DriverInfo;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-import com.quantum.view.bookmark.BookmarkNode;
-
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardPage;
@@ -24,19 +16,19 @@ import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.adapters.AdapterFactory;
+import com.quantum.adapters.DriverInfo;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.JDBCDriver;
+
 public class BookmarkWizard extends Wizard {
        BookmarkPage mainPage;
 
-       private Bookmark current;
-
-       public void init(BookmarkNode selection) {
-               System.out.println("Initing workbench"); //$NON-NLS-1$
-               this.current = selection.getBookmark();
-               setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
-       }
        public void init() {
                System.out.println("Initing workbench"); //$NON-NLS-1$
-               current = null;
                setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
        }
        public boolean performFinish() {
@@ -53,11 +45,9 @@ public class BookmarkWizard extends Wizard {
        }
        public void addPages() {
                System.out.println("adding pages"); //$NON-NLS-1$
-               if (current != null) {
-                       mainPage = new BookmarkPage(Messages.getString("BookmarkWizard.Testing"), current); //$NON-NLS-1$
-               } else {
-                       mainPage = new BookmarkPage(Messages.getString("BookmarkWizard.Testing")); //$NON-NLS-1$
-               }
+//             WizardPage page = new NewBookmarkPage1(Messages.getString("BookmarkWizard.Testing")); //$NON-NLS-1$
+//             addPage(page);
+               mainPage = new BookmarkPage(Messages.getString("BookmarkWizard.Testing")); //$NON-NLS-1$
                addPage(mainPage);
                System.out.println("adding pages"); //$NON-NLS-1$
        }
@@ -77,8 +67,6 @@ class BookmarkPage extends WizardPage {
        Text driverFile;
     Button prompt;
 
-       Bookmark initialData = null;
-
        FileDialog dialog;
 
        DriverInfo[] drivers = AdapterFactory.getInstance().getDriverList();
@@ -88,17 +76,7 @@ class BookmarkPage extends WizardPage {
         */
        public BookmarkPage(String pageName) {
                super(pageName);
-               initialData = null;
        }
-       /**
-        * Constructor for BookmarkPage.
-        * @param pageName
-        */
-       public BookmarkPage(String pageName, Bookmark bookmark) {
-               super(pageName);
-               this.initialData = bookmark;
-       }
-
        public void createControl(Composite parent) {
                System.out.println("page create control"); //$NON-NLS-1$
                dialog = new FileDialog(getContainer().getShell(), SWT.OPEN);
@@ -161,29 +139,6 @@ class BookmarkPage extends WizardPage {
                fullHorizontal.horizontalAlignment = GridData.FILL;
                driver.setLayoutData(fullHorizontal);
 
-               //label = new Label(container, SWT.NULL);
-               //fullHorizontal = new GridData();
-               //fullHorizontal.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
-               //fullHorizontal.verticalSpan = 3;
-               //label.setLayoutData(fullHorizontal);
-               //label.setText("(Drivers Found in File)");
-               /*driverList = new List(container, SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               fullHorizontal.verticalAlignment = GridData.FILL;
-               fullHorizontal.verticalSpan = 3;
-               driverList.setLayoutData(fullHorizontal);
-               driverList.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               String[] selection = driverList.getSelection();
-                               if (selection != null && selection.length > 0) {
-                                       driver.setText(selection[0]);
-                               }
-                       }
-               });*/
-
                label = new Label(container, SWT.NULL);
                label.setText(Messages.getString("BookmarkWizard.TypeAst")); //$NON-NLS-1$
                type = new Combo(container, SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY);
@@ -223,29 +178,6 @@ class BookmarkPage extends WizardPage {
                        }
                });
 
-//             if (initialData != null) {
-//                     name.setText(initialData.getName());
-//                     username.setText(initialData.getUsername());
-//            if (initialData.getPromptForPassword()) {
-//                this.password.setEditable(false);
-//            } else {
-//                password.setText(initialData.getPassword());
-//            }
-//                     connect.setText(initialData.getConnect());
-//                     driver.setText(initialData.getDriver());
-//                     String typeData = initialData.getType();
-//            this.prompt.setSelection(initialData.getPromptForPassword());
-//                     int selectedIndex = 0;
-//                     for (int i = 0; i < drivers.length; i++) {
-//                             if (typeData.equals(drivers[i].getDriverType())) {
-//                                     selectedIndex = i;
-//                             }
-//                     }
-//                     type.select(selectedIndex);
-//                     driverFile.setText(initialData.getDriverFile());
-//                     updateDriverList();
-//             }
-
         prompt.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(SelectionEvent event) {
                 BookmarkPage.this.password.setEditable(!prompt.getSelection());
@@ -273,9 +205,7 @@ class BookmarkPage extends WizardPage {
                        }*/
        }
        public void performFinish() {
-               if (initialData == null) {
-                       initialData = new Bookmark();
-               }
+               Bookmark initialData = new Bookmark();
                initialData.setName(name.getText());
                initialData.setUsername(username.getText());
         initialData.setPromptForPassword(this.prompt.getSelection());
@@ -286,12 +216,13 @@ class BookmarkPage extends WizardPage {
         }
                initialData.addSchema(schema.getText());
                initialData.setConnect(connect.getText());
-               initialData.setDriver(driver.getText());
+               JDBCDriver jdbcDriver = BookmarkCollection.getInstance().findDriver(
+                               driver.getText(), driverFile.getText());
+               initialData.setJDBCDriver(jdbcDriver);
                int selection = type.getSelectionIndex();
                if (selection >= 0) {
                        initialData.setType(drivers[selection].getDriverType());
                }
-               initialData.setDriverFile(driverFile.getText());
         BookmarkCollection.getInstance().addBookmark(initialData);
        }
 }
\ No newline at end of file