diff --git a/Mage.Client/src/main/java/mage/client/constants/Constants.java b/Mage.Client/src/main/java/mage/client/constants/Constants.java index 4401592754..a71ccc5750 100644 --- a/Mage.Client/src/main/java/mage/client/constants/Constants.java +++ b/Mage.Client/src/main/java/mage/client/constants/Constants.java @@ -32,7 +32,6 @@ import javax.swing.BorderFactory; import javax.swing.border.Border; /** - * * @author BetaSteward_at_googlemail.com */ public final class Constants { @@ -116,22 +115,12 @@ public final class Constants { } public static SortBy getByString(String text) { - switch (text) { - case "Card Type": - return CARD_TYPE; - case "Casting Cost": - return CASTING_COST; - case "Rarity": - return RARITY; - case "Color": - return COLOR; - case "Color Identity": - return COLOR_IDENTITY; - case "Name": - return NAME; - default: - return UNSORTED; + for (SortBy sortBy : values()) { + if (sortBy.text.equals(text)) { + return sortBy; + } } + return UNSORTED; } } diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/SortSetting.java b/Mage.Client/src/main/java/mage/client/deckeditor/SortSetting.java index 3301cc9039..ed08c68931 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/SortSetting.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/SortSetting.java @@ -31,16 +31,15 @@ import mage.client.constants.Constants.SortBy; import mage.client.dialog.PreferencesDialog; /** - * * @author LevelX2 */ public abstract class SortSetting { - + SortBy sortBy; int sortIndex; boolean ascending; boolean pilesToggle; - + final String prefSortBy; final String prefSortIndex; final String prefSortAscending; @@ -60,7 +59,7 @@ public abstract class SortSetting { this.ascending = PreferencesDialog.getCachedValue(this.prefSortAscending, "1").equals("1"); this.pilesToggle = PreferencesDialog.getCachedValue(this.prefPilesToggle, "true").equals("true"); } - + public void setSortBy(SortBy sortBy) { this.sortBy = sortBy; PreferencesDialog.saveValue(prefSortBy, sortBy.toString()); @@ -73,12 +72,12 @@ public abstract class SortSetting { public void setAscending(boolean ascending) { this.ascending = ascending; - PreferencesDialog.saveValue(this.prefSortAscending, this.ascending ? "1":"0"); + PreferencesDialog.saveValue(this.prefSortAscending, this.ascending ? "1" : "0"); } public void setPilesToggle(boolean pileToggle) { this.pilesToggle = pileToggle; - PreferencesDialog.saveValue(this.prefSortAscending, this.pilesToggle ? "true":"false"); + PreferencesDialog.saveValue(this.prefSortAscending, this.pilesToggle ? "true" : "false"); } public SortBy getSortBy() {