forked from External/mage
Revert "Feature/Add Set Selection filtering"
This commit is contained in:
parent
054cf4763a
commit
357d126596
6 changed files with 69 additions and 1017 deletions
|
|
@ -3,60 +3,54 @@ package mage.client.util.gui;
|
|||
import mage.choices.ChoiceImpl;
|
||||
import mage.client.dialog.PickChoiceDialog;
|
||||
|
||||
//import java.util.ArrayList;
|
||||
import mage.client.dialog.CheckBoxList;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
//import javax.swing.text.Position;
|
||||
|
||||
//import org.apache.log4j.helpers.LogLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class FastSearchUtil {
|
||||
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set(s) or expansion(s)";
|
||||
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set(s) or expansion(s)";
|
||||
public class FastSearchUtil {
|
||||
|
||||
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
|
||||
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
|
||||
|
||||
/**
|
||||
* Show fast choice modal dialog with incremental searching for any string CheckBoxList components
|
||||
* @param combo CheckBoxList control with default data model
|
||||
* Show fast choice modal dialog with incremental searching for any string combobox components
|
||||
* @param combo combobox control with default data model
|
||||
* @param chooseMessage caption message for dialog
|
||||
*/
|
||||
public static void showFastSearchForStringComboBox(CheckBoxList combo, String chooseMessage){
|
||||
// fast search/choice dialog for string combobox
|
||||
|
||||
*/
|
||||
public static void showFastSearchForStringComboBox(JComboBox combo, String chooseMessage){
|
||||
// fast search/choice dialog for string combobox
|
||||
|
||||
mage.choices.Choice choice = new ChoiceImpl(false);
|
||||
|
||||
// collect data from expansion combobox (String)
|
||||
DefaultListModel comboModel = (DefaultListModel)combo.getModel();
|
||||
DefaultComboBoxModel comboModel = (DefaultComboBoxModel)combo.getModel();
|
||||
Map<String, String> choiceItems = new HashMap<>(comboModel.getSize());
|
||||
Map<String, Integer> choiceSorting = new HashMap<>(comboModel.getSize());
|
||||
String item;
|
||||
|
||||
for(int i = 0; i < comboModel.size(); 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
|
||||
}
|
||||
|
||||
|
||||
choice.setKeyChoices(choiceItems);
|
||||
choice.setSortData(choiceSorting);
|
||||
choice.setMessage(chooseMessage);
|
||||
|
||||
// current selection value restore
|
||||
String needSelectValue;
|
||||
needSelectValue = comboModel.firstElement().toString();
|
||||
needSelectValue = comboModel.getSelectedItem().toString();
|
||||
|
||||
// ask for new value
|
||||
PickChoiceDialog dlg = new PickChoiceDialog(combo);
|
||||
PickChoiceDialog dlg = new PickChoiceDialog();
|
||||
dlg.setWindowSize(300, 500);
|
||||
dlg.showDialog(choice, needSelectValue);
|
||||
if(choice.isChosen()){
|
||||
if(choice.isChosen()){
|
||||
item = choice.getChoiceKey();
|
||||
|
||||
// compatible select for object's models (use setSelectedIndex instead setSelectedObject)
|
||||
|
|
@ -66,14 +60,5 @@ public class FastSearchUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int[] choiseValue=combo.getCheckedIndices();
|
||||
ListModel x= combo.getModel();
|
||||
for(int itemIndex: choiseValue){
|
||||
LogLog.warn(String.format("%d:%s",itemIndex,x.getElementAt(itemIndex).toString()));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue