public void actionPerformed( final ActionEvent e ) { if ( adjustingToExternalInput ) { return; } final Object theSource = e.getSource(); if ( theSource instanceof JComboBox ) { final JComboBox theComboBox = (JComboBox) theSource; final KeyedComboBoxModel theModel = (KeyedComboBoxModel) theComboBox.getModel(); updateContext.setParameterValue( key, theModel.getSelectedKey() ); } }
/** * Invoked when an action occurs. * * @param e * the event. */ public void actionPerformed( final ActionEvent e ) { final Double selected = (Double) source.getSelectedKey(); if ( selected != null ) { pane.setZoom( selected.doubleValue() ); } } }
/** * This method gets called when a bound property is changed. * * @param evt * A PropertyChangeEvent object describing the event source and the property that has changed. */ public void propertyChange( final PropertyChangeEvent evt ) { if ( "zoom".equals( evt.getPropertyName() ) == false ) { //$NON-NLS-1$ return; } final double zoom = getZoom(); pageDrawable.setZoom( zoom ); final KeyedComboBoxModel<Double, String> zoomModel = PreviewPane.this.getZoomModel(); zoomModel.setSelectedKey( new Double( zoom ) ); if ( zoomModel.getSelectedKey() == null ) { zoomModel.setSelectedItem( formatZoomText( zoom ) ); } drawablePanel.revalidate(); } }
@SuppressWarnings( "rawtypes" ) @Test public void testCheckActionListener() { ActionEvent e = mock( ActionEvent.class ); JComboBox box = mock( JComboBox.class ); KeyedComboBoxModel theModel = mock( KeyedComboBoxModel.class ); doReturn( box ).when( e ).getSource(); doReturn( theModel ).when( box ).getModel(); doReturn( "key" ).when( theModel ).getSelectedKey(); comp = new DropDownParameterComponent( listParameter, updateContext, parameterContext ); assertThat( comp.getActionListeners().length, is( equalTo( 1 ) ) ); ActionListener listener = comp.getActionListeners()[0]; listener.actionPerformed( e ); verify( updateContext ).setParameterValue( PARAM_NAME, "key" ); }
protected void updateEpson9Encoding() { final PrinterSpecification spec = (PrinterSpecification) epson9Printers.getSelectedKey(); if ( spec == null ) { encodingSelector.setEncodings( PrinterSpecificationManager.getGenericPrinter(), getGuiContext().getLocale() ); } else { encodingSelector.setEncodings( spec, getGuiContext().getLocale() ); } }
protected void updateEpson24Encoding() { final PrinterSpecification spec = (PrinterSpecification) epson9Printers.getSelectedKey(); if ( spec == null ) { encodingSelector.setEncodings( PrinterSpecificationManager.getGenericPrinter(), getGuiContext().getLocale() ); } else { encodingSelector.setEncodings( spec, getGuiContext().getLocale() ); } }
applyDefinedDimension( configuration ); final Double key = zoomModel.getSelectedKey(); zoomModel.clear(); for ( int i = 0; i < PreviewPane.ZOOM_FACTORS.length; i++ ) {