From 48fbf1d48d2b2bae7d0d68c8e9186b3012e8a1e5 Mon Sep 17 00:00:00 2001 From: willemc Date: Wed, 15 Aug 2007 22:47:38 +0200 Subject: [PATCH] [svn r271] removed small bug --- .../impl/swing/SwingVascViewRenderer.java | 42 +++++++++---------- .../idcanet/vasc/impl/swing/ui/SwingList.java | 10 +++-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java index 0920c6d..89292e7 100644 --- a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java +++ b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java @@ -177,7 +177,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { private Object result = null; private Object bean = null; - public SwingEditDialog(JComponent parent,VascTable table,Object bean,String title,String headerText) { + public SwingEditDialog(JComponent parent,VascTable table,Object bean,String title,String headerText) throws Exception { super(); this.headerText = headerText; this.title = title; @@ -230,7 +230,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { header.add(l); } - public void createBody(JPanel body) { + public void createBody(JPanel body) throws Exception { body.setLayout(new SpringLayout()); for(VascTableColumn c:table.getTableColumns()) { JLabel l = new JLabel(); @@ -242,27 +242,23 @@ public class SwingVascViewRenderer implements VascViewRenderer { } body.add(l); - try { - table.getVascTableController().initEditObjectColumn(c, bean); - - 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)); - model.addListener(new VascColumnValueModelListener(c,bean)); - comp.createComponent(table, model, body); - c.setColumnEditor(comp); - } - } catch (Exception e) { - logger.log(Level.WARNING,"Error making column editor: '"+c.getVascColumnValue()+"' error: "+e.getMessage(),e); - } - } + table.getVascTableController().initEditObjectColumn(c, bean); + + 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)); + model.addListener(new VascColumnValueModelListener(c,bean)); + 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); diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingList.java b/src/com/idcanet/vasc/impl/swing/ui/SwingList.java index d5adace..9bdbc2d 100644 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingList.java +++ b/src/com/idcanet/vasc/impl/swing/ui/SwingList.java @@ -58,14 +58,18 @@ public class SwingList extends AbstractVascUIComponent { public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception { VascList l = (VascList)getWrapper(); - final JComboBox def = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray()); + JComboBox def; + if (l.getVascSelectItemModel()==null) { + def = new JComboBox(); + } else { + def = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray()); + } ((JComponent)gui).add(def); def.setRenderer(new MyCellRenderer()); def.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - VascSelectItem i = (VascSelectItem)def.getSelectedItem(); - System.out.println("Setting value: "+i.getLabel()+" value: "+i.getValue()); + VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem(); model.setValue(i.getValue()); } });