sub-sort on name when editing decks

This commit is contained in:
BetaSteward 2011-02-13 23:48:43 -05:00
parent 127b7a9562
commit f8a26d4e7e
3 changed files with 43 additions and 7 deletions

View file

@ -256,7 +256,13 @@ class CardRarityComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
}
else {
return val;
}
}
}
@ -265,7 +271,13 @@ class CardCostComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
}
else {
return val;
}
}
}
@ -274,7 +286,13 @@ class CardColorComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
}
else {
return val;
}
}
}

View file

@ -35,7 +35,7 @@
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="321" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View file

@ -292,7 +292,13 @@ class CardViewRarityComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return o1.getRarity().compareTo(o2.getRarity());
int val = o1.getRarity().compareTo(o2.getRarity());
if (val == 0) {
return o1.getName().compareTo(o2.getName());
}
else {
return val;
}
}
}
@ -301,7 +307,13 @@ class CardViewCostComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
if (val == 0) {
return o1.getName().compareTo(o2.getName());
}
else {
return val;
}
}
}
@ -310,7 +322,13 @@ class CardViewColorComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return o1.getColor().compareTo(o2.getColor());
int val = o1.getColor().compareTo(o2.getColor());
if (val == 0) {
return o1.getName().compareTo(o2.getName());
}
else {
return val;
}
}
}