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