Package org.apache.cayenne.modeler

Examples of org.apache.cayenne.modeler.ProjectController$ControllerState


    }

    @Override
    public void performAction(ActionEvent e, boolean allowAsking) {
        ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
        ProjectController mediator = getProjectController();

        EmbeddableAttribute[] embAttrs = getProjectController().getCurrentEmbAttrs();

        ObjAttribute[] attrs = getProjectController().getCurrentObjAttributes();

        if (embAttrs != null && embAttrs.length > 0) {
            if ((embAttrs.length == 1 && dialog.shouldDelete(
                    "Embeddable Attribute",
                    embAttrs[0].getName()))
                    || (embAttrs.length > 1 && dialog
                            .shouldDelete("selected EmbAttributes"))) {

                Embeddable embeddable = mediator.getCurrentEmbeddable();

                EmbeddableAttribute[] eAttrs = getProjectController()
                        .getCurrentEmbAttrs();

                application.getUndoManager().addEdit(
                        new RemoveAttributeUndoableEdit(embeddable, eAttrs));

                removeEmbeddableAttributes(embeddable, eAttrs);

            }
        }
        else if (attrs != null && attrs.length > 0) {
            if ((attrs.length == 1 && dialog.shouldDelete("ObjAttribute", attrs[0]
                    .getName()))
                    || (attrs.length > 1 && dialog.shouldDelete("selected ObjAttributes"))) {

                ObjEntity entity = mediator.getCurrentObjEntity();
                ObjAttribute[] attribs = mediator.getCurrentObjAttributes();

                application.getUndoManager().addEdit(
                        new RemoveAttributeUndoableEdit(
                                mediator.getCurrentDataDomain(),
                                mediator.getCurrentDataMap(),
                                entity,
                                attribs));

                removeObjAttributes(entity, attribs);
            }
        }
        else {
            DbAttribute[] dbAttrs = getProjectController().getCurrentDbAttributes();
            if (dbAttrs != null && dbAttrs.length > 0) {
                if ((dbAttrs.length == 1 && dialog.shouldDelete("DbAttribute", dbAttrs[0]
                        .getName()))
                        || (dbAttrs.length > 1 && dialog
                                .shouldDelete("selected DbAttributes"))) {

                    DbEntity entity = mediator.getCurrentDbEntity();
                    DbAttribute[] attribs = mediator.getCurrentDbAttributes();

                    ProjectPath[] paths = getProjectController().getCurrentPaths();

                    application.getUndoManager().addEdit(
                            new RemoveAttributeUndoableEdit(
                                    mediator.getCurrentDataDomain(),
                                    mediator.getCurrentDataMap(),
                                    entity,
                                    attribs));

                    removeDbAttributes(mediator.getCurrentDataMap(), entity, attribs);
                }
            }
        }
    }
View Full Code Here


            }
        }
    }

    public void removeDbAttributes(DataMap dataMap, DbEntity entity, DbAttribute[] attribs) {
        ProjectController mediator = getProjectController();

        for (DbAttribute attrib : attribs) {
            entity.removeAttribute(attrib.getName());

            AttributeEvent e = new AttributeEvent(
                    Application.getFrame(),
                    attrib,
                    entity,
                    MapEvent.REMOVE);

            mediator.fireDbAttributeEvent(e);
        }

        ProjectUtil.cleanObjMappings(dataMap);
    }
View Full Code Here

        ProjectUtil.cleanObjMappings(dataMap);
    }

    public void removeObjAttributes(ObjEntity entity, ObjAttribute[] attribs) {
        ProjectController mediator = getProjectController();

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

    }

    public void removeEmbeddableAttributes(
            Embeddable embeddable,
            EmbeddableAttribute[] attrs) {
        ProjectController mediator = getProjectController();

        for (EmbeddableAttribute attrib : attrs) {
            embeddable.removeAttribute(attrib.getName());
            EmbeddableAttributeEvent e = new EmbeddableAttributeEvent(Application
                    .getFrame(), attrib, embeddable, MapEvent.REMOVE);
            mediator.fireEmbeddableAttributeEvent(e);
        }
    }
