1 11 12 package org.eclipse.ui.views.tasklist; 13 14 import java.util.ArrayList ; 15 16 19 class MarkerType { 20 private MarkerTypesModel model; 21 22 private String id; 23 24 private String label; 25 26 private String [] supertypeIds; 27 28 31 public MarkerType(MarkerTypesModel model, String id, String label, 32 String [] supertypeIds) { 33 this.model = model; 34 this.id = id; 35 this.label = label; 36 this.supertypeIds = supertypeIds; 37 } 38 39 42 public MarkerType[] getAllSupertypes() { 43 ArrayList result = new ArrayList (); 44 getAllSupertypes(result); 45 return (MarkerType[]) result.toArray(new MarkerType[result.size()]); 46 } 47 48 51 private void getAllSupertypes(ArrayList result) { 52 MarkerType[] supers = getSupertypes(); 53 for (int i = 0; i < supers.length; ++i) { 54 MarkerType sup = supers[i]; 55 if (!result.contains(sup)) { 56 result.add(sup); 57 sup.getAllSupertypes(result); 58 } 59 } 60 } 61 62 65 public String getId() { 66 return id; 67 } 68 69 72 public String getLabel() { 73 return label; 74 } 75 76 81 public MarkerType[] getSubtypes() { 82 MarkerType[] types = model.getTypes(); 83 ArrayList result = new ArrayList (); 84 for (int i = 0; i < types.length; ++i) { 85 MarkerType type = types[i]; 86 String [] supers = type.getSupertypeIds(); 87 for (int j = 0; j < supers.length; ++j) { 88 if (supers[j].equals(id)) { 89 result.add(type); 90 } 91 } 92 } 93 return (MarkerType[]) result.toArray(new MarkerType[result.size()]); 94 } 95 96 99 public String [] getSupertypeIds() { 100 return supertypeIds; 101 } 102 103 106 public MarkerType[] getSupertypes() { 107 ArrayList result = new ArrayList (); 108 for (int i = 0; i < supertypeIds.length; ++i) { 109 MarkerType sup = model.getType(supertypeIds[i]); 110 if (sup != null) { 111 result.add(sup); 112 } 113 } 114 return (MarkerType[]) result.toArray(new MarkerType[result.size()]); 115 } 116 117 123 public boolean isSubtypeOf(MarkerType superType) { 124 if (id.equals(superType.getId())) { 125 return true; 126 } 127 for (int i = 0; i < supertypeIds.length; ++i) { 128 MarkerType sup = model.getType(supertypeIds[i]); 129 if (sup != null && sup.isSubtypeOf(superType)) { 130 return true; 131 } 132 } 133 return false; 134 } 135 } 136 | Popular Tags |