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();
}
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;
}
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);
}
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;
}
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;
}
Aggregations