From 37e79418071dd04e9cf51752d3c27413a8015103 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sun, 24 Jun 2012 22:44:37 +0400 Subject: [PATCH] sorting sets in drafts by release date --- .../java/mage/client/deckeditor/CardSelector.java | 9 +-------- .../mage/client/dialog/NewTournamentDialog.java | 14 ++++++-------- Mage.Sets/src/mage/sets/Sets.java | 11 +++++++++++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java index e04fbef65b..31ef0d80cb 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java @@ -149,14 +149,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene this.btnBooster.setVisible(true); this.btnClear.setVisible(true); this.cbExpansionSet.setVisible(true); - Object[] l = Sets.getInstance().values().toArray(); - Arrays.sort(l, new Comparator() { - @Override - public int compare(Object o1, Object o2) { - return ((ExpansionSet)o2).getReleaseDate().compareTo(((ExpansionSet)o1).getReleaseDate()); - } - }); - cbExpansionSet.setModel(new DefaultComboBoxModel(l)); + cbExpansionSet.setModel(new DefaultComboBoxModel(Sets.getInstance().getSortedByReleaseDate())); cbExpansionSet.insertItemAt("-- All sets", 0); cbExpansionSet.insertItemAt("-- Standard", 1); cbExpansionSet.setSelectedIndex(0); diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index dfc4c17e71..838f95f7e2 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -34,13 +34,6 @@ package mage.client.dialog; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.SpinnerNumberModel; import mage.Constants.MultiplayerAttackOption; import mage.Constants.RangeOfInfluence; import mage.cards.ExpansionSet; @@ -56,6 +49,11 @@ import mage.view.TableView; import mage.view.TournamentTypeView; import org.apache.log4j.Logger; +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -364,7 +362,7 @@ public class NewTournamentDialog extends MageDialog { } while (packs.size() < numPacks) { JComboBox pack = new JComboBox(); - pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray())); + pack.setModel(new DefaultComboBoxModel(Sets.getInstance().getSortedByReleaseDate())); pnlPacks.add(pack); packs.add(pack); pack.addActionListener(new java.awt.event.ActionListener() { diff --git a/Mage.Sets/src/mage/sets/Sets.java b/Mage.Sets/src/mage/sets/Sets.java index 2d9cd5ed93..20dd162ab6 100644 --- a/Mage.Sets/src/mage/sets/Sets.java +++ b/Mage.Sets/src/mage/sets/Sets.java @@ -384,4 +384,15 @@ public class Sets extends HashMap { out.close(); } } + + public ExpansionSet[] getSortedByReleaseDate() { + ExpansionSet[] sets = Sets.getInstance().values().toArray(new ExpansionSet[0]); + Arrays.sort(sets, new Comparator() { + @Override + public int compare(ExpansionSet o1, ExpansionSet o2) { + return o2.getReleaseDate().compareTo(o1.getReleaseDate()); + } + }); + return sets; + } }