MCPcopy Create free account
hub / github.com/PCGen/pcgen / SpellNodeDataView

Class SpellNodeDataView

code/src/java/pcgen/gui2/tabs/spells/SpellNodeDataView.java:35–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33import org.apache.commons.lang3.StringUtils;
34
35class SpellNodeDataView implements DataView<SuperNode>
36{
37
38 private final List<? extends DataViewColumn> columns;
39 private final String prefsKey;
40 private final InfoFactory infoFactory;
41
42 public SpellNodeDataView(boolean initiallyVisible, String prefsKey, InfoFactory infoFactory)
43 {
44 super();
45 this.prefsKey = prefsKey;
46 this.infoFactory = infoFactory;
47 columns = Arrays.asList(new DefaultDataViewColumn("School", String.class, initiallyVisible),
48 new DefaultDataViewColumn("Subschool", String.class, initiallyVisible),
49 new DefaultDataViewColumn("Descriptors", String.class, initiallyVisible),
50 new DefaultDataViewColumn("Components", String.class, initiallyVisible),
51 new DefaultDataViewColumn("in_descrip", String.class, initiallyVisible),
52 new DefaultDataViewColumn("Range", String.class), new DefaultDataViewColumn("Duration", String.class),
53 new DefaultDataViewColumn("Source", String.class), new DefaultDataViewColumn("Cast Time", String.class));
54 }
55
56 @Override
57 public Object getData(SuperNode obj, int column)
58 {
59 if (obj instanceof SpellNode)
60 {
61 SpellFacade spell = ((SpellNode) obj).getSpell();
62 if (spell != null)
63 {
64 switch (column)
65 {
66 case 0:
67 return spell.getSchool();
68 case 1:
69 return spell.getSubschool();
70 case 2:
71 return StringUtils.join(spell.getDescriptors(), ", ");
72 case 3:
73 return spell.getComponents();
74 case 4:
75 return infoFactory.getDescription(spell);
76 case 5:
77 return spell.getRange();
78 case 6:
79 return spell.getDuration();
80 case 7:
81 return spell.getSource();
82 case 8:
83 return spell.getCastTime();
84 default:
85 //Case not caught, should this cause an error?
86 break;
87 }
88 }
89 }
90 return null;
91 }
92

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected