use of org.apache.cayenne.map.EmbeddableAttribute in project cayenne by apache.
the class BoxCellRenderer method setUpdatedValueAt.
@Override
public void setUpdatedValueAt(Object value, int row, int col) {
EmbeddableAttribute attribute = getEmbeddableAttribute(row);
if (col == DB_ATTRIBUTE) {
attribute.setDbAttributeName(value != null ? value.toString() : null);
fireTableCellUpdated(row, col);
this.isAttributeOverrideChange = true;
((ObjAttributeInfoDialogView) ((ObjAttributeInfoDialog) eventSource).getView()).getSaveButton().setEnabled(true);
if (value != null) {
DbEntity currentEnt = ((ObjEntity) attr.getEntity()).getDbEntity();
if (currentEnt != null) {
DbAttribute dbAttr = (DbAttribute) currentEnt.getAttribute(value.toString());
if (dbAttr != null) {
fireTableCellUpdated(DB_ATTRIBUTE_TYPE, col);
}
}
}
fireTableRowsUpdated(row, row);
}
}
use of org.apache.cayenne.map.EmbeddableAttribute in project cayenne by apache.
the class CreateAttributeAction method performAction.
/**
* Creates ObjAttribute, DbAttribute depending on context.
*/
@Override
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
if (getProjectController().getCurrentEmbeddable() != null) {
Embeddable embeddable = mediator.getCurrentEmbeddable();
EmbeddableAttribute attr = new EmbeddableAttribute();
attr.setName(NameBuilder.builder(attr, embeddable).name());
createEmbAttribute(embeddable, attr);
application.getUndoManager().addEdit(new CreateEmbAttributeUndoableEdit(embeddable, new EmbeddableAttribute[] { attr }));
}
if (getProjectController().getCurrentObjEntity() != null) {
ObjEntity objEntity = mediator.getCurrentObjEntity();
ObjAttribute attr = new ObjAttribute();
attr.setName(NameBuilder.builder(attr, objEntity).name());
createObjAttribute(mediator.getCurrentDataMap(), objEntity, attr);
application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), objEntity, attr));
} else if (getProjectController().getCurrentDbEntity() != null) {
DbEntity dbEntity = getProjectController().getCurrentDbEntity();
DbAttribute attr = new DbAttribute();
attr.setName(NameBuilder.builder(attr, dbEntity).name());
attr.setType(TypesMapping.NOT_DEFINED);
attr.setEntity(dbEntity);
createDbAttribute(mediator.getCurrentDataMap(), dbEntity, attr);
application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), dbEntity, attr));
}
}
use of org.apache.cayenne.map.EmbeddableAttribute in project cayenne by apache.
the class FindAction method jumpToResult.
/**
* Navigate to search result
* Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
*/
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
if (searchResultEntry.getObject() instanceof Entity) {
jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Embeddable) {
jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
jumpToAttributeResult(searchResultEntry, editor, domain);
}
}
use of org.apache.cayenne.map.EmbeddableAttribute in project cayenne by apache.
the class ObjAttributeInfoDialog method rebuildTable.
private void rebuildTable() {
String typeName = null;
Collection<EmbeddableAttribute> embAttrTempCopy = new ArrayList<>();
if (attributeSaved.getType() != null) {
typeName = attributeSaved.getType();
}
if (embeddableNames.contains(typeName)) {
Collection<EmbeddableAttribute> embAttrTemp = stringToEmbeddables.get(typeName).getAttributes();
for (EmbeddableAttribute temp : embAttrTemp) {
EmbeddableAttribute at = new EmbeddableAttribute();
at.setDbAttributeName(temp.getDbAttributeName());
at.setName(temp.getName());
at.setType(temp.getType());
at.setEmbeddable(temp.getEmbeddable());
embAttrTempCopy.add(at);
}
}
embeddableModel = new OverrideEmbeddableAttributeTableModel(mediator, this, embAttrTempCopy, attributeSaved);
view.getOverrideAttributeTable().setModel(embeddableModel);
view.getOverrideAttributeTable().setRowHeight(25);
view.getOverrideAttributeTable().setRowMargin(3);
setUpTableStructure();
if (view.getTypeComboBox().getSelectedItem() == null) {
lastObjectType = "";
} else {
lastObjectType = view.getTypeComboBox().getSelectedItem();
}
}
use of org.apache.cayenne.map.EmbeddableAttribute in project cayenne by apache.
the class EmbeddableHandler method createEmbeddableAttribute.
private void createEmbeddableAttribute(Attributes attributes) {
EmbeddableAttribute ea = new EmbeddableAttribute(attributes.getValue("name"));
ea.setType(attributes.getValue("type"));
ea.setDbAttributeName(attributes.getValue("db-attribute-name"));
embeddable.addAttribute(ea);
}
Aggregations