2
0
Fork 0

[svn r274] showplanner template views works

This commit is contained in:
willemc 2007-08-20 00:31:21 +02:00
parent 48fbf1d48d
commit e120304436
7 changed files with 141 additions and 46 deletions

View file

@ -184,7 +184,13 @@ public class VascAnnotationParser {
// recursif function: // recursif function:
return getValue(typeClass,annotationType,propRest); 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) { if(result!=null) {
return result; return result;
} }

View file

@ -33,5 +33,5 @@ package com.idcanet.vasc.core.column;
*/ */
public interface VascColumnRenderer { public interface VascColumnRenderer {
public Object createColumnRenderer(VascTableColumn column,Object gui) throws Exception; public String rendererColumn(VascTableColumn column,Object record) throws Exception;
} }

View file

@ -50,11 +50,14 @@ public class VascTableColumn {
private VascColumnRenderer vascColumnRenderer = null; private VascColumnRenderer vascColumnRenderer = null;
private VascUIComponent vascUIComponent = null; private VascUIComponent vascUIComponent = null;
private Object columnRenderer = null;
private Object columnEditor = null; private Object columnEditor = null;
private VascTable vascTable = null; private VascTable vascTable = null;
private boolean editDisplay = true;
private boolean editReadonly = false;
private boolean listDisplay = true;
/** /**
* @return the defaultValue * @return the defaultValue
*/ */
@ -154,20 +157,6 @@ public class VascTableColumn {
this.columnEditor = 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 * @return the helpId
*/ */
@ -209,4 +198,46 @@ public class VascTableColumn {
public void setVascTable(VascTable vascTable) { public void setVascTable(VascTable vascTable) {
this.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;
}
} }

View file

@ -24,14 +24,34 @@
* should not be interpreted as representing official policies, either expressed or implied, of IDCA. * 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 * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @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();
}
} }

View file

