use of org.apache.cayenne.map.DbEntity in project cayenne by apache.
the class DbEntityTab method setQualifier.
void setQualifier(String qualifier) {
if (qualifier != null && qualifier.trim().length() == 0) {
qualifier = null;
}
DbEntity ent = mediator.getCurrentDbEntity();
if (ent != null && !Util.nullSafeEquals(ent.getQualifier(), qualifier)) {
ExpressionConvertor convertor = new ExpressionConvertor();
try {
String oldQualifier = convertor.valueAsString(ent.getQualifier());
if (!Util.nullSafeEquals(oldQualifier, qualifier)) {
Expression exp = (Expression) convertor.stringAsValue(qualifier);
ent.setQualifier(exp);
mediator.fireDbEntityEvent(new EntityEvent(this, ent));
}
} catch (IllegalArgumentException ex) {
// unparsable qualifier
throw new ValidationException(ex.getMessage());
}
}
}
use of org.apache.cayenne.map.DbEntity in project cayenne by apache.
the class DbEntityTab method setCatalog.
void setCatalog(String text) {
if (text != null && text.trim().length() == 0) {
text = null;
}
DbEntity ent = mediator.getCurrentDbEntity();
if (ent != null && !Util.nullSafeEquals(ent.getCatalog(), text)) {
ent.setCatalog(text);
mediator.fireDbEntityEvent(new EntityEvent(this, ent));
}
}
use of org.apache.cayenne.map.DbEntity in project cayenne by apache.
the class DbEntityTabbedView method currentDbEntityChanged.
/**
* If entity is null hides it's contents, otherwise makes it visible.
*/
public void currentDbEntityChanged(EntityDisplayEvent e) {
Entity entity = e.getEntity();
if (e.isMainTabFocus() && entity instanceof DbEntity) {
if (getSelectedComponent() != entityPanel) {
setSelectedComponent(entityPanel);
entityPanel.setVisible(true);
}
}
resetRemoveButtons();
setVisible(e.getEntity() != null);
if (projectController.getEntityTabSelection() < getTabCount()) {
setSelectedIndex(projectController.getEntityTabSelection());
}
}
use of org.apache.cayenne.map.DbEntity in project cayenne by apache.
the class RemoveEntityAction method performAction.
@Override
public void performAction(ActionEvent e, boolean allowAsking) {
ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
Entity entity = builder.getSelectedEntity();
if (entity == null) {
return;
}
if (entity instanceof ObjEntity) {
if (dialog.shouldDelete("ObjEntity", entity.getName())) {
application.getUndoManager().addEdit(new RemoveUndoableEdit(entity.getDataMap(), (ObjEntity) entity));
removeObjEntity(entity.getDataMap(), (ObjEntity) entity);
}
} else {
if (dialog.shouldDelete("DbEntity", entity.getName())) {
application.getUndoManager().addEdit(new RemoveUndoableEdit(entity.getDataMap(), (DbEntity) entity));
removeDbEntity(entity.getDataMap(), (DbEntity) entity);
}
}
}
use of org.apache.cayenne.map.DbEntity in project cayenne by apache.
the class FindAction method searchInDbEntities.
private void searchInDbEntities(Pattern pattern, List<SearchResultEntry> result, DataMap dataMap) {
for (DbEntity ent : dataMap.getDbEntities()) {
if (match(ent.getName(), pattern)) {
result.add(new SearchResultEntry(ent, ent.getName()));
}
for (DbAttribute attr : ent.getAttributes()) {
if (match(attr.getName(), pattern)) {
result.add(new SearchResultEntry(attr, ent.getName() + "." + attr.getName()));
}
}
for (DbRelationship rel : ent.getRelationships()) {
if (match(rel.getName(), pattern)) {
result.add(new SearchResultEntry(rel, ent.getName() + "." + rel.getName()));
}
}
checkCatalogOrSchema(pattern, result, ent, ent.getCatalog());
checkCatalogOrSchema(pattern, result, ent, ent.getSchema());
}
}
Aggregations