Re-disabled Alpha and Beta in the Custom quest format dialog.

Very minor checkstyle (removed extra whitespace).
This commit is contained in:
RumbleBBU
2013-02-12 08:05:23 +00:00
parent c21689690f
commit 22a707e213

View File

@@ -27,14 +27,14 @@ public class DialogChooseSets {
private final List<String> selectedSets = new ArrayList<String>(); private final List<String> selectedSets = new ArrayList<String>();
private boolean wantReprints = true; private boolean wantReprints = true;
private Runnable okCallback; private Runnable okCallback;
private final List<FCheckBox> choices = new ArrayList<FCheckBox>(); private final List<FCheckBox> choices = new ArrayList<FCheckBox>();
private final FCheckBox cbWantReprints = new FCheckBox("Allow compatible reprints from other sets"); private final FCheckBox cbWantReprints = new FCheckBox("Allow compatible reprints from other sets");
// lists are of set codes (e.g. "2ED") // lists are of set codes (e.g. "2ED")
public DialogChooseSets( public DialogChooseSets(
Collection<String> preselectedSets, Collection<String> unselectableSets, boolean showWantReprintsCheckbox) { Collection<String> preselectedSets, Collection<String> unselectableSets, boolean showWantReprintsCheckbox) {
// create a local copy of the editions list so we can sort it // create a local copy of the editions list so we can sort it
List<CardEdition> editions = new ArrayList<CardEdition>(); List<CardEdition> editions = new ArrayList<CardEdition>();
for (CardEdition ce : Singletons.getModel().getEditions()) { for (CardEdition ce : Singletons.getModel().getEditions()) {
@@ -42,45 +42,47 @@ public class DialogChooseSets {
} }
Collections.sort(editions); Collections.sort(editions);
Collections.reverse(editions); Collections.reverse(editions);
List<FCheckBox> coreSets = new ArrayList<FCheckBox>(); List<FCheckBox> coreSets = new ArrayList<FCheckBox>();
List<FCheckBox> expansionSets = new ArrayList<FCheckBox>(); List<FCheckBox> expansionSets = new ArrayList<FCheckBox>();
List<FCheckBox> otherSets = new ArrayList<FCheckBox>(); List<FCheckBox> otherSets = new ArrayList<FCheckBox>();
for (CardEdition ce : editions) { for (CardEdition ce : editions) {
String code = ce.getCode(); if (choosableSet(ce)) {
FCheckBox box = new FCheckBox(String.format("%s (%s)", ce.getName(), code)); String code = ce.getCode();
box.setName(code); FCheckBox box = new FCheckBox(String.format("%s (%s)", ce.getName(), code));
box.setSelected(null == preselectedSets ? false : preselectedSets.contains(code)); box.setName(code);
box.setEnabled(null == unselectableSets ? true : !unselectableSets.contains(code)); box.setSelected(null == preselectedSets ? false : preselectedSets.contains(code));
switch (ce.getType()) { box.setEnabled(null == unselectableSets ? true : !unselectableSets.contains(code));
case CORE: coreSets.add(box); break; switch (ce.getType()) {
case EXPANSION: expansionSets.add(box); break; case CORE: coreSets.add(box); break;
default: otherSets.add(box); break; case EXPANSION: expansionSets.add(box); break;
default: otherSets.add(box); break;
}
} }
} }
FPanel p = new FPanel(new MigLayout("insets 0, gap 0, center, wrap 3")); FPanel p = new FPanel(new MigLayout("insets 0, gap 0, center, wrap 3"));
p.setOpaque(false); p.setOpaque(false);
p.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE)); p.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE));
p.add(new FLabel.Builder().text("Choose sets").fontSize(18).build(), "center, span, wrap, gaptop 10"); p.add(new FLabel.Builder().text("Choose sets").fontSize(18).build(), "center, span, wrap, gaptop 10");
String constraints = "aligny top"; String constraints = "aligny top";
p.add(makeCheckBoxList(coreSets, "Core sets", true), constraints); p.add(makeCheckBoxList(coreSets, "Core sets", true), constraints);
p.add(makeCheckBoxList(expansionSets, "Expansions", false), constraints); p.add(makeCheckBoxList(expansionSets, "Expansions", false), constraints);
p.add(makeCheckBoxList(otherSets, "Other sets", false), constraints); p.add(makeCheckBoxList(otherSets, "Other sets", false), constraints);
final JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel(); final JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel();
overlay.setLayout(new MigLayout("insets 0, gap 0, wrap, ax center, ay center")); overlay.setLayout(new MigLayout("insets 0, gap 0, wrap, ax center, ay center"));
final Runnable cleanup = new Runnable() { final Runnable cleanup = new Runnable() {
@Override @Override
public void run() { public void run() {
SOverlayUtils.hideOverlay(); SOverlayUtils.hideOverlay();
} }
}; };
FButton btnOk = new FButton("OK"); FButton btnOk = new FButton("OK");
btnOk.addActionListener(new ActionListener() { btnOk.addActionListener(new ActionListener() {
@Override @Override
@@ -105,18 +107,18 @@ public class DialogChooseSets {
} }
southPanel.add(btnOk, "center, w 40%, h 20!"); southPanel.add(btnOk, "center, w 40%, h 20!");
southPanel.add(btnCancel, "center, w 40%, h 20!"); southPanel.add(btnCancel, "center, w 40%, h 20!");
p.add(southPanel, "dock south, gapBottom 10"); p.add(southPanel, "dock south, gapBottom 10");
overlay.add(p); overlay.add(p);
p.getRootPane().setDefaultButton(btnOk); p.getRootPane().setDefaultButton(btnOk);
SOverlayUtils.showOverlay(); SOverlayUtils.showOverlay();
} }
public void setOkCallback(Runnable onOk) { public void setOkCallback(Runnable onOk) {
okCallback = onOk; okCallback = onOk;
} }
// result accessors // result accessors
public List<String> getSelectedSets() { return selectedSets; } public List<String> getSelectedSets() { return selectedSets; }
public boolean getWantReprints() { return wantReprints; } public boolean getWantReprints() { return wantReprints; }
@@ -126,7 +128,7 @@ public class DialogChooseSets {
final FCheckBoxList cbl = new FCheckBoxList(false); final FCheckBoxList cbl = new FCheckBoxList(false);
cbl.setListData(sets.toArray()); cbl.setListData(sets.toArray());
cbl.setVisibleRowCount(Math.min(20, sets.size())); cbl.setVisibleRowCount(Math.min(20, sets.size()));
if (focused) { if (focused) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
@@ -135,23 +137,27 @@ public class DialogChooseSets {
} }
}); });
} }
JPanel pnl = new JPanel(new MigLayout("center, wrap")); JPanel pnl = new JPanel(new MigLayout("center, wrap"));
pnl.setOpaque(false); pnl.setOpaque(false);
pnl.add(new FLabel.Builder().text(title).build()); pnl.add(new FLabel.Builder().text(title).build());
pnl.add(new JScrollPane(cbl)); pnl.add(new JScrollPane(cbl));
return pnl; return pnl;
} }
private boolean choosableSet(final CardEdition ce) {
return !("LEA".equalsIgnoreCase(ce.getCode()) || "LEB".equalsIgnoreCase(ce.getCode()));
}
private void handleOk() { private void handleOk() {
for (FCheckBox box : choices) { for (FCheckBox box : choices) {
if (box.isSelected()) { if (box.isSelected()) {
selectedSets.add(box.getName()); selectedSets.add(box.getName());
} }
wantReprints = cbWantReprints.isSelected(); wantReprints = cbWantReprints.isSelected();
} }
if (null != okCallback) { if (null != okCallback) {
okCallback.run(); okCallback.run();
} }