Search in sources :

Example 1 with EmbeddableAttributeEvent

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);
}
Also used : EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)

Example 2 with EmbeddableAttributeEvent

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);
}
Also used : EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute)

Example 3 with EmbeddableAttributeEvent

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());
        }
    }
}
Also used : EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent) RemoveAttributeUndoableEdit(org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Embeddable(org.apache.cayenne.map.Embeddable)

Example 4 with EmbeddableAttributeEvent

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);
    }
}
Also used : EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController)

Aggregations

EmbeddableAttributeEvent (org.apache.cayenne.map.event.EmbeddableAttributeEvent)4 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)3 Embeddable (org.apache.cayenne.map.Embeddable)1 ProjectController (org.apache.cayenne.modeler.ProjectController)1 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)1 RemoveAttributeUndoableEdit (org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit)1