New (Quantum SQL) wizard module which extends Quantum context menus (Bookmark-Tables...
authoraxelcl <axelcl>
Sat, 28 May 2005 09:44:48 +0000 (09:44 +0000)
committeraxelcl <axelcl>
Sat, 28 May 2005 09:44:48 +0000 (09:44 +0000)
- at the moment only the data is extracted as an example from the extensions
- the data output can de found in the development console (System.out.println()'s)

net.sourceforge.phpeclipse.wizards/.classpath [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/.project [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/build.properties [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/build.xml [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/plugin.xml [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/WizardsPlugin.java [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/PHPOpenSQLTableEditorAction.java [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/data/PHPDataWizard.java [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java [new file with mode: 0644]
net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/xml/ModelUtil.java [new file with mode: 0644]

diff --git a/net.sourceforge.phpeclipse.wizards/.classpath b/net.sourceforge.phpeclipse.wizards/.classpath
new file mode 100644 (file)
index 0000000..065ac06
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/net.sourceforge.phpeclipse.wizards/.project b/net.sourceforge.phpeclipse.wizards/.project
new file mode 100644 (file)
index 0000000..b297e1a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>net.sourceforge.phpeclipse.wizards</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/net.sourceforge.phpeclipse.wizards/build.properties b/net.sourceforge.phpeclipse.wizards/build.properties
new file mode 100644 (file)
index 0000000..186d8c9
--- /dev/null
@@ -0,0 +1,6 @@
+source.wizards.jar = src/
+output.wizards.jar = bin/
+bin.includes = plugin.xml,\
+               wizards.jar
+src.includes = src/,\
+               build.properties
diff --git a/net.sourceforge.phpeclipse.wizards/build.xml b/net.sourceforge.phpeclipse.wizards/build.xml
new file mode 100644 (file)
index 0000000..7301464
--- /dev/null
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="net.sourceforge.phpeclipse.wizards" default="build.jars" basedir=".">
+
+       <property name="bootclasspath" value=""/>
+       <property name="basews" value="${ws}"/>
+       <property name="baseos" value="${os}"/>
+       <property name="basearch" value="${arch}"/>
+       <property name="basenl" value="${nl}"/>
+       <property name="javacFailOnError" value="false"/>
+       <property name="javacDebugInfo" value="on"/>
+       <property name="javacVerbose" value="true"/>
+       <property name="javacSource" value="1.3"/>
+       <property name="javacTarget" value="1.2"/>
+       <property name="compilerArg" value=""/>
+
+       <target name="init" depends="properties">
+               <condition property="pluginTemp" value="${buildTempFolder}/plugins">
+                       <isset property="buildTempFolder"/>
+               </condition>
+               <property name="pluginTemp" value="${basedir}"/>
+               <condition property="build.result.folder" value="${pluginTemp}/net.sourceforge.phpeclipse.wizards">
+                       <isset property="buildTempFolder"/>
+               </condition>
+               <property name="build.result.folder" value="${basedir}"/>
+               <property name="temp.folder" value="${basedir}/temp.folder"/>
+               <property name="plugin.destination" value="${basedir}"/>
+       </target>
+
+       <target name="properties" if="eclipse.running">
+               <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
+       </target>
+
+       <target name="build.update.jar" depends="init" description="Build the plug-in: net.sourceforge.phpeclipse.wizards for an update site.">
+               <delete dir="${temp.folder}"/>
+               <mkdir dir="${temp.folder}"/>
+               <antcall target="build.jars"/>
+               <antcall target="gather.bin.parts">
+                       <param name="destination.temp.folder" value="${temp.folder}/"/>
+               </antcall>
+               <zip zipfile="${plugin.destination}/net.sourceforge.phpeclipse.wizards_1.0.0.jar" basedir="${temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" filesonly="false" whenempty="skip" update="false"/>
+               <delete dir="${temp.folder}"/>
+       </target>
+
+       <target name="wizards.jar" depends="init" unless="wizards.jar" description="Create jar: wizards.jar.">
+               <delete dir="${temp.folder}/wizards.jar.bin"/>
+               <mkdir dir="${temp.folder}/wizards.jar.bin"/>
+               <!-- compile the source code -->
+               <javac destdir="${temp.folder}/wizards.jar.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bootclasspath}" source="${javacSource}" target="${javacTarget}"           >
+                       <compilerarg line="${compilerArg}"/>
+                       <classpath>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui_3.0.1/ui.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.runtime_3.0.1/runtime.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/core.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/console.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/osgi.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/resolver.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/defaultAdaptor.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.osgi_3.0.1/eclipseAdaptor.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.help_3.0.0/help.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.swt_3.0.1/ws/${basews}/swt.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.swt.win32_3.0.1/ws/${basews}/swt.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.swt.win32_3.0.1"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.jface_3.0.0/jface.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.workbench_3.0.1/compatibility.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.workbench_3.0.1/workbench.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.workbench.compatibility_3.0.0/compatibility.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.workbench.compatibility_3.0.0/workbench.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.expressions_3.0.0/expressions.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.console_3.0.0/console.jar"/>
+                               <pathelement path="../org.eclipse.jface.text/bin"/>
+                               <pathelement path="../org.eclipse.jface.text/jfacetext.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.text_3.0.1/text.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.workbench.texteditor_3.0.1/texteditor.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.resources_3.0.1/resources.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.resources.win32_3.0.0/resources.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.resources.win32_3.0.0/resources-win32.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.runtime.compatibility_3.0.0/compatibility.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.update.configurator_3.0.0/configurator.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.search_3.0.1/search.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.filebuffers_3.0.1/filebuffers.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.ide_3.0.1/ide.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.win32_3.0.1/ide.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.win32_3.0.1/workbenchwin32.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.views_3.0.0/views.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.update.core_3.0.1/updatecore.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.update.core.win32_3.0.0/updatecore.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.update.ui_3.0.1/updateui.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.help.base_3.0.1/helpbase.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.apache.lucene_1.3.1/parser.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.apache.lucene_1.3.1/lucene-1.3-final.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.help.appserver_3.0.0/appserver.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.forms_3.0.0/forms.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.editors_3.0.1/editors.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.compare_3.0.0/compare.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse/phpeclipse.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.debug.core_3.0.1/dtcore.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.core.variables_3.0.0/variables.jar"/>
+                               <pathelement path="../org.eclipse.debug.ui/bin"/>
+                               <pathelement path="../org.eclipse.debug.ui/dtui.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.ui.externaltools_3.0.1/externaltools.jar"/>
+                               <pathelement path="../../../eclipse301/plugins/org.eclipse.team.core_3.0.0/team.jar"/>
+                               <pathelement path="../quantum-plugin/bin"/>
+                               <pathelement path="../quantum-plugin/quantum.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.webbrowser/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.webbrowser/webbrowser.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.core/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.core/webcore.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.ui/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.ui/ui.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.xml.core/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.xml.core/xmlcore.jar"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.xml.ui/bin"/>
+                               <pathelement path="../net.sourceforge.phpeclipse.xml.ui/xmlui.jar"/>
+                       </classpath>
+                       <src path="src/"                        />
+                       </javac>
+               <!-- Copy necessary resources -->
+               <copy todir="${temp.folder}/wizards.jar.bin" failonerror="true">
+                       <fileset dir="src/" excludes="**/*.java, **/package.htm*"                       />
+               </copy>
+               <mkdir dir="${build.result.folder}"/>
+               <jar jarfile="${build.result.folder}/wizards.jar" basedir="${temp.folder}/wizards.jar.bin"/>
+               <delete dir="${temp.folder}/wizards.jar.bin"/>
+       </target>
+
+       <target name="wizardssrc.zip" depends="init" unless="wizardssrc.zip">
+               <mkdir dir="${build.result.folder}"/>
+               <zip zipfile="${build.result.folder}/wizardssrc.zip" filesonly="false" whenempty="skip" update="false">
+                       <fileset dir="src/" includes="**/*.java"                        />
+               </zip>
+       </target>
+
+       <target name="build.jars" depends="init" description="Build all the jars for the plug-in: net.sourceforge.phpeclipse.wizards.">
+               <available property="wizards.jar" file="${build.result.folder}/wizards.jar"/>
+               <antcall target="wizards.jar"/>
+       </target>
+
+       <target name="build.sources" depends="init">
+               <available property="wizardssrc.zip" file="${build.result.folder}/wizardssrc.zip"/>
+               <antcall target="wizardssrc.zip"/>
+       </target>
+
+       <target name="gather.bin.parts" depends="init" if="destination.temp.folder">
+               <mkdir dir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0"/>
+               <copy todir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" failonerror="true">
+                       <fileset dir="${build.result.folder}" includes="wizards.jar"                    />
+               </copy>
+               <copy todir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" failonerror="true">
+                       <fileset dir="${basedir}" includes="plugin.xml,wizards.jar"                     />
+               </copy>
+       </target>
+
+       <target name="build.zips" depends="init">
+       </target>
+
+       <target name="gather.sources" depends="init" if="destination.temp.folder">
+               <mkdir dir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0"/>
+               <copy file="${build.result.folder}/wizardssrc.zip" todir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" failonerror="false"/>
+               <copy todir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" failonerror="false">
+                       <fileset dir="${basedir}" includes="src/,build.properties"                      />
+               </copy>
+       </target>
+
+       <target name="gather.logs" depends="init" if="destination.temp.folder">
+               <mkdir dir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0"/>
+               <copy file="${temp.folder}/wizards.jar.bin.log" todir="${destination.temp.folder}/net.sourceforge.phpeclipse.wizards_1.0.0" failonerror="false"/>
+       </target>
+
+       <target name="clean" depends="init" description="Clean the plug-in: net.sourceforge.phpeclipse.wizards of all the zips, jars and logs created.">
+               <delete file="${build.result.folder}/wizards.jar"/>
+               <delete file="${build.result.folder}/wizardssrc.zip"/>
+               <delete file="${plugin.destination}/net.sourceforge.phpeclipse.wizards_1.0.0.jar"/>
+               <delete file="${plugin.destination}/net.sourceforge.phpeclipse.wizards_1.0.0.zip"/>
+               <delete dir="${temp.folder}"/>
+       </target>
+
+       <target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
+               <eclipse.convertPath fileSystemPath="C:/eclipse3/workspace/net.sourceforge.phpeclipse.wizards" property="resourcePath"/>
+               <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
+       </target>
+
+       <target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: net.sourceforge.phpeclipse.wizards.">
+               <delete dir="${temp.folder}"/>
+               <mkdir dir="${temp.folder}"/>
+               <antcall target="build.jars"/>
+               <antcall target="build.sources"/>
+               <antcall target="gather.bin.parts">
+                       <param name="destination.temp.folder" value="${temp.folder}/"/>
+               </antcall>
+               <antcall target="gather.sources">
+                       <param name="destination.temp.folder" value="${temp.folder}/"/>
+               </antcall>
+               <delete>
+                       <fileset dir="${temp.folder}" includes="**/*.bin.log"                   />
+               </delete>
+               <zip zipfile="${plugin.destination}/net.sourceforge.phpeclipse.wizards_1.0.0.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/>
+               <delete dir="${temp.folder}"/>
+       </target>
+
+</project>
diff --git a/net.sourceforge.phpeclipse.wizards/plugin.xml b/net.sourceforge.phpeclipse.wizards/plugin.xml
new file mode 100644 (file)
index 0000000..f4d23b3
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+   id="net.sourceforge.phpeclipse.wizards"
+   name="Wizards Plug-in"
+   version="1.0.0"
+   provider-name=""
+   class="net.sourceforge.phpeclipse.wizards.WizardsPlugin">
+
+   <runtime>
+      <library name="wizards.jar">
+         <export name="*"/>
+      </library>
+   </runtime>
+  
+   <requires> 
+      <import plugin="org.eclipse.ui"/>
+      <import plugin="org.eclipse.ui.console"/>
+      <import plugin="org.eclipse.core.runtime"/>
+      <import plugin="org.eclipse.core.resources"/>
+      <import plugin="org.eclipse.search"/> 
+      <import plugin="org.eclipse.compare"/>
+      <import plugin="org.eclipse.core.filebuffers"/>
+      <import plugin="org.eclipse.jface.text"/>
+      <import plugin="org.eclipse.ui.workbench.texteditor"/>
+      <import plugin="org.eclipse.ui.ide"/>
+      <import plugin="org.eclipse.ui.views"/>
+      <import plugin="org.eclipse.ui.editors"/>
+      <import plugin="net.sourceforge.phpeclipse"/>
+      <import plugin="net.sourceforge.phpeclipse.ui"/>
+      <import plugin="com.quantum.Quantum"/>  
+   </requires>
+
+   <extension
+         point="org.eclipse.ui.popupMenus">
+      <viewerContribution
+            targetID="#PHPEditorContext"
+            id="net.sourceforge.phpeclipse.wizards.actions.popupOpenSQLTable">
+         <action
+               label="Open Quantum SQL Table View"
+               class="net.sourceforge.phpeclipse.wizards.actions.PHPOpenSQLTableEditorAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.wizards.actions.opensqltable">
+         </action>
+      </viewerContribution>
+    </extension>
+    
+    <extension
+         point="com.quantum.Quantum.metadata">
+      <metadataActor 
+            label="PHP Metadata Wizard" 
+            class="net.sourceforge.phpeclipse.wizards.actions.metadata.PHPMetadataWizard">
+      </metadataActor>
+    </extension>
+     
+    <extension
+         point="com.quantum.Quantum.data">
+      <dataActor 
+            label="PHP Data Wizard" 
+            class="net.sourceforge.phpeclipse.wizards.actions.data.PHPDataWizard">
+      </dataActor>
+    </extension>
+    
+</plugin>
diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/WizardsPlugin.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/WizardsPlugin.java
new file mode 100644 (file)
index 0000000..19f5718
--- /dev/null
@@ -0,0 +1,71 @@
+package net.sourceforge.phpeclipse.wizards;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class WizardsPlugin extends AbstractUIPlugin {
+       //The shared instance.
+       private static WizardsPlugin plugin;
+       //Resource bundle.
+       private ResourceBundle resourceBundle;
+       
+       /**
+        * The constructor.
+        */
+       public WizardsPlugin() {
+               super();
+               plugin = this;
+               try {
+                       resourceBundle = ResourceBundle.getBundle("net.sourceforge.phpeclipse.wizards.WizardsPluginResources");
+               } catch (MissingResourceException x) {
+                       resourceBundle = null;
+               }
+       }
+
+       /**
+        * This method is called upon plug-in activation
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+       }
+
+       /**
+        * This method is called when the plug-in is stopped
+        */
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance.
+        */
+       public static WizardsPlugin getDefault() {
+               return plugin;
+       }
+
+       /**
+        * Returns the string from the plugin's resource bundle,
+        * or 'key' if not found.
+        */
+       public static String getResourceString(String key) {
+               ResourceBundle bundle = WizardsPlugin.getDefault().getResourceBundle();
+               try {
+                       return (bundle != null) ? bundle.getString(key) : key;
+               } catch (MissingResourceException e) {
+                       return key;
+               }
+       }
+
+       /**
+        * Returns the plugin's resource bundle,
+        */
+       public ResourceBundle getResourceBundle() {
+               return resourceBundle;
+       }
+}
diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/PHPOpenSQLTableEditorAction.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/PHPOpenSQLTableEditorAction.java
new file mode 100644 (file)
index 0000000..e7c67e8
--- /dev/null
@@ -0,0 +1,316 @@
+/***********************************************************************************************************************************
+ * 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: www.phpeclipse.de
+ **********************************************************************************************************************************/
+package net.sourceforge.phpeclipse.wizards.actions;
+
+import java.sql.SQLException;
+
+import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
+import net.sourceforge.phpeclipse.ui.WebUI;
+import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionDelegate;
+
+import com.quantum.ExternalInterface;
+import com.quantum.QuantumPlugin;
+// import com.quantum.util.connection.NotConnectedException;
+
+public class PHPOpenSQLTableEditorAction extends ActionDelegate implements IEditorActionDelegate {
+
+  private IWorkbenchWindow fWindow;
+
+  private PHPEditor fEditor;
+
+  private IProject fProject;
+
+  public void dispose() {
+  }
+
+  public void init(IWorkbenchWindow window) {
+    this.fWindow = window;
+  }
+
+  public void selectionChanged(IAction action, ISelection selection) {
+    if (!selection.isEmpty()) {
+      if (selection instanceof TextSelection) {
+        action.setEnabled(true);
+      } else if (fWindow.getActivePage() != null && fWindow.getActivePage().getActivePart() != null) {
+        //
+      }
+    }
+  }
+
+  private IWorkbenchPage getActivePage() {
+    fWindow = fEditor.getEditorSite().getWorkbenchWindow();
+    IWorkbenchPage page = fWindow.getActivePage();
+    return page;
+  }
+
+  public IContainer getWorkingLocation(IFileEditorInput editorInput) {
+    if (editorInput == null || editorInput.getFile() == null) {
+      return null;
+    }
+    return editorInput.getFile().getParent();
+  }
+
+  private IFile getIncludeFile(IProject project, IFileEditorInput editorInput, String relativeFilename) {
+    //         IContainer container = getWorkingLocation(editorInput);
+    //         String fullPath = project.getLocation().toString();
+    Path path = new Path(relativeFilename);
+    IFile file = project.getFile(path);
+    return file;
+  }
+
+  public void run(IAction action) {
+    if (fEditor == null) {
+      IEditorPart targetEditor = fWindow.getActivePage().getActiveEditor();
+      if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
+        fEditor = (PHPEditor) targetEditor;
+      }
+    }
+    if (fEditor != null) {
+      fWindow = fEditor.getEditorSite().getWorkbenchWindow();
+      IFile f = ((IFileEditorInput) fEditor.getEditorInput()).getFile();
+      fProject = f.getProject();
+      String bookmarkString = ProjectPrefUtil.getMiscProjectsPreferenceValue(fProject, WebUI.PHP_BOOKMARK_DEFAULT);
+      if (bookmarkString != null && !bookmarkString.equals("")) {
+        ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
+        IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+        int pos = selection.getOffset();
+        //  System.out.println(selection.getText());
+        String tableName = getSQLTableName(doc, pos);
+        if (tableName != null && tableName.length() > 0)
+          try {
+            ExternalInterface.displayTable(bookmarkString, tableName);
+            
+            IViewPart viewPart = null;
+            String view = "com.quantum.view.tableview.TableView";
+            try {
+              IWorkbenchPage page = QuantumPlugin.getDefault().getActivePage();
+              viewPart = page.findView(view);
+              if (viewPart == null) {
+                viewPart = page.showView(view);
+              }
+              page.bringToTop(viewPart);
+            } catch (PartInitException e) {
+              e.printStackTrace();
+            }
+          } catch (SQLException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+          } catch (Exception /* NotConnectedException */ e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+          } 
+      }
+
+      //
+      //      IViewPart viewPart = null;
+      //      String view = "com.quantum.view.tableview.TableView";
+      //      try {
+      //        IWorkbenchPage page = QuantumPlugin.getDefault().getActivePage();
+      //        viewPart = page.findView(view);
+      //        if (viewPart == null) {
+      //          viewPart = page.showView(view);
+      //        }
+      //        page.bringToTop(viewPart);
+      //        getTables((TableView) viewPart, fProject, tableName);
+      //      } catch (PartInitException e) {
+      //        e.printStackTrace();
+      //      }
+
+    }
+  }
+
+  public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+    if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
+      fEditor = (PHPEditor) targetEditor;
+    }
+  }
+
+  private String getSQLTableName(IDocument doc, int pos) {
+    Point word = null;
+    int start = -1;
+    int end = -1;
+
+    try {
+
+      int position = pos;
+      char character;
+
+      while (position >= 0) {
+        character = doc.getChar(position);
+        if (Character.isWhitespace(character) || (character == '\"') || (character == '\'') || (character == '\r')
+            || (character == '\n'))
+          break;
+        --position;
+      }
+
+      start = position;
+
+      position = pos;
+      int length = doc.getLength();
+
+      while (position < length) {
+        character = doc.getChar(position);
+        if (Character.isWhitespace(character) || (character == '\"') || (character == '\'') || (character == '\r')
+            || (character == '\n'))
+          break;
+        ++position;
+      }
+
+      start++;
+      end = position;
+
+      if (end > start)
+        word = new Point(start, end - start);
+
+    } catch (BadLocationException x) {
+    }
+
+    if (word != null) {
+      try {
+        return doc.get(word.x, word.y);
+      } catch (BadLocationException e) {
+      }
+    }
+    return "";
+  }
+
+  //  public void getTables(TableView tableView, IProject project, String tableName) {
+  //    // Get The Database bookmark from the Quantum SQL plugin:
+  //    BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
+  //    if (sqlBookMarks != null) {
+  //      String bookmarkString = ProjectPrefUtil.getMiscProjectsPreferenceValue(project,
+  //          WebUI.PHP_BOOKMARK_DEFAULT);
+  //      if (bookmarkString != null && !bookmarkString.equals("")) {
+  //        Bookmark bookmark = sqlBookMarks.find(bookmarkString);
+  //        ArrayList sqlList = new ArrayList();
+  //        if (bookmark != null && !bookmark.isConnected()) {
+  //          new ConnectionUtil().connect(bookmark, null);
+  //        }
+  //        if (bookmark != null && bookmark.isConnected()) {
+  //          try {
+  //            Connection connection = bookmark.getConnection();
+  //            DatabaseMetaData metaData = connection.getMetaData();
+  //            ConnectionUtil connectionUtil = new ConnectionUtil();
+  //            Entity entity;
+  //            DatabaseAdapter adapter;
+  //
+  //            if (metaData != null) {
+  //              String columnName;
+  //              String prefixWithoutDollar = tableName;
+  //              if (prefixWithoutDollar.charAt(0) == '$') {
+  //                prefixWithoutDollar = prefixWithoutDollar.substring(1);
+  //              }
+  //              ResultSet set;
+  //              set = metaData.getTables(null, null, "%" + prefixWithoutDollar
+  //                  + "%", null);
+  //              while (set.next()) {
+  //                tableName = set.getString("TABLE_NAME");
+  //                tableName = (tableName == null) ? "" : tableName.trim();
+  //                if (tableName != null && tableName.length() > 0) {
+  //                  sqlList.add(tableName);
+  //                }
+  //              }
+  //              set.close();
+  //              EntityFactory entityFactory = EntityFactory.getInstance();
+  //              if (sqlList.size() == 1) {
+  //                adapter = bookmark.getAdapter();
+  //                entity = entityFactory.create(bookmark, null, (String) sqlList
+  //                    .get(0), Entity.TABLE_TYPE, false);
+  //                String query = adapter.getTableQuery(entity.getQualifiedName());
+  //
+  //                try {
+  //                  SQLResults results = MultiSQLServer.getInstance().execute(
+  //                      bookmark, connectionUtil.connect(bookmark, fWindow.getShell()),
+  //                      entity, query);
+  //
+  //                  if (results != null && results.isResultSet()) {
+  //                    SQLResultSetCollection.getInstance().addSQLResultSet(
+  //                        (SQLResultSetResults) results);
+  //                  }
+  //                } catch (SQLException e) {
+  //                  ExceptionDisplayDialog.openError(fWindow.getShell(), null, null, e);
+  //                }
+  //                // tableView.loadTable(entityFactory.create(
+  //                // bookmark, null,
+  //                // (String) sqlList.get(0),
+  //                // Entity.TABLE_TYPE));
+  //              } else if (sqlList.size() > 1) {
+  //                ListSelectionDialog listSelectionDialog = new ListSelectionDialog(
+  //                    PHPeclipsePlugin.getDefault().getWorkbench()
+  //                        .getActiveWorkbenchWindow().getShell(), sqlList,
+  //                    new ListContentProvider(), new LabelProvider(),
+  //                    "Select the SQL table to open.");
+  //                listSelectionDialog.setTitle("Multiple tablenames found");
+  //                if (listSelectionDialog.open() == Window.OK) {
+  //                  Object[] locations = listSelectionDialog.getResult();
+  //                  if (locations != null) {
+  //                    for (int i = 0; i < locations.length; i++) {
+  //                      adapter = bookmark.getAdapter();
+  //                      entity = entityFactory.create(bookmark, null,
+  //                          (String) locations[i], Entity.TABLE_TYPE, false);
+  //                      String query = adapter.getTableQuery(entity
+  //                          .getQualifiedName());
+  //
+  //                      try {
+  //                        SQLResults results = MultiSQLServer.getInstance()
+  //                            .execute(bookmark,
+  //                                connectionUtil.connect(bookmark, fWindow.getShell()),
+  //                                entity, query);
+  //
+  //                        if (results != null && results.isResultSet()) {
+  //                          SQLResultSetCollection.getInstance().addSQLResultSet(
+  //                              (SQLResultSetResults) results);
+  //                        }
+  //                      } catch (SQLException e) {
+  //                        ExceptionDisplayDialog.openError(fWindow.getShell(), null, null, e);
+  //                      }
+  //
+  //                      // tableView
+  //                      // .loadTable(entityFactory
+  //                      // .create(
+  //                      // bookmark,
+  //                      // null,
+  //                      // (String) locations[i],
+  //                      // Entity.TABLE_TYPE));
+  //                    }
+  //
+  //                  }
+  //                }
+  //              }
+  //            }
+  //          } catch (NotConnectedException e) {
+  //            // ignore this - not mission critical
+  //          } catch (SQLException e) {
+  //            e.printStackTrace();
+  //          }
+  //        }
+  //      }
+  //    }
+  //  }
+
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/data/PHPDataWizard.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/data/PHPDataWizard.java
new file mode 100644 (file)
index 0000000..483a689
--- /dev/null
@@ -0,0 +1,45 @@
+package net.sourceforge.phpeclipse.wizards.actions.data;
+
+import net.sourceforge.phpeclipse.wizards.xml.ModelUtil;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.quantum.extensions.IDataExtension;
+import com.quantum.model.Column;
+import com.quantum.model.xml.XMLToModelConverter;
+import com.quantum.util.StringMatrix;
+
+public class PHPDataWizard implements IDataExtension {
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see com.quantum.extensions.IDataExtension#run(org.w3c.dom.Document)
+   */
+  public void run(Document doc) {
+    Element root = doc.getDocumentElement();
+
+    // matrix contains the actual selected data in the row:
+//    StringMatrix matrix = new StringMatrix();
+//    String sub = "DataRow";
+//    ModelUtil.xmlToStringMatrix(matrix, root, sub);
+//    System.out.println(matrix.toString());
+
+    try {
+      XMLToModelConverter c = new XMLToModelConverter(root);
+      String name = ModelUtil.getTableName(root);
+      System.out.print("Table-name: ");
+      System.out.println(name);
+      Column[] cols = c.getColumns();
+      for (int i = 0; i < cols.length; i++) {
+        System.out.print("Column-name: " + i + " ");
+        System.out.println(cols[i].getName());
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java
new file mode 100644 (file)
index 0000000..da589b3
--- /dev/null
@@ -0,0 +1,40 @@
+package net.sourceforge.phpeclipse.wizards.actions.metadata;
+
+import net.sourceforge.phpeclipse.wizards.xml.ModelUtil;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.quantum.extensions.IMetadataExtension;
+import com.quantum.model.Column;
+import com.quantum.model.xml.XMLToModelConverter;
+
+public class PHPMetadataWizard implements IMetadataExtension {
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see com.quantum.extensions.IDataExtension#run(org.w3c.dom.Document)
+   */
+  public void run(Document doc) {
+//    System.out.println(doc);
+    
+    Element root = doc.getDocumentElement();
+
+    try {
+      XMLToModelConverter c = new XMLToModelConverter(root);
+      String name = ModelUtil.getTableName(root);
+      System.out.print("Table-name: ");
+      System.out.println(name);
+      Column[] cols = c.getColumns();
+      for (int i = 0; i < cols.length; i++) {
+        System.out.print("Column-name: "+i+" ");
+        System.out.println(cols[i].getName());
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/xml/ModelUtil.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/xml/ModelUtil.java
new file mode 100644 (file)
index 0000000..17ae760
--- /dev/null
@@ -0,0 +1,54 @@
+package net.sourceforge.phpeclipse.wizards.xml;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import com.quantum.util.StringMatrix;
+
+public class ModelUtil {
+
+  public static String getTableName(Element root) {
+    NodeList columns = root.getElementsByTagName("table");
+    for (int i = 0; i < columns.getLength(); i++) {
+      Node column = columns.item(i);
+      String header = column.getNodeName();
+      if (header.equals("table")) {
+        NamedNodeMap map = column.getAttributes();
+        Node name = map.getNamedItem("name");
+        if (name == null) {
+          return "";
+        }
+        return name.getNodeValue();
+      }
+    }
+    return "";
+  }
+
+  
+  public static void xmlToStringMatrix(StringMatrix matrix, Element root, String sub) {
+    NodeList columns = root.getElementsByTagName(sub);
+    for (int i = 0; i < columns.getLength(); i++) {
+      Node column = columns.item(i);
+      NodeList columnList = column.getChildNodes();
+      for (int j = 0; j < columnList.getLength(); j++) {
+        Node node = columnList.item(j);
+        String header = node.getNodeName();
+        if (header.equals("#text")) //$NON-NLS-1$
+          continue;
+        String value = null;
+        if (node != null && node.hasChildNodes()) {
+          Node valueNode = node.getFirstChild();
+          if (valueNode instanceof Text) {
+            value = valueNode.getNodeValue();
+          }
+        }
+        if (!matrix.contains(header))
+          matrix.addHeader(header);
+        matrix.addAt(header, value, i);
+      }
+    }
+  }
+}
\ No newline at end of file