Buggy code:
public class ROIMeasures extends EzPlug implements MainListener , SequenceListener { private static File xlsFile ; private static WritableWorkbook workbook ; private final EzVarSequence currentSeq = new EzVarSequence ( "Current<seq2seq4repair_space>sequence" ) ; private final EzVarBoolean liveUpdate = new EzVarBoolean ( "Auto-update" , true ) ; private final ExcelTable table = new ExcelTable ( ) ; private final HashMap < ROI2D , Color > ROIColors = new HashMap < ROI2D , Color > ( ) ; @ Override protected void initialize ( ) { getUI ( ) . setParametersIOVisible ( false ) ; getUI ( ) . setRunButtonText ( "Update" ) ; getUI ( ) . setActionPanelVisible ( ( ! ( liveUpdate . getValue ( ) ) ) ) ; addEzComponent ( currentSeq ) ; addEzComponent ( liveUpdate ) ; table . setPreferredSize ( new Dimension ( 500 , 100 ) ) ; addComponent ( table ) ; try { ROIMeasures . xlsFile = File . createTempFile ( ( "icy_ROI_Measures_" + ( UUID . randomUUID ( ) . toString ( ) ) ) , "xls" ) ; ROIMeasures . workbook = Workbook . createWorkbook ( ROIMeasures . xlsFile ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw new EzException ( "ROI<seq2seq4repair_space>Meaasures:<seq2seq4repair_space>unable<seq2seq4repair_space>to<seq2seq4repair_space>initialize\n(see<seq2seq4repair_space>output<seq2seq4repair_space>console<seq2seq4repair_space>for<seq2seq4repair_space>details)" , true ) ; } EzButton buttonExport = new EzButton ( "Export<seq2seq4repair_space>to<seq2seq4repair_space>.CSV<seq2seq4repair_space>file..." , new ActionListener ( ) { @ Override public void actionPerformed ( ActionEvent e ) { JFileChooser jfc = new JFileChooser ( ) ; jfc . setFileFilter ( new FileFilter ( ) { @ Override public boolean accept ( File f ) { return ( f . isDirectory ( ) ) || ( f . getAbsolutePath ( ) . toLowerCase ( ) . endsWith ( ".csv" ) ) ; } @ Override public String getDescription ( ) { return ".CSV<seq2seq4repair_space>(Comma<seq2seq4repair_space>Separated<seq2seq4repair_space>Values)" ; } } ) ; if ( ( jfc . showSaveDialog ( getUI ( ) ) ) == ( JFileChooser . APPROVE_OPTION ) ) { try { ExportCSV . export ( ROIMeasures . workbook , jfc . getSelectedFile ( ) , false ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } } } } ) ; addEzComponent ( buttonExport ) ; for ( final Sequence sequence : Icy . getMainInterface ( ) . getSequences ( ) ) sequence . addListener ( this ) ; Icy . getMainInterface ( ) . addListener ( this ) ; currentSeq . addVarChangeListener ( new plugins . adufour . ezplug . EzVarListener < Sequence > ( ) { @ Override public void variableChanged ( EzVar < Sequence > source , Sequence sequence ) { table . updateSheet ( ( sequence == null ? null : ROIMeasures . getOrCreateSheet ( sequence ) ) ) ; <START_BUG> if ( sequence != null ) <END_BUG> update ( sequence ) ; getUI ( ) . repack ( false ) ; } } ) ; liveUpdate . addVarChangeListener ( new plugins . adufour . ezplug . EzVarListener < Boolean > ( ) { @ Override public void variableChanged ( EzVar < Boolean > source , Boolean newValue ) { getUI ( ) . setActionPanelVisible ( ( ! newValue ) ) ; } } ) ; try { currentSeq . setValue ( getFocusedSequence ( ) ) ; update ( currentSeq . getValue ( ) ) ; table . repaint ( ) ; } catch ( EzException e ) { } } private static synchronized WritableSheet getOrCreateSheet ( Sequence sequence ) { } private static String getSheetName ( Sequence s ) { } @ Override protected void execute ( ) { } private void update ( Sequence sequence ) { } private void update ( Sequence sequence , ROI2D roi ) { } @ Override public void clean ( ) { } public void viewerOpened ( MainEvent event ) { } public void viewerFocused ( MainEvent event ) { } public void viewerClosed ( MainEvent event ) { } public void sequenceOpened ( MainEvent event ) { } public void sequenceFocused ( MainEvent event ) { } public void sequenceClosed ( MainEvent event ) { } public void roiRemoved ( MainEvent event ) { } public void roiAdded ( MainEvent event ) { } public void pluginOpened ( MainEvent event ) { } public void pluginClosed ( MainEvent event ) { } public void painterRemoved ( MainEvent event ) { } public void painterAdded ( MainEvent event ) { } @ Override public void sequenceClosed ( Sequence sequence ) { } @ Override public void sequenceChanged ( SequenceEvent sequenceEvent ) { } }

Fix:
if ( ( sequence != null ) && ( ( sequence . getFirstViewer ( ) ) != null ) )