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 (-49 / +82 lines)
Lines 94-100 Link Here
94
         * @return the objects related to the filename
94
         * @return the objects related to the filename
95
		 */
95
		 */
96
		public Object[] getRelatedObjects(String fileName) {
96
		public Object[] getRelatedObjects(String fileName) {
97
			return getEditors(fileName);
97
			IFileEditorMapping mapping = getMappingFor(fileName);
98
			if (mapping == null)
99
				return EMPTY;
100
			
101
			return mapping.getEditors();
98
		}
102
		}
99
		
103
		
100
	}
104
	}
Lines 483-489 Link Here
483
    /**
487
    /**
484
     * Add the system editors to the provided map. This will always add an
488
     * Add the system editors to the provided map. This will always add an
485
     * editor with an id of {@link #SYSTEM_EXTERNAL_EDITOR_ID} and may also add
489
     * editor with an id of {@link #SYSTEM_EXTERNAL_EDITOR_ID} and may also add
486
     * an editor with id of {@ #SYSTEM_INPLACE_EDITOR_ID} if the system
490
     * an editor with id of {@link #SYSTEM_INPLACE_EDITOR_ID} if the system
487
     * configuration supports it.
491
     * configuration supports it.
488
     * 
492
     * 
489
     * @param map the map to augment
493
     * @param map the map to augment
Lines 1220-1238 Link Here
1220
	 * @see org.eclipse.ui.IEditorRegistry#getDefaultEditor(java.lang.String, org.eclipse.core.runtime.content.IContentType)
1224
	 * @see org.eclipse.ui.IEditorRegistry#getDefaultEditor(java.lang.String, org.eclipse.core.runtime.content.IContentType)
1221
	 */
1225
	 */
1222
	public IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType) {
1226
	public IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType) {
1223
        FileEditorMapping[] mapping = getMappingForFilename(fileName);
1227
        return 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
1235
        return desc;	
1236
	}
1228
	}
1237
1229
1238
	/**
1230
	/**
Lines 1361-1398 Link Here
1361
	}
1353
	}
1362
    
1354
    
1363
    /**
1355
    /**
1364
     * Find objects related to the content type.
1356
	 * Find objects related to the content type.
1365
     * 
1357
	 * 
1366
     * This method is temporary and exists only to back us off of the
1358
	 * This method is temporary and exists only to back us off of the
1367
     * soon-to-be-removed IContentTypeManager.IRelatedRegistry API.
1359
	 * soon-to-be-removed IContentTypeManager.IRelatedRegistry API.
1368
     * 
1360
	 * 
1369
     * @param type
1361
	 * @param type
1370
     * @param fileName
1362
	 * @param fileName
1371
     * @param registry
1363
	 * @param registry
1372
     * @return the related objects
1364
	 * @return the related objects
1373
     */
1365
	 */
1374
    private Object[] findRelatedObjects(IContentType type, String fileName, RelatedRegistry registry) {
1366
	private Object[] findRelatedObjects(IContentType type, String fileName,
1375
        List allRelated = new ArrayList();
1367
			RelatedRegistry registry) {
1376
        // first add any objects directly related to the content type
1368
		List allRelated = new ArrayList();
1377
        Object[] related = registry.getRelatedObjects(type);
1369
		Object[] related;
1378
        for (int i = 0; i < related.length; i++)
1370
1379
            allRelated.add(related[i]);
1371
		// backward compatibility requested - add any objects related directly to the file name
1380
        // backward compatibility requested - add any objects related to the file name
1372
		if (fileName != null) {
1381
        if (fileName != null) {
1373
			related = registry.getRelatedObjects(fileName);
1382
            related = registry.getRelatedObjects(fileName);
1374
			for (int i = 0; i < related.length; i++) {
1383
            for (int i = 0; i < related.length; i++)
1375
				// we don't want to return duplicates
1384
                if (!allRelated.contains(related[i]))
1376
				if (!allRelated.contains(related[i])) {
1385
                    // we don't want to return duplicates
1377
					// if it's not filtered, add it to the list
1386
                    allRelated.add(related[i]);
1378
					if (!WorkbenchActivityHelper.filterItem(related[i]))
1387
        }
1379
						allRelated.add(related[i]);
1388
        // now add any indirectly related objects, walking up the content type hierarchy 
1380
				}
1389
        while ((type = type.getBaseType()) != null) {
1381
			}
1390
            related = registry.getRelatedObjects(type);
1382
		}
1391
            for (int i = 0; i < related.length; i++)
1383
1392
                if (!allRelated.contains(related[i]))
1384
		//now add any objects related to the file extension
1393
                    // we don't want to return duplicates                   
1385
		if (fileName != null) {
1394
                    allRelated.add(related[i]);
1386
			int index = fileName.lastIndexOf('.');
1395
        }
1387
			if (index > -1) {
1396
        return allRelated.toArray();
1388
				String extension = "*" + fileName.substring(index); //$NON-NLS-1$
1397
    }
1389
				related = registry.getRelatedObjects(extension);
1390
				for (int i = 0; i < related.length; i++) {
1391
					//                	 we don't want to return duplicates
1392
					if (!allRelated.contains(related[i])) {
1393
						// if it's not filtered, add it to the list
1394
						if (!WorkbenchActivityHelper.filterItem(related[i]))
1395
							allRelated.add(related[i]);
1396
					}
1397
				}
1398
			}
1399
		}
1400
		
1401
		if (type != null) {
1402
			// now add any objects directly related to the content type
1403
			related = registry.getRelatedObjects(type);
1404
			for (int i = 0; i < related.length; i++) {
1405
				// we don't want to return duplicates
1406
				if (!allRelated.contains(related[i])) {
1407
					// if it's not filtered, add it to the list
1408
					if (!WorkbenchActivityHelper.filterItem(related[i]))
1409
						allRelated.add(related[i]);
1410
				}
1411
			}
1412
1413
		}
1414
1415
		if (type != null) {
1416
			// now add any indirectly related objects, walking up the content type hierarchy 
1417
			while ((type = type.getBaseType()) != null) {
1418
				related = registry.getRelatedObjects(type);
1419
				for (int i = 0; i < related.length; i++) {
1420
					// we don't want to return duplicates
1421
					if (!allRelated.contains(related[i])) {
1422
						// if it's not filtered, add it to the list
1423
						if (!WorkbenchActivityHelper.filterItem(related[i]))
1424
							allRelated.add(related[i]);
1425
					}
1426
				}
1427
			}
1428
		}
1429
		return allRelated.toArray();
1430
	}
1398
}
1431
}

Return to bug 91966