|
Lines 859-864
Link Here
|
| 859 |
|
859 |
|
| 860 |
ICompareInput input= (ICompareInput) in; |
860 |
ICompareInput input= (ICompareInput) in; |
| 861 |
|
861 |
|
|
|
862 |
Object[] r = searchByContentType(input, cc); |
| 863 |
if (r != null) |
| 864 |
result.addAll((List)r[1]); |
| 865 |
|
| 866 |
|
| 867 |
r = searchByType(input, cc); |
| 868 |
if (r != null) { |
| 869 |
result.addAll((List)r[1]); |
| 870 |
return (ViewerDescriptor[]) result.toArray(new ViewerDescriptor[0]); |
| 871 |
} |
| 872 |
return null; |
| 873 |
} |
| 874 |
|
| 875 |
private Object[] searchByContentType(ICompareInput input, CompareConfiguration cc) { |
| 862 |
IContentType ctype= getCommonType(input); |
876 |
IContentType ctype= getCommonType(input); |
| 863 |
if (isCompareAsText(input, cc)) { |
877 |
if (isCompareAsText(input, cc)) { |
| 864 |
ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); |
878 |
ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); |
|
Lines 866-875
Link Here
|
| 866 |
if (ctype != null) { |
880 |
if (ctype != null) { |
| 867 |
initializeRegistries(); |
881 |
initializeRegistries(); |
| 868 |
List list = fContentMergeViewers.searchAll(ctype); |
882 |
List list = fContentMergeViewers.searchAll(ctype); |
| 869 |
if (list != null) |
883 |
return new Object[] {ctype.getName(), list}; |
| 870 |
result.addAll(list); |
|
|
| 871 |
} |
884 |
} |
| 872 |
|
885 |
return null; |
|
|
886 |
} |
| 887 |
|
| 888 |
private Object[] searchByType(ICompareInput input, CompareConfiguration cc) { |
| 873 |
String[] types= getTypes(input); |
889 |
String[] types= getTypes(input); |
| 874 |
String type= null; |
890 |
String type= null; |
| 875 |
if (isHomogenous(types)) |
891 |
if (isHomogenous(types)) |
|
Lines 894-900
Link Here
|
| 894 |
initializeRegistries(); |
910 |
initializeRegistries(); |
| 895 |
List list = fContentMergeViewers.searchAll(type); |
911 |
List list = fContentMergeViewers.searchAll(type); |
| 896 |
if (list != null) |
912 |
if (list != null) |
| 897 |
result.addAll(list); |
913 |
return new Object[] {type, list}; |
| 898 |
} |
914 |
} |
| 899 |
|
915 |
|
| 900 |
// fallback |
916 |
// fallback |
|
Lines 912-923
Link Here
|
| 912 |
initializeRegistries(); |
928 |
initializeRegistries(); |
| 913 |
List list = fContentMergeViewers.searchAll(type); |
929 |
List list = fContentMergeViewers.searchAll(type); |
| 914 |
if (list != null) |
930 |
if (list != null) |
| 915 |
result.addAll(list); |
931 |
return new Object[] {type, list}; |
| 916 |
return (ViewerDescriptor[]) result.toArray(new ViewerDescriptor[0]); |
|
|
| 917 |
} |
932 |
} |
| 918 |
return null; |
933 |
return null; |
| 919 |
} |
934 |
|
| 920 |
|
935 |
} |
| 921 |
/** |
936 |
/** |
| 922 |
* Returns a content compare viewer based on an old viewer and an input object. |
937 |
* Returns a content compare viewer based on an old viewer and an input object. |
| 923 |
* If the old viewer is suitable for showing the input the old viewer |
938 |
* If the old viewer is suitable for showing the input the old viewer |
|
Lines 1296-1361
Link Here
|
| 1296 |
public static void log(IStatus status) { |
1311 |
public static void log(IStatus status) { |
| 1297 |
getDefault().getLog().log(status); |
1312 |
getDefault().getLog().log(status); |
| 1298 |
} |
1313 |
} |
|
|
1314 |
|
| 1315 |
String findContentTypeNameOrType(ICompareInput input, |
| 1316 |
ViewerDescriptor vd, CompareConfiguration cc) { |
| 1299 |
|
1317 |
|
| 1300 |
String findContentTypeNameOrType(ICompareInput input, ViewerDescriptor vd, CompareConfiguration cc) { |
1318 |
Object[] result = searchByContentType(input, cc); |
| 1301 |
IContentType ctype= getCommonType(input); |
1319 |
if (result != null) |
| 1302 |
if (isCompareAsText(input, cc)) { |
1320 |
if (((List) result[1]).contains(vd)) |
| 1303 |
ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); |
1321 |
return (String) result[0]; |
| 1304 |
} |
1322 |
|
| 1305 |
if (ctype != null) { |
1323 |
result = searchByType(input, cc); |
| 1306 |
initializeRegistries(); |
1324 |
if (result != null) |
| 1307 |
List list = fContentMergeViewers.searchAll(ctype); |
1325 |
if (((List) result[1]).contains(vd)) |
| 1308 |
if (list != null) |
1326 |
return (String) result[0]; |
| 1309 |
if (list.contains(vd)) |
|
|
| 1310 |
return ctype.getName(); |
| 1311 |
} |
| 1312 |
|
| 1313 |
String[] types= getTypes(input); |
| 1314 |
String type= null; |
| 1315 |
if (isHomogenous(types)) |
| 1316 |
type= types[0]; |
| 1317 |
|
| 1318 |
if (ITypedElement.FOLDER_TYPE.equals(type)) |
| 1319 |
return null; |
| 1320 |
|
| 1321 |
if (type == null) { |
| 1322 |
int n= 0; |
| 1323 |
for (int i= 0; i < types.length; i++) |
| 1324 |
if (!ITypedElement.UNKNOWN_TYPE.equals(types[i])) { |
| 1325 |
n++; |
| 1326 |
if (type == null) |
| 1327 |
type= types[i]; // remember the first known type |
| 1328 |
} |
| 1329 |
if (n > 1) // don't use the type if there were more than one |
| 1330 |
type= null; |
| 1331 |
} |
| 1332 |
|
| 1333 |
if (type != null) { |
| 1334 |
initializeRegistries(); |
| 1335 |
List list = fContentMergeViewers.searchAll(type); |
| 1336 |
if (list != null) |
| 1337 |
if (list.contains(vd)) |
| 1338 |
return type; |
| 1339 |
} |
| 1340 |
|
1327 |
|
| 1341 |
// fallback |
|
|
| 1342 |
String leftType= guessType(input.getLeft()); |
| 1343 |
String rightType= guessType(input.getRight()); |
| 1344 |
|
| 1345 |
if (leftType != null || rightType != null) { |
| 1346 |
boolean right_text= rightType != null && ITypedElement.TEXT_TYPE.equals(rightType); |
| 1347 |
boolean left_text= leftType != null && ITypedElement.TEXT_TYPE.equals(leftType); |
| 1348 |
if ((leftType == null && right_text) || (left_text && rightType == null) || (left_text && right_text)) |
| 1349 |
type= ITypedElement.TEXT_TYPE; |
| 1350 |
else |
| 1351 |
type= BINARY_TYPE; |
| 1352 |
|
| 1353 |
initializeRegistries(); |
| 1354 |
List list = fContentMergeViewers.searchAll(type); |
| 1355 |
if (list != null) |
| 1356 |
if (list.contains(vd)) |
| 1357 |
return type; |
| 1358 |
} |
| 1359 |
return null; |
1328 |
return null; |
| 1360 |
} |
1329 |
} |
| 1361 |
} |
1330 |
} |