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 91966 | Differences between
and this patch

Collapse All | Expand All

(-)EditorRegistry.java (-45 / +75 lines)
Lines 1220-1236 Link Here
1220
	 * @see org.eclipse.ui.IEditorRegistry#getDefaultEditor(java.lang.String, org.eclipse.core.runtime.content.IContentType)
1220
	 * @see org.eclipse.ui.IEditorRegistry#getDefaultEditor(java.lang.String, org.eclipse.core.runtime.content.IContentType)
1221
	 */
1221
	 */
1222
	public IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType) {
1222
	public IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType) {
1223
        FileEditorMapping[] mapping = getMappingForFilename(fileName);
1223
        IEditorDescriptor desc = getEditorForContentType(fileName, contentType);;
1224
        IEditorDescriptor desc = null;
1225
		if (contentType != null)
1226
			desc = getEditorForContentType(fileName, contentType);
1227
        if (desc == null && mapping[0] != null)
1228
            desc = mapping[0].getDefaultEditor();
1229
        if (desc == null && mapping[1] != null)
1230
            desc = mapping[1].getDefaultEditor();
1231
1232
        if (WorkbenchActivityHelper.filterItem(desc))
1233
            return null;
1234
1224
1235
        return desc;	
1225
        return desc;	
1236
	}
1226
	}
Lines 1361-1398 Link Here
1361
	}
1351
	}
1362
    
1352
    
1363
    /**
1353
    /**
1364
     * Find objects related to the content type.
1354
	 * Find objects related to the content type.
1365
     * 
1355
	 * 
1366
     * This method is temporary and exists only to back us off of the
1356
	 * This method is temporary and exists only to back us off of the
1367
     * soon-to-be-removed IContentTypeManager.IRelatedRegistry API.
1357
	 * soon-to-be-removed IContentTypeManager.IRelatedRegistry API.
1368
     * 
1358
	 * 
1369
     * @param type
1359
	 * @param type
1370
     * @param fileName
1360
	 * @param fileName
1371
     * @param registry
1361
	 * @param registry
1372
     * @return the related objects
1362
	 * @return the related objects
1373
     */
1363
	 */
1374
    private Object[] findRelatedObjects(IContentType type, String fileName, RelatedRegistry registry) {
1364
	private Object[] findRelatedObjects(IContentType type, String fileName,
1375
        List allRelated = new ArrayList();
1365
			RelatedRegistry registry) {
1376
        // first add any objects directly related to the content type
1366
		List allRelated = new ArrayList();
1377
        Object[] related = registry.getRelatedObjects(type);
1367
		Object[] related;
1378
        for (int i = 0; i < related.length; i++)
1368
1379
            allRelated.add(related[i]);
1369
		// backward compatibility requested - add any objects related directly to the file name
1380
        // backward compatibility requested - add any objects related to the file name
1370
		if (fileName != null) {
1381
        if (fileName != null) {
1371
			related = registry.getRelatedObjects(fileName);
1382
            related = registry.getRelatedObjects(fileName);
1372
			for (int i = 0; i < related.length; i++) {
1383
            for (int i = 0; i < related.length; i++)
1373
				// we don't want to return duplicates
1384
                if (!allRelated.contains(related[i]))
1374
				if (!allRelated.contains(related[i])) {
1385
                    // we don't want to return duplicates
1375
					// if it's not filtered, add it to the list
1386
                    allRelated.add(related[i]);
1376
					if (!WorkbenchActivityHelper.filterItem(related[i]))
1387
        }
1377
						allRelated.add(related[i]);
1388
        // now add any indirectly related objects, walking up the content type hierarchy 
1378
				}
1389
        while ((type = type.getBaseType()) != null) {
1379
			}
1390
            related = registry.getRelatedObjects(type);
1380
		}
1391
            for (int i = 0; i < related.length; i++)
1381
1392
                if (!allRelated.contains(related[i]))
1382
		if (type != null) {
1393
                    // we don't want to return duplicates                   
1383
			// now add any objects directly related to the content type
1394
                    allRelated.add(related[i]);
1384
			related = registry.getRelatedObjects(type);
1395
        }
1385
			for (int i = 0; i < related.length; i++) {
1396
        return allRelated.toArray();
1386
				// we don't want to return duplicates
1397
    }
1387
				if (!allRelated.contains(related[i])) {
1388
					// if it's not filtered, add it to the list
1389
					if (!WorkbenchActivityHelper.filterItem(related[i]))
1390
						allRelated.add(related[i]);
1391
				}
1392
			}
1393
1394
		}
1395
		//now add any objects related to the file extension
1396
		if (fileName != null) {
1397
			int index = fileName.lastIndexOf('.');
1398
			if (index > -1) {
1399
				String extension = "*" + fileName.substring(index); //$NON-NLS-1$
1400
				related = registry.getRelatedObjects(extension);
1401
				for (int i = 0; i < related.length; i++) {
1402
					//                	 we don't want to return duplicates
1403
					if (!allRelated.contains(related[i])) {
1404
						// if it's not filtered, add it to the list
1405
						if (!WorkbenchActivityHelper.filterItem(related[i]))
1406
							allRelated.add(related[i]);
1407
					}
1408
				}
1409
			}
1410
		}
1411
1412
		if (type != null) {
1413
			// now add any indirectly related objects, walking up the content type hierarchy 
1414
			while ((type = type.getBaseType()) != null) {
1415
				related = registry.getRelatedObjects(type);
1416
				for (int i = 0; i < related.length; i++) {
1417
					// we don't want to return duplicates
1418
					if (!allRelated.contains(related[i])) {
1419
						// if it's not filtered, add it to the list
1420
						if (!WorkbenchActivityHelper.filterItem(related[i]))
1421
							allRelated.add(related[i]);
1422
					}
1423
				}
1424
			}
1425
		}
1426
		return allRelated.toArray();
1427
	}
1398
}
1428
}

Return to bug 91966