Search in sources :

Example 1 with PlayerCharacterWasClosedMessage

use of pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage in project pcgen by PCGen.

the class CharacterFacadeImpl method closeCharacter.

@Override
public void closeCharacter() {
    FacetLibrary.getFacet(LanguageFacet.class).removeDataFacetChangeListener(langListener);
    FacetLibrary.getFacet(TemplateFacet.class).removeDataFacetChangeListener(templateListener);
    FacetLibrary.getFacet(XPFacet.class).removeDataFacetChangeListener(xpListener);
    FacetLibrary.getFacet(AutoEquipmentFacet.class).removeDataFacetChangeListener(autoEquipListener);
    characterAbilities.closeCharacter();
    charLevelsFacade.closeCharacter();
    companionSupportFacade.closeCharacter();
    PluginManager.getInstance().getPostbox().handleMessage(new PlayerCharacterWasClosedMessage(this, theCharacter));
    Globals.getPCList().remove(theCharacter);
    lastExportChar = null;
    /*
		 * Unfortunately, a dummy rather than null is necessary because the UI
		 * does model swaps and such that do not pause events in the UI so that
		 * it is trying to update things that do not exist
		 */
    theCharacter = DUMMY_PC;
    charDisplay = null;
    dataSet.detachDelegates();
}
Also used : TemplateFacet(pcgen.cdom.facet.model.TemplateFacet) PlayerCharacterWasClosedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage) LanguageFacet(pcgen.cdom.facet.model.LanguageFacet) AutoEquipmentFacet(pcgen.cdom.facet.AutoEquipmentFacet) XPFacet(pcgen.cdom.facet.fact.XPFacet)

Example 2 with PlayerCharacterWasClosedMessage

use of pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage in project pcgen by PCGen.

the class PCGTrackerPlugin method handleMessage.

/**
	 * listens to messages from the GMGen system, and handles them as needed
	 * @param message the source of the event from the system
	 */
@Override
public void handleMessage(PCGenMessage message) {
    if (message instanceof FileMenuOpenMessage) {
        if (isActive()) {
            handleOpen();
        }
    } else if (message instanceof PlayerCharacterWasLoadedMessage) {
        PlayerCharacterWasLoadedMessage cmessage = (PlayerCharacterWasLoadedMessage) message;
        model.add(cmessage.getPc());
    } else if (message instanceof FocusOrStateChangeOccurredMessage) {
        if (isActive()) {
            charToolsItem.setEnabled(false);
            try {
                GMGenSystem.inst.openFileItem.setEnabled(true);
            } catch (Exception e) {
            // TODO Handle this?
            }
        } else {
            charToolsItem.setEnabled(true);
        }
    } else if (message instanceof GMGenBeingClosedMessage) {
        handleClose();
    } else /*else if (message instanceof SavePCGRequestMessage)
		 {
		 SavePCGRequestMessage smessage = (SavePCGRequestMessage) message;
		 savePC(smessage.getPC(), false);
		 }*/
    if (message instanceof PlayerCharacterWasClosedMessage) {
        PlayerCharacterWasClosedMessage cmessage = (PlayerCharacterWasClosedMessage) message;
        model.remove(cmessage.getPC());
    }
}
Also used : PlayerCharacterWasLoadedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasLoadedMessage) FocusOrStateChangeOccurredMessage(pcgen.pluginmgr.messages.FocusOrStateChangeOccurredMessage) FileMenuOpenMessage(gmgen.pluginmgr.messages.FileMenuOpenMessage) PlayerCharacterWasClosedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage) GMGenBeingClosedMessage(gmgen.pluginmgr.messages.GMGenBeingClosedMessage)

Example 3 with PlayerCharacterWasClosedMessage

use of pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage in project pcgen by PCGen.

the class PCGTrackerPlugin method removeSelected.

private void removeSelected() {
    for (Object obj : theView.getLoadedList().getSelectedValuesList()) {
        PlayerCharacter pc = model.get(obj);
        model.removeElement(obj);
        messageHandler.handleMessage(new PlayerCharacterWasClosedMessage(this, pc));
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PlayerCharacterWasClosedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage)

Aggregations

PlayerCharacterWasClosedMessage (pcgen.pluginmgr.messages.PlayerCharacterWasClosedMessage)3 FileMenuOpenMessage (gmgen.pluginmgr.messages.FileMenuOpenMessage)1 GMGenBeingClosedMessage (gmgen.pluginmgr.messages.GMGenBeingClosedMessage)1 AutoEquipmentFacet (pcgen.cdom.facet.AutoEquipmentFacet)1 XPFacet (pcgen.cdom.facet.fact.XPFacet)1 LanguageFacet (pcgen.cdom.facet.model.LanguageFacet)1 TemplateFacet (pcgen.cdom.facet.model.TemplateFacet)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 FocusOrStateChangeOccurredMessage (pcgen.pluginmgr.messages.FocusOrStateChangeOccurredMessage)1 PlayerCharacterWasLoadedMessage (pcgen.pluginmgr.messages.PlayerCharacterWasLoadedMessage)1