diff --git a/.classpath b/.classpath index fa68597..2d34a80 100644 --- a/.classpath +++ b/.classpath @@ -15,5 +15,6 @@ + diff --git a/lib/microba-0.4.2-bin.jar b/lib/microba-0.4.2-bin.jar new file mode 100644 index 0000000..0d09470 Binary files /dev/null and b/lib/microba-0.4.2-bin.jar differ diff --git a/src/com/idcanet/vasc/core/VascEventListener.java b/src/com/idcanet/vasc/core/VascEventListener.java index 3c5cbfa..da24029 100644 --- a/src/com/idcanet/vasc/core/VascEventListener.java +++ b/src/com/idcanet/vasc/core/VascEventListener.java @@ -34,7 +34,7 @@ package com.idcanet.vasc.core; */ public interface VascEventListener { - public enum VascEventType { DATA_UPDATE,OPTION_UPDATE } + public enum VascEventType { DATA_UPDATE,OPTION_UPDATE,CLOSE_WINDOW } public void vascEvent(VascEventType e,Object o); diff --git a/src/com/idcanet/vasc/impl/DefaultVascTableController.java b/src/com/idcanet/vasc/impl/DefaultVascTableController.java index 862b363..c0eaba2 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascTableController.java +++ b/src/com/idcanet/vasc/impl/DefaultVascTableController.java @@ -27,6 +27,7 @@ package com.idcanet.vasc.impl; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -37,7 +38,9 @@ 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.core.ui.VascDate; import com.idcanet.vasc.core.ui.VascTextField; +import com.idcanet.vasc.core.ui.VascToggle; import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue; /** @@ -91,7 +94,13 @@ public class DefaultVascTableController implements VascTableController { } } if (c.getVascUIComponent()==null) { - c.setVascUIComponent(new VascTextField()); + if (c.getDefaultValue() instanceof Boolean) { + c.setVascUIComponent(new VascToggle()); + } else if (c.getDefaultValue() instanceof Date) { + c.setVascUIComponent(new VascDate()); + } else { + c.setVascUIComponent(new VascTextField()); + } } if (c.getVascColumnRenderer()==null) { //c.setVascColumnRenderer(new DefaultVascColumnRenderer()); diff --git a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java index ff8cfdc..e3992bb 100644 --- a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java +++ b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java @@ -75,12 +75,16 @@ import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.RowVascAction; import com.idcanet.vasc.core.column.VascTableColumn; import com.idcanet.vasc.core.ui.VascColumnValueModelListener; +import com.idcanet.vasc.core.ui.VascDate; import com.idcanet.vasc.core.ui.VascList; import com.idcanet.vasc.core.ui.VascTextField; +import com.idcanet.vasc.core.ui.VascToggle; import com.idcanet.vasc.core.ui.VascUIComponent; import com.idcanet.vasc.core.ui.VascValueModel; +import com.idcanet.vasc.impl.swing.ui.SwingDate; import com.idcanet.vasc.impl.swing.ui.SwingList; import com.idcanet.vasc.impl.swing.ui.SwingTextField; +import com.idcanet.vasc.impl.swing.ui.SwingToggle; /** * @@ -112,7 +116,9 @@ public class SwingVascViewRenderer implements VascViewRenderer { table.getVascTableController().refreshData(table); table.putUIComponent(VascTextField.class, SwingTextField.class); table.putUIComponent(VascList.class, SwingList.class); - + table.putUIComponent(VascToggle.class, SwingToggle.class); + table.putUIComponent(VascDate.class, SwingDate.class); + this.table=table; } diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java b/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java new file mode 100644 index 0000000..8ad232a --- /dev/null +++ b/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java @@ -0,0 +1,71 @@ +/* + * 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.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; + +import javax.swing.JComponent; + +import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.ui.AbstractVascUIComponent; +import com.idcanet.vasc.core.ui.VascValueModel; +import com.michaelbaranov.microba.calendar.DatePicker; + + +/** + * + * + * @author Willem Cazander + * @version 1.0 Sep 21, 2007 + */ +public class SwingDate extends AbstractVascUIComponent { + + public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { + DatePicker def = new DatePicker(); + def.setDate((Date)model.getValue()); + ((JComponent)gui).add(def); + def.addActionListener(new SelectActionListener2(model)); + return def; + } +} +class SelectActionListener2 implements ActionListener { + + private VascValueModel model; + public SelectActionListener2(VascValueModel model) { + this.model=model; + } + + /** + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) { + Date value = ((DatePicker)e.getSource()).getDate(); + model.setValue(value); + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingList.java b/src/com/idcanet/vasc/impl/swing/ui/SwingList.java index e2a13ac..bca7ce1 100644 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingList.java +++ b/src/com/idcanet/vasc/impl/swing/ui/SwingList.java @@ -59,8 +59,7 @@ public class SwingList extends AbstractVascUIComponent { } else { def = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray()); } - ((JComponent)gui).add(def); - + ((JComponent)gui).add(def); def.setRenderer(new MyCellRenderer()); def.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -68,6 +67,21 @@ public class SwingList extends AbstractVascUIComponent { model.setValue(i.getValue()); } }); + + if (model.getValue()==null) { + return def; + } + + // set default !! + for (int i=0;i