Search in sources :

Example 1 with AbstractRecordTableModel

use of com.revolsys.swing.table.record.model.AbstractRecordTableModel 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)

Example 2 with AbstractRecordTableModel

use of com.revolsys.swing.table.record.model.AbstractRecordTableModel in project com.revolsys.open by revolsys.

the class ExcludeGeometryRowFilter method include.

@Override
public boolean include(final Entry<? extends TableModel, ? extends Integer> entry) {
    final TableModel model = entry.getModel();
    if (model instanceof AbstractRecordTableModel) {
        final AbstractRecordTableModel recordModel = (AbstractRecordTableModel) entry.getModel();
        final Integer identifier = entry.getIdentifier();
        final RecordDefinition recordDefinition = recordModel.getRecordDefinition();
        final Class<?> clazz = recordDefinition.getFieldClass(identifier);
        if (Geometry.class.isAssignableFrom(clazz)) {
            return false;
        }
    }
    return true;
}
Also used : AbstractRecordTableModel(com.revolsys.swing.table.record.model.AbstractRecordTableModel) AbstractRecordTableModel(com.revolsys.swing.table.record.model.AbstractRecordTableModel) TableModel(javax.swing.table.TableModel) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 AbstractRecordTableModel (com.revolsys.swing.table.record.model.AbstractRecordTableModel)2 AbstractRecordQueryField (com.revolsys.swing.field.AbstractRecordQueryField)1 Field (com.revolsys.swing.field.Field)1 TextField (com.revolsys.swing.field.TextField)1 Component (java.awt.Component)1 ComboBoxEditor (javax.swing.ComboBoxEditor)1 JComboBox (javax.swing.JComboBox)1 JComponent (javax.swing.JComponent)1 JTextField (javax.swing.JTextField)1 TableModel (javax.swing.table.TableModel)1