use of com.revolsys.swing.field.AbstractRecordQueryField 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.AbstractRecordQueryField 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.AbstractRecordQueryField in project com.revolsys.open by revolsys.
the class RecordTableCellEditor method stopCellEditing.
@Override
public boolean stopCellEditing() {
boolean stopped = false;
try {
if (this.editorComponent instanceof Field) {
final Field field = (Field) this.editorComponent;
field.updateFieldValue();
}
stopped = super.stopCellEditing();
} catch (final IndexOutOfBoundsException e) {
return true;
} catch (final Throwable t) {
final int result = JOptionPane.showConfirmDialog(this.editorComponent, "<html><p><b>'" + getCellEditorValue() + "' is not a valid " + this.dataType.getValidationName() + ".</b></p><p>Discard changes (Yes) or edit field (No).</p></html>", "Invalid value", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
cancelCellEditing();
return true;
} else {
return false;
}
} finally {
if (stopped) {
if (this.editorComponent != null) {
this.editorComponent.removeMouseListener(this.mouseListeners);
this.editorComponent.removeKeyListener(this);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.removeKeyListener(this);
comboEditorComponent.removeMouseListener(this.mouseListeners);
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
final TextField searchField = queryField.getSearchField();
searchField.removeKeyListener(this);
searchField.removeMouseListener(this.mouseListeners);
}
if (this.popupMenuListener != null) {
this.popupMenuListener.close();
this.popupMenuListener = null;
}
}
}
}
return stopped;
}
use of com.revolsys.swing.field.AbstractRecordQueryField in project com.revolsys.open by revolsys.
the class RecordTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, int rowIndex, int columnIndex) {
rowIndex = table.convertRowIndexToModel(rowIndex);
columnIndex = table.convertColumnIndexToModel(columnIndex);
this.oldValue = value;
final AbstractRecordTableModel model = getTableModel();
this.fieldName = model.getColumnFieldName(rowIndex, columnIndex);
final RecordDefinition recordDefinition = model.getRecordDefinition();
this.dataType = recordDefinition.getFieldType(this.fieldName);
final Field field = newField(this.fieldName);
this.editorComponent = (JComponent) field;
if (this.editorComponent instanceof JTextField) {
final JTextField textField = (JTextField) this.editorComponent;
textField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
queryField.setSearchFieldBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
}
this.editorComponent.setOpaque(false);
SwingUtil.setFieldValue(this.editorComponent, value);
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.editorComponent.addKeyListener(this);
this.editorComponent.addMouseListener(this.mouseListeners);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.addKeyListener(this);
comboEditorComponent.addMouseListener(this.mouseListeners);
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
final TextField searchField = queryField.getSearchField();
searchField.addKeyListener(this);
searchField.addMouseListener(this.mouseListeners);
}
this.popupMenuListener = ShowMenuMouseListener.addListener(this.editorComponent, this.popupMenuFactory);
return this.editorComponent;
}
Aggregations