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.editor.dbentity;
 
 import  org.apache.cayenne.map.DbEntity;
 import  org.apache.cayenne.map.DerivedDbAttribute;
 import  org.apache.cayenne.map.event.AttributeEvent;
Table model for derived DbAttributes.

Author(s):
Andrei Adamchik
 
 	// Column indices
 	private static final int DB_ATTRIBUTE_NAME = 0;
 	private static final int DB_ATTRIBUTE_SPEC = 1;
 	private static final int DB_ATTRIBUTE_TYPE = 2;
 	private static final int DB_ATTRIBUTE_GROUPBY = 3;
 	private static final int DB_ATTRIBUTE_PRIMARY_KEY = 4;
 	private static final int DB_ATTRIBUTE_MANDATORY = 5;


Constructor for DerivedDbAttributeTableModel.

Parameters:
entity
mediator
eventSource
 
 			DbEntity entity,
 			ProjectController mediator,
 			Object eventSource) {
 		super(entitymediatoreventSource);
 	}

See also:
javax.swing.table.TableModel.getColumnClass(int)
 
 	public Class getColumnClass(int col) {
 		switch (col) {
 				return Boolean.class;
 			default :
 				return String.class;
 		}
 	}
 
     public int mandatoryColumnInd() {
     	return ;
     }
     
     public int nameColumnInd() {
     	return ;
     }
     
     public int typeColumnInd() {
     	return ;
     }

See also:
javax.swing.table.TableModel.getColumnCount()
 
 	public int getColumnCount() {
 		return 6;
 	}


See also:
javax.swing.table.TableModel.getColumnName(int)
 
 	public String getColumnName(int col) {
 		switch(col) {
 			case return "Name";
 			case return "Spec";
 			case return "Type";
 			case return "Group By";
 			case return "PK";
 			case return "Mandatory";
			defaultreturn "";
		}
	}
	public Object getValueAt(int rowint column) {
		DerivedDbAttribute attr = (DerivedDbAttribute)getAttribute(row);
		if (attr == null) {
			return "";
		}
		switch (column) {
				return getAttributeName(attr);
				return getSpec(attr);
				return getAttributeType(attr);
				return isGroupBy(attr);
				return isPrimaryKey(attr);
				return isMandatory(attr);
			default :
				return "";
		}
	}
	public void setUpdatedValueAt(Object newValint rowint col) {
		DerivedDbAttribute attr = (DerivedDbAttribute)getAttribute(row);
		if (attr == null) {
			return;
		}
		AttributeEvent e = new AttributeEvent(attr);
		switch (col) {
				e.setOldName(attr.getName());
				setAttributeName((StringnewValattr);
				break;
				setSpec((StringnewValattr);
				break;
				setAttributeType((StringnewValattr);
				break;
				setGroupBy((BooleannewValattr);
				break;
				if(!setPrimaryKey((BooleannewValattrrow)) {
					return;
				}
				break;
				setMandatory((BooleannewValattr);
				break;
		}
	}
	public String getSpec(DerivedDbAttribute attr) {
		return attr.getExpressionSpec();
	}
	public void setSpec(String newVal, DerivedDbAttribute attr) {
		attr.setExpressionSpec(newVal);
	}
	public Boolean isGroupBy(DerivedDbAttribute attr) {
		return attr.isGroupBy() ? . : .;
	}
	public void setGroupBy(Boolean newVal, DerivedDbAttribute attr) {
		attr.setGroupBy(newVal.booleanValue());
	}


See also:
org.apache.cayenne.modeler.util.CayenneTableModel.getElementsClass()
	public Class getElementsClass() {
		return DerivedDbAttribute.class;
	}
New to GrepCode? Check out our FAQ X