ObjEntity entity = mediator.getCurrentObjEntity();
DbEntity dbEntity = (DbEntity) dbEntityCombo.getSelectedItem();
if (dbEntity != entity.getDbEntity()) {
entity.setDbEntity(dbEntity);
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
}
});
superEntityCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Change super-entity
CayenneMapEntry superEntity = (CayenneMapEntry) superEntityCombo
.getSelectedItem();
String name = (superEntity == noInheritance) ? null : superEntity
.getName();
ObjEntity entity = mediator.getCurrentObjEntity();
if (!Util.nullSafeEquals(name, entity.getSuperEntityName())) {
entity.setSuperEntityName(name);
// if a super-entity selected, disable table selection
// and also update parent DbEntity selection...
toggleEnabled(name == null, !serverOnly.isSelected());
dbEntityCombo.getModel().setSelectedItem(entity.getDbEntity());
superClassName.setText(entity.getSuperClassName());
// fire both EntityEvent and EntityDisplayEvent;
// the later is to update attribute and relationship display
DataDomain domain = mediator.getCurrentDataDomain();
DataMap map = mediator.getCurrentDataMap();
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(
this,
entity,
map,
domain));
}
}
});
tableLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Jump to DbEntity of the current ObjEntity
DbEntity entity = mediator.getCurrentObjEntity().getDbEntity();
if (entity != null) {
DataDomain dom = mediator.getCurrentDataDomain();
mediator.fireDbEntityDisplayEvent(new EntityDisplayEvent(
this,
entity,
entity.getDataMap(),
dom));
}
}
});
syncWithDbEntityButton.addActionListener(new ObjEntitySyncAction(mediator
.getApplication()));
readOnly.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null) {
entity.setReadOnly(readOnly.isSelected());
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
}
});
optimisticLocking.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null) {
entity.setDeclaredLockType(optimisticLocking.isSelected()
? ObjEntity.LOCK_TYPE_OPTIMISTIC
: ObjEntity.LOCK_TYPE_NONE);
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
}
});
serverOnly.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null) {
entity.setServerOnly(serverOnly.isSelected());
toggleEnabled(dbEntityCombo.isEnabled(), !serverOnly.isSelected());
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
}
});
}