Search in sources :

Example 11 with CatalogTreeNode

use of jmri.jmrit.catalog.CatalogTreeNode in project JMRI by JMRI.

the class IconAdder method getDefaultIconNodeFromMap.

private CatalogTreeNode getDefaultIconNodeFromMap() {
    if (log.isDebugEnabled()) {
        log.debug("getDefaultIconNodeFromMap for node= " + _type + ", _order.size()= " + _order.size());
    }
    _defaultIcons = new CatalogTreeNode(_type);
    Iterator<Entry<String, JToggleButton>> it = _iconMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, JToggleButton> e = it.next();
        NamedIcon icon = (NamedIcon) e.getValue().getIcon();
        _defaultIcons.addLeaf(new CatalogTreeLeaf(e.getKey(), icon.getURL(), _order.indexOf(e.getKey())));
    }
    return _defaultIcons;
}
Also used : Entry(java.util.Map.Entry) NamedIcon(jmri.jmrit.catalog.NamedIcon) CatalogTreeLeaf(jmri.jmrit.catalog.CatalogTreeLeaf) JToggleButton(javax.swing.JToggleButton) CatalogTreeNode(jmri.jmrit.catalog.CatalogTreeNode)

Example 12 with CatalogTreeNode

use of jmri.jmrit.catalog.CatalogTreeNode in project JMRI by JMRI.

the class ItemPalette method loadIndicatorFamilyMap.

static HashMap<String, HashMap<String, HashMap<String, NamedIcon>>> loadIndicatorFamilyMap(CatalogTreeNode node, Editor ed) {
    HashMap<String, HashMap<String, HashMap<String, NamedIcon>>> familyMap = new HashMap<String, HashMap<String, HashMap<String, NamedIcon>>>();
    // node.children() is still unchecked in JDOM2
    @SuppressWarnings("unchecked") Enumeration<CatalogTreeNode> ee = node.children();
    while (ee.hasMoreElements()) {
        CatalogTreeNode famNode = ee.nextElement();
        String name = (String) famNode.getUserObject();
        familyMap.put(name, loadFamilyMap(famNode, ed));
        Thread.yield();
    }
    return familyMap;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) CatalogTreeNode(jmri.jmrit.catalog.CatalogTreeNode)

Example 13 with CatalogTreeNode

use of jmri.jmrit.catalog.CatalogTreeNode in project JMRI by JMRI.

the class ItemPalette method loadSavedIcons.

static boolean loadSavedIcons(Editor ed) {
    CatalogTreeManager manager = InstanceManager.getDefault(jmri.CatalogTreeManager.class);
    CatalogTree tree = manager.getBySystemName("NXPI");
    if (tree != null) {
        CatalogTreeNode root = tree.getRoot();
        // root.children() is still unchecked in JDOM2
        @SuppressWarnings("unchecked") Enumeration<CatalogTreeNode> e = root.children();
        while (e.hasMoreElements()) {
            CatalogTreeNode node = e.nextElement();
            String typeName = (String) node.getUserObject();
            // not very elegant (i.e. extensible), but maybe all that's needed.
            if (typeName.equals("IndicatorTO")) {
                HashMap<String, HashMap<String, HashMap<String, NamedIcon>>> familyTOMap = loadIndicatorFamilyMap(node, ed);
                if (log.isDebugEnabled()) {
                    log.debug("Add " + familyTOMap.size() + " indicatorTO families to item type " + typeName + " to _indicatorTOMaps.");
                }
                _indicatorTOMaps.put(typeName, familyTOMap);
            } else {
                HashMap<String, HashMap<String, NamedIcon>> familyMap = loadFamilyMap(node, ed);
                _iconMaps.put(typeName, familyMap);
                if (log.isDebugEnabled()) {
                    log.debug("Add item type " + typeName + " to _iconMaps.");
                }
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("Icon Map has " + _iconMaps.size() + " members");
        }
        return true;
    }
    return false;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) CatalogTree(jmri.CatalogTree) CatalogTreeManager(jmri.CatalogTreeManager) CatalogTreeNode(jmri.jmrit.catalog.CatalogTreeNode)

Aggregations

CatalogTreeNode (jmri.jmrit.catalog.CatalogTreeNode)13 CatalogTreeManager (jmri.CatalogTreeManager)6 NamedIcon (jmri.jmrit.catalog.NamedIcon)6 HashMap (java.util.HashMap)5 CatalogTree (jmri.CatalogTree)5 CatalogTreeLeaf (jmri.jmrit.catalog.CatalogTreeLeaf)4 Element (org.jdom2.Element)4 Entry (java.util.Map.Entry)3 Attribute (org.jdom2.Attribute)2 File (java.io.File)1 JToggleButton (javax.swing.JToggleButton)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 XmlFile (jmri.jmrit.XmlFile)1 Document (org.jdom2.Document)1