Revision: 6617
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6617&view=rev
Author: gerdwagner
Date: 2012-05-15 18:02:45 +0000 (Tue, 15 May 2012)
Log Message:
-----------
New plugin 'Multi Source' by Dr. Ramon Lawrence
Modified Paths:
--------------
trunk/sql12/installer/squirrelsql-installer-deps/pom.xml
trunk/sql12/installer/squirrelsql-macosx-installer/src/main/resources/izpack-mac.xml
trunk/sql12/installer/squirrelsql-macosx-installer/src/test/resources/auto-install.xml
trunk/sql12/installer/squirrelsql-other-installer/src/main/resources/izpack-other.xml
trunk/sql12/installer/squirrelsql-other-installer/src/test/resources/optional-auto-install.xml
trunk/sql12/plugins/pom.xml
Added Paths:
-----------
trunk/sql12/plugins/multisource/
trunk/sql12/plugins/multisource/pom.xml
trunk/sql12/plugins/multisource/src/
trunk/sql12/plugins/multisource/src/main/
trunk/sql12/plugins/multisource/src/main/java/
trunk/sql12/plugins/multisource/src/main/java/net/
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAddSourceAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAliasChooser.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiExportAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveFieldAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveSourceAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveTableAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameFieldAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameSourceAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameTableAction.java
trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiSourcePlugin.java
trunk/sql12/plugins/multisource/src/main/resources/
trunk/sql12/plugins/multisource/src/main/resources/doc/
trunk/sql12/plugins/multisource/src/main/resources/doc/MultipleSourcePlugin_for_SQuirreL_UserManual.pdf
trunk/sql12/plugins/multisource/src/main/resources/doc/changes.txt
trunk/sql12/plugins/multisource/src/main/resources/doc/licence.txt
trunk/sql12/plugins/multisource/src/main/resources/doc/readme.txt
trunk/sql12/plugins/multisource/src/main/resources/net/
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/squirrel_sql/plugins/multisource/
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/squirrel_sql/plugins/multisource/I18NStrings.properties
trunk/sql12/plugins/multisource/src/main/resources/net/sourceforge/squirrel_sql/plugins/multisource/multisource.properties
trunk/sql12/plugins/net/
trunk/sql12/plugins/net/sourceforge/
trunk/sql12/plugins/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/I18NStrings.properties
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiAddSourceAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiAliasChooser.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiExportAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveFieldAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveSourceAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveTableAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameFieldAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameSourceAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameTableAction.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/MultiSourcePlugin.java
trunk/sql12/plugins/net/sourceforge/squirrel_sql/plugins/multisource/multisource.properties
Modified: trunk/sql12/installer/squirrelsql-installer-deps/pom.xml
===================================================================
--- trunk/sql12/installer/squirrelsql-installer-deps/pom.xml 2012-04-25 18:47:04 UTC (rev 6616)
+++ trunk/sql12/installer/squirrelsql-installer-deps/pom.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -317,7 +317,14 @@
<classifier>assembly</classifier>
<type>zip</type>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql.plugins</groupId>
+ <artifactId>multisource</artifactId>
+ <version>${project.version}</version>
+ <classifier>assembly</classifier>
+ <type>zip</type>
+ </dependency>
+ <dependency>
<groupId>net.sf.squirrel-sql.translations</groupId>
<artifactId>squirrelsql-translations</artifactId>
<version>${project.version}</version>
Modified: trunk/sql12/installer/squirrelsql-macosx-installer/src/main/resources/izpack-mac.xml
===================================================================
--- trunk/sql12/installer/squirrelsql-macosx-installer/src/main/resources/izpack-mac.xml 2012-04-25 18:47:04 UTC (rev 6616)
+++ trunk/sql12/installer/squirrelsql-macosx-installer/src/main/resources/izpack-mac.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -177,6 +177,15 @@
<file targetdir="$INSTALL_PATH/plugins" src="plugins/swingViolations" />
</pack>
+ <pack required="no" preselected="no" installGroups="OptionalPlugins"
+ name="Optional Plugin - Multi Source">
+ <description>
+ This plugin enables you to access multiple databases (e.g. join tables from different databases) within the same Session
+ </description>
+ <file targetdir="$INSTALL_PATH/plugins" src="plugins/multisource.jar" />
+ <file targetdir="$INSTALL_PATH/plugins" src="plugins/multisource" />
+ </pack>
+
<pack
required="no"
preselected="no"
Modified: trunk/sql12/installer/squirrelsql-macosx-installer/src/test/resources/auto-install.xml
===================================================================
--- trunk/sql12/installer/squirrelsql-macosx-installer/src/test/resources/auto-install.xml 2012-04-25 18:47:04 UTC (rev 6616)
+++ trunk/sql12/installer/squirrelsql-macosx-installer/src/test/resources/auto-install.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -46,6 +46,7 @@
<pack index="37" name="Optional Plugin - WIKI table configurations" selected="true"/>
<pack index="38" name="Optional Plugin - Greenplum" selected="true"/>
<pack index="39" name="Optional Plugin - Swing Violation Detector" selected="true"/>
+<pack index="40" name="Optional Plugin - Multi Source" selected="true"/>
</com.izforge.izpack.panels.PacksPanel>
<com.izforge.izpack.panels.InstallPanel id="UNKNOWN (com.izforge.izpack.panels.InstallPanel)"/>
<com.izforge.izpack.panels.FinishPanel id="UNKNOWN (com.izforge.izpack.panels.FinishPanel)"/>
Modified: trunk/sql12/installer/squirrelsql-other-installer/src/main/resources/izpack-other.xml
===================================================================
--- trunk/sql12/installer/squirrelsql-other-installer/src/main/resources/izpack-other.xml 2012-04-25 18:47:04 UTC (rev 6616)
+++ trunk/sql12/installer/squirrelsql-other-installer/src/main/resources/izpack-other.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -137,8 +137,17 @@
<file targetdir="$INSTALL_PATH/plugins" src="plugins/swingViolations" />
</pack>
- <pack required="no" preselected="no" installGroups="OptionalPlugins" name="Optional Plugin - Data import">
+ <pack required="no" preselected="no" installGroups="OptionalPlugins"
+ name="Optional Plugin - Multi Source">
<description>
+ This plugin is useful to detect violated rules of the Swing programming model.
+ </description>
+ <file targetdir="$INSTALL_PATH/plugins" src="plugins/multisource.jar" />
+ <file targetdir="$INSTALL_PATH/plugins" src="plugins/multisource" />
+ </pack>
+
+ <pack required="no" preselected="no" installGroups="OptionalPlugins" name="Optional Plugin - Data import">
+ <description>
This plugin allows you import files into the database.
</description>
<file targetdir="$INSTALL_PATH/plugins" src="plugins/dataimport.jar" />
Modified: trunk/sql12/installer/squirrelsql-other-installer/src/test/resources/optional-auto-install.xml
===================================================================
--- trunk/sql12/installer/squirrelsql-other-installer/src/test/resources/optional-auto-install.xml 2012-04-25 18:47:04 UTC (rev 6616)
+++ trunk/sql12/installer/squirrelsql-other-installer/src/test/resources/optional-auto-install.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -46,6 +46,7 @@
<pack index="37" name="Optional Plugin - WIKI table configurations" selected="true"/>
<pack index="38" name="Optional Plugin - Greenplum" selected="true"/>
<pack index="39" name="Optional Plugin - Swing Violation Detector" selected="true"/>
+<pack index="40" name="Optional Plugin - Multi Source" selected="true"/>
</com.izforge.izpack.panels.PacksPanel>
<com.izforge.izpack.panels.InstallPanel id="UNKNOWN (com.izforge.izpack.panels.InstallPanel)"/>
<com.izforge.izpack.panels.ShortcutPanel id="UNKNOWN (com.izforge.izpack.panels.ShortcutPanel)"/>
Added: trunk/sql12/plugins/multisource/pom.xml
===================================================================
--- trunk/sql12/plugins/multisource/pom.xml (rev 0)
+++ trunk/sql12/plugins/multisource/pom.xml 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,120 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>net.sf.squirrel-sql.plugins</groupId>
+ <artifactId>squirrelsql-plugins-parent-pom</artifactId>
+ <version>3.4.0-SNAPSHOT</version>
+ <relativePath>../squirrelsql-plugins-parent-pom/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>multisource</artifactId>
+ <packaging>jar</packaging>
+ <description>Multi Source Plugin</description>
+ <inceptionYear>2012</inceptionYear>
+ <developers>
+ <developer>
+ <name>Dr. Ramon Lawrence</name>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License</name>
+ <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <url>http://www.squirrelsql.org/</url>
+ <scm>
+ <connection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/sql12/plugins/oracle</connection>
+ <developerConnection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/sql12/plugins/oracle</developerConnection>
+ <url>http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/sql12/plugins/oracle</url>
+ </scm>
+ <issueManagement>
+ <system>SourceForge Tracker</system>
+ <url>http://sourceforge.net/tracker/?group_id=28383%26atid=393414</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Hudson</system>
+ <url>https://www.squirrel-sql.org/hudson/</url>
+ </ciManagement>
+ <dependencies>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>fw</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>fw</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrel-sql</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrel-sql</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>gsbase</groupId>
+ <artifactId>gsbase</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql.thirdparty-non-maven</groupId>
+ <artifactId>treetable</artifactId>
+ <version>20040121</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <pluginClassName>net.sourceforge.squirrel_sql.plugins.multisource.MultiSourcePlugin</pluginClassName>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAddSourceAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAddSourceAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAddSourceAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,60 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLAlias;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to add a source to the integrated, global view.
+ */
+public class MultiAddSourceAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiAddSourceAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ /**
+ * The add source action retrieves a list of all existing aliases that are not virtual (have unity in the URL) then
+ * allows the user to select one of them in a dialog. If a source is selected, it is added to the virtual view
+ * and the object tree is updated.
+ */
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ // List all the aliases in the system (then have user pick one).
+ Iterator<ISQLAlias> iterator = _session.getApplication().getDataCache().aliases();
+ ArrayList<ISQLAlias> aliasList = new ArrayList<ISQLAlias>();
+ while (iterator.hasNext())
+ { ISQLAlias alias = iterator.next();
+ if (alias.getUrl().toLowerCase().indexOf("jdbc:unity") < 0)
+ {
+ aliasList.add(alias);
+ }
+ }
+
+ if (aliasList.size() > 0)
+ { // Must have at least one alias source defined
+ // Put up window to select an alias
+ MultiAliasChooser dialog = new MultiAliasChooser(this._app, _session, aliasList);
+ ISQLAlias selected = dialog.showDialog();
+ if (selected != null)
+ { // Added a source
+ // Update object tree information
+ MultiSourcePlugin.updateSession(_session);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAliasChooser.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAliasChooser.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiAliasChooser.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,201 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.Container;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.util.ArrayList;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.action.RefreshObjectTreeCommand;
+import net.sourceforge.squirrel_sql.fw.gui.Dialogs;
+import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
+import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLAlias;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDriverClassLoader;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
+/**
+ * A dialog that allows a user to select an existing alias to add to the virtualization.
+ */
+public class MultiAliasChooser extends JDialog
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Internationalized strings for this class. */
+ private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(MultiAliasChooser.class);
+
+ private JComboBox _aliasCbx;
+ private JTextField _nameTxt;
+ private JTextField _schemaTxt;
+ private ArrayList<ISQLAlias> _aliasList;
+ private ISQLAlias _selectedAlias;
+ private String _sourceName;
+ private IApplication _app;
+ private ISession _session;
+
+ public MultiAliasChooser(IApplication app, ISession session, ArrayList<ISQLAlias> aliasList)
+ {
+ super((Frame) null, s_stringMgr.getString("MultiAliasChooser.title"), true);
+ setSize(300, 200);
+ _aliasList = aliasList;
+ _app = app;
+ _session = session;
+ createUserInterface();
+ }
+
+ /**
+ * Show dialog.
+ */
+ public ISQLAlias showDialog()
+ {
+ setVisible(true);
+ return _selectedAlias;
+ }
+
+ /**
+ * Builds the components of the dialog.
+ */
+ private void createUserInterface()
+ {
+ Container contentPane = getContentPane();
+
+ JPanel content = new JPanel(new GridLayout(4,1));
+
+ content.add(new JLabel(s_stringMgr.getString("MultiAliasChooser.prompt"), JLabel.LEFT));
+
+ _aliasCbx = new JComboBox(_aliasList.toArray());
+ _aliasCbx.setMaximumRowCount(5); // Display up to 5 rows without a scrollbar
+
+ content.add(_aliasCbx);
+ JPanel namePanel = new JPanel();
+ namePanel.add(new JLabel(s_stringMgr.getString("MultiAliasChooser.name"), JLabel.LEFT));
+ _nameTxt = new JTextField(15);
+ _nameTxt.setText(_aliasList.get(0).toString());
+ namePanel.add(_nameTxt);
+ content.add(namePanel);
+
+ JPanel schemaPanel = new JPanel();
+ schemaPanel.add(new JLabel(s_stringMgr.getString("MultiAliasChooser.schema"), JLabel.LEFT));
+ _schemaTxt = new JTextField(15);
+ schemaPanel.add(_schemaTxt);
+ content.add(schemaPanel);
+
+ contentPane.add(content, "Center");
+
+ contentPane.add(createButtonsPanel(), "South");
+
+ _aliasCbx.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt)
+ {
+ _sourceName = ((ISQLAlias) _aliasCbx.getSelectedItem()).getName();
+ _nameTxt.setText(_sourceName);
+ }
+ });
+
+ GUIUtils.centerWithinParent(this);
+ setResizable(false);
+ }
+
+ private JPanel createButtonsPanel()
+ {
+ JPanel pnl = new JPanel();
+
+ JButton okBtn = new JButton(s_stringMgr.getString("MultiAliasChooser.ok"));
+ okBtn.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ // Do positive action
+ ISQLAlias alias = (ISQLAlias) _aliasCbx.getSelectedItem();
+ MultiAliasChooser.this._selectedAlias = alias;
+ _sourceName = _nameTxt.getText();
+ if (_sourceName.contains(" "))
+ { Dialogs.showOk(_nameTxt.getParent().getParent(), "Source name cannot contain spaces.");
+ return;
+ }
+ String schemaName = _schemaTxt.getText();
+ if (schemaName.trim().equals(""))
+ schemaName = null;
+
+ try
+ {
+ // Verify that source name is not a duplicate
+ Object schema = MultiSourcePlugin.getSchema(_session.getSQLConnection().getConnection());
+ Method getDBMethod = schema.getClass().getMethod("getDB", new Class[]{java.lang.String.class});
+ Object result = getDBMethod.invoke(schema, new Object[]{_sourceName});
+
+ if (result != null)
+ { Dialogs.showOk(_nameTxt.getParent().getParent(), "Source name already exists in virtualization. Select a different name.");
+ return;
+ }
+
+ // Now actually do extract with this information
+ ClassLoader loader = _session.getSQLConnection().getConnection().getClass().getClassLoader();
+ Object extractor = Class.forName("com.unityjdbc.sourcebuilder.AnnotatedExtractor", true, loader).newInstance();
+
+ // Create connection
+ SQLDriverManager dm = _app.getSQLDriverManager();
+ IIdentifier driverID = alias.getDriverIdentifier();
+ ISQLDriver driver = _app.getDataCache().getDriver(driverID);
+ ISQLConnection con = dm.getConnection(driver, alias, alias.getUserName(), alias.getPassword(), alias.getDriverPropertiesClone());
+
+ ClassLoader newSourceLoader = new SQLDriverClassLoader(driver);
+
+ Method meth = extractor.getClass().getMethod("extract", new Class[]{java.lang.String.class, java.lang.String.class, java.lang.String.class,
+ java.lang.String.class, java.util.Properties.class, java.lang.String.class, java.lang.String.class, java.sql.Connection.class, java.lang.ClassLoader.class});
+
+ Connection c = con.getConnection();
+ Object asd = meth.invoke(extractor, new Object[]{driver.getDriverClassName(), alias.getUrl(), alias.getUserName(), alias.getPassword(), null,
+ _sourceName, schemaName, c, newSourceLoader});
+
+ // Add new database to schema
+ Method addSourceMethod = schema.getClass().getMethod("addDatabase", new Class[]{asd.getClass()});
+ addSourceMethod.invoke(schema, new Object[]{asd});
+
+ MultiSourcePlugin.refreshTree(_session);
+ }
+ catch (Exception e)
+ {
+ Dialogs.showOk(_nameTxt.getParent().getParent(), "Error during extraction: "+e);
+ return;
+ }
+ dispose();
+ }
+ });
+ JButton cancelBtn = new JButton(s_stringMgr.getString("MultiAliasChooser.cancel"));
+ cancelBtn.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ MultiAliasChooser.this._selectedAlias = null;
+ dispose();
+ }
+ });
+
+ pnl.add(okBtn);
+ pnl.add(cancelBtn);
+
+ GUIUtils.setJButtonSizesTheSame(new JButton[] { okBtn, cancelBtn });
+ getRootPane().setDefaultButton(okBtn);
+
+ return pnl;
+ }
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiExportAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiExportAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiExportAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,44 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to export the source information into XML files.
+ */
+public class MultiExportAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiExportAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ // Show a file chooser to select a file name
+ JFileChooser chooser = new JFileChooser();
+ FileNameExtensionFilter filter = new FileNameExtensionFilter("XML Configuration Files", "xml");
+ chooser.setFileFilter(filter);
+ chooser.setDialogTitle("Select location to save virtualization configuration file");
+ int returnVal = chooser.showSaveDialog(_session.getApplication().getMainFrame());
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ String sourcesFileName = chooser.getSelectedFile().getName();
+ MultiSourcePlugin.export(sourcesFileName, _session);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveFieldAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveFieldAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveFieldAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,33 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to add source to integrated, global view.
+ * @author rlawrenc
+ *
+ */
+public class MultiRemoveFieldAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRemoveFieldAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ // TODO: Not yet implemented
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveSourceAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveSourceAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveSourceAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,77 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to remove a source from the integrated view.
+ */
+public class MultiRemoveSourceAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRemoveSourceAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();
+ IObjectTreeAPI otree = sessMainFrm.getObjectTreeAPI();
+ IDatabaseObjectInfo[] dbObjs = otree.getSelectedDatabaseObjects();
+
+ // Only allow delete of one source regardless how many are selected
+ if (dbObjs.length > 0)
+ {
+ DatabaseObjectInfo di = (DatabaseObjectInfo) dbObjs[0];
+ String sourceName = di.getSimpleName();
+
+ Connection con = _session.getSQLConnection().getConnection(); // Retrieve connection
+ Object gs = MultiSourcePlugin.getSchema(con);
+ removeSource(sourceName, gs);
+ otree.removeNodes(otree.getSelectedNodes());
+ MultiSourcePlugin.updateSession(_session);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Removes a source from the global schema using reflection.
+ * @param gs
+ * @return
+ */
+ public void removeSource(String sourceName, Object gs)
+ {
+ Class<? extends Object> cls = gs.getClass();
+
+ try {
+ Method meth = cls.getMethod("removeDatabase", (Class[]) new Class[]{java.lang.String.class});
+ meth.invoke(gs, new Object[]{sourceName});
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveTableAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveTableAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRemoveTableAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,80 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to remove a table from the integrated view.
+ */
+public class MultiRemoveTableAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRemoveTableAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();
+ IObjectTreeAPI otree = sessMainFrm.getObjectTreeAPI();
+ List<ITableInfo> tables = otree.getSelectedTables();
+
+ // Only allow delete of one table regardless of how many are selected
+ if (tables.size() > 0)
+ {
+ ITableInfo ti = (ITableInfo) tables.get(0);
+ String sourceName = ti.getSchemaName();
+ String tableName = ti.getSimpleName();
+
+ Connection con = _session.getSQLConnection().getConnection(); // Retrieve connection
+ Object gs = MultiSourcePlugin.getSchema(con); // Invoke Get Global Schema Method using Reflection
+ removeTable(sourceName, tableName, gs);
+ otree.removeNodes(otree.getSelectedNodes());
+ MultiSourcePlugin.updateSession(_session);
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Removes a table from the global schema using reflection.
+ * @param gs
+ * @return
+ */
+ public void removeTable(String sourceName, String tableName, Object gs)
+ {
+ Class<? extends Object> cls = gs.getClass();
+
+ try {
+ Method meth = cls.getMethod("removeTable", (Class[]) new Class[]{java.lang.String.class,java.lang.String.class});
+ meth.invoke(gs, new Object[]{sourceName, tableName});
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameFieldAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameFieldAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameFieldAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,39 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to add source to integrated, global view.
+ * @author rlawrenc
+ *
+ */
+public class MultiRenameFieldAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRenameFieldAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ // TODO: Not implemented yet.
+
+ SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();
+
+ sessMainFrm.getSQLPanelAPI().appendSQLScript("RENAME FIELD!");
+ sessMainFrm.getSessionPanel().selectMainTab(ISession.IMainPanelTabIndexes.SQL_TAB);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameSourceAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameSourceAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameSourceAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,61 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+import java.sql.Connection;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to rename a source in the integrated view.
+ * @author rlawrenc
+ *
+ */
+public class MultiRenameSourceAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRenameSourceAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();
+ IObjectTreeAPI otree = sessMainFrm.getObjectTreeAPI();
+ IDatabaseObjectInfo[] dbObjs = otree.getSelectedDatabaseObjects();
+
+ // Only allow renaming of one source regardless how many are selected
+ if (dbObjs.length > 0)
+ {
+ DatabaseObjectInfo di = (DatabaseObjectInfo) dbObjs[0];
+ String sourceName = di.getSimpleName();
+
+ Connection con = _session.getSQLConnection().getConnection(); // Retrieve connection
+ Object gs = MultiSourcePlugin.getSchema(con); // Invoke Get Global Schema Method using Reflection
+ renameSource(sourceName, gs);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Removes a source from the global schema using reflection.
+ * @param gs
+ * @return
+ */
+ public void renameSource(String sourceName, Object gs)
+ {
+ // TODO: Not implemented yet.
+ }
+
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameTableAction.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameTableAction.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiRenameTableAction.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,45 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.awt.event.ActionEvent;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.Resources;
+
+/**
+ * Menu item that allows user to rename a table in the integrated view.
+ */
+public class MultiRenameTableAction extends SquirrelAction {
+ private static final long serialVersionUID = 1L;
+
+ private ISession _session;
+
+ public MultiRenameTableAction(IApplication app, Resources rsrc, ISession session) {
+ super(app, rsrc);
+ _session = session;
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ try {
+
+ SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();
+ IObjectTreeAPI otree = sessMainFrm.getObjectTreeAPI();
+ IDatabaseObjectInfo[] dbObjs = otree.getSelectedDatabaseObjects();
+
+ // Only allow one rename regardless of how many are selected
+ if (dbObjs.length > 0)
+ {
+ // DatabaseObjectInfo di = (DatabaseObjectInfo) dbObjs[0];
+ // String sourceName = di.getSimpleName();
+
+ // TODO: Not implemented yet.
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiSourcePlugin.java
===================================================================
--- trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiSourcePlugin.java (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/java/net/sourceforge/squirrel_sql/plugins/multisource/MultiSourcePlugin.java 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,365 @@
+package net.sourceforge.squirrel_sql.plugins.multisource;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
+import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
+import net.sourceforge.squirrel_sql.client.plugin.PluginException;
+import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
+import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
+import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallbackAdaptor;
+import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.action.RefreshObjectTreeCommand;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLAlias;
+import net.sourceforge.squirrel_sql.fw.util.FileWrapper;
+
+/**
+ * MultiSourcePlugin allows a user to query multiple databases with one query.
+ */
+public class MultiSourcePlugin extends DefaultSessionPlugin
+{
+ private PluginResources _resources;
+ private static FileWrapper _userSettingsFolder;
+
+ /**
+ * Return the internal name of this plugin.
+ *
+ * @return the internal name of this plugin.
+ */
+ public String getInternalName()
+ {
+ return "multisource";
+ }
+
+ /**
+ * Return the descriptive name of this plugin.
+ *
+ * @return the descriptive name of this plugin.
+ */
+ public String getDescriptiveName()
+ {
+ return "MultiSource Plugin";
+ }
+
+ /**
+ * Returns the current version of this plugin.
+ *
+ * @return the current version of this plugin.
+ */
+ public String getVersion()
+ {
+ return "0.1";
+ }
+
+ /**
+ * Returns the authors name.
+ *
+ * @return the authors name.
+ */
+ public String getAuthor()
+ {
+ return "Ramon Lawrence";
+ }
+
+ /**
+ * Returns the name of the change log for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the changelog file name or <TT>null</TT> if plugin doesn't have a change log.
+ */
+ public String getChangeLogFileName()
+ {
+ return "changes.txt";
+ }
+
+ /**
+ * Returns the name of the Help file for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the Help file name or <TT>null</TT> if plugin doesn't have a help file.
+ */
+ public String getHelpFileName()
+ {
+ return "readme.txt";
+ }
+
+ /**
+ * Returns the name of the Licence file for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the Licence file name or <TT>null</TT> if plugin doesn't have a licence file.
+ */
+ public String getLicenceFileName()
+ {
+ return "licence.txt";
+ }
+
+ /**
+ * @return Comma separated list of contributors.
+ */
+ public String getContributors()
+ {
+ return "";
+ }
+
+ /**
+ * Create preferences panel for the Global Preferences dialog.
+ *
+ * @return Preferences panel.
+ */
+ public IGlobalPreferencesPanel[] getGlobalPreferencePanels()
+ {
+ return new IGlobalPreferencesPanel[0];
+ }
+
+ /**
+ * Initialize this plugin.
+ */
+ public synchronized void initialize() throws PluginException
+ {
+ _resources = new PluginResources("net.sourceforge.squirrel_sql.plugins.multisource.multisource", this);
+ try
+ {
+ _userSettingsFolder = getPluginUserSettingsFolder(); // Retrieve the folder for user settings for storing connection info.
+ }
+ catch (Exception e)
+ { throw new PluginException(e); }
+ }
+
+ /**
+ * Called when a session started. Add commands to popup menu in object tree.
+ *
+ * @param session
+ * The session that is starting.
+ * @return An implementation of PluginSessionCallback or null to indicate the plugin does not work with
+ * this session
+ */
+ public PluginSessionCallback sessionStarted(ISession session)
+ {
+ String dbName = null;
+
+ // Determine if this is a Unity session.
+ try
+ {
+ dbName = session.getMetaData().getDatabaseProductName().toLowerCase();
+ }
+ catch (SQLException e) {}
+
+ if (dbName != null && dbName.contains("unity"))
+ { // Add new popup menu options for a Unity session
+ addTreeNodeMenuActions(session);
+
+ // Load session configuration information if URL says virtual
+ if (session.getAlias() != null)
+ {
+ String url = session.getAlias().getUrl();
+ if (url.toLowerCase().indexOf("/virtual") > 0)
+ { // Try to load based on session name
+ Object schema = MultiSourcePlugin.getSchema(session.getSQLConnection().getConnection()); // Retrieve schema
+ if (schema != null)
+ {
+ try
+ {
+ Method parseSourcesMethod = schema.getClass().getMethod("parseSourcesFile", new Class[]{java.io.BufferedReader.class, java.lang.String.class});
+ String filePath = getSourceFilePath(session);
+ System.out.println("LOad file: "+filePath);
+ System.out.println("ID: "+session.getAlias().getIdentifier());
+ BufferedReader reader = new BufferedReader(new FileReader(filePath));
+ parseSourcesMethod.invoke(schema, new Object[]{reader, "jdbc:unity://"+filePath});
+ // TODO: Not sure why these two lines below do not work.
+ // IObjectTreeAPI otree = session.getSessionInternalFrame().getObjectTreeAPI();
+ // otree.refreshTree();
+ new UpdateThread(session).run(); // A poor solution to force the object tree to update after a slight delay
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+ }
+ }
+ }
+ return new PluginSessionCallbackAdaptor(this);
+ }
+
+ /**
+ * Threads pauses for a small time then updates the object tree.
+ * Used when first starting the session to update the object tree.
+ */
+ private class UpdateThread extends Thread {
+ private ISession session;
+
+ public UpdateThread(ISession session) {
+ this.session = session;
+ }
+
+ public void run() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ refreshTree(session);
+ }
+ }
+
+ /**
+ * Returns the complete file path of the virtualization configuration file for the session.
+ * @param session
+ * @return
+ */
+ private static String getSourceFilePath(ISession session)
+ {
+ ISQLAlias alias = session.getAlias();
+ String aliasId = alias.getIdentifier().toString().replaceAll(":","_");
+ return _userSettingsFolder+File.separator+aliasId+File.separator+alias.getName()+".xml";
+ }
+
+ /**
+ * Adds virtualization menu items to the popup menu for the object tree.
+ * @param session
+ */
+ private void addTreeNodeMenuActions(ISession session)
+ {
+ try
+ {
+ // Add context menu items to the object tree's view and procedure nodes.
+ IObjectTreeAPI otApi = session.getSessionInternalFrame().getObjectTreeAPI();
+ IApplication app = session.getApplication();
+ otApi.addToPopup(DatabaseObjectType.SESSION, new MultiAddSourceAction(app, _resources, session));
+ otApi.addToPopup(DatabaseObjectType.SESSION, new MultiExportAction(app, _resources, session));
+ otApi.addToPopup(DatabaseObjectType.SCHEMA, new MultiRemoveSourceAction(app, _resources, session));
+ // otApi.addToPopup(DatabaseObjectType.SCHEMA, new MultiRenameSourceAction(app, _resources, session));
+ otApi.addToPopup(DatabaseObjectType.TABLE, new MultiRemoveTableAction(app, _resources, session));
+ // otApi.addToPopup(DatabaseObjectType.TABLE, new MultiRenameTableAction(app, _resources, session));
+ otApi.addToPopup(DatabaseObjectType.COLUMN, new MultiRemoveFieldAction(app, _resources, session));
+ // otApi.addToPopup(DatabaseObjectType.COLUMN, new MultiRenameFieldAction(app, _resources, session));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Gets the virtual schema from the connection using reflections.
+ * @param con
+ * @return
+ */
+ public static Object getSchema(Connection con)
+ {
+ Class<? extends Connection> cls = con.getClass();
+
+ Object retobj;
+ try {
+ Method meth = cls.getMethod("getSchema", (Class[]) null);
+ retobj = meth.invoke(con, (Object[]) null);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ return retobj;
+ }
+
+ /**
+ * Updates any session information including virtualization configuration files.
+ * @param session
+ */
+ public static void updateSession(ISession session)
+ { // Saves session information in user settings directory
+ String filePath = getSourceFilePath(session);
+ export(filePath, session);
+ }
+
+ /**
+ * Refreshes object tree. Used when virtual schema changes (e.g. adding a source).
+ * @param session
+ */
+ public static void refreshTree(ISession session)
+ {
+ SessionInternalFrame sessMainFrm = session.getSessionInternalFrame();
+ IObjectTreeAPI otree = sessMainFrm.getObjectTreeAPI();
+ new RefreshObjectTreeCommand(otree).execute();
+ }
+
+ /**
+ * Saves the virtualization configuration file to disk in the plugin's user directory.
+ * @param sourcesFileName
+ * @param session
+ */
+ public static void export(String sourcesFileName, ISession session)
+ {
+ File f = new File(sourcesFileName);
+ String path = f.getParent()+File.separator;
+ // Make sure directory exists
+ if (!f.getParentFile().exists())
+ {
+ f.getParentFile().mkdir();
+ }
+
+ sourcesFileName = f.getName();
+ String sourcesNoExt=sourcesFileName;
+ int idx = sourcesFileName.indexOf(".xml");
+ if (idx > 0)
+ sourcesNoExt = sourcesFileName.substring(0, sourcesFileName.length()-4);
+
+ Object schema = MultiSourcePlugin.getSchema(session.getSQLConnection().getConnection()); // Retrieve schema
+
+ try {
+ // Each source schema file is prefixed with sources file name (no extension) plus source name.
+ // Export schema files of each source first as each file location is needed in the sources file listing all sources.
+ Method exportSourceMethod = schema.getClass().getMethod("exportSchema", new Class[]{java.lang.String.class});
+ Method getDBsMethod = schema.getClass().getMethod("getAnnotatedDatabases", (Class[]) null);
+ @SuppressWarnings("unchecked")
+ ArrayList<Object> dbs = (ArrayList<Object>) getDBsMethod.invoke(schema, (Object[]) null);
+ for (int i=0; i < dbs.size(); i++)
+ { Object db = dbs.get(i);
+ Method getDBNameMethod = db.getClass().getMethod("getDatabaseName", (Class[]) null);
+ Method setDBSchemaMethod = db.getClass().getMethod("setSchemaFile", new Class[]{java.lang.String.class});
+ String dbName = (String) getDBNameMethod.invoke(db, (Object[]) null);
+ String fileName = sourcesNoExt+"_"+dbName+".xml";
+ setDBSchemaMethod.invoke(db, new Object[]{fileName});
+ String source = (String) exportSourceMethod.invoke(schema, new Object[]{dbName});
+ writeToFile(path+fileName, source);
+ }
+
+ // Write out sources file
+ Method exportSourcesMethod = schema.getClass().getMethod("exportSources", (Class[]) null);
+ String sources = (String) exportSourcesMethod.invoke(schema, (Object[]) null);
+ writeToFile(path+sourcesFileName, sources);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Writes to a given fileName the string contents. Note: The file is over-written if it previously exists.
+ * @param fileName
+ * @param contents
+ */
+ private static void writeToFile(String fileName, String contents) throws IOException
+ {
+ PrintWriter io = new PrintWriter(fileName);
+ io.print(contents);
+ io.close();
+ }
+}
Added: trunk/sql12/plugins/multisource/src/main/resources/doc/MultipleSourcePlugin_for_SQuirreL_UserManual.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/sql12/plugins/multisource/src/main/resources/doc/MultipleSourcePlugin_for_SQuirreL_UserManual.pdf
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/sql12/plugins/multisource/src/main/resources/doc/changes.txt
===================================================================
--- trunk/sql12/plugins/multisource/src/main/resources/doc/changes.txt (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/resources/doc/changes.txt 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,6 @@
+Change Log
+==========
+
+0.1
+===
+- Initial release
Added: trunk/sql12/plugins/multisource/src/main/resources/doc/licence.txt
===================================================================
--- trunk/sql12/plugins/multisource/src/main/resources/doc/licence.txt (rev 0)
+++ trunk/sql12/plugins/multisource/src/main/resources/doc/licence.txt 2012-05-15 18:02:45 UTC (rev 6617)
@@ -0,0 +1,503 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser ...
[truncated message content] |