It's possible to replace all default visualizer with an custom implementation. This is useful if you have special components to visualize specific datatypes e.g a special date picker bean. To do this you have to create and map a Visualizer which has to fulfill following requirements:
Requirements for a Default Visualizer:
- Needs to implement the Visualizer Interface
- Need Constructor with (Type model,Type context) parameters
- Extends the JComponent class
Two ways to add a custom visualizer to visualizer mapping:
- jaxfront.xml:
<property mutable="true"> <key>SimpleTypeDateView</key> <value>com.jaxfront.swing.ui.beans.DateBean</value> </property>
- API: JAXFrontProperties.getInstance().setStringProperty("SimpleTypeDateView","com.jaxfront.s wing.ui.beans.DateBean");
List of default visualizer:
Name | Description |
---|---|
RecursionWrapper | Visualize a recursion |
PagingView | Visualize a page layout |
ComplexGroupView | Visualize a complex group |
ComplexGroupListView | Visualize a complex group list |
SimpleGroupView | Visualize a simple group |
SimpleGroupListView | Visualize a simple group list |
KeyView | Visualize a key |
KeyRefView | Visualize a referenced key |
SimpleTypeColorView | Visualize a color |
SimpleTypeRadioView | Visualize simple items as radio view |
SimpleTypeComboView | Visualize simple items as a combobox |
SimpleTypeStringView | Visualize a simple string |
SimpleTypeBooleanView | Visualize a boolean value |
SimpleTypeNumericView | Visualize a numeric value |
SimpleTypeDateView | Visualize a date value |
SimpleTypeDateTimeView | Visualize a data time value |
SimpleTypeTimeView | Visualize a time value |
SimpleTypeDurationView | Visualize a duration |
SimpleTypeListView | Visualize a simple list |
Default Visualizer Example:
package com.jaxfront.demo.ui; import java.awt.BorderLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTextArea; import com.jaxfront.core.type.Type; import com.jaxfront.core.ui.Visualizer; public class OwnDefaultVisualizerImplementation extends JComponent implements com.jaxfront.core.ui.Visualizer { private Type _context; private Type _model; public OwnDefaultVisualizerImplementation(Type model, Type context) { _model = model; _context = context; setSize(100, 100); setLayout(new BorderLayout()); add(new JLabel("my own impl"), BorderLayout.WEST); add(new JTextArea("my own textarea"), BorderLayout.CENTER); } public Type getContext() {return _context;} public Visualizer getImplementation() {return this;} public String getLabelText() {return null;} public Type getModel() {return _model;} public boolean isViewReleased() {return false;} public void jumpTo() {} public void markError() {} public void populateModel() {} public void populateView() {} public void postInitialization() {} public void release() {} public void removeLabel() {} public void resetError() {} public void setApplicationRequired(boolean required) {} public void setEditable(boolean enabled) {} public void setEnabled(boolean enabled) {} public void setLabelColor(Color color) {} public void setLabelText(String text) {} public void setModel(Type type) {} public void setRequired(boolean required) {} public void setVisible(boolean visible) {} public void showLabel(boolean show) {}
JAXFrontProperties.getInstance().setStringProperty("SimpleTypeDateTimeView", "com.jaxfront.demo.ui.OwnSimpleImplementation");