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);
}
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;
}
}
Aggregations