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;
 
 
 import  org.apache.cayenne.map.DbEntity;
 import  org.apache.cayenne.map.DbJoin;
 import  org.apache.cayenne.map.DbRelationship;
Model for editing DbAttributePair-s. Changes in the join attributes don't take place until commit() is called. Creation of the new DbAttributes is not allowed - user should choose from the existing ones.
 
 public class DbJoinTableModel extends CayenneTableModel {
 
     // Columns
     static final int SOURCE = 0;
     static final int TARGET = 1;
 
     protected DbRelationship relationship;
     protected DbEntity source;
     protected DbEntity target;

    
Is the table editable.
 
     private boolean editable;
 
     public DbJoinTableModel(
         DbRelationship relationship,
         ProjectController mediator,
         Object src) {
 
         super(mediatorsrcnew ArrayList(relationship.getJoins()));
         this. = relationship;
         this. = (DbEntity) relationship.getSourceEntity();
         this. = (DbEntity) relationship.getTargetEntity();
     }
 
     public DbJoinTableModel(
         DbRelationship relationship,
         ProjectController mediator,
         Object src,
         boolean editable) {
 
         this(relationshipmediatorsrc);
         this. = editable;
     }
 
     public Class getElementsClass() {
         return DbJoin.class;
     }

    
Mode new attribute pairs from list to the DbRelationship.
 
     public void commit() {
         .setJoins(getObjectList());
     }

    
Returns null to disable ordering.
 
     public String getOrderingKey() {
         return null;
     }
 
     public int getColumnCount() {
         return 2;
     }
 
     public String getColumnName(int column) {
         if (column == )
             return "Source";
         else if (column == )
             return "Target";
         else
             return "";
     }
 
     public DbJoin getJoin(int row) {
         return (row >= 0 && row < .size())
             ? (DbJoin) .get(row)
            : null;
    }
    public Object getValueAt(int rowint column) {
        DbJoin join = getJoin(row);
        if (join == null) {
            return null;
        }
        if (column == ) {
            return join.getSourceName();
        }
        else if (column == ) {
            return join.getTargetName();
        }
        else {
            return null;
        }
    }
    public void setUpdatedValueAt(Object aValueint rowint column) {
        DbJoin join = getJoin(row);
        if (join == null) {
            return;
        }
        String value = (StringaValue;
        if (column == ) {
            if ( == null || .getAttribute(value) == null) {
                value = null;
            }
            join.setSourceName(value);
        }
        else if (column == ) {
            if ( == null || .getAttribute(value) == null) {
                value = null;
            }
            join.setTargetName(value);
        }
        
        fireTableRowsUpdated(rowrow);
    }
    public boolean isCellEditable(int rowint col) {
        if (col == ) {
            return .getSourceEntity() != null && ;
        }
        else if (col == ) {
            return .getTargetEntity() != null && ;
        }
        return false;
    }
New to GrepCode? Check out our FAQ X