<commit_before>package scoutmgr.client.application.admin.badges;

import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.proxy.NavigationEvent;
import com.gwtplatform.mvp.client.proxy.NavigationHandler;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import org.realityforge.replicant.client.EntityRepository;
import scoutmgr.client.entity.ScoutLevel;
import scoutmgr.client.place.NameTokens;

public class BadgeLevelPresenter
  extends PresenterWidget<BadgeLevelPresenter.View>
  implements NavigationHandler, BadgeLevelUiHandlers
{
  interface View
    extends com.gwtplatform.mvp.client.View, HasUiHandlers<BadgeLevelUiHandlers>
  {
    void setBadgeLevel( ScoutLevel level );
  }

  @Inject
  private PlaceManager _placeManager;

  @Inject
  private EntityRepository _entityRepository;

  @Inject
  BadgeLevelPresenter( final EventBus eventBus,
                       final View view )
  {
    super( eventBus, view );
    getView().setUiHandlers( this );
  }

  @Override
  protected void onBind()
  {
    super.onBind();
    addRegisteredHandler( NavigationEvent.getType(), this );
  }

  @Override
  public void onNavigation( final NavigationEvent navigationEvent )
  {
    if ( NameTokens.ADMIN_BADGES_LEVEL.equals( navigationEvent.getRequest().getNameToken()))
    {
      final String level = navigationEvent.getRequest().getParameter( "level", null );
      getView().setBadgeLevel( _entityRepository.findByID( ScoutLevel.class, level ) );
    }
  }
}<commit_msg>Navigate to the selected scout level, rather than the first.<commit_after>package scoutmgr.client.application.admin.badges;

import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.proxy.NavigationEvent;
import com.gwtplatform.mvp.client.proxy.NavigationHandler;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import java.util.ArrayList;
import org.realityforge.replicant.client.EntityRepository;
import scoutmgr.client.entity.ScoutLevel;
import scoutmgr.client.place.NameTokens;

public class BadgeLevelPresenter
  extends PresenterWidget<BadgeLevelPresenter.View>
  implements NavigationHandler, BadgeLevelUiHandlers
{
  interface View
    extends com.gwtplatform.mvp.client.View, HasUiHandlers<BadgeLevelUiHandlers>
  {
    void setBadgeLevel( ScoutLevel level );
  }

  @Inject
  private PlaceManager _placeManager;

  @Inject
  private EntityRepository _entityRepository;

  @Inject
  BadgeLevelPresenter( final EventBus eventBus,
                       final View view )
  {
    super( eventBus, view );
    getView().setUiHandlers( this );
  }

  @Override
  protected void onBind()
  {
    super.onBind();
    addRegisteredHandler( NavigationEvent.getType(), this );
  }

  @Override
  public void onNavigation( final NavigationEvent navigationEvent )
  {
    if ( NameTokens.ADMIN_BADGES_LEVEL.equals( navigationEvent.getRequest().getNameToken() ) )
    {
      final String level = navigationEvent.getRequest().getParameter( "level", null );
      navigateToBadgeLevel( level );
    }
  }

  private void navigateToBadgeLevel( final String level )
  {
    final ArrayList<ScoutLevel> scoutLevels = _entityRepository.findAll( ScoutLevel.class );
    for ( final ScoutLevel scoutLevel : scoutLevels )
    {
      if ( scoutLevel.getCode().equals( level ) )
      {
        getView().setBadgeLevel( scoutLevel );
        return;
      }
    }
    getView().setBadgeLevel( null );
  }

}
{'fraction_non_alphanumeric': 0.09355621461310326, 'fraction_numerical': 0.0, 'mean_word_length': 4.254957507082153, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5836716', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1125, 'n_words': 209}