Search in sources :

Example 71 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class SensorTableDataModel method setManager.

protected void setManager(SensorManager manager) {
    getManager().removePropertyChangeListener(this);
    if (sysNameList != null) {
        for (int i = 0; i < sysNameList.size(); i++) {
            // if object has been deleted, it's not here; ignore it
            NamedBean b = getBySystemName(sysNameList.get(i));
            if (b != null) {
                b.removePropertyChangeListener(this);
            }
        }
    }
    senManager = manager;
    getManager().addPropertyChangeListener(this);
    updateNameList();
}
Also used : NamedBean(jmri.NamedBean)

Example 72 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class LayoutBlockConnectivityTools method discoverValidBeanPairs.

/**
     * Discovers valid pairs of beans type T assigned to a layout editor. If no
     * bean type is provided, then either SignalMasts or Sensors are discovered
     * If no editor is provided, then all editors are considered
     *
     * @param pathMethod Determine whether or not we should reject pairs if
     *                   there are other beans in the way. Constant values of
     *                   NONE, ANY, MASTTOMAST, HEADTOHEAD
     */
public Hashtable<NamedBean, ArrayList<NamedBean>> discoverValidBeanPairs(LayoutEditor editor, Class<?> T, int pathMethod) {
    LayoutBlockManager lbm = InstanceManager.getDefault(LayoutBlockManager.class);
    Hashtable<NamedBean, ArrayList<NamedBean>> retPairs = new Hashtable<NamedBean, ArrayList<NamedBean>>();
    ArrayList<FacingProtecting> beanList = generateBlocksWithBeans(editor, T);
    for (FacingProtecting fp : beanList) {
        for (Block block : fp.getProtectingBlocks()) {
            if (log.isDebugEnabled()) {
                try {
                    log.debug("\nSource " + fp.getBean().getDisplayName());
                    log.debug("facing " + fp.getFacing().getDisplayName());
                    log.debug("protecting " + block.getDisplayName());
                } catch (java.lang.NullPointerException e) {
                //Can be considered normal if the signalmast is assigned to an end bumper.
                }
            }
            LayoutBlock lFacing = lbm.getLayoutBlock(fp.getFacing());
            LayoutBlock lProtecting = lbm.getLayoutBlock(block);
            NamedBean source = fp.getBean();
            try {
                retPairs.put(source, discoverPairDest(source, lProtecting, lFacing, beanList, pathMethod));
            } catch (JmriException ex) {
                log.error(ex.toString());
            }
        }
    }
    return retPairs;
}
Also used : NamedBean(jmri.NamedBean) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Block(jmri.Block) JmriException(jmri.JmriException)

Example 73 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class LayoutBlockManager method getFacingNamedBean.

/**
     * Method to return the named bean of either a Sensor or signalmast facing
     * into a specified Block from a specified protected Block.
     * <P>
     * @return The assigned sensor or signal mast as a named bean
     */
public NamedBean getFacingNamedBean(Block facingBlock, Block protectedBlock, LayoutEditor panel) {
    NamedBean bean = getFacingBean(facingBlock, protectedBlock, panel, SignalMast.class);
    if (bean != null) {
        return bean;
    }
    bean = getFacingBean(facingBlock, protectedBlock, panel, Sensor.class);
    if (bean != null) {
        return bean;
    }
    return getFacingSignalHead(facingBlock, protectedBlock);
}
Also used : NamedBean(jmri.NamedBean) Sensor(jmri.Sensor)

Example 74 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class TableItemPanel method getTableSelection.

/**
     * Used by Panel Editor to make the final installation of the icon(s) into
     * the user's Panel.
     * <P>
     * Note! the selection is cleared. When two successive calls are made, the
     * 2nd will always return null, regardless of the 1st return.
     */
public NamedBean getTableSelection() {
    int row = _table.getSelectedRow();
    row = _table.convertRowIndexToModel(row);
    if (row >= 0) {
        NamedBean b = _model.getBeanAt(row);
        _table.clearSelection();
        if (log.isDebugEnabled()) {
            log.debug("getTableSelection: row= " + row + ", bean= " + b.getDisplayName());
        }
        return b;
    } else if (log.isDebugEnabled()) {
        log.debug("getTableSelection: row= " + row);
    }
    return null;
}
Also used : NamedBean(jmri.NamedBean)

Example 75 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class OBlockManagerXml method storePortal.

private static Element storePortal(Portal portal) {
    Element elem = new Element("portal");
    elem.setAttribute("systemName", portal.getSystemName());
    elem.setAttribute("portalName", portal.getName());
    OBlock block = portal.getFromBlock();
    if (block != null) {
        Element fromElem = new Element("fromBlock");
        fromElem.setAttribute("blockName", block.getSystemName());
        List<OPath> paths = portal.getFromPaths();
        if (paths != null) {
            for (int i = 0; i < paths.size(); i++) {
                OPath path = paths.get(i);
                fromElem.addContent(storePathKey(path));
            }
        }
        elem.addContent(fromElem);
    } else {
        log.error("Portal \"" + portal.getName() + "\" has no fromBlock!");
    }
    NamedBean signal = portal.getFromSignal();
    if (signal != null) {
        Element fromElem = new Element("fromSignal");
        fromElem.setAttribute("signalName", signal.getSystemName());
        fromElem.setAttribute("signalDelay", "" + portal.getFromSignalOffset());
        elem.addContent(fromElem);
    }
    block = portal.getToBlock();
    if (block != null) {
        Element toElem = new Element("toBlock");
        toElem.setAttribute("blockName", block.getSystemName());
        List<OPath> paths = portal.getToPaths();
        if (paths != null) {
            for (int i = 0; i < paths.size(); i++) {
                OPath path = paths.get(i);
                toElem.addContent(storePathKey(path));
            }
        }
        elem.addContent(toElem);
    } else {
        log.error("Portal \"" + portal.getName() + "\" has no toBlock!");
    }
    signal = portal.getToSignal();
    if (signal != null) {
        Element toElem = new Element("toSignal");
        toElem.setAttribute("signalName", signal.getSystemName());
        toElem.setAttribute("signalDelay", "" + portal.getToSignalOffset());
        elem.addContent(toElem);
    }
    return elem;
}
Also used : NamedBean(jmri.NamedBean) Element(org.jdom2.Element) OPath(jmri.jmrit.logix.OPath) OBlock(jmri.jmrit.logix.OBlock)

Aggregations

NamedBean (jmri.NamedBean)104 ArrayList (java.util.ArrayList)18 JTextField (javax.swing.JTextField)12 JmriException (jmri.JmriException)12 SignalMast (jmri.SignalMast)12 JTable (javax.swing.JTable)11 Manager (jmri.Manager)9 Sensor (jmri.Sensor)9 JButton (javax.swing.JButton)8 InstanceManager (jmri.InstanceManager)8 JComboBox (javax.swing.JComboBox)7 MouseEvent (java.awt.event.MouseEvent)6 Hashtable (java.util.Hashtable)6 SignalHead (jmri.SignalHead)6 Turnout (jmri.Turnout)6 OBlock (jmri.jmrit.logix.OBlock)5 File (java.io.File)4 JLabel (javax.swing.JLabel)4 TableCellEditor (javax.swing.table.TableCellEditor)4 TableCellRenderer (javax.swing.table.TableCellRenderer)4