[204620] Need a method of contributing driver definition specific UIs to a connection profile wizard
diff --git a/examples/org.eclipse.datatools.connectivity.sample/META-INF/MANIFEST.MF b/examples/org.eclipse.datatools.connectivity.sample/META-INF/MANIFEST.MF
index ecbd27d..62bdf99 100644
--- a/examples/org.eclipse.datatools.connectivity.sample/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.datatools.connectivity.sample/META-INF/MANIFEST.MF
@@ -8,6 +8,5 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.datatools.connectivity.ui.dse,
- org.eclipse.datatools.connectivity.db.generic
+ org.eclipse.datatools.connectivity.ui.dse
Eclipse-LazyStart: true
diff --git a/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/popup/actions/CreateConnection.java b/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/popup/actions/CreateConnection.java
index c01171e..c2e1b76 100644
--- a/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/popup/actions/CreateConnection.java
+++ b/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/popup/actions/CreateConnection.java
@@ -18,7 +18,7 @@
import org.eclipse.datatools.connectivity.ProfileManager;
import org.eclipse.datatools.connectivity.drivers.DriverInstance;
import org.eclipse.datatools.connectivity.drivers.DriverManager;
-import org.eclipse.datatools.connectivity.ui.wizards.IDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IObjectActionDelegate;
@@ -54,15 +54,15 @@
ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
driverInstance.getId());
connectionProfileProperties.setProperty(
- IDriverDefinitionConstants.DATABASE_NAME_PROP_ID, databaseName);
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, databaseName);
connectionProfileProperties.setProperty(
- IDriverDefinitionConstants.USERNAME_PROP_ID, "");
+ IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, "");
connectionProfileProperties.setProperty(
- IDriverDefinitionConstants.PASSWORD_PROP_ID, "");
+ IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, "");
String databaseLocation = System.getProperty("user.home")
+ File.separator + "DerbyDB" + File.separator;
connectionProfileProperties.setProperty(
- IDriverDefinitionConstants.URL_PROP_ID, "jdbc:derby:"
+ IJDBCDriverDefinitionConstants.URL_PROP_ID, "jdbc:derby:"
+ databaseLocation + databaseName + ";create=true");
try {
ProfileManager
diff --git a/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java b/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java
index fc5c5ee..ea6af70 100644
--- a/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java
+++ b/examples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java
@@ -18,9 +18,9 @@
import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.drivers.DriverInstance;
import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.ui.dse.dialogs.ConnectionDisplayProperty;
import org.eclipse.datatools.connectivity.ui.dse.dialogs.ExistingConnectionProfilesDialogPage;
import org.eclipse.swt.widgets.Event;
@@ -47,20 +47,20 @@
.add(new ConnectionDisplayProperty(
"Database",
(String) baseProperties
- .get(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID)));
+ .get(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID)));
propertiesCollection
.add(new ConnectionDisplayProperty(
"JDBC Driver Class",
(String) baseProperties
- .get(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID)));
+ .get(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID)));
propertiesCollection.add(new ConnectionDisplayProperty(
"Class Location", getJarList(connectionProfile)));
propertiesCollection.add(new ConnectionDisplayProperty(
"Connection URL", (String) baseProperties
- .get(IDBDriverDefinitionConstants.URL_PROP_ID)));
+ .get(IJDBCDriverDefinitionConstants.URL_PROP_ID)));
propertiesCollection.add(new ConnectionDisplayProperty("User ID",
(String) baseProperties
- .get(IDBDriverDefinitionConstants.USERNAME_PROP_ID)));
+ .get(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID)));
properties = new ConnectionDisplayProperty[propertiesCollection.size()];
propertiesCollection.toArray(properties);
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/META-INF/MANIFEST.MF
index a7bc5f9..7ecd1e3 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.datatools.connectivity.apache.derby.ui;singleton:=true
-Bundle-Version: 1.0.0.200712071
+Bundle-Version: 1.0.0.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.apache.derby.internal.ui.DerbyUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
@@ -16,8 +16,6 @@
org.eclipse.datatools.modelbase.sql;bundle-version="[0.9.0,1.5.0)",
org.eclipse.datatools.modelbase.derby;bundle-version="[0.9.0,1.5.0)",
org.eclipse.datatools.connectivity.apache.derby;bundle-version="[0.9.1,1.5.0)",
- org.eclipse.datatools.connectivity.db.generic;bundle-version="[0.9.1,1.5.0)",
- org.eclipse.datatools.connectivity.db.generic.ui;bundle-version="[0.9.1,1.5.0)",
org.eclipse.datatools.connectivity;bundle-version="[0.9.1,1.5.0)",
org.eclipse.datatools.connectivity.ui;bundle-version="[0.9.1,1.5.0)"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/plugin.xml b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/plugin.xml
index a15f5b1..cbac333 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/plugin.xml
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/plugin.xml
@@ -119,5 +119,84 @@
</enabledWhen>
</page>
</extension>
-
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyOtherDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby.otherDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_0.DerbyOtherDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyOtherDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby101.otherDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_1.DerbyOtherDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyOtherDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby102.otherDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_2.DerbyOtherDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyEmbeddedDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby.genericDriverTemplate"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_0.DerbyEmbeddedDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyEmbeddedDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby101.genericDriverTemplate"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_1.DerbyEmbeddedDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyEmbeddedDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby102.genericDriverTemplate"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_2.DerbyEmbeddedDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby.db2UniversalDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_0.DerbyDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby101.db2UniversalDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_1.DerbyDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyClientDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby101.clientDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_1.DerbyClientDriverUIContributor">
+ </driverUIContributor>
+ </extension>
+
+ <extension point="org.eclipse.datatools.connectivity.ui.driverUIContributor">
+ <driverUIContributor
+ class="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.DerbyClientDriverUIContributor"
+ driverTemplateID="org.eclipse.datatools.connectivity.db.derby102.clientDriver"
+ id="org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.10_2.DerbyClientDriverUIContributor">
+ </driverUIContributor>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBProfileDetailsWizardPage.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBProfileDetailsWizardPage.java
index 1bd3545..48be1ae 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBProfileDetailsWizardPage.java
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBProfileDetailsWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004-2006 Sybase, Inc.
+ * Copyright (c) 2004-2006, 2007 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
@@ -7,635 +7,34 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: brianf - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.core.runtime.Path;
import org.eclipse.datatools.connectivity.apache.derby.internal.ui.DerbyUIPlugin;
import org.eclipse.datatools.connectivity.apache.internal.derby.connection.IDerbyConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.drivers.DriverInstance;
-import org.eclipse.datatools.connectivity.internal.ui.DelimitedStringList;
-import org.eclipse.datatools.connectivity.internal.ui.DriverListCombo;
-import org.eclipse.datatools.connectivity.ui.wizards.ConnectionProfileDetailsPage;
+import org.eclipse.datatools.connectivity.ui.wizards.ExtensibleProfileDetailsWizardPage;
import org.eclipse.datatools.help.ContextProviderDelegate;
import org.eclipse.datatools.help.HelpUtil;
import org.eclipse.help.IContext;
import org.eclipse.help.IContextProvider;
-import org.eclipse.swt.SWT;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
/**
- * This class gathers the properties for the derby embedded DB connection profile.
+ * This class gathers the properties for the derby embedded DB connection
+ * profile.
*
* @author brianf
*/
-public class DerbyEmbeddedDBProfileDetailsWizardPage
- extends ConnectionProfileDetailsPage
- implements IContextProvider {
+public class DerbyEmbeddedDBProfileDetailsWizardPage extends
+ ExtensibleProfileDetailsWizardPage implements IContextProvider {
- // ui pieces
- private Text mDatabaseNameText;
-
- private Text mURLText;
-
- private Text mDBUIDText;
-
- private Text mDBPWDText;
-
- private Button mSaveDBPWDCheckbox;
-
- private DelimitedStringList mDBConnProps;
-
- final DriverListCombo combo = new DriverListCombo();
-
- private Button mCreateDBCheckbox;
-
- private Button mUpgradeDBCheckbox;
-
- private Text mDBFilePathText;
-
- private Button mBrowseFilePathButton;
-
- // stashed driver instance
- private DriverInstance mDriverInstance;
-
- private String mDriverCategory;
-
- /**
- * Constructor
- *
- * @param pageName
- */
public DerbyEmbeddedDBProfileDetailsWizardPage(String pageName) {
- super(pageName);
- setTitle(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.title")); //$NON-NLS-1$
- setDescription(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.msg")); //$NON-NLS-1$
- setDriverCategory(IDerbyConnectionProfileConstants.DERBY_CATEGORY_ID);
- this.combo.setFilter("templateIDStartsWith = " + //$NON-NLS-1$
- IDerbyConnectionProfileConstants.DERBY_ENABLEMENT_DRIVER_PREFIX + "," + //$NON-NLS-1$
- "templateIDEndsWith = " + //$NON-NLS-1$
- IDerbyConnectionProfileConstants.DERBY_ENABLEMENT_DRIVER_SUFFIX);
+ super(pageName, IDerbyConnectionProfileConstants.DERBY_CATEGORY_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createCustomControl(Composite parent) {
- Composite content = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout(2, false);
- content.setLayout(layout);
-
- // set up the drivers combo
- this.combo.setLabelText(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.driverCombo.label")); //$NON-NLS-1$
- this.combo.setCategory(getDriverCategory());
- this.combo.setNullDriverIsValid(false);
- this.combo.createContents(content);
- if (this.combo.getErrorMessage() != null) {
- setErrorMessage(this.combo.getErrorMessage());
- }
-
- // set up the fields
- this.mDatabaseNameText = (Text) createLabelTextPair(
- content,
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.databaseName.label"), //$NON-NLS-1$
- this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
-
- Label label = new Label(content, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.0")); //$NON-NLS-1$
-
- Composite textAndBrowseComposite = new Composite(content, SWT.NULL);
- GridLayout subCompositeLayout = new GridLayout(2, false);
- subCompositeLayout.marginLeft = -5;
- subCompositeLayout.marginRight = -5;
- subCompositeLayout.marginTop = -5;
- subCompositeLayout.marginBottom = -5;
- textAndBrowseComposite.setLayout(subCompositeLayout);
- textAndBrowseComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.mDBFilePathText = new Text(textAndBrowseComposite, SWT.BORDER);
- this.mDBFilePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.mBrowseFilePathButton = new Button(textAndBrowseComposite, SWT.PUSH);
- this.mBrowseFilePathButton.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.1")); //$NON-NLS-1$
- this.mBrowseFilePathButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
- this.mDBUIDText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.userName.label"), //$NON-NLS-1$
- this.mDBUIDText, SWT.BORDER, GridData.FILL_HORIZONTAL);
-
- this.mDBPWDText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.password.label"), //$NON-NLS-1$
- this.mDBPWDText, SWT.BORDER | SWT.PASSWORD, GridData.FILL_HORIZONTAL);
-
- this.mURLText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.url.label"), //$NON-NLS-1$
- this.mURLText, SWT.BORDER | SWT.READ_ONLY, GridData.FILL_HORIZONTAL);
-
- this.mCreateDBCheckbox = new Button(content, SWT.CHECK);
- this.mCreateDBCheckbox.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.2")); //$NON-NLS-1$
- this.mCreateDBCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- this.mUpgradeDBCheckbox = new Button(content, SWT.CHECK);
- this.mUpgradeDBCheckbox.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.3")); //$NON-NLS-1$
- this.mUpgradeDBCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- this.mSaveDBPWDCheckbox = new Button(content, SWT.CHECK);
- this.mSaveDBPWDCheckbox.setText(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.persistpassword.label")); //$NON-NLS-1$
- this.mSaveDBPWDCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- // spacer
- Composite spacer = new Composite(content, SWT.NULL);
- GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- gdata.heightHint = 20;
- spacer.setLayoutData(gdata);
-
- // followed by the optional properties
- label = new Label(content, SWT.NULL);
- gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- label.setLayoutData(gdata);
- label.setText(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.optionalProps.label")); //$NON-NLS-1$
-
- this.mDBConnProps = new DelimitedStringList(content, SWT.NONE);
- gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- this.mDBConnProps.setLayoutData(gdata);
-
-// // now set up the initial instance
-// if (this.mDriverInstance == null)
-// this.mDriverInstance = this.combo.getSelectedDriverInstance();
-
- this.mDBConnProps.addChangeListener(new ChangeListener() {
-
- public void stateChanged(ChangeEvent arg0) {
- setErrorMessage(null);
- if (DerbyEmbeddedDBProfileDetailsWizardPage.this.mDBConnProps.getWarning() != null) {
- setErrorMessage(DerbyEmbeddedDBProfileDetailsWizardPage.this.mDBConnProps
- .getWarning());
- }
- }
-
- });
-
- // add a change listener to the combo box so
- // we know when a new driver has been selected
- this.combo.addChangeListener(new ChangeListener() {
-
- public void stateChanged(ChangeEvent arg0) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.mDriverInstance = DerbyEmbeddedDBProfileDetailsWizardPage.this.combo
- .getSelectedDriverInstance();
- setErrorMessage(null);
- if (DerbyEmbeddedDBProfileDetailsWizardPage.this.combo.getErrorMessage() != null) {
- setErrorMessage(DerbyEmbeddedDBProfileDetailsWizardPage.this.combo
- .getErrorMessage());
- }
- DerbyEmbeddedDBProfileDetailsWizardPage.this.mDatabaseNameText
- .setText(getDriverDatabaseName());
-
- DerbyEmbeddedDBProfileDetailsWizardPage.this.mURLText
- .setText(getDriverURL());
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updatePropsFromURL();
-
- String username = DerbyEmbeddedDBProfileDetailsWizardPage.this
- .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.USERNAME_PROP_ID);
- if (username == null || username.trim().length() == 0)
- username = new String();
- DerbyEmbeddedDBProfileDetailsWizardPage.this.mDBUIDText.setText(username);
-
- String password = DerbyEmbeddedDBProfileDetailsWizardPage.this
- .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.PASSWORD_PROP_ID);
- if (password == null || password.trim().length() == 0)
- password = new String();
- DerbyEmbeddedDBProfileDetailsWizardPage.this.mDBPWDText.setText(password);
-
- setPageComplete(isValid());
- }
-
- });
-
- this.mDBFilePathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updateURLFromProps();
- }
- });
-
- this.mCreateDBCheckbox.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updateURLFromProps();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updateURLFromProps();
- }
- });
-
- this.mUpgradeDBCheckbox.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updateURLFromProps();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.updateURLFromProps();
- }
- });
-
- this.mBrowseFilePathButton.addSelectionListener( new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.browseForDBFolder();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBProfileDetailsWizardPage.this.browseForDBFolder();
- }
- });
-
- this.combo.selectFirstItem();
- // now set up the initial instance
- if (this.mDriverInstance == null)
- this.mDriverInstance = this.combo.getSelectedDriverInstance();
- if (this.mDriverInstance != null) {
- this.mURLText.setText(getDriverURL());
- }
- }
-
- /**
- * Browse for the database folder
- */
- private void browseForDBFolder() {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setText(Messages
- .getString("DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.title.filebrowse")); //$NON-NLS-1$
- dialog.setMessage(Messages
- .getString("DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.msg.filebrowse")); //$NON-NLS-1$
-
- String dirName = mDBFilePathText.getText();
-
- File path = new File(dirName);
- if (path.exists()) {
- dialog.setFilterPath(new Path(dirName).toOSString());
- }
-
- String selectedDirectory = dialog.open();
- if (selectedDirectory != null) {
- this.mDBFilePathText.setText(selectedDirectory);
- }
- }
-
- /**
- * Update the UI components from the URL
- */
- private void updatePropsFromURL() {
- if (this.mDBFilePathText != null && this.mURLText != null && this.mCreateDBCheckbox != null && this.mUpgradeDBCheckbox != null) {
- String url = this.mURLText.getText();
- String[] chunks = parseString(url, ";"); //$NON-NLS-1$
- if (chunks.length > 0) {
- String[] chunks2 = parseString(chunks[0], ":"); //$NON-NLS-1$
- if (chunks2.length > 2) {
- String filepath = chunks2[2];
- if (chunks2.length > 3) {
- filepath = filepath + ":" + chunks2[3]; //$NON-NLS-1$
- }
- this.mDBFilePathText.setText(filepath);
- }
- }
- if (chunks.length > 1) {
- for (int i = 1; i < chunks.length; i++) {
- if (chunks[i].startsWith("create=")) //$NON-NLS-1$
- this.mCreateDBCheckbox.setSelection(true);
- else if (chunks[i].startsWith("upgrade=")) //$NON-NLS-1$
- this.mUpgradeDBCheckbox.setSelection(true);
- }
- }
- }
- }
-
- /**
- * Update the URL from the UI components
- */
- private void updateURLFromProps() {
- if (this.mDBFilePathText != null && this.mURLText != null && this.mCreateDBCheckbox != null && this.mUpgradeDBCheckbox != null) {
- String url = this.mURLText.getText();
- String filePath = this.mDBFilePathText.getText();
- boolean createDB = this.mCreateDBCheckbox.getSelection();
- boolean upgradeDB = this.mUpgradeDBCheckbox.getSelection();
- //jdbc:derby:C:\DerbyDatabases\MyDB;create=true
- String[] chunks = parseString(url, ";"); //$NON-NLS-1$
- if (chunks.length > 0) {
- String[] chunks2 = parseString(chunks[0], ":"); //$NON-NLS-1$
- if (chunks2.length > 2) {
- url = chunks2[0] + ":" + chunks2[1] + ":" + filePath; //$NON-NLS-1$ //$NON-NLS-2$
- if (createDB) {
- url = url + ";" + "create=true"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (upgradeDB) {
- url = url + ";" + "upgrade=true"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- this.mURLText.setText(url);
- }
- }
- }
- }
-
- /**
- * Parse a string into a string array based on a token
- * @param str_list
- * @param token
- * @return
- */
- private String[] parseString(String str_list, String token) {
- StringTokenizer tk = new StringTokenizer(str_list, token);
- String[] pieces = new String[tk.countTokens()];
- int index = 0;
- while (tk.hasMoreTokens())
- pieces[index++] = tk.nextToken();
- return pieces;
- }
-
- /**
- * @param propertyID
- * @return
- */
- private String getPropertyFromDriverInstance(String propertyID) {
- String returnStr = new String();
- if (this.mDriverInstance != null
- && this.mDriverInstance.getProperty(propertyID) != null) {
- returnStr = this.mDriverInstance.getProperty(propertyID);
- }
- return returnStr;
- }
-
- /**
- * Get the sample URL from the driver instance.
- *
- * @return
- */
- public String getDriverURL() {
- if (this.mDriverInstance != null
- && this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.URL_PROP_ID) != null)
- return this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.URL_PROP_ID);
- return new String();
- }
-
- /**
- * Get the sample database name from the driver instance.
- *
- * @return
- */
- public String getDriverDatabaseName() {
- if (this.mDriverInstance != null
- && this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID) != null)
- return this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
- return new String();
- }
-
- /**
- * Get the vendor
- *
- * @return
- */
- public String getVendor() {
- String vendor = ""; //$NON-NLS-1$
- if (this.mDriverInstance != null) {
- vendor = this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
- }
- return vendor;
- }
-
- /**
- * Get the version
- *
- * @return
- */
- public String getVersion() {
- String version = ""; //$NON-NLS-1$
- if (this.mDriverInstance != null) {
- version = this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
- }
- return version;
- }
-
- /**
- * Get the driver class
- *
- * @return
- */
- public String getDriverClass() {
- String driverClass = ""; //$NON-NLS-1$
- if (this.mDriverInstance != null) {
- driverClass = this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
- }
- return driverClass;
- }
-
- /**
- * Get the user name
- *
- * @return
- */
- public String getDBUID() {
- return this.mDBUIDText.getText();
- }
-
- /**
- * Get the password
- *
- * @return
- */
- public String getDBPWD() {
- return this.mDBPWDText.getText();
- }
-
- /**
- * Get the password
- *
- * @return
- */
- public boolean getSaveDBPWD() {
- return this.mSaveDBPWDCheckbox.getSelection();
- }
-
- /**
- * Get the optional connection properties
- *
- * @return
- */
- public String getDBConnProps() {
- return this.mDBConnProps.getSelection();
- }
-
- /**
- * Get the database name
- *
- * @return
- */
- public String getDatabaseName() {
- return this.mDatabaseNameText.getText();
- }
-
- /**
- * Get the URL for the CP
- *
- * @return
- */
- public String getURL() {
- return this.mURLText.getText();
- }
-
- /**
- * Get the driver ID
- *
- * @return
- */
- public String getDriverID() {
- return this.mDriverInstance.getId();
- }
-
- /*
- * Create a label and a text box side by side.
- */
- private Control createLabelTextPair(Composite parent, String labelText,
- Control ctl, int style, int gData) {
- Label label = new Label(parent, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(labelText);
-
- ctl = new Text(parent, style);
- ctl.setLayoutData(new GridData(gData));
-
- return ctl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.sybase.suade.common.ui.wizards.ISummaryDataSource#getSummaryData()
- */
- public List getSummaryData() {
- List data = new ArrayList();
-
- data
- .add(new String[] {
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.summary.driverName.label"), //$NON-NLS-1$
- mDriverInstance.getName() });
-
- data
- .add(new String[] {
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.summary.connProps.label"), //$NON-NLS-1$
- getDBConnProps() });
-
- data
- .add(new String[] {
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.summary.userName.label"), //$NON-NLS-1$
- getDBUID() });
-
- StringBuffer pwdMask = new StringBuffer();
- if (getDBPWD() != null && getDBPWD().length() > 0) {
- for (int i = 0, count = getDBPWD().length(); i < count; ++i) {
- pwdMask = pwdMask.append('*');
- }
- }
-
- data
- .add(new String[] {
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.summary.password.label"), //$NON-NLS-1$
- pwdMask.toString() });
-
- data.add(new String[] {
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.summary.url.label"), //$NON-NLS-1$
- getURL() });
-
- return data;
- }
-
- private boolean isValid() {
- if (getErrorMessage() != null) {
- setPageComplete(false);
- return false;
- }
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.DialogPage#setErrorMessage(java.lang.String)
- */
- public void setErrorMessage(String newMessage) {
- super.setErrorMessage(newMessage);
- isValid();
- }
-
-
- /**
- * @return
- */
- public String getDriverCategory() {
- return mDriverCategory;
- }
-
-
- /**
- * Sets the driver category that should be used for displaying available
- * driver defnitions.
- *
- * @param driverCategory
- */
- public void setDriverCategory(String driverCategory) {
- mDriverCategory = driverCategory;
- if (combo != null) {
- combo.setCategory(mDriverCategory);
- }
- }
-
- private ContextProviderDelegate contextProviderDelegate =
- new ContextProviderDelegate(DerbyUIPlugin.getDefault().getBundle().getSymbolicName());
+ private ContextProviderDelegate contextProviderDelegate = new ContextProviderDelegate(
+ DerbyUIPlugin.getDefault().getBundle().getSymbolicName());
public IContext getContext(Object target) {
return contextProviderDelegate.getContext(target);
@@ -651,7 +50,9 @@
public void createControl(Composite parent) {
super.createControl(parent);
- getShell().setData( HelpUtil.CONTEXT_PROVIDER_KEY, this);
- HelpUtil.setHelp( getControl(), HelpUtil.getContextId(IHelpContextsDerbyProfile.DERBY_PROFILE_WIZARD_PAGE, DerbyUIPlugin.getDefault().getBundle().getSymbolicName()));
+ getShell().setData(HelpUtil.CONTEXT_PROVIDER_KEY, this);
+ HelpUtil.setHelp(getControl(), HelpUtil.getContextId(
+ IHelpContextsDerbyProfile.DERBY_PROFILE_WIZARD_PAGE,
+ DerbyUIPlugin.getDefault().getBundle().getSymbolicName()));
}
}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBPropertyPage.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBPropertyPage.java
index 7916be1..8d844e4 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBPropertyPage.java
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/DerbyEmbeddedDBPropertyPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc.
+ * Copyright (c) 2006, 2007 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
@@ -8,540 +8,38 @@
*
* Contributors: rcernich - initial API and implementation
* brianf - customized for Derby url requirements
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection;
-import java.io.File;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.apache.derby.internal.ui.DerbyUIPlugin;
import org.eclipse.datatools.connectivity.apache.internal.derby.connection.IDerbyConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.drivers.DriverInstance;
import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin;
-import org.eclipse.datatools.connectivity.internal.ui.DelimitedStringList;
-import org.eclipse.datatools.connectivity.internal.ui.DriverListCombo;
import org.eclipse.datatools.connectivity.internal.ui.IHelpConstants;
-import org.eclipse.datatools.connectivity.ui.wizards.ProfileDetailsPropertyPage;
+import org.eclipse.datatools.connectivity.ui.wizards.ExtensibleProfileDetailsPropertyPage;
import org.eclipse.datatools.help.ContextProviderDelegate;
import org.eclipse.datatools.help.HelpUtil;
import org.eclipse.help.IContext;
import org.eclipse.help.IContextProvider;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-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.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
/**
* Property page for Derby Embedded profiles
- *
+ *
*/
-public class DerbyEmbeddedDBPropertyPage
- extends ProfileDetailsPropertyPage
- implements IContextProvider {
-
- private static final String EMPTY_STRING = new String();
-
- // UI components
- private Text mDatabaseNameText;
- private Text mDBUIDText;
- private Text mDBPWDText;
- private Text mURLText;
- private Button mSaveDBPWDCheckbox;
- private Button mCreateDBCheckbox;
- private Button mUpgradeDBCheckbox;
- private Text mDBFilePathText;
- private Button mBrowseFilePathButton;
- final DriverListCombo combo = new DriverListCombo();
- private DelimitedStringList mDBConnProps;
-
- // other components
- private DriverInstance mDriverInstance;
- private String mDriverCategory;
+public class DerbyEmbeddedDBPropertyPage extends
+ ExtensibleProfileDetailsPropertyPage implements IContextProvider {
/**
* Constructor
*/
public DerbyEmbeddedDBPropertyPage() {
- super();
- noDefaultAndApplyButton();
- setDriverCategory(IDerbyConnectionProfileConstants.DERBY_CATEGORY_ID);
- this.combo.setFilter("templateIDStartsWith = " + //$NON-NLS-1$
- IDerbyConnectionProfileConstants.DERBY_ENABLEMENT_DRIVER_PREFIX + "," + //$NON-NLS-1$
- "templateIDEndsWith = " + //$NON-NLS-1$
- IDerbyConnectionProfileConstants.DERBY_ENABLEMENT_DRIVER_SUFFIX);
+ super(IDerbyConnectionProfileConstants.DERBY_CATEGORY_ID);
}
- /**
- * @see PreferencePage#createContents(Composite)
- */
- protected void createCustomContents(Composite parent) {
- Composite content = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout(2, false);
- content.setLayout(layout);
-
- this.combo.setLabelText(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.driverCombo.label")); //$NON-NLS-1$
- this.combo.setCategory(getDriverCategory());
- this.combo.setNullDriverIsValid(false);
- this.combo.createContents(content);
-
- this.mDatabaseNameText = (Text) createLabelTextPair(
- content,
- Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.databaseName.label"), //$NON-NLS-1$
- this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
-
- Label label = new Label(content, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.0")); //$NON-NLS-1$
-
- Composite textAndBrowseComposite = new Composite(content, SWT.NULL);
- GridLayout subCompositeLayout = new GridLayout(2, false);
- subCompositeLayout.marginLeft = -5;
- subCompositeLayout.marginRight = -5;
- subCompositeLayout.marginTop = -5;
- subCompositeLayout.marginBottom = -5;
- textAndBrowseComposite.setLayout(subCompositeLayout);
- textAndBrowseComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.mDBFilePathText = new Text(textAndBrowseComposite, SWT.BORDER);
- this.mDBFilePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.mBrowseFilePathButton = new Button(textAndBrowseComposite, SWT.PUSH);
- this.mBrowseFilePathButton.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.1")); //$NON-NLS-1$
- this.mBrowseFilePathButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
- this.mURLText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.url.label"), //$NON-NLS-1$
- this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
- this.mDBUIDText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.userName.label"), //$NON-NLS-1$
- this.mDBUIDText, SWT.BORDER, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
-
- this.mDBPWDText = (Text) createLabelTextPair(content, Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.password.label"), //$NON-NLS-1$,
- this.mDBPWDText, SWT.BORDER | SWT.PASSWORD, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
-
- this.mCreateDBCheckbox = new Button(content, SWT.CHECK);
- this.mCreateDBCheckbox.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.2")); //$NON-NLS-1$
- this.mCreateDBCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- this.mUpgradeDBCheckbox = new Button(content, SWT.CHECK);
- this.mUpgradeDBCheckbox.setText(Messages.getString("DerbyEmbeddedDBProfileDetailsWizardPage.3")); //$NON-NLS-1$
- this.mUpgradeDBCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- this.mSaveDBPWDCheckbox = new Button(content, SWT.CHECK);
- this.mSaveDBPWDCheckbox.setText(Messages
- .getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.persistpassword.label")); //$NON-NLS-1$
- this.mSaveDBPWDCheckbox.setLayoutData(new GridData(GridData.BEGINNING,
- GridData.CENTER, true, false, 2, 1));
-
- Composite spacer = new Composite(content, SWT.NULL);
- GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- gdata.heightHint = 20;
- spacer.setLayoutData(gdata);
-
- label = new Label(content, SWT.NULL);
- gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- label.setLayoutData(gdata);
- label.setText(Messages.getString(
- "DerbyEmbeddedDBProfileDetailsWizardPage.optionalProps.label")); //$NON-NLS-1$
-
- this.mDBConnProps = new DelimitedStringList(content, SWT.NONE);
- gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.horizontalSpan = 2;
- this.mDBConnProps.setLayoutData(gdata);
-
- this.mDBConnProps.addChangeListener(new ChangeListener() {
-
- public void stateChanged(ChangeEvent arg0) {
- setErrorMessage(null);
- if (DerbyEmbeddedDBPropertyPage.this.mDBConnProps.getWarning() != null) {
- setErrorMessage(DerbyEmbeddedDBPropertyPage.this.mDBConnProps
- .getWarning());
- }
- }
-
- });
-
- this.combo.addChangeListener(new ChangeListener() {
-
- public void stateChanged(ChangeEvent arg0) {
- DerbyEmbeddedDBPropertyPage.this.mDriverInstance = DerbyEmbeddedDBPropertyPage.this.combo
- .getSelectedDriverInstance();
- setErrorMessage(null);
- if (DerbyEmbeddedDBPropertyPage.this.combo.getErrorMessage() != null) {
- setErrorMessage(DerbyEmbeddedDBPropertyPage.this.combo
- .getErrorMessage());
- }
- else
- DerbyEmbeddedDBPropertyPage.this.mURLText
- .setText(getDriverURL());
- String username = DerbyEmbeddedDBPropertyPage.this
- .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.USERNAME_PROP_ID);
- if (username == null || username.trim().length() == 0)
- username = new String();
- String oldUsername = DerbyEmbeddedDBPropertyPage.this.mDBUIDText
- .getText();
- if (oldUsername == null || oldUsername.trim().length() == 0)
- oldUsername = new String();
- if (oldUsername.length() == 0)
- DerbyEmbeddedDBPropertyPage.this.mDBUIDText
- .setText(username);
-
- String password = DerbyEmbeddedDBPropertyPage.this
- .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.PASSWORD_PROP_ID);
- if (password == null || password.trim().length() == 0)
- password = new String();
- String oldPassword = DerbyEmbeddedDBPropertyPage.this.mDBPWDText
- .getText();
- if (oldPassword == null || oldPassword.trim().length() == 0)
- oldPassword = new String();
- if (oldPassword.length() == 0)
- DerbyEmbeddedDBPropertyPage.this.mDBPWDText
- .setText(password);
- }
-
- });
-
- initControls();
-
- this.mDBFilePathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- DerbyEmbeddedDBPropertyPage.this.updateURLFromProps();
- }
- });
-
- this.mCreateDBCheckbox.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.updateURLFromProps();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.updateURLFromProps();
- }
- });
-
- this.mUpgradeDBCheckbox.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.updateURLFromProps();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.updateURLFromProps();
- }
- });
-
- this.mBrowseFilePathButton.addSelectionListener( new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.browseForDBFolder();
- }
-
- public void widgetSelected(SelectionEvent e) {
- DerbyEmbeddedDBPropertyPage.this.browseForDBFolder();
- }
- });
-
- // return content;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- protected Properties collectProperties() {
- Properties props = new Properties();
-
- String driverID = EMPTY_STRING;
-
- if (this.combo.getSelectedDriverInstance() != null) {
- DriverInstance instance = this.combo.getSelectedDriverInstance();
- driverID = instance.getId();
- }
-
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
- driverID);
- props.setProperty(
- IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
- this.mDBConnProps.getSelection());
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, getPropertyFromDriverInstance(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, getPropertyFromDriverInstance(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, getPropertyFromDriverInstance(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.mDatabaseNameText
- .getText());
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, this.mDBPWDText
- .getText());
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, this.mDBUIDText
- .getText());
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
- this.mURLText.getText());
- props.setProperty(
- IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
- .valueOf(this.mSaveDBPWDCheckbox.getSelection()));
-
- return props;
- }
-
- /**
- *
- */
- private void initControls() {
- IConnectionProfile profile = getConnectionProfile();
- String driverID = profile.getBaseProperties().getProperty(
- ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID);
- if (driverID != null) {
- this.combo.setSelectionToID(driverID);
- }
-
- String connectionProps = profile.getBaseProperties().getProperty(
- IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
- if (connectionProps != null) {
- this.mDBConnProps.setSelection(connectionProps);
- }
-
- String databaseName = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
- if (databaseName != null) {
- this.mDatabaseNameText.setText(databaseName);
- }
-
- String databasePwd = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.PASSWORD_PROP_ID);
- if (databasePwd != null) {
- this.mDBPWDText.setText(databasePwd);
- }
-
- String databaseUid = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.USERNAME_PROP_ID);
- if (databaseUid != null) {
- this.mDBUIDText.setText(databaseUid);
- }
-
- String urlText = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.URL_PROP_ID);
- if (urlText != null) {
- this.mURLText.setText(urlText);
- this.mURLText.setEnabled(false);
- }
-
- this.mSaveDBPWDCheckbox.setSelection(Boolean.valueOf(
- profile.getBaseProperties().getProperty(
- IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
- Boolean.FALSE.toString())).booleanValue());
-
- this.updatePropsFromURL();
-
- setErrorMessage(null);
- if (this.combo.getErrorMessage() != null) {
- setErrorMessage(this.combo.getErrorMessage());
- }
- }
-
- /**
- * Browse for a DB folder
- */
- private void browseForDBFolder() {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setText(Messages
- .getString("DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.title.filebrowse")); //$NON-NLS-1$
- dialog.setMessage(Messages
- .getString("DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.msg.filebrowse")); //$NON-NLS-1$
-
- String dirName = mDBFilePathText.getText();
-
- File path = new File(dirName);
- if (path.exists()) {
- dialog.setFilterPath(new Path(dirName).toOSString());
- }
-
- String selectedDirectory = dialog.open();
- if (selectedDirectory != null) {
- this.mDBFilePathText.setText(selectedDirectory);
- }
- }
-
- /**
- * Based on the URL, update the UI components accordingly
- */
- private void updatePropsFromURL() {
- if (this.mDBFilePathText != null && this.mURLText != null && this.mCreateDBCheckbox != null && this.mUpgradeDBCheckbox != null) {
- String url = this.mURLText.getText();
- String[] chunks = parseString(url, ";"); //$NON-NLS-1$
- if (chunks.length > 0) {
- String[] chunks2 = parseString(chunks[0], ":"); //$NON-NLS-1$
- if (chunks2.length > 2) {
- String filepath = chunks2[2];
- if (chunks2.length > 3) {
- filepath = filepath + ":" + chunks2[3]; //$NON-NLS-1$
- }
- this.mDBFilePathText.setText(filepath);
- }
- }
- if (chunks.length > 1) {
- for (int i = 1; i < chunks.length; i++) {
- if (chunks[i].startsWith("create=")) //$NON-NLS-1$
- this.mCreateDBCheckbox.setSelection(true);
- else if (chunks[i].startsWith("upgrade=")) //$NON-NLS-1$
- this.mUpgradeDBCheckbox.setSelection(true);
- }
- }
- }
- }
-
- /**
- * Based on the state of the UI components, reset the URL
- */
- private void updateURLFromProps() {
- if (this.mDBFilePathText != null && this.mURLText != null && this.mCreateDBCheckbox != null && this.mUpgradeDBCheckbox != null) {
- String url = this.mURLText.getText();
- String filePath = this.mDBFilePathText.getText();
- boolean createDB = this.mCreateDBCheckbox.getSelection();
- boolean upgradeDB = this.mUpgradeDBCheckbox.getSelection();
- //jdbc:derby:C:\DerbyDatabases\MyDB;create=true
- String[] chunks = parseString(url, ";"); //$NON-NLS-1$
- if (chunks.length > 0) {
- String[] chunks2 = parseString(chunks[0], ":"); //$NON-NLS-1$
- if (chunks2.length > 2) {
- url = chunks2[0] + ":" + chunks2[1] + ":" + filePath; //$NON-NLS-1$ //$NON-NLS-2$
- if (createDB) {
- url = url + ";" + "create=true"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (upgradeDB) {
- url = url + ";" + "upgrade=true"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- this.mURLText.setText(url);
- }
- }
- }
- }
-
- /**
- * Parse a string into an array based on a token
- * @param str_list
- * @param token
- * @return
- */
- private String[] parseString(String str_list, String token) {
- StringTokenizer tk = new StringTokenizer(str_list, token);
- String[] pieces = new String[tk.countTokens()];
- int index = 0;
- while (tk.hasMoreTokens())
- pieces[index++] = tk.nextToken();
- return pieces;
- }
-
- /**
- * @param propertyID
- * @return
- */
- private String getPropertyFromDriverInstance(String propertyID) {
- String returnStr = new String();
- if (this.mDriverInstance != null
- && this.mDriverInstance.getProperty(propertyID) != null) {
- returnStr = this.mDriverInstance.getProperty(propertyID);
- }
- return returnStr;
- }
-
- /**
- * @param parent
- * @param labelText
- * @param ctl
- * @param style
- * @param gData
- * @return
- */
- private Control createLabelTextPair(Composite parent, String labelText,
- Control ctl, int style, int gData) {
- Label label = new Label(parent, SWT.NULL);
- label.setLayoutData(new GridData());
- label.setText(labelText);
-
- ctl = new Text(parent, style);
- ctl.setLayoutData(new GridData(gData));
-
- return ctl;
- }
-
- /**
- * @return
- */
- public String getDriverURL() {
- return this.mDriverInstance
- .getProperty(IDBDriverDefinitionConstants.URL_PROP_ID);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#isValid()
- */
- public boolean isValid() {
- if (getErrorMessage() != null) {
- return false;
- }
- return super.isValid();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.DialogPage#setErrorMessage(java.lang.String)
- */
- public void setErrorMessage(String newMessage) {
- super.setErrorMessage(newMessage);
- isValid();
- }
-
- /**
- * @return
- */
- public String getDriverCategory() {
- return mDriverCategory;
- }
-
-
- /**
- * Sets the driver category that should be used for displaying available
- * driver defnitions.
- *
- * @param driverCategory
- */
- public void setDriverCategory(String driverCategory) {
- mDriverCategory = driverCategory;
- if (combo != null) {
- combo.setCategory(mDriverCategory);
- }
- }
-
- private ContextProviderDelegate contextProviderDelegate =
- new ContextProviderDelegate(DerbyUIPlugin.getDefault().getBundle().getSymbolicName());
+ private ContextProviderDelegate contextProviderDelegate = new ContextProviderDelegate(
+ DerbyUIPlugin.getDefault().getBundle().getSymbolicName());
public IContext getContext(Object target) {
return contextProviderDelegate.getContext(target);
@@ -557,8 +55,11 @@
protected Control createContents(Composite parent) {
Control contents = super.createContents(parent);
- getShell().setData( HelpUtil.CONTEXT_PROVIDER_KEY, this);
- HelpUtil.setHelp( getControl(), HelpUtil.getContextId(IHelpConstants.CONTEXT_ID_CP_PROPERTY_PAGE, ConnectivityUIPlugin.getDefault().getBundle().getSymbolicName()));
+ getShell().setData(HelpUtil.CONTEXT_PROVIDER_KEY, this);
+ HelpUtil.setHelp(getControl(), HelpUtil
+ .getContextId(IHelpConstants.CONTEXT_ID_CP_PROPERTY_PAGE,
+ ConnectivityUIPlugin.getDefault().getBundle()
+ .getSymbolicName()));
return contents;
}
}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/NewDerbyEmbeddedConnectionProfileWizard.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/NewDerbyEmbeddedConnectionProfileWizard.java
index a671930..2840cf0 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/NewDerbyEmbeddedConnectionProfileWizard.java
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/NewDerbyEmbeddedConnectionProfileWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004-2005 Sybase, Inc.
+ * Copyright (c) 2004-2005, 2007 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
@@ -7,16 +7,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: brianf - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection;
-import java.util.Properties;
-
-import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
import org.eclipse.datatools.connectivity.apache.derby.internal.ui.DerbyUIPlugin;
-import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
+import org.eclipse.datatools.connectivity.ui.wizards.ExtensibleNewConnectionProfileWizard;
import org.eclipse.datatools.help.ContextProviderDelegate;
import org.eclipse.datatools.help.HelpUtil;
import org.eclipse.help.IContext;
@@ -27,52 +23,13 @@
* @see Wizard
*/
public class NewDerbyEmbeddedConnectionProfileWizard extends
- NewConnectionProfileWizard {
-
- protected DerbyEmbeddedDBProfileDetailsWizardPage mPropPage;
+ExtensibleNewConnectionProfileWizard {
public NewDerbyEmbeddedConnectionProfileWizard() {
+ super(new DerbyEmbeddedDBProfileDetailsWizardPage("detailsPage")); //$NON-NLS-1$
setWindowTitle(Messages.getString("NewDerbyEmbeddedConnectionProfileWizard.DerbyEmbeddedDatabaseWizardTitle")); //$NON-NLS-1$
}
- /**
- * @see org.eclipse.datatools.connectivity.ui.wizards.NewDerbyEmbeddedConnectionProfileWizard#addCustomPages()
- */
- public void addCustomPages() {
- mPropPage = new DerbyEmbeddedDBProfileDetailsWizardPage("detailsPage"); //$NON-NLS-1$
- addPage(mPropPage);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard#getProfileProperties()
- */
- public Properties getProfileProperties() {
- Properties props = new Properties();
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
- this.mPropPage.getDriverID());
- props.setProperty(
- IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
- this.mPropPage.getDBConnProps());
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.mPropPage
- .getDriverClass());
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.mPropPage
- .getVendor());
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.mPropPage
- .getVersion());
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.mPropPage
- .getDatabaseName());
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, this.mPropPage
- .getDBPWD());
- props.setProperty(
- IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
- .valueOf(this.mPropPage.getSaveDBPWD()));
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, this.mPropPage
- .getDBUID());
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
- this.mPropPage.getURL());
- return props;
- }
-
private ContextProviderDelegate contextProviderDelegate =
new ContextProviderDelegate(DerbyUIPlugin.getDefault().getBundle().getSymbolicName());
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyClientDriverUIContributor.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyClientDriverUIContributor.java
new file mode 100644
index 0000000..e74f736
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyClientDriverUIContributor.java
@@ -0,0 +1,531 @@
+/*******************************************************************************
+ * Copyright (c) 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 accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributor;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributorInformation;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+public class DerbyClientDriverUIContributor implements IDriverUIContributor,
+ Listener {
+
+ protected String CUI_NEWCW_DATABASE_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_DATABASE_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_HOST_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_HOST_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PORT_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_PORT_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CONNECTIONURL_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_CONNECTIONURL_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_USERNAME_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PASSWORD_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_PASSWORD_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.2"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.3"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_SAVE_PASSWORD_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_URL_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_URL_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CREATE_EQUALS_TRUE_TEXT = "create=true"; //$NON-NLS-1$
+
+ private static final String UPGRADE_EQUALS_TRUE_TEXT = "upgrade=true"; //$NON-NLS-1$
+
+ private Label databaseLabel;
+
+ private Text databaseText;
+
+ private Label hostLabel;
+
+ private Text hostText;
+
+ private Label portLabel;
+
+ private Text portText;
+
+ private Label usernameLabel;
+
+ private Text usernameText;
+
+ private Label passwordLabel;
+
+ private Text passwordText;
+
+ private Button createCheck;
+
+ private Button upgradeCheck;
+
+ private Button savePasswordButton;
+
+ private Label urlLabel;
+
+ private Text urlText;
+
+ private DialogPage parentPage;
+
+ private ScrolledComposite parentComposite;
+
+ private IDriverUIContributorInformation contributorInformation;
+
+ private Properties properties;
+
+ public Composite getContributedDriverUI(Composite parent) {
+
+ if ((parentComposite == null) || parentComposite.isDisposed()) {
+ GridData gd;
+
+ parentComposite = new ScrolledComposite(parent, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ parentComposite.setExpandHorizontal(true);
+ parentComposite.setExpandVertical(true);
+ parentComposite.setLayout(new GridLayout());
+
+ Composite baseComposite = new Composite(parentComposite, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ baseComposite.setLayout(layout);
+
+ databaseLabel = new Label(baseComposite, SWT.NONE);
+ databaseLabel.setText(CUI_NEWCW_DATABASE_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ databaseLabel.setLayoutData(gd);
+
+ databaseText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.horizontalSpan = 2;
+ databaseText.setLayoutData(gd);
+
+ hostLabel = new Label(baseComposite, SWT.NONE);
+ hostLabel.setText(CUI_NEWCW_HOST_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ hostLabel.setLayoutData(gd);
+
+ hostText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 2;
+ gd.grabExcessHorizontalSpace = true;
+ hostText.setLayoutData(gd);
+
+ portLabel = new Label(baseComposite, SWT.NONE);
+ portLabel.setText(CUI_NEWCW_PORT_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ portLabel.setLayoutData(gd);
+
+ portText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ portText.setLayoutData(gd);
+
+ usernameLabel = new Label(baseComposite, SWT.NONE);
+ usernameLabel.setText(CUI_NEWCW_USERNAME_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ usernameLabel.setLayoutData(gd);
+
+ usernameText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ usernameText.setLayoutData(gd);
+
+ passwordLabel = new Label(baseComposite, SWT.NONE);
+ passwordLabel.setText(CUI_NEWCW_PASSWORD_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ passwordLabel.setLayoutData(gd);
+
+ passwordText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER
+ | SWT.PASSWORD);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ passwordText.setLayoutData(gd);
+
+ createCheck = new Button(baseComposite, SWT.CHECK);
+ createCheck.setText(CUI_NEWCW_CREATEDB_BTN_UI_);
+ createCheck.setSelection(true);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ createCheck.setLayoutData(gd);
+
+ upgradeCheck = new Button(baseComposite, SWT.CHECK);
+ upgradeCheck.setText(CUI_NEWCW_UPGRADEDB_BTN_UI_);
+ upgradeCheck.setSelection(false);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ upgradeCheck.setLayoutData(gd);
+
+ this.savePasswordButton = new Button(baseComposite, SWT.CHECK);
+ this.savePasswordButton.setText(CUI_NEWCW_SAVE_PASSWORD_LBL_UI_); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 3;
+ gd.grabExcessHorizontalSpace = true;
+ savePasswordButton.setLayoutData(gd);
+
+ urlLabel = new Label(baseComposite, SWT.NONE);
+ urlLabel.setText(CUI_NEWCW_CONNECTIONURL_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ urlLabel.setLayoutData(gd);
+
+ urlText = new Text(baseComposite, SWT.MULTI | SWT.BORDER
+ | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.widthHint = 190;
+ gd.heightHint = 90;
+ urlText.setLayoutData(gd);
+
+ parentComposite.setContent(baseComposite);
+ parentComposite.setMinSize(baseComposite.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+
+ initialize();
+ }
+ return parentComposite;
+ }
+
+ public void setConnectionInformation() {
+ properties.setProperty(
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
+ this.databaseText.getText().trim());
+ properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID,
+ this.passwordText.getText());
+
+ properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID,
+ this.usernameText.getText());
+ properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID,
+ this.urlText.getText().trim());
+
+ properties.setProperty(
+ IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
+ .valueOf(savePasswordButton.getSelection()));
+ this.contributorInformation.setProperties(properties);
+ }
+
+ public void updateURL() {
+ String url = "jdbc:derby://" + hostText.getText().trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ if (portText.getText().trim().length() > 0) {
+ url += ":" + portText.getText().trim();
+ }
+ url += "/" + databaseText.getText().trim(); //$NON-NLS-1$
+ if (createCheck.getSelection()) {
+ url += ";" + CREATE_EQUALS_TRUE_TEXT;
+ }
+ if (upgradeCheck.getSelection()) {
+ url += ";" + UPGRADE_EQUALS_TRUE_TEXT;
+ }
+ urlText.setText(url);
+ }
+
+ private void removeListeners() {
+ databaseText.removeListener(SWT.Modify, this);
+ hostText.removeListener(SWT.Modify, this);
+ portText.removeListener(SWT.Modify, this);
+ usernameText.removeListener(SWT.Modify, this);
+ passwordText.removeListener(SWT.Modify, this);
+ createCheck.removeListener(SWT.Selection, this);
+ upgradeCheck.removeListener(SWT.Selection, this);
+ savePasswordButton.removeListener(SWT.Selection, this);
+ }
+
+ private void addListeners() {
+ databaseText.addListener(SWT.Modify, this);
+ hostText.addListener(SWT.Modify, this);
+ portText.addListener(SWT.Modify, this);
+ usernameText.addListener(SWT.Modify, this);
+ passwordText.addListener(SWT.Modify, this);
+ createCheck.addListener(SWT.Selection, this);
+ upgradeCheck.addListener(SWT.Selection, this);
+ savePasswordButton.addListener(SWT.Selection, this);
+ }
+
+ private void initialize() {
+ updateURL();
+ addListeners();
+ }
+
+ public void handleEvent(Event event) {
+ updateURL();
+ setConnectionInformation();
+ }
+
+ public boolean determineContributorCompletion() {
+ boolean isComplete = true;
+ if (databaseText.getText().trim().length() < 1) { //$NON-NLS-1$
+ parentPage.setErrorMessage(MessageFormat.format(Messages
+ .getString("CUI_NEWCW_VALIDATE_DATABASE_REQ_UI_"), //$NON-NLS-1$
+ new Object[] { Messages
+ .getString("CUI_NEWCW_DEFDBNAME_VAL_UI_") })); //$NON-NLS-1$
+ isComplete = false;
+ } else if (hostText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_HOST_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ } else if (usernameText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_USERID_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ } else if (passwordText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_PASSWORD_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ }
+
+ if (isComplete) {
+ parentPage.setErrorMessage(null);
+ }
+ return isComplete;
+ }
+
+ public void setDialogPage(DialogPage parentPage) {
+ this.parentPage = parentPage;
+ }
+
+ public void setDriverUIContributorInformation(
+ IDriverUIContributorInformation contributorInformation) {
+ this.contributorInformation = contributorInformation;
+ this.properties = contributorInformation.getProperties();
+ }
+
+ public void loadProperties() {
+ removeListeners();
+ DerbyClientJDBCURL url = new DerbyClientJDBCURL(this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID));
+ hostText.setText(url.getNode());
+ portText.setText(url.getPort());
+ databaseText.setText(url.getDatabaseName());
+
+ String username = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
+ if (username != null) {
+ usernameText.setText(username);
+ }
+ String password = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
+ if (password != null) {
+ passwordText.setText(password);
+ }
+ if (!(url.getProperties().indexOf(CREATE_EQUALS_TRUE_TEXT) > -1)) {
+ createCheck.setSelection(false);
+ }
+ if ((url.getProperties().indexOf(UPGRADE_EQUALS_TRUE_TEXT) > -1)) {
+ upgradeCheck.setSelection(true);
+ }
+ String savePassword = this.properties
+ .getProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID);
+ if ((savePassword != null)
+ && Boolean.valueOf(savePassword) == Boolean.TRUE) {
+ savePasswordButton.setSelection(true);
+ }
+ updateURL();
+ addListeners();
+ setConnectionInformation();
+ }
+
+ public List getSummaryData() {
+ List summaryData = new ArrayList();
+
+ summaryData.add(new String[] { CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_,
+ this.databaseText.getText().trim() });
+ summaryData.add(new String[] { CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_,
+ this.hostText.getText().trim() });
+ summaryData.add(new String[] { CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_,
+ this.portText.getText().trim() });
+
+ summaryData.add(new String[] { CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_,
+ this.usernameText.getText().trim() });
+ summaryData.add(new String[] {
+ CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_,
+ createCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] {
+ CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_,
+ upgradeCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData
+ .add(new String[] {
+ CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_,
+ savePasswordButton.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] { CUI_NEWCW_URL_SUMMARY_DATA_TEXT_,
+ this.urlText.getText().trim() });
+ return summaryData;
+ }
+
+ private class DerbyClientJDBCURL {
+ private String subprotocol = ""; //$NON-NLS-1$
+
+ private String node = ""; //$NON-NLS-1$
+
+ private String port = ""; //$NON-NLS-1$
+
+ private String databaseName = ""; //$NON-NLS-1$
+
+ private String properties = ""; //$NON-NLS-1$
+
+ /**
+ * @param url
+ */
+ public DerbyClientJDBCURL(String url) {
+ if (url != null) {
+ parseURL(url);
+ }
+ }
+
+ /**
+ * @return Returns the databaseName.
+ */
+ public String getDatabaseName() {
+ return databaseName;
+ }
+
+ /**
+ * @return Returns the node.
+ */
+ public String getNode() {
+ return node;
+ }
+
+ /**
+ * @return Returns the subprotocol.
+ */
+ public String getSubprotocol() {
+ return subprotocol;
+ }
+
+ private void parseURL(String url) {
+ try {
+ String remainingURL = url.substring(url.indexOf(':') + 1);
+ this.subprotocol = remainingURL.substring(0, remainingURL
+ .indexOf(':'));
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf(':') + 3);
+ this.node = remainingURL
+ .substring(0, remainingURL.indexOf('/'));
+ if (this.node.indexOf(':') > -1) {
+ this.port = this.node.substring(this.node.indexOf(':') + 1);
+ this.node = this.node.substring(0, this.node.indexOf(':'));
+ }
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf('/') + 1);
+ if (remainingURL.indexOf('"') > -1) {
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf('"') + 1);
+ this.databaseName = "\""
+ + remainingURL.substring(0, remainingURL
+ .indexOf('"') + 1);
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf('"') + 1);
+ this.properties = remainingURL;
+ } else {
+ if (remainingURL.indexOf(';') > -1) {
+ this.databaseName = remainingURL.substring(0,
+ remainingURL.indexOf(';'));
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf(';') + 1);
+ this.properties = remainingURL;
+ } else {
+ this.databaseName = remainingURL;
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @return Returns the port.
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * @return Returns the properties.
+ */
+ public String getProperties() {
+ return properties;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyDriverUIContributor.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyDriverUIContributor.java
new file mode 100644
index 0000000..344649a
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyDriverUIContributor.java
@@ -0,0 +1,535 @@
+/*******************************************************************************
+ * Copyright (c) 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 accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributor;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributorInformation;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+public class DerbyDriverUIContributor implements IDriverUIContributor, Listener {
+
+ protected String CUI_NEWCW_DATABASE_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_DATABASE_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_HOST_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_HOST_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PORT_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_PORT_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CONNECTIONURL_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_CONNECTIONURL_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_USERNAME_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PASSWORD_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_PASSWORD_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.2"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.3"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_LBL_UI_ = Messages
+ .getString("CUI_NEWCW_SAVE_PASSWORD_LBL_UI_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_URL_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_URL_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CREATE_EQUALS_TRUE_TEXT = "create=true"; //$NON-NLS-1$
+
+ private static final String UPGRADE_EQUALS_TRUE_TEXT = "upgrade=true"; //$NON-NLS-1$
+
+ private Label databaseLabel;
+
+ private Text databaseText;
+
+ private Label hostLabel;
+
+ private Text hostText;
+
+ private Label portLabel;
+
+ private Text portText;
+
+ private Label usernameLabel;
+
+ private Text usernameText;
+
+ private Label passwordLabel;
+
+ private Text passwordText;
+
+ private Button createCheck;
+
+ private Button upgradeCheck;
+
+ private Button savePasswordButton;
+
+ private Label urlLabel;
+
+ private Text urlText;
+
+ private DialogPage parentPage;
+
+ private ScrolledComposite parentComposite;
+
+ private IDriverUIContributorInformation contributorInformation;
+
+ private Properties properties;
+
+ public Composite getContributedDriverUI(Composite parent) {
+
+ if ((parentComposite == null) || parentComposite.isDisposed()) {
+ GridData gd;
+
+ parentComposite = new ScrolledComposite(parent, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ parentComposite.setExpandHorizontal(true);
+ parentComposite.setExpandVertical(true);
+ parentComposite.setLayout(new GridLayout());
+
+ Composite baseComposite = new Composite(parentComposite, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ baseComposite.setLayout(layout);
+
+ databaseLabel = new Label(baseComposite, SWT.NONE);
+ databaseLabel.setText(CUI_NEWCW_DATABASE_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ databaseLabel.setLayoutData(gd);
+
+ databaseText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.horizontalSpan = 2;
+ databaseText.setLayoutData(gd);
+
+ hostLabel = new Label(baseComposite, SWT.NONE);
+ hostLabel.setText(CUI_NEWCW_HOST_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ hostLabel.setLayoutData(gd);
+
+ hostText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 2;
+ gd.grabExcessHorizontalSpace = true;
+ hostText.setLayoutData(gd);
+
+ portLabel = new Label(baseComposite, SWT.NONE);
+ portLabel.setText(CUI_NEWCW_PORT_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ portLabel.setLayoutData(gd);
+
+ portText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ portText.setLayoutData(gd);
+
+ usernameLabel = new Label(baseComposite, SWT.NONE);
+ usernameLabel.setText(CUI_NEWCW_USERNAME_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ usernameLabel.setLayoutData(gd);
+
+ usernameText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ usernameText.setLayoutData(gd);
+
+ passwordLabel = new Label(baseComposite, SWT.NONE);
+ passwordLabel.setText(CUI_NEWCW_PASSWORD_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ passwordLabel.setLayoutData(gd);
+
+ passwordText = new Text(baseComposite, SWT.SINGLE | SWT.BORDER
+ | SWT.PASSWORD);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ passwordText.setLayoutData(gd);
+
+ createCheck = new Button(baseComposite, SWT.CHECK);
+ createCheck.setText(CUI_NEWCW_CREATEDB_BTN_UI_);
+ createCheck.setSelection(true);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ createCheck.setLayoutData(gd);
+
+ upgradeCheck = new Button(baseComposite, SWT.CHECK);
+ upgradeCheck.setText(CUI_NEWCW_UPGRADEDB_BTN_UI_);
+ upgradeCheck.setSelection(false);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ upgradeCheck.setLayoutData(gd);
+
+ this.savePasswordButton = new Button(baseComposite, SWT.CHECK);
+ this.savePasswordButton.setText(CUI_NEWCW_SAVE_PASSWORD_LBL_UI_); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 3;
+ gd.grabExcessHorizontalSpace = true;
+ savePasswordButton.setLayoutData(gd);
+
+ urlLabel = new Label(baseComposite, SWT.NONE);
+ urlLabel.setText(CUI_NEWCW_CONNECTIONURL_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ urlLabel.setLayoutData(gd);
+
+ urlText = new Text(baseComposite, SWT.MULTI | SWT.BORDER
+ | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.widthHint = 190;
+ gd.heightHint = 90;
+ urlText.setLayoutData(gd);
+
+ parentComposite.setContent(baseComposite);
+ parentComposite.setMinSize(baseComposite.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+
+ initialize();
+ }
+ return parentComposite;
+ }
+
+ public void setConnectionInformation() {
+ properties.setProperty(
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
+ this.databaseText.getText().trim());
+ properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID,
+ this.passwordText.getText());
+
+ properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID,
+ this.usernameText.getText());
+ properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID,
+ this.urlText.getText().trim());
+
+ properties.setProperty(
+ IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
+ .valueOf(savePasswordButton.getSelection()));
+ this.contributorInformation.setProperties(properties);
+ }
+
+ public void updateURL() {
+ String url = "jdbc:derby:net://" + hostText.getText().trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ if (portText.getText().trim().length() > 0) {
+ url += ":" + portText.getText().trim();
+ }
+ url += "/" + databaseText.getText().trim() //$NON-NLS-1$
+ + ":retrieveMessagesFromServerOnGetMessage=true;"; //$NON-NLS-1$
+ if (createCheck.getSelection()) {
+ url += CREATE_EQUALS_TRUE_TEXT + ";";
+ }
+ if (upgradeCheck.getSelection()) {
+ url += UPGRADE_EQUALS_TRUE_TEXT + ";";
+ }
+ urlText.setText(url);
+ }
+
+ private void removeListeners() {
+ databaseText.removeListener(SWT.Modify, this);
+ hostText.removeListener(SWT.Modify, this);
+ portText.removeListener(SWT.Modify, this);
+ usernameText.removeListener(SWT.Modify, this);
+ passwordText.removeListener(SWT.Modify, this);
+ createCheck.removeListener(SWT.Selection, this);
+ upgradeCheck.removeListener(SWT.Selection, this);
+ savePasswordButton.removeListener(SWT.Selection, this);
+ }
+
+ private void addListeners() {
+ databaseText.addListener(SWT.Modify, this);
+ hostText.addListener(SWT.Modify, this);
+ portText.addListener(SWT.Modify, this);
+ usernameText.addListener(SWT.Modify, this);
+ passwordText.addListener(SWT.Modify, this);
+ createCheck.addListener(SWT.Selection, this);
+ upgradeCheck.addListener(SWT.Selection, this);
+ savePasswordButton.addListener(SWT.Selection, this);
+ }
+
+ private void initialize() {
+ updateURL();
+ addListeners();
+ }
+
+ public void handleEvent(Event event) {
+ updateURL();
+ setConnectionInformation();
+ }
+
+ public boolean determineContributorCompletion() {
+ boolean isComplete = true;
+ if (databaseText.getText().trim().length() < 1) { //$NON-NLS-1$
+ parentPage.setErrorMessage(MessageFormat.format(Messages
+ .getString("CUI_NEWCW_VALIDATE_DATABASE_REQ_UI_"), //$NON-NLS-1$
+ new Object[] { Messages
+ .getString("CUI_NEWCW_DEFDBNAME_VAL_UI_") })); //$NON-NLS-1$
+ isComplete = false;
+ } else if (hostText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_HOST_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ } else if (usernameText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_USERID_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ } else if (passwordText.getText().trim().length() < 1) {
+ parentPage.setErrorMessage(Messages
+ .getString("CUI_NEWCW_VALIDATE_PASSWORD_REQ_UI_")); //$NON-NLS-1$
+ isComplete = false;
+ }
+
+ if (isComplete) {
+ parentPage.setErrorMessage(null);
+ }
+ return isComplete;
+ }
+
+ public void setDialogPage(DialogPage parentPage) {
+ this.parentPage = parentPage;
+ }
+
+ public void setDriverUIContributorInformation(
+ IDriverUIContributorInformation contributorInformation) {
+ this.contributorInformation = contributorInformation;
+ this.properties = contributorInformation.getProperties();
+ }
+
+ public void loadProperties() {
+ removeListeners();
+ DerbyJDBCURL url = new DerbyJDBCURL(this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID));
+ hostText.setText(url.getNode());
+ portText.setText(url.getPort());
+ databaseText.setText(url.getDatabaseName());
+
+ String username = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
+ if (username != null) {
+ usernameText.setText(username);
+ }
+ String password = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
+ if (password != null) {
+ passwordText.setText(password);
+ }
+ if (!(url.getProperties().indexOf(CREATE_EQUALS_TRUE_TEXT) > -1)) {
+ createCheck.setSelection(false);
+ }
+ if ((url.getProperties().indexOf(UPGRADE_EQUALS_TRUE_TEXT) > -1)) {
+ upgradeCheck.setSelection(true);
+ }
+ String savePassword = this.properties
+ .getProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID);
+ if ((savePassword != null)
+ && Boolean.valueOf(savePassword) == Boolean.TRUE) {
+ savePasswordButton.setSelection(true);
+ }
+ updateURL();
+ addListeners();
+ setConnectionInformation();
+ }
+
+ public List getSummaryData() {
+ List summaryData = new ArrayList();
+
+ summaryData.add(new String[] { CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_,
+ this.databaseText.getText().trim() });
+ summaryData.add(new String[] { CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_,
+ this.hostText.getText().trim() });
+ summaryData.add(new String[] { CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_,
+ this.portText.getText().trim() });
+
+ summaryData.add(new String[] { CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_,
+ this.usernameText.getText().trim() });
+ summaryData.add(new String[] {
+ CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_,
+ createCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] {
+ CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_,
+ upgradeCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData
+ .add(new String[] {
+ CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_,
+ savePasswordButton.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] { CUI_NEWCW_URL_SUMMARY_DATA_TEXT_,
+ this.urlText.getText().trim() });
+ return summaryData;
+ }
+
+ private class DerbyJDBCURL {
+ private String subprotocol = ""; //$NON-NLS-1$
+
+ private String node = ""; //$NON-NLS-1$
+
+ private String port = ""; //$NON-NLS-1$
+
+ private String databaseName = ""; //$NON-NLS-1$
+
+ private String properties = ""; //$NON-NLS-1$
+
+ /**
+ * @param url
+ */
+ public DerbyJDBCURL(String url) {
+ if (url != null) {
+ parseURL(url);
+ }
+ }
+
+ /**
+ * @return Returns the databaseName.
+ */
+ public String getDatabaseName() {
+ return databaseName;
+ }
+
+ /**
+ * @return Returns the node.
+ */
+ public String getNode() {
+ return node;
+ }
+
+ /**
+ * @return Returns the subprotocol.
+ */
+ public String getSubprotocol() {
+ return subprotocol;
+ }
+
+ private void parseURL(String url) {
+ try {
+ String remainingURL = url.substring(url.indexOf(':') + 1);
+ this.subprotocol = remainingURL.substring(0, remainingURL
+ .indexOf(':'));
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf(':') + 1);
+ this.subprotocol += ":"
+ + remainingURL.substring(0, remainingURL.indexOf(':'));
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf(':') + 3);
+ this.node = remainingURL
+ .substring(0, remainingURL.indexOf('/'));
+ if (this.node.indexOf(':') > -1) {
+ this.port = this.node.substring(this.node.indexOf(':') + 1);
+ this.node = this.node.substring(0, this.node.indexOf(':'));
+ }
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf('/') + 1);
+ if (remainingURL.indexOf('"') > -1) {
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf('"') + 1);
+ this.databaseName = "\""
+ + remainingURL.substring(0, remainingURL
+ .indexOf('"') + 1);
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf('"') + 2);
+ this.properties = remainingURL;
+ } else {
+ if (remainingURL.indexOf(':') > -1) {
+ this.databaseName = remainingURL.substring(0,
+ remainingURL.indexOf(':'));
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf(':') + 1);
+ this.properties = remainingURL;
+ } else {
+ this.databaseName = remainingURL;
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @return Returns the port.
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * @return Returns the properties.
+ */
+ public String getProperties() {
+ return properties;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyEmbeddedDriverUIContributor.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyEmbeddedDriverUIContributor.java
new file mode 100644
index 0000000..8a9f8d1
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyEmbeddedDriverUIContributor.java
@@ -0,0 +1,559 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2006, 2007 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: brianf - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.internal.ui.DelimitedStringList;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributor;
+import org.eclipse.datatools.connectivity.ui.wizards.IDriverUIContributorInformation;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+public class DerbyEmbeddedDriverUIContributor implements IDriverUIContributor,
+ Listener, ModifyListener {
+
+ private static final String CUI_NEWCW_GENERAL_TAB_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.general.tab"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_OPTIONAL_TAB_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.optional.tab"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DBLOCATION_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.0"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DBBROWSE_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.1"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.2"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADEDB_BTN_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.3"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.userName.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_PASSWORD_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.password.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.persistpassword.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CONNECTIONURL_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.url.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_OPTIONAL_PROPERTIES_LBL_UI_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.optionalproperties.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DRIVER_NAME_SUMMARY_DATA_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.summary.driverName.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_DATABASE_LOCATION_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_DATABASE_LOCATION_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.summary.userName.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_URL_SUMMARY_DATA_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.summary.url.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_OPTIONAL_CONNECTION_PROPERTIES_SUMMARY_DATA_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.summary.connProps.label"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ = Messages
+ .getString("CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_FILE_BROWSER_TITLE_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.FileDialog.title.filebrowse"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_FILE_BROWSER_MESSAGE_TEXT_ = Messages
+ .getString("DerbyEmbeddedDriverUIContributor.FileDialog.msg.filebrowse"); //$NON-NLS-1$
+
+ private static final String CUI_NEWCW_VALIDATE_DBLOCATION_REQ_UI_ = Messages
+ .getString("CUI_NEWCW_VALIDATE_DBLOCATION_REQ_UI_"); //$NON-NLS-1$
+
+ private static final String CREATE_EQUALS_TRUE_TEXT = "create=true"; //$NON-NLS-1$
+
+ private static final String UPGRADE_EQUALS_TRUE_TEXT = "upgrade=true"; //$NON-NLS-1$
+
+ private ScrolledComposite parentComposite;
+
+ private Label databaseLocationLabel;
+
+ private Combo databaseLocationCombo;
+
+ private Button browseDatabaseLocation;
+
+ private Button createCheck;
+
+ private Button upgradeCheck;
+
+ private Label usernameLabel;
+
+ private Text usernameText;
+
+ private Label passwordLabel;
+
+ private Text passwordText;
+
+ private Button savePasswordButton;
+
+ private Label urlLabel;
+
+ private Text urlText;
+
+ private DelimitedStringList optionalConnectionProperties;
+
+ private DialogPage parentPage;
+
+ private IDriverUIContributorInformation contributorInformation;
+
+ private Properties properties;
+
+ private String databaseName;
+
+ public boolean determineContributorCompletion() {
+ boolean isComplete = true;
+ if (databaseLocationCombo.getText().equals("")) //$NON-NLS-1$
+ {
+ parentPage.setErrorMessage(CUI_NEWCW_VALIDATE_DBLOCATION_REQ_UI_); //$NON-NLS-1$
+ isComplete = false;
+ }
+
+ if (isComplete) {
+ parentPage.setErrorMessage(null);
+ }
+ return isComplete;
+ }
+
+ public Composite getContributedDriverUI(Composite parent) {
+ if (parentComposite == null || parentComposite.isDisposed()) {
+ parentComposite = new ScrolledComposite(parent, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ parentComposite.setExpandHorizontal(true);
+ parentComposite.setExpandVertical(true);
+ parentComposite.setLayout(new GridLayout());
+
+ TabFolder baseComposite = new TabFolder(parentComposite, SWT.TOP);
+
+ TabItem generalTab = new TabItem(baseComposite, SWT.None);
+ generalTab.setText(CUI_NEWCW_GENERAL_TAB_UI_); //$NON-NLS-1$
+
+ TabItem optionalTab = new TabItem(baseComposite, SWT.None);
+ optionalTab.setText(CUI_NEWCW_OPTIONAL_TAB_UI_); //$NON-NLS-1$
+
+ Composite generalComposite = new Composite(baseComposite, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ generalComposite.setLayout(layout);
+ generalTab.setControl(generalComposite);
+
+ Composite optionalComposite = new Composite(baseComposite, SWT.NULL);
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ optionalComposite.setLayout(layout);
+ optionalTab.setControl(optionalComposite);
+
+ GridData gd;
+
+ databaseLocationLabel = new Label(generalComposite, SWT.NONE);
+ databaseLocationLabel.setText(CUI_NEWCW_DBLOCATION_LBL_UI_);
+
+ Composite textAndBrowseComposite = new Composite(generalComposite,
+ SWT.NULL);
+ GridLayout subCompositeLayout = new GridLayout(2, false);
+ subCompositeLayout.marginLeft = -5;
+ subCompositeLayout.marginRight = -5;
+ subCompositeLayout.marginTop = -5;
+ subCompositeLayout.marginBottom = -5;
+ textAndBrowseComposite.setLayout(subCompositeLayout);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ textAndBrowseComposite.setLayoutData(gd);
+
+ databaseLocationCombo = new Combo(textAndBrowseComposite,
+ SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ databaseLocationCombo.setLayoutData(gd);
+
+ browseDatabaseLocation = new Button(textAndBrowseComposite,
+ SWT.PUSH);
+ browseDatabaseLocation.setText(CUI_NEWCW_DBBROWSE_BTN_UI_);
+ browseDatabaseLocation.setLayoutData(new GridData(
+ GridData.HORIZONTAL_ALIGN_END));
+ browseDatabaseLocation.addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(Event event) {
+ DerbyEmbeddedDriverUIContributor.this.browseForDBFolder();
+ }
+
+ });
+ usernameLabel = new Label(generalComposite, SWT.NONE);
+ usernameLabel.setText(CUI_NEWCW_USERNAME_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ usernameLabel.setLayoutData(gd);
+
+ usernameText = new Text(generalComposite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ usernameText.setLayoutData(gd);
+
+ passwordLabel = new Label(generalComposite, SWT.NONE);
+ passwordLabel.setText(CUI_NEWCW_PASSWORD_LBL_UI_);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.BEGINNING;
+ passwordLabel.setLayoutData(gd);
+
+ passwordText = new Text(generalComposite, SWT.SINGLE | SWT.BORDER
+ | SWT.PASSWORD);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ passwordText.setLayoutData(gd);
+
+ urlLabel = new Label(generalComposite, SWT.NONE);
+ urlLabel.setText(CUI_NEWCW_CONNECTIONURL_LBL_UI_);
+
+ urlText = new Text(generalComposite, SWT.SINGLE | SWT.BORDER
+ | SWT.READ_ONLY);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ urlText.setLayoutData(gd);
+
+ createCheck = new Button(generalComposite, SWT.CHECK);
+ createCheck.setText(CUI_NEWCW_CREATEDB_BTN_UI_);
+ createCheck.setSelection(true);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ createCheck.setLayoutData(gd);
+
+ upgradeCheck = new Button(generalComposite, SWT.CHECK);
+ upgradeCheck.setText(CUI_NEWCW_UPGRADEDB_BTN_UI_);
+ upgradeCheck.setSelection(false);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ upgradeCheck.setLayoutData(gd);
+
+ this.savePasswordButton = new Button(generalComposite, SWT.CHECK);
+ this.savePasswordButton.setText(CUI_NEWCW_SAVE_PASSWORD_LBL_UI_); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 3;
+ gd.grabExcessHorizontalSpace = true;
+ savePasswordButton.setLayoutData(gd);
+
+ Label optionalPropertiesLabel = new Label(optionalComposite,
+ SWT.NULL);
+ GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
+ gdata.horizontalSpan = 2;
+ optionalPropertiesLabel.setLayoutData(gdata);
+ optionalPropertiesLabel
+ .setText(CUI_NEWCW_OPTIONAL_PROPERTIES_LBL_UI_); //$NON-NLS-1$
+
+ optionalConnectionProperties = new DelimitedStringList(
+ optionalComposite, SWT.NONE);
+ gdata = new GridData(GridData.FILL_HORIZONTAL);
+ gdata.horizontalSpan = 2;
+ optionalConnectionProperties.setLayoutData(gdata);
+
+ parentComposite.setContent(baseComposite);
+ parentComposite.setMinSize(baseComposite.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+
+ initialize();
+ }
+
+ return parentComposite;
+ }
+
+ private void initialize() {
+ updateURL();
+ addListeners();
+ }
+
+ public List getSummaryData() {
+ List summaryData = new ArrayList();
+ String driverID = this.properties
+ .getProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID);
+ DriverInstance driverInstance = DriverManager.getInstance()
+ .getDriverInstanceByID(driverID);
+
+ summaryData.add(new String[] {
+ CUI_NEWCW_DRIVER_NAME_SUMMARY_DATA_TEXT_, //$NON-NLS-1$
+ driverInstance.getName() });
+ summaryData.add(new String[] {
+ CUI_NEWCW_DATABASE_LOCATION_SUMMARY_DATA_TEXT_,
+ this.databaseLocationCombo.getText().trim() });
+
+ summaryData.add(new String[] { CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_,
+ this.usernameText.getText().trim() });
+ summaryData.add(new String[] { CUI_NEWCW_URL_SUMMARY_DATA_TEXT_,
+ this.urlText.getText().trim() });
+ summaryData.add(new String[] {
+ CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_,
+ createCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] {
+ CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_,
+ upgradeCheck.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData
+ .add(new String[] {
+ CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_,
+ savePasswordButton.getSelection() ? CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_
+ : CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ });
+ summaryData.add(new String[] {
+ CUI_NEWCW_OPTIONAL_CONNECTION_PROPERTIES_SUMMARY_DATA_TEXT_, //$NON-NLS-1$
+ optionalConnectionProperties.getSelection() });
+ return summaryData;
+ }
+
+ public void loadProperties() {
+ removeListeners();
+ DerbyEmbeddedJDBCURL url = new DerbyEmbeddedJDBCURL(this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID));
+ databaseLocationCombo.setText(url.getNode());
+ updateDatabaseName();
+ String username = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
+ if (username != null) {
+ usernameText.setText(username);
+ }
+ String password = this.properties
+ .getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
+ if (password != null) {
+ passwordText.setText(password);
+ }
+ String savePassword = this.properties
+ .getProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID);
+ if ((savePassword != null)
+ && Boolean.valueOf(savePassword) == Boolean.TRUE) {
+ savePasswordButton.setSelection(true);
+ }
+ if (!(url.getProperties().indexOf(CREATE_EQUALS_TRUE_TEXT) > -1)) {
+ createCheck.setSelection(false);
+ }
+ if ((url.getProperties().indexOf(UPGRADE_EQUALS_TRUE_TEXT) > -1)) {
+ upgradeCheck.setSelection(true);
+ }
+
+ String connectionProperties = this.properties
+ .getProperty(IJDBCConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
+ if (connectionProperties != null) {
+ this.optionalConnectionProperties
+ .setSelection(connectionProperties);
+ }
+ updateURL();
+ addListeners();
+ setConnectionInformation();
+ }
+
+ protected void updateDatabaseName() {
+ if (databaseLocationCombo.getText() != null
+ && !databaseLocationCombo.getText().equals("")) { //$NON-NLS-1$
+ databaseName = databaseLocationCombo.getText()
+ .substring(
+ databaseLocationCombo.getText().lastIndexOf(
+ File.separator) + 1);
+ }
+ }
+
+ public void setDialogPage(DialogPage parentPage) {
+ this.parentPage = parentPage;
+ }
+
+ public void setConnectionInformation() {
+ updateDatabaseName();
+ properties.setProperty(
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
+ databaseName);
+ properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID,
+ this.passwordText.getText());
+ properties.setProperty(
+ IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
+ .valueOf(savePasswordButton.getSelection()));
+ properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID,
+ this.usernameText.getText());
+ properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID,
+ this.urlText.getText().trim());
+ properties.setProperty(
+ IJDBCConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
+ this.optionalConnectionProperties.getSelection());
+ this.contributorInformation.setProperties(properties);
+ }
+
+ public void setDriverUIContributorInformation(
+ IDriverUIContributorInformation contributorInformation) {
+ this.contributorInformation = contributorInformation;
+ this.properties = contributorInformation.getProperties();
+ }
+
+ public void handleEvent(Event event) {
+ updateURL();
+ setConnectionInformation();
+ }
+
+ public void addListeners() {
+ databaseLocationCombo.addListener(SWT.Modify, this);
+ browseDatabaseLocation.addListener(SWT.Selection, this);
+ usernameText.addListener(SWT.Modify, this);
+ passwordText.addListener(SWT.Modify, this);
+ savePasswordButton.addListener(SWT.Selection, this);
+ createCheck.addListener(SWT.Selection, this);
+ upgradeCheck.addListener(SWT.Selection, this);
+ optionalConnectionProperties.addModifyListener(this);
+ }
+
+ protected void removeListeners() {
+ databaseLocationCombo.removeListener(SWT.Modify, this);
+ browseDatabaseLocation.removeListener(SWT.Selection, this);
+ usernameText.removeListener(SWT.Modify, this);
+ passwordText.removeListener(SWT.Modify, this);
+ savePasswordButton.removeListener(SWT.Selection, this);
+ createCheck.removeListener(SWT.Selection, this);
+ upgradeCheck.removeListener(SWT.Selection, this);
+ optionalConnectionProperties.removeModifyListener(this);
+ }
+
+ protected void updateURL() {
+ String url = "jdbc:derby:" + databaseLocationCombo.getText(); //$NON-NLS-1$
+ url += !createCheck.getSelection() ? "" : ";create=true"; //$NON-NLS-1$ //$NON-NLS-2$
+ url += !upgradeCheck.getSelection() ? "" : ";upgrade=true"; //$NON-NLS-1$ //$NON-NLS-2$
+ urlText.setText(url);
+ }
+
+ protected class DerbyEmbeddedJDBCURL {
+ protected String subprotocol = ""; //$NON-NLS-1$
+
+ protected String node = ""; //$NON-NLS-1$
+
+ protected String properties = ""; //$NON-NLS-1$
+
+ /**
+ * @param url
+ */
+ public DerbyEmbeddedJDBCURL(String url) {
+ parseURL(url);
+ }
+
+ /**
+ * @return Returns the node.
+ */
+ public String getNode() {
+ return node;
+ }
+
+ /**
+ * @return Returns the subprotocol.
+ */
+ public String getSubprotocol() {
+ return subprotocol;
+ }
+
+ protected void parseURL(String url) {
+ try {
+ String remainingURL = url.substring(url.indexOf(':') + 1);
+ this.subprotocol = remainingURL.substring(0, remainingURL
+ .indexOf(':'));
+ remainingURL = remainingURL
+ .substring(remainingURL.indexOf(':') + 1);
+ if (remainingURL.indexOf(';') > -1) {
+ this.node = remainingURL.substring(0, remainingURL
+ .indexOf(';'));
+ remainingURL = remainingURL.substring(remainingURL
+ .indexOf(';') + 1);
+ this.properties = remainingURL;
+ } else {
+ this.node = remainingURL;
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @return Returns the properties.
+ */
+ public String getProperties() {
+ return properties;
+ }
+ }
+
+ /**
+ * Browse for the database folder
+ */
+ private void browseForDBFolder() {
+ DirectoryDialog dialog = new DirectoryDialog(databaseLocationCombo
+ .getShell());
+ dialog.setText(CUI_NEWCW_FILE_BROWSER_TITLE_TEXT_); //$NON-NLS-1$
+ dialog.setMessage(CUI_NEWCW_FILE_BROWSER_MESSAGE_TEXT_); //$NON-NLS-1$
+
+ String dirName = databaseLocationCombo.getText();
+
+ File path = new File(dirName);
+ if (path.exists()) {
+ dialog.setFilterPath(new Path(dirName).toOSString());
+ }
+
+ String selectedDirectory = dialog.open();
+ if (selectedDirectory != null) {
+ databaseLocationCombo.setText(selectedDirectory);
+ }
+ }
+
+ public void modifyText(ModifyEvent e) {
+ handleEvent(new Event());
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyOtherDriverUIContributor.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyOtherDriverUIContributor.java
new file mode 100644
index 0000000..b783eff
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/DerbyOtherDriverUIContributor.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 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 accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers;
+
+import org.eclipse.datatools.connectivity.ui.wizards.OtherDriverUIContributor;
+
+public class DerbyOtherDriverUIContributor extends OtherDriverUIContributor {
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/Messages.java b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/Messages.java
new file mode 100644
index 0000000..5b29cb4
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/Messages.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.datatools.connectivity.apache.derby.internal.ui.connection.drivers.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/messages.properties b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/messages.properties
new file mode 100644
index 0000000..152d334
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/drivers/messages.properties
@@ -0,0 +1,47 @@
+DerbyEmbeddedDriverUIContributor.0=Database location:
+DerbyEmbeddedDriverUIContributor.1=Browse...
+DerbyEmbeddedDriverUIContributor.2=Create database (if required)
+DerbyEmbeddedDriverUIContributor.3=Upgrade database to current version
+DerbyEmbeddedDriverUIContributor.url.label = URL:
+DerbyEmbeddedDriverUIContributor.userName.label = User name:
+DerbyEmbeddedDriverUIContributor.password.label = Password:
+DerbyEmbeddedDriverUIContributor.persistpassword.label = Save password
+DerbyEmbeddedDriverUIContributor.optionalProps.label = Optional properties:
+DerbyEmbeddedDriverUIContributor.summary.driverName.label = Driver name
+DerbyEmbeddedDriverUIContributor.summary.connProps.label = Optional properties
+DerbyEmbeddedDriverUIContributor.summary.userName.label = User name
+DerbyEmbeddedDriverUIContributor.summary.password.label = Password
+DerbyEmbeddedDriverUIContributor.summary.url.label = URL
+DerbyEmbeddedDriverUIContributor.FileDialog.title.filebrowse = Browse for Database Folder
+DerbyEmbeddedDriverUIContributor.FileDialog.msg.filebrowse = Select the folder that corresponds to your Derby database.
+DerbyEmbeddedDriverUIContributor.general.tab = General
+DerbyEmbeddedDriverUIContributor.optional.tab = Optional
+DerbyEmbeddedDriverUIContributor.optionalproperties.label = Optional properties:
+CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_ = Save password
+CUI_NEWCW_TRUE_SUMMARY_DATA_TEXT_ = true
+CUI_NEWCW_FALSE_SUMMARY_DATA_TEXT_ = false
+CUI_NEWCW_DATABASE_LOCATION_SUMMARY_DATA_TEXT_ = Database location
+CUI_NEWCW_CREATE_DATABASE_SUMMARY_DATA_TEXT_ = Create database (if required)
+CUI_NEWCW_UPGRADE_DATABASE_SUMMARY_DATA_TEXT_ = Upgrade database to current version
+CUI_NEWCW_DATABASE_LBL_UI_ = Databa&se:
+CUI_NEWCW_HOST_LBL_UI_ = &Host:
+CUI_NEWCW_PORT_LBL_UI_ = Port nu&mber:
+CUI_NEWCW_CONNECTIONURL_LBL_UI_= UR&L:
+CUI_NEWCW_USERNAME_LBL_UI_ = User name:
+CUI_NEWCW_PASSWORD_LBL_UI_ = Password:
+CUI_NEWCW_SAVE_PASSWORD_LBL_UI_ = Sa&ve password
+CUI_NEWCW_DATABASE_SUMMARY_DATA_TEXT_ = Database
+CUI_NEWCW_HOST_SUMMARY_DATA_TEXT_ = Host
+CUI_NEWCW_PORT_SUMMARY_DATA_TEXT_ = Port number
+CUI_NEWCW_USERNAME_SUMMARY_DATA_TEXT_ = User name
+CUI_NEWCW_SAVE_PASSWORD_SUMMARY_DATA_TEXT_ = Save password
+CUI_NEWCW_URL_SUMMARY_DATA_TEXT_ = URL
+
+CUI_NEWCW_VALIDATE_DATABASE_REQ_UI_ = Enter a database name.
+CUI_NEWCW_VALIDATE_DBLOCATION_REQ_UI_ = Enter a database location.
+CUI_NEWCW_VALIDATE_HOST_REQ_UI_= Enter the host name for the database server.
+CUI_NEWCW_VALIDATE_PORT_REQ_UI_ = Enter the connection port number for the database server.
+CUI_NEWCW_VALIDATE_USERID_REQ_UI_ = Enter a user name.
+CUI_NEWCW_VALIDATE_PASSWORD_REQ_UI_ = Enter a password.
+
+
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/messages.properties b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/messages.properties
index 34b77d1..a97f709 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/messages.properties
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby.ui/src/org/eclipse/datatools/connectivity/apache/derby/internal/ui/connection/messages.properties
@@ -1,23 +1 @@
-NewDerbyEmbeddedConnectionProfileWizard.DerbyEmbeddedDatabaseWizardTitle=Derby Embedded Database
-
-DerbyEmbeddedDBProfileDetailsWizardPage.title = Specify a Driver and Connection Details
-DerbyEmbeddedDBProfileDetailsWizardPage.msg = Select a driver from the drop-down and provide login details for the connection.
-DerbyEmbeddedDBProfileDetailsWizardPage.0=Database location:
-DerbyEmbeddedDBProfileDetailsWizardPage.1=Browse...
-DerbyEmbeddedDBProfileDetailsWizardPage.2=Create database (if required)
-DerbyEmbeddedDBProfileDetailsWizardPage.3=Upgrade database to current version
-DerbyEmbeddedDBProfileDetailsWizardPage.driverCombo.label = Select a driver from the drop-down:
-DerbyEmbeddedDBProfileDetailsWizardPage.databaseName.label = Database:
-DerbyEmbeddedDBProfileDetailsWizardPage.url.label = URL:
-DerbyEmbeddedDBProfileDetailsWizardPage.PingButton=Test connection
-DerbyEmbeddedDBProfileDetailsWizardPage.userName.label = User name:
-DerbyEmbeddedDBProfileDetailsWizardPage.password.label = Password:
-DerbyEmbeddedDBProfileDetailsWizardPage.persistpassword.label = Save Password
-DerbyEmbeddedDBProfileDetailsWizardPage.optionalProps.label = Optional properties:
-DerbyEmbeddedDBProfileDetailsWizardPage.summary.driverName.label = Driver name
-DerbyEmbeddedDBProfileDetailsWizardPage.summary.connProps.label = Connection properties
-DerbyEmbeddedDBProfileDetailsWizardPage.summary.userName.label = User name
-DerbyEmbeddedDBProfileDetailsWizardPage.summary.password.label = Password
-DerbyEmbeddedDBProfileDetailsWizardPage.summary.url.label = URL
-DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.title.filebrowse = Browse for Database Folder
-DerbyEmbeddedDBProfileDetailsWizardPage.FileDialog.msg.filebrowse = Select the folder that corresponds to your Derby database.
\ No newline at end of file
+NewDerbyEmbeddedConnectionProfileWizard.DerbyEmbeddedDatabaseWizardTitle=New Derby Connection Profile
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.apache.derby/META-INF/MANIFEST.MF
index 978656d..4b56fbb 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.datatools.connectivity.apache.derby;singleton:=true
-Bundle-Version: 1.0.0.200710151
+Bundle-Version: 1.0.0.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.apache.internal.derby.DerbyPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -19,7 +19,6 @@
org.eclipse.datatools.connectivity.sqm.core;bundle-version="[0.9.1,1.5.0)",
com.ibm.icu;bundle-version="[3.4.0,4.0.0)",
org.eclipse.datatools.modelbase.derby;bundle-version="[0.9.0,1.5.0)",
- org.eclipse.datatools.connectivity.db.generic;bundle-version="[0.9.1,1.5.0)",
org.eclipse.datatools.connectivity;bundle-version="[0.9.1,1.5.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.properties b/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.properties
index 58fffd6..9634043 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.properties
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2001, 2004 IBM Corporation and others.
+# Copyright (c) 2001, 2004, 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 accompanies this distribution, and is available at
@@ -30,9 +30,12 @@
10_2_VERSION_CATEGORY_NAME = 10.2
DERBY_EMBEDDED_DRIVER_TEMPLATE_NAME=Derby Embedded JDBC Driver
+DERBY_OTHER_DRIVER_TEMPLATE_NAME = Other Driver
DERBY101_EMBEDDED_DRIVER_TEMPLATE_NAME=Derby Embedded JDBC Driver
DERBY_NETWORK_EMBEDDED_DRIVER_TEMPLATE_NAME=DB2 Universal Driver
DERBY101_NETWORK_EMBEDDED_DRIVER_TEMPLATE_NAME=DB2 Universal Driver
DERBY101_CLIENT_DRIVER_TEMPLATE_NAME = Derby Client JDBC Driver
+DERBY101_OTHER_DRIVER_TEMPLATE_NAME = Other Driver
DERBY102_EMBEDDED_DRIVER_TEMPLATE_NAME=Derby Embedded JDBC Driver
-DERBY102_CLIENT_DRIVER_TEMPLATE_NAME = Derby Client JDBC Driver
\ No newline at end of file
+DERBY102_CLIENT_DRIVER_TEMPLATE_NAME = Derby Client JDBC Driver
+DERBY102_OTHER_DRIVER_TEMPLATE_NAME = Other Driver
\ No newline at end of file
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.xml b/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.xml
index 0b80a62..b6364c7 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.xml
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/plugin.xml
@@ -72,7 +72,8 @@
icon="icons/jdbc_16.gif"
pingFactory="org.eclipse.datatools.connectivity.apache.internal.derby.connection.DerbyJDBCConnectionFactory"
id="org.eclipse.datatools.connectivity.db.derby.embedded.connectionProfile"
- name="%DERBY_CONNECTION_PROFILE_NAME"/>
+ name="%DERBY_CONNECTION_PROFILE_NAME"
+ propertiesPersistenceHook="org.eclipse.datatools.connectivity.apache.internal.derby.connection.DerbyPropertiesPersistenceHook"/>
<connectionFactory
class="org.eclipse.datatools.connectivity.apache.internal.derby.connection.DerbyJDBCConnectionFactory"
id="java.sql.Connection"
@@ -509,6 +510,186 @@
visible="true"/>
</properties>
</driverTemplate>
+
+ <driverTemplate
+ createDefault="false"
+ emptyJarListIsOK="false"
+ id="org.eclipse.datatools.connectivity.db.derby102.otherDriver"
+ jarList=""
+ name="%DERBY102_OTHER_DRIVER_TEMPLATE_NAME"
+ parentCategory="org.eclipse.datatools.connectivity.db.derby.10_2.driverCategory">
+ <properties>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.driverClass"
+ name="%DRIVER_CLASS_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.vendor"
+ name="%VENDOR_PROPERTY_NAME"
+ value="Derby"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.version"
+ name="%VERSION_PROPERTY_NAME"
+ value="10.2"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.databaseName"
+ name="%DATABASE_NAME_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.URL"
+ name="%CONNECTION_URL_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.username"
+ name="%USER_ID_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.password"
+ name="%PASSWORD_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ </properties>
+ </driverTemplate>
+
+ <driverTemplate
+ createDefault="false"
+ emptyJarListIsOK="false"
+ id="org.eclipse.datatools.connectivity.db.derby101.otherDriver"
+ jarList=""
+ name="%DERBY101_OTHER_DRIVER_TEMPLATE_NAME"
+ parentCategory="org.eclipse.datatools.connectivity.db.derby.10_1.driverCategory">
+ <properties>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.driverClass"
+ name="%DRIVER_CLASS_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.vendor"
+ name="%VENDOR_PROPERTY_NAME"
+ value="Derby"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.version"
+ name="%VERSION_PROPERTY_NAME"
+ value="10.1"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.databaseName"
+ name="%DATABASE_NAME_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.URL"
+ name="%CONNECTION_URL_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.username"
+ name="%USER_ID_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.password"
+ name="%PASSWORD_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ </properties>
+ </driverTemplate>
+
+ <driverTemplate
+ createDefault="false"
+ emptyJarListIsOK="false"
+ id="org.eclipse.datatools.connectivity.db.derby.otherDriver"
+ jarList=""
+ name="%DERBY_OTHER_DRIVER_TEMPLATE_NAME"
+ parentCategory="org.eclipse.datatools.connectivity.db.derby.10_0.driverCategory">
+ <properties>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.driverClass"
+ name="%DRIVER_CLASS_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.vendor"
+ name="%VENDOR_PROPERTY_NAME"
+ value="Derby"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.version"
+ name="%VERSION_PROPERTY_NAME"
+ value="10.0"
+ required="true"
+ visible="false"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.databaseName"
+ name="%DATABASE_NAME_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.URL"
+ name="%CONNECTION_URL_PROPERTY_NAME"
+ value=""
+ required="true"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.username"
+ name="%USER_ID_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ <property
+ generated="false"
+ id="org.eclipse.datatools.connectivity.db.password"
+ name="%PASSWORD_PROPERTY_NAME"
+ value=""
+ required="false"
+ visible="true"/>
+ </properties>
+ </driverTemplate>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyEmbeddedJDBCConnection.java b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyEmbeddedJDBCConnection.java
index 86815d5..8f8f89a 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyEmbeddedJDBCConnection.java
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyEmbeddedJDBCConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc.
+ * Copyright (c) 2006, 2007 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
@@ -7,6 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.apache.internal.derby.connection;
@@ -18,8 +19,8 @@
import java.util.Properties;
import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.db.generic.JDBCConnection;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection;
/**
* This class is used to represent Derby embedded connections. There are a
@@ -72,7 +73,7 @@
try {
/* The particulars of closing the connection. */
String driverClass = getDriverDefinition().getProperty(
- IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
+ IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
Driver driver = (Driver) connection.getClass()
.getClassLoader().loadClass(driverClass)
.newInstance();
@@ -151,7 +152,7 @@
private String getBaseDBURL() {
String baseURL;
String connectURL = getConnectionProfile().getBaseProperties()
- .getProperty(IDBDriverDefinitionConstants.URL_PROP_ID);
+ .getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
int propertyStart = connectURL.indexOf(';');
if (propertyStart < 0) {
baseURL = connectURL;
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyPropertiesPersistenceHook.java b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyPropertiesPersistenceHook.java
new file mode 100644
index 0000000..625b4eb
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/DerbyPropertiesPersistenceHook.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.connectivity.apache.internal.derby.connection;
+
+import org.eclipse.datatools.connectivity.drivers.jdbc.JDBCPasswordPropertyPersistenceHook;
+
+public class DerbyPropertiesPersistenceHook extends
+ JDBCPasswordPropertyPersistenceHook {
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/IDerbyConnectionProfileConstants.java b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/IDerbyConnectionProfileConstants.java
index 5f9af48..9564507 100644
--- a/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/IDerbyConnectionProfileConstants.java
+++ b/plugins/org.eclipse.datatools.connectivity.apache.derby/src/org/eclipse/datatools/connectivity/apache/internal/derby/connection/IDerbyConnectionProfileConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc.
+ * Copyright (c) 2006,2007 Sybase, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,14 +8,12 @@
*
* Contributors:
* rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
*******************************************************************************/
package org.eclipse.datatools.connectivity.apache.internal.derby.connection;
public interface IDerbyConnectionProfileConstants {
- public static final String DERBY_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.derby.driverCategory"; //$NON-NLS-1$
- public static final String DERBY_ENABLEMENT_DRIVER_PREFIX = "org.eclipse.datatools.connectivity.db.derby"; //$NON-NLS-1$
- public static final String DERBY_ENABLEMENT_DRIVER_SUFFIX = "genericDriverTemplate"; //$NON-NLS-1$
-
+ public static final String DERBY_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.derby.driverCategory"; //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.db.generic/META-INF/MANIFEST.MF
index 2684758..269f3e9 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.datatools.connectivity.db.generic; singleton:=true
-Bundle-Version: 1.0.0.200711011
+Bundle-Version: 1.0.0.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.db.generic.GenericDBPlugin
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/GenericDBPropertiesPersistenceHook.java b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/GenericDBPropertiesPersistenceHook.java
index 97fdacd..ef69b6a 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/GenericDBPropertiesPersistenceHook.java
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/GenericDBPropertiesPersistenceHook.java
@@ -1,12 +1,9 @@
package org.eclipse.datatools.connectivity.db.generic;
-import java.util.Properties;
-
-import org.eclipse.datatools.connectivity.IPropertiesPersistenceHook;
-import org.eclipse.datatools.connectivity.PropertiesPersistenceHook;
+import org.eclipse.datatools.connectivity.drivers.jdbc.JDBCPasswordPropertyPersistenceHook;
/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc.
+ * Copyright (c) 2006, 2007 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
@@ -14,38 +11,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
-public class GenericDBPropertiesPersistenceHook extends
- PropertiesPersistenceHook implements IPropertiesPersistenceHook {
-
- public GenericDBPropertiesPersistenceHook() {
- super();
- }
-
- public boolean arePropertiesComplete(Properties props) {
- return persistPassword(props)
- || props.getProperty(
- IDBConnectionProfileConstants.PASSWORD_PROP_ID, null) != null;
- }
-
- public Properties getPersitentProperties(Properties props) {
- props = super.getPersitentProperties(props);
- if (!persistPassword(props)) {
- props.remove(IDBConnectionProfileConstants.PASSWORD_PROP_ID);
- }
- return props;
- }
-
- protected boolean persistPassword(Properties props) {
- return Boolean.valueOf(
- props.getProperty(
- IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
- Boolean.FALSE.toString())).booleanValue();
- }
-
- public String getConnectionPropertiesPageID() {
- return IDBConnectionProfileConstants.CONNECTION_PROPERTY_PAGE_ID;
- }
-
-}
+public class GenericDBPropertiesPersistenceHook extends JDBCPasswordPropertyPersistenceHook {
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBConnectionProfileConstants.java b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBConnectionProfileConstants.java
index 04a52fb..7fb5acc 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBConnectionProfileConstants.java
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBConnectionProfileConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Sybase, Inc.
+ * Copyright (c) 2005, 2007 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
@@ -7,36 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.db.generic;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
+
/**
* Constant definitions for property keys used to identify DB connection profile
* properties.
*/
-public interface IDBConnectionProfileConstants extends
- IDBDriverDefinitionConstants {
-
- /**
- * The connection profile ID for the generic DB connection profile type.
- */
- public static final String CONNECTION_PROFILE_ID = "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; //$NON-NLS-1$
-
- /**
- * The property page ID for the generic DB connection properties.
- */
- public static final String CONNECTION_PROPERTY_PAGE_ID = "org.eclipse.datatools.connectivity.db.generic.profileProperties"; //$NON-NLS-1$
-
- /**
- * Property used to store JDBC connection properties (i.e. properties passed
- * as a <code>Properties</code> object to <code>java.sql.Driver.connect()</code>).
- */
- public static final String CONNECTION_PROPERTIES_PROP_ID = PROP_PREFIX + "connectionProperties"; //$NON-NLS-1$
-
- /**
- * Property used to store the persistence setting for the password. A value
- * of true indicates the password will be persisted within the workspace.
- */
- public static final String SAVE_PASSWORD_PROP_ID = PROP_PREFIX + "savePWD"; //$NON-NLS-1$
+public interface IDBConnectionProfileConstants extends IJDBCConnectionProfileConstants {
}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBDriverDefinitionConstants.java b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBDriverDefinitionConstants.java
index deac287..f33ee72 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBDriverDefinitionConstants.java
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/IDBDriverDefinitionConstants.java
@@ -10,65 +10,11 @@
*******************************************************************************/
package org.eclipse.datatools.connectivity.db.generic;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+
/**
* Constant definitions for property keys used to identify DB driver definition
* properties.
*/
-public interface IDBDriverDefinitionConstants {
-
- /**
- * Base category ID for DB driver definitions.
- */
- public static final String DATABASE_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.driverCategory"; //$NON-NLS-1$
-
- /**
- * Property prefix used for property keys
- */
- public static final String PROP_PREFIX = "org.eclipse.datatools.connectivity.db."; //$NON-NLS-1$
-
- /**
- * Property used to store the DB vendor name. This property is used in
- * resolving the dbdefinition referenced by the driver.
- */
- public static final String DATABASE_VENDOR_PROP_ID = PROP_PREFIX + "vendor"; //$NON-NLS-1$
-
- /**
- * Property used to store the DB version. This property is used in
- * resolving the dbdefinition referenced by the driver.
- */
- public static final String DATABASE_VERSION_PROP_ID = PROP_PREFIX + "version"; //$NON-NLS-1$
-
- /**
- * Property used to store the driver class name. This property is used in
- * creating JDBC connections.
- */
- public static final String DRIVER_CLASS_PROP_ID = PROP_PREFIX + "driverClass"; //$NON-NLS-1$
-
- /**
- * Property used to store the default DB name value. This property is used
- * by the generic DB connection profile wizard during initialization. This
- * property is also used by the DB connection profile.
- */
- public static final String DATABASE_NAME_PROP_ID = PROP_PREFIX + "databaseName"; //$NON-NLS-1$
-
- /**
- * Property used to store the default connection URL. This property is used
- * the generic DB connection profile wizard during initialization. This
- * property is also used by the DB connection profile.
- */
- public static final String URL_PROP_ID = PROP_PREFIX + "URL"; //$NON-NLS-1$
-
- /**
- * Property used to store the default user name. This property is used
- * the generic DB connection profile wizard during initialization. This
- * property is also used by the DB connection profile.
- */
- public static final String USERNAME_PROP_ID = PROP_PREFIX + "username"; //$NON-NLS-1$
-
- /**
- * Property used to store the default password. This property is used
- * the generic DB connection profile wizard during initialization. This
- * property is also used by the DB connection profile.
- */
- public static final String PASSWORD_PROP_ID = PROP_PREFIX + "password"; //$NON-NLS-1$
+public interface IDBDriverDefinitionConstants extends IJDBCDriverDefinitionConstants{
}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnection.java b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnection.java
index d207395..da9c697 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnection.java
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Sybase, Inc.
+ * Copyright (c) 2005, 2007 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
@@ -7,19 +7,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.db.generic;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.eclipse.datatools.connectivity.DriverConnectionBase;
import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.Version;
/**
* NON-API
@@ -33,147 +25,8 @@
*
* Version information is provided by using <code>java.sql.DatabaseMetaData</code>.
*/
-public class JDBCConnection extends DriverConnectionBase {
-
- public static final String TECHNOLOGY_ROOT_KEY = "jdbc"; //$NON-NLS-1$
- public static final String TECHNOLOGY_NAME = GenericDBPlugin.getDefault()
- .getResourceString("JDBCConnection.technologyName"); //$NON-NLS-1$
-
- private Version mTechVersion = Version.NULL_VERSION;
- private Version mServerVersion = Version.NULL_VERSION;
- private String mServerName;
-
+public class JDBCConnection extends org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection {
public JDBCConnection(IConnectionProfile profile, Class factoryClass) {
super(profile, factoryClass);
}
-
- protected Object createConnection(ClassLoader cl) throws Throwable {
- Properties props = getConnectionProfile().getBaseProperties();
- Properties connectionProps = new Properties();
-
- String driverClass = getDriverDefinition().getProperty(
- IDBConnectionProfileConstants.DRIVER_CLASS_PROP_ID);
- String connectURL = props
- .getProperty(IDBConnectionProfileConstants.URL_PROP_ID);
- String uid = props
- .getProperty(IDBConnectionProfileConstants.USERNAME_PROP_ID);
- String pwd = props
- .getProperty(IDBConnectionProfileConstants.PASSWORD_PROP_ID);
- String nameValuePairs = props
- .getProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
- String propDelim = ",";//$NON-NLS-1$
-
- if (uid != null) {
- connectionProps.setProperty("user", uid); //$NON-NLS-1$
- }
- if (pwd != null) {
- connectionProps.setProperty("password", pwd); //$NON-NLS-1$
- }
-
- if (nameValuePairs != null && nameValuePairs.length() > 0) {
- String[] pairs = parseString(nameValuePairs, ","); //$NON-NLS-1$
- String addPairs = ""; //$NON-NLS-1$
- for (int i = 0; i < pairs.length; i++) {
- String[] namevalue = parseString(pairs[i], "="); //$NON-NLS-1$
- connectionProps.setProperty(namevalue[0], namevalue[1]);
- if (i == 0 || i < pairs.length - 1) {
- addPairs = addPairs + propDelim;
- }
- addPairs = addPairs + pairs[i];
- }
- }
-
- Driver jdbcDriver = (Driver) cl.loadClass(driverClass).newInstance();
- return jdbcDriver.connect(connectURL, connectionProps);
- }
-
- public void close() {
- Connection connection = (Connection) getRawConnection();
- if (connection != null) {
- try {
- connection.close();
- }
- catch (SQLException e) {
- // RJC Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public String getProviderName() {
- return mServerName;
- }
-
- public Version getProviderVersion() {
- return mServerVersion;
- }
-
- protected String getTechnologyRootKey() {
- return TECHNOLOGY_ROOT_KEY;
- }
-
- public String getTechnologyName() {
- return TECHNOLOGY_NAME;
- }
-
- public Version getTechnologyVersion() {
- return mTechVersion;
- }
-
- protected void initVersions() {
- try {
- DatabaseMetaData dbmd = ((Connection) getRawConnection())
- .getMetaData();
- try {
- mServerName = dbmd.getDatabaseProductName();
- }
- catch (Throwable e) {
- }
- try {
- String versionString = dbmd.getDatabaseProductVersion();
- if (versionString.indexOf('/') > 0) {
- // Special handling for ASE
- String versionComps[] = versionString.split("/", 4); //$NON-NLS-1$
- if (versionComps.length > 2) {
- versionString = versionComps[1];
- if (versionComps.length > 3) {
- versionString += '.' + (versionComps[2]
- .startsWith("EBF") ? versionComps[2] //$NON-NLS-1$
- .substring(3).trim() : versionComps[2]);
- }
- if (versionComps[0].length() > 0
- && !versionComps[0].equals(mServerName)) {
- // Special case for ASIQ
- mServerName = versionComps[0];
- }
- }
- }
- mServerVersion = Version.valueOf(versionString);
- }
- catch (Throwable e) {
- }
- try {
- mTechVersion = new Version(dbmd.getJDBCMajorVersion(), dbmd
- .getJDBCMinorVersion(), 0, new String());
- }
- catch (Throwable e) {
- }
- }
- catch (SQLException e) {
- }
- }
-
- /**
- * @param str_list
- * @param token
- * @return
- */
- protected String[] parseString(String str_list, String token) {
- StringTokenizer tk = new StringTokenizer(str_list, token);
- String[] pieces = new String[tk.countTokens()];
- int index = 0;
- while (tk.hasMoreTokens())
- pieces[index++] = tk.nextToken();
- return pieces;
- }
}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnectionFactory.java b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnectionFactory.java
index 0ac8c0f..80c8051 100644
--- a/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnectionFactory.java
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic/src/org/eclipse/datatools/connectivity/db/generic/JDBCConnectionFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Sybase, Inc.
+ * Copyright (c) 2005, 2007 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
@@ -7,12 +7,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
******************************************************************************/
package org.eclipse.datatools.connectivity.db.generic;
-import org.eclipse.datatools.connectivity.IConnection;
-import org.eclipse.datatools.connectivity.IConnectionFactory;
-import org.eclipse.datatools.connectivity.IConnectionProfile;
/**
* <code>org.eclipse.datatools.connectivity.IConnectionFactory</code> for
@@ -33,35 +31,6 @@
*
* Created on Oct 17, 2005
*/
-public class JDBCConnectionFactory implements IConnectionFactory {
-
- /**
- *
- */
- public JDBCConnectionFactory() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.datatools.connectivity.IConnectionFactory#createConnection(org.eclipse.datatools.connectivity.IConnectionProfile)
- */
- public IConnection createConnection(IConnectionProfile profile) {
- JDBCConnection connection = new JDBCConnection(profile, getClass());
- connection.open();
- return connection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.datatools.connectivity.IConnectionFactory#createConnection(org.eclipse.datatools.connectivity.IConnectionProfile,
- * java.lang.String, java.lang.String)
- */
- public IConnection createConnection(IConnectionProfile profile, String uid,
- String pwd) {
- return createConnection(profile);
- }
+public class JDBCConnectionFactory extends org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnectionFactory {
}
diff --git a/plugins/org.eclipse.datatools.connectivity.sqm.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.sqm.core/META-INF/MANIFEST.MF
index 9a1fc66..550b964 100644
--- a/plugins/org.eclipse.datatools.connectivity.sqm.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.sqm.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.datatools.connectivity.sqm.core; singleton:=true
-Bundle-Version: 1.0.1.200712041
+Bundle-Version: 1.0.1.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.sqm.internal.core.RDBCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -29,7 +29,6 @@
org.eclipse.datatools.modelbase.sql;bundle-version="[0.9.0,1.5.0)",
org.eclipse.datatools.modelbase.dbdefinition;bundle-version="[0.9.0,1.5.0)",
org.eclipse.datatools.connectivity;bundle-version="[0.9.1,1.5.0)",
- com.ibm.icu;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.datatools.connectivity.db.generic;bundle-version="[0.9.1,1.5.0)"
+ com.ibm.icu;bundle-version="[3.4.0,4.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/plugins/org.eclipse.datatools.connectivity.sqm.core/src/org/eclipse/datatools/connectivity/sqm/internal/core/connection/ConnectionInfoImpl.java b/plugins/org.eclipse.datatools.connectivity.sqm.core/src/org/eclipse/datatools/connectivity/sqm/internal/core/connection/ConnectionInfoImpl.java
index d48536a..3790573 100644
--- a/plugins/org.eclipse.datatools.connectivity.sqm.core/src/org/eclipse/datatools/connectivity/sqm/internal/core/connection/ConnectionInfoImpl.java
+++ b/plugins/org.eclipse.datatools.connectivity.sqm.core/src/org/eclipse/datatools/connectivity/sqm/internal/core/connection/ConnectionInfoImpl.java
@@ -49,7 +49,7 @@
import org.eclipse.datatools.connectivity.Version;
import org.eclipse.datatools.connectivity.VersionProviderConnection;
import org.eclipse.datatools.connectivity.IPropertySetChangeEvent.IChangedProperty;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.sqm.core.definition.DatabaseDefinition;
import org.eclipse.datatools.connectivity.sqm.core.definition.DatabaseDefinitionRegistry;
import org.eclipse.datatools.connectivity.sqm.internal.core.RDBCorePlugin;
@@ -613,11 +613,11 @@
String databaseName = null;
try{
vendor = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
+ IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
version = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
+ IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
databaseName = profile.getBaseProperties().getProperty(
- IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
if (databaseName == null || databaseName.trim().length() == 0) {
databaseName = profile.getName();
}
@@ -663,8 +663,8 @@
if(detectedDBDefinition != null) {
this.setDatabaseDefinition(detectedDBDefinition);
Properties props = profile.getBaseProperties();
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, detectedDBDefinition.getProduct());
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, detectedDBDefinition.getVersion());
+ props.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, detectedDBDefinition.getProduct());
+ props.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, detectedDBDefinition.getVersion());
profile.setBaseProperties(props);
}
this.setSharedConnection(connection);
diff --git a/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF
index 246baa8..b9552f6 100644
--- a/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.Name
Bundle-SymbolicName: org.eclipse.datatools.connectivity.ui; singleton:=true
-Bundle-Version: 1.1.0.200712121
+Bundle-Version: 1.1.0.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin
Bundle-Vendor: %Plugin.ProviderName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/ui/wizards/OtherDriverUIContributor.java b/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/ui/wizards/OtherDriverUIContributor.java
index e883826..e720328 100644
--- a/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/ui/wizards/OtherDriverUIContributor.java
+++ b/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/ui/wizards/OtherDriverUIContributor.java
@@ -12,6 +12,8 @@
import java.util.List;
import java.util.Properties;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin;
import org.eclipse.datatools.connectivity.internal.ui.DelimitedStringList;
import org.eclipse.jface.dialogs.DialogPage;
@@ -157,19 +159,19 @@
public void setConnectionInformation() {
properties.setProperty(
- IDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
+ IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
this.databaseNameText.getText().trim());
- properties.setProperty(IDriverDefinitionConstants.PASSWORD_PROP_ID,
+ properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID,
this.passwordText.getText());
- properties.setProperty(IDriverDefinitionConstants.USERNAME_PROP_ID,
+ properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID,
this.usernameText.getText());
properties.setProperty(
- IConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
+ IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String
.valueOf(savePasswordButton.getSelection()));
- properties.setProperty(IDriverDefinitionConstants.URL_PROP_ID,
+ properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID,
this.urlText.getText().trim());
properties.setProperty(
- IConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
+ IJDBCConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
this.optionalConnectionProperties.getSelection());
this.contributorInformation.setProperties(properties);
}
@@ -250,38 +252,38 @@
removeListeners();
String databaseName = this.properties
- .getProperty(IDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
+ .getProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
if (databaseName != null) {
databaseNameText.setText(databaseName);
}
String url = this.properties
- .getProperty(IDriverDefinitionConstants.URL_PROP_ID);
+ .getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
if (url != null) {
urlText.setText(url);
}
String username = this.properties
- .getProperty(IDriverDefinitionConstants.USERNAME_PROP_ID);
+ .getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
if (username != null) {
usernameText.setText(username);
}
String password = this.properties
- .getProperty(IDriverDefinitionConstants.PASSWORD_PROP_ID);
+ .getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
if (password != null) {
passwordText.setText(password);
}
String savePassword = this.properties
- .getProperty(IConnectionProfileConstants.SAVE_PASSWORD_PROP_ID);
+ .getProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID);
if ((savePassword != null)
&& Boolean.valueOf(savePassword) == Boolean.TRUE) {
savePasswordButton.setSelection(true);
}
String connectionProperties = this.properties
- .getProperty(IConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
+ .getProperty(IJDBCConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
if (connectionProperties != null) {
this.optionalConnectionProperties
.setSelection(connectionProperties);
diff --git a/plugins/org.eclipse.datatools.connectivity/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity/META-INF/MANIFEST.MF
index c1da806..8be0fa2 100644
--- a/plugins/org.eclipse.datatools.connectivity/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.Name
Bundle-SymbolicName: org.eclipse.datatools.connectivity; singleton:=true
-Bundle-Version: 1.0.1.200711131
+Bundle-Version: 1.0.1.200712171
Bundle-Activator: org.eclipse.datatools.connectivity.internal.ConnectivityPlugin
Bundle-Vendor: %Plugin.ProviderName
Bundle-Localization: plugin
@@ -12,6 +12,7 @@
Eclipse-LazyStart: true
Export-Package: org.eclipse.datatools.connectivity,
org.eclipse.datatools.connectivity.drivers,
+ org.eclipse.datatools.connectivity.drivers.jdbc,
org.eclipse.datatools.connectivity.drivers.models,
org.eclipse.datatools.connectivity.internal,
org.eclipse.datatools.connectivity.internal.repository,
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCConnectionProfileConstants.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCConnectionProfileConstants.java
new file mode 100644
index 0000000..0a83db9
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCConnectionProfileConstants.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.drivers.jdbc;
+
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
+
+/**
+ * Constant definitions for property keys used to identify DB connection profile
+ * properties.
+ */
+public interface IJDBCConnectionProfileConstants extends IJDBCDriverDefinitionConstants {
+ /**
+ * The connection profile ID for the generic DB connection profile type.
+ */
+ public static final String CONNECTION_PROFILE_ID = "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; //$NON-NLS-1$
+
+ /**
+ * The property page ID for the generic DB connection properties.
+ */
+ public static final String CONNECTION_PROPERTY_PAGE_ID = "org.eclipse.datatools.connectivity.db.generic.profileProperties"; //$NON-NLS-1$
+
+ /**
+ * Property used to store JDBC connection properties (i.e. properties passed
+ * as a <code>Properties</code> object to <code>java.sql.Driver.connect()</code>).
+ */
+ public static final String CONNECTION_PROPERTIES_PROP_ID = PROP_PREFIX + "connectionProperties"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the persistence setting for the password. A value
+ * of true indicates the password will be persisted within the workspace.
+ */
+ public static final String SAVE_PASSWORD_PROP_ID = PROP_PREFIX + "savePWD"; //$NON-NLS-1$
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCDriverDefinitionConstants.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCDriverDefinitionConstants.java
new file mode 100644
index 0000000..9ef66d3
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/IJDBCDriverDefinitionConstants.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 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 accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.datatools.connectivity.drivers.jdbc;
+
+/**
+ * Constant definitions for property keys used to identify DB driver definition
+ * properties.
+ */
+public interface IJDBCDriverDefinitionConstants {
+ /**
+ * Base category ID for DB driver definitions.
+ */
+ public static final String DATABASE_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.driverCategory"; //$NON-NLS-1$
+
+ /**
+ * Property prefix used for property keys
+ */
+ public static final String PROP_PREFIX = "org.eclipse.datatools.connectivity.db."; //$NON-NLS-1$
+
+ /**
+ * Property used to store the DB vendor name. This property is used in
+ * resolving the dbdefinition referenced by the driver.
+ */
+ public static final String DATABASE_VENDOR_PROP_ID = PROP_PREFIX + "vendor"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the DB version. This property is used in
+ * resolving the dbdefinition referenced by the driver.
+ */
+ public static final String DATABASE_VERSION_PROP_ID = PROP_PREFIX + "version"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the driver class name. This property is used in
+ * creating JDBC connections.
+ */
+ public static final String DRIVER_CLASS_PROP_ID = PROP_PREFIX + "driverClass"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the default DB name value. This property is used
+ * by the generic DB connection profile wizard during initialization. This
+ * property is also used by the DB connection profile.
+ */
+ public static final String DATABASE_NAME_PROP_ID = PROP_PREFIX + "databaseName"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the default connection URL. This property is used
+ * the generic DB connection profile wizard during initialization. This
+ * property is also used by the DB connection profile.
+ */
+ public static final String URL_PROP_ID = PROP_PREFIX + "URL"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the default user name. This property is used
+ * the generic DB connection profile wizard during initialization. This
+ * property is also used by the DB connection profile.
+ */
+ public static final String USERNAME_PROP_ID = PROP_PREFIX + "username"; //$NON-NLS-1$
+
+ /**
+ * Property used to store the default password. This property is used
+ * the generic DB connection profile wizard during initialization. This
+ * property is also used by the DB connection profile.
+ */
+ public static final String PASSWORD_PROP_ID = PROP_PREFIX + "password"; //$NON-NLS-1$
+}
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java
new file mode 100644
index 0000000..b4f4e44
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.drivers.jdbc;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.eclipse.datatools.connectivity.DriverConnectionBase;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.Version;
+import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin;
+
+/**
+ * NON-API
+ *
+ * IConnection implementation for <code>java.sql.Connection</code> objects.
+ * This object is responsible for openening and closing JDBC connections.
+ *
+ * The property keys specified in
+ * <code>org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants</code>
+ * are used to create the connection.
+ *
+ * Version information is provided by using <code>java.sql.DatabaseMetaData</code>.
+ */
+public class JDBCConnection extends DriverConnectionBase {
+
+ public static final String TECHNOLOGY_ROOT_KEY = "jdbc"; //$NON-NLS-1$
+ public static final String TECHNOLOGY_NAME = ConnectivityPlugin.getDefault()
+ .getResourceString("JDBCConnection.technologyName"); //$NON-NLS-1$
+
+ private Version mTechVersion = Version.NULL_VERSION;
+ private Version mServerVersion = Version.NULL_VERSION;
+ private String mServerName;
+
+ public JDBCConnection(IConnectionProfile profile, Class factoryClass) {
+ super(profile, factoryClass);
+ }
+
+ protected Object createConnection(ClassLoader cl) throws Throwable {
+ Properties props = getConnectionProfile().getBaseProperties();
+ Properties connectionProps = new Properties();
+
+ String driverClass = getDriverDefinition().getProperty(
+ IJDBCConnectionProfileConstants.DRIVER_CLASS_PROP_ID);
+ String connectURL = props
+ .getProperty(IJDBCConnectionProfileConstants.URL_PROP_ID);
+ String uid = props
+ .getProperty(IJDBCConnectionProfileConstants.USERNAME_PROP_ID);
+ String pwd = props
+ .getProperty(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID);
+ String nameValuePairs = props
+ .getProperty(IJDBCConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID);
+ String propDelim = ",";//$NON-NLS-1$
+
+ if (uid != null) {
+ connectionProps.setProperty("user", uid); //$NON-NLS-1$
+ }
+ if (pwd != null) {
+ connectionProps.setProperty("password", pwd); //$NON-NLS-1$
+ }
+
+ if (nameValuePairs != null && nameValuePairs.length() > 0) {
+ String[] pairs = parseString(nameValuePairs, ","); //$NON-NLS-1$
+ String addPairs = ""; //$NON-NLS-1$
+ for (int i = 0; i < pairs.length; i++) {
+ String[] namevalue = parseString(pairs[i], "="); //$NON-NLS-1$
+ connectionProps.setProperty(namevalue[0], namevalue[1]);
+ if (i == 0 || i < pairs.length - 1) {
+ addPairs = addPairs + propDelim;
+ }
+ addPairs = addPairs + pairs[i];
+ }
+ }
+
+ Driver jdbcDriver = (Driver) cl.loadClass(driverClass).newInstance();
+ return jdbcDriver.connect(connectURL, connectionProps);
+ }
+
+ public void close() {
+ Connection connection = (Connection) getRawConnection();
+ if (connection != null) {
+ try {
+ connection.close();
+ }
+ catch (SQLException e) {
+ // RJC Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String getProviderName() {
+ return mServerName;
+ }
+
+ public Version getProviderVersion() {
+ return mServerVersion;
+ }
+
+ protected String getTechnologyRootKey() {
+ return TECHNOLOGY_ROOT_KEY;
+ }
+
+ public String getTechnologyName() {
+ return TECHNOLOGY_NAME;
+ }
+
+ public Version getTechnologyVersion() {
+ return mTechVersion;
+ }
+
+ protected void initVersions() {
+ try {
+ DatabaseMetaData dbmd = ((Connection) getRawConnection())
+ .getMetaData();
+ try {
+ mServerName = dbmd.getDatabaseProductName();
+ }
+ catch (Throwable e) {
+ }
+ try {
+ String versionString = dbmd.getDatabaseProductVersion();
+ if (versionString.indexOf('/') > 0) {
+ // Special handling for ASE
+ String versionComps[] = versionString.split("/", 4); //$NON-NLS-1$
+ if (versionComps.length > 2) {
+ versionString = versionComps[1];
+ if (versionComps.length > 3) {
+ versionString += '.' + (versionComps[2]
+ .startsWith("EBF") ? versionComps[2] //$NON-NLS-1$
+ .substring(3).trim() : versionComps[2]);
+ }
+ if (versionComps[0].length() > 0
+ && !versionComps[0].equals(mServerName)) {
+ // Special case for ASIQ
+ mServerName = versionComps[0];
+ }
+ }
+ }
+ mServerVersion = Version.valueOf(versionString);
+ }
+ catch (Throwable e) {
+ }
+ try {
+ mTechVersion = new Version(dbmd.getJDBCMajorVersion(), dbmd
+ .getJDBCMinorVersion(), 0, new String());
+ }
+ catch (Throwable e) {
+ }
+ }
+ catch (SQLException e) {
+ }
+ }
+
+ /**
+ * @param str_list
+ * @param token
+ * @return
+ */
+ protected String[] parseString(String str_list, String token) {
+ StringTokenizer tk = new StringTokenizer(str_list, token);
+ String[] pieces = new String[tk.countTokens()];
+ int index = 0;
+ while (tk.hasMoreTokens())
+ pieces[index++] = tk.nextToken();
+ return pieces;
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnectionFactory.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnectionFactory.java
new file mode 100644
index 0000000..386fad4
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnectionFactory.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.drivers.jdbc;
+
+import org.eclipse.datatools.connectivity.IConnection;
+import org.eclipse.datatools.connectivity.IConnectionFactory;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+
+/**
+ * <code>org.eclipse.datatools.connectivity.IConnectionFactory</code> for
+ * creating <code>java.sql.Connection</code> connections.
+ *
+ * To use this class in a custom DB connection profile, you must make sure your
+ * profile contains the following properties from
+ * <code>org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants</code>:
+ * DRIVER_CLASS_PROP_ID, URL_PROP_ID, as well as
+ * <code>org.eclipse.datatools.connectivity.ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID</code>.
+ *
+ * The following properties from
+ * <code>org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants</code>
+ * are optional: USERNAME_PROP_ID, PASSWORD_PROP_ID,
+ * CONNECTION_PROPERTIES_PROP_ID
+ *
+ * @author rcernich
+ *
+ * Created on Oct 17, 2005
+ */
+public class JDBCConnectionFactory implements IConnectionFactory {
+
+ /**
+ *
+ */
+ public JDBCConnectionFactory() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.IConnectionFactory#createConnection(org.eclipse.datatools.connectivity.IConnectionProfile)
+ */
+ public IConnection createConnection(IConnectionProfile profile) {
+ JDBCConnection connection = new JDBCConnection(profile, getClass());
+ connection.open();
+ return connection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.IConnectionFactory#createConnection(org.eclipse.datatools.connectivity.IConnectionProfile,
+ * java.lang.String, java.lang.String)
+ */
+ public IConnection createConnection(IConnectionProfile profile, String uid,
+ String pwd) {
+ return createConnection(profile);
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCPasswordPropertyPersistenceHook.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCPasswordPropertyPersistenceHook.java
new file mode 100644
index 0000000..da79717
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCPasswordPropertyPersistenceHook.java
@@ -0,0 +1,52 @@
+package org.eclipse.datatools.connectivity.drivers.jdbc;
+
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.IPropertiesPersistenceHook;
+import org.eclipse.datatools.connectivity.PropertiesPersistenceHook;
+
+/*******************************************************************************
+ * Copyright (c) 2006,2007 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: rcernich - initial API and implementation
+ * IBM Corporation - migrated to new wizard framework
+ ******************************************************************************/
+
+public class JDBCPasswordPropertyPersistenceHook extends
+ PropertiesPersistenceHook implements IPropertiesPersistenceHook {
+
+ public JDBCPasswordPropertyPersistenceHook() {
+ super();
+ }
+
+ public boolean arePropertiesComplete(Properties props) {
+ return persistPassword(props)
+ || props.getProperty(
+ IJDBCConnectionProfileConstants.PASSWORD_PROP_ID, null) != null;
+ }
+
+ public Properties getPersitentProperties(Properties props) {
+ props = super.getPersitentProperties(props);
+ if (!persistPassword(props)) {
+ props.remove(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID);
+ }
+ return props;
+ }
+
+ protected boolean persistPassword(Properties props) {
+ return Boolean.valueOf(
+ props.getProperty(
+ IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
+ Boolean.FALSE.toString())).booleanValue();
+ }
+
+ public String getConnectionPropertiesPageID() {
+ return IJDBCConnectionProfileConstants.CONNECTION_PROPERTY_PAGE_ID;
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/internal/resources.properties b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/internal/resources.properties
index f843000..aee07d5 100644
--- a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/internal/resources.properties
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/internal/resources.properties
@@ -1,5 +1,5 @@
################################################################################
-## Copyright (c) 2005 Sybase, Inc.
+## Copyright (c) 2005, 2007 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
@@ -7,6 +7,7 @@
##
## Contributors:
## Sybase, Inc. - initial API and implementation
+## IBM Corporation - migrated to new wizard framework
################################################################################
plugin.internal_error=Internal Error - org.eclipse.datatools.connectivity
ConnectionProfileConstants.unknownVersion=unknown
@@ -65,4 +66,9 @@
ManagedConnection_save_not_connected_error = Must be connected to server to save offline data.
ManagedConnection_offline_not_supported_error = {0} does not support working offline.
-drivers.error.finding.property.no.template = Problem attempting to retrieve {0} from driver template.
\ No newline at end of file
+drivers.error.finding.property.no.template = Problem attempting to retrieve {0} from driver template.
+
+JDBCConnection.technologyName = JDBC
+
+
+