use of pcgen.facade.core.SpellSupportFacade.SpellNode in project pcgen by PCGen.
the class QualifiedSpellTreeCellRenderer method getTreeCellRendererComponent.
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean focus) {
Object obj = ((DefaultMutableTreeNode) value).getUserObject();
if (//$NON-NLS-1$
"".equals(obj)) {
//$NON-NLS-1$
obj = LanguageBundle.getString("in_none");
}
super.getTreeCellRendererComponent(tree, obj, sel, expanded, leaf, row, focus);
if (obj instanceof SpellNode) {
SpellNode spellNode = (SpellNode) obj;
SpellFacade spell = spellNode.getSpell();
ClassFacade pcClass = spellNode.getSpellcastingClass();
if (!character.isQualifiedFor(spell, pcClass)) {
setForeground(UIPropertyContext.getNotQualifiedColor());
}
}
if (obj instanceof InfoFacade && ((InfoFacade) obj).isNamePI()) {
setFont(FontManipulation.bold_italic(getFont()));
} else {
setFont(FontManipulation.plain(getFont()));
}
return this;
}
use of pcgen.facade.core.SpellSupportFacade.SpellNode in project pcgen by PCGen.
the class SpellInfoHandler method valueChanged.
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
Object obj;
if (e.getSource() == availableTable.getSelectionModel()) {
obj = availableTable.getSelectedObject();
} else {
obj = selectedTable.getSelectedObject();
}
if (obj instanceof SpellNode) {
SpellNode node = (SpellNode) obj;
String text = character.getInfoFactory().getHTMLInfo(node.getSpell());
currText = text;
spellsPane.setText(text);
} else if (obj instanceof RootNode) {
RootNode node = (RootNode) obj;
String text = character.getInfoFactory().getSpellBookInfo(node.getName());
if (!StringUtils.isEmpty(text)) {
currText = text;
spellsPane.setText(text);
}
}
}
}
use of pcgen.facade.core.SpellSupportFacade.SpellNode in project pcgen by PCGen.
the class SpellsPreparedTab method getCurrentSpellListName.
/**
* Identify the current spell list, being the spell list that spell should
* be added to. If no lists exist then a default one will be created.
*
* @param character The character qwe are checking for.
* @return The name of the 'current' spell list.
*/
String getCurrentSpellListName(CharacterFacade character) {
String spellList = "";
Object selectedObject = selectedTable.getSelectedObject();
if (selectedObject != null) {
if (selectedObject instanceof SpellNode) {
spellList = ((SpellNode) selectedObject).getRootNode().toString();
} else {
JTree tree = selectedTable.getTree();
TreePath path = tree.getSelectionPath();
while (path.getParentPath() != null && (path.getParentPath().getParentPath() != null)) {
path = path.getParentPath();
}
spellList = path.getLastPathComponent().toString();
}
}
if (StringUtils.isEmpty(spellList)) {
spellList = spellListField.getText();
}
if (StringUtils.isEmpty(spellList)) {
ListFacade<?> data = selectedTable.getTreeViewModel().getDataModel();
if (!data.isEmpty()) {
Object firstElem = data.getElementAt(0);
if (firstElem instanceof SpellNode) {
spellList = ((SpellNode) firstElem).getRootNode().toString();
}
}
}
if (StringUtils.isEmpty(spellList)) {
// No lists exist, so create a default one!
spellList = "Prepared Spells";
character.getSpellSupport().addSpellList(spellList);
}
return spellList;
}
Aggregations