Search in sources :

Example 1 with MergeDirection

use of org.apache.cayenne.dbsync.merge.context.MergeDirection in project cayenne by apache.

the class MergerTokenSelectorController method initController.

// ------ other stuff ------
protected void initController() {
    BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
    builder.bindToAction(view.getCheckAll(), "checkAllAction()");
    builder.bindToAction(view.getReverseAll(), "reverseAllAction()");
    TableModel model = new MergerTokenTableModel(this);
    MergeDirection[] dirs = new MergeDirection[] { MergeDirection.TO_DB, MergeDirection.TO_MODEL };
    view.getTokens().setModel(model);
    TableColumnModel columnModel = view.getTokens().getColumnModel();
    // dropdown for direction column
    JComboBox directionCombo = Application.getWidgetFactory().createComboBox(dirs, false);
    directionCombo.setEditable(false);
    TableColumn directionColumn = columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION);
    directionColumn.setCellRenderer(new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setHorizontalTextPosition(SwingConstants.LEFT);
            setIcon(ModelerUtil.buildIcon("icon-arrow-open.png"));
            return this;
        }
    });
    directionColumn.setCellEditor(new DefaultCellEditor(directionCombo));
    columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setPreferredWidth(50);
    columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setPreferredWidth(100);
    columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setMaxWidth(50);
    columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setMaxWidth(100);
}
Also used : BindingBuilder(org.apache.cayenne.swing.BindingBuilder) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) MergeDirection(org.apache.cayenne.dbsync.merge.context.MergeDirection) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

Example 2 with MergeDirection

use of org.apache.cayenne.dbsync.merge.context.MergeDirection in project cayenne by apache.

the class MergerTokenTableModel method setValueAt.

public void setValueAt(Object value, int rowIndex, int columnIndex) {
    MergerToken token = getToken(rowIndex);
    switch(columnIndex) {
        case COL_SELECT:
            Boolean val = (Boolean) value;
            getController().select(token, val.booleanValue());
            break;
        case COL_DIRECTION:
            MergeDirection direction = (MergeDirection) value;
            getController().setDirection(token, direction);
            break;
    }
}
Also used : MergeDirection(org.apache.cayenne.dbsync.merge.context.MergeDirection) MergerToken(org.apache.cayenne.dbsync.merge.token.MergerToken)

Aggregations

MergeDirection (org.apache.cayenne.dbsync.merge.context.MergeDirection)2 AbstractTableModel (javax.swing.table.AbstractTableModel)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 TableModel (javax.swing.table.TableModel)1 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)1 BindingBuilder (org.apache.cayenne.swing.BindingBuilder)1