The class TypeVisualizerFactory 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.
Hinweis |
---|
See class com.jaxfront.demo.api.OwnLayoutManager |
Codeblock |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
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();
}
} |
Tipp |
---|
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. |