From: Kevin D. <kev...@us...> - 2009-12-21 17:38:01
|
Update of /cvsroot/jmri/jmri/jmrit/display/configurexml In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv31798 Modified Files: MemoryIconXml.java MemoryInputIconXml.java Log Message: Updated so that the Memory and MemoryIconInput are now referenced using the namedBeanHandle. Also improved some of the save code. Index: MemoryIconXml.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/display/configurexml/MemoryIconXml.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** MemoryIconXml.java 17 Nov 2009 18:17:27 -0000 1.22 --- MemoryIconXml.java 21 Dec 2009 17:37:51 -0000 1.23 *************** *** 5,12 **** --- 5,15 ---- import jmri.jmrit.display.LayoutEditor; import jmri.jmrit.display.MemoryIcon; + import jmri.util.NamedBeanHandle; + import jmri.Memory; import org.jdom.Attribute; import org.jdom.Element; import java.util.List; + /** * Handle configuration for display.MemoryIcon objects. *************** *** 33,37 **** // include attributes ! element.setAttribute("memory", p.getMemory().getSystemName()); if (p.getOriginalX()!=0) element.setAttribute("x", ""+p.getOriginalX()); --- 36,40 ---- // include attributes ! element.setAttribute("memory", p.getMemory().getName()); if (p.getOriginalX()!=0) element.setAttribute("x", ""+p.getOriginalX()); *************** *** 114,120 **** } loadTextInfo(l, element); ! l.setMemory(jmri.InstanceManager.memoryManagerInstance().getMemory( ! element.getAttribute("memory").getValue())); // find display level --- 117,139 ---- } loadTextInfo(l, element); + String name; + Attribute attr = element.getAttribute("memory"); + if (attr == null) { + log.error("incorrect information for a memory location; must use memory name"); + return; + } else { + name = attr.getValue(); + } ! Memory m = jmri.InstanceManager.memoryManagerInstance().getMemory(name); ! ! if (m!=null) { ! l.setMemory(new NamedBeanHandle<Memory>(name, m)); ! } else { ! log.error("Memory named '"+attr.getValue()+"' not found."); ! return; ! } ! //l.setMemory(jmri.InstanceManager.memoryManagerInstance().getMemory( ! //element.getAttribute("memory").getValue())); // find display level *************** *** 128,132 **** } - Attribute a = element.getAttribute("selectable"); if (a!=null && a.getValue().equals("yes")) l.setSelectable(true); --- 147,150 ---- Index: MemoryInputIconXml.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/display/configurexml/MemoryInputIconXml.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MemoryInputIconXml.java 26 Jul 2009 22:29:30 -0000 1.1 --- MemoryInputIconXml.java 21 Dec 2009 17:37:51 -0000 1.2 *************** *** 4,8 **** --- 4,11 ---- import jmri.jmrit.display.PanelEditor; import jmri.jmrit.display.MemoryInputIcon; + import jmri.util.NamedBeanHandle; + import jmri.Memory; import org.jdom.Element; + import org.jdom.Attribute; /** *************** *** 31,35 **** // include attributes element.setAttribute("colWidth", ""+p.getNumColumns()); ! element.setAttribute("memory", p.getMemory().getSystemName()); element.setAttribute("x", ""+p.getX()); element.setAttribute("y", ""+p.getY()); --- 34,38 ---- // include attributes element.setAttribute("colWidth", ""+p.getNumColumns()); ! element.setAttribute("memory", p.getMemory().getName()); element.setAttribute("x", ""+p.getX()); element.setAttribute("y", ""+p.getY()); *************** *** 65,71 **** MemoryInputIcon l = new MemoryInputIcon(nCol); ! ! l.setMemory(jmri.InstanceManager.memoryManagerInstance().getMemory( ! element.getAttribute("memory").getValue())); // find coordinates --- 68,89 ---- MemoryInputIcon l = new MemoryInputIcon(nCol); ! ! String name; ! Attribute attr = element.getAttribute("memory"); ! if (attr == null) { ! log.error("incorrect information for a memory location; must use memory name"); ! return; ! } else { ! name = attr.getValue(); ! } ! ! Memory m = jmri.InstanceManager.memoryManagerInstance().getMemory(name); ! ! if (m!=null) { ! l.setMemory(new NamedBeanHandle<Memory>(name, m)); ! } else { ! log.error("Memory named '"+attr.getValue()+"' not found."); ! return; ! } // find coordinates |