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.
- M jbidwatcher/trunk/src/com/jbidwatcher/app/MacFriendlyFrame.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/app/UIBackbone.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/ui/AuctionsUIModel.java view
| 1026 | 1031 | |
|---|---|---|
| 5 | 5 | import com.jbidwatcher.util.db.ActiveRecord; |
| 6 | 6 | import com.jbidwatcher.util.db.Database; |
| 7 | 7 | import com.jbidwatcher.util.Constants; |
| 8 | import com.jbidwatcher.util.xml.XMLElement; | |
| 8 | 9 | import com.jbidwatcher.auction.server.AuctionStats; |
| 9 | 10 | import com.jbidwatcher.auction.server.AuctionServerManager; |
| 10 | 11 | import com.jbidwatcher.auction.AuctionEntry; |
| 11 | 12 | import com.jbidwatcher.ui.util.JMouseAdapter; |
| 12 | 13 | import com.jbidwatcher.ui.util.OptionUI; |
| 14 | import com.jbidwatcher.ui.util.ButtonMaker; | |
| 13 | 15 | import com.jbidwatcher.ui.*; |
| 14 | 16 | import com.jbidwatcher.platform.Platform; |
| 15 | 17 | import com.jbidwatcher.search.SearchManager; |
| 16 | 18 | |
| 17 | 19 | 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.*; | |
| 21 | 22 | import java.awt.BorderLayout; |
| 22 | 23 | import java.awt.Dimension; |
| 24 | import java.awt.Color; | |
| 23 | 25 | import java.net.URL; |
| 24 | 26 | import java.util.Properties; |
| 25 | 27 | |
| --- | --- | |
| 33 | 35 | */ |
| 34 | 36 | class MacFriendlyFrame extends JFrame implements com.apple.mrj.MRJQuitHandler, com.apple.mrj.MRJAboutHandler, com.apple.mrj.MRJPrefsHandler { |
| 35 | 37 | private JLabel mStatusBar; |
| 38 | private JLabel mPrices; | |
| 36 | 39 | |
| 37 | 40 | /** |
| 38 | 41 | * @brief Constructs a new window frame, with all the sorted tables, |
| --- | --- | |
| 61 | 64 | |
| 62 | 65 | JPanel headerBar = JBidToolBar.getInstance().buildHeaderBar(this, tabManager); |
| 63 | 66 | |
| 64 | mStatusBar = new JLabel("Ready!", SwingConstants.LEFT); | |
| 67 | JPanel statusPane = buildStatusLine(tabManager); | |
| 68 | ||
| 65 | 69 | getContentPane().add(tabManager.getTabs()); |
| 66 | getContentPane().add(mStatusBar, BorderLayout.SOUTH); | |
| 70 | getContentPane().add(statusPane, BorderLayout.SOUTH); | |
| 67 | 71 | getContentPane().add(headerBar, BorderLayout.NORTH); |
| 68 | 72 | |
| 69 | 73 | pack(); |
| --- | --- | |
| 86 | 90 | }); |
| 87 | 91 | } |
| 88 | 92 | |
| 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 | ||
| 89 | 154 | public void handleQuit() { |
| 90 | 155 | if (!(JConfig.queryConfiguration("prompt.snipe_quit", "false").equals("true")) && |
| 91 | 156 | (AuctionEntry.snipedCount() != 0)) { |
| --- | --- | |
| 121 | 186 | } |
| 122 | 187 | |
| 123 | 188 | public void setStatus(String status) { |
| 124 | mStatusBar.setText("<html><body>" + status + "</body></html>"); | |
| 189 | mStatusBar.setText(XMLElement.decodeString(status)); | |
| 125 | 190 | mStatusBar.paintImmediately(mStatusBar.getVisibleRect()); |
| 126 | 191 | } |
| 127 | 192 | |
| 193 | public void setPrice(String price) { | |
| 194 | mPrices.setText(price); | |
| 195 | mPrices.paintImmediately(mPrices.getVisibleRect()); | |
| 196 | } | |
| 197 | ||
| 128 | 198 | /** |
| 129 | 199 | * @return A property table of all the table column header information, suitable for saving. |
| 130 | 200 | * @brief Obtains a 'property list' of all the column widths, names, |
| 884 | 1031 | |
|---|---|---|
| 87 | 87 | private void setStatus(String newStatus) { |
| 88 | 88 | mNow.setTime(System.currentTimeMillis()); |
| 89 | 89 | String defaultServerTime = AuctionServerManager.getInstance().getDefaultServerTime(); |
| 90 | String bracketed = " [" + defaultServerTime + '/' + Constants.localClockFormat.format(mNow) + ']'; | |
| 90 | String bracketed = " [" + defaultServerTime + ']'; | |
| 91 | 91 | if (JConfig.queryConfiguration("timesync.enabled", "true").equals("false")) { |
| 92 | 92 | TimeZone tz = AuctionServerManager.getInstance().getServer().getOfficialServerTimeZone(); |
| 93 | 93 | if (tz != null && tz.hasSameRules(mCal.getTimeZone())) { |
| --- | --- | |
| 122 | 122 | private final static String VALID_LOGIN_MSG = "VALID LOGIN"; |
| 123 | 123 | private final static String START_UPDATING = "ALLOW_UPDATES"; |
| 124 | 124 | private static final String NOACCOUNT_MSG = "NOACCOUNT "; |
| 125 | private static final String PRICE = "PRICE "; | |
| 125 | 126 | |
| 126 | 127 | /** |
| 127 | 128 | * @brief Handle messages to tell the UI to do something. |
| --- | --- | |
| 200 | 201 | "Version check failed", JOptionPane.PLAIN_MESSAGE); |
| 201 | 202 | } else if (msg.equals("TOOLBAR")) { |
| 202 | 203 | JBidToolBar.getInstance().togglePanel(); |
| 204 | } else if (msg.startsWith(PRICE)) { | |
| 205 | mFrame.setPrice(msg.substring(PRICE.length())); | |
| 203 | 206 | } else { |
| 204 | 207 | logActivity(msg); |
| 205 | 208 | setStatus(msg); |
| 1018 | 1031 | |
|---|---|---|
| 8 | 8 | import com.jbidwatcher.util.config.*; |
| 9 | 9 | import com.jbidwatcher.util.Currency; |
| 10 | 10 | import com.jbidwatcher.util.Constants; |
| 11 | import com.jbidwatcher.util.queue.MQFactory; | |
| 11 | 12 | import com.jbidwatcher.auction.AuctionEntry; |
| 12 | 13 | import com.jbidwatcher.auction.Auctions; |
| 13 | 14 | import com.jbidwatcher.auction.EntryInterface; |
| --- | --- | |
| 23 | 24 | import javax.swing.event.ListSelectionListener; |
| 24 | 25 | import javax.swing.event.TableModelEvent; |
| 25 | 26 | import javax.swing.event.TableModelListener; |
| 26 | import javax.swing.table.TableCellRenderer; | |
| 27 | 27 | import javax.swing.table.TableColumn; |
| 28 | 28 | import java.awt.*; |
| 29 | 29 | import java.awt.event.ActionListener; |
| --- | --- | |
| 40 | 40 | private Color _bgColor; |
| 41 | 41 | private JPrintable _print; |
| 42 | 42 | private CSVExporter _export; |
| 43 | private JLabel _prices; | |
| 44 | 43 | private JPanel mPanel; |
| 45 | 44 | |
| 46 | 45 | private static final myTableCellRenderer _myRenderer = new myTableCellRenderer(); |
| --- | --- | |
| 116 | 115 | mPanel = new JPanel(); |
| 117 | 116 | mPanel.setLayout(new BorderLayout()); |
| 118 | 117 | mPanel.add(_scroller, BorderLayout.CENTER); |
| 119 | JPanel jp2 = buildBottomPanel(tableContextMenu); | |
| 120 | mPanel.add(jp2, BorderLayout.SOUTH); | |
| 118 | addSumMonitor(_table, _tSort); | |
| 121 | 119 | JPanel statusPanel = new TabStatusPanel(_dataModel.getName()); |
| 122 | 120 | mPanel.add(statusPanel, BorderLayout.NORTH); |
| 123 | 121 | } |
| --- | --- | |
| 126 | 124 | return mPanel; |
| 127 | 125 | } |
| 128 | 126 | |
| 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() { | |
| 136 | 129 | public void valueChanged(ListSelectionEvent event) { |
| 137 | 130 | updateSum(); |
| 138 | 131 | } |
| 139 | 132 | }); |
| 140 | _tSort.addTableModelListener(new TableModelListener() { | |
| 133 | ||
| 134 | sort.addTableModelListener(new TableModelListener() { | |
| 141 | 135 | public void tableChanged(TableModelEvent tableModelEvent) { |
| 142 | 136 | updateSum(); |
| 143 | 137 | } |
| 144 | 138 | }); |
| 145 | return jp2; | |
| 146 | 139 | } |
| 147 | 140 | |
| 148 | 141 | private void updateSum() { |
| 149 | 142 | 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 | |
| 152 | 147 | } 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); | |
| 159 | 149 | } |
| 160 | 150 | } |
| 161 | 151 | |
| --- | --- | |
| 303 | 293 | if(approx) { |
| 304 | 294 | String result; |
| 305 | 295 | if(withShipping != null && !accum.equals(withShipping)) { |
| 306 | result = "Approximately " + accum.toString() + " (" + withShipping + " with " + sAndH + ')'; | |
| 296 | result = "About " + accum.toString() + " (" + withShipping + " with " + sAndH + ')'; | |
| 307 | 297 | } else { |
| 308 | result = "Approximately " + accum.toString(); | |
| 298 | result = "About " + accum.toString(); | |
| 309 | 299 | } |
| 310 | 300 | return result; |
| 311 | 301 | } |
