2007-04-28 15:59:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2007 IDCA. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
|
|
|
* following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
|
|
|
* the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
|
|
|
* and the following disclaimer in the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
|
|
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.idcanet.vasc.impl;
|
|
|
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
import com.idcanet.vasc.annotations.VascAnnotationParser;
|
|
|
|
import com.idcanet.vasc.core.VascTable;
|
|
|
|
import com.idcanet.vasc.core.VascTableController;
|
|
|
|
import com.idcanet.vasc.core.column.VascAnnotationTableColumn;
|
|
|
|
import com.idcanet.vasc.core.column.VascTableColumn;
|
|
|
|
import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Willem Cazander
|
|
|
|
* @version 1.0 Apr 28, 2007
|
|
|
|
*/
|
|
|
|
public class DefaultVascTableController implements VascTableController {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see com.idcanet.vasc.core.VascTableController#finalizeVascColumns(com.idcanet.vasc.core.VascTable)
|
|
|
|
*/
|
|
|
|
public void finalizeVascColumns(VascTable table) throws Exception {
|
|
|
|
VascAnnotationParser vap = new VascAnnotationParser();
|
|
|
|
|
|
|
|
for(VascTableColumn c:table.getTableColumns()) {
|
|
|
|
if (c instanceof VascAnnotationTableColumn) {
|
|
|
|
VascAnnotationTableColumn column = (VascAnnotationTableColumn)c;
|
|
|
|
|
|
|
|
if (c.getName()==null) {
|
|
|
|
c.setName(vap.getVascNameKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
|
|
|
}
|
|
|
|
if (c.getToolTip()==null) {
|
|
|
|
c.setToolTip(vap.getVascToolTipKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
|
|
|
}
|
|
|
|
if (c.getDefaultValue()==null) {
|
|
|
|
c.setDefaultValue(vap.getVascDefaultValue(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
|
|
|
}
|
|
|
|
if (c.getWidth()==null) {
|
|
|
|
Object obj = vap.getVascColumnWidth(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty());
|
|
|
|
if (obj instanceof Integer) {
|
|
|
|
c.setWidth((Integer)obj);
|
|
|
|
}
|
|
|
|
// get KEY
|
|
|
|
}
|
|
|
|
if (c.getHelpId()==null) {
|
|
|
|
c.setHelpId(vap.getVascHelpId(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
|
|
|
}
|
|
|
|
if (c.getVascColumnValue()==null) {
|
|
|
|
c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty()));
|
|
|
|
}
|
2007-04-29 18:16:20 +00:00
|
|
|
if (c.getVascColumnEditor()==null) {
|
|
|
|
//c.setVascColumnEditor(new AutoVascColumnEditor(column.getBeanProperty()));
|
|
|
|
}
|
2007-04-28 15:59:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see com.idcanet.vasc.core.VascTableController#finalizeVascTable(com.idcanet.vasc.core.VascTable)
|
|
|
|
*/
|
|
|
|
public void finalizeVascTable(VascTable table) throws Exception {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see com.idcanet.vasc.core.VascTableController#getTotalColumnsWidth(com.idcanet.vasc.core.VascTable)
|
|
|
|
*/
|
|
|
|
public Integer getTotalColumnsWidth(VascTable table) {
|
|
|
|
int result = 0;
|
|
|
|
for(VascTableColumn c:table.getTableColumns()) {
|
|
|
|
if(c.getWidth()==null) {
|
|
|
|
Logger.getLogger(VascTable.class.getName()).finer("Column no size: "+c.getName());
|
2007-04-29 18:16:20 +00:00
|
|
|
} else {
|
|
|
|
result+=c.getWidth();
|
2007-04-28 15:59:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see com.idcanet.vasc.core.VascTableController#refreshData()
|
|
|
|
*/
|
|
|
|
public void refreshData(VascTable table) throws Exception {
|
|
|
|
table.setTableData(table.getVascDataSource().executeQuery(table.getQuery()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void handleException(Exception e,VascTable table) {
|
|
|
|
Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,e.getMessage(),e);
|
|
|
|
}
|
|
|
|
}
|