Package org.apache.cayenne.map.event

Examples of org.apache.cayenne.map.event.AttributeEvent


            attr.addParam(at);
        }

        // notify interested parties about the changes
        getMediator().fireDbAttributeEvent(
            new AttributeEvent(
                this,
                attr,
                attr.getEntity(),
                MapEvent.CHANGE));
View Full Code Here


        DbAttribute attr = getAttribute(row);
        if (attr == null) {
            return;
        }

        AttributeEvent e = new AttributeEvent(eventSource, attr, entity);

        switch (col) {
            case DB_ATTRIBUTE_NAME:
                e.setOldName(attr.getName());
                attr.setName((String) newVal);
                // setAttributeName((String) newVal, attr);
                fireTableCellUpdated(row, col);
                break;
            case DB_ATTRIBUTE_TYPE:
View Full Code Here

    DerivedDbAttribute attr = (DerivedDbAttribute)getAttribute(row);
    if (attr == null) {
      return;
    }

    AttributeEvent e = new AttributeEvent(eventSource, attr, entity);

    switch (col) {
      case DB_ATTRIBUTE_NAME :
        e.setOldName(attr.getName());
        setAttributeName((String) newVal, attr);
        fireTableCellUpdated(row, col);
        break;
      case DB_ATTRIBUTE_SPEC :
        setSpec((String) newVal, attr);
View Full Code Here

    }

    public void setUpdatedValueAt(Object value, int row, int column) {

        ObjAttribute attribute = getAttribute(row);
        AttributeEvent event = new AttributeEvent(eventSource, attribute, entity);

        if (column == OBJ_ATTRIBUTE) {
            event.setOldName(attribute.getName());
            ProjectUtil.setAttributeName(
                attribute,
                value != null ? value.toString().trim() : null);
            fireTableCellUpdated(row, column);
        }
View Full Code Here

                while (attributes.hasNext()) {

                    ObjAttribute a = (ObjAttribute) attributes.next();
                    if (a.isUsedForLocking() != on) {
                        a.setUsedForLocking(on);
                        parent.fireObjAttributeEvent(new AttributeEvent(this, a, entity));
                    }
                }
            }

            if (updateRelationships) {
View Full Code Here

           
            for(ObjAttribute attribute: entity.getAttributes()){
                if(attribute instanceof EmbeddedAttribute){
                    if(oldNameEmbeddableToNewName.size()>0 && oldNameEmbeddableToNewName.containsKey(attribute.getType())){
                        attribute.setType(oldNameEmbeddableToNewName.get(attribute.getType()));
                        AttributeEvent ev = new AttributeEvent(this, attribute, entity);
                        mediator.fireObjAttributeEvent(ev);
                    }
                }
            }
        }
View Full Code Here

            if (updateAttributes) {
                for (ObjAttribute a : entity.getAttributes()) {
                    if (a.isUsedForLocking() != on) {
                        a.setUsedForLocking(on);
                        parent.fireObjAttributeEvent(new AttributeEvent(this, a, entity));
                    }
                }
            }

            if (updateRelationships) {
View Full Code Here

        EntityDisplayEvent event = new EntityDisplayEvent(this, mediator
                .getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor)mediator.getProject().getRootNode());

        mediator.fireObjEntityDisplayEvent(event);

        mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeSaved, model
                .getEntity(), MapEvent.CHANGE));

        AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(
                this,
                attributeSaved,
View Full Code Here

                   
                    while (attrIt.hasNext()) {
                        ObjAttribute atribute = attrIt.next();
                        if (atribute.getType()==null || atribute.getType().equals(oldName)) {
                            atribute.setType(newClassName);
                            AttributeEvent ev = new AttributeEvent(this, atribute, atribute
                                    .getEntity());
                            mediator.fireObjAttributeEvent(ev);
                        }
                    }
                   
View Full Code Here

    }

    public void setUpdatedValueAt(Object value, int row, int column) {

        ObjAttribute attribute = getAttribute(row);
        AttributeEvent event = new AttributeEvent(eventSource, attribute, entity);
        String path = null;
        Collection<String> nameAttr = null;

        if (column == OBJ_ATTRIBUTE) {
            event.setOldName(attribute.getName());
            ProjectUtil.setAttributeName(attribute, value != null ? value
                    .toString()
                    .trim() : null);
            fireTableCellUpdated(row, column);
        }
        else if (column == OBJ_ATTRIBUTE_TYPE) {
            String oldType = attribute.getType();
            attribute.setType(value != null ? value.toString() : null);
            String newType = attribute.getType();
            String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
            Collection<String> registeredTypesList =  Arrays.asList(registeredTypes); ;
            if(oldType!=null && newType!=null && ! (registeredTypesList.contains(oldType) == registeredTypesList.contains(newType))){
                ObjAttribute attributeNew;
               
                ArrayList<Embeddable> embs = mediator.getEmbeddableNamesInCurRentDataDomain();
                ArrayList<String> embNames = new ArrayList<String>();
                Iterator<Embeddable> it = embs.iterator();
                while (it.hasNext()) {
                    embNames.add(it.next().getClassName());
                }
               
                if(registeredTypesList.contains(newType) || !embNames.contains(newType)){
                    attributeNew = new ObjAttribute();
                } else {
                    attributeNew = new EmbeddedAttribute();
                    attribute.setDbAttributePath(null);
                }
               
                attributeNew.setDbAttributePath(attribute.getDbAttributePath());
                attributeNew.setName(attribute.getName());
                attributeNew.setEntity(attribute.getEntity());
                attributeNew.setParent(attribute.getParent());
                attributeNew.setType(attribute.getType());
                attributeNew.setUsedForLocking(attribute.isUsedForLocking());
                Entity ent = attribute.getEntity();
                ent.removeAttribute(attribute.getName());
                ent.addAttribute(attributeNew);
               
                mediator.fireObjEntityEvent(new EntityEvent(
                        this,
                        ent,
                        MapEvent.CHANGE));

                EntityDisplayEvent ev = new EntityDisplayEvent(this, mediator
                        .getCurrentObjEntity(), mediator.getCurrentDataMap(), mediator
                        .getCurrentDataDomain());

                mediator.fireObjEntityDisplayEvent(ev);

                mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeNew, ent, MapEvent.CHANGE));

                AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(
                        this,
                        attributeNew,
                        mediator.getCurrentObjEntity(),
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.event.AttributeEvent

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.