synchronized from quantum plugin
authorkhartlage <khartlage>
Tue, 8 Jun 2004 19:53:14 +0000 (19:53 +0000)
committerkhartlage <khartlage>
Tue, 8 Jun 2004 19:53:14 +0000 (19:53 +0000)
24 files changed:
archive/net.sourceforge.phpeclipse.quantum.sql/icons/class.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/driver.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum32.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/extensions/ExtensionAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/xml/ModelToXMLConverter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/xml/XMLHelper.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/xml/XMLRenderer.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverContentProvider.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverView.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/PHPSourceConsole.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PHPDeleteRowPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PHPInsertRowPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PHPSelectRowPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PHPUpdateRowPage.java

diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/class.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/class.gif
new file mode 100644 (file)
index 0000000..4cebb10
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/class.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/driver.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/driver.gif
new file mode 100644 (file)
index 0000000..c40c4e5
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/driver.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif
new file mode 100644 (file)
index 0000000..b27e10a
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum32.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum32.gif
new file mode 100644 (file)
index 0000000..1aee702
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum32.gif differ
index 140a149..2ef70c3 100644 (file)
@@ -148,7 +148,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
 
             FileWriter writer =  new FileWriter(target);
             try {
-                XMLHelper.createDOMSerializer(writer).serialize(document);
+                XMLHelper.write(writer, document);
                } finally {
                        writer.close();
                }
index 06a897b..4d58eff 100644 (file)
@@ -30,10 +30,6 @@ tableview.close = Close Table
 tableview.update = Update...
 tableview.insert = Insert...
 tableview.delete = Delete...
-tableview.phpselect = PHP Select...
-tableview.phpupdate = PHP Update...
-tableview.phpinsert = PHP Insert...
-tableview.phpdelete = PHP Delete...
 tableview.filterSort = Sort or Filter Table...
 tableview.showAll = Toggle Show All Table Rows
 tableview.defaultEncoding = Set Default Encoding