View Full Code Here

     *
     * @param allowAsking If false, no question will be asked no matter what settings are
     */
    public void performAction(ActionEvent e, boolean allowAsking) {

        ProjectController mediator = getProjectController();

        ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);

        if (mediator.getCurrentObjEntity() != null) {
            if (dialog
                    .shouldDelete("ObjEntity", mediator.getCurrentObjEntity().getName())) {
                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(mediator.getCurrentDataMap(), mediator
                                .getCurrentObjEntity()));
                removeObjEntity(mediator.getCurrentDataMap(), mediator
                        .getCurrentObjEntity());
            }
        }
        else if (mediator.getCurrentDbEntity() != null) {
            if (dialog.shouldDelete("DbEntity", mediator.getCurrentDbEntity().getName())) {
                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(mediator.getCurrentDataMap(), mediator
                                .getCurrentDbEntity()));
                removeDbEntity(mediator.getCurrentDataMap(), mediator
                        .getCurrentDbEntity());
            }
        }
        else if (mediator.getCurrentQuery() != null) {
            if (dialog.shouldDelete("query", mediator.getCurrentQuery().getName())) {
                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(mediator.getCurrentDataMap(), mediator
                                .getCurrentQuery()));
                removeQuery(mediator.getCurrentDataMap(), mediator.getCurrentQuery());
            }
        }
        else if (mediator.getCurrentProcedure() != null) {
            if (dialog
                    .shouldDelete("procedure", mediator.getCurrentProcedure().getName())) {

                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(mediator.getCurrentDataMap(), mediator
                                .getCurrentProcedure()));

                removeProcedure(mediator.getCurrentDataMap(), mediator
                        .getCurrentProcedure());

            }
        }
        else if (mediator.getCurrentEmbeddable() != null) {
            if (dialog.shouldDelete("embeddable", mediator
                    .getCurrentEmbeddable()
                    .getClassName())) {

                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(mediator.getCurrentDataMap(), mediator
                                .getCurrentEmbeddable()));

                removeEmbeddable(mediator.getCurrentDataMap(), mediator
                        .getCurrentEmbeddable());
            }
        }
        else if (mediator.getCurrentDataMap() != null) {
            if (dialog.shouldDelete("data map", mediator.getCurrentDataMap().getName())) {

                // In context of Data node just remove from Data Node
                if (mediator.getCurrentDataNode() != null) {
                    application.getUndoManager().addEdit(
                            new RemoveUndoableEdit(application, mediator
                                    .getCurrentDataNode(), mediator.getCurrentDataMap()));

                    removeDataMapFromDataNode(mediator.getCurrentDataNode(), mediator
                            .getCurrentDataMap());

                }
                else {
                    // Not under Data Node, remove completely
                    application
                            .getUndoManager()
                            .addEdit(
                                    new RemoveUndoableEdit(application, mediator
                                            .getCurrentDataDomain(), mediator
                                            .getCurrentDataMap()));

                    removeDataMap(mediator.getCurrentDataDomain(), mediator
                            .getCurrentDataMap());

                }
            }
        }
        else if (mediator.getCurrentDataNode() != null) {
            if (dialog.shouldDelete("data node", mediator.getCurrentDataNode().getName())) {
                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(application, mediator
                                .getCurrentDataDomain(), mediator.getCurrentDataNode()));

                removeDataNode(mediator.getCurrentDataDomain(), mediator
                        .getCurrentDataNode());
            }
        }
        else if (mediator.getCurrentDataDomain() != null) {
            if (dialog.shouldDelete("data domain", mediator
                    .getCurrentDataDomain()
                    .getName())) {

                application.getUndoManager().addEdit(
                        new RemoveUndoableEdit(application, mediator
                                .getCurrentDataDomain()));

                removeDomain(mediator.getCurrentDataDomain());
            }
        }
        else if (mediator.getCurrentPaths() != null) { // multiple deletion
            if (dialog.shouldDelete("selected objects")) {
                ProjectPath[] paths = mediator.getCurrentPaths();

                CompoundEdit compoundEdit = new RemoveCompoundUndoableEdit();

                for (ProjectPath path : paths) {
                    compoundEdit.addEdit(removeLastPathComponent(path));
View Full Code Here

            case MAP_FROM_NODE: {
                this.dataNode.addDataMap(map);

                DataNodeEvent e = new DataNodeEvent(Application.getFrame(), this.dataNode);

                ProjectController controller = Application
                        .getInstance()
                        .getFrameController()
                        .getProjectController();

                e.setDomain(controller.findDomain(this.dataNode));

                controller.fireDataNodeEvent(e);
               
                break;
            }
            case MAP_FROM_DOMAIN: {
                CreateDataMapAction action = (CreateDataMapAction) actionManager
View Full Code Here

    }

    public void removeDomain(DataDomain domain) {
        ApplicationProject project = (ApplicationProject) getCurrentProject();
        ProjectController mediator = getProjectController();

        project.getConfiguration().removeDomain(domain.getName());
        mediator.fireDomainEvent(new DomainEvent(
                Application.getFrame(),
                domain,
                MapEvent.REMOVE));
    }
View Full Code Here

                domain,
                MapEvent.REMOVE));
    }

    public void removeDataMap(DataDomain domain, DataMap map) {
        ProjectController mediator = getProjectController();

        DataMapEvent e = new DataMapEvent(Application.getFrame(), map, MapEvent.REMOVE);
        e.setDomain(domain);

        domain.removeMap(map.getName());
        mediator.fireDataMapEvent(e);
    }
View Full Code Here

        domain.removeMap(map.getName());
        mediator.fireDataMapEvent(e);
    }

    public void removeDataNode(DataDomain domain, DataNode node) {
        ProjectController mediator = getProjectController();

        DataNodeEvent e = new DataNodeEvent(Application.getFrame(), node, MapEvent.REMOVE);
        e.setDomain(domain);

        domain.removeDataNode(node.getName());
        mediator.fireDataNodeEvent(e);
    }
View Full Code Here

    /**
     * Removes current DbEntity from its DataMap and fires "remove" EntityEvent.
     */
    public void removeDbEntity(DataMap map, DbEntity ent) {
        ProjectController mediator = getProjectController();

        EntityEvent e = new EntityEvent(Application.getFrame(), ent, MapEvent.REMOVE);
        e.setDomain(mediator.findDomain(map));

        map.removeDbEntity(ent.getName(), true);
        mediator.fireDbEntityEvent(e);
    }
View Full Code Here

TOP

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

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.