@Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int rowNum = table.getSelectedRow(); if (rowNum >= 0) { // get table model PeptideSpeciesPSMTableModel pepTableModel = (PeptideSpeciesPSMTableModel) table.getModel(); // get spectrum reference column int identColNum = pepTableModel.getColumnIndex(PeptideTableHeader.IDENTIFICATION_ID.getHeader()); int peptideColNum = pepTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_ID.getHeader()); // get spectrum id int modelRowIndex = table.convertRowIndexToModel(rowNum); Comparable identId = (Comparable) pepTableModel.getValueAt(modelRowIndex, identColNum); Comparable peptideId = (Comparable) pepTableModel.getValueAt(modelRowIndex, peptideColNum); logger.debug( "Peptide table selection: Protein id: " + identId + " Peptide Id: " + peptideId); // fire a background task to retrieve peptide if (peptideId != null && identId != null) { // publish the event to local event bus EventService eventBus = ContainerEventServiceFinder.getEventService(PeptidePSMPane.this); eventBus.publish(new PSMEvent(PeptidePSMPane.this, controller, identId, peptideId)); } } } }
@Override public void subscribeToEventBus(EventService eventBus) { if (eventBus == null) { eventBus = ContainerEventServiceFinder.getEventService(this); } peptideSpeciesEventSubscriber = new PeptideSpeciesEventSubscriber(psmTable); eventBus.subscribe(PeptideSpeciesEvent.class, peptideSpeciesEventSubscriber); changeRankingThresholdEventSubscriber = new ChangeRankingThresholdEventSubscriber(psmTable); eventBus.subscribe(ChangeRankingThresholdEvent.class, changeRankingThresholdEventSubscriber); }