01: package com.xoetrope.svgscanner.model;
02:
03: import java.io.IOException;
04: import java.io.StringWriter;
05: import net.xoetrope.swing.XTextArea;
06: import net.xoetrope.xml.XmlElement;
07: import net.xoetrope.xml.nanoxml.NanoXmlWriter;
08: import net.xoetrope.xui.XPage;
09:
10: /**
11: *
12: * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
13: * the GNU Public License (GPL), please see license.txt for more details. If
14: * you make commercial use of this software you must purchase a commercial
15: * license from Xoetrope.</p>
16: * <p>$Revision: 1.7 $</p>
17: */
18: public class ObjectElementHandler extends SynthElementHandler {
19:
20: /** Creates a new instance of ObjectElementHandler */
21: public ObjectElementHandler() {
22: }
23:
24: public String getName(XmlElement e) {
25: String name = super .getName(e);
26: String attr;
27: if ((attr = e.getAttribute("id")) != null)
28: name += "(" + attr + ")";
29:
30: return name;
31: }
32:
33: /**
34: * Update the panel showing details of this type of element
35: * @param page the page with the UI for this component
36: */
37: public void updateUI(XPage page) {
38: XTextArea idRefEdit = (XTextArea) page
39: .findComponent("objectEdit");
40: try {
41:
42: StringWriter sw = new StringWriter();
43: NanoXmlWriter writer = new NanoXmlWriter(sw);
44: writer.write(objectElement, true, 2);
45:
46: idRefEdit.setText(sw.toString());
47: } catch (IOException ex) {
48: ex.printStackTrace();
49: idRefEdit.setText("Error");
50: }
51: }
52: }
|