### Eclipse Workspace Patch 1.0 #P org.eclipse.datatools.connectivity.sample Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/samples/org.eclipse.datatools.connectivity.sample/META-INF/MANIFEST.MF,v retrieving revision 1.1 diff -u -r1.1 MANIFEST.MF --- META-INF/MANIFEST.MF 19 Sep 2007 00:38:53 -0000 1.1 +++ META-INF/MANIFEST.MF 20 Sep 2007 22:52:43 -0000 @@ -7,5 +7,7 @@ Bundle-Vendor: Eclipse.org Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.core.resources + org.eclipse.core.resources, + org.eclipse.datatools.connectivity.ui.dse, + org.eclipse.datatools.connectivity.db.generic Eclipse-LazyStart: true Index: src/org/eclipse/datatools/connectivity/sample/popup/actions/LaunchSample.java =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/samples/org.eclipse.datatools.connectivity.sample/src/org/eclipse/datatools/connectivity/sample/popup/actions/LaunchSample.java,v retrieving revision 1.1 diff -u -r1.1 LaunchSample.java --- src/org/eclipse/datatools/connectivity/sample/popup/actions/LaunchSample.java 19 Sep 2007 00:38:53 -0000 1.1 +++ src/org/eclipse/datatools/connectivity/sample/popup/actions/LaunchSample.java 20 Sep 2007 22:52:43 -0000 @@ -10,12 +10,16 @@ *******************************************************************************/ package org.eclipse.datatools.connectivity.sample.popup.actions; +import org.eclipse.datatools.connectivity.sample.wizards.SampleConnectionWizard; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; public class LaunchSample implements IObjectActionDelegate { @@ -36,11 +40,14 @@ * @see IActionDelegate#run(IAction) */ public void run(IAction action) { - Shell shell = new Shell(); - MessageDialog.openInformation( - shell, - "Sample Plug-in", - "Launch Sample was executed."); + SampleConnectionWizard wizard = new SampleConnectionWizard(); + wizard.setNeedsProgressMonitor(true); + + WizardDialog dialog = new WizardDialog(Display.getCurrent() + .getActiveShell(), wizard); + dialog.setMinimumPageSize(300, 350); + dialog.create(); + dialog.open(); } /** Index: plugin.xml =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/samples/org.eclipse.datatools.connectivity.sample/plugin.xml,v retrieving revision 1.1 diff -u -r1.1 plugin.xml --- plugin.xml 19 Sep 2007 00:38:53 -0000 1.1 +++ plugin.xml 20 Sep 2007 22:52:43 -0000 @@ -19,7 +19,7 @@ label="Launch Sample" class="org.eclipse.datatools.connectivity.sample.popup.actions.LaunchSample" menubarPath="org.eclipse.datatools.connectivity.sample.menu1/group1" - enablesFor="multiple" + enablesFor="*" id="org.eclipse.datatools.connectivity.sample.newAction"> Index: .settings/org.eclipse.jdt.core.prefs =================================================================== RCS file: .settings/org.eclipse.jdt.core.prefs diff -N .settings/org.eclipse.jdt.core.prefs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .settings/org.eclipse.jdt.core.prefs 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +#Thu Sep 20 15:32:39 PDT 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.4 Index: src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionWizardPage.java =================================================================== RCS file: src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionWizardPage.java diff -N src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionWizardPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionWizardPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.sample.wizards; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +public class SelectExistingConnectionWizardPage extends WizardPage { + + protected SelectExistingConnectionWizardPage(String pageName) { + super(pageName); + } + + public void createControl(Composite parent) { + setTitle("Sample Page"); //$NON-NLS-1$ + setMessage("Select an existing connection."); + + Composite container = new Composite(parent, SWT.NULL); + GridLayout gridLayout = new GridLayout(); + gridLayout.horizontalSpacing = 0; + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + container.setLayout(gridLayout); + + GridData gridData = new GridData(GridData.FILL_BOTH); + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = true; + container.setLayoutData(gridData); + + SelectExistingConnectionProfileDialogPage composite = new SelectExistingConnectionProfileDialogPage (); + composite.createControl(container); + setControl(container); + } + +} Index: src/org/eclipse/datatools/connectivity/sample/wizards/SampleConnectionWizard.java =================================================================== RCS file: src/org/eclipse/datatools/connectivity/sample/wizards/SampleConnectionWizard.java diff -N src/org/eclipse/datatools/connectivity/sample/wizards/SampleConnectionWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/connectivity/sample/wizards/SampleConnectionWizard.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.sample.wizards; + +import org.eclipse.jface.wizard.Wizard; + +public class SampleConnectionWizard extends Wizard { + + private SelectExistingConnectionWizardPage myExistingConnectionPage; + + private static final String EXISTING_CONNECTION_PAGE_NAME = "org.eclipse.datatools.connectivity.sample.SelectExistingConnectionWizardPage"; + + public SampleConnectionWizard() { + super(); + setWindowTitle("Connectivity Sample Wizard"); + } + + public boolean performFinish() { + // TODO Auto-generated method stub + return false; + } + public void addPages() { + super.addPages(); + + myExistingConnectionPage = new SelectExistingConnectionWizardPage( + EXISTING_CONNECTION_PAGE_NAME); + addPage(myExistingConnectionPage); + } +} Index: src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java =================================================================== RCS file: src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java diff -N src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/connectivity/sample/wizards/SelectExistingConnectionProfileDialogPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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.sample.wizards; + +import java.util.Arrays; +import java.util.Properties; +import java.util.Vector; + +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.ui.dse.dialogs.ConnectionDisplayProperty; +import org.eclipse.datatools.connectivity.ui.dse.dialogs.ExistingConnectionProfilesDialogPage; + +public class SelectExistingConnectionProfileDialogPage extends + ExistingConnectionProfilesDialogPage { + + protected ConnectionDisplayProperty[] updateConnectionDisplayProperties( + IConnectionProfile connectionProfile, + ConnectionDisplayProperty[] defaultDisplayProperties) { + ConnectionDisplayProperty[] properties = null; + Vector propertiesCollection = new Vector(); + propertiesCollection.addAll(Arrays.asList(defaultDisplayProperties)); + + Properties baseProperties = connectionProfile.getBaseProperties(); + + propertiesCollection + .add(new ConnectionDisplayProperty( + "Database", + (String) baseProperties + .get(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID))); + propertiesCollection + .add(new ConnectionDisplayProperty( + "JDBC Driver Class", + (String) baseProperties + .get(IDBDriverDefinitionConstants.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))); + propertiesCollection.add(new ConnectionDisplayProperty("User ID", + (String) baseProperties + .get(IDBDriverDefinitionConstants.USERNAME_PROP_ID))); + properties = new ConnectionDisplayProperty[propertiesCollection.size()]; + propertiesCollection.toArray(properties); + + return properties; + } + + protected IConnectionProfile[] getConnectionsToDisplay() { + String vendor = "Derby"; + Vector filteredProfilesCollection = new Vector(); + IConnectionProfile[] filteredProfiles = new IConnectionProfile[] {}; + IConnectionProfile[] allProfiles = ProfileManager.getInstance() + .getProfiles(false); + final int infoLength = allProfiles.length; + if (infoLength > 0) { + for (int index = 0; index < infoLength; index++) { + String vendorPropertyValue = ((String) allProfiles[index] + .getBaseProperties() + .get( + IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID)); + if ((vendorPropertyValue != null) + && (vendorPropertyValue.equals(vendor))) { + filteredProfilesCollection.add(allProfiles[index]); + } + filteredProfiles = new IConnectionProfile[filteredProfilesCollection + .size()]; + filteredProfilesCollection.copyInto(filteredProfiles); + } + } + return filteredProfiles; + } + + private String getJarList(IConnectionProfile connectionProfile) { + String jarList = ""; + DriverInstance driverInstance = null; + String driverID = connectionProfile.getBaseProperties().getProperty( + ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID); + if (driverID != null) { + driverInstance = DriverManager.getInstance().getDriverInstanceByID( + driverID); + if (driverInstance != null) { + jarList = driverInstance.getJarList(); + } + } + return jarList; + } +}