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> ");
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> ");
infoText.append(s);
}
}
}
}
}
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);
}
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;
}
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();
}
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);
}
Aggregations