mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
UI: added start selection value on choice dialog popup;
This commit is contained in:
parent
2d9fa97808
commit
e4dfa5925b
3 changed files with 42 additions and 1 deletions
|
@ -23,6 +23,7 @@ import mage.client.MageFrame;
|
||||||
import mage.client.util.SettingsManager;
|
import mage.client.util.SettingsManager;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.client.util.gui.MageDialogState;
|
import mage.client.util.gui.MageDialogState;
|
||||||
|
import org.jsoup.Connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -37,7 +38,19 @@ public class PickChoiceDialog extends MageDialog {
|
||||||
|
|
||||||
final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";
|
final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";
|
||||||
|
|
||||||
|
public void showDialog(Choice choice) {
|
||||||
|
showDialog(choice, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog(Choice choice, String startSelectionValue) {
|
||||||
|
showDialog(choice, null, null, startSelectionValue);
|
||||||
|
}
|
||||||
|
|
||||||
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) {
|
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) {
|
||||||
|
showDialog(choice, objectId, mageDialogState, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState, String startSelectionValue) {
|
||||||
this.choice = choice;
|
this.choice = choice;
|
||||||
|
|
||||||
setLabelText(this.labelMessage, choice.getMessage());
|
setLabelText(this.labelMessage, choice.getMessage());
|
||||||
|
@ -136,6 +149,23 @@ public class PickChoiceDialog extends MageDialog {
|
||||||
// final load
|
// final load
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
|
// start selection
|
||||||
|
if((startSelectionValue != null)){
|
||||||
|
int selectIndex = -1;
|
||||||
|
for(int i = 0; i < this.listChoices.getModel().getSize() - 1; i++){
|
||||||
|
KeyValueItem listItem = (KeyValueItem)this.listChoices.getModel().getElementAt(i);
|
||||||
|
if (listItem.Key.equals(startSelectionValue)){
|
||||||
|
selectIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(selectIndex >= 0){
|
||||||
|
this.listChoices.setSelectedIndex(selectIndex);
|
||||||
|
this.listChoices.ensureIndexIsVisible(selectIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ public interface Choice {
|
||||||
Map<String,String> getKeyChoices();
|
Map<String,String> getKeyChoices();
|
||||||
void setChoiceByKey(String choiceKey);
|
void setChoiceByKey(String choiceKey);
|
||||||
String getChoiceKey();
|
String getChoiceKey();
|
||||||
|
String getChoiceValue();
|
||||||
|
|
||||||
// search
|
// search
|
||||||
boolean isSearchEnabled();
|
boolean isSearchEnabled();
|
||||||
|
|
|
@ -149,12 +149,22 @@ public class ChoiceImpl implements Choice, Serializable {
|
||||||
return choiceKey;
|
return choiceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChoiceValue() {
|
||||||
|
if ((keyChoices != null) && (keyChoices.containsKey(choiceKey))){
|
||||||
|
return keyChoices.get(choiceKey);
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChoiceByKey(String choiceKey) {
|
public void setChoiceByKey(String choiceKey) {
|
||||||
String choiceToSet = keyChoices.get(choiceKey);
|
String choiceToSet = keyChoices.get(choiceKey);
|
||||||
if (choiceToSet != null) {
|
if (choiceToSet != null) {
|
||||||
this.choice = choiceToSet;
|
this.choice = choiceToSet;
|
||||||
this.choiceKey = choiceKey;
|
this.choiceKey = choiceKey;
|
||||||
|
this.chosen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue