Search in sources :

Example 1 with AbstractRecordQueryField

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);
    }
}
Also used : JXSearchField(org.jdesktop.swingx.JXSearchField) DateField(com.revolsys.swing.field.DateField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) QueryWhereConditionField(com.revolsys.swing.field.QueryWhereConditionField) JXSearchField(org.jdesktop.swingx.JXSearchField) JComboBox(javax.swing.JComboBox) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) DateField(com.revolsys.swing.field.DateField)

Example 2 with AbstractRecordQueryField

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);
    }
}
Also used : JXSearchField(org.jdesktop.swingx.JXSearchField) DateField(com.revolsys.swing.field.DateField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) QueryWhereConditionField(com.revolsys.swing.field.QueryWhereConditionField) JXSearchField(org.jdesktop.swingx.JXSearchField) JTextComponent(javax.swing.text.JTextComponent) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) DateField(com.revolsys.swing.field.DateField)

Example 3 with AbstractRecordQueryField

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;
}
Also used : JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JComponent(javax.swing.JComponent) Component(java.awt.Component) ComboBoxEditor(javax.swing.ComboBoxEditor)

Example 4 with AbstractRecordQueryField

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;
}
Also used : JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) AbstractRecordTableModel(com.revolsys.swing.table.record.model.AbstractRecordTableModel) JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JTextField(javax.swing.JTextField) JComponent(javax.swing.JComponent) Component(java.awt.Component) ComboBoxEditor(javax.swing.ComboBoxEditor) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

AbstractRecordQueryField (com.revolsys.swing.field.AbstractRecordQueryField)4 Field (com.revolsys.swing.field.Field)4 TextField (com.revolsys.swing.field.TextField)4 JComboBox (javax.swing.JComboBox)3 DateField (com.revolsys.swing.field.DateField)2 QueryWhereConditionField (com.revolsys.swing.field.QueryWhereConditionField)2 Component (java.awt.Component)2 ComboBoxEditor (javax.swing.ComboBoxEditor)2 JComponent (javax.swing.JComponent)2 JTextField (javax.swing.JTextField)2 JXSearchField (org.jdesktop.swingx.JXSearchField)2 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 AbstractRecordTableModel (com.revolsys.swing.table.record.model.AbstractRecordTableModel)1 JTextComponent (javax.swing.text.JTextComponent)1