Recover lost files
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/build.xml b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/build.xml
index 6bb193e..dc099df 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/build.xml
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/build.xml
@@ -97,22 +97,33 @@
 		</fileset>
 		<!-- Dependencies on other DTP plug-ins, built before this one -->
 		<fileset dir="../">
-			<include name="org.eclipse.datatools.connectivity/bin/*"/>
 			<include name="org.eclipse.datatools.connectivity/connectivity.jar"/>
-			<include name="org.eclipse.datatools.connectivity.sqm.core/bin/*"/>
+			<include name="org.eclipse.datatools.connectivity.ui/connectivityui.jar"/>
+			<include name="org.eclipse.datatools.connectivity.db.generic/genericdb.jar"/>
+			<include name="org.eclipse.datatools.connectivity.db.generic.ui/genericdbui.jar"/>
 			<include name="org.eclipse.datatools.connectivity.sqm.core/rdbcore.jar"/>
-			<include name="org.eclipse.datatools.modelbase.dbdefinition/bin/*"/>
 			<include name="org.eclipse.datatools.modelbase.dbdefinition/databasedefinition.jar"/>
-			<include name="org.eclipse.datatools.modelbase.sql/bin/*"/>
 			<include name="org.eclipse.datatools.modelbase.sql/sqlmodel.jar"/>
-			<include name="org.eclipse.datatools.sqltools.sql/bin/*"/>
 			<include name="org.eclipse.datatools.sqltools.sql/sqltools.jar"/>
-			<include name="org.eclipse.datatools.sqltools.editor.core/bin/*"/>
 			<include name="org.eclipse.datatools.sqltools.editor.core/sqleditorframe.jar"/>
-			<include name="org.eclipse.datatools.sqltools.result/bin/*"/>
+			<include name="org.eclipse.datatools.sqltools.common.ui/sqltoolscommonui.jar"/>
 			<include name="org.eclipse.datatools.sqltools.result/sqlresult.jar"/>
 			<include name="org.eclipse.datatools.sqltools.sqleditor/sqleditor.jar"/>
 		</fileset>
+		<dirset dir="../">
+			<include name="org.eclipse.datatools.connectivity/bin"/>
+			<include name="org.eclipse.datatools.connectivity.ui/bin"/>
+			<include name="org.eclipse.datatools.connectivity.db.generic/bin"/>
+			<include name="org.eclipse.datatools.connectivity.db.generic.ui/bin"/>
+			<include name="org.eclipse.datatools.connectivity.sqm.core/bin"/>
+			<include name="org.eclipse.datatools.modelbase.dbdefinition/bin"/>
+			<include name="org.eclipse.datatools.modelbase.sql/bin"/>
+			<include name="org.eclipse.datatools.sqltools.sql/bin"/>
+			<include name="org.eclipse.datatools.sqltools.editor.core/bin"/>
+			<include name="org.eclipse.datatools.sqltools.common.ui/bin"/>
+			<include name="org.eclipse.datatools.sqltools.result/bin"/>
+			<include name="org.eclipse.datatools.sqltools.sqleditor/bin"/>
+		</dirset>
 	</path>
 	<property name="bootclasspath" refid="path_bootclasspath"/>
 
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/images/qrydoc.gif b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/images/qrydoc.gif
new file mode 100644
index 0000000..cd1bd19
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/images/qrydoc.gif
Binary files differ
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/plugin.xml b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/plugin.xml
index 0c6d4d4..7b92cc3 100644
--- a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/plugin.xml
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/plugin.xml
@@ -29,6 +29,7 @@
       <import plugin="org.eclipse.datatools.sqltools.common.ui"/>
       <import plugin="org.eclipse.datatools.connectivity.db.generic"/>
       <import plugin="org.eclipse.datatools.connectivity.ui"/>
