Search in sources :

Example 6 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Ability ability, String value) {
    Visibility vis;
    if (value.equals("YES")) {
        vis = Visibility.DEFAULT;
    } else if (value.equals("DISPLAY")) {
        vis = Visibility.DISPLAY_ONLY;
    } else if (value.equals("EXPORT")) {
        vis = Visibility.OUTPUT_ONLY;
    } else if (value.equals("NO")) {
        vis = Visibility.HIDDEN;
    } else {
        return new ParseResult.Fail("Unable to understand " + getTokenName() + " tag: " + value, context);
    }
    context.getObjectContext().put(ability, ObjectKey.VISIBILITY, vis);
    return ParseResult.SUCCESS;
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Visibility(pcgen.util.enumeration.Visibility)

Example 7 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method parseNonEmptyToken.

@Override
public ParseResult parseNonEmptyToken(LoadContext context, AbilityCategory ac, String value) {
    Visibility vis;
    if (value.equals("YES")) {
        vis = Visibility.DEFAULT;
    } else if (value.equals("QUALIFY")) {
        vis = Visibility.QUALIFY;
    } else if (value.equals("NO")) {
        vis = Visibility.HIDDEN;
    } else {
        return new ParseResult.Fail("Unable to understand " + getTokenName() + " tag: " + value, context);
    }
    ac.setVisible(vis);
    return ParseResult.SUCCESS;
}
Also used : Visibility(pcgen.util.enumeration.Visibility)

Example 8 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method unparse.

@Override
public String[] unparse(LoadContext context, PCTemplate template) {
    Visibility vis = context.getObjectContext().getObject(template, ObjectKey.VISIBILITY);
    if (vis == null) {
        return null;
    }
    String visString;
    if (vis.equals(Visibility.DEFAULT)) {
        visString = "YES";
    } else if (vis.equals(Visibility.DISPLAY_ONLY)) {
        visString = "DISPLAY";
    } else if (vis.equals(Visibility.OUTPUT_ONLY)) {
        visString = "EXPORT";
    } else if (vis.equals(Visibility.HIDDEN)) {
        visString = "NO";
    } else {
        context.addWriteMessage("Visibility " + vis + " is not a valid Visibility for a PCTemplate");
        return null;
    }
    return new String[] { visString };
}
Also used : Visibility(pcgen.util.enumeration.Visibility)

Example 9 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, ContentDefinition factDef, String value) {
    Visibility vis;
    if (value.equals("YES")) {
        vis = Visibility.DEFAULT;
    } else if (value.equals("DISPLAY")) {
        vis = Visibility.DISPLAY_ONLY;
    } else if (value.equals("EXPORT")) {
        vis = Visibility.OUTPUT_ONLY;
    } else if (value.equals("NO")) {
        vis = Visibility.HIDDEN;
    } else {
        return new ParseResult.Fail("Unable to understand " + getTokenName() + " tag: " + value, context);
    }
    factDef.setVisibility(vis);
    return ParseResult.SUCCESS;
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Visibility(pcgen.util.enumeration.Visibility)

Example 10 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Equipment eq, String value) {
    Visibility vis;
    if (value.equals("YES")) {
        vis = Visibility.DEFAULT;
    } else if (value.equals("DISPLAY")) {
        vis = Visibility.DISPLAY_ONLY;
    } else if (value.equals("EXPORT")) {
        vis = Visibility.OUTPUT_ONLY;
    } else if (value.equals("NO")) {
        vis = Visibility.HIDDEN;
    } else {
        ComplexParseResult cpr = new ComplexParseResult();
        cpr.addErrorMessage("Unexpected value used in " + getTokenName() + " in Equipment");
        cpr.addErrorMessage(" " + value + " is not a valid value for " + getTokenName());
        cpr.addErrorMessage(" Valid values in Equipment are YES, NO, DISPLAY, EXPORT");
        return cpr;
    }
    context.getObjectContext().put(eq, ObjectKey.VISIBILITY, vis);
    return ParseResult.SUCCESS;
}
Also used : Visibility(pcgen.util.enumeration.Visibility) ComplexParseResult(pcgen.rules.persistence.token.ComplexParseResult)

Aggregations

Visibility (pcgen.util.enumeration.Visibility)23 ParseResult (pcgen.rules.persistence.token.ParseResult)4 Skill (pcgen.core.Skill)2 ComplexParseResult (pcgen.rules.persistence.token.ComplexParseResult)2 FactDefinition (pcgen.cdom.content.fact.FactDefinition)1 FactSetDefinition (pcgen.cdom.content.factset.FactSetDefinition)1 LoadContext (pcgen.rules.context.LoadContext)1