Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 240433 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/datatools/connectivity/internal/ui/dialogs/DriverDialog.java (-5 / +15 lines)
Lines 135-140 Link Here
135
135
136
		public void stateChanged(ChangeEvent arg0) {
136
		public void stateChanged(ChangeEvent arg0) {
137
			boolean flag = isValid(true);
137
			boolean flag = isValid(true);
138
			validateName();
138
			if (DriverDialog.this.mOKButton != null && !DriverDialog.this.mOKButton.isDisposed())
139
			if (DriverDialog.this.mOKButton != null && !DriverDialog.this.mOKButton.isDisposed())
139
				DriverDialog.this.mOKButton.setEnabled(flag);			
140
				DriverDialog.this.mOKButton.setEnabled(flag);			
140
		}
141
		}
Lines 848-858 Link Here
848
						throw e;
849
						throw e;
849
				}
850
				}
850
851
851
			if (this.mOKButton != null)
852
			if (this.mOKButton != null && !this.mOKButton.isDisposed())
852
				this.mOKButton.setEnabled(flag);
853
				this.mOKButton.setEnabled(flag);
853
		}
854
		}
854
		else {
855
		else {
855
			if (this.mOKButton != null)
856
			if (this.mOKButton != null && !this.mOKButton.isDisposed())
856
				this.mOKButton.setEnabled(false);
857
				this.mOKButton.setEnabled(false);
857
			return false;
858
			return false;
858
		}
859
		}
Lines 1015-1021 Link Here
1015
				// creating new driver, name matches existing driver
1016
				// creating new driver, name matches existing driver
1016
				String errorMessage = DriverMgmtMessages
1017
				String errorMessage = DriverMgmtMessages
1017
					.getString("NewDriverDialog.driverExistsWithName"); //$NON-NLS-1$
1018
					.getString("NewDriverDialog.driverExistsWithName"); //$NON-NLS-1$
1018
				this.setErrorMessage(errorMessage);
1019
				try {
1020
					this.setErrorMessage(errorMessage);
1021
				} catch (SWTException swt_e) {
1022
					// just in case the message widget is disposed, since we can't grab
1023
					// it directly
1024
				}
1019
				return;
1025
				return;
1020
			}
1026
			}
1021
			else {
1027
			else {
Lines 1056-1062 Link Here
1056
			isOk = isValid(true);
1062
			isOk = isValid(true);
1057
		}
1063
		}
1058
1064
1059
		if (this.mOKButton != null)
1065
		if (this.mOKButton != null && !this.mOKButton.isDisposed())
1060
			this.mOKButton.setEnabled(isOk);
1066
			this.mOKButton.setEnabled(isOk);
1061
	}
1067
	}
1062
1068
Lines 1376-1385 Link Here
1376
		
1382
		
1377
		String propIdPrefix = DriverMgmtMessages
1383
		String propIdPrefix = DriverMgmtMessages
1378
			.getString("EditDriverDialog.text.id_prefix"); //$NON-NLS-1$
1384
			.getString("EditDriverDialog.text.id_prefix"); //$NON-NLS-1$
1379
		String propId = propIdPrefix + this.mDriverName;
1385
		String propId = propIdPrefix + this.descriptor.getId() + "." + this.mDriverName; //$NON-NLS-1$
1386
//		String propId = propIdPrefix + this.mDriverName;
1380
		if (this.mPropertySet == null) {
1387
		if (this.mPropertySet == null) {
1381
			this.mPropertySet = new PropertySetImpl(propId, this.mDriverName);
1388
			this.mPropertySet = new PropertySetImpl(propId, this.mDriverName);
1382
		}
1389
		}
1390
		else {
1391
			this.mPropertySet.setID(propId);
1392
		}
1383
		this.mPropertySet.setName(this.mDriverName);
1393
		this.mPropertySet.setName(this.mDriverName);
1384
		Properties props = new Properties();
1394
		Properties props = new Properties();
1385
		props
1395
		props
(-)src/org/eclipse/datatools/connectivity/drivers/DriverManager.java (-1 / +1 lines)
Lines 348-354 Link Here
348
			pset.setName(name);
348
			pset.setName(name);
349
		String prefix = DriverMgmtMessages
349
		String prefix = DriverMgmtMessages
350
				.getString("NewDriverDialog.text.id_prefix"); //$NON-NLS-1$
350
				.getString("NewDriverDialog.text.id_prefix"); //$NON-NLS-1$
351
		String id = prefix + name;
351
		String id = prefix + templateID + "." + name; //$NON-NLS-1$
352
		pset.setID(id);
352
		pset.setID(id);
353
		Properties props = pset.getBaseProperties();
353
		Properties props = pset.getBaseProperties();
354
		if (jarList != null)
354
		if (jarList != null)
(-)src/org/eclipse/datatools/connectivity/internal/ConnectionProfileMgmt.java (-5 / +19 lines)
Lines 624-638 Link Here
624
					Properties props = keysElementsToProperties((Element) extNode);
624
					Properties props = keysElementsToProperties((Element) extNode);
625
					String driverName = props.getProperty(DRIVERNAMEATTR);
625
					String driverName = props.getProperty(DRIVERNAMEATTR);
626
					String driverTypeID = props.getProperty(DRIVERTYPEIDATTR);
626
					String driverTypeID = props.getProperty(DRIVERTYPEIDATTR);
627
					String driverID = "";
627
					
628
					
