All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datastax.data.dataset.event.DataTableEventAdapter Maven / Gradle / Ivy

The newest version!

package com.datastax.data.dataset.event;

import com.datastax.data.dataset.DataRow;

import java.beans.PropertyChangeListener;
import java.util.logging.Level;
import java.util.logging.Logger;


public abstract class DataTableEventAdapter implements DataTableListener, PropertyChangeListener {
    
    private static final Logger LOG = Logger.getLogger(DataTableEventAdapter.class.getName());
    
    
    public DataTableEventAdapter() {
    }
    
    
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
        LOG.log(Level.FINE, "propertyChange: {0}", evt);
        if ( evt.getSource().getClass() == DataRow.class ) {
            LOG.log(Level.FINE, "  is data row");
            DataRow row = (DataRow)evt.getSource();
            if ( evt.getPropertyName().equals("status")) {
                LOG.log(Level.FINE, "  is status change");
                rowStatusChanged(RowChangeEvent.newRowStatusChangeEvent(row, (DataRow.DataRowStatus)evt.getOldValue()));
            }
        }
    }

    
    public void rowChanged(RowChangeEvent evt) {
        switch ( evt.getEventType() ) {
            case ROW_STATUS_CHANGED:
                rowStatusChanged(evt);
                break;
            case CELL_CHANGED:
                cellChanged(evt);
                break;
            default:
                throw new RuntimeException("Unknown event type on row change event " + evt.getEventType());
        }
    }
    
    
    public void rowStatusChanged(RowChangeEvent evt) {}
    
    
    public void cellChanged(RowChangeEvent evt) {}
    
    
    public void tableChanged(TableChangeEvent evt) {
        switch ( evt.getEventType()) {
            case LOAD_STARTED:
                tableLoadStarted(evt);
                break;
            case LOAD_COMPLETE:
                tableLoadComplete(evt);
                break;
            case SAVE_STARTED:
                tableSaveStarted(evt);
                break;
            case SAVE_COMPLETE:
                tableSaveComplete(evt);
                break;
            case TABLE_CLEARED:
                tableCleared(evt);
                break;
            case ROW_ADDED:
                rowAdded(evt);
                break;
            case ROW_DELETED:
                rowDeleted(evt);
                break;
            case ROW_DISCARDED:
                rowDiscarded(evt);
                break;
            case COLUMN_ADDED:
                columnAdded(evt);
                break;
            case COLUMN_REMOVED:
                columnRemoved(evt);
                break;
            case COLUMN_CHANGED:
                columnChanged(evt);
                break;
            default:
                throw new RuntimeException("Unknown event type on row change event " + evt.getEventType());
        }
    }
    
    
    public void tableLoadStarted(TableChangeEvent evt) {}
    
    public void tableLoadComplete(TableChangeEvent evt) {}
    
    public void tableSaveStarted(TableChangeEvent evt) {}
    
    public void tableSaveComplete(TableChangeEvent evt) {}
    
    public void tableCleared(TableChangeEvent evt) {}
    
    public void rowAdded(TableChangeEvent evt) {}
    
    public void rowDeleted(TableChangeEvent evt) {}
    
    public void rowDiscarded(TableChangeEvent evt) {}
    
    public void columnAdded(TableChangeEvent evt) {}
    
    public void columnRemoved(TableChangeEvent evt) {}

    
    public void columnChanged(TableChangeEvent evt) {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy