ui specific details for db.generic
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.classpath b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.project b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.project
new file mode 100644
index 0000000..40516d1
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.datatools.connectivity.db.generic.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..0fac399
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Generic DB UI Plug-in
+Bundle-SymbolicName: org.eclipse.datatools.connectivity.db.generic.ui; singleton:=true
+Bundle-Version: 0.0.7
+Bundle-Activator: org.eclipse.datatools.connectivity.db.generic.ui.GenericDBUIPlugin
+Bundle-Vendor: Eclipse.org
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.datatools.connectivity,
+ org.eclipse.datatools.connectivity.ui,
+ org.eclipse.datatools.connectivity.db.generic
+Eclipse-AutoStart: true
+Bundle-ClassPath: genericdbui.jar
+Export-Package: org.eclipse.datatools.connectivity.db.generic.ui
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/about.html b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/about.html
new file mode 100644
index 0000000..6d7883a
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/about.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
+<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
+<HTML><HEAD><TITLE>About</TITLE>
+<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+<META content="MSHTML 6.00.2800.1515" name=GENERATOR></HEAD>
+<BODY lang=EN-US>
+<H2>About This Content</H2>
+<P>February 24, 2005</P>
+<H3>License</H3>
+<P>The Eclipse Foundation makes available all content in this plug-in
+("Content"). Unless otherwise indicated below, the Content is provided to you
+under the terms and conditions of the Eclipse Public License Version 1.0
+("EPL"). A copy of the EPL is available at <A
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
+For purposes of the EPL, "Program" will mean the Content.</P>
+<P>If you did not receive this Content directly from the Eclipse Foundation, the
+Content is being redistributed by another party ("Redistributor") and different
+terms and conditions may apply to your use of any object code in the Content.
+Check the Redistributor's license that was provided with the Content. If no such
+license exists, contact the Redistributor. Unless otherwise indicated below, the
+terms and conditions of the EPL still apply to any source code in the
+Content.</P></BODY></HTML>
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/build.properties b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/build.properties
new file mode 100644
index 0000000..77e56ea
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/build.properties
@@ -0,0 +1,15 @@
+bin.includes = META-INF/,\
+ plugin.xml,\
+ genericdbui.jar,\
+ about.html,\
+ icons/
+jars.compile.order = genericdbui.jar
+source.genericdbui.jar = src/
+output.genericdbui.jar = bin/
+src.dir = src/
+jars.extra.classpath =
+plugin.version = 0.7.0
+javadoc.dir = doc/api/
+download.dir = ./download/
+javac.source = 1.4
+javac.target = 1.4
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/icons/new_db_element.gif b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/icons/new_db_element.gif
new file mode 100644
index 0000000..1d459ce
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/icons/new_db_element.gif
Binary files differ
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/plugin.xml b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/plugin.xml
new file mode 100644
index 0000000..5b042cb
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/plugin.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.datatools.connectivity.connectionProfile">
+ <newWizard
+ class="org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard"
+ icon="icons/new_db_element.gif"
+ id="org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard"
+ name="SQL Model-JDBC Connection"
+ profile="org.eclipse.datatools.connectivity.db.generic.connectionProfile"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.datatools.connectivity.db.generic.ui.GenericDBProfilePropertyPage"
+ id="org.eclipse.datatools.connectivity.db.derby.profileProperties"
+ name="JDBC Connection Properties"
+ objectClass="org.eclipse.datatools.connectivity.IConnectionProfile">
+ <filter
+ name="org.eclipse.datatools.profile.property.id"
+ value="org.eclipse.datatools.connectivity.db.generic.connectionProfile"/>
+ </page>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfileDetailsWizardPage.java b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfileDetailsWizardPage.java
new file mode 100644
index 0000000..8822793
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfileDetailsWizardPage.java
@@ -0,0 +1,409 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2005 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: brianf - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.db.generic.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.eclipse.datatools.connectivity.db.generic.GenericDBPlugin;
+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.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class gathers the properties for a JDBC connection profile.
+ *
+ * @author brianf
+ */
+public class GenericDBProfileDetailsWizardPage extends ConnectionProfileDetailsPage {
+
+ // ui pieces
+ private Text mDatabaseNameText;
+
+ private Text mURLText;
+
+ private Text mDBUIDText;
+
+ private Text mDBPWDText;
+
+ private DelimitedStringList mDBConnProps;
+
+ final DriverListCombo combo = new DriverListCombo();
+
+ // stashed driver instance
+ private DriverInstance mDriverInstance;
+
+ /**
+ * Constructor
+ *
+ * @param pageName
+ */
+ public GenericDBProfileDetailsWizardPage(String pageName) {
+ super(pageName);
+ setTitle(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.title")); //$NON-NLS-1$
+ setDescription(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.msg")); //$NON-NLS-1$
+ }
+
+ /*
+ * (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(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.driverCombo.label")); //$NON-NLS-1$
+ this.combo
+ .setCategory(IDBDriverDefinitionConstants.DATABASE_CATEGORY_ID);
+ 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,
+ GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.databaseName.label"), //$NON-NLS-1$
+ this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+ this.mURLText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.url.label"), //$NON-NLS-1$
+ this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+ this.mDBUIDText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.userName.label"), //$NON-NLS-1$
+ this.mDBUIDText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+
+ this.mDBPWDText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.password.label"), //$NON-NLS-1$
+ this.mDBPWDText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+ this.mDBPWDText.setEchoChar('*');
+
+ // 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 label = new Label(content, SWT.NULL);
+ gdata = new GridData(GridData.FILL_HORIZONTAL);
+ gdata.horizontalSpan = 2;
+ label.setLayoutData(gdata);
+ label.setText(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.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();
+
+ if (this.mDriverInstance != null) {
+ this.mURLText.setText(getDriverURL());
+ }
+
+ this.mDBConnProps.addChangeListener(new ChangeListener() {
+
+ public void stateChanged(ChangeEvent arg0) {
+ setErrorMessage(null);
+ if (GenericDBProfileDetailsWizardPage.this.mDBConnProps.getWarning() != null) {
+ setErrorMessage(GenericDBProfileDetailsWizardPage.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) {
+ GenericDBProfileDetailsWizardPage.this.mDriverInstance = GenericDBProfileDetailsWizardPage.this.combo
+ .getSelectedDriverInstance();
+ setErrorMessage(null);
+ if (GenericDBProfileDetailsWizardPage.this.combo.getErrorMessage() != null) {
+ setErrorMessage(GenericDBProfileDetailsWizardPage.this.combo
+ .getErrorMessage());
+ }
+ GenericDBProfileDetailsWizardPage.this.mDatabaseNameText
+ .setText(getDriverDatabaseName());
+
+ GenericDBProfileDetailsWizardPage.this.mURLText
+ .setText(getDriverURL());
+
+ String username = GenericDBProfileDetailsWizardPage.this
+ .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.USERNAME_PROP_ID);
+ if (username == null || username.trim().length() == 0)
+ username = new String();
+ GenericDBProfileDetailsWizardPage.this.mDBUIDText.setText(username);
+
+ String password = GenericDBProfileDetailsWizardPage.this
+ .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.PASSWORD_PROP_ID);
+ if (password == null || password.trim().length() == 0)
+ password = new String();
+ GenericDBProfileDetailsWizardPage.this.mDBPWDText.setText(password);
+
+ setPageComplete(isValid());
+ }
+
+ });
+ }
+
+ 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 = "";
+ if (this.mDriverInstance != null) {
+ vendor = this.mDriverInstance
+ .getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
+ }
+ return vendor;
+ }
+
+ /**
+ * Get the version
+ *
+ * @return
+ */
+ public String getVersion() {
+ String version = "";
+ 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 = "";
+ 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 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[] {
+ GenericDBPlugin
+ .getDefault()
+ .getResourceString(
+ "GenericDBProfileDetailsWizardPage.summary.driverName.label"), //$NON-NLS-1$
+ mDriverInstance.getName() });
+
+ data
+ .add(new String[] {
+ GenericDBPlugin
+ .getDefault()
+ .getResourceString(
+ "GenericDBProfileDetailsWizardPage.summary.connProps.label"), //$NON-NLS-1$
+ getDBConnProps() });
+
+ data
+ .add(new String[] {
+ GenericDBPlugin
+ .getDefault()
+ .getResourceString(
+ "GenericDBProfileDetailsWizardPage.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[] {
+ GenericDBPlugin
+ .getDefault()
+ .getResourceString(
+ "GenericDBProfileDetailsWizardPage.summary.password.label"), //$NON-NLS-1$
+ pwdMask.toString() });
+
+ data.add(new String[] {
+ GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.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();
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfilePropertyPage.java b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfilePropertyPage.java
new file mode 100644
index 0000000..57a7482
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBProfilePropertyPage.java
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2005 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: brianf - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.db.generic.ui;
+
+import java.util.Properties;
+
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.db.generic.GenericDBPlugin;
+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.DelimitedStringList;
+import org.eclipse.datatools.connectivity.internal.ui.DriverListCombo;
+import org.eclipse.datatools.connectivity.ui.wizards.ProfileDetailsPropertyPage;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author ledunnel
+ */
+public class GenericDBProfilePropertyPage extends ProfileDetailsPropertyPage {
+
+ private static final String EMPTY_STRING = new String();
+
+ private Text mDatabaseNameText;
+ private Text mDBUIDText;
+ private Text mDBPWDText;
+ private Text mURLText;
+
+ final DriverListCombo combo = new DriverListCombo();
+ private DelimitedStringList mDBConnProps;
+ private DriverInstance mDriverInstance;
+
+ public GenericDBProfilePropertyPage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ /**
+ * @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(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.driverCombo.label")); //$NON-NLS-1$
+ this.combo
+ .setCategory(IDBDriverDefinitionConstants.DATABASE_CATEGORY_ID);
+ this.combo.setNullDriverIsValid(false);
+ this.combo.createContents(content);
+ if (this.combo.getErrorMessage() != null) {
+ setErrorMessage(this.combo.getErrorMessage());
+ }
+ this.mDatabaseNameText = (Text) createLabelTextPair(
+ content,
+ GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.databaseName.label"), //$NON-NLS-1$
+ this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+ this.mURLText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.url.label"), //$NON-NLS-1$
+ this.mURLText, SWT.BORDER, GridData.FILL_HORIZONTAL);
+ this.mDBUIDText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.userName.label"), //$NON-NLS-1$
+ this.mDBUIDText, SWT.BORDER, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+
+ this.mDBPWDText = (Text) createLabelTextPair(content, GenericDBPlugin
+ .getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.password.label"), //$NON-NLS-1$,
+ this.mDBPWDText, SWT.BORDER, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ this.mDBPWDText.setEchoChar('*');
+
+ Composite spacer = new Composite(content, SWT.NULL);
+ GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
+ gdata.horizontalSpan = 2;
+ gdata.heightHint = 20;
+ spacer.setLayoutData(gdata);
+
+ Label label = new Label(content, SWT.NULL);
+ gdata = new GridData(GridData.FILL_HORIZONTAL);
+ gdata.horizontalSpan = 2;
+ label.setLayoutData(gdata);
+ label.setText(GenericDBPlugin.getDefault().getResourceString(
+ "GenericDBProfileDetailsWizardPage.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 (GenericDBProfilePropertyPage.this.mDBConnProps.getWarning() != null) {
+ setErrorMessage(GenericDBProfilePropertyPage.this.mDBConnProps
+ .getWarning());
+ }
+ }
+
+ });
+
+ this.combo.addChangeListener(new ChangeListener() {
+
+ public void stateChanged(ChangeEvent arg0) {
+ GenericDBProfilePropertyPage.this.mDriverInstance = GenericDBProfilePropertyPage.this.combo
+ .getSelectedDriverInstance();
+ setErrorMessage(null);
+ if (GenericDBProfilePropertyPage.this.combo.getErrorMessage() != null) {
+ setErrorMessage(GenericDBProfilePropertyPage.this.combo
+ .getErrorMessage());
+ }
+ else
+ GenericDBProfilePropertyPage.this.mURLText
+ .setText(getDriverURL());
+ String username = GenericDBProfilePropertyPage.this
+ .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.USERNAME_PROP_ID);
+ if (username == null || username.trim().length() == 0)
+ username = new String();
+ String oldUsername = GenericDBProfilePropertyPage.this.mDBUIDText
+ .getText();
+ if (oldUsername == null || oldUsername.trim().length() == 0)
+ oldUsername = new String();
+ if (oldUsername.length() == 0)
+ GenericDBProfilePropertyPage.this.mDBUIDText
+ .setText(username);
+
+ String password = GenericDBProfilePropertyPage.this
+ .getPropertyFromDriverInstance(IDBDriverDefinitionConstants.PASSWORD_PROP_ID);
+ if (password == null || password.trim().length() == 0)
+ password = new String();
+ String oldPassword = GenericDBProfilePropertyPage.this.mDBPWDText
+ .getText();
+ if (oldPassword == null || oldPassword.trim().length() == 0)
+ oldPassword = new String();
+ if (oldPassword.length() == 0)
+ GenericDBProfilePropertyPage.this.mDBPWDText
+ .setText(password);
+ }
+
+ });
+
+ initControls();
+
+ // 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.PROP_CONNECTION_PROPERTIES,
+ 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());
+
+ 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.PROP_CONNECTION_PROPERTIES);
+ 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);
+ }
+
+ setErrorMessage(null);
+ }
+
+ 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();
+ }
+}
+
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBUIPlugin.java b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBUIPlugin.java
new file mode 100644
index 0000000..1101d42
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/GenericDBUIPlugin.java
@@ -0,0 +1,54 @@
+package org.eclipse.datatools.connectivity.db.generic.ui;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class GenericDBUIPlugin extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static GenericDBUIPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public GenericDBUIPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static GenericDBUIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.datatools.connectivity.db.generic.ui", path);
+ }
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/NewConnectionProfileWizard.java b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/NewConnectionProfileWizard.java
new file mode 100644
index 0000000..6210307
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.db.generic.ui/src/org/eclipse/datatools/connectivity/db/generic/ui/NewConnectionProfileWizard.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004-2005 Sybase, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: brianf - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.datatools.connectivity.db.generic.ui;
+
+
+
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.GenericDBPlugin;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * @see Wizard
+ */
+public class NewConnectionProfileWizard
+ extends
+ org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard {
+
+ protected GenericDBProfileDetailsWizardPage mPropPage;
+
+ public NewConnectionProfileWizard() {
+ setWindowTitle(GenericDBPlugin.getDefault().getResourceString(
+ "NewConnectionProfileWizard.title")); //$NON-NLS-1$
+ mProviderID = IDBConnectionProfileConstants.CONNECTION_PROFILE_ID;
+ }
+
+ /**
+ * @see org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard#addCustomPages()
+ */
+ public void addCustomPages() {
+ mPropPage = new GenericDBProfileDetailsWizardPage("detailsPage"); //$NON-NLS-1$
+ addPage(mPropPage);
+ }
+
+ /**
+ * @see org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard#getProfileProperties()
+ */
+ public Properties getProfileProperties() {
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
+ this.mPropPage.getDriverID());
+ props.setProperty(
+ IDBConnectionProfileConstants.PROP_CONNECTION_PROPERTIES,
+ 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(IDBDriverDefinitionConstants.USERNAME_PROP_ID, this.mPropPage
+ .getDBUID());
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
+ this.mPropPage.getURL());
+ return props;
+ }
+}
\ No newline at end of file