Componentization, 202587
Refactor sqlbuilder input related classes into a new sqlbuilder.input package
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogDialectTestEditorInputAction.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogDialectTestEditorInputAction.java
index 73f3e9e..d027127 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogDialectTestEditorInputAction.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogDialectTestEditorInputAction.java
@@ -16,9 +16,9 @@
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.modelbase.sql.schema.Database;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.dialogs.SQLBuilderDialog;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.util.EditorInputUtil;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLDialectInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLStatementInfo;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogEditorInputAction.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogEditorInputAction.java
index f42d679..063dd93 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogEditorInputAction.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogEditorInputAction.java
@@ -11,9 +11,9 @@
package org.eclipse.datatools.sqltools.sqlbuilder.examples.actions;
import org.eclipse.core.resources.IFile;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.dialogs.SQLBuilderDialog;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.util.EditorInputUtil;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogFileAction.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogFileAction.java
index 1786f93..963752c 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogFileAction.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogFileAction.java
@@ -11,8 +11,8 @@
package org.eclipse.datatools.sqltools.sqlbuilder.examples.actions;
import org.eclipse.core.resources.IFile;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderFileEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.dialogs.SQLBuilderDialog;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogNewStmtEditorInputAction.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogNewStmtEditorInputAction.java
index db0c865..9b9be17 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogNewStmtEditorInputAction.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogNewStmtEditorInputAction.java
@@ -12,9 +12,9 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.dialogs.SQLBuilderDialog;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.util.EditorInputUtil;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogStorageAction.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogStorageAction.java
index e049cfe..4a5b2ec 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogStorageAction.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/actions/SQLBuilderDialogStorageAction.java
@@ -11,9 +11,9 @@
package org.eclipse.datatools.sqltools.sqlbuilder.examples.actions;
import org.eclipse.core.resources.IFile;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderStorageEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.dialogs.SQLBuilderDialog;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.util.EditorInputUtil;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderStorageEditorInput;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/dialogs/SQLBuilderDialog.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/dialogs/SQLBuilderDialog.java
index 95b26c5..5eb5623 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/dialogs/SQLBuilderDialog.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/dialogs/SQLBuilderDialog.java
@@ -16,13 +16,13 @@
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.sqltools.result.ui.view.ResultsViewControl;
import org.eclipse.datatools.sqltools.sqlbuilder.IContentChangeListener;
-import org.eclipse.datatools.sqltools.sqlbuilder.ISQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilder;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderFileEditorInput;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderInputFactory;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderStorageEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.examples.util.ResultsHistoryFilter;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderInputFactory;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderStorageEditorInput;
import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorage;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
diff --git a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/util/EditorInputUtil.java b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/util/EditorInputUtil.java
index 05592ce..6fc460b 100644
--- a/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/util/EditorInputUtil.java
+++ b/examples/org.eclipse.datatools.sqltools.sqlbuilder.examples/src/org/eclipse/datatools/sqltools/sqlbuilder/examples/util/EditorInputUtil.java
@@ -1,8 +1,8 @@
package org.eclipse.datatools.sqltools.sqlbuilder.examples.util;
import org.eclipse.core.resources.IFile;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderStorageEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderStorageEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.util.SQLBuilderEditorInputUtil;
import org.eclipse.ui.XMLMemento;
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/META-INF/MANIFEST.MF
index 6f11b30..d426b7d 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@
org.eclipse.datatools.sqltools.sqlbuilder.expressionbuilder.multiexpr,
org.eclipse.datatools.sqltools.sqlbuilder.expressionbuilder.subquery,
org.eclipse.datatools.sqltools.sqlbuilder.icons,
+ org.eclipse.datatools.sqltools.sqlbuilder.input,
org.eclipse.datatools.sqltools.sqlbuilder.model,
org.eclipse.datatools.sqltools.sqlbuilder.provider.rdbschema,
org.eclipse.datatools.sqltools.sqlbuilder.util,
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java
index de66a39..3463021 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilder.java
@@ -29,6 +29,9 @@
import org.eclipse.datatools.modelbase.sql.schema.Database;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.actions.SQLBuilderActionBarContributor;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConstants;
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilderEditor.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilderEditor.java
index 3bf3a4d..4f0f3cc 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilderEditor.java
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/SQLBuilderEditor.java
@@ -17,6 +17,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.actions.SQLBuilderActionBarContributor;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.ISQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
import org.eclipse.datatools.sqltools.sqleditor.internal.SQLEditorResources;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.viewers.ISelection;
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/actions/ActionHelper.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/actions/ActionHelper.java
index 32cd0d4..9c88b85 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/actions/ActionHelper.java
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/actions/ActionHelper.java
@@ -16,7 +16,7 @@
import org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.Messages;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderFileEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.util.WorkbenchUtility;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java
new file mode 100644
index 0000000..f66130a
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/ISQLBuilderEditorInput.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright © 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.input;
+
+import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqleditor.ISQLEditorInput;
+
+/**
+ * This interface is a mix-in interface to be used with an <code>IEditorInput</code>
+ * to add additional information to the editor input for the SQL Builder.
+ */
+public interface ISQLBuilderEditorInput extends ISQLEditorInput {
+
+ /**
+ * Gets the SQL Statement for this input - the contents of the input.
+ *
+ * @return String the SQL Statement for this input.
+ */
+ public String getSQL();
+
+ /**
+ * Gets information about whether or not to omit the default schema name from SQL generated in
+ * the SQL Builder.
+ *
+ * return IOmitSchemaInfo the <code>IOmitSchemaInfo</code> belong to this <code>ISQLBuilderEditorInput</code>.
+ */
+ public IOmitSchemaInfo getOmitSchemaInfo();
+
+ /**
+ * Sets information about whether or not to omit the default schema name from SQL generated in
+ * the SQL Builder.
+ *
+ * @param IOmitSchemaInfo the <code>IOmitSchemaInfo</code> to be set.
+ */
+ public void setOmitSchemaInfo(IOmitSchemaInfo omitSchemaInfo);
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java
new file mode 100644
index 0000000..b158b1e
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderEditorInput.java
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * Copyright © 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.input;
+
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLStatementInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLBuilderConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * This class implements the <code>ISQLEditorInput</code> interface using a string
+ * for the SQL statement itself. This class is provided as a convenience for callers
+ * of the SQL Builder who want to open it with a SQL statement as text.
+ *
+ * There are constructors which allow you to pass in ISQLEditorConnectionInfo or
+ * IConnectionProfile objects.
+ *
+ * There are constructors which allow you to pass in an existing SQL statement in a
+ * SQLStatementInfo object or to create new SQL statements by passing in
+ * an integer to specify the statement type. The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+ *
+ * @author Jeremy Lindop
+*/
+public class SQLBuilderEditorInput implements ISQLBuilderEditorInput {
+
+ /** Contains connection information associated with this object. */
+ private ISQLEditorConnectionInfo _connectionInfo;
+
+ /** Contains the SQLStatement */
+ private ISQLStatementInfo _sqlStatementInfo;
+
+ /** Contains OmitSchemaInfo associated with this object. */
+ private IOmitSchemaInfo _omitSchemaInfo;
+
+ /*
+ * Statement type is used for creating new statements. The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+ */
+ protected int _statementType = StatementHelper.STATEMENT_TYPE_SELECT;
+
+
+ /**
+ * Creates an instance of this class with the given ConnectionInfo
+ * and StatementType. This constructor is used to create
+ * new SQL statements.
+ *
+ * @param connectionInfo the ConnectionInfo
+ * @param statementType statement type is used for creating new statements.
+ * The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+
+ */
+ public SQLBuilderEditorInput(ISQLEditorConnectionInfo connectionInfo, int statementType) {
+ this(connectionInfo, null, null);
+ _statementType = statementType;
+ }
+
+ /**
+ * Creates an instance of this class with the given ConnectionProfile
+ * and StatementType. This constructor is used to create
+ * new SQL statements.
+ *
+ * @param connectionProfile the ConnectionProfile
+ * @param statementType statement type is used for creating new statements.
+ * The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+
+ */
+ public SQLBuilderEditorInput(IConnectionProfile connectionProfile, int statementType) {
+ this(connectionProfile, null, null);
+ _statementType = statementType;
+ }
+
+ /**
+ * Creates an instance of this class with the given ConnectionInfo and
+ * SQLStatementInfo. This constructor should be used to create a
+ * SQLBuilderEditorInput based on an existing SQL statement.
+ * The SQLStatementInfo may optionally contain a SQLDialectInfo object to
+ * specify the SQL dialect.
+ *
+ * @param connectionInfo the ConnectionInfo
+ * @param sqlStatementInfo the SQLStatementInfo
+ */
+ public SQLBuilderEditorInput(ISQLEditorConnectionInfo connectionInfo,
+ ISQLStatementInfo sqlStatementInfo) {
+ this(connectionInfo, sqlStatementInfo, null);
+ }
+
+ /**
+ * Creates an instance of this class with the given ConnectionProfile and
+ * SQLStatementInfo. This constructor should be used to create a
+ * SQLBuilderEditorInput based on an existing SQL statement.
+ * The SQLStatementInfo may optionally contain a SQLDialectInfo object to
+ * specify the SQL dialect.
+ *
+ * @param connectionProfile the ConnectionProfile
+ * @param sqlStatementInfo the SQLStatementInfo
+ */
+ public SQLBuilderEditorInput(IConnectionProfile connectionProfile,
+ ISQLStatementInfo sqlStatementInfo) {
+ this(connectionProfile, sqlStatementInfo, null);
+ }
+
+ /**
+ * Creates an instance of this class with the given ConnectionInfo and SQLStatementInfo.
+ * This constructor should be used to create a
+ * SQLBuilderEditorInput based on an existing SQL statement.
+ * The SQLStatementInfo may optionally contain a SQLDialectInfo object to
+ * specify the SQL dialect.
+ *
+ * @param connectionInfo the ConnectionInfo
+ * @param sqlStatementInfo the SQLStatementInfo
+ * @param omitSchemaInfo the OmitSchemaInfo
+ */
+ public SQLBuilderEditorInput(ISQLEditorConnectionInfo connectionInfo,
+ ISQLStatementInfo sqlStatementInfo,
+ IOmitSchemaInfo omitSchemaInfo) {
+ _connectionInfo = connectionInfo;
+
+ _sqlStatementInfo = sqlStatementInfo;
+
+ if (omitSchemaInfo != null){
+ _omitSchemaInfo = omitSchemaInfo;
+ }
+ else {
+ _omitSchemaInfo = new OmitSchemaInfo();
+ _omitSchemaInfo.initFromPreferences();
+ }
+ }
+
+ /**
+ * Creates an instance of this class with the given ConnectionProfile, SQLStatementInfo
+ * and OmitSchemaInfo.
+ *
+ * This constructor should be used to create a
+ * SQLBuilderEditorInput based on an existing SQL statement.
+ * The SQLStatementInfo may optionally contain a SQLDialectInfo object to
+ * specify the SQL dialect.
+ *
+ * @param connectionProfile the ConnectionProfile
+ * @param sqlStatementInfo the SQLStatementInfo
+ * @param omitSchemaInfo the OmitSchemaInfo
+ */
+ public SQLBuilderEditorInput(IConnectionProfile connectionProfile,
+ ISQLStatementInfo sqlStatementInfo,
+ IOmitSchemaInfo omitSchemaInfo) {
+ _connectionInfo = new SQLBuilderConnectionInfo(connectionProfile);
+
+ _sqlStatementInfo = sqlStatementInfo;
+
+ if (omitSchemaInfo != null){
+ _omitSchemaInfo = omitSchemaInfo;
+ }
+ else {
+ _omitSchemaInfo = new OmitSchemaInfo();
+ _omitSchemaInfo.initFromPreferences();
+ }
+ }
+
+ /**
+ * Gets the <code>ISQLEditorConnectionInfo</code> associated with this input.
+ *
+ * @return the current <code>ISQLEditorConnectionInfo</code> object
+ */
+ public ISQLEditorConnectionInfo getConnectionInfo() {
+ return _connectionInfo;
+ }
+
+ /**
+ * Sets the <code>ISQLEditorConnectionInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param connInfo the <code>ISQLEditorConnectionInfo</code> object to set
+ */
+ public void setConnectionInfo( ISQLEditorConnectionInfo connInfo ) {
+ //the connection info must not be null
+ if (connInfo == null)
+ {
+ _connectionInfo = SQLEditorConnectionInfo.DEFAULT_SQLEDITOR_CONNECTION_INFO;
+ }
+ else
+ {
+ _connectionInfo = connInfo;
+ }
+ }
+
+ /**
+ * Gets the <code>IConnectionProfile</code> associated with this input.
+ *
+ * @return the current <code>IConnectionProfile</code> object
+ */
+ public IConnectionProfile getConnectionProfile() {
+ if (_connectionInfo != null){
+ return _connectionInfo.getConnectionProfile();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Sets the <code>IConnectionProfile</code> associated with this input to the given
+ * object.
+ *
+ * @param connInfo the <code>IConnectionProfile</code> object to set
+ */
+ public void setConnectionProfile( IConnectionProfile connProfile) {
+ //the connection info must not be null
+ if (connProfile == null)
+ {
+ _connectionInfo = SQLEditorConnectionInfo.DEFAULT_SQLEDITOR_CONNECTION_INFO;
+ }
+ else
+ {
+ _connectionInfo = new SQLBuilderConnectionInfo(connProfile);
+ }
+ }
+
+ /**
+ * Sets the <code>OmitSchemaInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param omitSchemaInfo the <code>OmitSchemaInfo</code> object to set
+ */
+ public void setOmitSchemaInfo( IOmitSchemaInfo omitSchemaInfo ) {
+ if (omitSchemaInfo == null)
+ {
+ _omitSchemaInfo = new OmitSchemaInfo();
+ _omitSchemaInfo.initFromPreferences();
+ }
+ else
+ {
+ _omitSchemaInfo = omitSchemaInfo;
+ }
+ }
+
+
+ /**
+ * Gets the <code>IOmitSchemaInfo</code> associated with this input.
+ *
+ * @return the current <code>IOmitSchemaInfo</code> object
+ */
+ public IOmitSchemaInfo getOmitSchemaInfo() {
+ return _omitSchemaInfo;
+ }
+
+ /**
+ * Sets the <code>SQLStatementInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param sqlStatementInfo the <code>ISQLStatementInfo</code> object to set
+ */
+ public void setSQLStatementInfo( ISQLStatementInfo sqlStatementInfo ) {
+ _sqlStatementInfo = sqlStatementInfo;
+ }
+
+
+ /**
+ * Gets the <code>ISQLStatementInfo</code> associated with this input.
+ *
+ * @return the current <code>ISQLStatementInfo</code> object
+ */
+ public ISQLStatementInfo getSQLStatementInfo() {
+ return _sqlStatementInfo;
+ }
+
+ /**
+ * Gets the SQLStatement contained in this input's File
+ */
+ public String getSQL() {
+ if (_sqlStatementInfo != null){
+ return _sqlStatementInfo.getSQL();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the StatementType for in this input.
+ *
+ * Statement type is used for creating new statements. The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+ */
+ public int getStatementType(){
+ return _statementType;
+ }
+
+ /**
+ * Sets the StatementType for in this input.
+ *
+ * Statement type is used for creating new statements. The value must be
+ * one of {@link org.eclipse.datatools.modelbase.sql.query.helper.StatementHelper}'s
+ * STATEMENT_TYPE constants.
+ */
+ public void setStatementType(int statementType){
+ _statementType = statementType;
+ }
+
+ public String getId() {
+ return null;
+ }
+
+ public boolean isConnectionRequired() {
+ return false;
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public String getName() {
+ return "";
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ public String getToolTipText() {
+ StringBuffer sb = new StringBuffer(30);
+ if (_connectionInfo != null) {
+ sb.append(_connectionInfo.getName());
+ }
+ return sb.toString();
+
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java
new file mode 100644
index 0000000..126b75a
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderFileEditorInput.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright © 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.input;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.util.FileUtil;
+import org.eclipse.datatools.sqltools.sqlbuilder.util.SQLFileUtil;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * This class implements the <code>ISQLEditorInput</code> interface using a
+ * <code>FileEditorInput</code> as the base. In addition, this class contains
+ * fields and methods that are specifically for launching the SQL Builder. This class
+ * is provided as a convenience for callers of the SQL Builder who want to open the
+ * SQL Builder on a file.
+ */
+public class SQLBuilderFileEditorInput extends FileEditorInput implements ISQLBuilderEditorInput {
+
+ /** Contains the SQLStatement */
+ private String fSQLStatement;
+ /** Contains connection information associated with this object. */
+ private ISQLEditorConnectionInfo fConnInfo;
+ /** Contains OmitSchemaInfo associated with this object. */
+ private IOmitSchemaInfo fOmitSchemaInfo;
+
+ /**
+ * Creates an instance of this class with the given file.
+ *
+ * @param aFile the file to associate with this input
+ */
+ public SQLBuilderFileEditorInput(IFile aFile) {
+ super(aFile);
+
+ ISQLEditorConnectionInfo connectionInfo = SQLFileUtil.getConnectionInfo(aFile);
+ setConnectionInfo(connectionInfo);
+
+ IOmitSchemaInfo omitSchemaInfo = SQLFileUtil.getOmitSchemaInfo(aFile);
+ setOmitSchemaInfo(omitSchemaInfo);
+ }
+
+ /**
+ * Gets the <code>ISQLEditorConnectionInfo</code> associated with this input.
+ *
+ * @return the current <code>ISQLEditorConnectionInfo</code> object
+ */
+ public ISQLEditorConnectionInfo getConnectionInfo() {
+ return fConnInfo;
+ }
+
+ /**
+ * Sets the <code>ISQLEditorConnectionInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param connInfo the <code>ISQLEditorConnectionInfo</code> object to set
+ */
+ public void setConnectionInfo( ISQLEditorConnectionInfo connInfo ) {
+ //the connection info must not be null
+ if (connInfo == null)
+ {
+ fConnInfo = SQLEditorConnectionInfo.DEFAULT_SQLEDITOR_CONNECTION_INFO;
+ }
+ else
+ {
+ fConnInfo = connInfo;
+ }
+ }
+
+ /**
+ * Sets the <code>OmitSchemaInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param omitSchemaInfo the <code>OmitSchemaInfo</code> object to set
+ */
+ public void setOmitSchemaInfo( IOmitSchemaInfo omitSchemaInfo ) {
+ if (omitSchemaInfo == null)
+ {
+ fOmitSchemaInfo = new OmitSchemaInfo();
+ fOmitSchemaInfo.initFromPreferences();
+ }
+ else
+ {
+ fOmitSchemaInfo = omitSchemaInfo;
+ }
+ }
+
+
+ /**
+ * Gets the <code>IOmitSchemaInfo</code> associated with this input.
+ *
+ * @return the current <code>IOmitSchemaInfo</code> object
+ */
+ public IOmitSchemaInfo getOmitSchemaInfo() {
+ return fOmitSchemaInfo;
+ }
+
+ /**
+ * Gets the SQLStatement contained in this input's File
+ */
+ public String getSQL() {
+ if (fSQLStatement == null){
+ try {
+ fSQLStatement = FileUtil.getFileContents(getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return fSQLStatement;
+ }
+
+ public boolean isConnectionRequired()
+ {
+ return false;
+ }
+
+ public String getId()
+ {
+ return toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java
new file mode 100644
index 0000000..e8b1785
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderInputFactory.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright © 2000, 2007 Sybase, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sybase, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.input;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorage;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+
+
+/**
+ * The class implements a factory which is capable of saving and recreating SQLBuilderStorageEditorInputs
+ * stored in a memento.
+ *
+ * @author Jeremy Lindop
+ */
+public class SQLBuilderInputFactory implements IElementFactory {
+
+ /**
+ * The Factory ID.
+ */
+ public final static String ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_FACTORY = "org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderInputFactory"; //$NON-NLS-1$
+ /**
+ * The InputType
+ */
+ public final static String ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_TYPE = "SQLBuilderStorageEditorInput"; //$NON-NLS-1$
+ /**
+ * The root element name used in <code>XMLMemento</code> objects representing
+ * <code>SQLBuilderStorageEditorInput</code> objects.
+ */
+ public final static String ID_XML_MEMENTO_ROOT_ELEMENT = "SQLQueryBuilder";
+ /**
+ * Key used for EditorInputType property.
+ */
+ public final static String KEY_EDITOR_INPUT_TYPE = "editorInputType"; //$NON-NLS-1$
+ /**
+ * Key used for StorageName property.
+ */
+ public final static String KEY_STORAGE_NAME = "name"; //$NON-NLS-1$
+ /**
+ * Key used for Version property.
+ */
+ public final static String KEY_STORAGE_VERSION = "version"; //$NON-NLS-1$
+
+ /**
+ * Key used for SQLStatement element.
+ */
+ public final static String KEY_STORAGE_SQLCONTENT = "SQLStatement"; //$NON-NLS-1$
+ /**
+ * Key used for ConnectionInfo element.
+ */
+ public final static String KEY_CONN_INFO_CODE = "connInfo"; //$NON-NLS-1$
+ /**
+ * Key used for OmitSchemaInfo element.
+ */
+ public final static String KEY_OMIT_SCHEMA_INFO_CODE = "omitSchemaInfo"; //$NON-NLS-1$
+
+ /**
+ * Re-creates and returns an object from the state captured within the given
+ * memento. Returns a SQLBuilderStorageEditorInput.
+ *
+ * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
+ */
+ public IAdaptable createElement( IMemento memento ) {
+ IAdaptable input = null;
+
+ // Get the editor input type from the memento.
+ String editorInputType = memento.getString( KEY_EDITOR_INPUT_TYPE );
+
+ // Process a storage editor input
+ if (editorInputType.equals (ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_TYPE)) {
+ // Create a Storage object from the memento.
+ String contentName = memento.getString( KEY_STORAGE_NAME );
+ IMemento sqlStmtChild = memento.getChild(KEY_STORAGE_SQLCONTENT);
+ String contentSQLStatement = "";
+ if (sqlStmtChild != null){
+ contentSQLStatement = sqlStmtChild.getTextData();
+ }
+ SQLEditorStorage storage = new SQLEditorStorage( contentName, contentSQLStatement );
+
+ // Create a SQLBuilderStorageEditorInput from the storage we just created.
+ SQLBuilderStorageEditorInput sqlStorageInput = new SQLBuilderStorageEditorInput( storage );
+
+ // Get the connectionInfo from the memento and put the
+ // ISQLEditorConnectionInfo into the editor input object.
+ IMemento connInfoChild = memento.getChild(KEY_CONN_INFO_CODE);
+ if (connInfoChild != null){
+ String connInfoCode = connInfoChild.getTextData();
+ if (connInfoCode != null) {
+ ISQLEditorConnectionInfo connInfo = null;
+ connInfo = SQLEditorConnectionInfo.decode(connInfoCode);
+ sqlStorageInput.setConnectionInfo( connInfo );
+ }
+ }
+
+ // Get the OmitSchemaInfo name from the memento and put the
+ // OmitSchemaInfo into the editor input object.
+ IOmitSchemaInfo omitSchemaInfo = null;
+ IMemento omitSchemaInfoChild = memento.getChild(KEY_OMIT_SCHEMA_INFO_CODE);
+ if (omitSchemaInfoChild != null){
+ String omitSchemaInfoCode = omitSchemaInfoChild.getTextData();
+ if (omitSchemaInfoCode != null) {
+ omitSchemaInfo = OmitSchemaInfo.decode(omitSchemaInfoCode);
+ sqlStorageInput.setOmitSchemaInfo(omitSchemaInfo);
+ }
+ }
+
+ input = sqlStorageInput;
+ }
+
+ return input;
+ }
+
+ /**
+ * Saves the state of the given storage editor input object in the given memento.
+ *
+ * @param memento the storage area for object's state
+ * @param input the storage editor input object that needs to be saved
+ */
+ public static void saveState(IMemento memento, SQLBuilderStorageEditorInput input) {
+ // Save the editor input type.
+ memento.putString( KEY_EDITOR_INPUT_TYPE, ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_TYPE );
+
+ // Get the name from the storage object
+ String storageName = null;
+ IStorage storage = input.getStorage();
+ if (storage != null) {
+ storageName = storage.getName();
+ }
+
+ // Save the storage content name in the memento
+ memento.putString( KEY_STORAGE_NAME, storageName );
+
+ // Save the version in the memento
+ memento.putString(KEY_STORAGE_VERSION, SQLBuilderStorageEditorInput.CURRENT_VERSION);
+
+ // Get the SQL Statement from the input
+ String storageContent = input.getSQL();
+
+ // Save the storage content string, i.e. the SQL statement
+ // in the memento as a <KEY_STORAGE_CONTENT> element
+ IMemento sqlStmtChild = memento.createChild(KEY_STORAGE_SQLCONTENT);
+ sqlStmtChild.putTextData(storageContent);
+
+ // Save the connection into in the memento as a <KEY_CONN_INFO_CODE> element.
+ ISQLEditorConnectionInfo connInfo = input.getConnectionInfo();
+ if (connInfo != null) {
+ String connInfoCode = connInfo.encode();
+ IMemento connInfoChild = memento.createChild(KEY_CONN_INFO_CODE);
+ connInfoChild.putTextData(connInfoCode);
+ }
+
+ // Save the omit schema info in the memento as a <KEY_CONN_INFO_CODE> element
+ IOmitSchemaInfo omitSchemaInfo = input.getOmitSchemaInfo();
+ if (omitSchemaInfo != null) {
+ String omitSchemaInfoCode = omitSchemaInfo.encode();
+ IMemento omitSchemaInfoChild = memento.createChild(KEY_OMIT_SCHEMA_INFO_CODE);
+ omitSchemaInfoChild.putTextData(omitSchemaInfoCode);
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java
new file mode 100644
index 0000000..7ec3ea5
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/input/SQLBuilderStorageEditorInput.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright © 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.input;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqlbuilder.model.OmitSchemaInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorage;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorStorageEditorInput;
+import org.eclipse.ui.IMemento;
+
+/**
+ * This class implements the <code>ISQLBuilderEditorInput</code> interface on a
+ * <code>IStorageEditorInput</code> base. In addition, this class contains
+ * fields and methods that are specifically for launching the SQL Builder. This class
+ * is provided as a convenience for callers of the SQL Builder who want to open the
+ * SQL Builder on an input that isn't a file.
+ */
+public class SQLBuilderStorageEditorInput extends SQLEditorStorageEditorInput
+ implements ISQLBuilderEditorInput {
+
+ /** Current version identifier */
+ public static final String CURRENT_VERSION = "1.0";
+
+ /** Contains OmitSchemaInfo associated with this object. */
+ private IOmitSchemaInfo fOmitSchemaInfo = null;
+
+ /**
+ * Constructs an instance of this class with the given string as the editor
+ * input source.
+ *
+ * @param storageSource the editor input source string, i.e. the SQL statement
+ */
+ public SQLBuilderStorageEditorInput(String name, String storageSource) {
+ super(name, storageSource);
+ }
+
+ /**
+ * Constructs an instance of this class with the given <code>IStorage</code>
+ * object as the editor input source.
+ *
+ * @param storage the storage object for this editor input
+ */
+ public SQLBuilderStorageEditorInput( IStorage storage ) {
+ super( storage );
+ }
+
+ /**
+ * Gets the <code>SQLStatement</code> associated with this input.
+ *
+ * @return the current <code>SQLStatement</code>
+ */
+ public String getSQL() {
+ SQLEditorStorage storage = (SQLEditorStorage)getStorage();
+ return storage.getContentsString();
+ }
+
+ /**
+ * Sets the <code>IOmitSchemaInfo</code> associated with this input to the given
+ * object.
+ *
+ * @param omitSchemaInfo the <code>IOmitSchemaInfo</code> object to set
+ */
+ public void setOmitSchemaInfo( IOmitSchemaInfo omitSchemaInfo ) {
+ if (omitSchemaInfo == null)
+ {
+ fOmitSchemaInfo = new OmitSchemaInfo();
+ fOmitSchemaInfo.initFromPreferences();
+ }
+ else
+ {
+ fOmitSchemaInfo = omitSchemaInfo;
+ }
+ }
+
+
+ /**
+ * Gets the <code>IOmitSchemaInfo</code> associated with this input.
+ *
+ * @return the current <code>IOmitSchemaInfo</code> object
+ */
+ public IOmitSchemaInfo getOmitSchemaInfo() {
+ return fOmitSchemaInfo;
+ }
+
+ /**
+ * Returns the id of the element factory which should be used to re-create this
+ * object.
+ *
+ * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+ */
+ public String getFactoryId() {
+ return SQLBuilderInputFactory.ID_SQL_BUILDER_STORAGE_EDITOR_INPUT_FACTORY;
+ }
+
+ /**
+ * Saves the state of the object in the given memento.
+ *
+ * @param memento the storage area for object's state
+ * @see org.eclipse.ui.IPersistableElement#saveState(org.eclipse.ui.IMemento)
+ */
+ public void saveState(IMemento memento) {
+ SQLBuilderInputFactory.saveState( memento, this );
+ }
+
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConnectionInfo.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConnectionInfo.java
new file mode 100644
index 0000000..6fbfa24
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/model/SQLBuilderConnectionInfo.java
@@ -0,0 +1,147 @@
+/***********************************************************************************************************************
+ * Copyright (c) 2005 Sybase, Inc. All rights reserved. This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Sybase, Inc. - initial API and implementation
+ **********************************************************************************************************************/
+package org.eclipse.datatools.sqltools.sqlbuilder.model;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.IConnection;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.IManagedConnection;
+import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo;
+import org.eclipse.datatools.modelbase.sql.schema.Database;
+import org.eclipse.datatools.sqltools.core.DatabaseVendorDefinitionId;
+import org.eclipse.datatools.sqltools.core.profile.ProfileUtil;
+import org.eclipse.datatools.sqltools.sqleditor.EditorConstants;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+
+/**
+ * This class extends SQLEditorConnectionInfo so that a ConnectionInfo object
+ * can be constructed from a ConnectionProfile.
+ *
+ * @author Jeremy Lindop
+ */
+public class SQLBuilderConnectionInfo extends SQLEditorConnectionInfo {
+
+ protected IConnectionProfile _connectionProfile = null;
+ protected static final String CANNOT_ENCODE = "CANNOT ENCODE SQLBuilderConnectionInfo BECAUSE IT WAS CONSTRUCTED FROM A ConnectionProfile, NOT A ConnectionInfo.";
+
+ /**
+ * Constructs a <code>SQLBuilderConnectionInfo</code> by
+ * <code>ConnectionProfile</code>.
+ *
+ * @param connectionProfile
+ * <code>IConnectionProfile</code>
+ */
+ public SQLBuilderConnectionInfo( IConnectionProfile connectionProfile) {
+ super(ProfileUtil.getDatabaseVendorDefinitionId(connectionProfile));
+ _connectionProfile = connectionProfile;
+
+ this.setConnectionProfileName(_connectionProfile.getName());
+
+ Properties props = _connectionProfile.getBaseProperties();
+ Object objUserName = props.get("org.eclipse.datatools.connectivity.db.username");
+ if (objUserName != null && objUserName instanceof String){
+ this.setDefaultSchemaName((String)objUserName);
+ }
+
+ Object objDbName = props.get("org.eclipse.datatools.connectivity.db.databaseName");
+ if (objDbName != null && objDbName instanceof String){
+ this.setDatabaseName((String)objDbName);
+ }
+
+ }
+
+
+ public IConnectionProfile getConnectionProfile() {
+ if (_connectionProfile != null){
+ return _connectionProfile;
+ }
+ else {
+ return super.getConnectionProfile();
+ }
+ }
+
+ public String getConnectionProfileName() {
+ if (_connectionProfile != null){
+ return _connectionProfile.getName();
+ }
+ else {
+ return super.getConnectionProfileName();
+ }
+ }
+
+ public Database getDatabase() {
+ if (_connectionProfile != null){
+ // This code comes from ProfileUtil.getDatabase()
+ IManagedConnection mc = _connectionProfile.getManagedConnection(ConnectionInfo.class.getName());
+ //during the profile connected event notification,
+ //IManagedConnection is connected while IConnectionProfile is not
+ if (!mc.isConnected())
+ {
+ _connectionProfile.connect();
+ }
+ IConnection ic = mc.getConnection();
+ if (ic == null)
+ {
+ return null;
+ }
+ Object rawConn = ic.getRawConnection();
+ if (rawConn instanceof ConnectionInfo)
+ {
+ ConnectionInfo ci = (ConnectionInfo)rawConn;
+ return ci.getSharedDatabase();
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return super.getDatabase();
+ }
+ }
+
+
+ /**
+ * Retrieves the sharable connection from IControlConnection, which in turn delegates to the connectivity layer.
+ */
+ public Connection getSharedConnection() {
+ if (_connectionProfile != null){
+ // This code is taken from ProfileUtil.getReusableConnection
+ if (!_connectionProfile.isConnected())
+ {
+ return null;
+ }
+ IManagedConnection managedConn = _connectionProfile.getManagedConnection("java.sql.Connection");
+ if (managedConn == null || !managedConn.isConnected())
+ {
+ return null;
+ }
+
+ IConnection iconn = managedConn.getConnection();
+ Connection conn = (Connection)iconn.getRawConnection();
+ _sharedConn = conn;
+ }
+ else {
+ _sharedConn = super.getSharedConnection();
+ }
+ return _sharedConn;
+ }
+
+ /**
+ * Encodes the given <code>SQLBuilderConnectionInfo</code> object for persistence
+ * @see decode()
+ * @param info
+ * @return A encoded String
+ */
+ public String encode()
+ {
+ return super.encode();
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLBuilderEditorInputUtil.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLBuilderEditorInputUtil.java
index 3474c48..a2084a8 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLBuilderEditorInputUtil.java
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLBuilderEditorInputUtil.java
@@ -17,10 +17,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderFileEditorInput;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderInputFactory;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderStorageEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderFileEditorInput;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderInputFactory;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderStorageEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.model.IOmitSchemaInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLStatementInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLStatementInfo;
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLParserUtil.java b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLParserUtil.java
index 7f19298..aadaf4b 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLParserUtil.java
+++ b/plugins/org.eclipse.datatools.sqltools.sqlbuilder/src/org/eclipse/datatools/sqltools/sqlbuilder/util/SQLParserUtil.java
@@ -11,8 +11,8 @@
import org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParseResult;
import org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager;
import org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManagerProvider;
-import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderPlugin;
+import org.eclipse.datatools.sqltools.sqlbuilder.input.SQLBuilderEditorInput;
import org.eclipse.datatools.sqltools.sqlbuilder.model.ISQLDialectInfo;
import org.eclipse.datatools.sqltools.sqlbuilder.model.SQLDomainModel;