[svn r274] showplanner template views works
This commit is contained in:
parent
48fbf1d48d
commit
e120304436
|
@ -184,7 +184,13 @@ public class VascAnnotationParser {
|
|||
// recursif function:
|
||||
return getValue(typeClass,annotationType,propRest);
|
||||
}
|
||||
result = doAnnotation(method.getAnnotation(annotationType));
|
||||
|
||||
Annotation anno = method.getAnnotation(annotationType);
|
||||
// no annotation == no default
|
||||
if (anno==null && annotationType.equals(VascDefaultValue.class)) {
|
||||
return null;
|
||||
}
|
||||
result = doAnnotation(anno);
|
||||
if(result!=null) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -33,5 +33,5 @@ package com.idcanet.vasc.core.column;
|
|||
*/
|
||||
public interface VascColumnRenderer {
|
||||
|
||||
public Object createColumnRenderer(VascTableColumn column,Object gui) throws Exception;
|
||||
public String rendererColumn(VascTableColumn column,Object record) throws Exception;
|
||||
}
|
|
@ -50,11 +50,14 @@ public class VascTableColumn {
|
|||
private VascColumnRenderer vascColumnRenderer = null;
|
||||
private VascUIComponent vascUIComponent = null;
|
||||
|
||||
private Object columnRenderer = null;
|
||||
private Object columnEditor = null;
|
||||
|
||||
private VascTable vascTable = null;
|
||||
|
||||
private boolean editDisplay = true;
|
||||
private boolean editReadonly = false;
|
||||
private boolean listDisplay = true;
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
|
@ -153,20 +156,6 @@ public class VascTableColumn {
|
|||
public void setColumnEditor(Object columnEditor) {
|
||||
this.columnEditor = columnEditor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the columnRenderer
|
||||
*/
|
||||
public Object getColumnRenderer() {
|
||||
return columnRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnRenderer the columnRenderer to set
|
||||
*/
|
||||
public void setColumnRenderer(Object columnRenderer) {
|
||||
this.columnRenderer = columnRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the helpId
|
||||
|
@ -209,4 +198,46 @@ public class VascTableColumn {
|
|||
public void setVascTable(VascTable vascTable) {
|
||||
this.vascTable = vascTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editDisplay
|
||||
*/
|
||||
public boolean isEditDisplay() {
|
||||
return editDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editDisplay the editDisplay to set
|
||||
*/
|
||||
public void setEditDisplay(boolean editDisplay) {
|
||||
this.editDisplay = editDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editReadonly
|
||||
*/
|
||||
public boolean isEditReadonly() {
|
||||
return editReadonly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editReadonly the editReadonly to set
|
||||
*/
|
||||
public void setEditReadonly(boolean editReadonly) {
|
||||
this.editReadonly = editReadonly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the listDisplay
|
||||
*/
|
||||
public boolean isListDisplay() {
|
||||
return listDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listDisplay the listDisplay to set
|
||||
*/
|
||||
public void setListDisplay(boolean listDisplay) {
|
||||
this.listDisplay = listDisplay;
|
||||
}
|
||||
}
|
|
@ -24,14 +24,34 @@
|
|||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.core.column;
|
||||
package com.idcanet.vasc.impl.column;
|
||||
|
||||
import com.idcanet.vasc.core.column.VascColumnRenderer;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascColumnEditor {
|
||||
public class BeanPropertyVascColumnRenderer extends BeanPropertyVascColumnValue implements VascColumnRenderer {
|
||||
|
||||
|
||||
public Object createColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception;
|
||||
public BeanPropertyVascColumnRenderer() {
|
||||
super();
|
||||
}
|
||||
public BeanPropertyVascColumnRenderer(String property) {
|
||||
super(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.column.VascColumnRenderer#rendererColumn(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
|
||||
*/
|
||||
public String rendererColumn(VascTableColumn column, Object record) throws Exception {
|
||||
Object o = getValue(column,record);
|
||||
if (o==null) {
|
||||
return "";
|
||||
}
|
||||
return o.toString();
|
||||
}
|
||||
}
|
|
@ -37,6 +37,8 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -51,13 +53,10 @@ import javax.swing.JOptionPane;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.Spring;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
@ -232,7 +231,14 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
public void createBody(JPanel body) throws Exception {
|
||||
body.setLayout(new SpringLayout());
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
int column = 0;
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
table.getVascTableController().initEditObjectColumn(c, bean);
|
||||
if (c.isEditDisplay()==false) {
|
||||
continue;
|
||||
}
|
||||
column++;
|
||||
|
||||
JLabel l = new JLabel();
|
||||
l.setHorizontalAlignment(JLabel.TRAILING);
|
||||
|
||||
|
@ -242,15 +248,20 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
}
|
||||
body.add(l);
|
||||
|
||||
table.getVascTableController().initEditObjectColumn(c, bean);
|
||||
|
||||
if (c.isEditReadonly()==true) {
|
||||
JLabel valueLabel = new JLabel();
|
||||
valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean));
|
||||
c.setColumnEditor(valueLabel);
|
||||
body.add(valueLabel);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(c.getVascUIComponent()==null) {
|
||||
JLabel valueLabel = new JLabel();
|
||||
valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean));
|
||||
c.setColumnEditor(valueLabel);
|
||||
body.add(valueLabel);
|
||||
} else {
|
||||
//c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
|
||||
VascUIComponent comp = c.getVascUIComponent();
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(c.getVascColumnValue().getValue(c, bean));
|
||||
|
@ -258,9 +269,9 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
comp.createComponent(table, model, body);
|
||||
c.setColumnEditor(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
//JComponent, rows, cols, initX, initY ,xPad, yPad
|
||||
SpringUtilities.makeCompactGrid(body, table.getTableColumns().size(),2, 6,6, 6,6);
|
||||
SpringUtilities.makeCompactGrid(body, column,2, 6,6, 6,6);
|
||||
|
||||
}
|
||||
public void createFooter(JPanel footer) {
|
||||
|
@ -370,10 +381,11 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
if(table.getHeaderImage()!=null) {
|
||||
JLabel l = new JLabel();
|
||||
|
||||
// TODO: hack images working
|
||||
l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(table.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
|
||||
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
|
||||
if (table.getHeaderToolTip()!=null) {
|
||||
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
|
||||
}
|
||||
header.add(l,BorderLayout.WEST);
|
||||
}
|
||||
|
||||
|
@ -381,7 +393,9 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
JLabel l = new JLabel(table.getVascTextValue().getTextValue(table.getHeaderName()));
|
||||
l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
l.setFont(new Font(null,Font.BOLD, 18));
|
||||
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
|
||||
if (table.getHeaderToolTip()!=null) {
|
||||
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
|
||||
}
|
||||
header.add(l,BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
@ -422,10 +436,14 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
TableColumn c = jTable.getColumnModel().getColumn(0); // idd, just remove index 0 every time
|
||||
jTable.removeColumn(c);
|
||||
}
|
||||
jTable.revalidate();
|
||||
|
||||
TableCellRenderer renderer = new JComponentTableCellRenderer();
|
||||
int counter=0;
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
if (c.isListDisplay()==false) {
|
||||
continue;
|
||||
}
|
||||
TableColumn t = new TableColumn();
|
||||
t.setPreferredWidth(c.getWidth());
|
||||
t.setHeaderValue(c);
|
||||
|
@ -548,7 +566,14 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
* @see javax.swing.table.TableModel#getColumnCount()
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return table.getTableColumns().size();
|
||||
int result = 0;
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
if (c.isListDisplay()==false) {
|
||||
continue;
|
||||
}
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -567,17 +592,26 @@ public class SwingVascViewRenderer implements VascViewRenderer {
|
|||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object bean = table.getTableData().get(rowIndex);
|
||||
logger.finer("Rending column; "+columnIndex+" bean: "+bean);
|
||||
VascTableColumn vtc = table.getTableColumns().get(columnIndex);
|
||||
if (vtc.getColumnRenderer()!=null) {
|
||||
//do iets
|
||||
return "RENDER";
|
||||
} else {
|
||||
try {
|
||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "Error";
|
||||
|
||||
List<VascTableColumn> list = new ArrayList<VascTableColumn>();
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
if (c.isListDisplay()==false) {
|
||||
continue;
|
||||
|
||||
}
|
||||
list.add(c);
|
||||
}
|
||||
|
||||
VascTableColumn vtc = list.get(columnIndex);
|
||||
try {
|
||||
if (vtc.getVascColumnRenderer()!=null) {
|
||||
return vtc.getVascColumnRenderer().rendererColumn(vtc,bean);
|
||||
} else {
|
||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ import com.idcanet.vasc.core.ui.VascValueModel;
|
|||
public class SwingList extends AbstractVascUIComponent {
|
||||
|
||||
public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception {
|
||||
|
||||
|
||||
VascList l = (VascList)getWrapper();
|
||||
JComboBox def;
|
||||
if (l.getVascSelectItemModel()==null) {
|
||||
|
@ -85,7 +85,11 @@ class MyCellRenderer extends JLabel implements ListCellRenderer {
|
|||
|
||||
public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {
|
||||
VascSelectItem i = (VascSelectItem)value;
|
||||
setText(i.getLabel());
|
||||
if (i!=null) {
|
||||
setText(i.getLabel());
|
||||
} else {
|
||||
setText("Error");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -661,7 +661,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
*/
|
||||
public String getColumnText(Object bean, int columnNumber) {
|
||||
VascTableColumn vtc = table.getTableColumns().get(columnNumber);
|
||||
if (vtc.getColumnRenderer()==null) {
|
||||
if (vtc.getVascColumnRenderer()==null) {
|
||||
try {
|
||||
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue