1 11 12 package org.eclipse.ui.views.tasklist; 13 14 import java.util.ArrayList ; 15 import java.util.HashMap ; 16 17 import org.eclipse.core.resources.IMarker; 18 import org.eclipse.core.resources.ResourcesPlugin; 19 import org.eclipse.core.runtime.IConfigurationElement; 20 import org.eclipse.core.runtime.IExtension; 21 import org.eclipse.core.runtime.IExtensionPoint; 22 import org.eclipse.core.runtime.Platform; 23 24 27 class MarkerTypesModel { 28 31 private HashMap types; 32 33 36 public MarkerTypesModel() { 37 types = readTypes(); 38 } 39 40 43 public MarkerType getType(String id) { 44 return (MarkerType) types.get(id); 45 } 46 47 50 public MarkerType[] getTypes() { 51 MarkerType[] result = new MarkerType[types.size()]; 52 types.values().toArray(result); 53 return result; 54 } 55 56 60 private String getWellKnownLabel(String type) { 61 if (type.equals(IMarker.PROBLEM)) { 62 return "Problem"; } 64 if (type.equals(IMarker.TASK)) { 65 return "Task"; } 67 if (type.equals("org.eclipse.jdt.core.problem")) { return "Java Problem"; } 70 return type; 71 } 72 73 76 private HashMap readTypes() { 77 HashMap types = new HashMap (); 78 IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint( 79 ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS); 80 if (point != null) { 81 IExtension[] extensions = point.getExtensions(); 83 for (int i = 0; i < extensions.length; ++i) { 84 IExtension ext = extensions[i]; 85 String id = ext.getUniqueIdentifier(); 86 String label = ext.getLabel(); 87 if (label.equals("")) { label = getWellKnownLabel(id); 89 } 90 ArrayList supersList = new ArrayList (); 91 IConfigurationElement[] configElements = ext 92 .getConfigurationElements(); 93 for (int j = 0; j < configElements.length; ++j) { 94 IConfigurationElement elt = configElements[j]; 95 if (elt.getName().equalsIgnoreCase("super")) { String sup = elt.getAttribute("type"); if (sup != null) { 98 supersList.add(sup); 99 } 100 } 101 } 102 String [] superTypes = new String [supersList.size()]; 103 supersList.toArray(superTypes); 104 MarkerType type = new MarkerType(this, id, label, superTypes); 105 types.put(id, type); 106 } 107 } 108 return types; 109 } 110 } 111 | Popular Tags |