use of com.revolsys.swing.field.DateField 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.DateField in project com.revolsys.open by revolsys.
the class FieldFilterPanel method removeListeners.
@SuppressWarnings("rawtypes")
private void removeListeners(final JComponent component) {
if (component instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) component;
queryField.removePropertyChangeListener("selectedRecord", this);
} else if (component instanceof JXSearchField) {
final JXSearchField searchTextField = (JXSearchField) component;
searchTextField.removeActionListener(this);
} else if (component instanceof JComboBox) {
final JComboBox comboField = (JComboBox) component;
comboField.removeActionListener(this);
} else if (component instanceof DateField) {
final DateField dateField = (DateField) component;
dateField.removeActionListener(this);
}
if (component instanceof Field) {
final Field field = (Field) component;
final String fieldName = field.getFieldName();
Property.removeListener(field, fieldName, this);
}
}
use of com.revolsys.swing.field.DateField in project com.revolsys.open by revolsys.
the class FieldFilterPanel method addListeners.
private void addListeners(final JComponent component) {
if (component instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) component;
queryField.addPropertyChangeListener("selectedRecord", this);
} else if (component instanceof JXSearchField) {
final JXSearchField searchTextField = (JXSearchField) component;
searchTextField.addActionListener(this);
} else if (component instanceof JTextComponent) {
final JTextComponent searchTextField = (JTextComponent) component;
searchTextField.getDocument().addDocumentListener(this);
} else if (component instanceof DateField) {
final DateField dateField = (DateField) component;
dateField.addActionListener(this);
}
if (component instanceof Field) {
final Field field = (Field) component;
final String fieldName = field.getFieldName();
Property.addListener(field, fieldName, this);
}
}
use of com.revolsys.swing.field.DateField in project com.revolsys.open by revolsys.
the class SwingUtil method newDateField.
static DateField newDateField(final String fieldName) {
final DateField dateField = new DateField(fieldName);
dateField.setFormats("yyyy-MM-dd", "yyyy/MM/dd", "yyyy-MMM-dd", "yyyy/MMM/dd");
MenuFactory.getPopupMenuFactory(dateField.getEditor());
return dateField;
}
Aggregations