/** * Factory method for creating a "run analysis" button that -upon execution- * creates and starts the tool worker. * * @return a "run analysis" button, with keyboard shortcuts enabled, never * <code>null</code>. */ public static JButton createRunAnalysisButton( final ToolDialog aToolDialog ) { final RunAnalysisAction action = new RunAnalysisAction( aToolDialog ); final JButton runButton = new JButton( action ); SwingComponentUtils.registerKeystroke( runButton, action, "RUN-ANALYSIS" ); return runButton; }
/** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed( final ActionEvent aEvent ) { final String name = ( String )getValue( NAME ); if ( "Abort".equals( name ) ) { cancelToolTask(); putValue( NAME, "Analyze" ); } else { if ( startToolTask() ) { // Update the state of this action to denote it can also be used as an // abort button... putValue( NAME, "Abort" ); putValue( SHORT_DESCRIPTION, "Aborts current analysis..." ); putValue( ACCELERATOR_KEY, SwingComponentUtils.createMenuKeyMask( KeyEvent.VK_ESCAPE ) ); } } }
/** * Creates a new RunAnalysisAction instance. */ public RunAnalysisAction( final ToolDialog aToolDialog ) { super( "Analyze" ); restore(); this.toolDialog = aToolDialog; }