Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.apache.cayenne.modeler.dialog.objentity;
 
 import java.awt.Color;
 import java.util.List;
 import java.util.Map;
 
 
 import  org.apache.cayenne.dba.TypesMapping;
 import  org.apache.cayenne.map.DbAttribute;
 import  org.apache.cayenne.map.DbEntity;
 import  org.apache.cayenne.map.EmbeddableAttribute;
 import  org.apache.cayenne.map.EmbeddedAttribute;
 import  org.apache.cayenne.map.ObjAttribute;
 import  org.apache.cayenne.map.ObjEntity;
 
 
     private Map<StringStringoverrideAttr;
     private ObjAttribute attr;
     private boolean isAttributeOverrideChange;
 
     private CayenneTable table;
 
     protected List<EmbeddableAttribute> embeddableList;
 
     public List<EmbeddableAttribute> getEmbeddableList() {
         return ;
     }
 
             Object eventSourceCollection<EmbeddableAttribute> embAttr, ObjAttribute attr) {
 
         super(mediatoreventSourcenew ArrayList<Object>(embAttr));
         this. = new ArrayList<EmbeddableAttribute>(embAttr);
         this. = attr;
         this. = false;
         if (attr instanceof EmbeddedAttribute) {
             EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attr;
             this. = embeddedAttribute.getAttributeOverrides();
         }
         else {
             this. = null;
         }
 
         Iterator<EmbeddableAttribute> it = .iterator();
 
         while (it.hasNext()) {
             EmbeddableAttribute emb = it.next();
             if ( != null) {
                 if (.get(emb.getName()) != null) {
                     emb.setDbAttributeName(.get(emb.getName()));
                 }
             }
         }
     }
 
     public Map<StringStringgetOverrideAttr() {
         return ;
     }
 
     // Columns
     static final int OBJ_ATTRIBUTE = 0;
     static final int OBJ_ATTRIBUTE_TYPE = 1;
     static final int DB_ATTRIBUTE = 2;
    static final int DB_ATTRIBUTE_TYPE = 3;
    protected void orderList() {
        // NOOP
    }

    
Returns ObjAttribute class.
    @Override
    public Class<?> getElementsClass() {
        return ObjAttribute.class;
    }
    @Override
    public void setUpdatedValueAt(Object valueint rowint col) {
        EmbeddableAttribute attribute = getEmbeddableAttribute(row);
        if (col == ) {
            attribute.setDbAttributeName(value != null ? value.toString() : null);
            fireTableCellUpdated(rowcol);
            this. = true;
                    .getView()).getSaveButton().setEnabled(true);
            if (value != null) {
                DbEntity currentEnt = ((ObjEntity) .getEntity()).getDbEntity();
                if (currentEnt != null) {
                    DbAttribute dbAttr = (DbAttribute) currentEnt.getAttribute(value
                            .toString());
                    if (dbAttr != null) {
                        fireTableCellUpdated(col);
                    }
                }
            }
            fireTableRowsUpdated(rowrow);
        }
    }
    public boolean isAttributeOverrideChange() {
        return ;
    }
            Collection<StringnameAttr,
            CayenneTable table) {
        this. = table;
        this. = new CellEditorForAttributeTable(table, CayenneWidgetFactory
                .createComboBox(nameAttrtrue));
        return ;
    }
        return ;
    }
    public boolean isCellEditable(int rowint col) {
        return col == ;
    }
    public EmbeddableAttribute getEmbeddableAttribute(int row) {
        return (row >= 0 && row < .size())
                ? (EmbeddableAttribute) .get(row)
                : null;
    }
    public int getColumnCount() {
        return 4;
    }
    public Object getValueAt(int rowint column) {
        EmbeddableAttribute attribute = getEmbeddableAttribute(row);
        if (column == ) {
            return attribute.getName();
        }
        else if (column == ) {
            return attribute.getType();
        }
        else {
            String dbAttributeName = attribute.getDbAttributeName();
            if (column == ) {
                return dbAttributeName;
            }
            else if (column == ) {
                DbEntity currentEnt = ((ObjEntity) .getEntity()).getDbEntity();
                if (currentEnt != null
                        && currentEnt.getAttributes() != null
                        && dbAttributeName != null) {
                    DbAttribute dbAttr = (DbAttribute) currentEnt
                            .getAttribute(dbAttributeName);
                    if (dbAttr != null) {
                        return TypesMapping.getSqlNameByType(dbAttr.getType());
                    }
                }
                return null;
            }
            else {
                return null;
            }
        }
    }
    public String getColumnName(int column) {
        switch (column) {
            case :
                return "ObjAttribute";
            case :
                return "Java Type";
            case :
                return "DbAttribute";
            case :
                return "DB Type";
            default:
                return "";
        }
    }
    public void setComboBoxes(Collection<StringnameAttrint column) {
        int count = getRowCount();
        for (int i = 0; i < counti++) {
            EmbeddableAttribute embAt = getEmbeddableAttribute(i);
            if (!nameAttr.contains(embAt.getDbAttributeName())
                    && embAt.getDbAttributeName() != null) {
                Collection<StringattributeComboForRow = new ArrayList<String>();
                attributeComboForRow.addAll(nameAttr);
                attributeComboForRow.add(embAt.getDbAttributeName());
                JComboBox comboBoxForRow = CayenneWidgetFactory.createComboBox(
                        attributeComboForRow,
                        true);
                .setEditorAt(new Integer(i), new DefaultCellEditor(
                        comboBoxForRow));
                BoxCellRenderer renderer = new BoxCellRenderer();
                renderer.setNotActiveColumn(attributeComboForRow.size() - 1);
                comboBoxForRow.setRenderer(renderer);
            }
        }
    }
    public ObjAttribute getAttribute() {
        return ;
    }
class BoxCellRenderer implements ListCellRenderer {
    private int notActiveColumn;
            JList list,
            Object value,
            int index,
            boolean isSelected,
            boolean cellHasFocus) {
                list,
                value,
                index,
                isSelected,
                cellHasFocus);
        if (getNotActiveColumn() != 0 && index == getNotActiveColumn()) {
            renderer.setForeground(.);
        }
        return renderer;
    }
    public int getNotActiveColumn() {
        return ;
    }
    public void setNotActiveColumn(int notActiveColumn) {
        this. = notActiveColumn;
    }
New to GrepCode? Check out our FAQ X