use of org.apache.cayenne.swing.BindingBuilder in project cayenne by apache.
the class LockingUpdateController method initBindings.
protected void initBindings() {
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.bindToAction(view.getCancelButton(), "cancelAction()");
builder.bindToAction(view.getUpdateButton(), "updateAction()");
}
use of org.apache.cayenne.swing.BindingBuilder in project cayenne by apache.
the class DBGeneratorOptions method initController.
protected void initController() {
DefaultComboBoxModel<String> adapterModel = new DefaultComboBoxModel<>(DbAdapterInfo.getStandardAdapters());
view.getAdapters().setModel(adapterModel);
view.getAdapters().setSelectedIndex(0);
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
sqlBinding = builder.bindToTextArea(view.getSql(), "textForSQL");
adapterBinding = builder.bindToComboSelection(view.getAdapters(), "connectionInfo.dbAdapter", "refreshSQLAction()", "org.apache.cayenne.dba.JdbcAdapter");
optionBindings = new ObjectBinding[5];
optionBindings[0] = builder.bindToStateChangeAndAction(view.getCreateFK(), "generatorDefaults.createFK", "refreshSQLAction()");
optionBindings[1] = builder.bindToStateChangeAndAction(view.getCreatePK(), "generatorDefaults.createPK", "refreshSQLAction()");
optionBindings[2] = builder.bindToStateChangeAndAction(view.getCreateTables(), "generatorDefaults.createTables", "refreshSQLAction()");
optionBindings[3] = builder.bindToStateChangeAndAction(view.getDropPK(), "generatorDefaults.dropPK", "refreshSQLAction()");
optionBindings[4] = builder.bindToStateChangeAndAction(view.getDropTables(), "generatorDefaults.dropTables", "refreshSQLAction()");
builder.bindToAction(view.getGenerateButton(), "generateSchemaAction()");
builder.bindToAction(view.getSaveSqlButton(), "storeSQLAction()");
builder.bindToAction(view.getCancelButton(), "closeAction()");
// refresh SQL if different tables were selected
view.getTabs().addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (view.getTabs().getSelectedIndex() == 0) {
// this assumes that some tables where checked/unchecked... not very
// efficient
refreshGeneratorAction();
}
}
});
}
use of org.apache.cayenne.swing.BindingBuilder in project cayenne by apache.
the class TableSelectorController method initController.
// ------ other stuff ------
protected void initController() {
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.bindToAction(view.getCheckAll(), "checkAllAction()");
TableBindingBuilder tableBuilder = new TableBindingBuilder(builder);
tableBuilder.addColumn("", "setTable(#item), included", Boolean.class, true, Boolean.TRUE);
tableBuilder.addColumn("Table", "#item.name", String.class, false, "XXXXXXXXXXXXXXXX");
tableBuilder.addColumn("Problems", "setTable(#item), problem", String.class, false, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
this.tableBinding = tableBuilder.bindToTable(view.getTables(), "tables");
}
use of org.apache.cayenne.swing.BindingBuilder 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.swing.BindingBuilder in project cayenne by apache.
the class ObjAttributeInfoDialog method initController.
private void initController(ObjAttribute attr) {
for (String embeddableName : embeddableNames) {
((DefaultComboBoxModel) view.getTypeComboBox().getModel()).addElement(embeddableName);
}
this.attribute = attr;
if (attribute instanceof EmbeddedAttribute || embeddableNames.contains(attribute.getType())) {
this.attributeSaved = new EmbeddedAttribute();
} else {
this.attributeSaved = new ObjAttribute();
}
copyObjAttribute(attributeSaved, attribute);
relTargets = new ArrayList<DbEntity>(attribute.getEntity().getDataMap().getDbEntities());
/*
* Register auto-selection of the target
*/
view.getPathBrowser().addTreeSelectionListener(this);
view.getAttributeName().setText(attribute.getName());
if (attribute.getDbAttributePath() != null) {
if (attribute.getDbAttributePath().contains(".")) {
String path = attribute.getDbAttributePath();
view.getCurrentPathLabel().setText(path.replace(".", " -> "));
} else {
view.getCurrentPathLabel().setText(attribute.getDbAttributePath());
}
} else {
view.getCurrentPathLabel().setText("");
}
view.getSourceEntityLabel().setText(attribute.getEntity().getName());
view.getTypeComboBox().setSelectedItem(attribute.getType());
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.bindToAction(view.getCancelButton(), "closeAction()");
builder.bindToAction(view.getSelectPathButton(), "setPath(true)");
builder.bindToAction(view.getSaveButton(), "saveMapping()");
/*
* set filter for ObjAttributePathBrowser
*/
if (view.getPathBrowser().getModel() == null) {
Entity firstEntity = null;
if (attribute.getDbAttribute() == null) {
if (attribute.getParent() instanceof ObjEntity) {
DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();
if (dbEnt != null) {
Collection<DbAttribute> attrib = dbEnt.getAttributes();
Collection<DbRelationship> rel = dbEnt.getRelationships();
if (attrib.size() > 0) {
Iterator<DbAttribute> iter = attrib.iterator();
firstEntity = iter.next().getEntity();
} else if (rel.size() > 0) {
Iterator<DbRelationship> iter = rel.iterator();
firstEntity = iter.next().getSourceEntity();
}
}
}
} else {
firstEntity = getFirstEntity();
}
if (firstEntity != null) {
EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
treeModel.setFilter(new EntityTreeAttributeRelationshipFilter());
view.getPathBrowser().setModel(treeModel);
}
}
if (attribute.getDbAttribute() != null) {
setSelectionPath();
}
view.getTypeComboBox().addItemListener(e -> {
if (lastObjectType != null) {
if (!lastObjectType.equals(e.getItemSelectable())) {
if (embeddableNames.contains(e.getItemSelectable().getSelectedObjects()[0].toString())) {
if (attributeSaved instanceof ObjAttribute) {
EmbeddedAttribute copyAttrSaved = new EmbeddedAttribute();
copyObjAttribute(copyAttrSaved, attributeSaved);
attributeSaved = copyAttrSaved;
}
} else {
if (attributeSaved instanceof EmbeddedAttribute) {
ObjAttribute copyAttrSaved = new ObjAttribute();
copyObjAttribute(copyAttrSaved, attributeSaved);
attributeSaved = copyAttrSaved;
}
}
attributeSaved.setType(e.getItemSelectable().getSelectedObjects()[0].toString());
rebuildTable();
setEnabledSaveButton();
}
}
});
view.getAttributeName().addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (!view.getAttributeName().getText().equals(attribute.getName())) {
setEnabledSaveButton();
}
}
public void keyReleased(KeyEvent e) {
if (!view.getAttributeName().getText().equals(attribute.getName())) {
setEnabledSaveButton();
}
}
public void keyTyped(KeyEvent e) {
}
});
rebuildTable();
}
Aggregations