Search in sources :

Example 1 with FactDefinition

use of pcgen.cdom.content.fact.FactDefinition 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 FactDefinition

use of pcgen.cdom.content.fact.FactDefinition in project pcgen by PCGen.

the class RequiredTokenTest method resetContext.

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

Example 3 with FactDefinition

use of pcgen.cdom.content.fact.FactDefinition in project pcgen by PCGen.

the class SelectableTokenTest method resetContext.

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

Example 4 with FactDefinition

use of pcgen.cdom.content.fact.FactDefinition in project pcgen by PCGen.

the class DisplayNameTokenTest method resetContext.

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

Example 5 with FactDefinition

use of pcgen.cdom.content.fact.FactDefinition in project pcgen by PCGen.

the class SelectableTokenIntegrationTest method resetContext.

private void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    cd = new FactDefinition();
    cd.setDisplayName(PROP_1);
    cd.setFormatManager(STRING_MGR);
    cd.setName(PROP_1);
    cd.setFactName(PROP_1);
    cd.setUsableLocation(Domain.class);
    cd.setVisibility(Visibility.DEFAULT);
}
Also used : FactDefinition(pcgen.cdom.content.fact.FactDefinition) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Aggregations

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