Move the RSS button down to the status bar, along with the price summary information. Fix up the status text area to fit itself between the two. Remove the status line from individual tabs, and generally clean up the status bar handling.

by mrs, 08 Nov, 2009 09:21 AM
1026 1031  
55 import com.jbidwatcher.util.db.ActiveRecord;
66 import com.jbidwatcher.util.db.Database;
77 import com.jbidwatcher.util.Constants;
8 import com.jbidwatcher.util.xml.XMLElement;
89 import com.jbidwatcher.auction.server.AuctionStats;
910 import com.jbidwatcher.auction.server.AuctionServerManager;
1011 import com.jbidwatcher.auction.AuctionEntry;
1112 import com.jbidwatcher.ui.util.JMouseAdapter;
1213 import com.jbidwatcher.ui.util.OptionUI;
14 import com.jbidwatcher.ui.util.ButtonMaker;
1315 import com.jbidwatcher.ui.*;
1416 import com.jbidwatcher.platform.Platform;
1517 import com.jbidwatcher.search.SearchManager;
1618 
1719 import javax.swing.*;
18 import java.awt.event.WindowListener;
19 import java.awt.event.WindowAdapter;
20 import java.awt.event.WindowEvent;
20 import javax.swing.border.Border;
21 import java.awt.event.*;
2122 import java.awt.BorderLayout;
2223 import java.awt.Dimension;
24 import java.awt.Color;
2325 import java.net.URL;
2426 import java.util.Properties;
2527 
------
3335  */
3436 class MacFriendlyFrame extends JFrame implements com.apple.mrj.MRJQuitHandler, com.apple.mrj.MRJAboutHandler, com.apple.mrj.MRJPrefsHandler {
3537   private JLabel mStatusBar;
38   private JLabel mPrices;
3639 
3740   /**
3841    * @brief Constructs a new window frame, with all the sorted tables,
------
6164 
6265     JPanel headerBar = JBidToolBar.getInstance().buildHeaderBar(this, tabManager);
6366 
64     mStatusBar = new JLabel("Ready!", SwingConstants.LEFT);
67     JPanel statusPane = buildStatusLine(tabManager);
68 
6569     getContentPane().add(tabManager.getTabs());
66     getContentPane().add(mStatusBar, BorderLayout.SOUTH);
70     getContentPane().add(statusPane, BorderLayout.SOUTH);
6771     getContentPane().add(headerBar, BorderLayout.NORTH);
6872 
6973     pack();
------
8690     });
8791   }
8892 
93   private JPanel buildStatusLine(JTabManager tabManager) {
94     final JPanel statusPane = new JPanel();
95     Border myBorder = BorderFactory.createCompoundBorder(
96         BorderFactory.createCompoundBorder(
97             BorderFactory.createEmptyBorder(0, 2, 0, 2),
98             BorderFactory.createMatteBorder(1, 0, 0, 0, Color.DARK_GRAY)),
99         BorderFactory.createEmptyBorder(1, 5, 1, 5));
100     statusPane.setBorder(myBorder);
101     statusPane.setLayout(new BoxLayout(statusPane, BoxLayout.X_AXIS));
102 
103     JButton rssButton = ButtonMaker.makeButton("icons/xml.png", "Show RSS feed information", "RSS", tabManager, true);
104     rssButton.setMinimumSize(new Dimension(rssButton.getIcon().getIconWidth()+2, rssButton.getIcon().getIconHeight()));
105     statusPane.add(rssButton);
106 
107     JSeparator vert1 = new JSeparator(SwingConstants.VERTICAL);
108     vert1.setForeground(Color.DARK_GRAY);
109     vert1.setMinimumSize(new Dimension(10, 5));
110     vert1.setMaximumSize(new Dimension(10, 20));
111     statusPane.add(vert1);
112 
113     mStatusBar = new JLabel("Ready!");
114 //    mStatusBar.setBorder(BorderFactory.createCompoundBorder(
115 //        BorderFactory.createLineBorder(Color.red),
116 //        mStatusBar.getBorder()));
117     final Dimension statusBarSize = new Dimension(600, 16);
118 //    mStatusBar.setPreferredSize(statusBarSize);
119     mStatusBar.setMaximumSize(statusBarSize);
120     mStatusBar.setMinimumSize(statusBarSize);
121     mStatusBar.setPreferredSize(statusBarSize);
122     statusPane.add(mStatusBar);
123 
124     statusPane.add(Box.createHorizontalGlue());
125 
126     JSeparator vert2 = new JSeparator(SwingConstants.VERTICAL);
127     vert2.setForeground(Color.DARK_GRAY);
128     vert2.setMinimumSize(new Dimension(10, 5));
129     vert2.setMaximumSize(new Dimension(10, 20));
130     statusPane.add(vert2);
131 
132     mPrices = new JLabel(" ");
133     Dimension priceSize = new Dimension(300, 16);
134     mPrices.setMinimumSize(priceSize);
135     mPrices.setPreferredSize(priceSize);
136     statusPane.add(mPrices);
137 
138     statusPane.add(Box.createHorizontalStrut(10));
139 
140     final int baseSize = 14 + rssButton.getIcon().getIconWidth() + 2 + 10 + 10 + 300 + 10;
141     addComponentListener(new ComponentAdapter() {
142       public void componentResized(ComponentEvent e) {
143         int textWidthAllowed = statusPane.getWidth() - baseSize;
144         statusBarSize.setSize(textWidthAllowed - 15, 16);
145         mStatusBar.setMaximumSize(statusBarSize);
146         mStatusBar.setMinimumSize(statusBarSize);
147         mStatusBar.setPreferredSize(statusBarSize);
148       }
149     });
150 
151     return statusPane;
152   }
153 
89154   public void handleQuit() {
90155     if (!(JConfig.queryConfiguration("prompt.snipe_quit", "false").equals("true")) &&
91156         (AuctionEntry.snipedCount() != 0)) {
------
121186   }
122187 
123188   public void setStatus(String status) {
124     mStatusBar.setText("<html><body>" + status + "</body></html>");
189     mStatusBar.setText(XMLElement.decodeString(status));
125190     mStatusBar.paintImmediately(mStatusBar.getVisibleRect());
126191   }
127192 
193   public void setPrice(String price) {
194     mPrices.setText(price);
195     mPrices.paintImmediately(mPrices.getVisibleRect());
196   }
197 
128198   /**
129199    * @return A property table of all the table column header information, suitable for saving.
130200    * @brief Obtains a 'property list' of all the column widths, names,
884 1031  
8787   private void setStatus(String newStatus) {
8888     mNow.setTime(System.currentTimeMillis());
8989     String defaultServerTime = AuctionServerManager.getInstance().getDefaultServerTime();
90     String bracketed = " [" + defaultServerTime + '/' + Constants.localClockFormat.format(mNow) + ']';
90     String bracketed = " [" + defaultServerTime + ']';
9191     if (JConfig.queryConfiguration("timesync.enabled", "true").equals("false")) {
9292       TimeZone tz = AuctionServerManager.getInstance().getServer().getOfficialServerTimeZone();
9393       if (tz != null && tz.hasSameRules(mCal.getTimeZone())) {
------
122122   private final static String VALID_LOGIN_MSG = "VALID LOGIN";
123123   private final static String START_UPDATING = "ALLOW_UPDATES";
124124   private static final String NOACCOUNT_MSG = "NOACCOUNT ";
125   private static final String PRICE = "PRICE ";
125126 
126127   /**
127128    * @brief Handle messages to tell the UI to do something.
------
200201           "Version check failed", JOptionPane.PLAIN_MESSAGE);
201202     } else if (msg.equals("TOOLBAR")) {
202203       JBidToolBar.getInstance().togglePanel();
204     } else if (msg.startsWith(PRICE)) {
205       mFrame.setPrice(msg.substring(PRICE.length()));
203206     } else {
204207       logActivity(msg);
205208       setStatus(msg);
1018 1031  
88 import com.jbidwatcher.util.config.*;
99 import com.jbidwatcher.util.Currency;
1010 import com.jbidwatcher.util.Constants;
11 import com.jbidwatcher.util.queue.MQFactory;
1112 import com.jbidwatcher.auction.AuctionEntry;
1213 import com.jbidwatcher.auction.Auctions;
1314 import com.jbidwatcher.auction.EntryInterface;
------
2324 import javax.swing.event.ListSelectionListener;
2425 import javax.swing.event.TableModelEvent;
2526 import javax.swing.event.TableModelListener;
26 import javax.swing.table.TableCellRenderer;
2727 import javax.swing.table.TableColumn;
2828 import java.awt.*;
2929 import java.awt.event.ActionListener;
------
4040   private Color _bgColor;
4141   private JPrintable _print;
4242   private CSVExporter _export;
43   private JLabel _prices;
4443   private JPanel mPanel;
4544 
4645   private static final myTableCellRenderer _myRenderer = new myTableCellRenderer();
------
116115     mPanel = new JPanel();
117116     mPanel.setLayout(new BorderLayout());
118117     mPanel.add(_scroller, BorderLayout.CENTER);
119     JPanel jp2 = buildBottomPanel(tableContextMenu);
120     mPanel.add(jp2, BorderLayout.SOUTH);
118     addSumMonitor(_table, _tSort);
121119     JPanel statusPanel = new TabStatusPanel(_dataModel.getName());
122120     mPanel.add(statusPanel, BorderLayout.NORTH);
123121   }
------
126124     return mPanel;
127125   }
128126 
129   private JPanel buildBottomPanel(JContext tableContextMenu) {
130     JPanel jp2 = new JPanel();
131     jp2.setLayout(new BorderLayout());
132     _prices = new JLabel(" ");
133     jp2.add(_prices, BorderLayout.EAST);
134     jp2.add(ButtonMaker.makeButton("icons/xml.png", "Show RSS feed information", "RSS", tableContextMenu, true), BorderLayout.WEST);
135     _table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
127   private void addSumMonitor(JTable table, TableSorter sort) {
128     table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
136129       public void valueChanged(ListSelectionEvent event) {
137130         updateSum();
138131       }
139132     });
140     _tSort.addTableModelListener(new TableModelListener() {
133 
134     sort.addTableModelListener(new TableModelListener() {
141135       public void tableChanged(TableModelEvent tableModelEvent) {
142136         updateSum();
143137       }
144138     });
145     return jp2;
146139   }
147140 
148141   private void updateSum() {
149142     int[] rowList = _table.getSelectedRows();
150     if(rowList.length == 0) {
151       _prices.setText(" ");
143     String total = sum(rowList);
144 
145     if(total == null) {
146       MQFactory.getConcrete("Swing").enqueue("PRICE  "); // A blank space to clear the price
152147     } else {
153       String total = sum(rowList);
154       if(total != null) {
155         _prices.setText(rowList.length + " items, price total: " + total);
156       } else {
157         _prices.setText(" ");
158       }
148       MQFactory.getConcrete("Swing").enqueue("PRICE " + rowList.length + " / " + total);
159149     }
160150   }
161151 
------
303293     if(approx) {
304294       String result;
305295       if(withShipping != null && !accum.equals(withShipping)) {
306         result = "Approximately " + accum.toString() + " (" + withShipping + " with " + sAndH + ')';
296         result = "About " + accum.toString() + " (" + withShipping + " with " + sAndH + ')';
307297       } else {
308         result = "Approximately " + accum.toString();
298         result = "About " + accum.toString();
309299       }
310300       return result;
311301     }