* @param metadata the metadata to get HTML for
* @return the HTML for type constructor metadata specific information
*/
private static String getTypeConstructorMetadataHtml(NavFrameOwner owner, TypeConstructorMetadata metadata) {
TypeConstructor typeCons = (TypeConstructor) owner.getPerspective().getWorkspace().getScopedEntity(metadata.getFeatureName());
StringBuilder buffer = new StringBuilder();
ScopedEntityNamingPolicy namingPolicy = new UnqualifiedUnlessAmbiguous(owner.getPerspective().getWorkingModuleTypeInfo());
// list the data constructors for this type
buffer.append("<h2>" + getAnchorHtml(CONSTRUCTORS_ANCHOR, NavigatorMessages.getString("NAV_Constructors_Header")) + "</h2>");
int count = typeCons.getNDataConstructors();
if (count == 0) {
buffer.append(NavigatorMessages.getString("NAV_NoValue"));
} else {
buffer.append("<tt>");
for (int i = 0; i < count; i++) {
DataConstructor dataCons = typeCons.getNthDataConstructor(i);
NavAddress dataConsUrl = NavAddress.getAddress(dataCons);
String dataConsLink = getLinkHtml(dataConsUrl, NavAddressHelper.getDisplayText(owner, dataConsUrl, ScopedEntityNamingPolicy.UNQUALIFIED));
buffer.append("<b>" + dataConsLink + "</b> :: ");
buffer.append("<i>" + getTypeStringHtml(owner, dataCons.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 type
//todoBI the above comment is false. Need to just search all module imported, either directly or indirectly,
//into the module in which the instance is defined.
CALWorkspace workspace = owner.getPerspective().getWorkspace();
List<TypeClass> classes = new ArrayList<TypeClass>();
List<ClassInstance> instances = new ArrayList<ClassInstance>();
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.isTypeConstructorInstance() &&
((ClassInstanceIdentifier.TypeConstructorInstance)instance.getIdentifier()).getTypeConsName().equals(typeCons.getName())) {
classes.add(instance.getTypeClass());
instances.add(instance);
}
}
}