[svn r236] fixed swt test and added annotations
This commit is contained in:
parent
5e425bd032
commit
54ca574e58
18 changed files with 931 additions and 23 deletions
143
src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java
Normal file
143
src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* 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.swing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.VascUserOption;
|
||||
import com.idcanet.vasc.core.VascViewRenderer;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascViewRenderer implements VascViewRenderer {
|
||||
|
||||
private Logger logger = null;
|
||||
private JComponent parent = null;
|
||||
private VascTable table = null;
|
||||
|
||||
public SwingVascViewRenderer(JComponent parent) {
|
||||
logger = Logger.getLogger(SwingVascViewRenderer.class.getName());
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascViewRenderer#renderView(com.idcanet.vasc.core.VascTable)
|
||||
*/
|
||||
public void renderView(VascTable table) {
|
||||
this.table=table;
|
||||
try {
|
||||
table.setTableData(table.getVascDataSource().executeQuery(table.getQuery()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
JPanel topPanel = new JPanel();
|
||||
renderHeader(topPanel);
|
||||
renderBody(topPanel);
|
||||
renderFooter(topPanel);
|
||||
parent.add(topPanel);
|
||||
}
|
||||
|
||||
private void renderHeader(JComponent parent2) {
|
||||
}
|
||||
|
||||
private void renderBody(JComponent parent2) {
|
||||
JTable jTable = new JTable(new VascColumnModel());
|
||||
|
||||
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
VascJTableColumn t = new VascJTableColumn();
|
||||
t.setPreferredWidth(c.getWidth());
|
||||
t.setHeaderValue(c.getName());
|
||||
|
||||
jTable.addColumn(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(jTable);
|
||||
parent2.add(scrollPane);
|
||||
}
|
||||
private void renderFooter(JComponent parent2) {
|
||||
|
||||
}
|
||||
class VascJTableColumn extends TableColumn {
|
||||
|
||||
}
|
||||
|
||||
class VascColumnModel extends AbstractTableModel {
|
||||
|
||||
/**
|
||||
* @see javax.swing.table.TableModel#getColumnCount()
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return table.getTableColumns().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.table.TableModel#getRowCount()
|
||||
*/
|
||||
public int getRowCount() {
|
||||
if (table.getTableData()==null) {
|
||||
return 0;
|
||||
}
|
||||
return table.getTableData().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
||||
*/
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object bean = table.getTableData().get(rowIndex);
|
||||
System.out.println("Rending column; "+columnIndex+" bean: "+bean);
|
||||
VascTableColumn vtc = table.getTableColumns().get(columnIndex);
|
||||
if (vtc.getColumnRenderer()!=null) {
|
||||
//do iets
|
||||
return "RENDER";
|
||||
} else {
|
||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue