Search in sources :

Example 51 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class InferRelationshipsController method generateAction.

public void generateAction() {
    ProjectController mediator = application.getFrameController().getProjectController();
    InferRelationshipsUndoableEdit undoableEdit = new InferRelationshipsUndoableEdit();
    for (InferredRelationship temp : selectedEntities) {
        DbRelationship rel = new DbRelationship(uniqueRelName(temp.getSource(), temp.getName()));
        RelationshipEvent e = new RelationshipEvent(Application.getFrame(), rel, temp.getSource(), MapEvent.ADD);
        mediator.fireDbRelationshipEvent(e);
        rel.setSourceEntity(temp.getSource());
        rel.setTargetEntityName(temp.getTarget());
        DbJoin join = new DbJoin(rel, temp.getJoinSource().getName(), temp.getJoinTarget().getName());
        rel.addJoin(join);
        rel.setToMany(temp.isToMany());
        temp.getSource().addRelationship(rel);
        undoableEdit.addEdit(new CreateRelationshipUndoableEdit(temp.getSource(), new DbRelationship[] { rel }));
    }
    JOptionPane.showMessageDialog(this.getView(), getSelectedEntitiesSize() + " relationships generated");
    view.dispose();
}
Also used : DbRelationship(org.apache.cayenne.map.DbRelationship) CreateRelationshipUndoableEdit(org.apache.cayenne.modeler.undo.CreateRelationshipUndoableEdit) DbJoin(org.apache.cayenne.map.DbJoin) ProjectController(org.apache.cayenne.modeler.ProjectController) InferRelationshipsUndoableEdit(org.apache.cayenne.modeler.undo.InferRelationshipsUndoableEdit) RelationshipEvent(org.apache.cayenne.map.event.RelationshipEvent)

Example 52 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CopyAction method performAction.

/**
 * Performs copying of items into system buffer
 */
@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    Object content = copy(mediator);
    if (content != null) {
        Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
        sysClip.setContents(new CayenneTransferable(content), null);
    }
    // update paste button
    getApplication().getActionManager().getAction(PasteAction.class).updateState();
}
Also used : CayenneTransferable(org.apache.cayenne.modeler.util.CayenneTransferable) Clipboard(java.awt.datatransfer.Clipboard) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 53 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateAttributeAction method createObjAttribute.

public void createObjAttribute(DataMap map, ObjEntity objEntity, ObjAttribute attr) {
    ProjectController mediator = getProjectController();
    objEntity.addAttribute(attr);
    fireObjAttributeEvent(this, mediator, map, objEntity, attr);
}
Also used : ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 54 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateDataMapAction method performAction.

public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) mediator.getProject().getRootNode();
    DataMap map = new DataMap();
    map.setName(NameBuilder.builder(map, dataChannelDescriptor).name());
    createDataMap(map);
    application.getUndoManager().addEdit(new CreateDataMapUndoableEdit(dataChannelDescriptor, map));
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) CreateDataMapUndoableEdit(org.apache.cayenne.modeler.undo.CreateDataMapUndoableEdit) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMap(org.apache.cayenne.map.DataMap)

Example 55 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class CreateEmbeddableAction method performAction.

@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    DataMap dataMap = mediator.getCurrentDataMap();
    Embeddable embeddable = new Embeddable();
    String baseName = NameBuilder.builder(embeddable, dataMap).name();
    String nameWithPackage = dataMap.getNameWithDefaultPackage(baseName);
    embeddable.setClassName(nameWithPackage);
    createEmbeddable(dataMap, embeddable);
    application.getUndoManager().addEdit(new CreateEmbeddableUndoableEdit(dataMap, embeddable));
}
Also used : CreateEmbeddableUndoableEdit(org.apache.cayenne.modeler.undo.CreateEmbeddableUndoableEdit) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Aggregations

ProjectController (org.apache.cayenne.modeler.ProjectController)59 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)12 ObjEntity (org.apache.cayenne.map.ObjEntity)10 DbEntity (org.apache.cayenne.map.DbEntity)8 DataMap (org.apache.cayenne.map.DataMap)7 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)6 EntityEvent (org.apache.cayenne.map.event.EntityEvent)6 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)5 ObjAttribute (org.apache.cayenne.map.ObjAttribute)5 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)5 ArrayList (java.util.ArrayList)4 DbAttribute (org.apache.cayenne.map.DbAttribute)4 DbRelationship (org.apache.cayenne.map.DbRelationship)4 Embeddable (org.apache.cayenne.map.Embeddable)4 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)4 ObjRelationship (org.apache.cayenne.map.ObjRelationship)4 RelationshipEvent (org.apache.cayenne.map.event.RelationshipEvent)4 ComponentAdapter (java.awt.event.ComponentAdapter)3 ComponentEvent (java.awt.event.ComponentEvent)3 EntityMergeSupport (org.apache.cayenne.dbsync.merge.context.EntityMergeSupport)3