When items are updated (redrawn), redo the selection area, so that the sum potentially updates.
[#211 state:resolved]
- M jbidwatcher/trunk/src/com/jbidwatcher/ui/AuctionsUIModel.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/ui/table/TableSorter.java view
| 778 | 780 | |
|---|---|---|
| 22 | 22 | import javax.swing.event.ListSelectionEvent; |
| 23 | 23 | import javax.swing.event.ListSelectionListener; |
| 24 | 24 | import javax.swing.event.TableModelEvent; |
| 25 | import javax.swing.event.TableModelListener; | |
| 25 | 26 | import javax.swing.table.TableCellRenderer; |
| 26 | 27 | import javax.swing.table.TableColumn; |
| 27 | 28 | import java.awt.*; |
| --- | --- | |
| 131 | 132 | jp2.add(ButtonMaker.makeButton("icons/xml.png", "Show RSS feed information", "RSS", tableContextMenu, true), BorderLayout.WEST); |
| 132 | 133 | _table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
| 133 | 134 | public void valueChanged(ListSelectionEvent event) { |
| 134 | int[] rowList = _table.getSelectedRows(); | |
| 135 | if(rowList.length == 0) { | |
| 136 | _prices.setText(" "); | |
| 137 | } else { | |
| 138 | String total = sum(rowList); | |
| 139 | if(total != null) { | |
| 140 | _prices.setText(rowList.length + " items, price total: " + total); | |
| 141 | } else { | |
| 142 | _prices.setText(" "); | |
| 143 | } | |
| 144 | } | |
| 135 | updateSum(); | |
| 145 | 136 | } |
| 146 | 137 | }); |
| 138 | _tSort.addTableModelListener(new TableModelListener() { | |
| 139 | public void tableChanged(TableModelEvent tableModelEvent) { | |
| 140 | updateSum(); | |
| 141 | } | |
| 142 | }); | |
| 147 | 143 | return jp2; |
| 148 | 144 | } |
| 149 | 145 | |
| 146 | private void updateSum() { | |
| 147 | int[] rowList = _table.getSelectedRows(); | |
| 148 | if(rowList.length == 0) { | |
| 149 | _prices.setText(" "); | |
| 150 | } else { | |
| 151 | String total = sum(rowList); | |
| 152 | if(total != null) { | |
| 153 | _prices.setText(rowList.length + " items, price total: " + total); | |
| 154 | } else { | |
| 155 | _prices.setText(" "); | |
| 156 | } | |
| 157 | } | |
| 158 | } | |
| 159 | ||
| 150 | 160 | /** |
| 151 | 161 | * @brief Pick and return a value from the entry that best describes |
| 152 | 162 | * how much COULD be spent on it by the buyer. |
| 609 | 780 | |
|---|---|---|
| 220 | 220 | if (myRow != -1) { |
| 221 | 221 | SwingUtilities.invokeLater(new Runnable() { |
| 222 | 222 | public void run() { |
| 223 | Selection save = new Selection(_table, _sorted); | |
| 223 | 224 | int row = m_tm.findRow(updated); |
| 224 | 225 | _table.tableChanged(new TableModelEvent(sorter, row)); |
| 226 | restoreSelection(save); | |
| 225 | 227 | } |
| 226 | 228 | }); |
| 227 | 229 | } |
