fix bug 11991. sorting support for sbsv2 build configs
authortimkelly
Fri, 17 Sep 2010 16:02:09 -0500
changeset 2050 0d6ae58214f3
parent 2044 2a4e35146637
child 2051 2ad90ffa5d8b
fix bug 11991. sorting support for sbsv2 build configs
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java	Fri Sep 17 13:35:34 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java	Fri Sep 17 16:02:09 2010 -0500
@@ -236,16 +236,7 @@
 		}
 		return sbsPath != null ? sbsPath : new Path(sbsScriptName);  // dummy
 	}
-	
-	private static List<ISymbianBuildContext> sortContexts(List<ISymbianBuildContext> contexts){ 
-		Collections.sort(contexts, new Comparator<ISymbianBuildContext>() {
-			public int compare(ISymbianBuildContext o1, ISymbianBuildContext o2) {
-				return o2.getDisplayString().compareTo(o1.getDisplayString());
-			}
-		});
-		
-		return contexts; 
-	}
+
 	
 	private static boolean isSBSv1Supported() {
 		if (HostOS.IS_UNIX){
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java	Fri Sep 17 13:35:34 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java	Fri Sep 17 16:02:09 2010 -0500
@@ -15,6 +15,8 @@
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -66,7 +68,7 @@
 
 	public List<ISymbianBuildContext> getAllBuildConfigurations() {
 		// This really only applies to SBSv1. We never return the full list of configs for SBSv2, only the filtered ones
-		return sbsv2FilteredContexts;
+		return sortContexts(sbsv2FilteredContexts);
 	}
 
 	public void clearDataFromBuildCache(){
@@ -120,7 +122,9 @@
 			}
 		} 
 		
-		return sbsv2FilteredContexts;
+		
+		
+		return sortContexts(sbsv2FilteredContexts);
 	}
 
 	private void initSBSv2BuildContextList(List<String> allowedConfigs) throws SBSv2MinimumVersionException {
@@ -323,5 +327,34 @@
 	public void setPreviouslyScanned(boolean wasScanned) {
 		this.wasScanned = wasScanned;
 	}
+	
+	private static List<ISymbianBuildContext> sortContexts(List<ISymbianBuildContext> contexts){ 
+		Collections.sort(contexts, new Comparator<ISymbianBuildContext>() {
+			
+			public int compare(ISymbianBuildContext o1, ISymbianBuildContext o2) {
+				
+				ISBSv2BuildContext sbs1 = (ISBSv2BuildContext)o1;
+				ISBSv2BuildContext sbs2 = (ISBSv2BuildContext)o2;
+				
+				//String[] sbs1Prefix = sbs1.getSBSv2Alias().split("_");
+				String[] sbs2Prefix = sbs2.getSBSv2Alias().split("_");
+				
+				if (sbs1.getSBSv2Alias().length() == sbs2.getSBSv2Alias().length()){
+					return sbs1.getSBSv2Alias().compareTo(sbs2.getSBSv2Alias());
+				}
+				
+				if (sbs2Prefix.length > 0){
+					if (sbs1.getSBSv2Alias().startsWith(sbs2Prefix[0])){
+						return -1;
+					}
+				}
+				
+				
+				return sbs1.getSBSv2Alias().compareTo(sbs2.getSBSv2Alias());
+			}
+		});
+		
+		return contexts; 
+	}
 
 }