use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class AbstractPCClassLevelTokenTestCase method classSetUp.
@BeforeClass
public static final void classSetUp() throws URISyntaxException {
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class Campaign method getSubCampaigns.
/**
* Returns a list of the Campaign objects that were loaded by this Campaign.
*
* @return A list of <tt>Campaign</tt>s loaded by this Campaign.
*/
public List<Campaign> getSubCampaigns() {
final List<CampaignSourceEntry> pccFiles = getSafeListFor(ListKey.FILE_PCC);
final List<Campaign> ret = new ArrayList<>(pccFiles.size());
for (final CampaignSourceEntry fileName : pccFiles) {
final Campaign campaign = Globals.getCampaignByURI(fileName.getURI(), true);
if (campaign != null) {
ret.add(campaign);
}
}
return ret;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class Gui2CampaignInfoFactory method appendCampaignInfo.
private void appendCampaignInfo(Campaign aCamp, final HtmlInfoBuilder infoText) {
infoText.appendLineBreak();
if (aCamp.getSizeOfListFor(ListKey.FILE_COVER) > 0) {
CampaignSourceEntry image = aCamp.getSafeListFor(ListKey.FILE_COVER).get(0);
infoText.appendIconElement(image.getURI().toString());
}
if (aCamp.getSizeOfListFor(ListKey.FILE_LOGO) > 0) {
CampaignSourceEntry image = aCamp.getSafeListFor(ListKey.FILE_LOGO).get(0);
infoText.appendIconElement(image.getURI().toString());
}
if (aCamp.getSizeOfListFor(ListKey.FILE_COVER) > 0 || aCamp.getSizeOfListFor(ListKey.FILE_LOGO) > 0) {
infoText.appendLineBreak();
}
String bString = SourceFormat.getFormattedString(aCamp, SourceFormat.MEDIUM, true);
if (StringUtils.isEmpty(bString)) {
bString = SourceFormat.getFormattedString(aCamp, SourceFormat.LONG, true);
}
//$NON-NLS-1$
infoText.appendI18nElement("in_sumSource", bString);
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_infByPub", aCamp.getSafe(StringKey.PUB_NAME_LONG));
infoText.appendLineBreak();
// Add the data set release status
Status status = aCamp.getSafe(ObjectKey.STATUS);
//$NON-NLS-1$
infoText.appendI18nElement(//$NON-NLS-1$
"in_infStatus", //$NON-NLS-1$ //$NON-NLS-2$
"<font color=\"#" + Integer.toHexString(status.getColor()) + "\">" + status + //$NON-NLS-1$
"</font>");
infoText.appendLineBreak();
String descr = aCamp.get(StringKey.DESCRIPTION);
if (descr != null) {
//$NON-NLS-1$
infoText.appendI18nElement("in_infDesc", descr);
infoText.appendLineBreak();
}
// Add the website URLs
List<CampaignURL> webURLs = getUrlListForKind(aCamp, URLKind.WEBSITE);
if (!webURLs.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nElement("in_infWebsite", buildURLListString(webURLs));
infoText.appendLineBreak();
}
if (!aCamp.getType().isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nElement("in_infType", aCamp.getType());
infoText.appendSpacer();
}
infoText.appendI18nElement("in_infRank", String.valueOf(//$NON-NLS-1$
aCamp.getSafe(IntegerKey.CAMPAIGN_RANK)));
if (!StringUtil.join(aCamp.getSafeListFor(ListKey.GAME_MODE), ", ").isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement(//$NON-NLS-1$
"in_infGame", StringUtil.join(aCamp.getSafeListFor(ListKey.GAME_MODE), ", "));
}
infoText.appendLineBreak();
// Add the purchase URLs
List<CampaignURL> purchaseURLs = getUrlListForKind(aCamp, URLKind.PURCHASE);
if (!purchaseURLs.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nElement("in_infPurchase", buildURLListString(purchaseURLs));
infoText.appendLineBreak();
}
// Add the survey URLs
List<CampaignURL> surveyURLs = getUrlListForKind(aCamp, URLKind.SURVEY);
if (!surveyURLs.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nElement("in_infSurvey", buildURLListString(surveyURLs));
infoText.appendLineBreak();
}
String preString = PrerequisiteUtilities.preReqHTMLStringsForList(null, null, aCamp.getPrerequisiteList(), false);
if (!preString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement("in_InfoRequirements", preString);
}
boolean infoDisplayed = false;
List<String> info = aCamp.getListFor(ListKey.INFO_TEXT);
if (info != null) {
if (!infoDisplayed) {
infoText.appendLineBreak();
}
//$NON-NLS-1$
infoText.appendSmallTitleElement(LanguageBundle.getString("in_infInf"));
infoText.appendLineBreak();
for (String infotext : info) {
infoText.append(infotext);
infoText.appendLineBreak();
}
infoDisplayed = true;
}
List<String> copyright = aCamp.getListFor(ListKey.SECTION_15);
if (copyright != null) {
if (!infoDisplayed) {
infoText.appendLineBreak();
}
//$NON-NLS-1$
infoText.appendSmallTitleElement(LanguageBundle.getString("in_infCopyright"));
infoText.appendLineBreak();
for (String license : copyright) {
infoText.append(license);
infoText.appendLineBreak();
}
}
List<Campaign> subCampaigns = aCamp.getSubCampaigns();
List<CampaignSourceEntry> notFoundSubCampaigns = aCamp.getNotFoundSubCampaigns();
if (subCampaigns != null && notFoundSubCampaigns != null && (!subCampaigns.isEmpty() || !notFoundSubCampaigns.isEmpty())) {
infoText.appendLineBreak();
infoText.appendSmallTitleElement(LanguageBundle.getString(//$NON-NLS-1$
"in_infIncludedCampaigns"));
infoText.appendLineBreak();
for (Campaign subCamp : subCampaigns) {
infoText.append(subCamp.getDisplayName());
infoText.appendLineBreak();
}
for (CampaignSourceEntry subCse : notFoundSubCampaigns) {
infoText.append(LanguageBundle.getFormattedString("in_infMissingCampaign", subCse.getURI()));
infoText.appendLineBreak();
}
}
infoText.appendLineBreak();
infoText.appendI18nElement("in_infPccPath", aCamp.getSourceURI().getPath());
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class AbstractBasicCampaignToken method unparse.
public String[] unparse(LoadContext context, Campaign campaign) {
Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, getListKey());
Collection<CampaignSourceEntry> added = cseChanges.getAdded();
if (added == null) {
//empty indicates no token
return null;
}
Set<String> set = new TreeSet<>();
for (CampaignSourceEntry cse : added) {
set.add(cse.getLSTformat());
}
return set.toArray(new String[set.size()]);
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class AbstractBasicCampaignToken method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
if (cse == null) {
return ParseResult.INTERNAL_ERROR;
}
context.getObjectContext().addToList(campaign, getListKey(), cse);
return ParseResult.SUCCESS;
}
Aggregations