clean up some code as part of displaying configs remvoed from filtering. C3_BUILDER_WORK
authortimkelly
Mon, 07 Jun 2010 10:17:00 -0500
branchC3_BUILDER_WORK
changeset 1437 8534c28043b9
parent 1433 1a693b01d107
child 1438 03403c6a4740
clean up some code as part of displaying configs remvoed from filtering.
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java	Fri Jun 04 16:34:02 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java	Mon Jun 07 10:17:00 2010 -0500
@@ -229,15 +229,12 @@
 			sdk = SDKCorePlugin.getSDKManager().getSDK(sdkID, true);
 			// TODO: NEED TO HANDLE MISSING SDK ID
 			if (sdk != null){
-				if (displayString == null || !displayString.startsWith(ISBSv2BuildContext.BUILDER_ID)) {
-					// likely an old config that has used the display name as the config id
-					displayString = configID;
+				
+				if (displayString == null && !configID.startsWith(ISBSv2BuildContext.BUILDER_ID)){
+					displayString = configID; // Old config, used unique 'id' and config name interchangably
+				} else {
+					displayString = displayString;
 				}
-				
-				if (!configID.startsWith(ISBSv2BuildConfigInfo.ATTRIB_SBSV2_BUILD_ALIAS)){
-					System.out.println("old config");
-				}
-				displayString = displayString + " [" + sdk.getUniqueId() + "]";
 				return new BuildContextSBSv2(sdk, platform, target, buidAlias, displayString, configID);
 			}
 		}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java	Fri Jun 04 16:34:02 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java	Mon Jun 07 10:17:00 2010 -0500