@@ -43,6 +39,10 @@ tableview.QuantumTableViewName=Quantum Table View
 tableview.ViewNameFinalDecoration=)
 tableview.BookmarkSeparator=:
 tableview.ViewNameInitialDecoration=\ (
+tableview.phpselect = PHP Select...
+tableview.phpupdate = PHP Update...
+tableview.phpinsert = PHP Insert...
+tableview.phpdelete = PHP Delete...
 filedialog.preferences = Preferences (*.ini)
 filedialog.allfiles = All Files (*.*)
 filedialog.sqlFiles = SQL query (*.sql)
@@ -288,3 +288,18 @@ com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.SQLException.title=SQL Exc
 com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.SQLException.message=An SQL Exception was encountered while trying to process your request.
 BookmarkWizard.Error=Error
 BookmarkWizard.bookmarkAlreadyExists=The selected bookmark name already exists.
+
+com.quantum.wizards.NewBookmarkPage1.driverColumn0=JDBC Driver Name
+com.quantum.wizards.NewBookmarkPage1.driverColumn1=Driver Class Name
+com.quantum.wizards.NewBookmarkPage1.driverColumn2=Version
+com.quantum.wizards.NewBookmarkPage1.driverColumn3=File Path
+
+com.quantum.view.JDBCDriverTableViewer.driverColumn0=JDBC Driver Name
+com.quantum.view.JDBCDriverTableViewer.driverColumn1=Driver Class Name
+com.quantum.view.JDBCDriverTableViewer.driverColumn2=Version
+com.quantum.view.JDBCDriverTableViewer.driverColumn3=File Path
+
+com.quantum.ui.dialog.AddDriverDialog.title=Add Driver
+com.quantum.ui.dialog.AddDriverDialog.browse=Browse
+com.quantum.ui.dialog.AddDriverDialog.fileName=File name:
+com.quantum.ui.dialog.AddDriverDialog.driverClassName=Class name:
index 50a35db..f3efb58 100644 (file)
@@ -110,7 +110,7 @@ public class ExtensionAction extends SelectionListenerAction {
                
                StringWriter text = new StringWriter();
                try {
-                       XMLHelper.createDOMSerializer(text).serialize(doc);
+                       XMLHelper.write(text, doc);
                } catch (IOException e) {
                        e.printStackTrace();
                }
index 908b239..fc282e6 100644 (file)
@@ -4,6 +4,7 @@ import com.quantum.Messages;
 import com.quantum.model.Bookmark;
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
+import com.quantum.model.JDBCDriver;
 import com.quantum.model.Schema;
 import com.quantum.sql.metadata.MetaDataXMLInterface;
 
@@ -28,6 +29,15 @@ public class ModelToXMLConverter {
     public void createRoot(Document document) {
         document.appendChild(document.createElement("SAVED_DATA"));
     }
+    public void convert(Element bookmarkRoot, JDBCDriver jdbcDriver) {
+        Document document = bookmarkRoot.getOwnerDocument();
+        Element driverNode = document.createElement("jdbcDriver");
+        driverNode.setAttribute("name", jdbcDriver.getName());
+        driverNode.setAttribute("version", jdbcDriver.getVersion());
+        driverNode.setAttribute("jarFileName", jdbcDriver.getJarFileName());
+        driverNode.setAttribute("className", jdbcDriver.getClassName());
+        bookmarkRoot.appendChild(driverNode);
+    }
 
     public void convert(Element bookmarkRoot, Bookmark b) {
         Document document = bookmarkRoot.getOwnerDocument();
@@ -39,9 +49,9 @@ public class ModelToXMLConverter {
         MetaDataXMLInterface.createElementText(bookmark,"connect", b.getConnect()); //$NON-NLS-1$
                MetaDataXMLInterface.createElementText(bookmark,"autoCommit", b.isAutoCommit() ? "true" : "false"); //$NON-NLS-1$
                MetaDataXMLInterface.createElementText(bookmark,"autoCommitPreference", b.getAutoCommitPreference()); //$NON-NLS-1$
-        MetaDataXMLInterface.createElementText(bookmark,"driver", b.getDriver()); //$NON-NLS-1$
+        MetaDataXMLInterface.createElementText(bookmark,"driver", b.getJDBCDriver().getClassName()); //$NON-NLS-1$
         MetaDataXMLInterface.createElementText(bookmark,"type", b.getType()); //$NON-NLS-1$
-               MetaDataXMLInterface.createElementText(bookmark,"driverLocation", b.getDriverFile()); //$NON-NLS-1$
+               MetaDataXMLInterface.createElementText(bookmark,"driverLocation", b.getJDBCDriver().getJarFileName()); //$NON-NLS-1$
         Element otherSchemas = (Element) bookmark.appendChild(document.createElement(Messages.getString("ExportXMLAction.OtherSchemas"))); //$NON-NLS-1$
         Schema[] schemas = b.getSchemas();
         for (int i = 0, length = (schemas == null) ? 0 : schemas.length;
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java
new file mode 100644 (file)
index 0000000..bcab770
--- /dev/null
@@ -0,0 +1,124 @@
+package com.quantum.ui.dialog;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.util.JarUtil;
+
+/**
+ * @author BC
+ */
+public class AddDriverDialog extends Dialog {
+
+       private FileDialog fileDialog;
+
+       private Text driverFileName;
+       private Text driverClassName;
+
+       
+       /**
+        * @param parentShell
+        */
+       public AddDriverDialog(Shell parentShell) {
+               super(parentShell);
+       }
+
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               shell.setText(Messages.getString(getClass(), "title"));
+       }
+       
+    /* (non-Javadoc)
+     * Method declared on Dialog
+     */
+    protected Control createDialogArea(Composite parent) {
+       parent.setLayout(new GridLayout());
+        Composite composite = (Composite) super.createDialogArea(parent);
+               GridLayout layout = new GridLayout();
+               composite.setLayout(layout);
+               layout.numColumns = 3;
+               GridData fullHorizontal = new GridData(
+                               GridData.HORIZONTAL_ALIGN_BEGINNING,
+                               GridData.VERTICAL_ALIGN_BEGINNING, 
+                               true, false);
+               composite.setLayoutData(fullHorizontal);
+               
+
+               this.fileDialog = new FileDialog(composite.getShell(), SWT.OPEN);
+               this.fileDialog.setFilterExtensions(new String[] { "*.jar", "*.zip", "*.*" });
+               this.fileDialog.setFilterNames(new String[] {
+                               Messages.getString("BookmarkWizard.JarFiles"),
+                               Messages.getString("BookmarkWizard.ZipFiles"),
+                               Messages.getString("BookmarkWizard.AllFiles") });
+
+               Label label = new Label(composite, SWT.NULL);
+               label.setText(Messages.getString(getClass(), "fileName"));
+               this.driverFileName = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               fullHorizontal = new GridData(
+                               GridData.HORIZONTAL_ALIGN_FILL,
+                               GridData.VERTICAL_ALIGN_BEGINNING, 
+                               true, false);
+               fullHorizontal.widthHint = 150;
+               this.driverFileName.setLayoutData(fullHorizontal);
+
+               Button button = new Button(composite, SWT.PUSH);
+               button.setText(Messages.getString(getClass(), "browse"));
+
+               button.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               AddDriverDialog.this.fileDialog.setFilterPath(QuantumPlugin.getDefault()
+                                               .getPreferenceStore().getString(
+                                                               "quantum.dialogs.bookmarkwizard.path"));
+                               String filename = AddDriverDialog.this.fileDialog.open();
+                               if (filename != null) {
+                                       AddDriverDialog.this.driverFileName.setText(filename);
+                                       QuantumPlugin.getDefault().getPreferenceStore().setValue(
+                                                       "quantum.dialogs.bookmarkwizard.path", filename);
+                               }
+                       }
+               });
+
+               label = new Label(composite, SWT.NULL);
+               label.setText(Messages.getString(getClass(), "driverClassName"));
+               this.driverClassName = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               fullHorizontal = new GridData(
+                               GridData.HORIZONTAL_ALIGN_FILL,
+                               GridData.VERTICAL_ALIGN_BEGINNING, 
+                               true, false);
+               fullHorizontal.widthHint = 150;
+               this.driverClassName.setLayoutData(fullHorizontal);
+
+               button = new Button(composite, SWT.PUSH);
+               button.setText(Messages.getString(getClass(), "browse"));
+
+               button.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               SimpleSelectionDialog dialog = new SimpleSelectionDialog(
+                                               getShell(), "Select a Driver", JarUtil.getAllDriverNames(
+                                                               getDriverFile()), QuantumPlugin.getImage("class.gif"));
+                               if (dialog.open() == SimpleSelectionDialog.OK) {
+                                       AddDriverDialog.this.driverClassName.setText(
+                                                       dialog.getSelectedElement());
+                               }
+                       }
+               });
+               return composite;
+    }
+    
+    protected String getDriverFile() {
+       return this.driverFileName.getText();
+    }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java
new file mode 100644 (file)
index 0000000..311b217
--- /dev/null
@@ -0,0 +1,127 @@
+package com.quantum.ui.dialog;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * @author BC
+ */
+public class SimpleSelectionDialog extends Dialog {
+       
+       class LabelProvider implements ITableLabelProvider {
+
+               public Image getColumnImage(Object element, int columnIndex) {
+                       return SimpleSelectionDialog.this.image;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       return (String) element;
+               }
+
+               public void addListener(ILabelProviderListener listener) {
+               }
+
+               public void dispose() {
+               }
+
+               public boolean isLabelProperty(Object element, String property) {
+                       return false;
+               }
+
+               public void removeListener(ILabelProviderListener listener) {
+               }
+       }
+       
+       class ContentProvider implements IStructuredContentProvider {
+
+               public Object[] getElements(Object inputElement) {
+                       return SimpleSelectionDialog.this.objects;
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+               
+       }
+
+       private final String title;
+       private TableViewer viewer;
+       private final Image image;
+       private final String[] objects;
+       
+       private String selectedElement = null;
+
+       /**
+        * @param parentShell
+        */
+       protected SimpleSelectionDialog(Shell parentShell, String title, 
+                       String[] objects, Image image) {
+               super(parentShell);
+               this.title = title;
+               this.objects = objects;
+               this.image = image;
+       }
+
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+        shell.setText(title);
+        GridLayout layout = new GridLayout();
+        shell.setLayout(layout);
+    }
+        
+    protected Control createDialogArea(Composite parent) {
+
+        Composite composite = new Composite(parent, 0);
+        GridLayout layout = new GridLayout();
+        composite.setLayout(layout);
+        layout.numColumns = 1;
+        layout.verticalSpacing = 1;
+        
+        this.viewer = new TableViewer(composite);
+        GridData full = new GridData(GridData.FILL_HORIZONTAL);
+        full.widthHint = 200;
+        full.heightHint = 50;
+        this.viewer.getControl().setLayoutData(full);
+        
+        this.viewer.setLabelProvider(new LabelProvider());
+        this.viewer.setContentProvider(new ContentProvider());
+
+        this.viewer.setInput(this);
+
+        return composite;
+    }
+    
+       
+       protected void okPressed() {
+               
+        IStructuredSelection selection = (IStructuredSelection) this.viewer.getSelection();
+        this.selectedElement = (String) selection.getFirstElement();
+        super.okPressed();
+       }
+       /**
+        * @return Returns the selectedElement.
+        */
+       public String getSelectedElement() {
+               return this.selectedElement;
+       }
+       /**
+        * @param selectedElement The selectedElement to set.
+        */
+       public void setSelectedElement(String selectedElement) {
+               this.selectedElement = selectedElement;
+       }
+}
index 9fdeeef..2e78469 100644 (file)
@@ -10,8 +10,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.FactoryConfigurationError;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.xalan.serialize.DOMSerializer;
-import org.apache.xalan.serialize.SerializerToXML;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -25,30 +23,6 @@ public class XMLHelper {
     
     private XMLHelper() {}
     
-    public static DOMSerializer createDOMSerializer(Writer writer) 
-        throws IOException {
-//      XMLSerializer serializer = new XMLSerializer(writer, createOutputFormat());
-//     return serializer.asDOMSerializer();
-       SerializerToXML serializer = new SerializerToXML();
-        serializer.setWriter(writer);
-        return serializer.asDOMSerializer();
-    }
-
-    public static DOMSerializer createDOMSerializer(OutputStream stream) 
-        throws IOException {
-//      XMLSerializer serializer = new XMLSerializer(stream, createOutputFormat());
-//      return serializer.asDOMSerializer();
-        SerializerToXML serializer = new SerializerToXML();
-        serializer.setOutputStream(stream);
-        return serializer.asDOMSerializer();
-    }
-//    private static OutputFormat createOutputFormat() {
-//        OutputFormat format = new OutputFormat();
-//        format.setIndenting(true);
-//        format.setLineWidth(80);
-//        return format;
-//    }
-    
     public static Document createEmptyDocument() throws ParserConfigurationException {
         DocumentBuilder builder = createDocumentBuilder();
         return builder.newDocument();
@@ -68,11 +42,11 @@ public class XMLHelper {
     
     public static void write(Writer writer, Document document) 
         throws IOException {
-        createDOMSerializer(writer).serialize(document);
+        writer.write(XMLRenderer.render(document));
     }
 
     public static void write(OutputStream stream, Document document) 
         throws IOException {
-        createDOMSerializer(stream).serialize(document);
+        stream.write(XMLRenderer.render(document).getBytes());
     }
 }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/xml/XMLRenderer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/xml/XMLRenderer.java
new file mode 100644 (file)
index 0000000..4bd4632
--- /dev/null
@@ -0,0 +1,225 @@
+package com.quantum.util.xml;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author BC Holmes
+ */
+public class XMLRenderer {
+
+    protected boolean insertNewLine = false;
+    protected int numberOfTabs;
+
+    protected final static String LINE_SEPARATOR = System
+            .getProperty("line.separator");
+
+    protected final static String INDENT_STRING = "\t";
+
+    /** Returns a sorted list of attributes. */
+    protected Attr[] sortAttributes(NamedNodeMap attrs) {
+
+        int len = (attrs != null) ? attrs.getLength() : 0;
+        Attr array[] = new Attr[len];
+        for (int i = 0; i < len; i++) {
+            array[i] = (Attr) attrs.item(i);
+        }
+        for (int i = 0; i < len - 1; i++) {
+            String name = array[i].getNodeName();
+            int index = i;
+            for (int j = i + 1; j < len; j++) {
+                String curName = array[j].getNodeName();
+                if (curName.compareTo(name) < 0) {
+                    name = curName;
+                    index = j;
+                }
+            }
+            if (index != i) {
+                Attr temp = array[i];
+                array[i] = array[index];
+                array[index] = temp;
+            }
+        }
+
+        return (array);
+
+    }
+
+    protected XMLRenderer() {
+        this.numberOfTabs = 0;
+        this.insertNewLine = true;
+    }
+
+    protected void newLine(StringBuffer buffer) {
+        if (this.insertNewLine) {
+            buffer.append(LINE_SEPARATOR);
+            for (int i = 0; i < this.numberOfTabs; i++) {
+                buffer.append(INDENT_STRING);
+            }
+        }
+    }
+
+    /** Prints the specified node, recursively. */
+    protected void print(Node node, StringBuffer buffer) {
+        // is there anything to do?
+        if (node != null) {
+            int type = node.getNodeType();
+            switch (type) {
+
+            case Node.DOCUMENT_NODE:
+                printDocumentNode(node, buffer);
+                break;
+
+            // print element with attributes
+            case Node.ELEMENT_NODE:
+                printElementNode(node, buffer);
+                break;
+            // handle entity reference nodes
+            case Node.ENTITY_REFERENCE_NODE:
+                printEntityReferenceNode(node, buffer);
+                break;
+
+            // print cdata sections
+            case Node.CDATA_SECTION_NODE:
+                printCDataSectionNode(node, buffer);
+                break;
+
+            // print text
+            case Node.TEXT_NODE:
+                printTextNode(node, buffer);
+                break;
+
+            // print processing instruction
+            case Node.PROCESSING_INSTRUCTION_NODE:
+                printProcessingInstructionNode(node, buffer);
+                break;
+            }
+        }
+    }
+
+    protected void printProcessingInstructionNode(Node node, StringBuffer buffer) {
+        buffer.append("<?");
+        buffer.append(node.getNodeName());
+        String data = node.getNodeValue();
+        if (data != null && data.length() > 0) {
+            buffer.append(' ');
+            buffer.append(data);
+        }
+        buffer.append("?>");
+    }
+
+    protected void printTextNode(Node node, StringBuffer buffer) {
+        printString(node.getNodeValue(), buffer);
+        this.insertNewLine = false;
+    }
+
+    protected void printCDataSectionNode(Node node, StringBuffer buffer) {
+        buffer.append("<![CDATA[");
+        buffer.append(node.getNodeValue());
+        buffer.append("]]>");
+    }
+
+    protected void printEntityReferenceNode(Node node, StringBuffer buffer) {
+        buffer.append('&');
+        buffer.append(node.getNodeName());
+        buffer.append(';');
+    }
+
+    protected void printElementNode(Node node, StringBuffer buffer) {
+        newLine(buffer);
+        this.numberOfTabs++;
+        buffer.append('<');
+        buffer.append(node.getNodeName());
+        Attr attrs[] = sortAttributes(node.getAttributes());
+        for (int i = 0; i < attrs.length; i++) {
+            Attr attr = attrs[i];
+            buffer.append(' ');
+            buffer.append(attr.getNodeName());
+            buffer.append("=\"");
+            printString(attr.getNodeValue(), buffer);
+            buffer.append('"');
+        }
+
+        if (!node.hasChildNodes()) {
+            buffer.append(" />");
+            this.numberOfTabs--;
+        } else {
+            buffer.append(">");
+            printAllChildNodes(node, buffer);
+            this.numberOfTabs--;
+            newLine(buffer);
+
+            buffer.append("</");
+            buffer.append(node.getNodeName());
+            buffer.append(">");
+        }
+        this.insertNewLine = true;
+    }
+
+    protected void printDocumentNode(Node node, StringBuffer buffer) {
+        buffer.append("<?xml version=\"1.0\" ?>");
+
+        printAllChildNodes(node, buffer);
+    }
+
+    protected void printAllChildNodes(Node node, StringBuffer buffer) {
+        NodeList children = node.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            print(children.item(i), buffer);
+        }
+    }
+
+    /** Normalizes the given string. */
+    protected void printString(String s, StringBuffer buffer) {
+
+        int len = (s != null) ? s.length() : 0;
+        for (int i = 0; i < len; i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+            case '<': {
+                buffer.append("&lt;");
+                break;
+            }
+            case '>': {
+                buffer.append("&gt;");
+                break;
+            }
+            case '&': {
+                buffer.append("&amp;");
+                break;
+            }
+            case '"':
+                buffer.append("&quot;");
+                break;
+            case '\r':
+            case '\n':
+            default: {
+                buffer.append(ch);
+            }
+            }
+        }
+    }
+
+    public static String render(Node node) {
+        XMLRenderer renderer = new XMLRenderer();
+        StringBuffer buffer = new StringBuffer();
+        renderer.print(node, buffer);
+
+        return buffer.toString();
+    }
+
+    /**
+     * <p>
+     * Renders a String in a format that it would appear in a text node. That is
+     * to say, special characters (such as &amp;) are converted into entity
+     * references (&amp;amp;).
+     */
+    public static String render(String string) {
+        XMLRenderer renderer = new XMLRenderer();
+        StringBuffer buffer = new StringBuffer();
+        renderer.printString(string, buffer);
+        return buffer.toString();
+    }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverContentProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverContentProvider.java
new file mode 100644 (file)
index 0000000..ea96414
--- /dev/null
@@ -0,0 +1,28 @@
+package com.quantum.view;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import com.quantum.model.BookmarkCollection;
+
+
+/**
+ * @author BC
+ */
+public class JDBCDriverContentProvider implements IStructuredContentProvider {
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+
+       public Object[] getElements(Object inputElement) {
+               if (inputElement == BookmarkCollection.getInstance()) {
+                       return BookmarkCollection.getInstance().getJDBCDrivers();
+               } else {
+                       return null;
+               }
+       }
+
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java
new file mode 100644 (file)
index 0000000..ca2f50f
--- /dev/null
@@ -0,0 +1,51 @@
+package com.quantum.view;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import com.quantum.QuantumPlugin;
+import com.quantum.model.JDBCDriver;
+
+
+/**
+ * @author BC
+ */
+public class JDBCDriverLabelProvider implements ITableLabelProvider {
+
+       public Image getColumnImage(Object element, int columnIndex) {
+               if (columnIndex == 0) {
+                       return QuantumPlugin.getImage("driver.gif");
+               } else {
+                       return null;
+               }
+       }
+
+       public String getColumnText(Object element, int columnIndex) {
+               switch (columnIndex) {
+               case 0: 
+                       return ((JDBCDriver) element).getName();
+               case 1: 
+                       return ((JDBCDriver) element).getClassName();
+               case 2: 
+                       return ((JDBCDriver) element).getVersion();
+               case 3: 
+                       return ((JDBCDriver) element).getJarFileName();
+               }
+               return null;
+       }
+
+       public void addListener(ILabelProviderListener listener) {
+       }
+
+       public void dispose() {
+       }
+
+       public boolean isLabelProperty(Object element, String property) {
+               return false;
+       }
+
+       public void removeListener(ILabelProviderListener listener) {
+       }
+
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java
new file mode 100644 (file)
index 0000000..05cd697
--- /dev/null
@@ -0,0 +1,80 @@
+package com.quantum.view;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import com.quantum.Messages;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.JDBCDriver;
+
+
+/**
+ * @author BC
+ */
+public class JDBCDriverTableViewer implements PropertyChangeListener {
+
+       private TableViewer tableViewer;
+       
+       public JDBCDriverTableViewer(Composite container) {
+               Table table = new Table(container, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+        table.setHeaderVisible(true);
+        for (int i = 0, length = 4; i < length; i++) {
+            TableColumn column = new TableColumn(table, SWT.NONE);
+            column.setText(Messages.getString(getClass(), "driverColumn" + i));
+        }
+               
+        for (int i = 0, length = 4; i < length; i++) {
+            table.getColumn(i).pack();
+        }
+               
+               this.tableViewer = new TableViewer(table);
+               this.tableViewer.setContentProvider(new JDBCDriverContentProvider());
+               this.tableViewer.setLabelProvider(new JDBCDriverLabelProvider());
+               this.tableViewer.setColumnProperties(new String[] { "name", "className", "version", "jarFileName" });
+               this.tableViewer.setInput(BookmarkCollection.getInstance());
+               
+               BookmarkCollection.getInstance().addPropertyChangeListener(this);
+               registerWithAllDrivers();
+       }
+       /**
+        * 
+        */
+       private void registerWithAllDrivers() {
+               JDBCDriver[] drivers = BookmarkCollection.getInstance().getJDBCDrivers();
+               for (int i = 0, length = drivers == null ? 0 : drivers.length; i < length; i++) {
+                       drivers[i].addPropertyChangeListener(this);
+               }
+       }
+       /**
+        * @return
+        */
+       public Control getControl() {
+               return this.tableViewer.getControl();
+       }
+       /* (non-Javadoc)
+        * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               if ("drivers".equals(event.getPropertyName())) {
+                       registerWithAllDrivers();
+                       this.tableViewer.refresh();
+               } else if (event.getSource() instanceof JDBCDriver) {
+                       this.tableViewer.refresh(event.getSource());
+               }
+       }
+       
+       public void dispose() {
+               JDBCDriver[] drivers = BookmarkCollection.getInstance().getJDBCDrivers();
+               for (int i = 0, length = drivers == null ? 0 : drivers.length; i < length; i++) {
+                       drivers[i].removePropertyChangeListener(this);
+               }
+               BookmarkCollection.getInstance().removePropertyChangeListener(this);
+       }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverView.java
new file mode 100644 (file)
index 0000000..31e75b5
--- /dev/null
@@ -0,0 +1,30 @@
+package com.quantum.view;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * @author BC
+ */
+public class JDBCDriverView extends ViewPart {
+       
+       private JDBCDriverTableViewer viewer;
+
+       public void createPartControl(Composite parent) {
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 1;
+               parent.setLayout(layout);
+               this.viewer = new JDBCDriverTableViewer(parent);
+               this.viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+       }
+
+       public void setFocus() {
+       }
+       public void dispose() {
+               this.viewer.dispose();
+               super.dispose();
+       }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/PHPSourceConsole.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/PHPSourceConsole.java
deleted file mode 100644 (file)
index 42c2956..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.quantum.view;
-
-/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
-       IBM Corporation - Initial implementation
-       Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-
-/**
- * The PHPSourceConsole is used to display the output from the PHP SQL wizards
- * @see ViewPart
- */
-public class PHPSourceConsole extends ViewPart {
-
-  public static final String CONSOLE_ID =
-       "net.sourceforge.phpdt.sql.view.phpsourceconsoleview";
-
-  TextViewer viewer = null;
-  private Document document = null;
-
-  /**
-   * The constructor.
-   */
-  public PHPSourceConsole() {
-  }
-
-  /**
-   * Insert the method's description here.
-   * @see ViewPart#createPartControl
-   */
-  public void createPartControl(Composite parent) {
-       viewer = new TextViewer(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
-       GridData viewerData = new GridData(GridData.FILL_BOTH);
-       viewer.getControl().setLayoutData(viewerData);
-       viewer.setEditable(false);
-
-       StyledText widget = viewer.getTextWidget();
-       widget.setFont(
-         JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
-       Action cutAction = new Action() {
-         public void run() {
-               viewer.getTextWidget().cut();
-         }
-       };
-       Action copyAction = new Action() {
-         public void run() {
-               viewer.getTextWidget().copy();
-         }
-       };
-       Action pasteAction = new Action() {
-         public void run() {
-               viewer.getTextWidget().paste();
-         }
-       };
-
-       IActionBars bars = this.getViewSite().getActionBars();
-       bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction);
-       bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyAction);
-       bars.setGlobalActionHandler(IWorkbenchActionConstants.PASTE, pasteAction);
-  }
-
-  /**
-   * Insert the method's description here.
-   * @see ViewPart#setFocus
-   */
-  public void setFocus() {
-  }
-
-  /**
-   * Set the text for the viewer
-   */
-  private void setOutputText(String text) {
-       document = new Document(text);
-       viewer.setDocument(document);
-  }
-
-  private void appendOutputText(String text) {
-       try {
-         if (document == null) {
-               document = new Document(text);
-               viewer.setDocument(document);
-         }
-         document.replace(document.getLength(), 0, text);
-       } catch (BadLocationException e) {
-       }
-       //  viewer.setDocument(document);
-  }
-
-  public static PHPSourceConsole getInstance() {
-       IWorkbenchPage page =
-         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-       PHPSourceConsole console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID);
-       // if (PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) {
-
-       try {
-         page.showView(PHPSourceConsole.CONSOLE_ID);
-         if (console == null) { 
-               console = (PHPSourceConsole) page.findView(PHPSourceConsole.CONSOLE_ID);
-         }
-       } catch (PartInitException e) {
-         QuantumPlugin.getDefault().getLog().log(
-               new Status(
-                 IStatus.ERROR,
-                 QuantumPlugin.PLUGIN_ID,  
-                 0,
-                 Messages.getString("sqlconsole.viewopeningproblem"),
-                 e));
-       }
-
-       //   }
-       return console;
-  }
-
-  /**
-   * Prints out the string represented by the string buffer
-   */
-  public synchronized void print(String output) {
-       appendOutputText(output);
-  }
-
-  /**
-   * Prints out the string represented by the string buffer
-   */
-  public synchronized void println(String output) {
-       appendOutputText(output+'\n');
-  }
-
-  public synchronized void clear() {
-       setOutputText("");
-  }
-}
index 5978426..ec24e79 100644 (file)
@@ -64,7 +64,7 @@ final class CopyAction extends SelectionListenerAction {
                        ModelToXMLConverter.getInstance().convert(root, ((EntityNode) selection).getEntity());
                        StringWriter text = new StringWriter();
                        try {
-                    XMLHelper.createDOMSerializer(text).serialize(doc);
+                    XMLHelper.write(text, doc);
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
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
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java
new file mode 100644 (file)
index 0000000..89bb37f
--- /dev/null
@@ -0,0 +1,170 @@
+package com.quantum.wizards;
+
+import java.io.File;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.ui.dialog.AddDriverDialog;
+import com.quantum.view.JDBCDriverContentProvider;
+import com.quantum.view.JDBCDriverLabelProvider;
+
+/**
+ * @author BC
+ */
+public class NewBookmarkPage1 extends WizardPage {
+
+       private FileDialog fileDialog;
+
+       private Text driverFileName;
+       
+       private TableViewer tableViewer;
+
+       /**
+        * @param pageName
+        */
+       protected NewBookmarkPage1(String pageName) {
+               super(pageName);
+       }
+
+       public void createControl(Composite parent) {
+               Composite container = createBasicContainer(parent, 1);
+               GridLayout layout = new GridLayout(2, false);
+               container.setLayout(layout);
+               
+               Label label = new Label(container, SWT.NONE);
+               label.setText("Select a driver");
+               GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               data.horizontalSpan = 2;
+               label.setLayoutData(data);
+               
+               Table table = new Table(container, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+        table.setHeaderVisible(true);
+        for (int i = 0, length = 4; i < length; i++) {
+            TableColumn column = new TableColumn(table, SWT.NONE);
+            column.setText(Messages.getString(getClass(), "driverColumn" + i));
+        }
+               
+        for (int i = 0, length = 4; i < length; i++) {
+            table.getColumn(i).pack();
+        }
+               
+               this.tableViewer = new TableViewer(table);
+               data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+               this.tableViewer.getControl().setLayoutData(data);
+               this.tableViewer.setContentProvider(new JDBCDriverContentProvider());
+               this.tableViewer.setLabelProvider(new JDBCDriverLabelProvider());
+               this.tableViewer.setColumnProperties(new String[] { "name", "className", "version", "jarFileName" });
+//             Table table = ((Table) this.tableViewer.getControl());
+               this.tableViewer.setInput(BookmarkCollection.getInstance());
+               
+               
+               Button newDriver = new Button(container, SWT.PUSH);
+               newDriver.setText("Add driver...");
+               newDriver.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                       AddDriverDialog dialog = new AddDriverDialog(getShell());
+                       dialog.open();
+                       }
+               });
+               data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               newDriver.setLayoutData(data);
+               
+               setControl(container);
+       }
+
+       /**
+        * @param parent
+        */
+       private Composite createBasicContainer(Composite parent, int numberOfColumns) {
+               Composite container = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               container.setLayout(layout);
+               layout.numColumns = numberOfColumns;
+               layout.verticalSpacing = 9;
+               GridData fullHorizontal = new GridData(
+                               GridData.HORIZONTAL_ALIGN_BEGINNING,
+                               GridData.VERTICAL_ALIGN_BEGINNING, 
+                               true, false);
+               container.setLayoutData(fullHorizontal);
+               return container;
+       }
+
+       /**
+        * @param parent
+        * @return
+        */
+       private Composite createNewDriverSelection(Composite parent) {
+               this.fileDialog = new FileDialog(getContainer().getShell(), SWT.OPEN);
+               this.fileDialog.setFilterExtensions(new String[] { "*.jar", "*.zip", "*.*" });
+               this.fileDialog.setFilterNames(new String[] {
+                               Messages.getString("BookmarkWizard.JarFiles"),
+                               Messages.getString("BookmarkWizard.ZipFiles"),
+                               Messages.getString("BookmarkWizard.AllFiles") });
+
+               Composite container = createBasicContainer(parent, 3);
+
+               Label label = new Label(container, SWT.NULL);
+               label.setText(Messages.getString("BookmarkWizard.DriverAst")); //$NON-NLS-1$
+               this.driverFileName = new Text(container, SWT.BORDER | SWT.SINGLE);
+               GridData fullHorizontal = new GridData(
+                               GridData.HORIZONTAL_ALIGN_BEGINNING,
+                               GridData.VERTICAL_ALIGN_BEGINNING, 
+                               false, false);
+               this.driverFileName.setLayoutData(fullHorizontal);
+
+               Button button = new Button(container, SWT.PUSH);
+               button.setText(Messages.getString("BookmarkWizard.Browse")); //$NON-NLS-1$
+
+               button.addSelectionListener(new SelectionListener() {
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+
+                       public void widgetSelected(SelectionEvent e) {
+                               NewBookmarkPage1.this.fileDialog.setFilterPath(QuantumPlugin.getDefault()
+                                               .getPreferenceStore().getString(
+                                                               "quantum.dialogs.bookmarkwizard.path"));
+                               String filename = NewBookmarkPage1.this.fileDialog.open();
+                               if (filename != null) {
+                                       NewBookmarkPage1.this.driverFileName.setText(filename);
+                                       QuantumPlugin.getDefault().getPreferenceStore().setValue(
+                                                       "quantum.dialogs.bookmarkwizard.path", filename);
+                               }
+                       }
+               });
+               return container;
+       }
+
+       //      public boolean isPageComplete() {
+       //              File file = getDriverFile();
+       //              if (file == null) {
+       //                      return false;
+       //              } else if (!file.exists() || !file.isFile()) {
+       //                      return false;
+       //              } else {
+       //                      return true;
+       //              }
+       //      }
+       //      
+       private File getDriverFile() {
+               return (this.driverFileName == null || this.driverFileName.getText() == null) ? null
+                               : new File(this.driverFileName.getText());
+       }
+}
\ No newline at end of file
index 8b48541..6dc8db2 100644 (file)
@@ -5,6 +5,8 @@ import java.text.MessageFormat;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
@@ -18,7 +20,7 @@ import org.eclipse.swt.widgets.Text;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.sql.TableRow;
-import com.quantum.view.PHPSourceConsole;
+//import com.quantum.view.PHPSourceConsole;
 import com.quantum.view.tableview.TableAdapter;
 
 public class PHPDeleteRowPage extends WizardPage implements SQLPage {
@@ -166,9 +168,12 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage {
     this.query.setText(query);
   }
   public boolean performFinish() {
-    PHPSourceConsole console = PHPSourceConsole.getInstance();
-    console.clear();
-    console.print(query.getText());
+//    PHPSourceConsole console = PHPSourceConsole.getInstance();
+//    console.clear();
+//    console.print(query.getText());
+    QuantumPlugin.getDefault().getSysClip().setContents(
+                       new Object[] { query.getText() },
+                       new Transfer[] { TextTransfer.getInstance()});
     return true;
   }
 }
\ No newline at end of file
index 4e850b7..3436157 100644 (file)
@@ -5,6 +5,8 @@ import java.text.MessageFormat;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.layout.GridData;
@@ -15,7 +17,7 @@ import org.eclipse.swt.widgets.Text;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.sql.TableRow;
-import com.quantum.view.PHPSourceConsole;
+//import com.quantum.view.PHPSourceConsole;
 import com.quantum.view.tableview.TableAdapter;
 
 public class PHPInsertRowPage extends WizardPage implements SQLPage {
@@ -136,9 +138,12 @@ public class PHPInsertRowPage extends WizardPage implements SQLPage {
     this.query.setText(query);
   }
   public boolean performFinish() {
-    PHPSourceConsole console = PHPSourceConsole.getInstance();
-    console.clear();
-    console.print(query.getText());
+//    PHPSourceConsole console = PHPSourceConsole.getInstance();
+//    console.clear();
+//    console.print(query.getText());
+       QuantumPlugin.getDefault().getSysClip().setContents(
+                       new Object[] { query.getText() },
+                       new Transfer[] { TextTransfer.getInstance()});
     return true;
   }
 }
\ No newline at end of file
index 05cb2d4..2f9e545 100644 (file)
@@ -5,6 +5,8 @@ import java.text.MessageFormat;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
@@ -18,7 +20,7 @@ import org.eclipse.swt.widgets.Text;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.sql.TableRow;
-import com.quantum.view.PHPSourceConsole;
+//import com.quantum.view.PHPSourceConsole;
 import com.quantum.view.tableview.TableAdapter;
 
 public class PHPSelectRowPage extends WizardPage implements SQLPage {
@@ -194,9 +196,12 @@ public class PHPSelectRowPage extends WizardPage implements SQLPage {
   }
 
   public boolean performFinish() {
-    PHPSourceConsole console = PHPSourceConsole.getInstance();
-    console.clear();
-    console.print(query.getText());
+//    PHPSourceConsole console = PHPSourceConsole.getInstance();
+//    console.clear();
+//    console.print(query.getText());
+       QuantumPlugin.getDefault().getSysClip().setContents(
+                       new Object[] { query.getText() },
+                       new Transfer[] { TextTransfer.getInstance()});
     return true;
   }
 }
\ No newline at end of file
index 26b2ea9..0767336 100644 (file)
@@ -5,6 +5,8 @@ import java.text.MessageFormat;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
@@ -18,7 +20,7 @@ import org.eclipse.swt.widgets.Text;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.sql.TableRow;
-import com.quantum.view.PHPSourceConsole;
+//import com.quantum.view.PHPSourceConsole;
 import com.quantum.view.tableview.TableAdapter;
 
 public class PHPUpdateRowPage extends WizardPage implements SQLPage {
@@ -187,9 +189,12 @@ public class PHPUpdateRowPage extends WizardPage implements SQLPage {
     this.query.setText(query);
   }
   public boolean performFinish() {
-    PHPSourceConsole console = PHPSourceConsole.getInstance();
-    console.clear();
-    console.print(query.getText());
+//    PHPSourceConsole console = PHPSourceConsole.getInstance();
+//    console.clear();
+//    console.print(query.getText());
+       QuantumPlugin.getDefault().getSysClip().setContents(
+                       new Object[] { query.getText() },
+                       new Transfer[] { TextTransfer.getInstance()});
     return true;
   }
 }
\ No newline at end of file