Search in sources :

Example 86 with DataChannelDescriptor

use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.

the class RemoveAction method removeDataNode.

public void removeDataNode(DataNodeDescriptor node) {
    ProjectController mediator = getProjectController();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    DataNodeEvent e = new DataNodeEvent(Application.getFrame(), node, MapEvent.REMOVE);
    e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
    domain.getNodeDescriptors().remove(node);
    mediator.fireDataNodeEvent(e);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataNodeEvent(org.apache.cayenne.configuration.event.DataNodeEvent) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 87 with DataChannelDescriptor

use of org.apache.cayenne.configuration.DataChannelDescriptor 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);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMapDisplayEvent(org.apache.cayenne.modeler.event.DataMapDisplayEvent) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) ObjEntity(org.apache.cayenne.map.ObjEntity) DomainDisplayEvent(org.apache.cayenne.modeler.event.DomainDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) Procedure(org.apache.cayenne.map.Procedure)

Example 88 with DataChannelDescriptor

use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.

the class ProjectTreeView method entityAdded.

/**
 * Event handler for ObjEntity and DbEntity additions. Adds a tree node for the entity
 * and make it selected.
 */
protected void entityAdded(EntityEvent e) {
    Entity entity = e.getEntity();
    DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath(new Object[] { e.getDomain() != null ? e.getDomain() : (DataChannelDescriptor) mediator.getProject().getRootNode(), e.getEntity().getDataMap() });
    if (mapNode == null) {
        return;
    }
    DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(entity, false);
    positionNode(mapNode, currentNode, Comparators.getDataMapChildrenComparator());
    showNode(currentNode);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 89 with DataChannelDescriptor

use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.

the class ProjectTreeView method dataMapRemoved.

public void dataMapRemoved(DataMapEvent e) {
    DataMap map = e.getDataMap();
    DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    removeNode(new Object[] { dataChannelDescriptor, map });
    mediator.getEntityResolver().removeDataMap(e.getDataMap());
    // Clean up map from the nodes
    for (DataNodeDescriptor dataNode : new ArrayList<>(dataChannelDescriptor.getNodeDescriptors())) {
        removeNode(new Object[] { dataChannelDescriptor, dataNode, map });
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ArrayList(java.util.ArrayList) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 90 with DataChannelDescriptor

use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.

the class ProjectTreeView method queryAdded.

public void queryAdded(QueryEvent e) {
    DefaultMutableTreeNode node = getProjectModel().getNodeForObjectPath(new Object[] { e.getDomain() != null ? e.getDomain() : (DataChannelDescriptor) mediator.getProject().getRootNode(), e.getDataMap() });
    if (node == null) {
        return;
    }
    QueryDescriptor query = e.getQuery();
    DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(query, false);
    positionNode(node, currentNode, Comparators.getDataMapChildrenComparator());
    showNode(currentNode);
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Aggregations

DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)100 DataMap (org.apache.cayenne.map.DataMap)50 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)28 Test (org.junit.Test)20 ObjEntity (org.apache.cayenne.map.ObjEntity)18 DbEntity (org.apache.cayenne.map.DbEntity)12 ProjectController (org.apache.cayenne.modeler.ProjectController)12 URL (java.net.URL)11 Embeddable (org.apache.cayenne.map.Embeddable)11 ArrayList (java.util.ArrayList)10 URLResource (org.apache.cayenne.resource.URLResource)10 ObjAttribute (org.apache.cayenne.map.ObjAttribute)8 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)8 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)8 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)6 Injector (org.apache.cayenne.di.Injector)6 Procedure (org.apache.cayenne.map.Procedure)6 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)6 Resource (org.apache.cayenne.resource.Resource)6