@@ -272,83 +272,88 @@
 	}
 
 	/**
-	 * When displaying build configs there may be configurations in the project that may not be displayed.
+	 * When displaying build configs there may be configurations in the project that may not be displayed
 	 * We add those back in so they reside in the checked tree viewer in case the user wants to remove them.
 	 * @param sdkConfigTreeNodes
 	 */
 	private void replaceFilteredConfigsFromProject(BuildTargetTreeNode[] sdkConfigTreeNodes) {
 		List<ICarbideBuildConfiguration> bldConfigs = cpi.getBuildConfigurations();
 		
-		/////////////
-		//////////// TODO TODO TODO
-		/////////// Refactor me. This is very inefficient code, just used for prototyping of adding in filtered out configs
-		////////////
-		
+		HashMap<BuildTargetTreeNode, List<ISymbianBuildContext>> missingConfigMap = new HashMap<BuildTargetTreeNode, List<ISymbianBuildContext>>();
 		for (ICarbideBuildConfiguration config : bldConfigs){
 			boolean foundConfig = false;
 			// Add in configs that are only defined in the project and not the
 			// suggested filtered config cache
 			for (BuildTargetTreeNode sdkConfigNode : sdkConfigTreeNodes){
-				TreeNode[] configNodes = sdkConfigNode.getChildren();
-				for (TreeNode childConfig : configNodes){
-					if (childConfig == null){
-						continue;
+				ISymbianSDK sdk = sdkConfigNode.getSymbianSDK();
+				if (!sdk.getUniqueId().equals(config.getSDK().getUniqueId())){
+					continue; // not in this SDK, don't bother looking at all configs
+				} else {
+					// Found the right SDK, now check and see if the config exists
+					TreeNode[] configNodes = sdkConfigNode.getChildren();
+					for (TreeNode childConfig : configNodes){
+						if (childConfig == null){
+							continue;
+						}
+						if (childConfig.getValue() instanceof ISymbianBuildContext){
+							ISymbianBuildContext context = (ISymbianBuildContext)(childConfig.getValue());
+							if (config.getBuildContext().equals(context)){
+								foundConfig = true;
+								break;
+							}
+						}
 					}
-					if (childConfig.getValue() instanceof ISymbianBuildContext){
-						ISymbianBuildContext context = (ISymbianBuildContext)(childConfig.getValue());
-						if (config.getBuildContext().equals(context)){
-							foundConfig = true;
-							break;
+					if (!foundConfig){
+						// save config off, we'll add it back in later
+						List<ISymbianBuildContext> contextsToAdd = new ArrayList<ISymbianBuildContext>();
+						if (null == missingConfigMap.get(sdkConfigNode)){
+							contextsToAdd.add(config.getBuildContext());
+						} else {
+							contextsToAdd = missingConfigMap.get(sdkConfigNode);
+							contextsToAdd.add(config.getBuildContext());
 						}
-					} else {
-						System.out.println("Huh? Not an ISymbiabBuildContext : " + childConfig.getValue());
+						missingConfigMap.put(sdkConfigNode, contextsToAdd);
+						
 					}
 				}
-				if (foundConfig) break;
+			}			
+		}
+		
+		for (BuildTargetTreeNode sdkNode : missingConfigMap.keySet()){
+			List<ISymbianBuildContext> configsToAdd = missingConfigMap.get(sdkNode);
+			TreeNode[] oldConfigNodes = sdkNode.getChildren();
+			TreeNode[] newConfigNodes = new TreeNode[oldConfigNodes.length + configsToAdd.size()];
+			int index = 0;
+			// build up the old list....
+			for (TreeNode newConfigNode : oldConfigNodes){
+				if (newConfigNode == null){
+					continue;
+				}
+				if (newConfigNode.getValue() instanceof ISymbianBuildContext){
+					ISymbianBuildContext context = (ISymbianBuildContext)(newConfigNode.getValue());
+					newConfigNodes[index++] = new TreeNode(context) {
+						@Override
+						public String toString() {
+							ISymbianBuildContext context = (ISymbianBuildContext)getValue();
+							return context.getDisplayString();
+						}
+					};
+				}
 			}
 			
-			if (!foundConfig){
-				for (BuildTargetTreeNode sdkConfigNode : sdkConfigTreeNodes){
-					ISymbianSDK sdk = sdkConfigNode.getSymbianSDK();
-					if (sdk.getUniqueId().equals(config.getSDK().getUniqueId())){
-						// add the config
-						TreeNode[] oldConfigNodes = sdkConfigNode.getChildren();
-						TreeNode[] newConfigNodes = new TreeNode[oldConfigNodes.length + 1];
-						int index = 0;
-						for (TreeNode newConfigNode : oldConfigNodes){
-							if (newConfigNode == null){
-								continue;
-							}
-							if (newConfigNode.getValue() instanceof ISymbianBuildContext){
-								ISymbianBuildContext context = (ISymbianBuildContext)(newConfigNode.getValue());
-								newConfigNodes[index++] = new TreeNode(context) {
-									@Override
-									public String toString() {
-										ISymbianBuildContext context = (ISymbianBuildContext)getValue();
-										return context.getDisplayString();
-									}
-								};
-							}
-						}
-						
-						// add the missing config
-						newConfigNodes[index++] = new TreeNode(config.getBuildContext()) {
-							@Override
-							public String toString() {
-								ISymbianBuildContext context = (ISymbianBuildContext)getValue();
-								return context.getDisplayString();
-							}
-						};
-						
-						sdkConfigNode.setChildren(newConfigNodes);
-						
-					} else {
-						continue; // not the SDK we're looking for
+			// ... then add the project specific items...
+			for (ISymbianBuildContext newContext : configsToAdd){
+				newConfigNodes[index++] = new TreeNode(newContext) {
+					@Override
+					public String toString() {
+						ISymbianBuildContext context = (ISymbianBuildContext)getValue();
+						return context.getDisplayString();
 					}
-				}
-
+				};
 			}
 			
+			sdkNode.setChildren(newConfigNodes);
+			
 		}
 		
 	}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java	Fri Jun 04 16:34:02 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java	Mon Jun 07 10:17:00 2010 -0500
@@ -59,7 +59,7 @@
 		
 		// TODO: Still need to decide on how to set display string
 		// and how it's used for legacy SBSv2 configs
-		if (displayString != null && !displayString.equals(configID)){
+		if (displayString != null){
 			return displayString;
 		}