use of org.apache.cayenne.modeler.util.DbRelationshipPathComboBoxEditor in project cayenne by apache.
the class ObjEntityRelationshipPanel method rebuildTable.
protected void rebuildTable(ObjEntity entity) {
final ObjRelationshipTableModel model = new ObjRelationshipTableModel(entity, mediator, this);
model.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if (table.getSelectedRow() >= 0) {
ObjRelationship rel = model.getRelationship(table.getSelectedRow());
enabledResolve = rel.getSourceEntity().getDbEntity() != null;
resolveMenu.setEnabled(enabledResolve);
}
}
});
table.setModel(model);
table.setRowHeight(25);
table.setRowMargin(3);
TableColumn col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_TARGET_PATH);
col.setCellEditor(new DbRelationshipPathComboBoxEditor());
col.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);
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
setToolTipText("To choose relationship press enter two times.To choose next relationship press dot.");
return this;
}
});
col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_DELETE_RULE);
JComboBox deleteRulesCombo = Application.getWidgetFactory().createComboBox(DELETE_RULES, false);
deleteRulesCombo.setFocusable(false);
deleteRulesCombo.setEditable(true);
((JComponent) deleteRulesCombo.getEditor().getEditorComponent()).setBorder(null);
deleteRulesCombo.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
// Default to the first value
deleteRulesCombo.setSelectedIndex(0);
col.setCellEditor(Application.getWidgetFactory().createCellEditor(deleteRulesCombo));
tablePreferences.bind(table, null, null, null, ObjRelationshipTableModel.REL_NAME, true);
}
Aggregations