@Test public void testCreateComponent() throws Exception { ParameterValues paramValues = mock( ParameterValues.class ); doReturn( "key_0" ).when( updateContext ).getParameterValue( PARAM_NAME ); doReturn( paramValues ).when( listParameter ).getValues( parameterContext ); doReturn( 3 ).when( paramValues ).getRowCount(); doReturn( "key_0" ).when( paramValues ).getKeyValue( 0 ); doReturn( new BigDecimal( 1.1 ) ).when( paramValues ).getKeyValue( 1 ); doReturn( new Date() ).when( paramValues ).getKeyValue( 2 ); doReturn( "val_0" ).when( paramValues ).getTextValue( 0 ); doReturn( "val_1" ).when( paramValues ).getTextValue( 1 ); doReturn( "val_2" ).when( paramValues ).getTextValue( 1 ); comp = new DropDownParameterComponent( listParameter, updateContext, parameterContext ); verify( updateContext ).addChangeListener( any( ChangeListener.class ) ); comp.initialize(); assertThat( (String) comp.getSelectedItem(), is( equalTo( "val_0" ) ) ); doReturn( new BigDecimal( 1.0 ) ).when( updateContext ).getParameterValue( PARAM_NAME ); comp.initialize(); assertThat( (String) comp.getSelectedItem(), is( nullValue() ) ); doReturn( new Date() ).when( updateContext ).getParameterValue( PARAM_NAME ); comp.initialize(); assertThat( (String) comp.getSelectedItem(), is( nullValue() ) ); doReturn( null ).when( updateContext ).getParameterValue( PARAM_NAME ); comp.initialize(); assertThat( (String) comp.getSelectedItem(), is( nullValue() ) ); }
public void initialize() throws ReportDataFactoryException { adjustingToExternalInput = true; try { final KeyedComboBoxModel<Object, Object> keyedComboBoxModel = DefaultParameterComponentFactory.createModel( listParameter, parameterContext ); final Object value = updateContext.getParameterValue( listParameter.getName() ); setSelectedValue( value, keyedComboBoxModel ); setModel( keyedComboBoxModel ); } finally { adjustingToExternalInput = false; } }
DropDownParameterComponent extends JComboBox implements ParameterComponent { public void initialize() throws ReportDataFactoryException { adjustingToExternalInput = true; try { final KeyedComboBoxModel<Object, Object> keyedComboBoxModel = DefaultParameterComponentFactory.createModel( listParameter, parameterContext ); final Object value = updateContext.getParameterValue( listParameter.getName() ); setSelectedValue( value, keyedComboBoxModel ); setModel( keyedComboBoxModel ); } finally { adjustingToExternalInput = false; } } }
DropDownParameterComponent extends JComboBox implements ParameterComponent { public void initialize() throws ReportDataFactoryException { adjustingToExternalInput = true; try { final KeyedComboBoxModel<Object, Object> keyedComboBoxModel = DefaultParameterComponentFactory.createModel( listParameter, parameterContext ); final Object value = updateContext.getParameterValue( listParameter.getName() ); setSelectedValue( value, keyedComboBoxModel ); setModel( keyedComboBoxModel ); } finally { adjustingToExternalInput = false; } } DropDownParameterComponent( final ListParameter listParameter, final ParameterUpdateContext updateContext,
      final ParameterContext parameterContext ); }
DropDownParameterComponent extends JComboBox implements ParameterComponent { public void initialize() throws ReportDataFactoryException { adjustingToExternalInput = true; try { final KeyedComboBoxModel<Object, Object> keyedComboBoxModel = DefaultParameterComponentFactory.createModel( listParameter, parameterContext ); final Object value = updateContext.getParameterValue( listParameter.getName() ); setSelectedValue( value, keyedComboBoxModel ); setModel( keyedComboBoxModel ); } finally { adjustingToExternalInput = false; } } DropDownParameterComponent( final ListParameter listParameter, final ParameterUpdateContext updateContext,
      final ParameterContext parameterContext ); void initialize(); JComponent getUIComponent(); }
DropDownParameterComponent extends JComboBox implements ParameterComponent { public void initialize() throws ReportDataFactoryException { adjustingToExternalInput = true; try { final KeyedComboBoxModel<Object, Object> keyedComboBoxModel = DefaultParameterComponentFactory.createModel( listParameter, parameterContext ); final Object value = updateContext.getParameterValue( listParameter.getName() ); setSelectedValue( value, keyedComboBoxModel ); setModel( keyedComboBoxModel ); } finally { adjustingToExternalInput = false; } } DropDownParameterComponent( final ListParameter listParameter, final ParameterUpdateContext updateContext,
      final ParameterContext parameterContext ); void initialize(); JComponent getUIComponent();  }