summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSal Ledezma2012-08-20 20:30:17 (EDT)
committer Brian Payton2012-08-20 20:30:17 (EDT)
commitd91d44db1dab3278e980c5aae7dfa96050f4698a (patch)
tree4ab155efb3a5da30a8df32155a861880fe4b4101
parent0844e5217e39884fc0d25f7214e175ba4869b73d (diff)
downloadorg.eclipse.datatools.connectivity-d91d44db1dab3278e980c5aae7dfa96050f4698a.zip
org.eclipse.datatools.connectivity-d91d44db1dab3278e980c5aae7dfa96050f4698a.tar.gz
org.eclipse.datatools.connectivity-d91d44db1dab3278e980c5aae7dfa96050f4698a.tar.bz2
[384194] Applied patch to o.e.d.connectivity
-rw-r--r--plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/DriverManager.java56
1 files changed, 48 insertions, 8 deletions
diff --git a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/DriverManager.java b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/DriverManager.java
index 1a88d82..dff0201 100644
--- a/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/DriverManager.java
+++ b/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/DriverManager.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
import java.util.Vector;
@@ -120,7 +121,7 @@ public class DriverManager {
}
private DriverManager() {
- resetDefaultInstances();
+ resetDefaultInstances(true);
}
private DriverInstance getDriverInstanceFromMapByName( String name ) {
@@ -510,6 +511,12 @@ public class DriverManager {
addDriverInstance(di);
}
+ public void addDriverInstances(IPropertySet[] propertySets) {
+ saveChanges(propertySets);
+ mDriverInstanceMap = new HashMap();
+ loadAllInstances();
+ }
+
/**
* Parses the incoming string by the token.
* @param str_list String list
@@ -798,7 +805,10 @@ public class DriverManager {
* This is when the plug-in is loaded.
*/
public void resetDefaultInstances() {
-
+ resetDefaultInstances(false);
+ }
+
+ public void resetDefaultInstances(boolean batchUpdate) {
debug ("resetDefaultInstances"); //$NON-NLS-1$
// Start building a list
@@ -821,14 +831,20 @@ public class DriverManager {
}
wereDefaultDriversCreated();
-// if (wereDefaultDriversCreated())
-// return;
debug ("resetDefaultInstances: checking for drivers to create by default"); //$NON-NLS-1$
// Now grab all the driver instances from the file
IPropertySet[] psets = getPropertySetsFromMap();
+ List<IPropertySet> pendingPropertySets = null;
+ List<TemplateDescriptor> pendingDefaultsCreated = null;
+ boolean updatePending = false;
+ if (batchUpdate) {
+ pendingPropertySets = new ArrayList<IPropertySet>();
+ pendingDefaultsCreated = new ArrayList<TemplateDescriptor>();
+ }
+
// now process the templates and see if we need to
// create any instances
for (int i = 0; i < types.length; i++) {
@@ -881,21 +897,45 @@ public class DriverManager {
debug("Default already exists for " + type.getId() + ": " + defaultExists); //$NON-NLS-1$ //$NON-NLS-2$
if ((createDefaultValue || type.getCreateDefaultFlag()) && !defaultExists && !alreadyExists) {
IPropertySet newPset = createDefaultInstance(type);
- if (newPset != null)
- addDriverInstance(newPset);
-
- setDefaultCreated( type.getId(), true );
+ if (newPset != null) {
+ if (batchUpdate) {
+ pendingPropertySets.add(newPset);
+ pendingDefaultsCreated.add(type);
+ updatePending = true;
+ } else {
+ addDriverInstance(newPset);
+ setDefaultCreated( type.getId(), true );
+ }
+ }
}
}
+
+ if (batchUpdate && updatePending) {
+ addDriverInstances(pendingPropertySets.toArray(new IPropertySet[0]));
+ setDefaultCreated(pendingDefaultsCreated.toArray(new TemplateDescriptor[0]), true);
+ }
+
boolean markerCreated = createDefaultDriversMarker();
debug("Marker created: " + markerCreated); //$NON-NLS-1$
}
+ private void setDefaultCreated(TemplateDescriptor[] types, boolean isDefaultCreated) {
+ for (TemplateDescriptor type : types) {
+ ConnectivityPlugin.getDefault().setPreferenceValue( type.getId(), isDefaultCreated );
+ }
+
+ savePreferences();
+ }
+
private void setDefaultCreated( String driverTemplateId, boolean isDefaultCreated )
{
ConnectivityPlugin.getDefault().
setPreferenceValue( driverTemplateId, isDefaultCreated );
+ savePreferences();
+ }
+
+ private void savePreferences() {
IPath metadataPath =
ConnectivityPlugin.getWorkspaceFilePath(DRIVER_MARKER_FILE_NAME);
File file = metadataPath.toFile();