use of com.revolsys.swing.field.CheckBox in project com.revolsys.open by revolsys.
the class SwingUtil method newField.
@SuppressWarnings("unchecked")
static <T extends JComponent> T newField(final Class<?> fieldClass, final String fieldName, final Object fieldValue) {
JComponent field;
if (Number.class.isAssignableFrom(fieldClass)) {
final NumberTextField numberTextField = new NumberTextField(fieldName, DataTypes.DOUBLE, 10, 2);
if (fieldValue instanceof Number) {
final Number number = (Number) fieldValue;
numberTextField.setFieldValue(number);
}
field = numberTextField;
} else if (Date.class.isAssignableFrom(fieldClass)) {
final DateField dateField = newDateField(fieldName);
if (fieldValue instanceof Date) {
final Date date = (Date) fieldValue;
dateField.setDate(date);
}
field = dateField;
} else if (Geometry.class.isAssignableFrom(fieldClass)) {
final ObjectLabelField objectField = new ObjectLabelField(fieldName);
objectField.setFieldValue(fieldValue);
field = objectField;
} else if (Color.class.isAssignableFrom(fieldClass)) {
field = new ColorChooserField(fieldName, (Color) fieldValue);
} else if (Boolean.class.isAssignableFrom(fieldClass)) {
field = new CheckBox(fieldName, fieldValue);
} else {
final TextField textField = new TextField(fieldName, fieldValue);
textField.setColumns(50);
MenuFactory.getPopupMenuFactory(textField);
field = textField;
}
if (field instanceof JTextField) {
final JTextField textField = (JTextField) field;
final int preferedWidth = textField.getPreferredSize().width;
textField.setMinimumSize(new Dimension(preferedWidth, 0));
textField.setMaximumSize(new Dimension(preferedWidth, Integer.MAX_VALUE));
textField.setText(DataTypes.toString(fieldValue));
}
field.setFont(FONT);
return (T) field;
}
use of com.revolsys.swing.field.CheckBox in project com.revolsys.open by revolsys.
the class BaseStylePanel method newField.
@SuppressWarnings("unchecked")
protected Field newField(final String fieldName, final Class<?> fieldClass, final Object value) {
Field field;
if (fieldName.equals("visible")) {
this.visibleField = new CheckBox(fieldName, value);
field = this.visibleField;
} else if (fieldName.equals("textFaceName")) {
field = new FontChooserField(fieldName, (String) value);
} else if (fieldName.endsWith("HorizontalAlignment")) {
field = newHorizontalAlignmentField(fieldName, (String) value);
} else if (fieldName.endsWith("VerticalAlignment")) {
field = newVerticalAlignmentField(fieldName, (String) value);
} else if (fieldName.equals("lineCap")) {
field = newLineCapField((LineCap) value);
} else if (fieldName.equals("lineJoin")) {
field = newLineJoinField((LineJoin) value);
} else if (fieldName.equals("lineDashArray")) {
field = new DashField(fieldName, (List<Quantity<Length>>) value);
} else if (fieldName.equals("queryFilter")) {
final AbstractRecordLayer layer = getLayer();
field = new QueryFilterField(layer, fieldName, (String) value);
field.setFieldValue(value);
Property.addListener(field, fieldName, this);
} else if (fieldName.equals("marker")) {
field = new MarkerField(fieldName, value);
} else if (fieldName.endsWith("OrientationType")) {
final ComboBox<String> orientationTypeField = ComboBox.newComboBox(fieldName, "auto", "none");
orientationTypeField.setFieldValue(value);
field = orientationTypeField;
} else if (fieldName.equals("markerPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "vertices", "segment(0)", "segment(n)", "segments");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.equals("textPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "segment(0)", "segment(n)");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.endsWith("Scale")) {
field = newScaleField(fieldName, (Long) value);
} else if (Color.class.equals(fieldClass)) {
field = new ColorChooserField(fieldName, (Color) value);
} else if (Boolean.TYPE.equals(fieldClass) || Boolean.class.equals(fieldClass)) {
field = new CheckBox(fieldName, value);
} else if (Quantity.class.equals(fieldClass)) {
field = new LengthMeasureTextField(fieldName, (Quantity<Length>) value, CustomUnits.PIXEL);
} else {
field = new TextField(fieldName, value, 40);
}
return field;
}
use of com.revolsys.swing.field.CheckBox in project com.revolsys.open by revolsys.
the class BaseStylePanel method addCheckBoxField.
protected void addCheckBoxField(final JPanel container, final Object object, final String fieldName) {
SwingUtil.addLabel(container, fieldName);
final CheckBox field = new CheckBox(fieldName);
final Object value = Property.get(object, fieldName);
field.setFieldValue(value);
Property.addListener(field, fieldName, this);
container.add(field);
}
Aggregations