use of pcgen.facade.core.AbilityCategoryFacade in project pcgen by PCGen.
the class AbilityChooserTab method adviseTodo.
@Override
public void adviseTodo(String fieldName) {
CategoryTableModel model = (CategoryTableModel) categoryTable.getModel();
model.refilter();
for (int i = 0; i < model.getRowCount(); i++) {
AbilityCategoryFacade category = model.getCategory(i);
if (category.getName().equals(fieldName)) {
categoryTable.getSelectionModel().setSelectionInterval(i, i);
return;
}
}
}
use of pcgen.facade.core.AbilityCategoryFacade in project pcgen by PCGen.
the class CharacterAbilities method rebuildAbilityLists.
/**
* Rebuild the ability lists for the character to include the character's
* current abilities.
*/
synchronized void rebuildAbilityLists() {
Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap = new LinkedHashMap<>();
DefaultListFacade<AbilityCategoryFacade> workingActiveCategories = new DefaultListFacade<>();
for (AbilityCategoryFacade category : dataSetFacade.getAbilities().getKeys()) {
AbilityCategory cat = (AbilityCategory) category;
for (CNAbility cna : theCharacter.getPoolAbilities(cat)) {
addCategorisedAbility(cna, workingAbilityListMap);
}
// deal with visibility
boolean visible = cat.isVisibleTo(theCharacter, View.VISIBLE_DISPLAY);
if (visible && !workingActiveCategories.containsElement(cat)) {
int index = getCatIndex(cat, workingActiveCategories);
workingActiveCategories.addElement(index, cat);
}
if (!visible && workingActiveCategories.containsElement(cat)) {
workingActiveCategories.removeElement(cat);
// updateAbilityCategoryTodo(cat);
}
if (visible) {
adviseSelectionChangeLater(cat);
}
}
// Update map contents
for (AbilityCategoryFacade category : workingAbilityListMap.keySet()) {
DefaultListFacade<AbilityFacade> workingListFacade = workingAbilityListMap.get(category);
DefaultListFacade<AbilityFacade> masterListFacade = abilityListMap.get(category);
if (masterListFacade == null) {
abilityListMap.put(category, workingListFacade);
} else {
masterListFacade.updateContentsNoOrder(workingListFacade.getContents());
}
updateAbilityCategoryTodo((AbilityCategory) category);
}
Set<AbilityCategoryFacade> origCats = new HashSet<>(abilityListMap.keySet());
for (AbilityCategoryFacade category : origCats) {
if (!workingAbilityListMap.containsKey(category)) {
if (workingActiveCategories.containsElement(category)) {
abilityListMap.get(category).clearContents();
} else {
abilityListMap.remove(category);
}
updateAbilityCategoryTodo((AbilityCategory) category);
}
}
activeCategories.updateContents(workingActiveCategories.getContents());
}
use of pcgen.facade.core.AbilityCategoryFacade in project pcgen by PCGen.
the class CharacterAbilities method removeElement.
private void removeElement(CNAbilitySelection cnas) {
CNAbility cas = cnas.getCNAbility();
Ability ability = cas.getAbility();
AbilityCategoryFacade cat = (AbilityCategoryFacade) cas.getAbilityCategory();
DefaultListFacade<AbilityFacade> listFacade = abilityListMap.get(cat);
if (listFacade != null) {
listFacade.removeElement(ability);
}
}
use of pcgen.facade.core.AbilityCategoryFacade in project pcgen by PCGen.
the class CharacterAbilitiesTest method testRebuildAbilityListsNoMult.
/**
* Test method for {@link pcgen.gui2.facade.CharacterAbilities#rebuildAbilityLists()}.
*/
@Test
public final void testRebuildAbilityListsNoMult() {
PlayerCharacter pc = getCharacter();
CharacterAbilities ca = new CharacterAbilities(pc, uiDelegate, dataset, todoManager);
ca.rebuildAbilityLists();
ListFacade<AbilityCategoryFacade> categories = ca.getActiveAbilityCategories();
assertNotNull("Categories should not be null", categories);
assertTrue("Feat should be active", categories.containsElement(AbilityCategory.FEAT));
ListFacade<AbilityFacade> abilities = ca.getAbilities(AbilityCategory.FEAT);
assertNotNull("Feat list should not be null", abilities);
assertTrue("Feat list should be empty", abilities.isEmpty());
// Add an entry - note rebuild is implicit
Ability fencing = TestHelper.makeAbility("fencing", AbilityCategory.FEAT, "sport");
addAbility(AbilityCategory.FEAT, fencing);
abilities = ca.getAbilities(AbilityCategory.FEAT);
assertEquals("Feat list should have one entry", 1, abilities.getSize());
Ability abilityFromList = (Ability) abilities.getElementAt(0);
assertEquals("Should have found fencing", fencing, abilityFromList);
}
Aggregations