6. GadgetFactory

What is a GadgetFactory?

A GadgetFactory is a factory creating a com.xmlmind.xmledit.gadget.Gadget for use as the custom view of an XML element.

Gadgets are very lightweight visual components built on the top of Java™ AWT and Swing. The tree view and styled view of a document almost exclusively consist in (possibly thousands of) Gadgets.

Where to declare a GadgetFactory?

In the CSS stylesheet used to style the document being edited, using the proprietary gadget() pseudo-function in XMLmind XML Editor - Support of Cascading Style Sheets (W3C CSS). XHTML input element example:

input[type=text],
input {
    content: gadget("com.xmlmind.xmleditext.xhtml.form.InputField",
                    attribute, value,
                    columns, xpath("if(number(@size) > 0, @size, 20)"),
                    pattern, xpath("if(@multiple, '', @pattern)"));
}

How to implement a GadgetFactory?

Implement interface GadgetFactory. See also GadgetFactory2.