* This sucks. I need to push the generic code up, and leave the auction-specific code here, or
* somehow move all the non-auction-specific functionality to its own class. This code is broken,
* at the least because it has to use 'instanceof' to work.
*/
Object resolvedObject = resolvePoint();
AuctionEntry ae = null;
if (resolvedObject != null && resolvedObject instanceof AuctionEntry) {
ae = (AuctionEntry) resolvedObject;
}
int[] rowList = getPossibleRows();
if (rowList != null && rowList.length != 0) {
if (rowList.length == 1) {
Object firstSelected = getIndexedEntry(rowList[0]);
if (firstSelected != null && firstSelected instanceof AuctionEntry) {
ae = (AuctionEntry) firstSelected;
}
} else {
ae = null;
}
}
// Ignored if it wasn't renamed, but otherwise always restore to 'known state'.
rename("Multisnipe", "Snipe");
rename("Edit", "Add"); // Comment
if (ae != null) {
if (ae.getComment() == null) {
disable("View");
disable("Remove");
} else {
rename("Add", "Edit");
}
if (!ae.isSniped()) disable("Cancel Snipe");
if (!ae.isComplete()) {
disable("Complete");
disable("Mark As Not Ended");
} else {
enable("Mark As Not Ended");
}
if (ae.isSeller() || ae.isComplete()) {
disable("Buy");
disable("Bid");
disable("Snipe");
}
if (ae.isFixed()) {
disable("Bid");
disable("Snipe");
}
if (!ae.isFixed() && ae.getBuyNow().isNull()) {
disable("Buy");
}
}
if (rowList != null && rowList.length > 1) {
disable("Bid");
disable("Buy");
disable("Show Last Error");
disable("Set Shipping");
disable("Add");
disable("View");
disable("Remove");
boolean anySniped = false;
boolean anyFixed = false;
boolean anyEnded = false;
boolean anyCurrent = false;
for (int aRowList : rowList) {
Object line = getIndexedEntry(aRowList);
AuctionEntry step = (AuctionEntry) line;
if (step.isSniped()) anySniped = true;
if (step.isFixed()) anyFixed = true;
if (step.isComplete()) anyEnded = true;
if (!step.isComplete()) anyCurrent = true;
}
if (!anySniped) disable("Cancel Snipe");
if (anyFixed || anyEnded) disable("Snipe");
if (!anyCurrent) enable("Complete");