\\ The class <span style="color: #ff0000"><strong>TypeVisualizerFactory</strong></span> acts as a factory that creates visualizers (JAXFront GUI components) for a JAXFront type (a representation of a schema node). It allows to create a bundle of GUI elements that might be placed on different panels or frames. The created GUI components implements the interface Visualizer. \\ !worddav2f51b87e377051db4caf28225cc7f883.png|height=32,width=29! See class com.jaxfront.demo.api.OwnLayoutManager \\ public class OwnLayoutManager extends AbstractCompositeView implements ListSelectionListener\{ \\ private Document _dom; private JPanel _detailPanel; \\ protected void defaultBuild() \{ setLayout(new BorderLayout()); try \{ URL xsdURL = URLHelper.getUserURL("examples/purchaseOrder/po.xsd"); URL xmlURL = URLHelper.getUserURL("examples/purchaseOrder/po.xml"); URL xuiURL = URLHelper.getUserURL("examples/purchaseOrder/po.xui"); _dom = DOMBuilder.getInstance().build(null,xsdURL, xmlURL, xuiURL, "purchaseOrder"); \\ JPanel upperPanel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; \\ Type purchaseOrderRoot = _dom.getRootType(); \\ JComponent visualizer = (JComponent)TypeVisualizerFactory.getInstance().getVisualizer(purchaseOrderRoot.getDirectChild("orderDate")); c.weightx = 0.5; c.gridx = 0; c.gridy = 0; upperPanel.add(visualizer, c); \\ visualizer = (JComponent){*}TypeVisualizerFactory.getInstance().getVisualizer{*}(purchaseOrderRoot.getDirectChild("deliveryOption")); c.gridx = 1; c.gridy = 0; upperPanel.add(visualizer, c); \\ visualizer = (JComponent){*}TypeVisualizerFactory.getInstance().getVisualizer{*}(purchaseOrderRoot.getDirectChild("email")); c.gridx = 0; c.gridy = 1; upperPanel.add(visualizer, c); \\ JPanel lowerPanel = new JPanel(new BorderLayout()); _detailPanel = new JPanel(new BorderLayout()); JList list = new JList(new String\[\]\{"shipTo", "billTo", "paymentMethod", "item"\}); list.addListSelectionListener(this); list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setPreferredSize(new Dimension(200,200)); JPanel listPanel = new JPanel(new BorderLayout()); listPanel.add(scrollPane, BorderLayout.NORTH); lowerPanel.add(listPanel, BorderLayout.WEST); lowerPanel.add(_detailPanel, BorderLayout.CENTER); \\ add(upperPanel, BorderLayout.NORTH); add(lowerPanel, BorderLayout.CENTER); \} catch (DocumentCreationException ex) \{ LogRegistry.getInstance().warn(getClass(), "Error while creating po.xsd DOM: " + ex.getLocalizedMessage()); \} \\ \} \\ public void setApplicationRequired(boolean aBoolean) \{\} \\ public void setRequired(boolean aBoolean) \{\} \\ public void valueChanged(ListSelectionEvent e) \{ _detailPanel.removeAll(); String name = (String)((JList)e.getSource()).getSelectedValue(); JComponent visualizer = (JComponent){*}TypeVisualizerFactory.getInstance().getVisualizer{*}(_dom.getRootType().getDirectChild(name)); _detailPanel.add(visualizer, BorderLayout.CENTER); _detailPanel.updateUI(); \\ \} \} \\ !worddave577c8b17a58a775504916e0944cbedc.png|height=38,width=38! Create a JComponent from any type you want. The returned JComponent will care about event handling (populate model/populate view) and rules defined in the XUI. |