use of org.apache.cayenne.configuration.event.DomainEvent in project cayenne by apache.
the class DataDomainView method setDomainProperty.
/**
* Helper method that updates domain properties. If a value equals to default, null
* value is used instead.
*/
protected void setDomainProperty(String property, String value, String defaultValue) {
DataChannelDescriptor domain = (DataChannelDescriptor) projectController.getProject().getRootNode();
if (domain == null) {
return;
}
// no empty strings
if ("".equals(value)) {
value = null;
}
// use NULL for defaults
if (value != null && value.equals(defaultValue)) {
value = null;
}
Map properties = domain.getProperties();
Object oldValue = properties.get(property);
if (!Util.nullSafeEquals(value, oldValue)) {
properties.put(property, value);
DomainEvent e = new DomainEvent(this, domain);
projectController.fireDomainEvent(e);
}
}
use of org.apache.cayenne.configuration.event.DomainEvent in project cayenne by apache.
the class DataDomainView method setDomainName.
void setDomainName(String newName) {
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
if (Util.nullSafeEquals(dataChannelDescriptor.getName(), newName)) {
return;
}
if (newName == null || newName.trim().length() == 0) {
throw new ValidationException("Enter name for DataDomain");
}
Preferences prefs = projectController.getPreferenceForDataDomain();
DomainEvent e = new DomainEvent(this, dataChannelDescriptor, dataChannelDescriptor.getName());
dataChannelDescriptor.setName(newName);
RenamedPreferences.copyPreferences(newName, prefs);
projectController.fireDomainEvent(e);
}
use of org.apache.cayenne.configuration.event.DomainEvent in project cayenne by apache.
the class ProjectController method removeFromHistory.
private void removeFromHistory(EventObject e) {
int count = controllerStateHistory.size();
List<ControllerState> removeList = new ArrayList<>();
for (int i = 0; i < count; i++) {
ControllerState cs = controllerStateHistory.get(i);
if (cs == null || cs.event == null) {
continue;
}
EventObject csEvent = cs.event;
if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
removeList.add(cs);
}
} else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
removeList.add(cs);
}
} else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
removeList.add(cs);
}
} else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
removeList.add(cs);
}
} else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
removeList.add(cs);
}
} else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
removeList.add(cs);
}
} else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
removeList.add(cs);
}
}
}
for (ControllerState o : removeList) {
controllerStateHistory.remove(o);
}
}
use of org.apache.cayenne.configuration.event.DomainEvent in project cayenne by apache.
the class DomainEventTest method testConstructor2.
@Test
public void testConstructor2() throws Exception {
Object src = new Object();
DataChannelDescriptor d = new DataChannelDescriptor();
DomainEvent e = new DomainEvent(src, d, "oldname");
assertSame(src, e.getSource());
assertSame(d, e.getDomain());
assertEquals("oldname", e.getOldName());
}
use of org.apache.cayenne.configuration.event.DomainEvent in project cayenne by apache.
the class DomainEventTest method testDomain.
@Test
public void testDomain() throws Exception {
Object src = new Object();
DataChannelDescriptor d = new DataChannelDescriptor();
DomainEvent e = new DomainEvent(src, null);
e.setDomain(d);
assertSame(d, e.getDomain());
}
Aggregations