|
8 | 8 |
|
9 | 9 | import javax.swing.*; |
10 | 10 | import javax.swing.border.Border; |
| 11 | +import javax.swing.event.ListSelectionEvent; |
| 12 | +import javax.swing.event.ListSelectionListener; |
11 | 13 | import javax.swing.plaf.ColorUIResource; |
12 | 14 | import javax.swing.table.DefaultTableModel; |
13 | 15 | import javax.swing.table.JTableHeader; |
@@ -615,6 +617,44 @@ private void MakeSidePanel(ArrayList<String> indexlist){ |
615 | 617 | mainFrame.repaint(); |
616 | 618 | } |
617 | 619 |
|
| 620 | + |
| 621 | + /** |
| 622 | + * SharedListSelectionHandler handles the selection in the ORF table |
| 623 | + */ |
| 624 | + class SharedListSelectionHandler implements ListSelectionListener { |
| 625 | + /** |
| 626 | + * valueChanged makes an indexlist of all de IDs of the selected rows when the user stops changing the selection |
| 627 | + * @param e action |
| 628 | + */ |
| 629 | + public void valueChanged(ListSelectionEvent e) { |
| 630 | + ArrayList<String> indexlist = new ArrayList<>(); |
| 631 | + ListSelectionModel lsm = (ListSelectionModel) e.getSource(); |
| 632 | + |
| 633 | + // boolean to check if the user is done with changing the selection |
| 634 | + boolean isAdjusting = e.getValueIsAdjusting(); |
| 635 | + if (lsm.isSelectionEmpty()) { |
| 636 | + } else { |
| 637 | + // if no more changes are made to the selection get the index of the row selected |
| 638 | + if (!isAdjusting) { |
| 639 | + int minIndex = lsm.getMinSelectionIndex(); |
| 640 | + int maxIndex = lsm.getMaxSelectionIndex(); |
| 641 | + // for all selected rows get the ID out of column 4 and put it in the index list |
| 642 | + for (int i = minIndex; i <= maxIndex; i++) { |
| 643 | + if (lsm.isSelectedIndex(i)) { |
| 644 | + String index = (String) table.getValueAt(i, 4); |
| 645 | + System.out.println(index); |
| 646 | + indexlist.add(index); |
| 647 | + |
| 648 | + } |
| 649 | + } |
| 650 | + // make the sidePanel |
| 651 | + MakeSidePanel(indexlist); |
| 652 | + } |
| 653 | + |
| 654 | + } |
| 655 | + } |
| 656 | + } |
| 657 | + |
618 | 658 | /** |
619 | 659 | * MenuItemlistner handles the clicks on the menu |
620 | 660 | */ |
|
0 commit comments