@ -37,6 +37,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -51,13 +53,10 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.Spring; import javax.swing.Spring;
import javax.swing.SpringLayout; import javax.swing.SpringLayout;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -232,7 +231,14 @@ public class SwingVascViewRenderer implements VascViewRenderer {
public void createBody(JPanel body) throws Exception { public void createBody(JPanel body) throws Exception {
body.setLayout(new SpringLayout()); body.setLayout(new SpringLayout());
int column = 0;
for(VascTableColumn c:table.getTableColumns()) { for(VascTableColumn c:table.getTableColumns()) {
table.getVascTableController().initEditObjectColumn(c, bean);
if (c.isEditDisplay()==false) {
continue;
}
column++;
JLabel l = new JLabel(); JLabel l = new JLabel();
l.setHorizontalAlignment(JLabel.TRAILING); l.setHorizontalAlignment(JLabel.TRAILING);
@ -242,7 +248,13 @@ public class SwingVascViewRenderer implements VascViewRenderer {
} }
body.add(l); 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) { if(c.getVascUIComponent()==null) {
JLabel valueLabel = new JLabel(); JLabel valueLabel = new JLabel();
@ -250,7 +262,6 @@ public class SwingVascViewRenderer implements VascViewRenderer {
c.setColumnEditor(valueLabel); c.setColumnEditor(valueLabel);
body.add(valueLabel); body.add(valueLabel);
} else { } else {
//c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
VascUIComponent comp = c.getVascUIComponent(); VascUIComponent comp = c.getVascUIComponent();
VascValueModel model = new VascValueModel(); VascValueModel model = new VascValueModel();
model.setValue(c.getVascColumnValue().getValue(c, bean)); model.setValue(c.getVascColumnValue().getValue(c, bean));
@ -260,7 +271,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
} }
} }
//JComponent, rows, cols, initX, initY ,xPad, yPad //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) { public void createFooter(JPanel footer) {
@ -370,10 +381,11 @@ public class SwingVascViewRenderer implements VascViewRenderer {
if(table.getHeaderImage()!=null) { if(table.getHeaderImage()!=null) {
JLabel l = new JLabel(); JLabel l = new JLabel();
// TODO: hack images working // TODO: hack images working
l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(table.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH))); l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(table.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
if (table.getHeaderToolTip()!=null) {
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
}
header.add(l,BorderLayout.WEST); header.add(l,BorderLayout.WEST);
} }
@ -381,7 +393,9 @@ public class SwingVascViewRenderer implements VascViewRenderer {
JLabel l = new JLabel(table.getVascTextValue().getTextValue(table.getHeaderName())); JLabel l = new JLabel(table.getVascTextValue().getTextValue(table.getHeaderName()));
l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
l.setFont(new Font(null,Font.BOLD, 18)); l.setFont(new Font(null,Font.BOLD, 18));
if (table.getHeaderToolTip()!=null) {
l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip()));
}
header.add(l,BorderLayout.CENTER); 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 TableColumn c = jTable.getColumnModel().getColumn(0); // idd, just remove index 0 every time
jTable.removeColumn(c); jTable.removeColumn(c);
} }
jTable.revalidate();
TableCellRenderer renderer = new JComponentTableCellRenderer(); TableCellRenderer renderer = new JComponentTableCellRenderer();
int counter=0; int counter=0;
for(VascTableColumn c:table.getTableColumns()) { for(VascTableColumn c:table.getTableColumns()) {
if (c.isListDisplay()==false) {
continue;
}
TableColumn t = new TableColumn(); TableColumn t = new TableColumn();
t.setPreferredWidth(c.getWidth()); t.setPreferredWidth(c.getWidth());
t.setHeaderValue(c); t.setHeaderValue(c);
@ -548,7 +566,14 @@ public class SwingVascViewRenderer implements VascViewRenderer {
* @see javax.swing.table.TableModel#getColumnCount() * @see javax.swing.table.TableModel#getColumnCount()
*/ */
public int 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,13 +592,23 @@ public class SwingVascViewRenderer implements VascViewRenderer {
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
Object bean = table.getTableData().get(rowIndex); Object bean = table.getTableData().get(rowIndex);
logger.finer("Rending column; "+columnIndex+" bean: "+bean); logger.finer("Rending column; "+columnIndex+" bean: "+bean);
VascTableColumn vtc = table.getTableColumns().get(columnIndex);
if (vtc.getColumnRenderer()!=null) { List<VascTableColumn> list = new ArrayList<VascTableColumn>();
//do iets for(VascTableColumn c:table.getTableColumns()) {
return "RENDER"; if (c.isListDisplay()==false) {
} else { continue;
}
list.add(c);
}
VascTableColumn vtc = list.get(columnIndex);
try { try {
if (vtc.getVascColumnRenderer()!=null) {
return vtc.getVascColumnRenderer().rendererColumn(vtc,bean);
} else {
return ""+vtc.getVascColumnValue().getValue(vtc,bean); return ""+vtc.getVascColumnValue().getValue(vtc,bean);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return "Error"; return "Error";
@ -581,7 +616,6 @@ public class SwingVascViewRenderer implements VascViewRenderer {
} }
} }
} }
}
/** /**
* A 1.4 file that provides utility methods for creating form- or grid-style * A 1.4 file that provides utility methods for creating form- or grid-style

View file

@ -85,7 +85,11 @@ class MyCellRenderer extends JLabel implements ListCellRenderer {
public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) { public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {
VascSelectItem i = (VascSelectItem)value; VascSelectItem i = (VascSelectItem)value;
if (i!=null) {
setText(i.getLabel()); setText(i.getLabel());
} else {
setText("Error");
}
return this; return this;
} }
} }

View file

@ -661,7 +661,7 @@ public class SwtVascViewRenderer implements VascViewRenderer {
*/ */
public String getColumnText(Object bean, int columnNumber) { public String getColumnText(Object bean, int columnNumber) {
VascTableColumn vtc = table.getTableColumns().get(columnNumber); VascTableColumn vtc = table.getTableColumns().get(columnNumber);
if (vtc.getColumnRenderer()==null) { if (vtc.getVascColumnRenderer()==null) {
try { try {
return ""+vtc.getVascColumnValue().getValue(vtc,bean); return ""+vtc.getVascColumnValue().getValue(vtc,bean);
} catch (Exception e) { } catch (Exception e) {