public void populateGroupsLegendByValidation ( final RolloutGroupsValidation validation , final List < RolloutGroupCreate > groups ) { loadingLabel . setVisible ( false ) ; if ( validation == null ) { return ; } final List < Long > targetsPerGroup = validation . getTargetsPerGroup ( ) ; final long unassigned = validation . getTotalTargets ( ) - validation . getTargetsInGroups ( ) ; final int labelsToUpdate = ( unassigned > 0 ) ? ( getGroupsWithoutToBeContinuedLabel ( groups . size ( ) ) - 1 ) : groupsLegend . getComponentCount ( ) ; for ( int i = 0 ; i < getGroupsWithoutToBeContinuedLabel ( groups . size ( ) ) ; i ++ ) { final Component component = groupsLegend . getComponent ( i ) ; final Label label = ( Label ) component ; if ( targetsPerGroup . size ( ) > i && groups . size ( ) > i && labelsToUpdate > i ) { final Long targetCount = targetsPerGroup . get ( i ) ; final String groupName = groups . get ( i ) . build ( ) . getName ( ) ; label . setValue ( getTargetsInGroupMessage ( targetCount , groupName ) ) ; label . setVisible ( true ) ; } else { label . setValue ( "" ) ; label . setVisible ( false ) ; } } showOrHideToBeContinueLabel ( groups ) ; if ( unassigned > 0 ) { unassignedTargetsLabel . setValue ( getTargetsInGroupMessage ( unassigned , "Unassigned" ) ) ; unassignedTargetsLabel . setVisible ( true ) ; } else { unassignedTargetsLabel . setValue ( "" ) ; unassignedTargetsLabel . setVisible ( false ) ; } }
Populates the legend based on a groups validation and a list of groups that is used for resolving their names . Positions of the groups in the groups list and the validation need to be in correct order . Can have unassigned targets that are displayed on top of the groups list which results in one group less to be displayed