@Test public void testCreateModel() throws Exception { ListParameter parameter = mock( ListParameter.class ); ParameterContext parameterContext = mock( ParameterContext.class ); ParameterValues paramValues = mock( ParameterValues.class ); doReturn( paramValues ).when( parameter ).getValues( parameterContext ); doReturn( 2 ).when( paramValues ).getRowCount(); doReturn( "key_0" ).when( paramValues ).getKeyValue( 0 ); doReturn( "key_1" ).when( paramValues ).getKeyValue( 1 ); doReturn( "val_0" ).when( paramValues ).getTextValue( 0 ); doReturn( "val_1" ).when( paramValues ).getTextValue( 1 ); KeyedComboBoxModel<Object, Object> result = DefaultParameterComponentFactory.createModel( parameter, parameterContext ); assertThat( result, is( notNullValue() ) ); assertThat( result.getSize(), is( equalTo( 2 ) ) ); assertThat( (String) result.getKeyAt( 0 ), is( equalTo( "key_0" ) ) ); assertThat( (String) result.getElementAt( 0 ), is( equalTo( "val_0" ) ) ); assertThat( (String) result.getKeyAt( 1 ), is( equalTo( "key_1" ) ) ); assertThat( (String) result.getElementAt( 1 ), is( equalTo( "val_1" ) ) ); }
public static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter, final ParameterContext parameterContext ) throws ReportDataFactoryException { final ParameterValues paramValues = parameter.getValues( parameterContext ); final int count = paramValues.getRowCount(); final Object[] keys = new Object[count]; final Object[] values = new Object[count]; for ( int i = 0; i < count; i++ ) { final Object key = paramValues.getKeyValue( i ); keys[i] = key; values[i] = paramValues.getTextValue( i ); } final KeyedComboBoxModel<Object, Object> model = new KeyedComboBoxModel<Object, Object>(); model.setData( keys, values ); return model; }
DefaultParameterComponentFactory implements ParameterComponentFactory { public static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter, final ParameterContext parameterContext ) throws ReportDataFactoryException { final ParameterValues paramValues = parameter.getValues( parameterContext ); final int count = paramValues.getRowCount(); final Object[] keys = new Object[count]; final Object[] values = new Object[count]; for ( int i = 0; i < count; i++ ) { final Object key = paramValues.getKeyValue( i ); keys[i] = key; values[i] = paramValues.getTextValue( i ); } final KeyedComboBoxModel<Object, Object> model = new KeyedComboBoxModel<Object, Object>(); model.setData( keys, values ); return model; } }
DefaultParameterComponentFactory implements ParameterComponentFactory { public static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter, final ParameterContext parameterContext ) throws ReportDataFactoryException { final ParameterValues paramValues = parameter.getValues( parameterContext ); final int count = paramValues.getRowCount(); final Object[] keys = new Object[count]; final Object[] values = new Object[count]; for ( int i = 0; i < count; i++ ) { final Object key = paramValues.getKeyValue( i ); keys[i] = key; values[i] = paramValues.getTextValue( i ); } final KeyedComboBoxModel<Object, Object> model = new KeyedComboBoxModel<Object, Object>(); model.setData( keys, values ); return model; } DefaultParameterComponentFactory(); }
DefaultParameterComponentFactory implements ParameterComponentFactory { public static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter, final ParameterContext parameterContext ) throws ReportDataFactoryException { final ParameterValues paramValues = parameter.getValues( parameterContext ); final int count = paramValues.getRowCount(); final Object[] keys = new Object[count]; final Object[] values = new Object[count]; for ( int i = 0; i < count; i++ ) { final Object key = paramValues.getKeyValue( i ); keys[i] = key; values[i] = paramValues.getTextValue( i ); } final KeyedComboBoxModel<Object, Object> model = new KeyedComboBoxModel<Object, Object>(); model.setData( keys, values ); return model; } DefaultParameterComponentFactory(); ParameterComponent create( final ParameterDefinitionEntry entry, final ParameterContext parameterContext,
      final ParameterUpdateContext updateContext ); ParameterComponent createListParameter( final ListParameter listParameter,
      final ParameterContext parameterContext, final ParameterUpdateContext updateContext ); static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter,
      final ParameterContext parameterContext ); }
DefaultParameterComponentFactory implements ParameterComponentFactory { public static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter, final ParameterContext parameterContext ) throws ReportDataFactoryException { final ParameterValues paramValues = parameter.getValues( parameterContext ); final int count = paramValues.getRowCount(); final Object[] keys = new Object[count]; final Object[] values = new Object[count]; for ( int i = 0; i < count; i++ ) { final Object key = paramValues.getKeyValue( i ); keys[i] = key; values[i] = paramValues.getTextValue( i ); } final KeyedComboBoxModel<Object, Object> model = new KeyedComboBoxModel<Object, Object>(); model.setData( keys, values ); return model; } DefaultParameterComponentFactory(); ParameterComponent create( final ParameterDefinitionEntry entry, final ParameterContext parameterContext,
      final ParameterUpdateContext updateContext ); ParameterComponent createListParameter( final ListParameter listParameter,
      final ParameterContext parameterContext, final ParameterUpdateContext updateContext ); static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter,
      final ParameterContext parameterContext );  }