Search in sources :

Example 16 with EntityEvent

use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.

the class SuperclassUpdateController method updateSuperclass.

protected void updateSuperclass() {
    boolean doAll = isAllEntities();
    String defaultSuperclass = getSuperclass();
    for (ObjEntity entity : dataMap.getObjEntities()) {
        if (doAll || Util.isEmptyString(getSuperClassName(entity))) {
            if (!Util.nullSafeEquals(defaultSuperclass, getSuperClassName(entity))) {
                setSuperClassName(entity, defaultSuperclass);
                // any way to batch events, a big change will flood the app with
                // entity events..?
                mediator.fireDbEntityEvent(new EntityEvent(this, entity));
            }
        }
    }
    view.dispose();
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 17 with EntityEvent

use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.

the class EntityEventTest method testConstructor2.

@Test
public void testConstructor2() throws Exception {
    Object src = new Object();
    Entity d = new DbEntity("abc");
    EntityEvent e = new EntityEvent(src, d, "oldname");
    assertSame(src, e.getSource());
    assertSame(d, e.getEntity());
    assertEquals("oldname", e.getOldName());
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent) Test(org.junit.Test)

Example 18 with EntityEvent

use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.

the class EntityEventTest method testNameChange1.

@Test
public void testNameChange1() throws Exception {
    Entity d = new DbEntity("abc");
    EntityEvent e = new EntityEvent(new Object(), d, "xyz");
    assertEquals(d.getName(), e.getNewName());
    assertTrue(e.isNameChange());
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent) Test(org.junit.Test)

Example 19 with EntityEvent

use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.

the class ObjEntityTab method setSuperClassName.

void setSuperClassName(String text) {
    if (text != null && text.trim().length() == 0) {
        text = null;
    }
    ObjEntity ent = mediator.getCurrentObjEntity();
    if (ent != null && !Util.nullSafeEquals(ent.getSuperClassName(), text)) {
        ent.setSuperClassName(text);
        mediator.fireObjEntityEvent(new EntityEvent(this, ent));
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 20 with EntityEvent

use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.

the class ObjEntityTab method setClientClassName.

void setClientClassName(String className) {
    if (className != null && className.trim().length() == 0) {
        className = null;
    }
    ObjEntity entity = mediator.getCurrentObjEntity();
    // "ent" may be null if we quit editing by changing tree selection
    if (entity != null && !Util.nullSafeEquals(entity.getClientClassName(), className)) {
        entity.setClientClassName(className);
        mediator.fireObjEntityEvent(new EntityEvent(this, entity));
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Aggregations

EntityEvent (org.apache.cayenne.map.event.EntityEvent)36 DbEntity (org.apache.cayenne.map.DbEntity)14 ObjEntity (org.apache.cayenne.map.ObjEntity)13 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)7 ProjectController (org.apache.cayenne.modeler.ProjectController)6 Entity (org.apache.cayenne.map.Entity)5 Test (org.junit.Test)5 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)4 ArrayList (java.util.ArrayList)3 ProcedureEvent (org.apache.cayenne.configuration.event.ProcedureEvent)3 DbAttribute (org.apache.cayenne.map.DbAttribute)3 ObjAttribute (org.apache.cayenne.map.ObjAttribute)3 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)3 ValidationException (org.apache.cayenne.validation.ValidationException)3 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)2 EntityMergeSupport (org.apache.cayenne.dbsync.merge.context.EntityMergeSupport)2 Expression (org.apache.cayenne.exp.Expression)2 DbKeyGenerator (org.apache.cayenne.map.DbKeyGenerator)2