mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
UI: added custom sorting in choice dialog
This commit is contained in:
parent
35a950dc80
commit
af0c77a409
3 changed files with 37 additions and 6 deletions
|
|
@ -68,4 +68,9 @@ public interface Choice {
|
|||
void setSearchEnabled(boolean isEnabled);
|
||||
void setSearchText(String searchText);
|
||||
String getSearchText();
|
||||
|
||||
// sorting
|
||||
boolean isSortEnabled();
|
||||
void setSortData(Map<String, Integer> sortData);
|
||||
Map<String, Integer> getSortData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
protected String choiceKey;
|
||||
protected Set<String> choices = new LinkedHashSet<>();
|
||||
protected Map<String, String> keyChoices = new LinkedHashMap<>();
|
||||
protected Map<String, Integer> sortData = new LinkedHashMap<>();
|
||||
protected String message;
|
||||
protected String subMessage;
|
||||
protected boolean searchEnabled = true; // enable for all windows by default
|
||||
|
|
@ -70,7 +71,8 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
this.searchText = choice.searchText;
|
||||
this.choices.addAll(choice.choices);
|
||||
this.choiceKey = choice.choiceKey;
|
||||
this.keyChoices = choice.keyChoices; // list should never change for the same object so copy by reference
|
||||
this.keyChoices = choice.keyChoices; // list should never change for the same object so copy by reference TODO: check errors with that, it that ok? Color list is static
|
||||
this.sortData = choice.sortData;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -193,4 +195,19 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
return this.searchText;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isSortEnabled(){
|
||||
return (this.sortData != null) && !this.sortData.isEmpty();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setSortData(Map<String, Integer> sortData){
|
||||
this.sortData = sortData;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getSortData(){
|
||||
return this.sortData;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue