avatar

780

When items are updated (redrawn), redo the selection area, so that the sum potentially updates.

[#211 state:resolved]

by mrs, 08 Feb, 2009 10:19 PM
778 780  
2222 import javax.swing.event.ListSelectionEvent;
2323 import javax.swing.event.ListSelectionListener;
2424 import javax.swing.event.TableModelEvent;
25 import javax.swing.event.TableModelListener;
2526 import javax.swing.table.TableCellRenderer;
2627 import javax.swing.table.TableColumn;
2728 import java.awt.*;
------
131132     jp2.add(ButtonMaker.makeButton("icons/xml.png", "Show RSS feed information", "RSS", tableContextMenu, true), BorderLayout.WEST);
132133     _table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
133134       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();
145136       }
146137     });
138     _tSort.addTableModelListener(new TableModelListener() {
139       public void tableChanged(TableModelEvent tableModelEvent) {
140         updateSum();
141       }
142     });
147143     return jp2;
148144   }
149145 
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 
150160   /**
151161    * @brief Pick and return a value from the entry that best describes
152162    * how much COULD be spent on it by the buyer.
609 780  
220220     if (myRow != -1) {
221221       SwingUtilities.invokeLater(new Runnable() {
222222         public void run() {
223           Selection save = new Selection(_table, _sorted);
223224           int row = m_tm.findRow(updated);
224225           _table.tableChanged(new TableModelEvent(sorter, row));
226           restoreSelection(save);
225227         }
226228       });
227229     }