use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class ShowGraphEntityAction method performAction.
@Override
public void performAction(ActionEvent e) {
Entity entity = null;
ProjectController mediator = getProjectController();
if (mediator.getCurrentDbEntity() != null) {
entity = mediator.getCurrentDbEntity();
} else if (mediator.getCurrentObjEntity() != null) {
entity = mediator.getCurrentObjEntity();
}
if (entity != null) {
showEntity(entity);
}
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class LinkDataMapAction method linkDataMap.
public void linkDataMap(DataMap map, DataNodeDescriptor node) {
if (map == null) {
return;
}
// no change?
if (node != null && node.getDataMapNames().contains(map.getName())) {
return;
}
ProjectController mediator = getProjectController();
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) mediator.getProject().getRootNode();
Collection<DataNodeDescriptor> unlinkedNodes = new ArrayList<>();
// Being paranoid, we will still scan through all.
for (DataNodeDescriptor nextNode : dataChannelDescriptor.getNodeDescriptors()) {
if (nextNode.getDataMapNames().contains(map.getName())) {
nextNode.getDataMapNames().remove(map.getName());
mediator.fireDataNodeEvent(new DataNodeEvent(this, nextNode));
unlinkedNodes.add(nextNode);
}
}
// link to a selected node
if (node != null) {
node.getDataMapNames().add(map.getName());
// announce DataNode change
mediator.fireDataNodeEvent(new DataNodeEvent(this, node));
}
application.getUndoManager().addEdit(new LinkDataMapUndoableEdit(map, node, unlinkedNodes, mediator));
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class LinkDataMapsAction method performAction.
@Override
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) mediator.getProject().getRootNode();
Collection<String> linkedDataMaps = new ArrayList<>();
DataNodeDescriptor dataNodeDescriptor = mediator.getCurrentDataNode();
for (DataNodeDescriptor dataNodeDesc : dataChannelDescriptor.getNodeDescriptors()) {
linkedDataMaps.addAll(dataNodeDesc.getDataMapNames());
}
for (DataMap dataMap : dataChannelDescriptor.getDataMaps()) {
if (!linkedDataMaps.contains(dataMap.getName())) {
dataNodeDescriptor.getDataMapNames().add(dataMap.getName());
mediator.fireDataNodeEvent(new DataNodeEvent(this, dataNodeDescriptor));
}
}
application.getUndoManager().addEdit(new LinkDataMapsUndoableEdit(dataNodeDescriptor, linkedDataMaps, mediator));
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class NavigateBackwardAction method performAction.
/**
* Moves to the next element in the navigation history
*/
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
EventObject newEvent = new EventObject(this);
mediator.fireNavigationEvent(newEvent);
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class ObjEntitySyncAction method syncObjEntity.
protected void syncObjEntity() {
ProjectController mediator = getProjectController();
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null && entity.getDbEntity() != null) {
EntityMergeSupport merger = new EntitySyncController(Application.getInstance().getFrameController(), entity).createMerger();
if (merger == null) {
return;
}
merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
if (merger.synchronizeWithDbEntity(entity)) {
mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, entity, entity.getDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
}
}
Aggregations