mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Fixed fast search compatibly with non string data models
This commit is contained in:
parent
c6d27bb3c9
commit
b697346cb6
3 changed files with 12 additions and 6 deletions
|
@ -744,7 +744,7 @@ public class ConnectDialog extends MageDialog {
|
|||
DefaultComboBoxModel flagModel = (DefaultComboBoxModel)cbFlag.getModel();
|
||||
String[] flagItem;
|
||||
|
||||
for(int i = 0; i < flagModel.getSize() - 1; i++){
|
||||
for(int i = 0; i < flagModel.getSize(); i++){
|
||||
flagItem = (String[])flagModel.getElementAt(i);
|
||||
choiceItems.put(flagItem[1], flagItem[0]);
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ public class PickChoiceDialog extends MageDialog {
|
|||
// start selection
|
||||
if((startSelectionValue != null)){
|
||||
int selectIndex = -1;
|
||||
for(int i = 0; i < this.listChoices.getModel().getSize() - 1; i++){
|
||||
for(int i = 0; i < this.listChoices.getModel().getSize(); i++){
|
||||
KeyValueItem listItem = (KeyValueItem)this.listChoices.getModel().getElementAt(i);
|
||||
if (listItem.Key.equals(startSelectionValue)){
|
||||
selectIndex = i;
|
||||
|
|
|
@ -32,8 +32,8 @@ public class FastSearchUtil {
|
|||
Map<String, Integer> choiceSorting = new HashMap<>(comboModel.getSize());
|
||||
String item;
|
||||
|
||||
for(int i = 0; i < comboModel.getSize() - 1; i++){
|
||||
item = (String)comboModel.getElementAt(i);
|
||||
for(int i = 0; i < comboModel.getSize(); i++){
|
||||
item = comboModel.getElementAt(i).toString();
|
||||
choiceItems.put(item, item);
|
||||
choiceSorting.put(item, i); // need so sorting
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class FastSearchUtil {
|
|||
|
||||
// current selection value restore
|
||||
String needSelectValue;
|
||||
needSelectValue = (String)comboModel.getSelectedItem();
|
||||
needSelectValue = comboModel.getSelectedItem().toString();
|
||||
|
||||
// ask for new value
|
||||
PickChoiceDialog dlg = new PickChoiceDialog();
|
||||
|
@ -52,7 +52,13 @@ public class FastSearchUtil {
|
|||
dlg.showDialog(choice, needSelectValue);
|
||||
if(choice.isChosen()){
|
||||
item = choice.getChoiceKey();
|
||||
comboModel.setSelectedItem(item);
|
||||
|
||||
// compatible select for object's models (use setSelectedIndex instead setSelectedObject)
|
||||
for(int i = 0; i < comboModel.getSize(); i++){
|
||||
if(comboModel.getElementAt(i).toString().equals(item)){
|
||||
combo.setSelectedIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue