use of main.swing.generic.components.editors.lists.ListChooser in project Eidolons by IDemiurge.
the class ListEditor method launch.
@Override
public String launch(String value, String name) {
if (listData == null && !listDataSet) {
if (res_name != null) {
listData = ResourceManager.getFilesInFolder(res_name);
// StringMaster.formatResList(listData);
Collections.sort(listData);
} else if (ENUM) {
// TODO get enum class by name (constants)
if (enumClass != null) {
listData = EnumMaster.getEnumConstantNames(enumClass);
} else {
Class<?> ENUM_CLASS = EnumMaster.getEnumClass(name);
if (// TODO find
ENUM_CLASS == null) {
ENUM_CLASS = EnumMaster.getEnumClass(name, MACRO_CONTENT_CONSTS.class);
}
listData = EnumMaster.getEnumConstantNames(ENUM_CLASS);
StringMaster.formatList(listData);
}
} else {
if (TYPE == null) {
TYPE = DC_TYPE.ABILS;
subgroup = name;
if (!XML_Reader.getSubGroups(TYPE.toString()).contains(subgroup)) {
Err.info("No subgroup found! - " + subgroup);
}
if (getBASE_TYPE() instanceof DC_TYPE) {
switch((DC_TYPE) getBASE_TYPE()) {
case BF_OBJ:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
case CHARS:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
case UNITS:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
}
}
}
listData = DataManager.getTypeNamesGroup(TYPE, subgroup);
if (filterGroup != null) {
listData = DataManager.getTypeNamesGroup(TYPE, filterGroup);
} else if (filterSubgroup != null) {
listData = DataManager.getTypesSubGroupNames(TYPE, filterSubgroup);
}
if (getConditions() != null) {
Ref ref = new Ref(Game.game, getEntity().getId());
listData = DataManager.toStringList(new Filter<ObjType>(ref, getConditions()).filter(DataManager.toTypeList(listData, TYPE)));
}
}
}
ListChooser listChooser;
if (mode == SELECTION_MODE.SINGLE) {
listChooser = new ListChooser(listData, ENUM, TYPE);
} else {
secondListData = new ArrayList<>();
if (value != null) {
if (!value.equals(ContentManager.getDefaultEmptyValue())) {
secondListData = ListMaster.toList(value.toString(), ENUM);
}
}
listChooser = new ListChooser(listData, secondListData, ENUM, TYPE);
}
if (ENUM || TYPE == DC_TYPE.UNITS || TYPE == DC_TYPE.CHARS || TYPE == DC_TYPE.DEITIES) {
columns = 1;
}
listChooser.setColumns(columns);
listChooser.setVarTypes(getVarTypes());
listChooser.setVarClass(getVarTypesClass());
String newValue = listChooser.getString();
return newValue;
}
use of main.swing.generic.components.editors.lists.ListChooser in project Eidolons by IDemiurge.
the class NameMaster method pickName.
public static String pickName(Entity hero) {
List<String> nameGroups = StringMaster.openContainer(getNamesGroups(getBg(hero)), " ");
List<String> list = new ArrayList<>();
for (String nameGroup : nameGroups) {
list.addAll(StringMaster.openContainer(getNamesForGroup(nameGroup, EntityCheckMaster.getGender(hero) == HeroEnums.GENDER.FEMALE), " "));
}
String name = new ListChooser(SELECTION_MODE.MULTIPLE, list, false).choose();
if (name != null) {
return StringMaster.joinStringList(StringMaster.openContainer(name), " ", true);
}
return null;
}
use of main.swing.generic.components.editors.lists.ListChooser in project Eidolons by IDemiurge.
the class LE_Palette method deletePalettes.
protected void deletePalettes(boolean removeFile) {
// int i = DialogMaster.optionChoice(paletteTabs.getTabs().toArray(),
// "choose palette to remove");
// paletteTabs.removeTab(i);
List<String> list = new ArrayList<>();
for (HC_Tab tab : paletteTabs.getTabs()) {
list.add(tab.getName());
}
String string = new ListChooser(SELECTION_MODE.MULTIPLE, list, false).choose();
for (String ws : StringMaster.open(string)) {
int i = list.indexOf(ws);
paletteTabs.removeTab(i);
if (removeFile) {
FileManager.getFile(getWorkspaceFolder() + ws + ".xml").delete();
}
}
// if (!removeFile) {
// if (DialogMaster.confirm("Remove File?"))
// FileManager.getFile(getWorkspaceFolder()).delete();
// } else
refresh();
}
use of main.swing.generic.components.editors.lists.ListChooser in project Eidolons by IDemiurge.
the class PresetLauncher method choosePreset.
public static Preset choosePreset(List<Preset> presets) {
List<String> list = new ArrayList<>();
for (Preset s : presets) {
list.add(s.toString());
}
String result = new ListChooser(SELECTION_MODE.SINGLE, list, false).choose();
if (result == null) {
return null;
}
Preset preset = PresetMaster.findPreset(result);
if (preset != null) {
PresetMaster.setPreset(preset);
}
return preset;
}
use of main.swing.generic.components.editors.lists.ListChooser in project Eidolons by IDemiurge.
the class TestLauncher method choose.
public String choose(DC_TYPE type) {
String filterGroup = getFilterGroup(type);
List<String> data = DataManager.getTypeNames(type);
if (!filterGroup.isEmpty()) {
data = DataManager.getTypesSubGroupNames(type, filterGroup);
}
String objects = new ListChooser(SELECTION_MODE.MULTIPLE, data, type).choose();
return objects;
}
Aggregations