use of pcgen.facade.core.EquipmentSetFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method initEquipSet.
/**
* Initialise the equipment set facades, ensuring that the character has a
* default equipment set.
*/
private void initEquipSet() {
// Setup the default EquipSet if not already present
if (!charDisplay.hasEquipSet()) {
String id = EquipmentSetFacadeImpl.getNewIdPath(charDisplay, null);
EquipSet eSet = new EquipSet(id, LanguageBundle.getString("in_ieDefault"));
theCharacter.addEquipSet(eSet);
theCharacter.setCalcEquipSetId(id);
}
// Detach listeners from old set
if (equipSet.get() != null) {
EquipmentListFacade equippedItems = equipSet.get().getEquippedItems();
equippedItems.removeListListener(this);
equippedItems.removeEquipmentListListener(this);
}
// Make facades for each root equipset.
List<EquipmentSetFacade> eqSetList = new ArrayList<>();
EquipmentSetFacade currSet = null;
String currIdPath = theCharacter.getCalcEquipSetId();
for (EquipSet es : charDisplay.getEquipSet()) {
if (es.getParentIdPath().equals("0")) {
final EquipmentSetFacadeImpl facade = new EquipmentSetFacadeImpl(delegate, theCharacter, es, dataSet, purchasedEquip, todoManager, this);
eqSetList.add(facade);
if (es.getIdPath().equals(currIdPath)) {
currSet = facade;
}
}
}
equipmentSets.updateContents(eqSetList);
if (currSet != null) {
equipSet.set(currSet);
}
EquipmentSetFacade set = equipSet.get();
set.getEquippedItems().addListListener(this);
set.getEquippedItems().addEquipmentListListener(this);
refreshTotalWeight();
}
use of pcgen.facade.core.EquipmentSetFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method setEquipmentSet.
/**
* @see pcgen.core.facade.CharacterFacade#setEquipmentSet(pcgen.core.facade.EquipmentSetFacade)
*/
@Override
public void setEquipmentSet(EquipmentSetFacade set) {
EquipmentSetFacade oldSet = equipSet.get();
if (oldSet != null) {
oldSet.getEquippedItems().removeListListener(this);
oldSet.getEquippedItems().removeEquipmentListListener(this);
}
if (set instanceof EquipmentSetFacadeImpl) {
((EquipmentSetFacadeImpl) set).activateEquipSet();
}
equipSet.set(set);
set.getEquippedItems().addListListener(this);
set.getEquippedItems().addEquipmentListListener(this);
refreshTotalWeight();
}
Aggregations