Search in sources :

Example 1 with FactSetDefinition

use of pcgen.cdom.content.factset.FactSetDefinition in project pcgen by PCGen.

the class Gui2InfoFactory method appendFacts.

private void appendFacts(HtmlInfoBuilder infoText, CDOMObject cdo) {
    Class<? extends CDOMObject> cl = cdo.getClass();
    LoadContext context = Globals.getContext();
    Collection<FactDefinition> defs = context.getReferenceContext().getConstructedCDOMObjects(FactDefinition.class);
    for (FactDefinition<?, ?> def : defs) {
        if (def.getUsableLocation().isAssignableFrom(cl)) {
            Visibility visibility = def.getVisibility();
            if (visibility != null && visibility.isVisibleTo(View.VISIBLE_DISPLAY)) {
                FactKey<?> fk = def.getFactKey();
                Indirect<?> fact = cdo.get(fk);
                if (fact != null) {
                    infoText.appendSpacer();
                    infoText.append("<b>");
                    infoText.append(fk.toString());
                    infoText.append(":</b>&nbsp;");
                    infoText.append(fact.getUnconverted());
                }
            }
        }
    }
    Collection<FactSetDefinition> setdefs = context.getReferenceContext().getConstructedCDOMObjects(FactSetDefinition.class);
    for (FactSetDefinition<?, ?> def : setdefs) {
        if (def.getUsableLocation().isAssignableFrom(cl)) {
            Visibility visibility = def.getVisibility();
            if (visibility != null && visibility.isVisibleTo(View.VISIBLE_DISPLAY)) {
                FactSetKey<?> fk = def.getFactSetKey();
                String s = getSetString(cdo, fk);
                if (s != null) {
                    infoText.appendSpacer();
                    infoText.append("<b>");
                    infoText.append(fk.toString());
                    infoText.append(":</b>&nbsp;");
                    infoText.append(s);
                }
            }
        }
    }
}
Also used : FactDefinition(pcgen.cdom.content.fact.FactDefinition) FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) LoadContext(pcgen.rules.context.LoadContext) Visibility(pcgen.util.enumeration.Visibility)

Example 2 with FactSetDefinition

use of pcgen.cdom.content.factset.FactSetDefinition in project pcgen by PCGen.

the class FactSetIntegrationTest method setUp.

@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
    TokenRegistration.clearTokens();
    super.setUp();
    cd = new FactSetDefinition();
    cd.setDisplayName(PROP_1);
    cd.setFormatManager(STRING_MGR);
    cd.setName(PROP_1);
    cd.setFactSetName(PROP_1);
    cd.setUsableLocation(PCTemplate.class);
    cd.setVisibility(Visibility.DEFAULT);
    primaryContext.getReferenceContext().importObject(cd);
    SourceFileLoader.processFactDefinitions(primaryContext);
    secondaryContext.getReferenceContext().importObject(cd);
    SourceFileLoader.processFactDefinitions(secondaryContext);
}
Also used : FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition)

Example 3 with FactSetDefinition

use of pcgen.cdom.content.factset.FactSetDefinition in project pcgen by PCGen.

the class BuildUtilities method createFactSet.

/**
	 * Define a new FACTSET to hold a set of strings for a type of object. 
	 * @param context The context in which the data is being loaded 
	 * @param factsetname The name of the new FACTSET
	 * @param cls The object type the set will apply to.
	 * @return The full definition, already loaded into the context. 
	 */
public static FactSetDefinition<?, String> createFactSet(LoadContext context, String factsetname, Class<? extends Loadable> cls) {
    FactSetDefinition<?, String> fd = new FactSetDefinition<>();
    fd.setUsableLocation(cls);
    fd.setName("*" + factsetname);
    fd.setFactSetName(factsetname);
    fd.setFormatManager(new StringManager());
    context.getReferenceContext().importObject(fd);
    return fd;
}
Also used : FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) StringManager(pcgen.base.format.StringManager)

Example 4 with FactSetDefinition

use of pcgen.cdom.content.factset.FactSetDefinition in project pcgen by PCGen.

the class FactSetDefTokenTest method resetContext.

protected void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    fd = new FactSetDefinition();
}
Also used : FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 5 with FactSetDefinition

use of pcgen.cdom.content.factset.FactSetDefinition in project pcgen by PCGen.

the class FactSetLstTest method setUp.

@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
    TokenRegistration.clearTokens();
    super.setUp();
    FactSetDefinition fd = new FactSetDefinition();
    fd.setName("DEITY.Possibility");
    fd.setFactSetName("Possibility");
    fd.setUsableLocation(Domain.class);
    fd.setFormatManager(new StringManager());
    fd.setVisibility(Visibility.HIDDEN);
    primaryContext.getReferenceContext().importObject(fd);
    secondaryContext.getReferenceContext().importObject(fd);
    SourceFileLoader.processFactDefinitions(primaryContext);
    SourceFileLoader.processFactDefinitions(secondaryContext);
}
Also used : FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) StringManager(pcgen.base.format.StringManager)

Aggregations

FactSetDefinition (pcgen.cdom.content.factset.FactSetDefinition)5 StringManager (pcgen.base.format.StringManager)2 URI (java.net.URI)1 FactDefinition (pcgen.cdom.content.fact.FactDefinition)1 ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)1 LoadContext (pcgen.rules.context.LoadContext)1 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)1 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)1 Visibility (pcgen.util.enumeration.Visibility)1