Skip to content
Snippets Groups Projects
Commit c94ef5b7 authored by buczekp's avatar buczekp
Browse files

[LMS-1194] fixed reordering of property type assignments

SVN: 13090
parent ce0d01c0
No related branches found
No related tags found
No related merge requests found
...@@ -179,6 +179,9 @@ public class PropertyTypeAssignmentGrid extends ...@@ -179,6 +179,9 @@ public class PropertyTypeAssignmentGrid extends
private final IDelegatedAction postRegistrationCallback; private final IDelegatedAction postRegistrationCallback;
// < entity type, list of etpts assigned to this entity type >
private Map<EntityType, List<EntityTypePropertyType<?>>> entityTypePropertyTypes;
private PropertyTypeAssignmentGrid(final IViewContext<ICommonClientServiceAsync> viewContext) private PropertyTypeAssignmentGrid(final IViewContext<ICommonClientServiceAsync> viewContext)
{ {
super(viewContext, BROWSER_ID, GRID_ID, super(viewContext, BROWSER_ID, GRID_ID,
...@@ -292,24 +295,29 @@ public class PropertyTypeAssignmentGrid extends ...@@ -292,24 +295,29 @@ public class PropertyTypeAssignmentGrid extends
private EntityTypePropertyTypeSelectionWidget createETPTSelectionWidget() private EntityTypePropertyTypeSelectionWidget createETPTSelectionWidget()
{ {
final EntityType entityType = etpt.getEntityType(); final EntityType entityType = etpt.getEntityType();
final List<EntityTypePropertyType<?>> all = getPropertyTypes(entityType); // create a new list of items from all etpts assigned to entity type
final List<EntityTypePropertyType<?>> all =
new ArrayList<EntityTypePropertyType<?>>();
all.add(null); // null will be transformed into '(top)'
String initialPropertyTypeCodeOrNull = null;
String previousPropertyTypeCodeOrNull = String previousPropertyTypeCodeOrNull =
EntityTypePropertyTypeSelectionWidget.TOP_ITEM_CODE; EntityTypePropertyTypeSelectionWidget.TOP_ITEM_CODE;
for (int i = 0; i < all.size(); i++) for (EntityTypePropertyType<?> currentETPT : getPropertyTypes(entityType))
{ {
final String currentPropertyTypeCode = final String currentPropertyTypeCode =
all.get(i).getPropertyType().getCode(); currentETPT.getPropertyType().getCode();
if (propertyTypeCode.equals(currentPropertyTypeCode)) if (propertyTypeCode.equals(currentPropertyTypeCode) == false)
{
all.add(currentETPT);
previousPropertyTypeCodeOrNull = currentPropertyTypeCode;
} else
{ {
all.remove(i); initialPropertyTypeCodeOrNull = previousPropertyTypeCodeOrNull;
break;
} }
previousPropertyTypeCodeOrNull = currentPropertyTypeCode;
} }
all.add(0, null); // null will be transformed into '(top)'
final EntityTypePropertyTypeSelectionWidget result = final EntityTypePropertyTypeSelectionWidget result =
new EntityTypePropertyTypeSelectionWidget(viewContext, getId(), all, new EntityTypePropertyTypeSelectionWidget(viewContext, getId(), all,
previousPropertyTypeCodeOrNull); initialPropertyTypeCodeOrNull);
FieldUtil.setMandatoryFlag(result, true); FieldUtil.setMandatoryFlag(result, true);
return result; return result;
} }
...@@ -389,8 +397,6 @@ public class PropertyTypeAssignmentGrid extends ...@@ -389,8 +397,6 @@ public class PropertyTypeAssignmentGrid extends
PropertyTypeAssignmentColDefKind.ENTITY_KIND }); PropertyTypeAssignmentColDefKind.ENTITY_KIND });
} }
private Map<EntityType, List<EntityTypePropertyType<?>>> entityTypePropertyTypes;
private List<EntityTypePropertyType<?>> getPropertyTypes(EntityType entityType) private List<EntityTypePropertyType<?>> getPropertyTypes(EntityType entityType)
{ {
return entityTypePropertyTypes.get(entityType); return entityTypePropertyTypes.get(entityType);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment