Search in sources :

Example 26 with DataChannelDescriptor

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

the class CreateProcedureParameterAction method fireProcedureParameterEvent.

/**
 * Fires events when an proc parameter was added
 */
static void fireProcedureParameterEvent(Object src, ProjectController mediator, Procedure procedure, ProcedureParameter parameter) {
    mediator.fireProcedureParameterEvent(new ProcedureParameterEvent(src, parameter, MapEvent.ADD));
    mediator.fireProcedureParameterDisplayEvent(new ProcedureParameterDisplayEvent(src, parameter, procedure, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
Also used : ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ProcedureParameterEvent(org.apache.cayenne.configuration.event.ProcedureParameterEvent)

Example 27 with DataChannelDescriptor

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

the class CreateRelationshipUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveRelationshipAction action = actionManager.getAction(RemoveRelationshipAction.class);
    if (objEnt != null) {
        action.removeObjRelationships(objEnt, objectRel);
        controller.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, objEnt, objEnt.getDataMap(), (DataChannelDescriptor) controller.getProject().getRootNode()));
    }
    if (dbEnt != null) {
        action.removeDbRelationships(dbEnt, dbRel);
        controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEnt, dbEnt.getDataMap(), (DataChannelDescriptor) controller.getProject().getRootNode()));
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) RemoveRelationshipAction(org.apache.cayenne.modeler.action.RemoveRelationshipAction)

Example 28 with DataChannelDescriptor

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

the class CayenneAction method buildTreePath.

/**
 * Builds a tree path for a given entity. Urgent for later selection.
 *
 * @param entity to build path for
 * @return tree path
 */
protected static TreePath buildTreePath(Entity entity) {
    DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    Object[] path = new Object[] { domain, entity.getDataMap(), entity };
    Object[] mutableTreeNodes = new Object[path.length];
    mutableTreeNodes[0] = ((ProjectTreeModel) editor().getProjectTreeView().getModel()).getRootNode();
    Object[] helper;
    for (int i = 1; i < path.length; i++) {
        helper = new Object[i];
        for (int j = 0; j < i; ) {
            helper[j] = path[++j];
        }
        mutableTreeNodes[i] = ((ProjectTreeModel) editor().getProjectTreeView().getModel()).getNodeForObjectPath(helper);
    }
    return new TreePath(mutableTreeNodes);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) TreePath(javax.swing.tree.TreePath)

Example 29 with DataChannelDescriptor

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

the class FindAction method jumpToResult.

/**
 * Navigate to search result
 * Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
 */
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
    EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
    DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    if (searchResultEntry.getObject() instanceof Entity) {
        jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
        jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Embeddable) {
        jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
        jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
        jumpToAttributeResult(searchResultEntry, editor, domain);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EJBQLQueryDescriptor(org.apache.cayenne.map.EJBQLQueryDescriptor) SelectQueryDescriptor(org.apache.cayenne.map.SelectQueryDescriptor) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) EditorView(org.apache.cayenne.modeler.editor.EditorView) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) CayenneModelerFrame(org.apache.cayenne.modeler.CayenneModelerFrame) Embeddable(org.apache.cayenne.map.Embeddable)

Example 30 with DataChannelDescriptor

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

the class FindAction method search.

private List<SearchResultEntry> search(String searchStr) {
    Pattern pattern = Pattern.compile(searchStr, Pattern.CASE_INSENSITIVE);
    List<SearchResultEntry> result = new ArrayList<>();
    for (DataMap dataMap : ((DataChannelDescriptor) getProjectController().getProject().getRootNode()).getDataMaps()) {
        searchInQueryDescriptors(pattern, result, dataMap);
        searchInEmbeddables(pattern, result, dataMap);
        searchInDbEntities(pattern, result, dataMap);
        searchInObjEntities(pattern, result, dataMap);
    }
    Collections.sort(result);
    return result;
}
Also used : Pattern(java.util.regex.Pattern) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ArrayList(java.util.ArrayList) DataMap(org.apache.cayenne.map.DataMap)

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