* @param metadata the metadata to get HTML for
* @return the HTML for type class metadata specific information
*/
private static String getTypeClassMetadataHtml(NavFrameOwner owner, TypeClassMetadata metadata) {
TypeClass typeClass = (TypeClass) owner.getPerspective().getWorkspace().getScopedEntity(metadata.getFeatureName());
StringBuilder buffer = new StringBuilder();
ScopedEntityNamingPolicy namingPolicy = new UnqualifiedUnlessAmbiguous(owner.getPerspective().getWorkingModuleTypeInfo());
// list the parent classes of the class
buffer.append("<h2>" + getAnchorHtml(PARENTS_ANCHOR, NavigatorMessages.getString("NAV_ParentClasses_Header")) + "</h2>");
int count = typeClass.getNParentClasses();
if (count == 0) {
buffer.append(NavigatorMessages.getString("NAV_NoValue"));
} else {
SortedSet<TypeClass> parents = new TreeSet<TypeClass>(new ScopedEntityQualifiedComparator());
for (int i = 0; i < count; i++) {
parents.add(typeClass.getNthParentClass(i));
}
buffer.append("<tt>");
for (final TypeClass parentClass : parents) {
NavAddress parentUrl = NavAddress.getAddress(parentClass);
buffer.append(getLinkHtml(parentUrl, NavAddressHelper.getDisplayText(owner, parentUrl, namingPolicy)) + ", ");
}
// remove trailing comma
buffer.delete(buffer.length() - 2, buffer.length());
buffer.append("</tt>");
}
// list the class methods of this class
buffer.append("<h2>" + getAnchorHtml(METHODS_ANCHOR, NavigatorMessages.getString("NAV_ClassMethods_Header")) + "</h2>");
buffer.append("<tt>");
count = typeClass.getNClassMethods();
for (int i = 0; i < count; i++) {
ClassMethod method = typeClass.getNthClassMethod(i);
NavAddress methodUrl = NavAddress.getAddress(method);
buffer.append("<b>" + getLinkHtml(methodUrl, NavAddressHelper.getDisplayText(owner, methodUrl, ScopedEntityNamingPolicy.UNQUALIFIED) + "</b> :: "));
buffer.append("<i>" + getTypeStringHtml(owner, method.getTypeExpr(), namingPolicy) + "</i>");
buffer.append("<br>");
}
// remove trailing <br>
buffer.delete(buffer.length() - 4, buffer.length());
buffer.append("</tt>");
// we have to search all instances in all modules to see if they're an instance of this class
CALWorkspace workspace = owner.getPerspective().getWorkspace();
List<ClassInstance> instances = new ArrayList<ClassInstance>();
List<TypeConstructor> types = new ArrayList<TypeConstructor>();
for (int n = 0, numMods = workspace.getNMetaModules(); n < numMods; n++) {
MetaModule metaModule = workspace.getNthMetaModule(n);
ModuleTypeInfo moduleTypeInfo = metaModule.getTypeInfo();
for (int i = 0, num = moduleTypeInfo.getNClassInstances(); i < num; i++) {
ClassInstance instance = moduleTypeInfo.getNthClassInstance(i);
if (instance.isUniversalRecordInstance()) {
continue;
}
if (instance.getTypeClass().getName().equals(typeClass.getName())) {
QualifiedName typeConsName = ((TypeConsApp)instance.getType()).getName();
MetaModule typeModule = owner.getPerspective().getMetaModule(typeConsName.getModuleName());
TypeConstructor typeCons = typeModule.getTypeInfo().getTypeConstructor(typeConsName.getUnqualifiedName());
types.add(typeCons);
instances.add(instance);