628
					if (DriverManager.getInstance().getDriverInstanceByName(driverName) != null) {
629
					// Bug 240433 - brianf
630
					// Issue with importing 2 profiles with same driver ID but from different exports
631
					boolean existingDriverHasName = false;
632
					DriverInstance testDI = DriverManager.getInstance().getDriverInstanceByName(driverName);
633
					if (testDI != null) {
629
						// we found the driver, so we're ok to continue
634
						// we found the driver, so we're ok to continue
635
						if (testDI.getTemplate().getId().equalsIgnoreCase(driverTypeID)) {
636
							// the driver with the same name happens to have the same template ID, so we should be ok
637
							existingDriverHasName = true;
638
						}
630
					}
639
					}
631
					else {
640
					if (testDI == null || (testDI != null && !existingDriverHasName)) {
632
						DriverInstance di = DriverManager.getInstance().createNewDriverInstance(driverTypeID, driverName, new String());
641
						DriverInstance di = DriverManager.getInstance().createNewDriverInstance(driverTypeID, driverName, new String());
633
						if (di != null) {
642
						if (di != null) {
634
							String driverID = di.getId();
643
							driverID = di.getId();
635
							cp.getBaseProperties().setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, driverID);
644
							
645
							Properties baseProps = cp.getBaseProperties();
646
							baseProps.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, driverID);
647
							cp.setBaseProperties(baseProps);
636
							
648
							
637
							// This section is to fix BZ 213258 -- brianf
649
							// This section is to fix BZ 213258 -- brianf
638
							String jarList = 
650
							String jarList = 
Lines 799-805 Link Here
799
					
811
					
800
					Properties props = keysToProperties(elem);
812
					Properties props = keysToProperties(elem);
801
					try {
813
					try {
802
						props = ((ConnectionProfileProvider) cp.getProvider())
814
						if (((ConnectionProfileProvider) cp.getProvider())
815
								.getPropertiesPersistenceHook() != null)
816
							props = ((ConnectionProfileProvider) cp.getProvider())
803
								.getPropertiesPersistenceHook()
817
								.getPropertiesPersistenceHook()
804
								.populateTransientProperties(props);
818
								.populateTransientProperties(props);
805
					}
819
					}
(-)src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java (-8 / +35 lines)
Lines 54-59 Link Here
54
import org.eclipse.datatools.connectivity.ProfileManager;
54
import org.eclipse.datatools.connectivity.ProfileManager;
55
import org.eclipse.datatools.connectivity.drivers.DriverInstance;
55
import org.eclipse.datatools.connectivity.drivers.DriverInstance;
56
import org.eclipse.datatools.connectivity.drivers.DriverManager;
56
import org.eclipse.datatools.connectivity.drivers.DriverManager;
57
import org.eclipse.datatools.connectivity.drivers.DriverValidator;
57
import org.eclipse.datatools.connectivity.internal.repository.IConnectionProfileRepository;
58
import org.eclipse.datatools.connectivity.internal.repository.IConnectionProfileRepository;
58
import org.osgi.framework.Bundle;
59
import org.osgi.framework.Bundle;
59
import org.osgi.framework.BundleException;
60
import org.osgi.framework.BundleException;
Lines 1317-1332 Link Here
1317
1318
1318
		String defName = inName;
1319
		String defName = inName;
1319
1320
1320
		DriverInstance driverInstance = DriverManager.getInstance().getDriverInstanceByID(driverTemplateID);
1321
		/* 
1321
		if (driverInstance != null) {
1322
		 * Let's first see if we can find a valid instance of this driver template 
1322
			// jarList is not required, so it can be null, which isn't going to match any jarList coming back from a DriverInstance
1323
		 * with the same name and jar list. That would narrow things down.
1323
			if ((jarList == null) || (driverInstance.getJarList().equals(jarList))) {
1324
		 */
1324
				return driverInstance;
1325
		DriverInstance[] dilist = DriverManager.getInstance().getDriverInstancesByTemplate(driverTemplateID);
1326
		if (dilist != null && dilist.length > 0 ) {
1327
			for (int i = 0; i < dilist.length; i++) {
1328
				DriverInstance driverInstance = dilist[i];
1329
				if (driverInstance != null) {
1330
					// jarList is not required, so it can be null, which isn't going to match any jarList coming back from a DriverInstance
1331
					if ((jarList == null) || (driverInstance.getJarList().equals(jarList))) {
1332
						DriverValidator validator = new DriverValidator(driverInstance);
1333
						if (validator.isValid()) {
1334
							if (driverInstance.getName().equals(inName)) {
1335
								return driverInstance;
1336
							}
1337
						}
1338
					}
1339
						
1340
				}
1325
			}
1341
			}
1326
			 
1342
			/*
1327
			defName = determineUniqueDriverName(defName);
1343
			 * If we found drivers of that driver type, but didn't match on the
1328
				
1344
			 * jar list, name, or valid property set, then let's do a final check
1345
			 * to see if we find one with the same name (obviously something's not 
1346
			 * right with it) and create a new version with a unique name if we
1347
			 * find one.
1348
			 */
1349
			if (DriverManager.getInstance().getDriverInstanceByName(defName) != null)
1350
				defName = determineUniqueDriverName(defName);
1329
		}
1351
		}
1352
		
1353
		/*
1354
		 * Now we'll create it (with the original name if we didn't even get close,
1355
		 * or with the unique name if we did. 
1356
		 */
1330
		return DriverManager.getInstance()
1357
		return DriverManager.getInstance()
1331
			.createNewDriverInstance(
1358
			.createNewDriverInstance(
1332
				driverTemplateID,
1359
				driverTemplateID,

Return to bug 240433