*
* @param enumName enumeration name
* @return true if specified enumeration exists; false if not
*/
private boolean retrieveEnumerationValues(String enumName) {
ModuleTypeInfo workingModuleTypeInfo = perspective.getWorkingModuleTypeInfo();
TypeConstructor typeCons = workingModuleTypeInfo.getTypeConstructor(enumName);
if (typeCons != null) {
((DefaultListModel)enumListControl.getModel()).clear();
if(typeCons.getScope() == Scope.PUBLIC) {
publicButton.doClick();
} else {
privateButton.doClick();
}
int constructors = typeCons.getNDataConstructors();
for (int i = 0; i < constructors; i++) {
QualifiedName constructorName = typeCons.getNthDataConstructor(i).getName();
((DefaultListModel)enumListControl.getModel()).addElement(constructorName.getUnqualifiedName());
}
// We need to determine whether the existing enumeration has only a derived Eq instance,
// or the full complement of derived instances (i.e. Eq, Ord, Bounded, Enum), so that
// the correct selection can be shown in the derived instances combo box.
TypeClass ordTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Ord);
ClassInstance ordInstance = workingModuleTypeInfo.getVisibleClassInstance(ordTypeClass, typeCons);
TypeClass boundedTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Bounded);
ClassInstance boundedInstance = workingModuleTypeInfo.getVisibleClassInstance(boundedTypeClass, typeCons);
TypeClass enumTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Enum);
ClassInstance enumInstance = workingModuleTypeInfo.getVisibleClassInstance(enumTypeClass, typeCons);
if (ordInstance == null && boundedInstance == null && enumInstance == null) {
getDerivedInstancesField().setSelectedItem(DerivedInstancesOption.EQ_ONLY_DERIVED_INSTANCES_OPTION);
} else {
getDerivedInstancesField().setSelectedItem(DerivedInstancesOption.EQ_ORD_BOUNDED_ENUM_DERIVED_INSTANCES_OPTION);