use of jmri.jmrit.display.panelEditor.PanelEditor in project JMRI by JMRI.
the class PanelEditorXml method store.
/**
* Default implementation for storing the contents of a PanelEditor
*
* @param o Object to store, of type PanelEditor
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
PanelEditor p = (PanelEditor) o;
Element panel = new Element("paneleditor");
JFrame frame = p.getTargetFrame();
Dimension size = frame.getSize();
Point posn = frame.getLocation();
panel.setAttribute("class", "jmri.jmrit.display.panelEditor.configurexml.PanelEditorXml");
panel.setAttribute("name", "" + frame.getTitle());
panel.setAttribute("x", "" + posn.x);
panel.setAttribute("y", "" + posn.y);
panel.setAttribute("height", "" + size.height);
panel.setAttribute("width", "" + size.width);
panel.setAttribute("editable", "" + (p.isEditable() ? "yes" : "no"));
panel.setAttribute("positionable", "" + (p.allPositionable() ? "yes" : "no"));
//panel.setAttribute("showcoordinates", ""+(p.showCoordinates()?"yes":"no"));
panel.setAttribute("showtooltips", "" + (p.showTooltip() ? "yes" : "no"));
panel.setAttribute("controlling", "" + (p.allControlling() ? "yes" : "no"));
panel.setAttribute("hide", p.isVisible() ? "no" : "yes");
panel.setAttribute("panelmenu", p.isPanelMenuVisible() ? "yes" : "no");
panel.setAttribute("scrollable", p.getScrollable());
if (p.getBackgroundColor() != null) {
panel.setAttribute("redBackground", "" + p.getBackgroundColor().getRed());
panel.setAttribute("greenBackground", "" + p.getBackgroundColor().getGreen());
panel.setAttribute("blueBackground", "" + p.getBackgroundColor().getBlue());
}
// include contents
List<Positionable> contents = p.getContents();
if (log.isDebugEnabled()) {
log.debug("N elements: " + contents.size());
}
for (int i = 0; i < contents.size(); i++) {
Positionable sub = contents.get(i);
if (sub != null && sub.storeItem()) {
try {
Element e = jmri.configurexml.ConfigXmlManager.elementFromObject(sub);
if (e != null) {
panel.addContent(e);
}
} catch (Exception e) {
log.error("Error storing panel element: " + e);
e.printStackTrace();
}
}
}
return panel;
}
Aggregations