@Test public void testExportAction() { Icon smallIcon = mock( Icon.class ); Icon largeIcon = mock( Icon.class ); ArgumentCaptor<String> propCaptor = ArgumentCaptor.forClass( String.class ); doReturn( true ).when( actionPlugin ).isEnabled(); doNothing().when( actionPlugin ).addPropertyChangeListener( propCaptor.capture(), any( PropertyChangeListener.class ) ); doReturn( "Action name" ).when( actionPlugin ).getDisplayName(); doReturn( "Action description" ).when( actionPlugin ).getShortDescription(); doReturn( null ).when( actionPlugin ).getAcceleratorKey(); doReturn( 65 ).when( actionPlugin ).getMnemonicKey(); doReturn( smallIcon ).when( actionPlugin ).getSmallIcon(); doReturn( largeIcon ).when( actionPlugin ).getLargeIcon(); action = new ExportAction( actionPlugin, previewPane ); assertThat( action.isEnabled(), is( equalTo( true ) ) ); verify( actionPlugin ).addPropertyChangeListener( anyString(), any( PropertyChangeListener.class ) ); assertThat( propCaptor.getValue(), is( equalTo( "enabled" ) ) ); assertThat( (String) action.getValue( Action.NAME ), is( equalTo( "Action name" ) ) ); assertThat( (String) action.getValue( Action.SHORT_DESCRIPTION ), is( equalTo( "Action description" ) ) ); assertThat( action.getValue( Action.ACCELERATOR_KEY ), is( nullValue() ) ); assertThat( (Integer) action.getValue( Action.MNEMONIC_KEY ), is( equalTo( 65 ) ) ); assertThat( (Icon) action.getValue( Action.SMALL_ICON ), is( equalTo( smallIcon ) ) ); assertThat( (Icon) action.getValue( SwingCommonModule.LARGE_ICON_PROPERTY ), is( equalTo( largeIcon ) ) ); }
public ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ) { if ( actionPlugin == null ) { throw new NullPointerException(); } if ( previewPane == null ) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue( Action.NAME, actionPlugin.getDisplayName() ); putValue( Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription() ); putValue( Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey() ); putValue( Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey() ); putValue( Action.SMALL_ICON, actionPlugin.getSmallIcon() ); putValue( SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon() ); this.actionPlugin.addPropertyChangeListener( "enabled", new EnableChangeListener() ); setEnabled( actionPlugin.isEnabled() ); }
ExportAction extends AbstractAction { public ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ) { if ( actionPlugin == null ) { throw new NullPointerException(); } if ( previewPane == null ) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue( Action.NAME, actionPlugin.getDisplayName() ); putValue( Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription() ); putValue( Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey() ); putValue( Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey() ); putValue( Action.SMALL_ICON, actionPlugin.getSmallIcon() ); putValue( SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon() ); this.actionPlugin.addPropertyChangeListener( "enabled", new EnableChangeListener() ); setEnabled( actionPlugin.isEnabled() ); } }
ExportAction extends AbstractAction { public ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ) { if ( actionPlugin == null ) { throw new NullPointerException(); } if ( previewPane == null ) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue( Action.NAME, actionPlugin.getDisplayName() ); putValue( Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription() ); putValue( Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey() ); putValue( Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey() ); putValue( Action.SMALL_ICON, actionPlugin.getSmallIcon() ); putValue( SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon() ); this.actionPlugin.addPropertyChangeListener( "enabled", new EnableChangeListener() ); setEnabled( actionPlugin.isEnabled() ); } ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ); }
ExportAction extends AbstractAction { public ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ) { if ( actionPlugin == null ) { throw new NullPointerException(); } if ( previewPane == null ) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue( Action.NAME, actionPlugin.getDisplayName() ); putValue( Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription() ); putValue( Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey() ); putValue( Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey() ); putValue( Action.SMALL_ICON, actionPlugin.getSmallIcon() ); putValue( SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon() ); this.actionPlugin.addPropertyChangeListener( "enabled", new EnableChangeListener() ); setEnabled( actionPlugin.isEnabled() ); } ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ); void actionPerformed( final ActionEvent e ); }
ExportAction extends AbstractAction { public ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ) { if ( actionPlugin == null ) { throw new NullPointerException(); } if ( previewPane == null ) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue( Action.NAME, actionPlugin.getDisplayName() ); putValue( Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription() ); putValue( Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey() ); putValue( Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey() ); putValue( Action.SMALL_ICON, actionPlugin.getSmallIcon() ); putValue( SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon() ); this.actionPlugin.addPropertyChangeListener( "enabled", new EnableChangeListener() ); setEnabled( actionPlugin.isEnabled() ); } ExportAction( final ExportActionPlugin actionPlugin, final PreviewPane previewPane ); void actionPerformed( final ActionEvent e );  }