Package org.apache.cayenne.modeler

Examples of org.apache.cayenne.modeler.ProjectController


    /**
     * @see org.apache.cayenne.modeler.util.CayenneAction#performAction(ActionEvent)
     */
    public void performAction(ActionEvent e) {
        ProjectController mediator = getProjectController();
        DataDomain domain = mediator.getCurrentDataDomain();

        // use domain name as DataNode base, as node names must be unique across the
        // project...
        DataNode node = buildDataNode();
        mediator.fireDataNodeEvent(new DataNodeEvent(this, node, MapEvent.ADD));
        mediator.fireDataNodeDisplayEvent(new DataNodeDisplayEvent(this, domain, node));
    }
View Full Code Here


    /**
     * Creates a new DataNode, adding to the current domain, but doesn't send any events.
     */
    protected DataNode buildDataNode() {
        ProjectController mediator = getProjectController();
        DataDomain domain = mediator.getCurrentDataDomain();

        // use domain name as DataNode base, as node names must be unique across the
        // project...
        DataNode node = createDataNode(domain);

View Full Code Here

    /**
     * Moves to the previous element in the navigation history
     */
    public void performAction(ActionEvent e) {
        ProjectController mediator = getProjectController();
        EventObject newEvent = new EventObject(this);
        mediator.fireNavigationEvent(newEvent);
    }
View Full Code Here

    protected void createDomain() {
        // only ApplicationProjects can have domains, so this cast is reasonable
        ApplicationProject project = (ApplicationProject) getCurrentProject();

        ProjectController mediator = getProjectController();
        DataDomain domain = (DataDomain) NamedObjectFactory.createObject(
                DataDomain.class,
                project.getConfiguration());
        domain.getEntityResolver().setIndexedByClass(false);
        project.getConfiguration().addDomain(domain);
        mediator.fireDomainEvent(new DomainEvent(this, domain, MapEvent.ADD));
        mediator.fireDomainDisplayEvent(new DomainDisplayEvent(this, domain));
    }
View Full Code Here

    public void performAction(ActionEvent e) {
        synchDbEntity();
    }

    protected void synchDbEntity() {
        ProjectController mediator = getProjectController();

        DbEntity dbEntity = mediator.getCurrentDbEntity();

        if (dbEntity != null) {

            Iterator it = dbEntity.getDataMap().getMappedEntities(dbEntity).iterator();
            if (!it.hasNext()) {
                return;
            }

            EntityMergeSupport merger = new EntitySyncController(Application
                    .getInstance()
                    .getFrameController(), dbEntity).createMerger();

            if (merger == null) {
                return;
            }

            while (it.hasNext()) {
                ObjEntity entity = (ObjEntity) it.next();
                if (merger.synchronizeWithDbEntity(entity)) {
                    mediator.fireObjEntityEvent(new EntityEvent(
                            this,
                            entity,
                            MapEvent.CHANGE));
                }
            }
View Full Code Here

            removeDbAttribute();
        }
    }

    protected void removeDbAttribute() {
        ProjectController mediator = getProjectController();
        DbEntity entity = mediator.getCurrentDbEntity();
        DbAttribute attrib = mediator.getCurrentDbAttribute();
        entity.removeAttribute(attrib.getName());
        ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());

        AttributeEvent e = new AttributeEvent(
                Application.getFrame(),
                attrib,
                entity,
                MapEvent.REMOVE);
        mediator.fireDbAttributeEvent(e);
    }
View Full Code Here

                MapEvent.REMOVE);
        mediator.fireDbAttributeEvent(e);
    }

    protected void removeObjAttribute() {
        ProjectController mediator = getProjectController();
        ObjEntity entity = mediator.getCurrentObjEntity();
        ObjAttribute attrib = mediator.getCurrentObjAttribute();

        entity.removeAttribute(attrib.getName());
        AttributeEvent e = new AttributeEvent(
                Application.getFrame(),
                attrib,
                entity,
                MapEvent.REMOVE);
        mediator.fireObjAttributeEvent(e);
    }
View Full Code Here

    public void performAction(ActionEvent e) {
        synchObjEntity();
    }

    protected void synchObjEntity() {
        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;
            }

            if (merger.synchronizeWithDbEntity(entity)) {
                mediator
                        .fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
                mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(
                        this,
                        entity,
                        entity.getDataMap(),
                        mediator.getCurrentDataDomain()));
            }
        }
    }
View Full Code Here

            removeDbRelationship();
        }
    }

    protected void removeObjRelationship() {
        ProjectController mediator = getProjectController();
        ObjEntity entity = mediator.getCurrentObjEntity();
        ObjRelationship rel = mediator.getCurrentObjRelationship();
        entity.removeRelationship(rel.getName());
        RelationshipEvent e = new RelationshipEvent(
                Application.getFrame(),
                rel,
                entity,
                MapEvent.REMOVE);
        mediator.fireObjRelationshipEvent(e);
    }
View Full Code Here

                MapEvent.REMOVE);
        mediator.fireObjRelationshipEvent(e);
    }

    protected void removeDbRelationship() {
        ProjectController mediator = getProjectController();
        DbEntity entity = mediator.getCurrentDbEntity();
        DbRelationship rel = mediator.getCurrentDbRelationship();
        entity.removeRelationship(rel.getName());
        ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());

        RelationshipEvent e = new RelationshipEvent(
                Application.getFrame(),
                rel,
                entity,
                MapEvent.REMOVE);
        mediator.fireDbRelationshipEvent(e);
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.modeler.ProjectController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.