mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
Added auto enabled search for all pickup dialogs with many items;
This commit is contained in:
parent
00d7a1f336
commit
531b5bc569
2 changed files with 13 additions and 1 deletions
|
@ -168,6 +168,7 @@ public class PickChoiceDialog extends MageDialog {
|
|||
int maxSel = this.listChoices.getModel().getSize() - 1;
|
||||
if(newSel <= maxSel){
|
||||
this.listChoices.setSelectedIndex(newSel);
|
||||
this.listChoices.ensureIndexIsVisible(newSel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,6 +176,7 @@ public class PickChoiceDialog extends MageDialog {
|
|||
int newSel = this.listChoices.getSelectedIndex() - 1;
|
||||
if(newSel >= 0){
|
||||
this.listChoices.setSelectedIndex(newSel);
|
||||
this.listChoices.ensureIndexIsVisible(newSel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ import java.util.Set;
|
|||
*/
|
||||
public class ChoiceImpl implements Choice, Serializable {
|
||||
|
||||
private int ENABLE_SEARCH_FOR_ITEMS_COUNT = 5; // enable search for choices more then X items (for non standard choices)
|
||||
|
||||
protected boolean chosen;
|
||||
protected final boolean required;
|
||||
protected String choice;
|
||||
|
@ -48,7 +50,7 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
protected Map<String, String> keyChoices = new LinkedHashMap<>();
|
||||
protected String message;
|
||||
protected String subMessage;
|
||||
protected boolean searchEnabled;
|
||||
protected boolean searchEnabled = true;
|
||||
protected String searchText;
|
||||
|
||||
public ChoiceImpl() {
|
||||
|
@ -70,6 +72,12 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
this.keyChoices = choice.keyChoices; // list should never change for the same object so copy by reference
|
||||
}
|
||||
|
||||
private void autoSearchEnable(){
|
||||
if((this.choices != null) && (this.choices.size() >= ENABLE_SEARCH_FOR_ITEMS_COUNT)){
|
||||
this.setSearchEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChosen() {
|
||||
return chosen;
|
||||
|
@ -106,6 +114,7 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
@Override
|
||||
public void setChoices(Set<String> choices) {
|
||||
this.choices = choices;
|
||||
autoSearchEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,6 +148,7 @@ public class ChoiceImpl implements Choice, Serializable {
|
|||
@Override
|
||||
public void setKeyChoices(Map<String, String> choices) {
|
||||
keyChoices = choices;
|
||||
autoSearchEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue