use of org.apache.cayenne.modeler.event.EmbeddableDisplayEvent in project cayenne by apache.
the class FindAction method jumpToEmbeddableResult.
private static void jumpToEmbeddableResult(Embeddable embeddable, EditorView editor, DataChannelDescriptor domain) {
DataMap map = embeddable.getDataMap();
buildAndSelectTreePath(map, embeddable, editor);
EmbeddableDisplayEvent event = new EmbeddableDisplayEvent(editor.getProjectTreeView(), embeddable, map, domain);
event.setMainTabFocus(true);
editor.currentEmbeddableChanged(event);
}
use of org.apache.cayenne.modeler.event.EmbeddableDisplayEvent in project cayenne by apache.
the class CreateEmbeddableAction method fireEmbeddableEvent.
static void fireEmbeddableEvent(Object src, ProjectController mediator, DataMap dataMap, Embeddable embeddable) {
mediator.fireEmbeddableEvent(new EmbeddableEvent(src, embeddable, MapEvent.ADD), dataMap);
EmbeddableDisplayEvent displayEvent = new EmbeddableDisplayEvent(src, embeddable, dataMap, (DataChannelDescriptor) mediator.getProject().getRootNode());
displayEvent.setMainTabFocus(true);
mediator.fireEmbeddableDisplayEvent(displayEvent);
}
use of org.apache.cayenne.modeler.event.EmbeddableDisplayEvent in project cayenne by apache.
the class EmbeddableDisplayEventType method fireLastDisplayEvent.
@Override
public void fireLastDisplayEvent() {
DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
if (!dataChannel.getName().equals(preferences.getDomain())) {
return;
}
DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
if (dataMap == null) {
return;
}
Embeddable embeddable = dataMap.getEmbeddable(preferences.getEmbeddable());
if (embeddable == null) {
return;
}
EmbeddableDisplayEvent embeddableDisplayEvent = new EmbeddableDisplayEvent(this, embeddable, dataMap, dataChannel);
controller.fireEmbeddableDisplayEvent(embeddableDisplayEvent);
}
use of org.apache.cayenne.modeler.event.EmbeddableDisplayEvent 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.modeler.event.EmbeddableDisplayEvent in project cayenne by apache.
the class ProjectTreeView method processSelection.
/**
* Processes node selection regardless of whether a new node was selected, or an
* already selected node was clicked again. Normally called from event listener
* methods.
*/
public void processSelection(TreePath path) {
if (path == null) {
return;
}
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Object[] data = getUserObjects(currentNode);
if (data.length == 0) {
// this should clear the right-side panel
DomainDisplayEvent domEvent = new DomainDisplayEvent(this, null);
domEvent.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireDomainDisplayEvent(domEvent);
return;
}
Object obj = data[data.length - 1];
if (obj instanceof DataChannelDescriptor) {
mediator.fireDomainDisplayEvent(new DomainDisplayEvent(this, (DataChannelDescriptor) obj));
} else if (obj instanceof DataMap) {
if (data.length == 2) {
mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(this, (DataMap) obj, (DataChannelDescriptor) mediator.getProject().getRootNode(), (DataNodeDescriptor) data[data.length - 2]));
} else if (data.length == 1) {
mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(this, (DataMap) obj, (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
} else if (obj instanceof DataNodeDescriptor) {
if (data.length == 1) {
mediator.fireDataNodeDisplayEvent(new DataNodeDisplayEvent(this, (DataChannelDescriptor) mediator.getProject().getRootNode(), (DataNodeDescriptor) obj));
}
} else if (obj instanceof Entity) {
EntityDisplayEvent e = new EntityDisplayEvent(this, (Entity) obj);
e.setUnselectAttributes(true);
if (data.length == 3) {
e.setDataMap((DataMap) data[data.length - 2]);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
e.setDataNode((DataNodeDescriptor) data[data.length - 3]);
} else if (data.length == 2) {
e.setDataMap((DataMap) data[data.length - 2]);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
}
if (obj instanceof ObjEntity) {
mediator.fireObjEntityDisplayEvent(e);
} else if (obj instanceof DbEntity) {
mediator.fireDbEntityDisplayEvent(e);
}
} else if (obj instanceof Embeddable) {
EmbeddableDisplayEvent e = new EmbeddableDisplayEvent(this, (Embeddable) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireEmbeddableDisplayEvent(e);
} else if (obj instanceof Procedure) {
ProcedureDisplayEvent e = new ProcedureDisplayEvent(this, (Procedure) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireProcedureDisplayEvent(e);
} else if (obj instanceof QueryDescriptor) {
QueryDisplayEvent e = new QueryDisplayEvent(this, (QueryDescriptor) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireQueryDisplayEvent(e);
}
this.scrollPathToVisible(path);
}
Aggregations