+      <import plugin="org.eclipse.datatools.connectivity.db.generic.ui"/>
    </requires>
    <extension
          point="org.eclipse.ui.editors">
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/SqlscrapbookPlugin.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/SqlscrapbookPlugin.java
new file mode 100644
index 0000000..af0f914
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/SqlscrapbookPlugin.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Exadel Inc - additional implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor.SQLScrapbookDocumentProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class SqlscrapbookPlugin extends AbstractUIPlugin {
+    // The shared instance of this plugin class
+    private static SqlscrapbookPlugin plugin;
+    private IDocumentProvider documentProvider;
+    
+    public static final String PLUGIN_ID="org.eclipse.datatools.sqltools.sqlscrapbook";
+    /**
+     * The constructor.
+     */
+    public SqlscrapbookPlugin() {
+        super();
+        plugin = this;
+    }
+
+    /**
+     * Returns the shared instance.
+     */
+    public static SqlscrapbookPlugin getDefault() {
+        return plugin;
+    }
+
+    /**
+     * Returns the plugin's resource bundle,
+     */
+    public ResourceBundle getResourceBundle() {
+        return Platform.getResourceBundle(getDefault().getBundle());
+    }
+
+    /**
+     * Returns the string from the plugin's resource bundle,
+     * or 'key' if not found.
+     */
+    public static String getResourceString(String key) {
+        ResourceBundle bundle = SqlscrapbookPlugin.getDefault().getResourceBundle();
+        try {
+            return (bundle != null) ? bundle.getString(key) : key;
+        } catch (MissingResourceException e) {
+            return key;
+        }
+    }
+
+    /**
+     * Gets the string resource for a key and does one substitution.
+     * 
+     * @param key
+     *            The key for the String
+     * @param s1
+     *            the substitution
+     * @return the new string after substitution
+     */
+    public String getString(String key, Object s1) {
+        String resourceString = getResourceString( key );
+        return MessageFormat.format(resourceString, new Object[] { s1 });
+    }
+
+    public static IWorkspace getWorkspace() {
+		return ResourcesPlugin.getWorkspace();
+	}
+
+	public static IWorkbenchPage getActivePage() {
+		return getDefault().internalGetActivePage();
+	}
+
+	public static IWorkbenchWindow getActiveWorkbenchWindow() {
+		return getDefault().getWorkbench().getActiveWorkbenchWindow();
+	}
+
+	public static Shell getActiveWorkbenchShell() {
+		IWorkbenchWindow window = getActiveWorkbenchWindow();
+		if (window != null) {
+			return window.getShell();
+		}
+		return null;
+	}
+
+	private IWorkbenchPage internalGetActivePage() {
+		IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
+		if (window == null)
+			return null;
+		return getWorkbench().getActiveWorkbenchWindow().getActivePage();
+	}
+
+	public static String getPluginId() {
+		return getDefault().getBundle().getSymbolicName();
+	}
+
+	public static void log(IStatus status) {
+		getDefault().getLog().log(status);
+	}
+
+	public static void log(Throwable e) {
+		log(new Status(IStatus.ERROR, getPluginId(), 1,
+				getResourceString("SQLScrapbookPlugin.internal_error"), e)); //$NON-NLS-1$
+	}
+
+	public IDocumentProvider getSQLEditorDocumentProvider() {
+		if (documentProvider == null)
+			documentProvider = new SQLScrapbookDocumentProvider();
+		return documentProvider;
+	}
+
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+	}
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/actions/SetConnectionInfoAction.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/actions/SetConnectionInfoAction.java
new file mode 100644
index 0000000..40cff6c
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/actions/SetConnectionInfoAction.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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 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.internal.sqlscrapbook.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.connection.ConnectionInfoDialog;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor.SQLScrapbookEditor;
+import org.eclipse.datatools.sqltools.sqleditor.internal.IHelpContextIds;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+
+/**
+ * @author Li Huang
+ *
+ */
+public class SetConnectionInfoAction extends TextEditorAction
+{
+    SQLScrapbookEditor _sqlEditor;
+
+    /**
+     * @param bundle
+     * @param prefix
+     * @param editor
+     */
+    public SetConnectionInfoAction(ResourceBundle bundle, String prefix, ITextEditor editor)
+    {
+        super(bundle, prefix, editor);
+        _sqlEditor = (SQLScrapbookEditor) editor;
+        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IHelpContextIds.ATTACH_CONNECTION_PROFILE_ACTION);
+    }
+
+    public void run()
+    {
+        ConnectionInfoDialog dlg = new ConnectionInfoDialog(_sqlEditor.getEditorSite().getShell(), _sqlEditor.getConnectionInfo());
+        if (dlg.open() != IDialogConstants.CANCEL_ID)
+        {
+        	_sqlEditor.setConnectionInfo(dlg.getConnectionInfo());
+        }
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoDialog.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoDialog.java
new file mode 100644
index 0000000..18b0650
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoDialog.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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 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.internal.sqlscrapbook.connection;
+
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.internal.IHelpContextIds;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Hui Cao
+ * 
+ */
+public class ConnectionInfoDialog extends Dialog implements Listener {
+	private ConnectionInfoGroup _group = null;
+
+	private boolean _isConnected = false;
+
+	private boolean _mustConnect = false;
+
+	private ISQLEditorConnectionInfo _connInfo = null;
+
+	/**
+	 * @param parentShell
+	 */
+	public ConnectionInfoDialog(Shell parentShell) {
+		this(parentShell, null);
+	}
+
+	/**
+	 * @param parentShell
+	 */
+	public ConnectionInfoDialog(Shell parentShell,
+			ISQLEditorConnectionInfo connInfo) {
+		super(parentShell);
+		this._connInfo = connInfo;
+	}
+
+	/**
+	 * Returns the <code>ISQLEditorConnectionInfo</code> object specified by
+	 * user. This should be called after {@link #finish()}.
+	 * 
+	 * @return <code>ISQLEditorConnectionInfo</code> containing all the
+	 *         information specified by user
+	 */
+	public ISQLEditorConnectionInfo getConnectionInfo() {
+		return _connInfo;
+	}
+
+	public boolean isConnected() {
+		return _isConnected;
+	}
+
+	/**
+	 * Sets whether user can finish this dialog without connecting.
+	 * @param mustConnect true if user has to connect, default is false.
+	 */
+	public void setMustConnect(boolean mustConnect) {
+		this._mustConnect = mustConnect;
+	}
+
+	protected Control createDialogArea(Composite parent) {
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getShell(),
+				IHelpContextIds.ATTACHING_PROFILE);
+
+		Composite composite = (Composite) super.createDialogArea(parent);
+		if (_connInfo == null || _connInfo.getConnectionProfile() == null ) {
+			Label label = new Label(composite, SWT.NONE);
+			label.setText(Messages
+					.getString("SelectProfileDialog.noprofile"));
+			label.setForeground(JFaceColors.getErrorText(label.getDisplay()));
+		}else 
+		{
+			String profileName = _connInfo.getConnectionProfileName();
+			if (_connInfo.getConnectionProfile() == null) {
+				Label label = new Label(composite, SWT.NONE);
+				
+				label.setText(Messages.getString(
+						"SelectProfileDialog.wrongprofile", profileName));
+				label.setForeground(JFaceColors.getErrorText(label.getDisplay()));
+			}
+		}
+		_group = new ConnectionInfoGroup(composite, this, _connInfo, true,
+				_mustConnect);
+		checkOK();
+		return composite;
+	}
+
+	/*
+	 * (non-Javadoc) Method declared in Window.
+	 */
+	protected void configureShell(Shell shell) {
+		super.configureShell(shell);
+		shell.setText(Messages.getString("SelectProfileDialog.title")); //$NON-NLS-1$
+	}
+
+	protected void okPressed() {
+		if (!_group.canFinish()) {
+			return;
+		}
+		_group.finish();
+		_isConnected = _group.isConnected();
+		_connInfo = _group.getConnectionInfo();
+		super.okPressed();
+	}
+
+	protected void createButtonsForButtonBar(Composite parent) {
+		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+				true);
+		createButton(parent, IDialogConstants.CANCEL_ID,
+				IDialogConstants.CANCEL_LABEL, false);
+		checkOK();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+	 */
+	public void handleEvent(Event event) {
+		if (event.widget == _group) {
+			checkOK();
+		}
+	}
+
+	private boolean checkOK() {
+		boolean enabled = _group.canFinish();
+		if (getButton(IDialogConstants.OK_ID) != null) {
+			getButton(IDialogConstants.OK_ID).setEnabled(enabled);
+		}
+		return enabled;
+	}
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoGroup.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoGroup.java
new file mode 100644
index 0000000..386fe8c
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/ConnectionInfoGroup.java
@@ -0,0 +1,639 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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 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.internal.sqlscrapbook.connection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
+import org.eclipse.datatools.sqltools.common.ui.util.SWTUtils;
+import org.eclipse.datatools.sqltools.core.DatabaseIdentifier;
+import org.eclipse.datatools.sqltools.core.DatabaseVendorDefinitionId;
+import org.eclipse.datatools.sqltools.core.DefaultDBFactory;
+import org.eclipse.datatools.sqltools.core.EditorCorePlugin;
+import org.eclipse.datatools.sqltools.core.IDBFactory;
+import org.eclipse.datatools.sqltools.core.SQLToolsFacade;
+import org.eclipse.datatools.sqltools.core.profile.ProfileUtil;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A reusable component for user to specify database vendor definition,
+ * (optional) connection profile name, (optional) database name and whether to
+ * connect.
+ * 
+ * @author Hui Cao
+ * 
+ */
+public class ConnectionInfoGroup extends Composite implements SelectionListener,
+		Listener {
+	private Label _labelName = null;
+
+	private Combo _comboProfileName = null;
+
+	private Combo _comboType = null;
+
+	private Label _labelType = null;
+
+	private Label _labelDbName = null;
+
+	private Combo _combodbName = null;
+
+	private Button _checkBoxConnect = null;
+
+	private Text _textWarning = null;
+
+	private Button _create = null;
+
+	private String _profileName = null;
+
+	private String _dbName = null;
+
+	private DatabaseVendorDefinitionId _dbVendorId = DefaultDBFactory
+			.getDefaultInstance().getDatabaseVendorDefinitionId();
+
+	private boolean _isConnected = false;
+
+	private boolean _showWarning = true;
+
+	private boolean _mustConnect = true;
+
+	// The listener to notify of events
+	private Listener _listener;
+
+	private ISQLEditorConnectionInfo _connInfo = null;
+
+	/**
+	 * @param parent
+	 *            The parent widget of the group.
+	 * @param listener
+	 *            A listener to forward events to. Can be null if no listener is
+	 *            required.
+	 */
+	public ConnectionInfoGroup(Composite parent, Listener listener,
+			boolean showWarning) {
+		this(parent, listener, null, null, showWarning, false);
+	}
+
+	public ConnectionInfoGroup(Composite parent, Listener listener,
+			String profileName, String dbName, boolean showWarning,
+			boolean mustConnect) {
+		this(parent, listener, null, showWarning, false);
+	}
+
+	/**
+	 * @param parent
+	 *            The parent widget of the group.
+	 * @param listener
+	 *            A listener to forward events to. Can be null if no listener is
+	 *            required.
+	 * @param profileName
+	 *            the old profile name
+	 * @param dbType
+	 *            the initial selected db type, only useful when profileName is
+	 *            null
+	 */
+	public ConnectionInfoGroup(Composite parent, Listener listener,
+			ISQLEditorConnectionInfo connInfo, boolean showWarning,
+			boolean mustConnect) {
+		super(parent, SWT.NONE);
+		if (connInfo != null)
+		{
+			this._profileName = connInfo.getConnectionProfileName();
+			this._dbName = connInfo.getDatabaseName();
+			this._dbVendorId = connInfo.getDatabaseVendorDefinitionId();
+		}
+		this._listener = listener;
+		this._showWarning = showWarning;
+		this._mustConnect = mustConnect;
+		createContents();
+		updateFields();
+	}
+
+	/**
+	 * Returns the <code>ISQLEditorConnectionInfo</code> object specified by
+	 * user. This should be called after {@link #finish()}.
+	 * 
+	 * @return <code>ISQLEditorConnectionInfo</code> containing all the
+	 *         information specified by user
+	 */
+	public ISQLEditorConnectionInfo getConnectionInfo() {
+		return _connInfo;
+	}
+	
+    public boolean isConnected()
+    {
+        return _isConnected;
+    }
+
+
+	protected Control createContents() {
+		// add controls to composite as necessary
+		org.eclipse.swt.layout.GridLayout gridLayout1 = new GridLayout();
+		org.eclipse.swt.layout.GridLayout gridLayout2 = new GridLayout();
+		org.eclipse.swt.layout.GridData gridData2 = new org.eclipse.swt.layout.GridData();
+		org.eclipse.swt.layout.GridData gridData3 = new org.eclipse.swt.layout.GridData();
+		org.eclipse.swt.layout.GridData gridData6 = new org.eclipse.swt.layout.GridData();
+
+		this.setLayoutData(new GridData(GridData.FILL_BOTH));
+		gridLayout1.marginWidth = 0;
+		gridLayout1.numColumns = 2;
+		this.setLayout(gridLayout1);
+
+		_labelType = new Label(this, SWT.NONE);
+		_labelType.setText(Messages
+				.getString("SelectProfileDialog.profile.type")); //$NON-NLS-1$
+		createComboType(this);
+
+		_labelName = new Label(this, SWT.NONE);
+		_labelName.setText(Messages
+				.getString("SelectProfileDialog.profile.name")); //$NON-NLS-1$
+		//hide the "create" button for now since we can't invoke the right wizard
+//		Composite compositeName = new Composite(this, SWT.NONE);
+//		gridData3.grabExcessHorizontalSpace = true;
+//		gridData3.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+//		compositeName.setLayoutData(gridData3);
+//		gridLayout2.numColumns = 2;
+//		gridLayout2.marginHeight = 0;
+//		gridLayout2.marginWidth = 0;
+//		compositeName.setLayout(gridLayout2);
+		createComboProfileName(this);
+//		_create = new Button(compositeName, SWT.PUSH);
+//		_create.setText(Messages.getString("SelectProfileDialog.create")); //$NON-NLS-1$
+//		_create.addListener(SWT.Selection, this);
+
+		_labelDbName = new Label(this, SWT.NONE);
+		_labelDbName.setText("Database Name:");
+		createComboDbName(this);
+
+		if (!_mustConnect) {
+			_checkBoxConnect = new Button(this, SWT.CHECK);
+			gridData2.horizontalSpan = 2;
+			_checkBoxConnect.setLayoutData(gridData2);
+			_checkBoxConnect.setText(Messages
+					.getString("SelectProfileDialog.donot.connect")); //$NON-NLS-1$
+			_checkBoxConnect.addListener(SWT.Selection, this);
+			if (_listener != null) {
+				_checkBoxConnect.addListener(SWT.Selection, _listener);
+			}
+		}
+		if (_showWarning) {
+			_textWarning = new Text(this, SWT.MULTI | SWT.WRAP);
+			gridData6.grabExcessHorizontalSpace = true;
+			gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+			gridData6.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
+			gridData6.horizontalSpan = 2;
+			gridData6.verticalSpan = 2;
+			_textWarning.setLayoutData(gridData6);
+			_textWarning.setEditable(false);
+			_textWarning.setText(Messages
+					.getString("SelectProfileDialog.warning")); //$NON-NLS-1$
+			_textWarning.setVisible(false);
+			// setSize to hold the warning
+			this.setSize(new org.eclipse.swt.graphics.Point(460, 469));
+		}
+
+		return this;
+	}
+
+	/**
+	 * Accepts user's input and generates a
+	 * <code>ISQLEditorConnectionInfo</code> object.
+	 * 
+	 * @see #getConnectionInfo()
+	 * 
+	 */
+	public void finish() {
+		updateFields();
+		if (!canFinish()) {
+			return;
+		}
+		_connInfo = new SQLEditorConnectionInfo(_dbVendorId, _profileName, _dbName);
+
+		if (!_mustConnect && _checkBoxConnect.getSelection()) {
+			_isConnected = false;
+		} else if (!SWTUtils.notEmpty(_comboProfileName)) {
+			_isConnected = false;
+		} else {
+			// connect using the profile
+			IConnectionProfile profile = ProfileManager.getInstance()
+					.getProfileByName(_profileName);
+			if (profile == null) {
+				return;
+			}
+
+			try {
+				ProfileUtil.getReusableConnection(new DatabaseIdentifier(
+						_profileName, _dbName));
+				_isConnected = true;
+			} catch (Exception e) {
+				String statusmsg = e.getMessage();
+				if (statusmsg == null) {
+					statusmsg = ""; //$NON-NLS-1$
+				}
+				IStatus status = new Status(IStatus.ERROR,
+						EditorCorePlugin.PLUGIN_ID, 0, statusmsg, e);
+				Shell shell = getShell();
+				String title = Messages
+						.getString("SelectProfileDialog.error.jdbc.title"); //$NON-NLS-1$
+				String msg = Messages
+						.getString("SelectProfileDialog.error.jdbc.message"); //$NON-NLS-1$
+				ErrorDialog.openError(shell, title, msg, status);
+
+				return;
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+	 */
+	public void widgetSelected(SelectionEvent e) {
+		if (e.widget == _comboType) {
+			refreshProfileNames(_comboType.getText(), null);
+		} else if (e.widget == _comboProfileName) {
+			canFinish();
+		}
+		updateFields();
+
+		notifyListener();
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+	 */
+	public void widgetDefaultSelected(SelectionEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+	 */
+	public void handleEvent(Event event) {
+		if (event.widget == _create) {
+			IDBFactory f = SQLToolsFacade.getDBFactoryByDBDefName(_comboType.getText());
+			if (f == null) {
+				return;
+			}
+			// FIXME: should invoke NewConnectionProfileWizard specific to the
+			// database vendor definition
+			NewConnectionProfileWizard wizard = new NewConnectionProfileWizard();
+			String[] currentNames = getCurrentProfileNames();
+			WizardDialog dlg = new WizardDialog(getShell(), wizard);
+			int id = dlg.open();
+			if (id != IDialogConstants.CANCEL_ID) {
+				// refresh all the profile info so that we can select the newly
+				// created one
+				String[] newNames = getCurrentProfileNames();
+				String newProfile = getNewProfileName(currentNames, newNames);
+				if (newProfile != null) {
+					selectTypebyProfile(newProfile);
+					refreshProfileNames(_comboType.getText(), newProfile);
+					canFinish();
+				}
+				notifyListener();
+			}
+		} else if (event.widget == _checkBoxConnect) {
+
+			_isConnected = !_checkBoxConnect.getSelection();
+			if (_showWarning) {
+				_textWarning.setVisible(_checkBoxConnect.getSelection());
+			}
+		}
+	}
+
+	/**
+	 * Validates user's input to see whether the information is complete.
+	 * 
+	 * @return true if so, otherwise false
+	 */
+	public boolean canFinish() {
+		IConnectionProfile connectionProfile = ProfileManager.getInstance()
+				.getProfileByName(_profileName);
+		// OK is disabled if profileName is selected and database name is empty.
+		if (SWTUtils.notEmpty(_comboType)
+				&& !SWTUtils.notEmpty(_comboProfileName)) {
+			return true;
+		} else if ((SWTUtils.notEmpty(_comboProfileName) && SWTUtils
+				.notEmpty(_combodbName))) {
+			return true;
+		}
+		// For Replication Server
+		else if (SWTUtils.notEmpty(_comboType)
+				&& !ProfileUtil.isDatabaseProfile(connectionProfile)) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	public String getWarning() {
+		if (!_mustConnect && _checkBoxConnect.getSelection()) {
+			return Messages.getString("SelectProfileDialog.warning");
+		}
+		return null;
+	}
+
+	/**
+	 * Finds the first profile name that does not exist in currentNames. This is
+	 * used
+	 * 
+	 * @param currentNames
+	 * @param newNames
+	 * @return
+	 */
+	private String getNewProfileName(String[] currentNames, String[] newNames) {
+		if (currentNames != null && newNames != null) {
+			for (int i = 0; i < newNames.length; i++) {
+				boolean found = false;
+				for (int j = 0; j < currentNames.length; j++) {
+					if (newNames[i].equals(currentNames[j])) {
+						found = true;
+						break;
+					}
+				}
+				if (!found) {
+					return newNames[i];
+				}
+			}
+		}
+		if (currentNames == null && newNames != null && newNames.length > 0) {
+			return newNames[0];
+		}
+		return null;
+	}
+
+	private String[] getCurrentProfileNames() {
+		IConnectionProfile profiles[] = ProfileManager.getInstance()
+				.getProfiles();
+		String[] currentNames = new String[profiles.length];
+		for (int i = 0; i < profiles.length; i++) {
+			currentNames[i] = profiles[i].getName();
+		}
+		return currentNames;
+	}
+
+	/**
+	 * 
+	 */
+	private void updateFields() {
+		if (_comboType.getText() != null && !"".equals(_comboType.getText()))
+		{
+			_dbVendorId = new DatabaseVendorDefinitionId(_comboType.getText());
+		}
+		// set _profileName to "" has no meaning
+		if (_comboProfileName.getText() != null
+				&& !"".equals(_comboProfileName.getText())) {
+			_profileName = _comboProfileName.getText();
+		} else {
+			_profileName = null;
+		}
+		if (_combodbName != null && _combodbName.getText() != null
+				&& !"".equals(_combodbName.getText())) {
+			_dbName = _combodbName.getText();
+		}
+
+	}
+
+	/**
+	 * 
+	 */
+	private void notifyListener() {
+		// fire an event so the parent can update its controls
+		if (_listener != null) {
+			Event changeEvent = new Event();
+			changeEvent.type = SWT.Selection;
+			changeEvent.widget = this;
+			_listener.handleEvent(changeEvent);
+		}
+	}
+
+	/**
+	 * This method initializes _comboProfileName
+	 * 
+	 */
+	private void createComboProfileName(Composite composite) {
+		org.eclipse.swt.layout.GridData gridData5 = new org.eclipse.swt.layout.GridData();
+		_comboProfileName = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
+		gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+		gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
+		gridData5.grabExcessHorizontalSpace = true;
+		_comboProfileName.setLayoutData(gridData5);
+
+		_comboProfileName.addModifyListener(new ModifyListener() {
+
+			public void modifyText(ModifyEvent e) {
+				if (_comboProfileName.getSelectionIndex() != -1) {
+					if (_combodbName != null) {
+						_combodbName.removeAll();
+
+						// for non-database profile, this combo box is always
+						// disabled.
+						String profileName = _comboProfileName.getText();
+						IConnectionProfile connectionProfile = ProfileManager
+								.getInstance().getProfileByName(profileName);
+						if (ProfileUtil.isDatabaseProfile(connectionProfile)) {
+							_combodbName.setEnabled(true);
+						} else {
+							_combodbName.setEnabled(false);
+						}
+					}
+				} else {
+					if (_combodbName != null) {
+						_combodbName.removeAll();
+						_combodbName.setEnabled(false);
+					}
+				}
+
+			}
+		});
+		refreshProfileNames(_comboType.getText(), _profileName);
+		_comboProfileName.addSelectionListener(this);
+	}
+
+	private void createComboDbName(Composite composite) {
+		org.eclipse.swt.layout.GridData gridData5 = new org.eclipse.swt.layout.GridData();
+		_combodbName = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
+		gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+		gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
+		gridData5.grabExcessHorizontalSpace = true;
+		_combodbName.setVisibleItemCount(20);
+		_combodbName.setLayoutData(gridData5);
+
+		if (_comboProfileName.getSelectionIndex() == -1) {
+			_combodbName.setEnabled(false);
+		}
+
+		_combodbName.addFocusListener(new FocusListener() {
+
+			public void focusGained(FocusEvent e) {
+				_combodbName.removeAll();
+				String profileName = _comboProfileName.getText();
+				if (profileName != null) {
+					List list = ProfileUtil.getDatabaseList(profileName);
+					Iterator iterator = list.iterator();
+					while (iterator.hasNext()) {
+						_combodbName.add(iterator.next().toString());
+					}
+				}
+
+			}
+
+			public void focusLost(FocusEvent e) {
+
+			}
+		});
+
+		// for non-database profile, this combo box is always disabled.
+		String profileName = _comboProfileName.getText();
+		if (profileName != null) {
+			IConnectionProfile connectionProfile = ProfileManager.getInstance()
+					.getProfileByName(profileName);
+			if (ProfileUtil.isDatabaseProfile(connectionProfile)) {
+				_combodbName.setEnabled(true);
+			} else {
+				_combodbName.setEnabled(false);
+			}
+		}
+		_combodbName.addSelectionListener(this);
+		if (_dbName != null) {
+			_combodbName.add(_dbName);
+			_combodbName.setText(_dbName);
+		}
+
+	}
+
+	/**
+	 * This method initializes _comboType
+	 * 
+	 */
+	private void createComboType(Composite composite) {
+		// com.sybase.stf.servers.core.category.database
+		org.eclipse.swt.layout.GridData gridData4 = new org.eclipse.swt.layout.GridData();
+		_comboType = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
+		gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+		gridData4.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
+		gridData4.grabExcessHorizontalSpace = true;
+		_comboType.setLayoutData(gridData4);
+
+		Collection supportedDBDefinitionNames = SQLToolsFacade
+				.getSupportedDBDefinitionNames();
+		_comboType.setItems((String[]) supportedDBDefinitionNames
+				.toArray(new String[0]));
+		if (_profileName != null) {
+			selectTypebyProfile(_profileName);
+		} else if (supportedDBDefinitionNames.contains(_dbVendorId.toString())) {
+			_comboType.setText(_dbVendorId.toString());
+		} else if (supportedDBDefinitionNames.size() > 0) {
+			_comboType.setText((String) supportedDBDefinitionNames.iterator()
+					.next());
+		}
+		_comboType.addSelectionListener(this);
+
+	}
+
+	/**
+	 * Tries to set the database vendor definition combo box when a connection
+	 * profile name is specified (during initialization or connection profile
+	 * creation)
+	 */
+	private void selectTypebyProfile(String profileName) {
+		IDBFactory factory = SQLToolsFacade
+				.getDBFactoryByProfileName(profileName);
+		if (factory != null) {
+			String dbDefName = factory.getDatabaseVendorDefinitionId()
+					.toString();
+			_comboType.setText(dbDefName);
+
+		}
+	}
+
+	/**
+	 * Refreshes the connection profile name combo box
+	 * 
+	 * @param dbVendorName
+	 */
+	private void refreshProfileNames(String dbVendorName, String initialProfName) {
+		if (dbVendorName == null || dbVendorName.equals("")) {
+			//$NON-NLS-1$
+			return;
+		}
+		DatabaseVendorDefinitionId selectedDbVendorId = new DatabaseVendorDefinitionId(dbVendorName);
+		
+		IConnectionProfile profiles[] = ProfileManager.getInstance()
+				.getProfiles();
+		;
+		ArrayList rightProfiles = new ArrayList();
+
+		for (int i = 0; i < profiles.length; i++) {
+			DatabaseVendorDefinitionId dbVendorId = ProfileUtil
+					.getDatabaseVendorDefinitionId(profiles[i].getName());
+			if (selectedDbVendorId.equals(dbVendorId)) {
+				rightProfiles.add(profiles[i].getName());
+			}
+		}
+
+		Collections.sort(rightProfiles);
+
+		rightProfiles.add(0, new String(""));
+		_comboProfileName.setItems((String[]) rightProfiles
+				.toArray(new String[] {}));
+		if (initialProfName != null) {
+			for (Iterator iter = rightProfiles.iterator(); iter.hasNext();) {
+				if (iter.next().equals(initialProfName)) {
+					_comboProfileName.setText(initialProfName);
+					break;
+				}
+
+			}
+		}
+		updateFields();
+		canFinish();
+	}
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/Messages.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/Messages.java
new file mode 100644
index 0000000..3372c27
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/Messages.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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 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.internal.sqlscrapbook.connection;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Hui Cao
+ * 
+ */
+public class Messages {
+	private static final String BUNDLE_NAME = "org.eclipse.datatools.sqltools.internal.sqlscrapbook.connection.messages"; //$NON-NLS-1$
+
+	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+			.getBundle(BUNDLE_NAME);
+
+	private Messages() {
+	}
+
+	public static String getString(String key) {
+		try {
+			return RESOURCE_BUNDLE.getString(key);
+		} catch (MissingResourceException e) {
+			return '!' + key + '!';
+		}
+	}
+	
+    public static String getString(String key, String arg0)
+    {
+        return getString(key, new Object[]{arg0});
+    }
+
+    public static String getString(String key, String arg0, String arg1)
+    {
+        return getString(key, new Object[]{arg0,arg1});
+    }
+
+    public static String getString(String key, String arg0, String arg1, String arg2)
+    {
+        return getString(key, new Object[]{arg0,arg1,arg2});
+    }
+    
+    public static String getString(String key, Object[] args)
+    {
+        try
+        {
+            return MessageFormat.format(RESOURCE_BUNDLE.getString(key),args);
+        }
+        catch (MissingResourceException e)
+        {
+            StringBuffer argString = new StringBuffer(key);
+            argString.append(":");
+            for (int i=0; i< args.length; i++){
+                argString.append(args[i]);
+            }
+            return argString.toString();
+        }
+    }
+
+    /**
+     * Return the Locale that is loaded during startup
+     */
+    public static Locale getLocale()
+    {
+        return RESOURCE_BUNDLE.getLocale();
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/messages.properties b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/messages.properties
new file mode 100644
index 0000000..aa45674
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/connection/messages.properties
@@ -0,0 +1,11 @@
+SelectProfileDialog.title=Select Profile for the Editor
+SelectProfileDialog.create=C&reate...
+SelectProfileDialog.warning=Warning\!\n  The full feature of the editor will not be available without connection.
+SelectProfileDialog.error.jdbc.title=Connection Error
+SelectProfileDialog.profile.name=Connection profile &name:
+SelectProfileDialog.profile.type=Connection profile &type:
+SelectProfileDialog.donot.connect=&Do not connect now
+SelectProfileDialog.error.jdbc.message=Error occurred while trying to establish connection
+SelectProfileGroup.error.init=Error initializing SelectProfileGroup using: {0}
+SelectProfileDialog.noprofile=There is no connection profile associated with this resource. Select a connection profile type/name.
+SelectProfileDialog.wrongprofile=The connection profile (\"{0}\") associated with this resource is not valid. Select a connection profile type/name.
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/Messages.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/Messages.java
new file mode 100644
index 0000000..960c772
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/Messages.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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 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.internal.sqlscrapbook.editor;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Hui Cao
+ * 
+ */
+public class Messages {
+	private static final String BUNDLE_NAME = "org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor.messages"; //$NON-NLS-1$
+
+	public static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+			.getBundle(BUNDLE_NAME);
+
+	private Messages() {
+	}
+
+	public static String getString(String key) {
+		try {
+			return RESOURCE_BUNDLE.getString(key);
+		} catch (MissingResourceException e) {
+			return '!' + key + '!';
+		}
+	}
+	
+    public static String getString(String key, String arg0)
+    {
+        return getString(key, new Object[]{arg0});
+    }
+
+    public static String getString(String key, String arg0, String arg1)
+    {
+        return getString(key, new Object[]{arg0,arg1});
+    }
+
+    public static String getString(String key, String arg0, String arg1, String arg2)
+    {
+        return getString(key, new Object[]{arg0,arg1,arg2});
+    }
+    
+    public static String getString(String key, Object[] args)
+    {
+        try
+        {
+            return MessageFormat.format(RESOURCE_BUNDLE.getString(key),args);
+        }
+        catch (MissingResourceException e)
+        {
+            StringBuffer argString = new StringBuffer(key);
+            argString.append(":");
+            for (int i=0; i< args.length; i++){
+                argString.append(args[i]);
+            }
+            return argString.toString();
+        }
+    }
+
+    /**
+     * Return the Locale that is loaded during startup
+     */
+    public static Locale getLocale()
+    {
+        return RESOURCE_BUNDLE.getLocale();
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookDocumentProvider.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookDocumentProvider.java
new file mode 100644
index 0000000..a0919ad
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookDocumentProvider.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Exadel Inc - additional implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.util.NodeSQLPage;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.util.SQLUtility;
+import org.eclipse.datatools.sqltools.sqleditor.EditorConstants;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditor;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+
+public class SQLScrapbookDocumentProvider extends FileDocumentProvider {
+	
+	protected IDocument createDocument(Object element) throws CoreException {
+
+		IDocument document = null;
+        document = super.createDocument(element);
+        if (document == null) {
+            document = new Document("");
+        }
+
+		// Attempt show Message Connection through SQLScrapbookEditorInput		
+        if (element instanceof SQLScrapbookEditorInput) ((SQLScrapbookEditorInput)element).showMessageConnection();		
+		
+        return document;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
+     * tau 21.03.2005
+     */
+    protected void doSaveDocument(IProgressMonitor monitor, Object element,
+                                  IDocument document, boolean overwrite) throws CoreException {
+
+		IDocument storageDocument = null;
+        String statementSQL = document.get();
+        if (statementSQL == null) statementSQL = "";
+
+		String encodedConnection = null;
+		IFile fileResource = null;
+		SQLEditor sqlEditor = null;
+		
+		if (encodedConnection == null) {
+			// get encodedConnection from SQLEditor 
+			IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditor((IEditorInput)element);
+			if ((editor != null) && (editor instanceof SQLEditor)) {
+				sqlEditor = (SQLEditor) editor;
+				ISQLEditorConnectionInfo connectionInfo = sqlEditor.getConnectionInfo();
+				if (connectionInfo != null) encodedConnection = connectionInfo.encode(); 
+			} 			
+		}		
+		
+        if (element instanceof IFileEditorInput) fileResource = ((IFileEditorInput) element).getFile();
+				
+		if (((encodedConnection == null) && element instanceof SQLScrapbookEditorInput)) {
+			// get encodedConnection from SQLScrapbookEditorInput
+			ISQLEditorConnectionInfo connectionInfo = ((SQLScrapbookEditorInput)element).getConnectionInfo();
+			if (connectionInfo != null) encodedConnection = connectionInfo.encode();
+		}
+				
+		if ((encodedConnection == null) && (fileResource != null) && !fileResource.getFileExtension().equalsIgnoreCase("sqlpage")) {
+			// get encodedConnection from PersistentProperty
+			if (fileResource.exists()){
+				encodedConnection = fileResource.getPersistentProperty(new QualifiedName(SqlscrapbookPlugin.PLUGIN_ID, "encodedConnection"));
+			}
+
+		}	
+			
+		if (encodedConnection == null) encodedConnection = "";
+				
+		if ( (fileResource != null) && fileResource.getFileExtension().equalsIgnoreCase("sqlpage")) {
+				// Do xml document (*.sqlpage file) with only encodedConnection and statementSQL
+				Map map = new HashMap();
+				map.put("encodedConnection", encodedConnection);
+				
+		        String pageXML = SQLUtility.getOutputSQLPageXML(statementSQL, map);
+				storageDocument = new Document(pageXML);				
+		}
+				
+		if ((encodedConnection != null) && (fileResource != null) && !fileResource.getFileExtension().equalsIgnoreCase("sqlpage")){
+			// Save PersistentProperty encodedConnection for not *.sqlpage
+			if (fileResource.exists()){			
+				fileResource.setPersistentProperty(new QualifiedName(SqlscrapbookPlugin.PLUGIN_ID, "encodedConnection"),encodedConnection);
+			}
+		}
+		
+		if (storageDocument == null) storageDocument = document;
+		
+        super.doSaveDocument(monitor, element, storageDocument, overwrite);
+        
+        // tau 21.03.05
+		// First attempt show Message Connection through SQLScrapbookEditorInput
+        if (element instanceof SQLScrapbookEditorInput) ((SQLScrapbookEditorInput)element).showMessageConnection();
+		// Second attempt show Message Connection through sqlEditor
+		if (sqlEditor != null) sqlEditor.refreshConnectionStatus(); 		
+        
+    }
+
+	
+
+	
+	
+	
+}
+
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditor.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditor.java
new file mode 100644
index 0000000..b6e7b2f
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditor.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Exadel 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.actions.SetConnectionInfoAction;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+
+public class SQLScrapbookEditor extends SQLEditor {
+
+	public SQLScrapbookEditor() {
+		super();
+	}
+
+	protected void initializeEditor() {
+		super.initializeEditor();
+        setDocumentProvider(SqlscrapbookPlugin.getDefault().getSQLEditorDocumentProvider());
+	}
+
+	public void doSetInput(IEditorInput input) throws CoreException {
+		SQLScrapbookEditorInput newInput = null;
+		if (input instanceof SQLScrapbookEditorInput) {
+            newInput = (SQLScrapbookEditorInput) input;
+        } else if (input instanceof IFileEditorInput) {
+			newInput = new SQLScrapbookEditorInput(((IFileEditorInput) input).getFile());
+        }
+		
+		if (newInput == null){
+			super.doSetInput(input);			
+		} else {
+			newInput.setEditorSite(this.getEditorSite());
+			super.doSetInput(newInput);			
+		}
+
+	}
+
+	protected void createActions() {
+		super.createActions();
+        ResourceBundle bundle = Messages.RESOURCE_BUNDLE;
+
+        IAction a = new SetConnectionInfoAction(bundle,
+				"SetConnectionInfo.", this); //$NON-NLS-1$
+        setAction( "SetConnectionInfo", a ); //$NON-NLS-1$
+
+	}
+
+	protected void editorContextMenuAboutToShow(IMenuManager menu) {
+		super.editorContextMenuAboutToShow(menu);
+        menu.add( new Separator() );
+        addAction( menu, "SetConnectionInfo" ); //$NON-NLS-1$
+	}
+
+	public void setConnectionInfo(ISQLEditorConnectionInfo connInfo) {
+		super.setConnectionInfo(connInfo);
+		//TODO save the connection info in metadata
+	}	
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditorInput.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditorInput.java
new file mode 100644
index 0000000..254defc
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/SQLScrapbookEditorInput.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.views.execute.SQLScrapbookSelectConnectionAction;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorFileEditorInput;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.texteditor.AbstractDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * File based editor input for SQL scrapbook. 
+ */
+public class SQLScrapbookEditorInput extends SQLEditorFileEditorInput implements
+        IPropertyChangeListener {
+
+    private String statementSQL;
+
+    private IAction connectionAction;
+
+    private IEditorSite editorSite;
+
+	public SQLScrapbookEditorInput(IFile file) {
+        super(file);
+			
+		String encodedConnection = null;
+		if (file != null) {
+			try {
+				encodedConnection = file
+						.getPersistentProperty(new QualifiedName(
+								SqlscrapbookPlugin.PLUGIN_ID,
+								"encodedConnection"));
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+		}
+		SQLEditorConnectionInfo connectionInfo;
+		if ((encodedConnection != null)
+				&& (!encodedConnection.trim().equals(""))) {
+			connectionInfo = SQLEditorConnectionInfo.decode(encodedConnection);
+		} else {
+			connectionInfo = SQLEditorConnectionInfo.DEFAULT_SQLEDITOR_CONNECTION_INFO;
+		}
+		setConnectionInfo(connectionInfo);
+		
+    }	
+
+    public SQLScrapbookEditorInput(IFile file, ISQLEditorConnectionInfo connectionInfo) {
+        super(file);
+        setConnectionInfo( connectionInfo );
+    }
+
+    public SQLScrapbookEditorInput(IFile file, String statementSQL) {
+        super(file);
+        this.statementSQL = statementSQL;
+    }
+
+    // tau 17.07.04
+    public ISQLEditorConnectionInfo getConnectionInfo(boolean dialog) {
+        ISQLEditorConnectionInfo connectionInfo = getConnectionInfo();
+        if (connectionInfo == null && connectionAction != null && dialog) {
+            connectionAction.run();
+        }
+        return connectionInfo;
+    }
+
+	public void setStatementSQL(String statementSQL) {
+		this.statementSQL = statementSQL;
+	}
+	
+    public String getStatementSQL() {
+        return statementSQL;
+    }
+
+    /**
+     * @return Returns the editorSite.
+     */
+    public IEditorSite getEditorSite() {
+        return editorSite;
+    }
+
+    /**
+     * @param editorSite
+     *            The editorSite to set.
+     */
+    public void setEditorSite(IEditorSite editorSite) {
+        this.editorSite = editorSite;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+     */
+    public void propertyChange(PropertyChangeEvent event) {
+
+        if (event.getProperty().equals(
+                SQLScrapbookSelectConnectionAction.CONNECTION)) {
+            ISQLEditorConnectionInfo connectionInfo = (ISQLEditorConnectionInfo) event.getNewValue();
+            setConnectionInfo( connectionInfo );
+        }
+
+        // 19.07.04 tau
+        IEditorPart editor = null;
+        IWorkbenchPage page = editorSite.getPage();
+
+        if (page != null) {
+            editor = page.getActiveEditor();
+        }
+
+        if (editor != null && editor instanceof ITextEditor) {
+            ((AbstractDocumentProvider) ((ITextEditor) editor).getDocumentProvider()).setCanSaveDocument(this);
+        }
+
+        showMessageConnection(); // 17.07.04
+    }
+
+    public void showMessageConnection() {
+        IActionBars bars = editorSite.getActionBars();
+        ISQLEditorConnectionInfo connectionInfo = getConnectionInfo();
+        if (bars != null && connectionInfo != null && connectionInfo.getConnectionProfile() != null && connectionInfo.getDatabase() != null) {
+            bars.getStatusLineManager().setErrorMessage(null);
+            bars.getStatusLineManager().setMessage(
+                    connectionInfo.getConnectionProfile().getName()
+                            + " ("
+                            + connectionInfo.getDatabase().getName()
+                            + ")");
+            bars.updateActionBars();
+        } else if (bars != null && connectionInfo == null) {
+            bars.getStatusLineManager().setErrorMessage("No connection!");
+        }
+
+    }
+
+    /**
+     * @return Returns the setConnectionAction. tau 09.07.04
+     */
+    public IAction getConnectionAction() {
+        return connectionAction;
+    }
+
+    /**
+     * @param setConnectionAction
+     *            The setConnectionAction to set. tau 09.07.04
+     */
+    public void setConnectionAction(IAction setConnectionAction) {
+        this.connectionAction = setConnectionAction;
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/messages.properties b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/messages.properties
new file mode 100644
index 0000000..7a0c2d7
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/editor/messages.properties
@@ -0,0 +1,5 @@
+SetConnectionInfo.label       =Set Connec&tion Info
+SetConnectionInfo.tooltip     =Set Connection Information
+SetConnectionInfo.image       =
+SetConnectionInfo.description =Set connection information of the editor 
+
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/icons/executesql.gif b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/icons/executesql.gif
new file mode 100644
index 0000000..3379503
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/icons/executesql.gif
Binary files differ
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/ExceptionHandler.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/ExceptionHandler.java
new file mode 100644
index 0000000..d7c55be
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/ExceptionHandler.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Exadel Inc - additional implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.util;
+
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The default exception handler shows an error dialog when one of its handle
+ * methods is called. If the passed exception is a <code>CoreException</code>
+ * an error dialog pops up showing the exception's status information. For a
+ * <code>InvocationTargetException</code> a normal message dialog pops up
+ * showing the exception's message. Additionally the exception is written to the
+ * platform log.
+ */
+public class ExceptionHandler {
+
+    private static ExceptionHandler fgInstance = new ExceptionHandler();
+
+    /**
+     * Logs the given exception using the platform's logging mechanism. The
+     * exception is logged as an error with the error code
+     * <code>JavaStatusConstants.INTERNAL_ERROR</code>.
+     */
+    public static void log(Throwable t, String message) {
+        SqlscrapbookPlugin.log(new Status(IStatus.ERROR, SqlscrapbookPlugin
+                .getPluginId(), 1, message, t));
+    }
+
+    /**
+     * Handles the given <code>CoreException</code>. The workbench shell is
+     * used as a parent for the dialog window.
+     * 
+     * @param e
+     *            the <code>CoreException</code> to be handled
+     * @param title
+     *            the dialog window's window title
+     * @param message
+     *            message to be displayed by the dialog window
+     */
+    public static void handle(CoreException e, String title, String message) {
+        handle(e, SqlscrapbookPlugin.getActiveWorkbenchShell(), title, message);
+    }
+
+    /**
+     * Handles the given <code>CoreException</code>.
+     * 
+     * @param e
+     *            the <code>CoreException</code> to be handled
+     * @param parent
+     *            the dialog window's parent shell
+     * @param title
+     *            the dialog window's window title
+     * @param message
+     *            message to be displayed by the dialog window
+     */
+    public static void handle(CoreException e, Shell parent, String title,
+            String message) {
+        fgInstance.perform(e, parent, title, message);
+    }
+
+    /**
+     * Handles the given <code>InvocationTargetException</code>. The
+     * workbench shell is used as a parent for the dialog window.
+     * 
+     * @param e
+     *            the <code>InvocationTargetException</code> to be handled
+     * @param title
+     *            the dialog window's window title
+     * @param message
+     *            message to be displayed by the dialog window
+     */
+    public static void handle(InvocationTargetException e, String title,
+            String message) {
+        handle(e, SqlscrapbookPlugin.getActiveWorkbenchShell(), title, message);
+    }
+
+    /**
+     * Handles the given <code>InvocationTargetException</code>.
+     * 
+     * @param e
+     *            the <code>InvocationTargetException</code> to be handled
+     * @param parent
+     *            the dialog window's parent shell
+     * @param title
+     *            the dialog window's window title
+     * @param message
+     *            message to be displayed by the dialog window
+     */
+    public static void handle(InvocationTargetException e, Shell parent,
+            String title, String message) {
+        fgInstance.perform(e, parent, title, message);
+    }
+
+    // ---- Hooks for subclasses to control exception handling
+    // ------------------------------------
+    protected void perform(CoreException e, Shell shell, String title,
+            String message) {
+        SqlscrapbookPlugin.log(e);
+        IStatus status = e.getStatus();
+        if (status != null) {
+            ErrorDialog.openError(shell, title, message, status);
+        } else {
+            displayMessageDialog(e, e.getMessage(), shell, title, message);
+        }
+    }
+
+    protected void perform(InvocationTargetException e, Shell shell,
+            String title, String message) {
+        Throwable target = e.getTargetException();
+        if (target instanceof CoreException) {
+            perform((CoreException) target, shell, title, message);
+        } else {
+            SqlscrapbookPlugin.log(e);
+            if (e.getMessage() != null && e.getMessage().length() > 0) {
+                displayMessageDialog(e, e.getMessage(), shell, title, message);
+            } else {
+                displayMessageDialog(e, target.getMessage(), shell, title,
+                        message);
+            }
+        }
+    }
+
+    // ---- Helper methods
+    // -----------------------------------------------------------------------
+    private void displayMessageDialog(Throwable t, String exceptionMessage,
+            Shell shell, String title, String message) {
+        StringWriter msg = new StringWriter();
+        if (message != null) {
+            msg.write(message);
+            msg.write("\n\n"); //$NON-NLS-1$
+        }
+        if (exceptionMessage == null || exceptionMessage.length() == 0) {
+            msg.write(SqlscrapbookPlugin
+                    .getResourceString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$
+        } else {
+            msg.write(exceptionMessage);
+        }
+        MessageDialog.openError(shell, title, msg.toString());
+    }
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/NodeSQLPage.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/NodeSQLPage.java
new file mode 100644
index 0000000..d1b8822
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/NodeSQLPage.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Exadel 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.util;
+
+public class NodeSQLPage {
+	private String nameConnection;
+	private String statementSQL;
+
+	public String getStatementSQL() {
+		return statementSQL;
+	}
+	
+	void setStatementSQL(String statementSQL) {
+		this.statementSQL = statementSQL;
+	}
+
+	public String getNameConnection() {
+		return nameConnection;
+	}
+	
+
+	void setNameConnection(String nameConnection) {
+		this.nameConnection = nameConnection;
+	}
+	
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/SQLUtility.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/SQLUtility.java
new file mode 100644
index 0000000..2ded5c6
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/util/SQLUtility.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Exadel 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.sqleditor.SQLEditorConnectionInfo;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class SQLUtility {
+	
+    //TODO: add parameters to this method since profile name is not enough
+	public static ISQLEditorConnectionInfo getConnectionInfo(String profileName) {
+        ISQLEditorConnectionInfo connection = null;        
+        connection = new SQLEditorConnectionInfo(null, profileName, null);
+        return connection;
+    }
+	
+	
+	public static String getOutputSQLPageXML(String inStatement, Map map) {
+        // tau 27.06.04 06.07.04
+
+		org.w3c.dom.Document doc = null;
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder builder = null;
+        try {
+            builder = factory.newDocumentBuilder();
+        } catch (ParserConfigurationException e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
+        DOMImplementation impl = builder.getDOMImplementation();
+        doc = impl.createDocument(null, "SQLPage", null);
+        
+        Element root = doc.getDocumentElement();
+		
+		for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
+			Object element = it.next();
+			if (element instanceof Map.Entry) {
+				String key = (String) ((Map.Entry) element).getKey();
+				String value = (String) ((Map.Entry) element).getValue();
+		        Attr attr = doc.createAttribute(key);
+		        attr.setValue(value);
+		        root.setAttributeNode(attr);				
+			} 
+		} 
+
+		/*
+        String userid = "";
+        String driver = "";
+        String url = "";
+        String password = "";
+        
+        if (rdbConnection != null) {
+            userid = rdbConnection.getUserName();
+            driver = rdbConnection.getDriverClassName();
+            url = rdbConnection.getURL();
+            password = rdbConnection.getPassword();
+        }
+        
+        Attr attr = doc.createAttribute("userid");
+        attr.setValue(userid);
+        root.setAttributeNode(attr);
+        
+        attr = doc.createAttribute("driver");
+        attr.setValue(driver);
+        root.setAttributeNode(attr);
+        
+        attr = doc.createAttribute("url");
+        attr.setValue(url);
+        root.setAttributeNode(attr);
+        
+        attr = doc.createAttribute("password");
+        attr.setValue(password);
+        root.setAttributeNode(attr);
+        
+        */
+        
+        Element item = doc.createElement("Statement");       // Create element        
+
+        if (inStatement == null) inStatement = "";
+        item.appendChild( doc.createCDATASection(inStatement) );        
+        root.appendChild( item );
+        
+        StringWriter stringOut = new StringWriter();        //Writer will be a String
+
+        
+        //       Serialisation through Tranform. add tau 06.04.07
+        DOMSource domSource = new DOMSource(doc);
+        
+        StreamResult streamResult = new StreamResult(stringOut);
+        
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer serializer = null;
+        
+        try {
+            serializer = tf.newTransformer();
+        } catch (TransformerConfigurationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
+        serializer.setOutputProperty(OutputKeys.INDENT,"yes");
+        
+        try {
+            serializer.transform(domSource, streamResult);
+        } catch (TransformerException e2) {
+            // TODO Auto-generated catch block
+            e2.printStackTrace();
+        } 
+    
+        return stringOut.toString();
+    }
+	
+	public static NodeSQLPage getInputSQLPageXML(File fileXMLin) {
+		org.w3c.dom.Document xmlDocument = null;
+		NodeSQLPage nodeSQLPage = null;
+		
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+                
+			xmlDocument = builder.parse(fileXMLin);
+		
+            Element xmlElement = xmlDocument.getDocumentElement();
+		
+			if (!xmlElement.getNodeName().equals("SQLPage")){
+				return null;
+			}
+
+			NodeSQLPage new_nodeSQLPage = new NodeSQLPage();
+			new_nodeSQLPage.setNameConnection(xmlElement.getAttribute("nameConnection"));
+                
+            NodeList nodeList = xmlElement.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node.getNodeType() == Node.ELEMENT_NODE &&
+                    node.getNodeName().equals("Statement")) {
+                    Element statementElement = (Element) node;
+                    NodeList statementNodeList = statementElement.getChildNodes();
+                    for (int j = 0; j < statementNodeList.getLength(); j++) {
+                        Node nodeSQL = statementNodeList.item(j);
+                        if (nodeSQL.getNodeType() == Node.CDATA_SECTION_NODE) {
+							new_nodeSQLPage.setStatementSQL(nodeSQL.getNodeValue());
+                            break;
+                        }
+                    }                       
+                    break;
+                }
+            }
+			
+			nodeSQLPage = new_nodeSQLPage;
+                
+        } catch (FactoryConfigurationError e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (SAXException e) {
+            //e.printStackTrace(); tau 05.07.04
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+		
+		return nodeSQLPage;
+		
+	}
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/views/execute/SQLScrapbookSelectConnectionAction.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/views/execute/SQLScrapbookSelectConnectionAction.java
new file mode 100644
index 0000000..1850063
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/views/execute/SQLScrapbookSelectConnectionAction.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.views.execute;
+
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.jface.action.Action;
+
+/**
+ * Select connection for SQL scrapbook editor from list of available connections. 
+ */
+public class SQLScrapbookSelectConnectionAction extends Action {
+
+    public static final String CONNECTION = "Connection"; //$NON-NLS-1$
+
+    private ISQLEditorConnectionInfo connectionInfo = null;
+
+    public SQLScrapbookSelectConnectionAction() {
+        super(SqlscrapbookPlugin.getResourceString("_UI_MENU_SELECT_CONNECTION"));
+    }
+
+    public void setConnectionInfo(ISQLEditorConnectionInfo connectionInfo) {
+        this.connectionInfo = connectionInfo;
+    }
+
+    public void run() {
+        //TODO: 
+//        IConnectedServerDialog dialog = IServicesManager.INSTANCE.getConnectedServerDialog();
+//        int result = dialog.open();
+//        if (result == Window.OK) {
+//            IConnectionNode node = dialog.getUserSelection();
+//            if (node != null) {
+//                ISQLEditorConnectionInfo newISQLEditorConnectionInfo = node.getConnectionInfo();
+//                if (newISQLEditorConnectionInfo != null) {
+//                    firePropertyChange(CONNECTION, connectionInfo, newISQLEditorConnectionInfo);
+//                    connectionInfo = newISQLEditorConnectionInfo;
+//                }
+//            }
+//        }
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileCreationWizard.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileCreationWizard.java
new file mode 100644
index 0000000..6dbf557
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileCreationWizard.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.wizards;
+
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Creates a new snippet page
+ */
+public class NewSQLScrapbookFileCreationWizard extends Wizard implements
+        INewWizard {
+
+    private NewSQLScrapbookFileWizardPage fPage;
+
+    private IStructuredSelection fSelection;
+
+    private ISQLEditorConnectionInfo connectionInfo; // tau 04.07.04
+
+    public NewSQLScrapbookFileCreationWizard() {
+        setNeedsProgressMonitor(true);
+        setWindowTitle(SqlscrapbookPlugin
+                .getResourceString("NewSQLScrapbookFileCreationWizard.title")); //$NON-NLS-1$
+    }
+
+    /*
+     * @see Wizard#addPages
+     */
+    public void addPages() {
+        super.addPages();
+        if (fSelection == null) {
+            fSelection = StructuredSelection.EMPTY;
+        }
+        fPage = new NewSQLScrapbookFileWizardPage(fSelection);
+        addPage(fPage);
+    }
+
+    /*
+     * @see Wizard#performFinish
+     */
+    public boolean performFinish() {
+        return fPage.finish(connectionInfo); // tau 04.07.04
+    }
+
+    /*
+     * @see org.eclipse.ui.IWorkbenchWizard#init
+     */
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        fSelection = selection;
+        // setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWSCRAPPAGE);
+    }
+
+    /**
+     * @param connection
+     *            The connection to set. tau 04.07.04
+     */
+    public void setConnectionInfo(ISQLEditorConnectionInfo connectionInfo) {
+        this.connectionInfo = connectionInfo;
+    }
+}
diff --git a/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileWizardPage.java b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileWizardPage.java
new file mode 100644
index 0000000..c35d0e4
--- /dev/null
+++ b/plugins/org.eclipse.datatools.sqltools.sqlscrapbook/src/org/eclipse/datatools/sqltools/internal/sqlscrapbook/wizards/NewSQLScrapbookFileWizardPage.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2004 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Exadel Inc - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.sqltools.internal.sqlscrapbook.wizards;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.SqlscrapbookPlugin;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor.SQLScrapbookEditorInput;
+import org.eclipse.datatools.sqltools.internal.sqlscrapbook.util.ExceptionHandler;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+/**
+ * Page to create a new SQL scrapbook file.
+ */
+public class NewSQLScrapbookFileWizardPage extends WizardNewFileCreationPage {
+	
+	private static final String fgDefaultExtension= ".sqlpage"; //$NON-NLS-1$
+	
+	public NewSQLScrapbookFileWizardPage(IStructuredSelection selection) {
+		super("createScrapBookPage", selection); //$NON-NLS-1$
+		setTitle(SqlscrapbookPlugin.getResourceString("NewSQLScrapbookFileWizardPage.title")); //$NON-NLS-1$
+	}
+
+	public boolean finish(ISQLEditorConnectionInfo connectionInfo) {
+		// add extension if non is provided 
+		String fileName= getFileName();
+		if (fileName != null && !fileName.endsWith(fgDefaultExtension)) {
+			setFileName(fileName + fgDefaultExtension);
+		}
+
+		boolean retValue= super.validatePage();
+
+		final IFile file= createNewFile();
+		if (retValue && file != null) {
+			Shell shell= getShell();
+			IWorkbenchPage page= SqlscrapbookPlugin.getActivePage();
+			if (shell == null || page == null) {
+				return true;
+			}
+			final IWorkbenchPart focusPart= page.getActivePart();
+			if (focusPart instanceof ISetSelectionTarget) {
+				shell.getDisplay().asyncExec(new Runnable() {
+					public void run() {
+						ISelection selection= new StructuredSelection(file);
+						((ISetSelectionTarget) focusPart).selectReveal(selection);
+					}
+				});
+			}
+			
+			
+			try {
+				//IDE.openEditor(page, file, true); // tau 04.07.04
+				// tau 04.07.04, 17.07.04
+				
+				// add tau 10.03.2005
+			    SQLScrapbookEditorInput editorInput = new SQLScrapbookEditorInput(file, connectionInfo);
+			    
+				/*
+                SqlscrapbookPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
+                    "org.eclipse.datatools.sqltools.internal.sqlscrapbook.views.SQLScrapbookEditor");
+				*/
+
+                SqlscrapbookPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
+                "org.eclipse.datatools.sqltools.internal.sqlscrapbook.editor.SQLScrapbookEditor");				
+				
+				return true;
+			} catch (PartInitException e) {
+				ExceptionHandler.handle(e, shell, SqlscrapbookPlugin.getResourceString("NewSQLScrapbookFileWizardPage.open_error.message"),  e.getMessage()); //$NON-NLS-1$
+			}
+			
+		}
+		return false;
+	}
+	
+	/**
+	 * @see WizardNewFileCreationPage#validatePage
+	 */
+	protected boolean validatePage() {
+		// check whether file with extension doesn't exist
+		boolean valid= super.validatePage();
+		if (!valid)
+			return false;
+		
+		IWorkspaceRoot workspaceRoot= SqlscrapbookPlugin.getWorkspace().getRoot();
+		/*IPath containerPath= getContainerFullPath();
+		if (containerPath != null && containerPath.segmentCount() > 0) {
+			IProject project= workspaceRoot.getProject(containerPath.segment(0));
+			try {
+				if (!project.hasNature(JavaCore.NATURE_ID)) {
+					setErrorMessage(SQLScrapbookMessages.getString("NewSQLScrapbookFileWizardPage.error.OnlyInJavaProject")); //$NON-NLS-1$
+					return false;
+				}
+			} catch (CoreException e) {
+                SqlscrapbookPlugin.log(e.getStatus());
+			}
+		}*/
+	
+		String fileName= getFileName();
+		if (fileName != null && !fileName.endsWith(fgDefaultExtension)) {		
+			fileName= fileName + fgDefaultExtension;
+			IPath path= getContainerFullPath();
+			
+			if (path != null && workspaceRoot.exists(path.append(fileName))) {
+				setErrorMessage(SqlscrapbookPlugin.getResourceString("NewSQLScrapbookFileWizardPage.error.AlreadyExists")); //$NON-NLS-1$
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	/*
+	 * @see WizardNewFileCreationPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		super.createControl(parent);
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "new_sqlscrapbook_wizard_page_context");		
+	}
+
+}
+
+