avatar

597

If there are less than 2 columns in any given tab, freak out and fill it in with defaults... Also log that information. ALSO don't try to make JBidwatcher 0x0 pixels if the display.cfg file is corrupt. Hopefully display.cfg will be corrupted less, now that we're closing the file regularly.

by mrs, 12 Aug, 2008 10:32 PM
564 597  
44 import com.jbidwatcher.util.config.JConfig;
55 import com.jbidwatcher.util.config.ErrorManagement;
66 import com.jbidwatcher.util.Constants;
7 import com.jbidwatcher.util.queue.SuperQueue;
78 
89 import javax.swing.*;
910 import javax.swing.table.TableModel;
------
139140     }
140141   }
141142 
143   private static final String[][] DEFAULT_COLUMNS = new String[][]{
144           {"Number", "100"},
145           {"Current", "89"},
146           {"Max", "62"},
147           {"Description", "297"},
148           {"Time left", "127"},
149           {"Status", "67"},
150           {"Seller", "147"},
151   };
152 
153   private static int notify_delay = 0;
154 
142155   private void loadColumnSettings(String prefix, TableModel atm) {
143156     String curColumnName = "";
144157 
------
175188       ErrorManagement.logDebug("No longer loading column widths from configuration.");
176189     }
177190 
191     //  If there are less than 2 columns, freak out and refresh.
192     if(initialToSaved.size() < 2) {
193       SuperQueue.getInstance().preQueue("NOTIFY Column data for '" + prefix + "' was corrupted; resetting to defaults", "Swing", System.currentTimeMillis() + Constants.ONE_SECOND * 12 + notify_delay);
194       ErrorManagement.logMessage("Column data for '\" + prefix + \"' was corrupted; resetting to defaults");
195       notify_delay += 2 * Constants.ONE_SECOND;
196       for(String[] column : DEFAULT_COLUMNS) {
197         if(column[0].equals("Time left") && prefix.equals("complete")) continue;
198 
199         TableColumn tc = new TableColumn(TableColumnController.getInstance().getColumnNumber(column[0]));
200         tc.setHeaderValue(column[0]);
201         tc.setIdentifier(column[0]);
202         addColumn(tc);
203         getColumn(column[0]).setPreferredWidth(Integer.parseInt(column[1]));
204         getColumn(column[0]).setWidth(Integer.parseInt(column[1]));
205       }
206     }
207 
178208     if(!initialToSaved.isEmpty()) {
179209       for (String colName : initialToSaved.keySet()) {
180210         int colFrom = getColumnModel().getColumnIndex(colName);
595 597  
448448         width = Integer.parseInt(displayProps.getProperty("width", "0"));
449449 
450450         //  If either is invalid, reset it via later code.
451         if(height < 0 || width < 0) {
451         if(height <= 0 || width <= 0) {
452452           height = 0;
453453           width = 0;
454454           setOwnProps = true;