Search in sources :

Example 1 with SpellNode

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;
}
Also used : SpellNode(pcgen.facade.core.SpellSupportFacade.SpellNode) ClassFacade(pcgen.facade.core.ClassFacade) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) InfoFacade(pcgen.facade.core.InfoFacade) SpellFacade(pcgen.facade.core.SpellFacade)

Example 2 with SpellNode

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);
            }
        }
    }
}
Also used : SpellNode(pcgen.facade.core.SpellSupportFacade.SpellNode) RootNode(pcgen.facade.core.SpellSupportFacade.RootNode)

Example 3 with SpellNode

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;
}
Also used : SpellNode(pcgen.facade.core.SpellSupportFacade.SpellNode) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath)

Aggregations

SpellNode (pcgen.facade.core.SpellSupportFacade.SpellNode)3 JTree (javax.swing.JTree)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1 ClassFacade (pcgen.facade.core.ClassFacade)1 InfoFacade (pcgen.facade.core.InfoFacade)1 SpellFacade (pcgen.facade.core.SpellFacade)1 RootNode (pcgen.facade.core.SpellSupportFacade.RootNode)1