use of org.apache.cayenne.map.event.EmbeddableAttributeEvent in project cayenne by apache.
the class CreateAttributeAction method fireEmbeddableAttributeEvent.
static void fireEmbeddableAttributeEvent(Object src, ProjectController mediator, Embeddable embeddable, EmbeddableAttribute attr) {
mediator.fireEmbeddableAttributeEvent(new EmbeddableAttributeEvent(src, attr, embeddable, MapEvent.ADD));
EmbeddableAttributeDisplayEvent e = new EmbeddableAttributeDisplayEvent(src, embeddable, attr, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireEmbeddableAttributeDisplayEvent(e);
}
use of org.apache.cayenne.map.event.EmbeddableAttributeEvent in project cayenne by apache.
the class EmbeddableAttributeTableModel method setUpdatedValueAt.
@Override
public void setUpdatedValueAt(Object value, int row, int col) {
EmbeddableAttribute attribute = getEmbeddableAttribute(row);
EmbeddableAttributeEvent event = new EmbeddableAttributeEvent(eventSource, embeddable, attribute);
String path = null;
Collection<String> nameAttr = null;
if (col == OBJ_ATTRIBUTE) {
event.setOldName(attribute.getName());
ProjectUtil.setEmbeddableAttributeName(attribute, value != null ? value.toString().trim() : null);
fireTableCellUpdated(row, col);
} else if (col == OBJ_ATTRIBUTE_TYPE) {
attribute.setType(value != null ? value.toString() : null);
fireTableCellUpdated(row, col);
} else if (col == DB_ATTRIBUTE) {
attribute.setDbAttributeName(value != null ? value.toString() : null);
fireTableCellUpdated(row, col);
}
mediator.fireEmbeddableAttributeEvent(event);
}
use of org.apache.cayenne.map.event.EmbeddableAttributeEvent in project cayenne by apache.
the class RemoveAction method removeEmbAttributes.
private void removeEmbAttributes(ProjectController mediator, ConfirmRemoveDialog dialog, EmbeddableAttribute[] embAttrs) {
if (embAttrs != null && embAttrs.length > 0) {
if ((embAttrs.length == 1 && dialog.shouldDelete("DbAttribute", embAttrs[0].getName())) || (embAttrs.length > 1 && dialog.shouldDelete("selected DbAttributes"))) {
Embeddable embeddable = mediator.getCurrentEmbeddable();
application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(embeddable, embAttrs));
for (EmbeddableAttribute attrib : embAttrs) {
embeddable.removeAttribute(attrib.getName());
EmbeddableAttributeEvent e = new EmbeddableAttributeEvent(Application.getFrame(), attrib, embeddable, MapEvent.REMOVE);
mediator.fireEmbeddableAttributeEvent(e);
}
ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());
}
}
}
use of org.apache.cayenne.map.event.EmbeddableAttributeEvent in project cayenne by apache.
the class RemoveAttributeAction method removeEmbeddableAttributes.
public void removeEmbeddableAttributes(Embeddable embeddable, EmbeddableAttribute[] attrs) {
ProjectController mediator = getProjectController();
for (EmbeddableAttribute attrib : attrs) {
embeddable.removeAttribute(attrib.getName());
EmbeddableAttributeEvent e = new EmbeddableAttributeEvent(Application.getFrame(), attrib, embeddable, MapEvent.REMOVE);
mediator.fireEmbeddableAttributeEvent(e);
}
}
Aggregations