diff --git a/src/com/idcanet/vasc/core/column/VascAnnotationTableColumn.java b/src/com/idcanet/vasc/core/column/VascAnnotationTableColumn.java deleted file mode 100644 index 0d778f6..0000000 --- a/src/com/idcanet/vasc/core/column/VascAnnotationTableColumn.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.core.column; - - -/** - * - * @author Willem Cazander - * @version 1.0 Apr 11, 2007 - */ -public class VascAnnotationTableColumn extends VascTableColumn { - - private String beanProperty = null; - - public VascAnnotationTableColumn() { - - } - public VascAnnotationTableColumn(String beanProperty) { - setBeanProperty(beanProperty); - } - - - /** - * @return the beanProperty - */ - public String getBeanProperty() { - return beanProperty; - } - - /** - * @param beanProperty the beanProperty to set - */ - public void setBeanProperty(String beanProperty) { - this.beanProperty = beanProperty; - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/column/VascColumnRenderer.java b/src/com/idcanet/vasc/core/column/VascColumnRenderer.java deleted file mode 100644 index 54c6b9b..0000000 --- a/src/com/idcanet/vasc/core/column/VascColumnRenderer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.core.column; - -/** - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public interface VascColumnRenderer { - - public String rendererColumn(VascTableColumn column,Object record) throws Exception; -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/column/VascColumnValue.java b/src/com/idcanet/vasc/core/column/VascColumnValue.java deleted file mode 100644 index c943733..0000000 --- a/src/com/idcanet/vasc/core/column/VascColumnValue.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.core.column; - -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; - -/** - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public interface VascColumnValue { - - public Object getValue(VascTableColumn column,Object record) throws ElementParameterException,ElementParameterNotFoundException; - - public void setValue(VascTableColumn column,Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException; -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/column/VascTableColumn.java b/src/com/idcanet/vasc/core/column/VascTableColumn.java deleted file mode 100644 index 987a4f8..0000000 --- a/src/com/idcanet/vasc/core/column/VascTableColumn.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * 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.core.column; - -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.ui.VascUIComponent; - -/** - * Defines an VascTableColumn - * - * - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public class VascTableColumn { - - private String name = null; - private String toolTip = null; - private Object defaultValue = null; - private Integer width = null; - private String helpId = null; - private String image = null; - - private VascColumnValue vascColumnValue = null; - private VascColumnRenderer vascColumnRenderer = null; - private VascUIComponent vascUIComponent = null; - - private Object columnEditor = null; - - private VascTable vascTable = null; - - private boolean editDisplay = true; - private boolean editReadonly = false; - private boolean listDisplay = true; - - /** - * @return the defaultValue - */ - public Object getDefaultValue() { - return defaultValue; - } - /** - * @param defaultValue the defaultValue to set - */ - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } - /** - * @return the name - */ - public String getName() { - return name; - } - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - /** - * @return the toolTip - */ - public String getToolTip() { - return toolTip; - } - /** - * @param toolTip the toolTip to set - */ - public void setToolTip(String toolTip) { - this.toolTip = toolTip; - } - /** - * @return the vascColumnEditor - */ - public VascUIComponent getVascUIComponent() { - return vascUIComponent; - } - /** - * @param vascColumnEditor the vascColumnEditor to set - */ - public void setVascUIComponent(VascUIComponent vascUIComponent) { - this.vascUIComponent = vascUIComponent; - } - /** - * @return the vascColumnRenderer - */ - public VascColumnRenderer getVascColumnRenderer() { - return vascColumnRenderer; - } - /** - * @param vascColumnRenderer the vascColumnRenderer to set - */ - public void setVascColumnRenderer(VascColumnRenderer vascColumnRenderer) { - this.vascColumnRenderer = vascColumnRenderer; - } - /** - * @return the vascColumnValue - */ - public VascColumnValue getVascColumnValue() { - return vascColumnValue; - } - /** - * @param vascColumnValue the vascColumnValue to set - */ - public void setVascColumnValue(VascColumnValue vascColumnValue) { - this.vascColumnValue = vascColumnValue; - } - /** - * @return the width - */ - public Integer getWidth() { - return width; - } - /** - * @param width the width to set - */ - public void setWidth(Integer width) { - this.width = width; - } - - /** - * @return the columnEditor - */ - public Object getColumnEditor() { - return columnEditor; - } - - /** - * @param columnEditor the columnEditor to set - */ - public void setColumnEditor(Object columnEditor) { - this.columnEditor = columnEditor; - } - - /** - * @return the helpId - */ - public String getHelpId() { - return helpId; - } - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId) { - this.helpId = helpId; - } - - /** - * @return the image - */ - public String getImage() { - return image; - } - - /** - * @param image the image to set - */ - public void setImage(String image) { - this.image = image; - } - - /** - * @return the vascTable - */ - public VascTable getVascTable() { - return vascTable; - } - - /** - * @param vascTable the vascTable to set - */ - 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; - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnRenderer.java b/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnRenderer.java deleted file mode 100644 index 001f918..0000000 --- a/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnRenderer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.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 class BeanPropertyVascColumnRenderer extends BeanPropertyVascColumnValue implements VascColumnRenderer { - - - 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(); - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnValue.java b/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnValue.java deleted file mode 100644 index e3aeaa8..0000000 --- a/src/com/idcanet/vasc/impl/column/BeanPropertyVascColumnValue.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.column; - -import com.idcanet.vasc.core.column.VascColumnValue; -import com.idcanet.vasc.core.column.VascTableColumn; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; -import com.idcanet.x4o.impl.DefaultElementParameterHelper; - -/** - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public class BeanPropertyVascColumnValue implements VascColumnValue { - - private String property = null; - - private DefaultElementParameterHelper helper = null; - - public BeanPropertyVascColumnValue() { - helper = new DefaultElementParameterHelper(); - } - public BeanPropertyVascColumnValue(String property) { - this(); - setProperty(property); - } - - /** - * @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object) - */ - public Object getValue(VascTableColumn column,Object record) throws ElementParameterException,ElementParameterNotFoundException { - if(getProperty()==null) { - return null; - } - if(getProperty().equals("")) { - return ""; - } - return helper.getParameter(record, getProperty()); - } - - /** - * @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object) - */ - public void setValue(VascTableColumn column, Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException { - if(getProperty()==null) { - return; - } - if(getProperty().equals("")) { - return; - } - helper.setParameter(record, getProperty(),value); - } - - /** - * @return the property - */ - public String getProperty() { - return property; - } - - /** - * @param property the property to set - */ - public void setProperty(String property) { - this.property = property; - } - - -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/column/NullVascColumnValue.java b/src/com/idcanet/vasc/impl/column/NullVascColumnValue.java deleted file mode 100644 index 7e90569..0000000 --- a/src/com/idcanet/vasc/impl/column/NullVascColumnValue.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.column; - -import com.idcanet.vasc.core.column.VascColumnValue; -import com.idcanet.vasc.core.column.VascTableColumn; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; - -/** - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public class NullVascColumnValue implements VascColumnValue { - - /** - * @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object) - */ - public Object getValue(VascTableColumn column, Object record) throws ElementParameterException,ElementParameterNotFoundException { - return null; - } - - /** - * @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object) - */ - public void setValue(VascTableColumn column, Object record, Object value) throws ElementParameterException,ElementParameterNotFoundException { - } - - -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java b/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java deleted file mode 100644 index 9b40b3f..0000000 --- a/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.serv5; - -import java.util.List; - -import org.hibernate.Query; - -import com.idcanet.serv5.services.hibernate3.Hibernate3Factory; -import com.idcanet.vasc.core.AbstractVascDataSource; -import com.idcanet.xtes.xpql.query.QueryParameterValue; - -/** - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public class Serv5HibernateVascDataSource extends AbstractVascDataSource { - - private String session = null; - - private com.idcanet.xtes.xpql.query.Query query = null; - - public Serv5HibernateVascDataSource() { - - } - public Serv5HibernateVascDataSource(String session,com.idcanet.xtes.xpql.query.Query query) { - setSession(session); - setQuery(query); - } - - @SuppressWarnings("unchecked") - public List execute() throws Exception { - try { - Query q = Hibernate3Factory.getSession(getSession()).createQuery(query.toPreparedSQL(query)); - - - List values = query.getOrderQueryParameterValues(); - int i = 0; - for (QueryParameterValue value:values) { - q.setParameter(i,value.getValue()); - i++; - } - List data = q.list(); - //logger.fine("Query returned: "+data.size()+" of: "+crudTable.getQueryName()); - return data; - } finally { - Hibernate3Factory.getSession("flowstats").close(); // close session in threads - } - } - - public void persist(Object object) throws Exception { - try { - Hibernate3Factory.getSession(getSession()).persist(object); - } finally { - Hibernate3Factory.getSession(getSession()).close(); - } - } - - public Object merge(Object object) throws Exception { - try { - return Hibernate3Factory.getSession(getSession()).merge(object); - } finally { - Hibernate3Factory.getSession(getSession()).close(); - } - } - - public void delete(Object object) throws Exception { - try { - Object newObject = Hibernate3Factory.getSession(getSession()).merge(object); - Hibernate3Factory.getSession(getSession()).delete(newObject); - } finally { - Hibernate3Factory.getSession(getSession()).close(); - } - } - - /** - * @return the session - */ - public String getSession() { - return session; - } - - /** - * @param session the session to set - */ - public void setSession(String session) { - this.session = session; - } - - /** - * @return the query - */ - public com.idcanet.xtes.xpql.query.Query getQuery() { - return query; - } - - /** - * @param query the query to set - */ - public void setQuery(com.idcanet.xtes.xpql.query.Query query) { - this.query = query; - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java deleted file mode 100644 index 452b8e7..0000000 --- a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java +++ /dev/null @@ -1,853 +0,0 @@ -/* - * 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.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Font; -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.Spring; -import javax.swing.SpringLayout; -import javax.swing.UIManager; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; - -import com.idcanet.fff.SwingImageHelper; -import com.idcanet.vasc.core.VascDataExporter; -import com.idcanet.vasc.core.VascEventListener; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.VascUserOption; -import com.idcanet.vasc.core.VascViewRenderer; -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.VascColorChooser; -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.SwingColorChooser; -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; - -/** - * - * @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; - } - - - public void initTable(VascTable table) throws Exception { - if (table.getVascViewRenderer()==null) { - table.setVascViewRenderer(this); - } else { - if (table.getVascViewRenderer()!=this) { - throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); - } - } - table.getVascTableController().finalizeVascColumns(table); - table.getVascTableController().finalizeVascTable(table); - 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); - table.putUIComponent(VascColorChooser.class, SwingColorChooser.class); - - this.table=table; - } - - - public ImageIcon getImageIcon(String imageResource) { - /// TODO hack beter - String key = table.getVascTextValue().getTextValue(imageResource); - //logger.fine("KEY======================="+key); - - if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) { - return SwingImageHelper.getImageIcon(key); - } else { - return null; - } - } - - - - /** - * @see com.idcanet.vasc.core.VascViewRenderer#renderEdit(com.idcanet.vasc.core.VascTable, java.lang.Object) - */ - public void renderEdit(Object rowBean) throws Exception { - logger.fine("Rending Edit View"); - rowBean = table.getVascTableController().initEditObject(table, rowBean); - String beanValue = rowBean.toString(); - if (table.getUIIdentifierVascTableColomn()!=null) { - Object vv = table.getUIIdentifierVascTableColomn().getVascColumnValue().getValue(table.getUIIdentifierVascTableColomn(), rowBean); - if (vv==null) { - beanValue=""; - } else { - beanValue=""+vv; - } - if (beanValue.length()>30) { - beanValue=beanValue.substring(0, 30); - } - } - SwingEditDialog dialog = new SwingEditDialog(parent,table,rowBean,table.getVascTextValue().getTextValue("vasc.dialog.edit.title"),table.getVascTextValue().getTextValue("vasc.dialog.edit.message",beanValue)); - Object result = dialog.openDialog(); - logger.finest("OPEN closed : "+result); - if(result==null) { - return; - } - table.getVascTableController().mergeObject(table, result); - } - - public void renderDelete(Object rowBean) throws Exception { - String beanValue = rowBean.toString(); - if (table.getUIIdentifierVascTableColomn()!=null) { - beanValue = ""+table.getUIIdentifierVascTableColomn().getVascColumnValue().getValue(table.getUIIdentifierVascTableColomn(), rowBean); - if (beanValue.length()>30) { - beanValue=beanValue.substring(0, 30); - } - } - int response = JOptionPane.showOptionDialog( - parent // Center in window. - , table.getVascTextValue().getTextValue("vasc.dialog.delete.message",beanValue) // Message - , table.getVascTextValue().getTextValue("vasc.dialog.delete.title") // Title in titlebar - , JOptionPane.YES_NO_OPTION // Option type - , JOptionPane.PLAIN_MESSAGE // messageType - , null // Icon (none) - , null // Button text as above. - , null // Default button's label - ); - if (response==JOptionPane.YES_OPTION) { - table.getVascDataSource().delete(rowBean); - table.getTableData().remove(rowBean); - table.setSelectedObject(null); - table.getVascTableController().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean); - } - } - - - class SwingEditDialog extends JDialog { - - private static final long serialVersionUID = 10L; - private String headerText = null; - private Object result = null; - private Object bean = null; - - public SwingEditDialog(JComponent parent,VascTable table,Object bean,String title,String headerText) throws Exception { - super(); - this.headerText = headerText; - this.bean = bean; - - setTitle(table.getVascTextValue().getTextValue(title)); - setModal(true); - - JPanel pane = new JPanel(); - pane.setLayout(new BorderLayout()); - - JPanel header = new JPanel(); - createHeader(header); - pane.add(header,BorderLayout.NORTH); - - JPanel body = new JPanel(); - createBody(body); - pane.add(body,BorderLayout.CENTER); - - JPanel footer = new JPanel(); - createFooter(footer); - pane.add(footer,BorderLayout.SOUTH); - - add(pane); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - - //Ensure the text field always gets the first focus. - //addComponentListener(new ComponentAdapter() { - // public void componentShown(ComponentEvent ce) { - // textField.requestFocusInWindow(); - // } - /// }); - - pack(); - setLocationRelativeTo(parent); - } - - - public Object openDialog() { - setVisible(true); - return result; - } - - public void createHeader(JPanel header) { - JLabel l = new JLabel(); - l.setText(table.getVascTextValue().getTextValue(headerText)); - l.setFont(new Font(null,Font.BOLD, 14)); - //l.setToolTipText(table.getVascTextValue().getTextValue(headerText)); - header.add(l); - } - - public void createBody(JPanel body) throws Exception { - body.setLayout(new SpringLayout()); - 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); - - l.setText(table.getVascTextValue().getTextValue(c.getName())); - if(c.getToolTip()!=null) { - l.setToolTipText(table.getVascTextValue().getTextValue(c.getToolTip())); - } - body.add(l); - - 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 { - VascUIComponent comp = c.getVascUIComponent(); - VascValueModel model = new VascValueModel(table); - 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, column,2, 6,6, 6,6); - - } - public void createFooter(JPanel footer) { - - JButton saveButton = new JButton(); - saveButton.setIcon(getImageIcon("vasc.dialog.save.image")); - saveButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.save.name")); - saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip")); - saveButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - if(table.getVascTableController().setUIComponentsBeanErrors(table, bean)) { - return; - } - result = bean; - setVisible(false); - } - }); - footer.add(saveButton); - - JButton cancelButton = new JButton(); - cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image")); - cancelButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.name")); - cancelButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.tooltip")); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - result = null; - setVisible(false); - } - }); - footer.add(cancelButton); - } - } - - - - - /** - * @see com.idcanet.vasc.core.VascViewRenderer#renderExport(com.idcanet.vasc.core.VascTable, com.idcanet.vasc.core.VascDataExporter) - */ - public void renderExport(VascDataExporter exporter) throws Exception { - - String fileName = null; - JFileChooser c = new JFileChooser(); - // Demonstrate "Save" dialog: - int rVal = c.showSaveDialog(null); - if (rVal == JFileChooser.APPROVE_OPTION) { - fileName = c.getSelectedFile().getAbsolutePath(); - // filename.setText(c.getSelectedFile().getName()); - //dir.setText(c.getCurrentDirectory().toString()); - } - if (rVal == JFileChooser.CANCEL_OPTION) { - return; - } - - logger.fine("FileName: "+fileName); - if (fileName == null) { - return; - } - OutputStream out = new FileOutputStream(fileName); - try { - exporter.doExport(out, table); - } catch (Exception e) { - table.getVascTableController().handleException(e, table); - } finally { - if (out!=null) { - out.close(); - } - } - } - - - /** - * @see com.idcanet.vasc.core.VascViewRenderer#renderView(com.idcanet.vasc.core.VascTable) - */ - public void renderView() throws Exception { - - JPanel topPanel = new JPanel(); - topPanel.setLayout(new BorderLayout()); - //topPanel.setBackground(Color.PINK); - - JPanel n = new JPanel(); - topPanel.add(n,BorderLayout.NORTH); - renderHeader(n); - - JPanel c = new JPanel(); - c.setLayout(new BorderLayout()); - topPanel.add(c,BorderLayout.CENTER); - renderBody(c); - - JPanel f = new JPanel(); - //f.setBackground(Color.BLUE); - topPanel.add(f,BorderLayout.SOUTH); - renderFooter(f); - - //parent.setBackground(Color.CYAN); - parent.setLayout(new BorderLayout()); - parent.add(topPanel); - } - - private void renderHeader(JComponent parent2) { - - JPanel header = new JPanel(); - header.setLayout(new BorderLayout()); - header.setBackground(Color.WHITE); - header.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - 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))); - if (table.getHeaderToolTip()!=null) { - l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); - } - header.add(l,BorderLayout.WEST); - } - - if(table.getHeaderName()!=null) { - 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)); - if (table.getHeaderToolTip()!=null) { - l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); - } - header.add(l,BorderLayout.CENTER); - } - - JPanel top = new JPanel(); - //top.setBackground(Color.BLUE); - for (GlobalVascAction action:table.getGlobalActions()) { - JButton but = new JButton(); - but.setText(table.getVascTextValue().getTextValue(action.getName())); - but.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); - but.addActionListener(new GlobalActionListener(action)); - but.setIcon(getImageIcon(action.getImage())); - top.add(but); - } - - // create options - JPanel optionPanel = new JPanel(); - //top.setBackground(Color.GREEN); - for(VascUserOption option:table.getUserOptions()) { - option.createUserOptionRenderer(table); - } - - //top.add(header,BorderLayout.NORTH); - parent2.setLayout(new BorderLayout()); - parent2.add(header,BorderLayout.NORTH); - parent2.add(optionPanel,BorderLayout.CENTER); - parent2.add(top,BorderLayout.EAST); - } - - private void renderBody(JComponent parent2) { - - VascColumnModel model = new VascColumnModel(); - table.getVascTableController().addEventListener(model); - JTable jTable = new JTable(); - //TODO: remove this extra model for sorting, AND fixup a real sorting stuff - TableSorter tableSorter = new TableSorter(); - // this regs the listeners for the sorting - tableSorter.setTableHeader(jTable.getTableHeader()); - tableSorter.setTableModel(model); - - - jTable.setModel(tableSorter); - jTable.getTableHeader().setReorderingAllowed(false); - - // remove auto columns :( - int cols = jTable.getColumnModel().getColumnCount(); - for (int i=0;i list = new ArrayList(); - 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) { - return "Error"; - } - } - } -} - -/** - * A 1.4 file that provides utility methods for creating form- or grid-style - * layouts with SpringLayout. These utilities are used by several programs, such - * as SpringBox and SpringCompactGrid. - */ - -class SpringUtilities { - - /** - * Aligns the first rows*cols components of - * parent in a grid. Each component is as big as the maximum - * preferred width and height of the components. The parent is made just big - * enough to fit them all. - * - * @param rows - * number of rows - * @param cols - * number of columns - * @param initialX - * x location to start the grid at - * @param initialY - * y location to start the grid at - * @param xPad - * x padding between cells - * @param yPad - * y padding between cells - */ - public static void makeGrid(Container parent, int rows, int cols, - int initialX, int initialY, int xPad, int yPad) { - SpringLayout layout; - try { - layout = (SpringLayout) parent.getLayout(); - } catch (ClassCastException exc) { - System.err - .println("The first argument to makeGrid must use SpringLayout."); - return; - } - - Spring xPadSpring = Spring.constant(xPad); - Spring yPadSpring = Spring.constant(yPad); - Spring initialXSpring = Spring.constant(initialX); - Spring initialYSpring = Spring.constant(initialY); - int max = rows * cols; - - //Calculate Springs that are the max of the width/height so that all - //cells have the same size. - Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)) - .getWidth(); - Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)) - .getWidth(); - for (int i = 1; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints(parent - .getComponent(i)); - - maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth()); - maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight()); - } - - //Apply the new width/height Spring. This forces all the - //components to have the same size. - for (int i = 0; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints(parent - .getComponent(i)); - - cons.setWidth(maxWidthSpring); - cons.setHeight(maxHeightSpring); - } - - //Then adjust the x/y constraints of all the cells so that they - //are aligned in a grid. - SpringLayout.Constraints lastCons = null; - SpringLayout.Constraints lastRowCons = null; - for (int i = 0; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints(parent - .getComponent(i)); - if (i % cols == 0) { //start of new row - lastRowCons = lastCons; - cons.setX(initialXSpring); - } else { //x position depends on previous component - cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), - xPadSpring)); - } - - if (i / cols == 0) { //first row - cons.setY(initialYSpring); - } else { //y position depends on previous row - cons.setY(Spring.sum(lastRowCons - .getConstraint(SpringLayout.SOUTH), yPadSpring)); - } - lastCons = cons; - } - - //Set the parent's size. - SpringLayout.Constraints pCons = layout.getConstraints(parent); - pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring - .constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH))); - pCons.setConstraint(SpringLayout.EAST, Spring.sum( - Spring.constant(xPad), lastCons - .getConstraint(SpringLayout.EAST))); - } - - /* Used by makeCompactGrid. */ - private static SpringLayout.Constraints getConstraintsForCell(int row, - int col, Container parent, int cols) { - SpringLayout layout = (SpringLayout) parent.getLayout(); - Component c = parent.getComponent(row * cols + col); - return layout.getConstraints(c); - } - - /** - * Aligns the first rows*cols components of - * parent in a grid. Each component in a column is as wide as - * the maximum preferred width of the components in that column; height is - * similarly determined for each row. The parent is made just big enough to - * fit them all. - * - * @param rows - * number of rows - * @param cols - * number of columns - * @param initialX - * x location to start the grid at - * @param initialY - * y location to start the grid at - * @param xPad - * x padding between cells - * @param yPad - * y padding between cells - */ - public static void makeCompactGrid(Container parent, int rows, int cols, - int initialX, int initialY, int xPad, int yPad) { - SpringLayout layout; - try { - layout = (SpringLayout) parent.getLayout(); - } catch (ClassCastException exc) { - System.err - .println("The first argument to makeCompactGrid must use SpringLayout."); - return; - } - - //Align all cells in each column and make them the same width. - Spring x = Spring.constant(initialX); - for (int c = 0; c < cols; c++) { - Spring width = Spring.constant(0); - for (int r = 0; r < rows; r++) { - width = Spring.max(width, getConstraintsForCell(r, c, parent, - cols).getWidth()); - } - for (int r = 0; r < rows; r++) { - SpringLayout.Constraints constraints = getConstraintsForCell(r, - c, parent, cols); - constraints.setX(x); - constraints.setWidth(width); - } - x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad))); - } - - //Align all cells in each row and make them the same height. - Spring y = Spring.constant(initialY); - for (int r = 0; r < rows; r++) { - Spring height = Spring.constant(0); - for (int c = 0; c < cols; c++) { - height = Spring.max(height, getConstraintsForCell(r, c, parent, - cols).getHeight()); - } - for (int c = 0; c < cols; c++) { - SpringLayout.Constraints constraints = getConstraintsForCell(r, - c, parent, cols); - constraints.setY(y); - constraints.setHeight(height); - } - y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad))); - } - - //Set the parent's size. - SpringLayout.Constraints pCons = layout.getConstraints(parent); - pCons.setConstraint(SpringLayout.SOUTH, y); - pCons.setConstraint(SpringLayout.EAST, x); - } -} - diff --git a/src/com/idcanet/vasc/impl/swing/TableSorter.java b/src/com/idcanet/vasc/impl/swing/TableSorter.java deleted file mode 100644 index c671c96..0000000 --- a/src/com/idcanet/vasc/impl/swing/TableSorter.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * - * - * THIS FILE IS FROM: - * http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting - */ - -package com.idcanet.vasc.impl.swing; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.util.List; - -import javax.swing.*; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.table.*; - -/** - * TableSorter is a decorator for TableModels; adding sorting - * functionality to a supplied TableModel. TableSorter does - * not store or copy the data in its TableModel; instead it maintains - * a map from the row indexes of the view to the row indexes of the - * model. As requests are made of the sorter (like getValueAt(row, col)) - * they are passed to the underlying model after the row numbers - * have been translated via the internal mapping array. This way, - * the TableSorter appears to hold another copy of the table - * with the rows in a different order. - *

- * TableSorter registers itself as a listener to the underlying model, - * just as the JTable itself would. Events recieved from the model - * are examined, sometimes manipulated (typically widened), and then - * passed on to the TableSorter's listeners (typically the JTable). - * If a change to the model has invalidated the order of TableSorter's - * rows, a note of this is made and the sorter will resort the - * rows the next time a value is requested. - *

- * When the tableHeader property is set, either by using the - * setTableHeader() method or the two argument constructor, the - * table header may be used as a complete UI for TableSorter. - * The default renderer of the tableHeader is decorated with a renderer - * that indicates the sorting status of each column. In addition, - * a mouse listener is installed with the following behavior: - *

    - *
  • - * Mouse-click: Clears the sorting status of all other columns - * and advances the sorting status of that column through three - * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to - * NOT_SORTED again). - *
  • - * SHIFT-mouse-click: Clears the sorting status of all other columns - * and cycles the sorting status of the column through the same - * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}. - *
  • - * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except - * that the changes to the column do not cancel the statuses of columns - * that are already sorting - giving a way to initiate a compound - * sort. - *
- *

- * This is a long overdue rewrite of a class of the same name that - * first appeared in the swing table demos in 1997. - * - * @author Philip Milne - * @author Brendon McLean - * @author Dan van Enckevort - * @author Parwinder Sekhon - * @version 2.0 02/27/04 - */ -@SuppressWarnings("unchecked") -public class TableSorter extends AbstractTableModel { - - private static final long serialVersionUID = 10L; - protected TableModel tableModel; - - public static final int DESCENDING = -1; - public static final int NOT_SORTED = 0; - public static final int ASCENDING = 1; - - private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED); - - public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() { - public int compare(Object o1, Object o2) { - return ((Comparable) o1).compareTo(o2); - } - }; - public static final Comparator LEXICAL_COMPARATOR = new Comparator() { - public int compare(Object o1, Object o2) { - return o1.toString().compareTo(o2.toString()); - } - }; - - private Row[] viewToModel; - private int[] modelToView; - - private JTableHeader tableHeader; - private MouseListener mouseListener; - private TableModelListener tableModelListener; - private Map columnComparators = new HashMap(); - private List sortingColumns = new ArrayList(); - - public TableSorter() { - this.mouseListener = new MouseHandler(); - this.tableModelListener = new TableModelHandler(); - } - - public TableSorter(TableModel tableModel) { - this(); - setTableModel(tableModel); - } - - public TableSorter(TableModel tableModel, JTableHeader tableHeader) { - this(); - setTableHeader(tableHeader); - setTableModel(tableModel); - } - - private void clearSortingState() { - viewToModel = null; - modelToView = null; - } - - public TableModel getTableModel() { - return tableModel; - } - - public void setTableModel(TableModel tableModel) { - if (this.tableModel != null) { - this.tableModel.removeTableModelListener(tableModelListener); - } - - this.tableModel = tableModel; - if (this.tableModel != null) { - this.tableModel.addTableModelListener(tableModelListener); - } - - clearSortingState(); - fireTableStructureChanged(); - } - - public JTableHeader getTableHeader() { - return tableHeader; - } - - public void setTableHeader(JTableHeader tableHeader) { - if (this.tableHeader != null) { - this.tableHeader.removeMouseListener(mouseListener); - TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer(); - if (defaultRenderer instanceof SortableHeaderRenderer) { - this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer); - } - } - this.tableHeader = tableHeader; - if (this.tableHeader != null) { - this.tableHeader.addMouseListener(mouseListener); - this.tableHeader.setDefaultRenderer( - new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer())); - } - } - - public boolean isSorting() { - return sortingColumns.size() != 0; - } - - private Directive getDirective(int column) { - for (int i = 0; i < sortingColumns.size(); i++) { - Directive directive = (Directive)sortingColumns.get(i); - if (directive.column == column) { - return directive; - } - } - return EMPTY_DIRECTIVE; - } - - public int getSortingStatus(int column) { - return getDirective(column).direction; - } - - private void sortingStatusChanged() { - clearSortingState(); - fireTableDataChanged(); - if (tableHeader != null) { - tableHeader.repaint(); - } - } - - public void setSortingStatus(int column, int status) { - Directive directive = getDirective(column); - if (directive != EMPTY_DIRECTIVE) { - sortingColumns.remove(directive); - } - if (status != NOT_SORTED) { - sortingColumns.add(new Directive(column, status)); - } - sortingStatusChanged(); - } - - protected Icon getHeaderRendererIcon(int column, int size) { - Directive directive = getDirective(column); - if (directive == EMPTY_DIRECTIVE) { - return null; - } - return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive)); - } - - private void cancelSorting() { - sortingColumns.clear(); - sortingStatusChanged(); - } - - public void setColumnComparator(Class type, Comparator comparator) { - if (comparator == null) { - columnComparators.remove(type); - } else { - columnComparators.put(type, comparator); - } - } - - protected Comparator getComparator(int column) { - Class columnType = tableModel.getColumnClass(column); - Comparator comparator = (Comparator) columnComparators.get(columnType); - if (comparator != null) { - return comparator; - } - if (Comparable.class.isAssignableFrom(columnType)) { - return COMPARABLE_COMAPRATOR; - } - return LEXICAL_COMPARATOR; - } - - private Row[] getViewToModel() { - if (viewToModel == null) { - int tableModelRowCount = tableModel.getRowCount(); - viewToModel = new Row[tableModelRowCount]; - for (int row = 0; row < tableModelRowCount; row++) { - viewToModel[row] = new Row(row); - } - - if (isSorting()) { - Arrays.sort(viewToModel); - } - } - return viewToModel; - } - - public int modelIndex(int viewIndex) { - return getViewToModel()[viewIndex].modelIndex; - } - - private int[] getModelToView() { - if (modelToView == null) { - int n = getViewToModel().length; - modelToView = new int[n]; - for (int i = 0; i < n; i++) { - modelToView[modelIndex(i)] = i; - } - } - return modelToView; - } - - // TableModel interface methods - - public int getRowCount() { - return (tableModel == null) ? 0 : tableModel.getRowCount(); - } - - public int getColumnCount() { - return (tableModel == null) ? 0 : tableModel.getColumnCount(); - } - - public String getColumnName(int column) { - return tableModel.getColumnName(column); - } - - public Class getColumnClass(int column) { - return tableModel.getColumnClass(column); - } - - public boolean isCellEditable(int row, int column) { - return tableModel.isCellEditable(modelIndex(row), column); - } - - public Object getValueAt(int row, int column) { - return tableModel.getValueAt(modelIndex(row), column); - } - - public void setValueAt(Object aValue, int row, int column) { - tableModel.setValueAt(aValue, modelIndex(row), column); - } - - // Helper classes - - private class Row implements Comparable { - private int modelIndex; - - public Row(int index) { - this.modelIndex = index; - } - - public int compareTo(Object o) { - int row1 = modelIndex; - int row2 = ((Row) o).modelIndex; - - for (Iterator it = sortingColumns.iterator(); it.hasNext();) { - Directive directive = (Directive) it.next(); - int column = directive.column; - Object o1 = tableModel.getValueAt(row1, column); - Object o2 = tableModel.getValueAt(row2, column); - - int comparison = 0; - // Define null less than everything, except null. - if (o1 == null && o2 == null) { - comparison = 0; - } else if (o1 == null) { - comparison = -1; - } else if (o2 == null) { - comparison = 1; - } else { - comparison = getComparator(column).compare(o1, o2); - } - if (comparison != 0) { - return directive.direction == DESCENDING ? -comparison : comparison; - } - } - return 0; - } - } - - private class TableModelHandler implements TableModelListener { - public void tableChanged(TableModelEvent e) { - // If we're not sorting by anything, just pass the event along. - if (!isSorting()) { - clearSortingState(); - fireTableChanged(e); - return; - } - - // If the table structure has changed, cancel the sorting; the - // sorting columns may have been either moved or deleted from - // the model. - if (e.getFirstRow() == TableModelEvent.HEADER_ROW) { - cancelSorting(); - fireTableChanged(e); - return; - } - - // We can map a cell event through to the view without widening - // when the following conditions apply: - // - // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, - // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and, - // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and, - // d) a reverse lookup will not trigger a sort (modelToView != null) - // - // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS. - // - // The last check, for (modelToView != null) is to see if modelToView - // is already allocated. If we don't do this check; sorting can become - // a performance bottleneck for applications where cells - // change rapidly in different parts of the table. If cells - // change alternately in the sorting column and then outside of - // it this class can end up re-sorting on alternate cell updates - - // which can be a performance problem for large tables. The last - // clause avoids this problem. - int column = e.getColumn(); - if (e.getFirstRow() == e.getLastRow() - && column != TableModelEvent.ALL_COLUMNS - && getSortingStatus(column) == NOT_SORTED - && modelToView != null) { - int viewIndex = getModelToView()[e.getFirstRow()]; - fireTableChanged(new TableModelEvent(TableSorter.this, - viewIndex, viewIndex, - column, e.getType())); - return; - } - - // Something has happened to the data that may have invalidated the row order. - clearSortingState(); - fireTableDataChanged(); - return; - } - } - - private class MouseHandler extends MouseAdapter { - public void mouseClicked(MouseEvent e) { - JTableHeader h = (JTableHeader) e.getSource(); - TableColumnModel columnModel = h.getColumnModel(); - int viewColumn = columnModel.getColumnIndexAtX(e.getX()); - int column = columnModel.getColumn(viewColumn).getModelIndex(); - if (column != -1) { - int status = getSortingStatus(column); - if (!e.isControlDown()) { - cancelSorting(); - } - // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or - // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. - status = status + (e.isShiftDown() ? -1 : 1); - status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} - setSortingStatus(column, status); - } - } - } - - private static class Arrow implements Icon { - private boolean descending; - private int size; - private int priority; - - public Arrow(boolean descending, int size, int priority) { - this.descending = descending; - this.size = size; - this.priority = priority; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - Color color = c == null ? Color.GRAY : c.getBackground(); - // In a compound sort, make each succesive triangle 20% - // smaller than the previous one. - int dx = (int)(size/2*Math.pow(0.8, priority)); - int dy = descending ? dx : -dx; - // Align icon (roughly) with font baseline. - y = y + 5*size/6 + (descending ? -dy : 0); - int shift = descending ? 1 : -1; - g.translate(x, y); - - // Right diagonal. - g.setColor(color.darker()); - g.drawLine(dx / 2, dy, 0, 0); - g.drawLine(dx / 2, dy + shift, 0, shift); - - // Left diagonal. - g.setColor(color.brighter()); - g.drawLine(dx / 2, dy, dx, 0); - g.drawLine(dx / 2, dy + shift, dx, shift); - - // Horizontal line. - if (descending) { - g.setColor(color.darker().darker()); - } else { - g.setColor(color.brighter().brighter()); - } - g.drawLine(dx, 0, 0, 0); - - g.setColor(color); - g.translate(-x, -y); - } - - public int getIconWidth() { - return size; - } - - public int getIconHeight() { - return size; - } - } - - private class SortableHeaderRenderer implements TableCellRenderer { - private TableCellRenderer tableCellRenderer; - - public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) { - this.tableCellRenderer = tableCellRenderer; - } - - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) { - Component c = tableCellRenderer.getTableCellRendererComponent(table, - value, isSelected, hasFocus, row, column); - if (c instanceof JLabel) { - JLabel l = (JLabel) c; - l.setHorizontalTextPosition(JLabel.LEFT); - int modelColumn = table.convertColumnIndexToModel(column); - l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize())); - } - return c; - } - } - - private static class Directive { - private int column; - private int direction; - - public Directive(int column, int direction) { - this.column = column; - this.direction = direction; - } - } -} diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingColorChooser.java b/src/com/idcanet/vasc/impl/swing/ui/SwingColorChooser.java deleted file mode 100644 index a107594..0000000 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingColorChooser.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JColorChooser; -import javax.swing.JComponent; - -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.ui.AbstractVascUIComponent; -import com.idcanet.vasc.core.ui.VascColorChooser; -import com.idcanet.vasc.core.ui.VascValueModel; - -/** - * - * - * @author Willem Cazander - * @version 1.0 Nov 25, 2007 - */ -public class SwingColorChooser extends AbstractVascUIComponent { - - private JButton colorButton = null; - private Color orgBackgroundColor = null; - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - - - VascColorChooser org = (VascColorChooser)getWrapper(); - - JButton colorButton = new JButton("Color"); - orgBackgroundColor = colorButton.getBackground(); - ((JComponent)gui).add(colorButton); - colorButton.addActionListener(new SelectActionListener3(model,org.getHexSwingEncoding(),table)); - return colorButton; - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText() - */ - public String getErrorText() { - if (colorButton==null) { - return null; - } - return colorButton.getToolTipText(); - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String) - */ - public void setErrorText(String text) { - if (colorButton==null) { - return; - } - colorButton.setToolTipText(text); - if (text==null) { - colorButton.setBackground(orgBackgroundColor); - } else { - colorButton.setBackground(Color.RED); - } - } -} -class SelectActionListener3 implements ActionListener { - - private VascValueModel model; - private boolean hexEncoding = false; - private VascTable table = null; - public SelectActionListener3(VascValueModel model,boolean hexEncoding,VascTable table) { - this.model=model; - this.hexEncoding=hexEncoding; - this.table=table; - } - - /** - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - if (hexEncoding==false) { - Color cur = (Color)model.getValue(); - if (cur==null) { - cur = Color.YELLOW; - } - Color newColor = JColorChooser.showDialog(null,"Choose a color...",cur); - try { - model.setValue(newColor); - } catch (Exception ee) { - table.getVascTableController().handleException(ee, table); - } - } else { - String cur = (String)model.getValue(); - Color c = Color.YELLOW; - try { - if (cur!=null) { - c = Color.decode(cur); - } - Color newColor = JColorChooser.showDialog(null,"Choose a color...",c); - String newColorString = "#"+Integer.toHexString( newColor.getRGB() & 0x00ffffff ); - model.setValue(newColorString); - } catch (Exception ee) { - table.getVascTableController().handleException(ee, table); - } - } - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java b/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java deleted file mode 100644 index d9cc6df..0000000 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingDate.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.Color; -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 { - - private DatePicker datePicker = null; - private Color orgBackgroundColor = null; - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - datePicker = new DatePicker(); - orgBackgroundColor = datePicker.getBackground(); - datePicker.setDate((Date)model.getValue()); - ((JComponent)gui).add(datePicker); - datePicker.addActionListener(new SelectActionListener2(model,table)); - return datePicker; - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText() - */ - public String getErrorText() { - if (datePicker==null) { - return null; - } - return datePicker.getToolTipText(); - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String) - */ - public void setErrorText(String text) { - if (datePicker==null) { - return; - } - datePicker.setToolTipText(text); - if (text==null) { - datePicker.setBackground(orgBackgroundColor); - } else { - datePicker.setBackground(Color.RED); - } - } -} -class SelectActionListener2 implements ActionListener { - - private VascValueModel model; - private VascTable table = null; - public SelectActionListener2(VascValueModel model,VascTable table) { - this.model=model; - this.table=table; - } - - /** - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - Date value = ((DatePicker)e.getSource()).getDate(); - try { - model.setValue(value); - } catch (Exception ee) { - table.getVascTableController().handleException(ee, table); - } - } -} \ 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 deleted file mode 100644 index ca5d095..0000000 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingList.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.Color; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.ui.AbstractVascUIComponent; -import com.idcanet.vasc.core.ui.VascList; -import com.idcanet.vasc.core.ui.VascSelectItem; -import com.idcanet.vasc.core.ui.VascValueModel; - - -/** - * - * @author Willem Cazander - * @version 1.0 Aug 12, 2007 - */ -public class SwingList extends AbstractVascUIComponent { - - private JComboBox comboBox = null; - private Color orgBackgroundColor = null; - - public Object createComponent(final VascTable table,final VascValueModel model,Object gui) throws Exception { - VascList l = (VascList)getWrapper(); - if (l.getVascSelectItemModel()==null) { - comboBox = new JComboBox(); - } else { - comboBox = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray()); - } - orgBackgroundColor = comboBox.getBackground(); - ((JComponent)gui).add(comboBox); - comboBox.setRenderer(new MyCellRenderer()); - comboBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem(); - try { - model.setValue(i.getValue()); - } catch (Exception ee) { - table.getVascTableController().handleException(ee, table); - } - } - }); - - - // set default !! - if (model.getValue()!=null) { - for (int i=0;i0) { - // else select the top one. - comboBox.setSelectedIndex(0); - } - return comboBox; - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText() - */ - public String getErrorText() { - if (comboBox==null) { - return null; - } - return comboBox.getToolTipText(); - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String) - */ - public void setErrorText(String text) { - if (comboBox==null) { - return; - } - comboBox.setToolTipText(text); - if (text==null) { - comboBox.setBackground(orgBackgroundColor); - } else { - comboBox.setBackground(Color.RED); - } - } -} - -class MyCellRenderer extends JLabel implements ListCellRenderer { - - private static final long serialVersionUID = 10L; - - public MyCellRenderer() { - setOpaque(true); - } - - public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) { - VascSelectItem i = (VascSelectItem)value; - if (i!=null) { - setText(i.getLabel()); - } else { - setText("Error"); - } - return this; - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingTextField.java b/src/com/idcanet/vasc/impl/swing/ui/SwingTextField.java deleted file mode 100644 index b76f03c..0000000 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingTextField.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.Color; - -import javax.swing.JComponent; -import javax.swing.JTextField; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.ui.AbstractVascUIComponent; -import com.idcanet.vasc.core.ui.VascValueModel; - - -/** - * - * @author Willem Cazander - * @version 1.0 Aug 12, 2007 - */ -public class SwingTextField extends AbstractVascUIComponent { - - private JTextField textField = null; - private Color orgBackgroundColor = null; - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - textField = new JTextField(); - orgBackgroundColor = textField.getBackground(); - textField.setText(""+model.getValue()); - ((JComponent)gui).add(textField); - textField.getDocument().addDocumentListener(new TextListener(model,table,this)); - return textField; - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText() - */ - public String getErrorText() { - if (textField==null) { - return null; - } - return textField.getToolTipText(); - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String) - */ - public void setErrorText(String text) { - if (textField==null) { - return; - } - textField.setToolTipText(text); - if (text==null) { - textField.setBackground(orgBackgroundColor); - } else { - textField.setBackground(Color.RED); - } - } -} - -class TextListener implements DocumentListener { - - private VascValueModel model = null; - //private VascTable table = null; - private SwingTextField textField = null; - - public TextListener(VascValueModel model,VascTable table,SwingTextField textField) { - this.model=model; - //this.table=table; - this.textField=textField; - } - - /** - * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) - */ - public void changedUpdate(DocumentEvent e) { - update(e); - } - - /** - * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) - */ - public void insertUpdate(DocumentEvent e) { - update(e); - } - - /** - * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) - */ - public void removeUpdate(DocumentEvent e) { - update(e); - } - - public void update(DocumentEvent event) { - try { - String value = event.getDocument().getText(0, event.getDocument().getLength()); - model.setValue(value); - textField.setErrorText(null); - } catch (Exception ee) { - textField.setErrorText(ee.getLocalizedMessage()); - //table.getVascTableController().handleException(ee, table); - } - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/ui/SwingToggle.java b/src/com/idcanet/vasc/impl/swing/ui/SwingToggle.java deleted file mode 100644 index 3c27653..0000000 --- a/src/com/idcanet/vasc/impl/swing/ui/SwingToggle.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JCheckBox; -import javax.swing.JComponent; - -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.ui.AbstractVascUIComponent; -import com.idcanet.vasc.core.ui.VascValueModel; - - -/** - * - * - * @author Willem Cazander - * @version 1.0 Sep 21, 2007 - */ -public class SwingToggle extends AbstractVascUIComponent { - - private JCheckBox checkBox = null; - private Color orgBackgroundColor = null; - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - checkBox = new JCheckBox(); - orgBackgroundColor = checkBox.getBackground(); - checkBox.setSelected((Boolean)model.getValue()); - ((JComponent)gui).add(checkBox); - checkBox.addActionListener(new SelectActionListener(model,table)); - return checkBox; - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText() - */ - public String getErrorText() { - if (checkBox==null) { - return null; - } - return checkBox.getToolTipText(); - } - - /** - * @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String) - */ - public void setErrorText(String text) { - if (checkBox==null) { - return; - } - checkBox.setToolTipText(text); - if (text==null) { - checkBox.setBackground(orgBackgroundColor); - } else { - checkBox.setBackground(Color.RED); - } - } -} -class SelectActionListener implements ActionListener { - - private VascValueModel model; - private VascTable table = null; - public SelectActionListener(VascValueModel model,VascTable table) { - this.model=model; - this.table=table; - } - - /** - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - boolean value = ((JCheckBox)e.getSource()).isSelected(); - try { - model.setValue(value); - } catch (Exception ee) { - table.getVascTableController().handleException(ee, table); - } - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java b/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java deleted file mode 100644 index a9fd355..0000000 --- a/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java +++ /dev/null @@ -1,717 +0,0 @@ -/* - * 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.swt; - -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; - -import com.idcanet.fff.SwingImageHelper; -import com.idcanet.vasc.core.VascDataExporter; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.VascViewRenderer; -import com.idcanet.vasc.core.actions.GlobalVascAction; -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 SwtVascViewRenderer implements VascViewRenderer { - - private Logger logger = null; - private Composite parent = null; - private VascTable table = null; - - public SwtVascViewRenderer(Composite parent) { - logger = Logger.getLogger(SwtVascViewRenderer.class.getName()); - this.parent=parent; - } - - public void initTable(VascTable table) throws Exception { - if (table.getVascViewRenderer()==null) { - table.setVascViewRenderer(this); - } else { - if (table.getVascViewRenderer()!=this) { - throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); - } - } - table.getVascTableController().finalizeVascColumns(table); - table.getVascTableController().finalizeVascTable(table); - table.getVascTableController().refreshData(table); - this.table=table; - } - - private static final String[] FILTER_NAMES = { - "All Files (*.*)", - "Comma Separated Values Files (*.csv)", - "Microsoft Excel Spreadsheet Files (*.xls)", - }; - /** These filter extensions are used to filter which files are displayed. */ - private static final String[] FILTER_EXTS = { "*.*","*.csv","*.xls" }; - - public void renderExport(VascDataExporter exporter) throws Exception { - FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); - dlg.setFilterNames(FILTER_NAMES); - dlg.setFilterExtensions(FILTER_EXTS); - dlg.setFileName(table.getHeaderName()+".csv"); - String fileName = dlg.open(); - logger.fine("FileName: "+fileName); - if (fileName == null) { - return; - } - OutputStream out = new FileOutputStream(fileName); - try { - exporter.doExport(out, table); - } catch (Exception e) { - //MessageDialog.openError(Display.getCurrent().getActiveShell(),crudTable.i18n("crud.event.export.error.title"),crudTable.i18n("crud.event.export.error.message")); - logger.log(Level.WARNING,"Error: "+e.getMessage(),e); - } finally { - if (out!=null) { - out.close(); - } - } - } - - public void renderEdit(Object object) throws Exception { - - logger.fine("Rending Edit View"); - table.getVascTableController().initEditObject(table, object); - - SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Vasc Edit","Edit"); - Object result = dialog.open(); - if(result==null) { - return; - } - try { - result = table.getVascDataSource().merge(object); - //table.getVascTableController().fireModelUpdateListeners(result); - } finally { - //TODO: or merge into table == faster - table.getVascTableController().refreshData(table); - } - } - - public ImageDescriptor getImageDescriptor(String path) { - try { - path = table.getVascTextValue().getTextValue(path); - - - logger.fine("Loading image: "+path); - ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path); - result = ImageDescriptor.createFromFile(SwingImageHelper.class, path); - if(result==null) { - // try load fff - //result = ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource(path)); - } - if(result==null) { - throw new NullPointerException("Can't load resource: "+path); - } - return result; - } catch (Exception e) { - logger.warning("Could not load image from path: '"+path+"'"); - try { - ImageDescriptor result = null; //ImageDescriptor.createFromURL(SwingImageHelper.class.getClass().getResource("/META-INF/images/silk/png/bomb.png")); - if(result==null) { - throw new NullPointerException("Can't load resource: "+path); - } - return result; - } catch (Exception e2) { - return ImageDescriptor.getMissingImageDescriptor(); // default swt missing image fall back - } - } - } - - public void renderDelete(Object rowBean) throws Exception { - - } - - public class SwtVascEditDialog extends Dialog { - - private Shell shell = null; - //private String headerText = null; - private String title = null; - private Object result = null; - private Object bean = null; - - public SwtVascEditDialog (Shell parent,VascTable table,Object bean,String title,String headerText) { - super (parent, 0); - ///this.headerText = headerText; - this.title = title; - this.bean = bean; - } - public Object open() { - shell = new Shell(getParent(), SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL); - shell.setText(title); - - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - shell.setLayout(layout); - - Composite header = new Composite(shell, SWT.NONE); - GridLayout headerLayout = new GridLayout(); - headerLayout.numColumns = 6; - header.setLayout(headerLayout); - header.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite body = new Composite(shell, SWT.NONE); - GridLayout bodyLayout = new GridLayout(); - bodyLayout.numColumns = 1; - body.setLayout(bodyLayout); - body.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite footer = new Composite(shell, SWT.NONE); - GridLayout footerLayout = new GridLayout(); - footerLayout.numColumns = 6; - footer.setLayout(footerLayout); - footer.setLayoutData(new GridData(SWT.NONE)); - - //createHeader(header); - createBody(body); - //createFooter(footer); - - // should be last - partCreated(); - - shell.pack(); - shell.open(); - - Display display = shell.getDisplay(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - //image.dispose(); - //closeDialog(); - return result; - } - - public void createBody(Composite body) { - body.setLayout(new GridLayout(2, true)); - body.setLayoutData(new GridData(GridData.FILL_BOTH)); - - for(VascTableColumn c:table.getTableColumns()) { - Label l = new Label(body, SWT.WRAP); - l.setText(c.getName()); - - if(c.getToolTip()!=null) { - l.setToolTipText(c.getToolTip()); - } - - - - try { - table.getVascTableController().initEditObjectColumn(c, bean); - - //if(c.getVascColumnEditor()==null) { - Label valueLabel = new Label(body, SWT.WRAP); - valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean)); - c.setColumnEditor(valueLabel); - /* - } else { - c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body)); - } - */ - } catch (Exception e) { - logger.log(Level.WARNING,"Error making column editor: '"+c.getVascColumnValue()+"' error: "+e.getMessage(),e); - } - - if(c.getColumnEditor() instanceof Control) { - Control editor = (Control)c.getColumnEditor(); - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.FILL; - editor.setLayoutData(gridData); - } - } - - // create some spaceing , should replace by seperator - new Label(body, SWT.WRAP); - new Label(body, SWT.WRAP); - - Button saveButton = new Button(body, SWT.NONE); - saveButton.setImage(getImageDescriptor("vasc.dialog.save.image").createImage()); - saveButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.save.name")); - saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip")); - saveButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - //if(hasRecordError()) { - // return; - //} - //result = bean; - shell.dispose(); - } - }); - Button cancelButton = new Button(body, SWT.NONE); - cancelButton.setImage(getImageDescriptor("vasc.dialog.cancel.image").createImage()); - cancelButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.name")); - cancelButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.tooltip")); - cancelButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - result = null; - shell.dispose(); - } - }); - } - } - - public Object defaultColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception { - - Composite body = (Composite)gui; - Text text = new Text(body,SWT.SINGLE); - text.addSelectionListener(new TextListener(column,bean)); - text.setText(""+column.getVascColumnValue().getValue(column, bean)); - return text; - } - - class TextListener extends SelectionAdapter { - - private VascTableColumn column = null; - private Object bean = null; - - public TextListener(VascTableColumn column,Object bean) { - this.column=column; - this.bean=bean; - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - // SHIT it works :) - Object value = e.data; - logger.finer("Setting value: "+value); - try { - column.getVascColumnValue().setValue(column, bean, value); - } catch (Exception ee) { - ee.printStackTrace(); - } - } - } - - public Object defaultColumnRenderer(VascTableColumn column,Object gui) throws Exception { - - return null; - } - - - public void renderView() throws Exception { - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - parent.setLayout(layout); - - Composite header = new Composite(parent, SWT.NONE); - GridLayout headerLayout = new GridLayout(); - headerLayout.numColumns = 6; - header.setLayout(headerLayout); - header.setLayoutData(new GridData(SWT.NONE)); - - Composite body = new Composite(parent, SWT.NONE); - GridLayout bodyLayout = new GridLayout(); - bodyLayout.numColumns = 1; - body.setLayout(bodyLayout); - body.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite footer = new Composite(parent, SWT.NONE); - GridLayout footerLayout = new GridLayout(); - footerLayout.numColumns = 6; - footer.setLayout(footerLayout); - footer.setLayoutData(new GridData(SWT.NONE)); - - createHeader(header); - createBody(body); - createFooter(footer); - - // should be last - partCreated(); - } - - - public void createHeader(Composite header) { - logger.finest("Creating header"); - - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - header.setLayout(layout); - header.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite headerBar = new Composite(header, SWT.NONE); - //GridLayout headerLayout = new GridLayout(); - //headerLayout.numColumns = 1; - headerBar.setLayout(new FillLayout()); - //headerBar.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite headerName = new Composite(header, SWT.NONE); - GridLayout bodyLayout = new GridLayout(); - bodyLayout.numColumns = 1; - headerName.setLayout(bodyLayout); - headerName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //headerName.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite headerOptions = new Composite(header, SWT.NONE); - GridLayout footerLayout = new GridLayout(); - footerLayout.numColumns = 1; - headerOptions.setLayout(footerLayout); - //headerOptions.setLayoutData(new GridData(SWT.NONE)); - headerOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - ToolBar toolBar = new ToolBar(headerBar, SWT.NONE); - for (GlobalVascAction action:table.getGlobalActions()) { - ToolItem item = new ToolItem(toolBar, SWT.PUSH); - item.setText(table.getVascTextValue().getTextValue(action.getName())); - item.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); - if (action.getImage()!=null) { - item.setImage(getImageDescriptor(action.getImage()).createImage()); - } - item.addSelectionListener(new GlobalActionListener(action)); - } - - - Color c = new Color(header.getDisplay(),255,255,255); - headerName.setBackground(c); - if(table.getHeaderName()!=null) { - Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD); - Label l = new Label(headerName, SWT.CENTER); - l.setImage(getImageDescriptor(table.getHeaderImage()).createImage()); - l.setFont(headerFont); - l.setText(table.getVascTextValue().getTextValue(table.getHeaderName())); - l.setBackground(c); - } - - // create options - //for(VascUserOption option:table.getUserOptions()) { - - /* - if(option.getLabelText()!=null) { - Label l = new Label(header,SWT.WRAP); - l.setText(crudTable.i18n(cpo.getLabelText())); - l.setBackground(c); - } - - // create ValueHolder - cpo.setValueHolder(new ValueHolder(null)); - // create control - cpo.setTempObjectPropertyControl(cpo.getPropertyEditor().createPropertyEditor(header,cpo.getValueHolder())); - - cpo.getValueHolder().addPropertyChangeListener(this); - */ - //} - } - class GlobalActionListener extends SelectionAdapter { - - private GlobalVascAction action = null; - - public GlobalActionListener(GlobalVascAction action) { - this.action=action; - } - /** - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent event) { - logger.fine("Global Action"); - try { - action.doGlobalAction(table); - } catch (Exception e) { - table.getVascTableController().handleException(e, table); - } - } - } - - - - - - - - - public void createBody(Composite body) { - logger.finer("Creating body"); - - // Create the table viewer to display the players - final TableViewer tableViewer = new TableViewer(body, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - final Table table2 = tableViewer.getTable(); - table2.setLayoutData(new GridData(GridData.FILL_BOTH)); - table2.setHeaderVisible(true); - table2.setLinesVisible(true); - - table2.addSelectionListener(new SelectionListener() { - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) { - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - Object data = e.item.getData(); - logger.fine("Slecting data: "+data); - table.setSelectedObject(data); - } - - }); - - // Set the content and label providers - tableViewer.setContentProvider(new ListConverterContentProvider()); - tableViewer.setLabelProvider(new DefaultLabelProvider(table)); - //TODO: add renderer support - - //Add sort indicator and sort data when column selected - Listener sortListener = new Listener() { - public void handleEvent(Event e) { - // determine new sort column and direction - TableColumn sortColumn = table2.getSortColumn(); - TableColumn currentColumn = (TableColumn) e.widget; - int dir = table2.getSortDirection(); - if (sortColumn == currentColumn) { - dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; - } else { - table2.setSortColumn(currentColumn); - dir = SWT.UP; - } - // sort the data based on column and direction - //String prop = (String)currentColumn.getData("PROP"); - - //List l = new ArrayList(10); - /* - * //columns[i].setData("PROP",table.getTableColumns().get(i)....); - * - for(int i=0;i