|
|
| 528 |
530 |
|
| 7 | 7 |
|
| 8 | 8 | import java.awt.*;
|
| 9 | 9 | import java.awt.event.*;
|
| 10 | | import java.awt.datatransfer.*;
|
| 11 | | import java.awt.datatransfer.Clipboard;
|
| 12 | 10 | import java.io.*;
|
| 13 | 11 | import javax.swing.*;
|
| 14 | 12 | import java.util.*;
|
| --- | --- | |
| 35 | 33 | import com.jbidwatcher.auction.server.AuctionServerManager;
|
| 36 | 34 | import com.jbidwatcher.auction.AuctionServerInterface;
|
| 37 | 35 |
|
| 38 | | public class JBidMouse extends JBidContext implements MessageQueue.Listener {
|
| 36 | public class JBidMouse implements MessageQueue.Listener {
|
| 37 | private static JTabManager mTabs = JTabManager.getInstance();
|
| 39 | 38 | private static JConfigFrame jcf = null;
|
| 40 | 39 | private static SearchFrame _searchFrame = null;
|
| 41 | | private JDropListener _jdl = new JDropListener(null); // This would fail miserably if we called drop()...
|
| 42 | 40 | private OptionUI _oui = new OptionUI();
|
| 43 | 41 | private RSSDialog _rssDialog = null;
|
| 44 | 42 | private static StringBuffer _colorHelp = null;
|
| --- | --- | |
| 46 | 44 | private static StringBuffer _faqText = null;
|
| 47 | 45 |
|
| 48 | 46 | private boolean _in_deleting = false;
|
| 49 | | private JMenu tabMenu = null;
|
| 50 | 47 | private ScriptManager mScriptFrame;
|
| 48 | private static JBidMouse sInstance;
|
| 51 | 49 |
|
| 52 | | public JBidMouse(JPopupMenu inPopup) {
|
| 53 | | super(inPopup);
|
| 54 | | buildMenu(inPopup);
|
| 55 | | }
|
| 50 | private JBidMouse() { }
|
| 56 | 51 |
|
| 57 | | public JBidMouse() {
|
| 58 | | buildMenu(localPopup);
|
| 59 | | MQFactory.getConcrete("user").registerListener(this);
|
| 60 | | }
|
| 61 | |
|
| 62 | 52 | public static void setConfigFrame(JConfigFrame curCfg) {
|
| 63 | 53 | if(curCfg != null) jcf = curCfg;
|
| 64 | 54 | }
|
| --- | --- | |
| 144 | 134 | }
|
| 145 | 135 | }
|
| 146 | 136 |
|
| 147 | | protected boolean confirmDeletion(Component src, String prompt) {
|
| 148 | | int endResult = JOptionPane.showOptionDialog(src, prompt,
|
| 149 | | "Confirm", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
|
| 150 | | null, null, null);
|
| 151 | |
|
| 152 | | return !(endResult == JOptionPane.CANCEL_OPTION ||
|
| 153 | | endResult == JOptionPane.CLOSED_OPTION);
|
| 154 | |
|
| 155 | | }
|
| 156 | |
|
| 157 | 137 | private void DoHideShowToolbar() {
|
| 158 | 138 | MQFactory.getConcrete("Swing").enqueue("TOOLBAR");
|
| 159 | 139 | }
|
| --- | --- | |
| 177 | 157 |
|
| 178 | 158 | private void DoShowLastError(Component src, AuctionEntry passedAE) {
|
| 179 | 159 | AuctionEntry ae = passedAE;
|
| 180 | | int[] rowList = getPossibleRows();
|
| 160 | int[] rowList = mTabs.getPossibleRows();
|
| 181 | 161 |
|
| 182 | 162 | if(ae == null && rowList.length == 0 || rowList.length > 1) {
|
| 183 | 163 | JOptionPane.showMessageDialog(src, "You must select a single auction to view the error page for.",
|
| --- | --- | |
| 185 | 165 | return;
|
| 186 | 166 | }
|
| 187 | 167 |
|
| 188 | | if(ae == null) ae = (AuctionEntry) getIndexedEntry(rowList[0]);
|
| 168 | if(ae == null) ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]);
|
| 189 | 169 |
|
| 190 | 170 | StringBuffer wholeStatus = ae.getErrorPage();
|
| 191 | 171 | Dimension statusBox = new Dimension(756, 444);
|
| --- | --- | |
| 208 | 188 |
|
| 209 | 189 | ArrayList<AuctionEntry> deleteIds = new ArrayList<AuctionEntry>();
|
| 210 | 190 | StringBuffer wholeDelete = new StringBuffer();
|
| 211 | | int[] rowList = getPossibleRows();
|
| 191 | int[] rowList = mTabs.getPossibleRows();
|
| 212 | 192 |
|
| 213 | 193 | if(ae == null && rowList.length == 0) {
|
| 214 | 194 | _in_deleting = false;
|
| --- | --- | |
| 221 | 201 | wholeDelete.append("<table border=0 spacing=0 width=\"100%\">");
|
| 222 | 202 | wholeDelete.append("<tr><td><u><b>Item Number</b></u></td><td><u><b>Title</b></u></td></tr>");
|
| 223 | 203 | for(int i = 0; i<rowList.length; i++) {
|
| 224 | | AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(rowList[i]);
|
| 204 | AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]);
|
| 225 | 205 | deleteIds.add(tempEntry);
|
| 226 | 206 | String color = "FFFFFF";
|
| 227 | 207 | if( (i % 2) == 1) {
|
| --- | --- | |
| 245 | 225 | statusBox = new Dimension(756, Math.min(372, rowList.length * 30 + 30));
|
| 246 | 226 | } else {
|
| 247 | 227 | if(rowList.length == 1) {
|
| 248 | | ae = (AuctionEntry) getIndexedEntry(rowList[0]);
|
| 228 | ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]);
|
| 249 | 229 | }
|
| 250 | 230 | if ((ae == null)) {
|
| 251 | 231 | throw new IllegalArgumentException();
|
| --- | --- | |
| 315 | 295 | }
|
| 316 | 296 | }
|
| 317 | 297 |
|
| 318 | | private String getClipboardString() {
|
| 319 | | Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
|
| 320 | | Transferable t = sysClip.getContents(null);
|
| 321 | |
|
| 322 | | ErrorManagement.logDebug("Clipboard: " + sysClip.getName() + ", valid flavors: " + Arrays.toString(t.getTransferDataFlavors()));
|
| 323 | |
|
| 324 | | StringBuffer stBuff = _jdl.getTransferData(t);
|
| 325 | | String clipString;
|
| 326 | | if(stBuff == null) {
|
| 327 | | try {
|
| 328 | | clipString = (String)t.getTransferData(DataFlavor.stringFlavor);
|
| 329 | | } catch(Exception e) {
|
| 330 | | // Nothing really to do here...
|
| 331 | | clipString = null;
|
| 332 | | }
|
| 333 | | } else {
|
| 334 | | clipString = stBuff.toString();
|
| 335 | | }
|
| 336 | |
|
| 337 | | return clipString;
|
| 338 | | }
|
| 339 | |
|
| 340 | 298 | private static Pattern digitSearch = Pattern.compile("[0-9]+");
|
| 341 | 299 |
|
| 342 | 300 | private void DoPasteFromClipboard() {
|
| 343 | | String auctionId = getClipboardString();
|
| 301 | String auctionId = Clipboard.getClipboardString();
|
| 344 | 302 | String original = auctionId;
|
| 345 | 303 |
|
| 346 | 304 | if(auctionId.charAt(0) == '<') {
|
| --- | --- | |
| 408 | 366 |
|
| 409 | 367 | for (int aRowList : rowList) {
|
| 410 | 368 | try {
|
| 411 | | AuctionEntry ae2 = (AuctionEntry) getIndexedEntry(aRowList);
|
| 369 | AuctionEntry ae2 = (AuctionEntry) mTabs.getIndexedEntry(aRowList);
|
| 412 | 370 | if (accum == null) {
|
| 413 | 371 | accum = ae2.getUSCurBid();
|
| 414 | 372 | realAccum = getBestBidValue(ae2);
|
| --- | --- | |
| 450 | 408 | return accum.toString();
|
| 451 | 409 | }
|
| 452 | 410 |
|
| 453 | | private void DoSendTo(String tab) {
|
| 454 | | int[] rowList = getPossibleRows();
|
| 455 | |
|
| 456 | | if(rowList.length == 0) {
|
| 457 | | JOptionPane.showMessageDialog(null, "No auctions selected to move!", "Error moving listings", JOptionPane.PLAIN_MESSAGE);
|
| 458 | | return;
|
| 459 | | }
|
| 460 | |
|
| 461 | | Category c = Category.findFirstByName(tab);
|
| 462 | |
|
| 463 | | if(c == null) {
|
| 464 | | JOptionPane.showMessageDialog(null, "Cannot locate that tab, something has gone wrong.\nClose and restart JBidwatcher.", "Error moving listings", JOptionPane.PLAIN_MESSAGE);
|
| 465 | | return;
|
| 466 | | }
|
| 467 | |
|
| 468 | | // Build a temporary table, because the items will vanish out of
|
| 469 | | // the table when we start refiltering them, and that will mess
|
| 470 | | // everything up.
|
| 471 | | ArrayList<AuctionEntry> tempTable = new ArrayList<AuctionEntry>(rowList.length);
|
| 472 | | for (int aRowList : rowList) {
|
| 473 | | AuctionEntry moveEntry = (AuctionEntry) getIndexedEntry(aRowList);
|
| 474 | | tempTable.add(moveEntry);
|
| 475 | | }
|
| 476 | |
|
| 477 | | // Now move all entries in the temporary table to the new tab.
|
| 478 | | for (AuctionEntry moveEntry : tempTable) {
|
| 479 | | moveEntry.setCategory(tab);
|
| 480 | | MQFactory.getConcrete("redraw").enqueue(moveEntry);
|
| 481 | | }
|
| 482 | | }
|
| 483 | |
|
| 484 | 411 | private void DoAdd(Component src) {
|
| 485 | 412 | String prompt = "Enter the auction number to add";
|
| 486 | 413 |
|
| --- | --- | |
| 506 | 433 | }
|
| 507 | 434 |
|
| 508 | 435 | private void CancelSnipe(Component src, AuctionEntry ae) {
|
| 509 | | int[] rowList = getPossibleRows();
|
| 436 | int[] rowList = mTabs.getPossibleRows();
|
| 510 | 437 | int len = rowList.length;
|
| 511 | 438 |
|
| 512 | 439 | if(ae == null && len == 0) {
|
| --- | --- | |
| 517 | 444 |
|
| 518 | 445 | if(len != 0) {
|
| 519 | 446 | for (int aRowList : rowList) {
|
| 520 | | AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(aRowList);
|
| 447 | AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(aRowList);
|
| 521 | 448 |
|
| 522 | 449 | tempEntry.cancelSnipe(false);
|
| 523 | 450 | MQFactory.getConcrete("redraw").enqueue(tempEntry);
|
| --- | --- | |
| 549 | 476 | }
|
| 550 | 477 |
|
| 551 | 478 | private void DoInformation(Component src, AuctionEntry ae) {
|
| 552 | | int[] rowList = getPossibleRows();
|
| 479 | int[] rowList = mTabs.getPossibleRows();
|
| 553 | 480 |
|
| 554 | 481 | int len = rowList.length;
|
| 555 | 482 | if(ae == null && len == 0) {
|
| --- | --- | |
| 564 | 491 | private void showComplexInformation(int[] rowList) {
|
| 565 | 492 | StringBuffer prompt = new StringBuffer();
|
| 566 | 493 | for (int aRowList : rowList) {
|
| 567 | | AuctionEntry stepAE = (AuctionEntry) getIndexedEntry(aRowList);
|
| 494 | AuctionEntry stepAE = (AuctionEntry) mTabs.getIndexedEntry(aRowList);
|
| 568 | 495 | prompt.append(stepAE.buildInfoHTML(false)).append("<hr>");
|
| 569 | 496 | }
|
| 570 | 497 | Dimension statusBox = new Dimension(480, Math.min(372, rowList.length * 30 + 200));
|
| --- | --- | |
| 602 | 529 | boolean foundDangerousSnipe=false;
|
| 603 | 530 |
|
| 604 | 531 | for(int i = 0; i<rowList.length && !foundDangerousSnipe; i++) {
|
| 605 | | AuctionEntry ae1 = (AuctionEntry) getIndexedEntry(rowList[i]);
|
| 532 | AuctionEntry ae1 = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]);
|
| 606 | 533 | if(ms != null) {
|
| 607 | 534 | if(!ms.isSafeToAdd(ae1)) foundDangerousSnipe = true;
|
| 608 | 535 | }
|
| 609 | 536 |
|
| 610 | 537 | for(int j = i + 1; j<rowList.length && !foundDangerousSnipe; j++) {
|
| 611 | | AuctionEntry ae2 = (AuctionEntry) getIndexedEntry(rowList[j]);
|
| 538 | AuctionEntry ae2 = (AuctionEntry) mTabs.getIndexedEntry(rowList[j]);
|
| 612 | 539 | if(!MultiSnipe.isSafeMultiSnipe(ae1, ae2)) {
|
| 613 | 540 | foundDangerousSnipe = true;
|
| 614 | 541 | }
|
| --- | --- | |
| 619 | 546 | }
|
| 620 | 547 |
|
| 621 | 548 | private void DoMultiSnipe(Component src) {
|
| 622 | | int[] rowList = getPossibleRows();
|
| 549 | int[] rowList = mTabs.getPossibleRows();
|
| 623 | 550 | Currency baseAllBid = Currency.NoValue();
|
| 624 | 551 |
|
| 625 | 552 | // You must select multiple auctions to make this work.
|
| --- | --- | |
| 633 | 560 | MultiSnipe aeMS = null;
|
| 634 | 561 | int i;
|
| 635 | 562 | for(i=0; i<rowList.length; i++) {
|
| 636 | | AuctionEntry tempAE = (AuctionEntry) getIndexedEntry(rowList[i]);
|
| 563 | AuctionEntry tempAE = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]);
|
| 637 | 564 | Currency curBid = tempAE.getCurBid();
|
| 638 | 565 |
|
| 639 | 566 | if(tempAE.getServer().isDefaultUser()) {
|
| --- | --- | |
| 753 | 680 | }
|
| 754 | 681 |
|
| 755 | 682 | for(i=0; i<rowList.length; i++) {
|
| 756 | | AuctionEntry stepAE = (AuctionEntry)getIndexedEntry(rowList[i]);
|
| 683 | AuctionEntry stepAE = (AuctionEntry)mTabs.getIndexedEntry(rowList[i]);
|
| 757 | 684 | stepAE.setMultiSnipe(aeMS);
|
| 758 | 685 | MQFactory.getConcrete("redraw").enqueue(stepAE);
|
| 759 | 686 | }
|
| --- | --- | |
| 780 | 707 |
|
| 781 | 708 | private void DoSnipe(Component src, AuctionEntry passedAE) {
|
| 782 | 709 | AuctionEntry ae = passedAE;
|
| 783 | | int[] rowList = getPossibleRows();
|
| 710 | int[] rowList = mTabs.getPossibleRows();
|
| 784 | 711 |
|
| 785 | 712 | if(rowList.length > 1) {
|
| 786 | 713 | DoMultiSnipe(src);
|
| 787 | 714 | return;
|
| 788 | 715 | }
|
| 789 | 716 | if(rowList.length == 1) {
|
| 790 | | ae = (AuctionEntry) getIndexedEntry(rowList[0]);
|
| 717 | ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]);
|
| 791 | 718 | }
|
| 792 | 719 | if (ae == null) {
|
| 793 | 720 | JOptionPane.showMessageDialog(src, "You have not chosen an auction to snipe on!",
|
| --- | --- | |
| 981 | 908 |
|
| 982 | 909 | private void DoShowInBrowser(Component src, AuctionEntry inAuction) {
|
| 983 | 910 | AuctionEntry ae = inAuction;
|
| 984 | | int[] rowList = getPossibleRows();
|
| 911 | int[] rowList = mTabs.getPossibleRows();
|
| 985 | 912 |
|
| 986 | 913 | if(rowList.length != 0) {
|
| 987 | 914 | // Vector<String> multiAuctionIds = new Vector<String>();
|
| 988 | 915 | // int i;
|
| 989 | 916 | //
|
| 990 | 917 | // for(i=0; i<rowList.length; i++) {
|
| 991 | | // AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(rowList[i]);
|
| 918 | // AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]);
|
| 992 | 919 | //
|
| 993 | 920 | // multiAuctionIds.add(tempEntry.getIdentifier());
|
| 994 | 921 | // }
|
| 995 | 922 | // TODO -- Find another way to do this...
|
| 996 | 923 | // JBidProxy.setItems(multiAuctionIds);
|
| 997 | 924 |
|
| 998 | | ae = (AuctionEntry) getIndexedEntry(rowList[0]);
|
| 925 | ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]);
|
| 999 | 926 | } else {
|
| 1000 | 927 | if(ae == null) {
|
| 1001 | 928 | JOptionPane.showMessageDialog(src, "Cannot launch browser from menu, you must select an auction.", "Menu Error", JOptionPane.PLAIN_MESSAGE);
|
| --- | --- | |
| 1098 | 1025 | }
|
| 1099 | 1026 |
|
| 1100 | 1027 | private void DoUpdate(Component src, AuctionEntry inAuction) {
|
| 1101 | | int[] rowList = getPossibleRows();
|
| 1028 | int[] rowList = mTabs.getPossibleRows();
|
| 1102 | 1029 |
|
| 1103 | 1030 | if(rowList.length != 0) {
|
| 1104 | 1031 | for (int aRowList : rowList) {
|
| 1105 | | AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(aRowList);
|
| 1032 | AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(aRowList);
|
| 1106 | 1033 |
|
| 1107 | 1034 | tempEntry.setNeedsUpdate();
|
| 1108 | 1035 | if (tempEntry.isComplete() || tempEntry.isPaused()) {
|
| --- | --- | |
| 1122 | 1049 | }
|
| 1123 | 1050 |
|
| 1124 | 1051 | private void DoSetNotEnded(AuctionEntry whichAuction) {
|
| 1125 | | int[] rowList = getPossibleRows();
|
| 1052 | int[] rowList = mTabs.getPossibleRows();
|
| 1126 | 1053 |
|
| 1127 | 1054 | if (rowList.length != 0) {
|
| 1128 | 1055 | for (int aRowList : rowList) {
|
| 1129 | | AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(aRowList);
|
| 1056 | AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(aRowList);
|
| 1130 | 1057 |
|
| 1131 | 1058 | tempEntry.setComplete(false);
|
| 1132 | 1059 | tempEntry.setNeedsUpdate();
|
| --- | --- | |
| 1283 | 1210 | */
|
| 1284 | 1211 | private void DoCopySomething(Component src, AuctionEntry passedAE, int action, String fail_msg, String seperator) {
|
| 1285 | 1212 | AuctionEntry ae = passedAE;
|
| 1286 | | int[] rowList = getPossibleRows();
|
| 1213 | int[] rowList = mTabs.getPossibleRows();
|
| 1287 | 1214 |
|
| 1288 | 1215 | if(ae == null && rowList.length == 0) {
|
| 1289 | 1216 | JOptionPane.showMessageDialog(src, fail_msg, "Error copying", JOptionPane.PLAIN_MESSAGE);
|
| --- | --- | |
| 1294 | 1221 | StringBuffer sb = new StringBuffer();
|
| 1295 | 1222 |
|
| 1296 | 1223 | for(int i = 0; i<rowList.length; i++) {
|
| 1297 | | AuctionEntry tempEntry = (AuctionEntry) getIndexedEntry(rowList[i]);
|
| 1224 | AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]);
|
| 1298 | 1225 |
|
| 1299 | 1226 | if(i != 0) sb.append(seperator);
|
| 1300 | 1227 |
|
| 1301 | 1228 | sb.append(getActionValue(action, tempEntry));
|
| 1302 | 1229 | }
|
| 1303 | 1230 |
|
| 1304 | | com.jbidwatcher.ui.util.Clipboard.setClipboardString(sb.toString());
|
| 1231 | Clipboard.setClipboardString(sb.toString());
|
| 1305 | 1232 | } else {
|
| 1306 | 1233 | // Shortcut to not have to create and destroy a Stringbuffer
|
| 1307 | | if(rowList.length == 1) ae = (AuctionEntry) getIndexedEntry(rowList[0]);
|
| 1234 | if(rowList.length == 1) ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]);
|
| 1308 | 1235 |
|
| 1309 | | com.jbidwatcher.ui.util.Clipboard.setClipboardString(getActionValue(action, ae));
|
| 1236 | Clipboard.setClipboardString(getActionValue(action, ae));
|
| 1310 | 1237 | }
|
| 1311 | 1238 | }
|
| 1312 | 1239 |
|
| --- | --- | |
| 1391 | 1318 | _oui.promptWithCheckbox(src, "Cleared " + clearedCount + " deleted entries.", "Clear Complete", "prompt.clear_complete", JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_OPTION);
|
| 1392 | 1319 | }
|
| 1393 | 1320 |
|
| 1394 | | protected void buildMenu(JPopupMenu menu) {
|
| 1395 | | menu.add(makeMenuItem("Snipe")).addActionListener(this);
|
| 1396 | | menu.add(makeMenuItem("Cancel Snipe")).addActionListener(this);
|
| 1397 | | menu.add(new JPopupMenu.Separator());
|
| 1398 | |
|
| 1399 | | menu.add(makeMenuItem("Bid")).addActionListener(this);
|
| 1400 | | menu.add(makeMenuItem("Buy")).addActionListener(this);
|
| 1401 | | menu.add(new JPopupMenu.Separator());
|
| 1402 | |
|
| 1403 | | menu.add(makeMenuItem("Update Auction", "Update")).addActionListener(this);
|
| 1404 | | menu.add(makeMenuItem("Show Information", "Information")).addActionListener(this);
|
| 1405 | | menu.add(makeMenuItem("Show In Browser", "Browse")).addActionListener(this);
|
| 1406 | | //menu.add(makeMenuItem("Add Up Prices", "Sum")).addActionListener(this);
|
| 1407 | | menu.add(new JPopupMenu.Separator());
|
| 1408 | | menu.add(makeMenuItem("Set Shipping", "Shipping")).addActionListener(this);
|
| 1409 | | menu.add(new JPopupMenu.Separator());
|
| 1410 | |
|
| 1411 | | tabMenu = new JMenu("Send To");
|
| 1412 | | menu.add(tabMenu);
|
| 1413 | | JMenu comment = new JMenu("Comment");
|
| 1414 | | comment.add(makeMenuItem("Add", "Add Comment")).addActionListener(this);
|
| 1415 | | comment.add(makeMenuItem("View", "View Comment")).addActionListener(this);
|
| 1416 | | comment.add(makeMenuItem("Remove", "Remove Comment")).addActionListener(this);
|
| 1417 | | menu.add(comment);
|
| 1418 | | JMenu advanced = new JMenu("Advanced");
|
| 1419 | | advanced.add(makeMenuItem("Show Last Error", "ShowError")).addActionListener(this);
|
| 1420 | | advanced.add(makeMenuItem("Mark As Not Ended", "NotEnded")).addActionListener(this);
|
| 1421 | | menu.add(advanced);
|
| 1422 | | menu.add(new JPopupMenu.Separator());
|
| 1423 | |
|
| 1424 | | menu.add(makeMenuItem("Delete")).addActionListener(this);
|
| 1425 | | }
|
| 1426 | |
|
| 1427 | | protected void beforePopup(JPopupMenu jp, MouseEvent e) {
|
| 1428 | | ActionListener tabActions = new ActionListener() {
|
| 1429 | | public void actionPerformed(ActionEvent action) {
|
| 1430 | | String toTab = action.getActionCommand();
|
| 1431 | | DoSendTo(toTab);
|
| 1432 | | }
|
| 1433 | | };
|
| 1434 | | super.beforePopup(jp, e);
|
| 1435 | |
|
| 1436 | | if(tabMenu != null) {
|
| 1437 | | tabMenu.removeAll();
|
| 1438 | |
|
| 1439 | | JTabbedPane tabbedPane = JTabManager.getInstance().getTabs();
|
| 1440 | | String currentTitle = tabbedPane.getTitleAt(tabbedPane.getSelectedIndex());
|
| 1441 | | List<String> tabs = Category.categories();
|
| 1442 | | if(tabs == null) {
|
| 1443 | | tabMenu.setEnabled(false);
|
| 1444 | | } else {
|
| 1445 | | tabs.remove("selling");
|
| 1446 | | tabs.remove(currentTitle);
|
| 1447 | | tabMenu.setEnabled(true);
|
| 1448 | | for (String tab : tabs) {
|
| 1449 | | tabMenu.add(makeMenuItem(tab)).addActionListener(tabActions);
|
| 1450 | | }
|
| 1451 | | }
|
| 1452 | | }
|
| 1453 | |
|
| 1454 | | /**
|
| 1455 | | * This sucks. I need to push the generic code up, and leave the auction-specific code here, or
|
| 1456 | | * somehow move all the non-auction-specific functionality to its own class. This code is broken,
|
| 1457 | | * at the least because it has to use 'instanceof' to work.
|
| 1458 | | */
|
| 1459 | | Object resolvedObject = resolvePoint();
|
| 1460 | | AuctionEntry ae = null;
|
| 1461 | |
|
| 1462 | | if(resolvedObject != null && resolvedObject instanceof AuctionEntry) {
|
| 1463 | | ae = (AuctionEntry) resolvedObject;
|
| 1464 | | }
|
| 1465 | |
|
| 1466 | | int[] rowList = getPossibleRows();
|
| 1467 | |
|
| 1468 | | if(rowList != null && rowList.length != 0) {
|
| 1469 | | if(rowList.length == 1) {
|
| 1470 | | Object firstSelected = getIndexedEntry(rowList[0]);
|
| 1471 | | if(firstSelected != null && firstSelected instanceof AuctionEntry) {
|
| 1472 | | ae = (AuctionEntry) firstSelected;
|
| 1473 | | }
|
| 1474 | | } else {
|
| 1475 | | ae = null;
|
| 1476 | | }
|
| 1477 | | }
|
| 1478 | |
|
| 1479 | | // Ignored if it wasn't renamed, but otherwise always restore to 'known state'.
|
| 1480 | | rename("Multisnipe", "Snipe");
|
| 1481 | | rename("Edit", "Add"); // Comment
|
| 1482 | |
|
| 1483 | | if(ae != null) {
|
| 1484 | | if(ae.getComment() == null) {
|
| 1485 | | disable("View");
|
| 1486 | | disable("Remove");
|
| 1487 | | } else {
|
| 1488 | | rename("Add", "Edit");
|
| 1489 | | }
|
| 1490 | | if(!ae.isSniped()) disable("Cancel Snipe");
|
| 1491 | | if(!ae.isComplete()) {
|
| 1492 | | disable("Complete");
|
| 1493 | | disable("Mark As Not Ended");
|
| 1494 | | } else {
|
| 1495 | | enable("Mark As Not Ended");
|
| 1496 | | }
|
| 1497 | |
|
| 1498 | | if(ae.isSeller() || ae.isComplete()) {
|
| 1499 | | disable("Buy");
|
| 1500 | | disable("Bid");
|
| 1501 | | disable("Snipe");
|
| 1502 | | }
|
| 1503 | |
|
| 1504 | | if(ae.isFixed()) {
|
| 1505 | | disable("Bid");
|
| 1506 | | disable("Snipe");
|
| 1507 | | }
|
| 1508 | |
|
| 1509 | | if(!ae.isFixed() && ae.getBuyNow().isNull()) {
|
| 1510 | | disable("Buy");
|
| 1511 | | }
|
| 1512 | | }
|
| 1513 | |
|
| 1514 | | if(rowList != null && rowList.length > 1) {
|
| 1515 | | disable("Bid");
|
| 1516 | | disable("Buy");
|
| 1517 | | disable("Show Last Error");
|
| 1518 | | disable("Set Shipping");
|
| 1519 | | disable("Add");
|
| 1520 | | disable("View");
|
| 1521 | | disable("Remove");
|
| 1522 | |
|
| 1523 | | boolean anySniped = false;
|
| 1524 | | boolean anyFixed = false;
|
| 1525 | | boolean anyEnded = false;
|
| 1526 | | boolean anyCurrent = false;
|
| 1527 | | for (int aRowList : rowList) {
|
| 1528 | | Object line = getIndexedEntry(aRowList);
|
| 1529 | | AuctionEntry step = (AuctionEntry) line;
|
| 1530 | | if (step.isSniped()) anySniped = true;
|
| 1531 | | if (step.isFixed()) anyFixed = true;
|
| 1532 | | if (step.isComplete()) anyEnded = true;
|
| 1533 | | if (!step.isComplete()) anyCurrent = true;
|
| 1534 | | }
|
| 1535 | |
|
| 1536 | | if(!anySniped) disable("Cancel Snipe");
|
| 1537 | | if(anyFixed || anyEnded) disable("Snipe");
|
| 1538 | | if(!anyCurrent) enable("Complete");
|
| 1539 | | if(anyEnded) enable("Mark As Not Ended"); else disable("Mark As Not Ended");
|
| 1540 | | rename("Snipe", "Multisnipe");
|
| 1541 | | }
|
| 1542 | |
|
| 1543 | | if(ae == null || ae.getErrorPage() == null) {
|
| 1544 | | disable("Show Last Error");
|
| 1545 | | }
|
| 1546 | | }
|
| 1547 | |
|
| 1548 | 1321 | protected void DoAction(Object src, String actionString, Object whichAuction) {
|
| 1549 | 1322 | DoAction(src, actionString, (AuctionEntry)whichAuction);
|
| 1550 | 1323 | }
|
| --- | --- | |
| 1614 | 1387 | else if(actionString.equals("Report Bug")) MQFactory.getConcrete("browse").enqueue("http://jbidwatcher.lighthouseapp.com/projects/8037-jbidwatcher/tickets");
|
| 1615 | 1388 | else ErrorManagement.logDebug('[' + actionString + ']');
|
| 1616 | 1389 | }
|
| 1390 |
|
| 1391 | public static void start() {
|
| 1392 | if (sInstance == null) MQFactory.getConcrete("user").registerListener(sInstance = new JBidMouse());
|
| 1393 | }
|
| 1617 | 1394 | }
|