From 435a26f4d633ae292207b359967eb91db30a0999 Mon Sep 17 00:00:00 2001 From: willemc Date: Mon, 8 Sep 2008 02:07:46 +0200 Subject: [PATCH] [svn r340] WIP commit --- .classpath | 3 + src/META-INF/vasc-fields.xml | 143 +++ .../idcanet/vasc/annotations/VascAdmin.java | 52 ++ .../annotations/VascAnnotationParser.java | 12 +- .../idcanet/vasc/annotations/VascChoices.java | 50 + .../vasc/annotations/VascColumnWidth.java | 2 +- .../vasc/annotations/VascDefaultValue.java | 10 +- ...{VascToolTip.java => VascDescription.java} | 2 +- .../vasc/annotations/VascDisplayName.java | 53 ++ .../vasc/annotations/VascEditorType.java | 54 ++ .../vasc/annotations/VascEventChannel.java | 57 ++ .../vasc/annotations/VascFieldOptions.java | 56 ++ .../vasc/annotations/VascModelReference.java | 2 + .../vasc/annotations/VascPrimaryKey.java | 45 + .../vasc/annotations/VascUserRoles.java | 59 ++ .../backends/jdbc/JdbcConnectionProvider.java | 40 + .../jdbc/JdbcVascBackend.java} | 55 +- .../backends/jdbc/JdbcXpqlVascBackend.java | 116 +++ .../jpa/AbstractHibernateVascBackend.java | 79 ++ .../jpa/AbstractPersistenceVascBackend.java | 79 ++ .../jpa/Serv5XpqlHibernateVascBackend.java | 119 +++ .../backends/ldap/LdapConnectionProvider.java | 39 + .../vasc/backends/ldap/LdapVascBackend.java | 133 +++ .../ldap/SimpleLdapConnectionProvider.java | 153 ++++ .../vasc/core/AbstractVascBackend.java | 192 ++++ .../vasc/core/AbstractVascDataSource.java | 57 -- src/com/idcanet/vasc/core/VascBackend.java | 109 +++ ...Option.java => VascBackendController.java} | 7 +- .../core/VascBackendControllerResolver.java | 38 + src/com/idcanet/vasc/core/VascEntry.java | 363 ++++++++ ...dCreator.java => VascEntryController.java} | 8 +- .../core/VascEntryControllerResolver.java | 38 + src/com/idcanet/vasc/core/VascEntryField.java | 313 +++++++ .../idcanet/vasc/core/VascEntryFieldSet.java | 147 +++ .../idcanet/vasc/core/VascEntryFieldType.java | 68 ++ ...ascViewRenderer.java => VascFrontend.java} | 12 +- .../vasc/core/VascFrontendController.java | 40 + .../core/VascFrontendControllerResolver.java | 38 + ...java => VascFrontendExceptionHandler.java} | 4 +- ...ontroller.java => VascFrontendHelper.java} | 33 +- ...scDataExporter.java => VascLinkEntry.java} | 10 +- src/com/idcanet/vasc/core/VascTable.java | 344 ------- .../vasc/core/actions/ColumnVascAction.java | 6 +- .../vasc/core/actions/GlobalVascAction.java | 4 +- .../vasc/core/actions/RowVascAction.java | 4 +- .../idcanet/vasc/core/actions/VascAction.java | 21 +- .../VascEntryEventListener.java} | 4 +- .../vasc/core/entry/VascEntryExporter.java | 47 + .../entry/VascEntryFieldEventChannel.java | 41 + .../VascEntryFieldValue.java} | 21 +- .../core/entry/VascEntryRecordCreator.java | 42 + .../VascEntryResourceResolver.java} | 4 +- .../vasc/core/ui/AbstractVascUIComponent.java | 4 +- .../core/ui/VascColumnValueModelListener.java | 13 +- src/com/idcanet/vasc/core/ui/VascList.java | 6 +- src/com/idcanet/vasc/core/ui/VascToggle.java | 42 - .../idcanet/vasc/core/ui/VascUIComponent.java | 4 +- .../core/ui/VascUIComponentImplLoader.java | 12 +- .../idcanet/vasc/core/ui/VascValueModel.java | 4 +- .../frontends/swing/SwingVascFrontend.java | 857 ++++++++++++++++++ .../vasc/frontends/swing/TableSorter.java | 492 ++++++++++ .../frontends/swing/ui/SwingColorChooser.java | 131 +++ .../vasc/frontends/swing/ui/SwingDate.java | 107 +++ .../vasc/frontends/swing/ui/SwingList.java | 140 +++ .../frontends/swing/ui/SwingTextField.java | 129 +++ .../vasc/frontends/swing/ui/SwingToggle.java | 106 +++ .../vasc/frontends/swt/SwtVascFrontend.java | 714 +++++++++++++++ .../idcanet/vasc/impl/DefaultVascEntry.java | 568 ++++++++++++ .../vasc/impl/DefaultVascEntryField.java | 475 ++++++++++ .../vasc/impl/DefaultVascEntryFieldSet.java | 201 ++++ .../vasc/impl/actions/AddRowAction.java | 6 +- .../impl/actions/CSVExportGlobalAction.java | 30 +- .../vasc/impl/actions/DeleteRowAction.java | 6 +- .../vasc/impl/actions/EditRowAction.java | 6 +- .../impl/actions/RefreshDataGlobalAction.java | 6 +- .../impl/actions/XMLExportGlobalAction.java | 28 +- .../BeanPropertyVascEntryFieldValue.java | 95 ++ .../BeanVascEntryRecordCreator.java} | 14 +- .../DefaultVascEntryResourceResolver.java} | 6 +- .../vasc/validators/VascDateFuture.java | 45 + .../VascDateFutureValidator.java} | 21 +- .../idcanet/vasc/validators/VascDatePast.java | 46 + .../validators/VascDatePastValidator.java | 43 + .../idcanet/vasc/validators/VascIntSize.java | 56 ++ .../vasc/validators/VascIntSizeValidator.java | 43 + .../idcanet/vasc/validators/VascLongSize.java | 56 ++ .../validators/VascLongSizeValidator.java | 43 + .../vasc/validators/VascObjectNotNull.java | 46 + .../VascObjectNotNullValidator.java | 43 + .../vasc/validators/VascObjectNull.java | 46 + .../validators/VascObjectNullValidator.java | 43 + .../vasc/validators/VascStringEmail.java | 46 + .../validators/VascStringEmailValidator.java | 43 + .../vasc/validators/VascStringLength.java | 56 ++ .../validators/VascStringLengthValidator.java | 43 + .../vasc/validators/VascStringRegex.java | 50 + .../validators/VascStringRegexValidator.java | 43 + .../vasc/validators/VascStringZipCode.java | 46 + .../VascStringZipCodeValidator.java | 43 + .../vasc/validators/VascValidator.java | 39 + .../validators/VascValidatorException.java | 39 + .../VascValidatorField.java} | 21 +- tests/com/idcanet/vasc/SwingTest.java | 14 +- .../idcanet/vasc/TestModelVascDataSource.java | 16 +- tests/com/idcanet/vasc/TestTable.java | 106 +-- tests/com/idcanet/vasc/VascI18nTextValue.java | 5 +- tests/com/idcanet/vasc/models/TestModel.java | 10 +- tests/resources/vasc/tables.xml | 224 +++++ 108 files changed, 8325 insertions(+), 680 deletions(-) create mode 100644 src/META-INF/vasc-fields.xml create mode 100644 src/com/idcanet/vasc/annotations/VascAdmin.java create mode 100644 src/com/idcanet/vasc/annotations/VascChoices.java rename src/com/idcanet/vasc/annotations/{VascToolTip.java => VascDescription.java} (98%) create mode 100644 src/com/idcanet/vasc/annotations/VascDisplayName.java create mode 100644 src/com/idcanet/vasc/annotations/VascEditorType.java create mode 100644 src/com/idcanet/vasc/annotations/VascEventChannel.java create mode 100644 src/com/idcanet/vasc/annotations/VascFieldOptions.java create mode 100644 src/com/idcanet/vasc/annotations/VascPrimaryKey.java create mode 100644 src/com/idcanet/vasc/annotations/VascUserRoles.java create mode 100644 src/com/idcanet/vasc/backends/jdbc/JdbcConnectionProvider.java rename src/com/idcanet/vasc/{core/ui/VascColorChooser.java => backends/jdbc/JdbcVascBackend.java} (58%) create mode 100644 src/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java create mode 100644 src/com/idcanet/vasc/backends/jpa/AbstractHibernateVascBackend.java create mode 100644 src/com/idcanet/vasc/backends/jpa/AbstractPersistenceVascBackend.java create mode 100644 src/com/idcanet/vasc/backends/jpa/Serv5XpqlHibernateVascBackend.java create mode 100644 src/com/idcanet/vasc/backends/ldap/LdapConnectionProvider.java create mode 100644 src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java create mode 100644 src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java create mode 100644 src/com/idcanet/vasc/core/AbstractVascBackend.java delete mode 100644 src/com/idcanet/vasc/core/AbstractVascDataSource.java create mode 100644 src/com/idcanet/vasc/core/VascBackend.java rename src/com/idcanet/vasc/core/{VascUserOption.java => VascBackendController.java} (92%) create mode 100644 src/com/idcanet/vasc/core/VascBackendControllerResolver.java create mode 100644 src/com/idcanet/vasc/core/VascEntry.java rename src/com/idcanet/vasc/core/{VascRecordCreator.java => VascEntryController.java} (90%) create mode 100644 src/com/idcanet/vasc/core/VascEntryControllerResolver.java create mode 100644 src/com/idcanet/vasc/core/VascEntryField.java create mode 100644 src/com/idcanet/vasc/core/VascEntryFieldSet.java create mode 100644 src/com/idcanet/vasc/core/VascEntryFieldType.java rename src/com/idcanet/vasc/core/{VascViewRenderer.java => VascFrontend.java} (86%) create mode 100644 src/com/idcanet/vasc/core/VascFrontendController.java create mode 100644 src/com/idcanet/vasc/core/VascFrontendControllerResolver.java rename src/com/idcanet/vasc/core/{VascExceptionListener.java => VascFrontendExceptionHandler.java} (91%) rename src/com/idcanet/vasc/core/{VascTableController.java => VascFrontendHelper.java} (62%) rename src/com/idcanet/vasc/core/{VascDataExporter.java => VascLinkEntry.java} (90%) delete mode 100644 src/com/idcanet/vasc/core/VascTable.java rename src/com/idcanet/vasc/core/{VascEventListener.java => entry/VascEntryEventListener.java} (95%) create mode 100644 src/com/idcanet/vasc/core/entry/VascEntryExporter.java create mode 100644 src/com/idcanet/vasc/core/entry/VascEntryFieldEventChannel.java rename src/com/idcanet/vasc/core/{VascDataSource.java => entry/VascEntryFieldValue.java} (76%) create mode 100644 src/com/idcanet/vasc/core/entry/VascEntryRecordCreator.java rename src/com/idcanet/vasc/core/{VascTextValue.java => entry/VascEntryResourceResolver.java} (95%) delete mode 100644 src/com/idcanet/vasc/core/ui/VascToggle.java create mode 100644 src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java create mode 100644 src/com/idcanet/vasc/frontends/swing/TableSorter.java create mode 100644 src/com/idcanet/vasc/frontends/swing/ui/SwingColorChooser.java create mode 100644 src/com/idcanet/vasc/frontends/swing/ui/SwingDate.java create mode 100644 src/com/idcanet/vasc/frontends/swing/ui/SwingList.java create mode 100644 src/com/idcanet/vasc/frontends/swing/ui/SwingTextField.java create mode 100644 src/com/idcanet/vasc/frontends/swing/ui/SwingToggle.java create mode 100644 src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java create mode 100644 src/com/idcanet/vasc/impl/DefaultVascEntry.java create mode 100644 src/com/idcanet/vasc/impl/DefaultVascEntryField.java create mode 100644 src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java create mode 100644 src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java rename src/com/idcanet/vasc/impl/{BeanVascRecordCreator.java => entry/BeanVascEntryRecordCreator.java} (83%) rename src/com/idcanet/vasc/impl/{DefaultVascTextValue.java => entry/DefaultVascEntryResourceResolver.java} (90%) create mode 100644 src/com/idcanet/vasc/validators/VascDateFuture.java rename src/com/idcanet/vasc/{core/ui/VascDate.java => validators/VascDateFutureValidator.java} (80%) create mode 100644 src/com/idcanet/vasc/validators/VascDatePast.java create mode 100644 src/com/idcanet/vasc/validators/VascDatePastValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascIntSize.java create mode 100644 src/com/idcanet/vasc/validators/VascIntSizeValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascLongSize.java create mode 100644 src/com/idcanet/vasc/validators/VascLongSizeValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascObjectNotNull.java create mode 100644 src/com/idcanet/vasc/validators/VascObjectNotNullValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascObjectNull.java create mode 100644 src/com/idcanet/vasc/validators/VascObjectNullValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascStringEmail.java create mode 100644 src/com/idcanet/vasc/validators/VascStringEmailValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascStringLength.java create mode 100644 src/com/idcanet/vasc/validators/VascStringLengthValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascStringRegex.java create mode 100644 src/com/idcanet/vasc/validators/VascStringRegexValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascStringZipCode.java create mode 100644 src/com/idcanet/vasc/validators/VascStringZipCodeValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascValidator.java create mode 100644 src/com/idcanet/vasc/validators/VascValidatorException.java rename src/com/idcanet/vasc/{core/ui/VascTextField.java => validators/VascValidatorField.java} (78%) create mode 100644 tests/resources/vasc/tables.xml diff --git a/.classpath b/.classpath index 2d34a80..4ce1b82 100644 --- a/.classpath +++ b/.classpath @@ -16,5 +16,8 @@ + + + diff --git a/src/META-INF/vasc-fields.xml b/src/META-INF/vasc-fields.xml new file mode 100644 index 0000000..adc9931 --- /dev/null +++ b/src/META-INF/vasc-fields.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascAdmin.java b/src/com/idcanet/vasc/annotations/VascAdmin.java new file mode 100644 index 0000000..dca021b --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascAdmin.java @@ -0,0 +1,52 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Defines the admin interface settings + * + * @author Willem Cazander + * @version 1.0 Aug 18, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface VascAdmin { + + boolean list() default true; + + boolean create() default true; + + boolean update() default true; + + boolean delete() default true; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascAnnotationParser.java b/src/com/idcanet/vasc/annotations/VascAnnotationParser.java index 7f2749d..7daad8b 100644 --- a/src/com/idcanet/vasc/annotations/VascAnnotationParser.java +++ b/src/com/idcanet/vasc/annotations/VascAnnotationParser.java @@ -62,12 +62,12 @@ public class VascAnnotationParser { * @param property The property for the ToolTip * @return The i18n key for an ToolTip */ - public String getVascToolTipKey(Class beanClass,String property) { - return (String)getValue(beanClass,VascToolTip.class,property); + public String getVascDescriptionKey(Class beanClass,String property) { + return (String)getValue(beanClass,VascDescription.class,property); } - public String getVascToolTipKey(Class beanClass) { - return (String)getValue(beanClass,VascToolTip.class,null); + public String getVascDescriptionKey(Class beanClass) { + return (String)getValue(beanClass,VascDescription.class,null); } /** @@ -211,8 +211,8 @@ public class VascAnnotationParser { } return l.key(); } - if (a.equals(VascToolTip.class)) { - VascToolTip t = (VascToolTip)b; + if (a.equals(VascDescription.class)) { + VascDescription t = (VascDescription)b; if("".equals(t.key()) | "null".equals(t.key())) { return null; } diff --git a/src/com/idcanet/vasc/annotations/VascChoices.java b/src/com/idcanet/vasc/annotations/VascChoices.java new file mode 100644 index 0000000..55c8170 --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascChoices.java @@ -0,0 +1,50 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Some choises options + * + * @author Willem Cazander + * @version 1.0 Aug 19, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascChoices { + + String[] choisesKeys(); + + String[] choisesNames(); + + boolean editAsRadio() default true; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascColumnWidth.java b/src/com/idcanet/vasc/annotations/VascColumnWidth.java index a495433..047216e 100644 --- a/src/com/idcanet/vasc/annotations/VascColumnWidth.java +++ b/src/com/idcanet/vasc/annotations/VascColumnWidth.java @@ -39,7 +39,7 @@ import java.lang.annotation.Target; * @version 1.0 Apr 28, 2007 */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD,ElementType.TYPE}) +@Target(ElementType.METHOD) public @interface VascColumnWidth { int width() default 150; diff --git a/src/com/idcanet/vasc/annotations/VascDefaultValue.java b/src/com/idcanet/vasc/annotations/VascDefaultValue.java index bccde37..4830ab0 100644 --- a/src/com/idcanet/vasc/annotations/VascDefaultValue.java +++ b/src/com/idcanet/vasc/annotations/VascDefaultValue.java @@ -39,13 +39,15 @@ import java.lang.annotation.Target; * @version 1.0 Mar 28, 2007 */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD,ElementType.TYPE}) +@Target(ElementType.METHOD) public @interface VascDefaultValue { + String key() default "null"; + + String defaultValue() default "null"; + /** * The defaultValue of the method */ - Class defaultValueClass() default Object.class; - - String defaultValue() default "null"; + //Class defaultValueClass() default Object.class; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascToolTip.java b/src/com/idcanet/vasc/annotations/VascDescription.java similarity index 98% rename from src/com/idcanet/vasc/annotations/VascToolTip.java rename to src/com/idcanet/vasc/annotations/VascDescription.java index cf683a6..ba9e9de 100644 --- a/src/com/idcanet/vasc/annotations/VascToolTip.java +++ b/src/com/idcanet/vasc/annotations/VascDescription.java @@ -40,7 +40,7 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD,ElementType.TYPE}) -public @interface VascToolTip { +public @interface VascDescription { /** * The key of the ToolTip default to "null" diff --git a/src/com/idcanet/vasc/annotations/VascDisplayName.java b/src/com/idcanet/vasc/annotations/VascDisplayName.java new file mode 100644 index 0000000..6bdd008 --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascDisplayName.java @@ -0,0 +1,53 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * The field(s)/method used for displaying the display name in lists/etc. + * + * @author Willem Cazander + * @version 1.0 Aug 18, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascDisplayName { + + /** + * The field or fields which are the display name. + * If used on method then field may be left out. + * + */ + String fields() default "null"; + + String format() default "null"; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascEditorType.java b/src/com/idcanet/vasc/annotations/VascEditorType.java new file mode 100644 index 0000000..d65a1fb --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascEditorType.java @@ -0,0 +1,54 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Specefiecs the editor needed for a field + * + * @author Willem Cazander + * @version 1.0 Aug 15, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascEditorType { + + /** + * The editor of the method/field + */ + String type() default "null"; + + /** + * Hints for the choosen editor + */ + String hints() default "null"; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascEventChannel.java b/src/com/idcanet/vasc/annotations/VascEventChannel.java new file mode 100644 index 0000000..19a7780 --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascEventChannel.java @@ -0,0 +1,57 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Specefiecs the type of events we want to get from vasc. + * + * @author Willem Cazander + * @version 1.0 Aug 15, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascEventChannel { + + /** + * The channel to send to. + */ + String channel() default "null"; + + boolean create() default false; + + boolean update() default false; + + boolean delete() default false; + + boolean listed() default false; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascFieldOptions.java b/src/com/idcanet/vasc/annotations/VascFieldOptions.java new file mode 100644 index 0000000..0bf2716 --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascFieldOptions.java @@ -0,0 +1,56 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Some generic field options + * + * @author Willem Cazander + * @version 1.0 Aug 15, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascFieldOptions { + + /** + * + */ + boolean blank() default false; + + /** + * + */ + String choises() default "null"; // + radio admin + + boolean editable() default true; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascModelReference.java b/src/com/idcanet/vasc/annotations/VascModelReference.java index fe7cbc9..14bcd5f 100644 --- a/src/com/idcanet/vasc/annotations/VascModelReference.java +++ b/src/com/idcanet/vasc/annotations/VascModelReference.java @@ -42,5 +42,7 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface VascModelReference { + boolean editAsRadio() default true; + Class type() default Object.class; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascPrimaryKey.java b/src/com/idcanet/vasc/annotations/VascPrimaryKey.java new file mode 100644 index 0000000..34131fb --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascPrimaryKey.java @@ -0,0 +1,45 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * The field(s)/method used for letting vasc know what the PrimaryKey is so we can load it. + * + * @author Willem Cazander + * @version 1.0 Aug 18, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascPrimaryKey { + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/annotations/VascUserRoles.java b/src/com/idcanet/vasc/annotations/VascUserRoles.java new file mode 100644 index 0000000..f289edc --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascUserRoles.java @@ -0,0 +1,59 @@ +/* + * Copyright 2004-2006 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Specefiecs the roles to view/edit or edit-view only modes + * + * @author Willem Cazander + * @version 1.0 Aug 18, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface VascUserRoles { + + /** + * + */ + String list() default "null"; + + /** + * + */ + String edit() default "null"; + + /** + * + */ + String editViewOnly() default "null"; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/jdbc/JdbcConnectionProvider.java b/src/com/idcanet/vasc/backends/jdbc/JdbcConnectionProvider.java new file mode 100644 index 0000000..8522f32 --- /dev/null +++ b/src/com/idcanet/vasc/backends/jdbc/JdbcConnectionProvider.java @@ -0,0 +1,40 @@ +/* + * 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.backends.jdbc; + +import java.sql.Connection; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public interface JdbcConnectionProvider { + + public Connection getJdbcConnection(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/VascColorChooser.java b/src/com/idcanet/vasc/backends/jdbc/JdbcVascBackend.java similarity index 58% rename from src/com/idcanet/vasc/core/ui/VascColorChooser.java rename to src/com/idcanet/vasc/backends/jdbc/JdbcVascBackend.java index 9952245..f608797 100644 --- a/src/com/idcanet/vasc/core/ui/VascColorChooser.java +++ b/src/com/idcanet/vasc/backends/jdbc/JdbcVascBackend.java @@ -24,38 +24,61 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core.ui; +package com.idcanet.vasc.backends.jdbc; -import com.idcanet.vasc.core.VascTable; +import java.util.List; +import com.idcanet.vasc.core.AbstractVascBackend; /** * * @author Willem Cazander - * @version 1.0 Nov 25, 2007 + * @version 1.0 Sep 5, 2008 */ -public class VascColorChooser extends VascUIComponentImplLoader { +public class JdbcVascBackend extends AbstractVascBackend { + + private JdbcConnectionProvider jdbcConnectionProvider = null; - // TODO: remove this hack with converters - boolean hexSwingEncoding = false; - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - return loadAndCreateComponent(this, table, model, gui); + /** + * @return the JdbcConnectionProvider + */ + public JdbcConnectionProvider getJdbcConnectionProvider() { + return jdbcConnectionProvider; } /** - * @return the hexSwingEncoding + * @param JdbcConnectionProvider the JdbcConnectionProvider to set */ - public boolean getHexSwingEncoding() { - return hexSwingEncoding; + public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) { + this.jdbcConnectionProvider = jdbcConnectionProvider; + } + + + + + /** + * @see com.idcanet.vasc.core.VascBackend#execute() + */ + public List execute() throws Exception { + return null; } /** - * @param hexSwingEncoding the hexSwingEncoding to set + * @see com.idcanet.vasc.core.VascBackend#merge(java.lang.Object) */ - public void setHexSwingEncoding(boolean hexSwingEncoding) { - this.hexSwingEncoding = hexSwingEncoding; + public Object merge(Object object) throws Exception { + return object; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#persist(java.lang.Object) + */ + public void persist(Object object) throws Exception { } - + /** + * @see com.idcanet.vasc.core.VascBackend#delete(java.lang.Object) + */ + public void delete(Object object) throws Exception { + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java b/src/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java new file mode 100644 index 0000000..f28cf08 --- /dev/null +++ b/src/com/idcanet/vasc/backends/jdbc/JdbcXpqlVascBackend.java @@ -0,0 +1,116 @@ +/* + * 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.backends.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.core.AbstractVascBackend; +import com.idcanet.xtes.xpql.query.QueryParameterValue; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class JdbcXpqlVascBackend extends AbstractVascBackend { + + private JdbcConnectionProvider jdbcConnectionProvider = null; + + private com.idcanet.xtes.xpql.query.Query query = null; + + /** + * @return the JdbcConnectionProvider + */ + public JdbcConnectionProvider getJdbcConnectionProvider() { + return jdbcConnectionProvider; + } + + /** + * @param JdbcConnectionProvider the JdbcConnectionProvider to set + */ + public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) { + this.jdbcConnectionProvider = jdbcConnectionProvider; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#execute() + */ + public List execute() throws Exception { + Connection c = getJdbcConnectionProvider().getJdbcConnection(); + try { + PreparedStatement q = c.prepareStatement(query.toPreparedSQL(query)); + + List values = query.getOrderQueryParameterValues(); + int i = 0; + for (QueryParameterValue value:values) { + q.setObject(i,value.getValue()); + i++; + } + q.execute(); + ResultSet rs = q.getResultSet(); + + List data = new ArrayList(100); + do { + Map obj = new HashMap(10); + for (i=0;i execute() throws Exception { + Session s = getHibernateSession(); + try { + Query q = s.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(); + return data; + } finally { + if (s!=null) { + s.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; + } + + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { + return null; + } + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { + return null; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/ldap/LdapConnectionProvider.java b/src/com/idcanet/vasc/backends/ldap/LdapConnectionProvider.java new file mode 100644 index 0000000..a519c76 --- /dev/null +++ b/src/com/idcanet/vasc/backends/ldap/LdapConnectionProvider.java @@ -0,0 +1,39 @@ +/* + * 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.backends.ldap; + +import com.novell.ldap.LDAPConnection; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface LdapConnectionProvider { + + public LDAPConnection getLdapConnection(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java b/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java new file mode 100644 index 0000000..8370b51 --- /dev/null +++ b/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java @@ -0,0 +1,133 @@ +/* + * 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.backends.ldap; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.core.AbstractVascBackend; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.core.entry.VascEntryRecordCreator; +import com.idcanet.x4o.element.ElementParameterException; +import com.idcanet.x4o.element.ElementParameterNotFoundException; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public class LdapVascBackend extends AbstractVascBackend { + + + private LdapConnectionProvider ldapConnectionProvider = null; + + /** + * @return the ldapConnectionProvider + */ + public LdapConnectionProvider getLdapConnectionProvider() { + return ldapConnectionProvider; + } + + /** + * @param ldapConnectionProvider the ldapConnectionProvider to set + */ + public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) { + this.ldapConnectionProvider = ldapConnectionProvider; + } + + + + + /** + * @see com.idcanet.vasc.core.VascBackend#execute() + */ + public List execute() throws Exception { + return null; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#merge(java.lang.Object) + */ + public Object merge(Object object) throws Exception { + return object; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#persist(java.lang.Object) + */ + public void persist(Object object) throws Exception { + } + + /** + * @see com.idcanet.vasc.core.VascBackend#delete(java.lang.Object) + */ + public void delete(Object object) throws Exception { + } + + /** + * @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry) + */ + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { + return new VascEntryRecordCreator() { + + public Class getObjectClass() { + return Map.class; + } + + public Object newRecord(VascEntry entry) throws Exception { + return new HashMap(10); + } + }; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField) + */ + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { + VascEntryFieldValue result = new VascEntryFieldValue() { + /** + * @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object) + */ + public Object getValue(VascEntryField field, Object record) throws ElementParameterException,ElementParameterNotFoundException { + Map map = (Map)record; + return map.get(field.getBackendName()); + } + + /** + * @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object) + */ + public void setValue(VascEntryField field, Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException { + Map map = (Map)record; + map.put(field.getBackendName(), value); + } + }; + return result; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java b/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java new file mode 100644 index 0000000..bade087 --- /dev/null +++ b/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java @@ -0,0 +1,153 @@ +/* + * 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.backends.ldap; + +import java.security.Security; + +import com.novell.ldap.LDAPConnection; +import com.novell.ldap.LDAPJSSESecureSocketFactory; +import com.novell.ldap.LDAPSocketFactory; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public class SimpleLdapConnectionProvider implements LdapConnectionProvider { + + + private String ldapHost = "localhost"; + private int ldapPort = LDAPConnection.DEFAULT_PORT; + private int ldapVersion = LDAPConnection.LDAP_V3; + private String bindUser = null; + private String bindPass = null; + + + /** + * @see com.idcanet.vasc.backends.ldap.LdapConnectionProvider#getLdapConnection() + */ + public LDAPConnection getLdapConnection() { + try { + + // if ssl; + //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + //System.setProperty("javax.net.ssl.trustStore", "/tmp/somewhere/ldap.root.crt"); + //LDAPSocketFactory ssf = new LDAPJSSESecureSocketFactory(); + // Set the socket factory as the default for all future connections + //LDAPConnection.setSocketFactory(ssf); + + LDAPConnection lc = new LDAPConnection(); + lc.connect( ldapHost, ldapPort ); + if (bindUser!=null && bindPass!=null) { + lc.bind( ldapVersion, bindUser, bindPass.getBytes("UTF8") ); + } + return lc; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + /** + * @return the ldapHost + */ + public String getLdapHost() { + return ldapHost; + } + + + /** + * @param ldapHost the ldapHost to set + */ + public void setLdapHost(String ldapHost) { + this.ldapHost = ldapHost; + } + + + /** + * @return the ldapPort + */ + public int getLdapPort() { + return ldapPort; + } + + + /** + * @param ldapPort the ldapPort to set + */ + public void setLdapPort(int ldapPort) { + this.ldapPort = ldapPort; + } + + + /** + * @return the ldapVersion + */ + public int getLdapVersion() { + return ldapVersion; + } + + + /** + * @param ldapVersion the ldapVersion to set + */ + public void setLdapVersion(int ldapVersion) { + this.ldapVersion = ldapVersion; + } + + + /** + * @return the bindUser + */ + public String getBindUser() { + return bindUser; + } + + + /** + * @param bindUser the bindUser to set + */ + public void setBindUser(String bindUser) { + this.bindUser = bindUser; + } + + + /** + * @return the bindPass + */ + public String getBindPass() { + return bindPass; + } + + + /** + * @param bindPass the bindPass to set + */ + public void setBindPass(String bindPass) { + this.bindPass = bindPass; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/AbstractVascBackend.java b/src/com/idcanet/vasc/core/AbstractVascBackend.java new file mode 100644 index 0000000..9af7a21 --- /dev/null +++ b/src/com/idcanet/vasc/core/AbstractVascBackend.java @@ -0,0 +1,192 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * + * @author Willem Cazander + * @version 1.0 Aug 2, 2007 + */ +abstract public class AbstractVascBackend implements VascBackend { + + private String name = null; + protected Map parameters = null; + private int pageIndex = 0; + private int pageSize = 100; + private String sortField = null; + private String searchString = null; + private boolean ascending = true; + + public AbstractVascBackend() { + parameters = new HashMap(10); + } + + public void setDataParameter(String key,Object data) { + parameters.put(key,data); + } + + public Object getDataParameter(String key) { + return parameters.get(key); + } + + public Set getDataParameterKeys() { + return parameters.keySet(); + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getName() + */ + public String getName() { + return name; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setName(java.lang.String) + */ + public void setName(String name) { + if (name==null) { + throw new IllegalArgumentException("name may not be null"); + } + this.name=name; + } + + + /** + * @see com.idcanet.vasc.core.VascBackend#isPageable() + */ + public boolean isPageable() { + return false; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getPageIndex() + */ + public int getPageIndex() { + return pageIndex; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setPageIndex(int) + */ + public void setPageIndex(int pageIndex) { + this.pageIndex=pageIndex; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getPageSize() + */ + public int getPageSize() { + return pageSize; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setPageSize(int) + */ + public void setPageSize(int pageSize) { + this.pageSize=pageSize; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getPagesTotal() + */ + public int getPagesTotal() { + return 0; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getPagesTotalRecords() + */ + public int getPagesTotalRecords() { + return 0; + } + + + + + /** + * @see com.idcanet.vasc.core.VascBackend#isSearchable() + */ + public boolean isSearchable() { + return false; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getSearchString() + */ + public String getSearchString() { + return searchString; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setSearchString(java.lang.String) + */ + public void setSearchString(String searchString) { + this.searchString=searchString; + } + + + + + /** + * @see com.idcanet.vasc.core.VascBackend#isSortable() + */ + public boolean isSortable() { + return false; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#isSortAscending() + */ + public boolean isSortAscending() { + return ascending; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setSortAscending(boolean) + */ + public void setSortAscending(boolean ascending) { + this.ascending=ascending; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#getSortField() + */ + public String getSortField() { + return sortField; + } + + /** + * @see com.idcanet.vasc.core.VascBackend#setSortField(java.lang.String) + */ + public void setSortField(String sortField) { + this.sortField=sortField; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/AbstractVascDataSource.java b/src/com/idcanet/vasc/core/AbstractVascDataSource.java deleted file mode 100644 index 5bfb22b..0000000 --- a/src/com/idcanet/vasc/core/AbstractVascDataSource.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.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * - * @author Willem Cazander - * @version 1.0 Aug 2, 2007 - */ -abstract public class AbstractVascDataSource implements VascDataSource { - - Map parameters = null; - - public AbstractVascDataSource() { - parameters = new HashMap(10); - } - - public void setDataParameter(String key,Object data) { - parameters.put(key,data); - } - - public Object getDataParameter(String key) { - return parameters.get(key); - } - - public Set getDataParameterKeys() { - return parameters.keySet(); - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascBackend.java b/src/com/idcanet/vasc/core/VascBackend.java new file mode 100644 index 0000000..fcae0f4 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascBackend.java @@ -0,0 +1,109 @@ +/* + * 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; + +import java.util.List; +import java.util.Set; + +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.core.entry.VascEntryRecordCreator; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascBackend { + + public String getName(); + public void setName(String name); + + public void setDataParameter(String key,Object data); + public Object getDataParameter(String key); + public Set getDataParameterKeys(); + + public List execute() throws Exception; + + public void persist(Object object) throws Exception; + + public Object merge(Object object) throws Exception; + + public void delete(Object object) throws Exception; + + + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field); + + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry); + + /** + * Defines if the backend supports sorting + * @return + */ + public boolean isSortable(); + public String getSortField(); + public void setSortField(String name); + public boolean isSortAscending(); + public void setSortAscending(boolean ascending); + + + + /** + * Defines if the backend supports pageing + * @return + */ + public boolean isPageable(); + + /** + * Returns the total amount of pages + * @return + */ + public int getPagesTotal(); + + public int getPagesTotalRecords(); + + + public void setPageSize(int size); + public int getPageSize(); + + public void setPageIndex(int index); + public int getPageIndex(); + + + /** + * Defines if the backend supports pageing + * @return + */ + public boolean isSearchable(); + public void setSearchString(String searchString); + public String getSearchString(); + + /* + public boolean hasSettings(); + public Map getSettings(); + public void putSetting(String key,String value); + */ +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascUserOption.java b/src/com/idcanet/vasc/core/VascBackendController.java similarity index 92% rename from src/com/idcanet/vasc/core/VascUserOption.java rename to src/com/idcanet/vasc/core/VascBackendController.java index 7be7fdd..851516d 100644 --- a/src/com/idcanet/vasc/core/VascUserOption.java +++ b/src/com/idcanet/vasc/core/VascBackendController.java @@ -30,10 +30,9 @@ package com.idcanet.vasc.core; /** * * @author Willem Cazander - * @version 1.0 Mar 21, 2007 + * @version 1.0 Sep 4, 2008 */ -public interface VascUserOption { - - public Object createUserOptionRenderer(VascTable table); +public interface VascBackendController { + public VascBackend getVascBackend(String name); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascBackendControllerResolver.java b/src/com/idcanet/vasc/core/VascBackendControllerResolver.java new file mode 100644 index 0000000..d1c4f9e --- /dev/null +++ b/src/com/idcanet/vasc/core/VascBackendControllerResolver.java @@ -0,0 +1,38 @@ +/* + * 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; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface VascBackendControllerResolver { + + public VascBackendController getVascBackendController(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntry.java b/src/com/idcanet/vasc/core/VascEntry.java new file mode 100644 index 0000000..8e3d0b3 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntry.java @@ -0,0 +1,363 @@ +/* + * 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; + +import java.util.List; + +import com.idcanet.vasc.core.actions.ColumnVascAction; +import com.idcanet.vasc.core.actions.GlobalVascAction; +import com.idcanet.vasc.core.actions.RowVascAction; +import com.idcanet.vasc.core.entry.VascEntryResourceResolver; + +/** + * + * TODO: + * private List userOptions = null; + * private List listeners = null; + * private Map vascLinks = null; + * private Map vascFunctions = null; + * + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascEntry { + + /** + * @return the id + */ + public String getId(); + + /** + * @param id the id to set + */ + public void setId(String id); + + /** + * @return the name + */ + public String getName(); + + /** + * @param name the name to set + */ + public void setName(String name); + + /** + * @return the description + */ + public String getDescription(); + + /** + * @param description the description to set + */ + public void setDescription(String description); + + /** + * @return the helpId + */ + public String getHelpId(); + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId); + + /** + * @return the image + */ + public String getImage(); + + /** + * @param image the image to set + */ + public void setImage(String image); + + /** + * @return the headerName + */ + public String getHeaderName(); + + /** + * @param headerName the headerName to set + */ + public void setHeaderName(String headerName); + + /** + * @return the headerImage + */ + public String getHeaderImage(); + + /** + * @param headerImage the headerImage to set + */ + public void setHeaderImage(String headerImage); + + /** + * @return the headerDescription + */ + public String getHeaderDescription(); + + /** + * @param headerDescription the headerDescription to set + */ + public void setHeaderDescription(String headerDescription); + + /** + * @return the primaryKeyField + */ + public String getPrimaryKeyField(); + + /** + * @param primaryKeyField the primaryKeyField to set + */ + public void setPrimaryKeyField(String primaryKeyField); + + /** + * @return the displayNameField + */ + public String getDisplayNameField(); + + /** + * @param displayNameField the displayNameField to set + */ + public void setDisplayNameField(String displayNameField); + + /** + * @return the vascAdmimList + */ + public boolean isVascAdmimList(); + + /** + * @param vascAdmimList the vascAdmimList to set + */ + public void setVascAdmimList(boolean vascAdmimList); + + /** + * @return the vascAdmimEdit + */ + public boolean isVascAdmimEdit(); + + /** + * @param vascAdmimEdit the vascAdmimEdit to set + */ + public void setVascAdmimEdit(boolean vascAdmimEdit); + + /** + * @return the vascAdmimCreate + */ + public boolean isVascAdmimCreate(); + + /** + * @param vascAdmimCreate the vascAdmimCreate to set + */ + public void setVascAdmimCreate(boolean vascAdmimCreate); + + /** + * @return the vascAdmimDelete + */ + public boolean isVascAdmimDelete(); + + /** + * @param vascAdmimDelete the vascAdmimDelete to set + */ + public void setVascAdmimDelete(boolean vascAdmimDelete); + + /** + * @return the vascFields + */ + public List getVascEntryFields(); + + /** + * @param vascField the vascField to add + */ + public void addVascEntryField(VascEntryField vascField); + + /** + * @param vascField the vascField to remove + */ + public void removeVascEntryField(VascEntryField vascField); + + /** + * @return the entryDataList + */ + public List getEntryDataList(); + + /** + * @param entryDataList the entryDataList to set + */ + public void setEntryDataList(List entryDataList); + + /** + * @return the entryDataObject + */ + public Object getEntryDataObject(); + + /** + * @param entryDataObject the entryDataObject to set + */ + public void setEntryDataObject(Object entryDataObject); + + /** + * @return the vascBackend + */ + public VascBackend getVascBackend(); + + /** + * @param vascBackend the vascBackend to set + */ + public void setVascBackend(VascBackend vascBackend); + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend(); + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(VascFrontend vascFrontend); + + /** + * @return the vascBackendController + */ + public VascBackendController getVascBackendController(); + + /** + * @param vascBackendController the vascBackendController to set + */ + public void setVascBackendController(VascBackendController vascBackendController); + + /** + * @return the vascEntryController + */ + public VascEntryController getVascEntryController(); + + /** + * @param vascEntryController the vascEntryController to set + */ + public void setVascEntryController(VascEntryController vascEntryController); + + /** + * @return the vascFrontendController + */ + public VascFrontendController getVascFrontendController(); + + /** + * @param vascFrontendController the vascFrontendController to set + */ + public void setVascFrontendController(VascFrontendController vascFrontendController); + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver(); + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver); + + /** + * @return the rowActions + */ + public List getRowActions(); + + /** + * @param rowAction the rowAction to add + */ + public void addRowAction(RowVascAction rowAction); + + /** + * @param rowAction the rowAction to remove + */ + public void removeRowAction(RowVascAction rowAction); + + /** + * @return the columnActions + */ + public List getColumnActions(); + + /** + * @param columnAction the columnAction to add + */ + public void addColumnAction(ColumnVascAction columnAction); + + /** + * @param columnAction the columnAction to remove + */ + public void removeColumnAction(ColumnVascAction columnAction); + + /** + * @return the globalActions + */ + public List getGlobalActions(); + + /** + * @param globalAction the globalAction to add + */ + public void addGlobalAction(GlobalVascAction globalAction); + + /** + * @param globalAction the globalAction to remove + */ + public void removeGlobalAction(GlobalVascAction globalAction); + + /** + * @return the vascEntryFieldSets + */ + public List getVascEntryFieldSets(); + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void addVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet); + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to remove + */ + public void removeVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet); + + /** + * @return the vascLinkEntries + */ + public List getVascLinkEntries(); + + /** + * @param vascLinkEntry the vascLinkEntry to add + */ + public void addVascLinkEntry(VascLinkEntry vascLinkEntry); + + /** + * @param vascLinkEntry the vascLinkEntry to remover + */ + public void removeVascLinkEntry(VascLinkEntry vascLinkEntry); + + public Object getEntryParameter(String key); + public void setEntryParameter(String key,Object value); + public List getEntryParameterKeys(); +} diff --git a/src/com/idcanet/vasc/core/VascRecordCreator.java b/src/com/idcanet/vasc/core/VascEntryController.java similarity index 90% rename from src/com/idcanet/vasc/core/VascRecordCreator.java rename to src/com/idcanet/vasc/core/VascEntryController.java index afb8083..1da70b8 100644 --- a/src/com/idcanet/vasc/core/VascRecordCreator.java +++ b/src/com/idcanet/vasc/core/VascEntryController.java @@ -30,11 +30,9 @@ package com.idcanet.vasc.core; /** * * @author Willem Cazander - * @version 1.0 Mar 21, 2007 + * @version 1.0 Sep 4, 2008 */ -public interface VascRecordCreator { +public interface VascEntryController { - public Object newRecord(VascTable table) throws Exception; - - public Class getObjectClass(); + public VascEntry getVascEntry(String name); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryControllerResolver.java b/src/com/idcanet/vasc/core/VascEntryControllerResolver.java new file mode 100644 index 0000000..8c00bea --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntryControllerResolver.java @@ -0,0 +1,38 @@ +/* + * 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; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface VascEntryControllerResolver { + + public VascEntryController getVascEntryController(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryField.java b/src/com/idcanet/vasc/core/VascEntryField.java new file mode 100644 index 0000000..fb9f843 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntryField.java @@ -0,0 +1,313 @@ +/* + * 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; + +import java.util.List; + +import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.validators.VascValidator; + +/** + * Defines an VascTableColumn + * + * + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascEntryField { + + public VascEntry getVascEntry(); + + public void setVascEntry(VascEntry entry); + + /** + * @return the id + */ + public String getId(); + + /** + * @param id the id to set + */ + public void setId(String id); + + /** + * @return the vascEntryFieldType + */ + public VascEntryFieldType getVascEntryFieldType(); + + /** + * @param vascEntryFieldType the vascEntryFieldType to set + */ + public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType); + + /** + * @return the backendName + */ + public String getBackendName(); + + /** + * @param backendName the backendName to set + */ + public void setBackendName(String backendName); + + /** + * @return the vascEntryFieldValue + */ + public VascEntryFieldValue getVascEntryFieldValue(); + + /** + * @param vascEntryFieldValue the vascEntryFieldValue to set + */ + public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue); + + /** + * @return the vascEntryFieldEventChannel + */ + public VascEntryFieldEventChannel getVascEntryFieldEventChannel(); + + /** + * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set + */ + public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel); + + /** + * @return the vascValidators + */ + public List getVascValidators(); + + /** + * @param vascValidator the vascValidator to add + */ + public void addVascValidator(VascValidator vascValidator); + + /** + * @param vascValidator the vascValidator to remove + */ + public void removeVascValidator(VascValidator vascValidator); + + /** + * @return the name + */ + public String getName(); + + /** + * @param name the name to set + */ + public void setName(String name); + + /** + * @return the description + */ + public String getDescription(); + + /** + * @param description the description to set + */ + public void setDescription(String description); + + /** + * @return the helpId + */ + public String getHelpId(); + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId); + + /** + * @return the image + */ + public String getImage(); + + /** + * @param image the image to set + */ + public void setImage(String image); + + /** + * @return the defaultValue + */ + public Object getDefaultValue(); + + /** + * @param defaultValue the defaultValue to set + */ + public void setDefaultValue(Object defaultValue); + + /** + * @return the sizeList + */ + public Integer getSizeList(); + + /** + * @param sizeList the sizeList to set + */ + public void setSizeList(Integer sizeList); + + /** + * @return the sizeEdit + */ + public Integer getSizeEdit(); + + /** + * @param sizeEdit the sizeEdit to set + */ + public void setSizeEdit(Integer sizeEdit); + + /** + * @return the styleList + */ + public String getStyleList(); + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList); + + /** + * @return the styleEdit + */ + public String getStyleEdit(); + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit); + + /** + * @return the choices + */ + public String getChoices(); + + /** + * @param choices the choices to set + */ + public void setChoices(String choices); + + /** + * @return the view + */ + public boolean isView(); + + /** + * @param view the view to set + */ + public void setView(boolean view); + + /** + * @return the optional + */ + public boolean isOptional(); + + /** + * @param optional the optional to set + */ + public void setOptional(boolean optional); + + /** + * @return the create + */ + public boolean isCreate(); + + /** + * @param create the create to set + */ + public void setCreate(boolean create); + + /** + * @return the edit + */ + public boolean isEdit(); + + /** + * @param edit the edit to set + */ + public void setEdit(boolean edit); + + /** + * @return the editReadOnly + */ + public boolean isEditReadOnly(); + + /** + * @param editReadOnly the editReadOnly to set + */ + public void setEditReadOnly(boolean editReadOnly); + + /** + * @return the list + */ + public boolean isList(); + + /** + * @param list the list to set + */ + public void setList(boolean list); + + /** + * @return the rolesCreate + */ + public String getRolesCreate(); + + /** + * @param rolesCreate the rolesCreate to set + */ + public void setRolesCreate(String rolesCreate); + + /** + * @return the rolesEdit + */ + public String getRolesEdit(); + + /** + * @param rolesEdit the rolesEdit to set + */ + public void setRolesEdit(String rolesEdit); + + /** + * @return the rolesEditReadOnly + */ + public String getRolesEditReadOnly(); + + /** + * @param rolesEditReadOnly the rolesEditReadOnly to set + */ + public void setRolesEditReadOnly(String rolesEditReadOnly); + + /** + * @return the rolesList + */ + public String getRolesList(); + + /** + * @param rolesList the rolesList to set + */ + public void setRolesList(String rolesList); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryFieldSet.java b/src/com/idcanet/vasc/core/VascEntryFieldSet.java new file mode 100644 index 0000000..9dc146c --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntryFieldSet.java @@ -0,0 +1,147 @@ +/* + * 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; + +import java.util.List; + +/** + * Orgenisess Fields + * + * + * + * @author Willem Cazander + * @version 1.0 Sep 56, 2008 + */ +public interface VascEntryFieldSet { + + /** + * @return the id + */ + public String getId(); + + /** + * @param id the id to set + */ + public void setId(String id); + + /** + * @return the name + */ + public String getName(); + + /** + * @param name the name to set + */ + public void setName(String name); + + /** + * @return the description + */ + public String getDescription(); + + /** + * @param description the description to set + */ + public void setDescription(String description); + + /** + * @return the helpId + */ + public String getHelpId(); + + /** + * @param helpId the helpId to set + */ + public void setHelpId(String helpId); + + /** + * @return the image + */ + public String getImage(); + + /** + * @param image the image to set + */ + public void setImage(String image); + + /** + * @return the styleList + */ + public String getStyleList(); + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList); + + /** + * @return the styleEdit + */ + public String getStyleEdit(); + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit); + + /** + * @return the collapsed + */ + public boolean isCollapsed(); + + /** + * @param collapsed the collapsed to set + */ + public void setCollapsed(boolean collapsed); + + /** + * @return the optional + */ + public boolean isOptional(); + + /** + * @param optional the optional to set + */ + public void setOptional(boolean optional); + + /** + * @return the vascEntryFieldIds + */ + public List getVascEntryFieldIds(); + + /** + * Add and VascEntryFieldId + * @param vascEntryFieldIds the vascEntryFieldIds to add + */ + public void addVascEntryFieldId(String vascEntryFieldId); + + /** + * Removes and VascEntryFieldId + * @param vascEntryFieldIds the vascEntryFieldIds to remove + */ + public void removeVascEntryFieldId(String vascEntryFieldId); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryFieldType.java b/src/com/idcanet/vasc/core/VascEntryFieldType.java new file mode 100644 index 0000000..db33d7d --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntryFieldType.java @@ -0,0 +1,68 @@ +/* + * 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; + +import java.util.List; + +import com.idcanet.vasc.core.ui.VascUIComponent; +import com.idcanet.vasc.validators.VascValidator; + + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascEntryFieldType { + + public String getName(); + public void setName(String name); + + public Class getAutoFieldClass(); + public void setAutoFieldClass(Class classObject); + + public void addVascValidator(VascValidator vascValidator); + public void removeVascValidator(VascValidator vascValidator); + public List getVascValidators(); + + public void setProperty(String name,String value); + public String getProperty(String name); + public List getPropertyNames(); + + public String getParentEntryFieldTypeName(); + public void setParentEntryFieldTypeName(String name); + + public ObjectConverter getObjectConverter(); + public void setObjectConverter(ObjectConverter converter); + + public VascUIComponent getVascUIComponent(); + public void setVascUIComponent(VascUIComponent vascUIComponent); + + interface ObjectConverter { + + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascViewRenderer.java b/src/com/idcanet/vasc/core/VascFrontend.java similarity index 86% rename from src/com/idcanet/vasc/core/VascViewRenderer.java rename to src/com/idcanet/vasc/core/VascFrontend.java index 64a1d90..06f5a5b 100644 --- a/src/com/idcanet/vasc/core/VascViewRenderer.java +++ b/src/com/idcanet/vasc/core/VascFrontend.java @@ -26,15 +26,21 @@ package com.idcanet.vasc.core; +import com.idcanet.vasc.core.entry.VascEntryExporter; + /** * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascViewRenderer { +public interface VascFrontend { - public void initTable(VascTable table) throws Exception; + public void setName(String name); + + public String getName(); + + public void initEntry(VascEntry table) throws Exception; public void renderView() throws Exception; @@ -42,5 +48,5 @@ public interface VascViewRenderer { public void renderDelete(Object rowBean) throws Exception; - public void renderExport(VascDataExporter exporter) throws Exception; + public void renderExport(VascEntryExporter exporter) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendController.java b/src/com/idcanet/vasc/core/VascFrontendController.java new file mode 100644 index 0000000..3887684 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascFrontendController.java @@ -0,0 +1,40 @@ +/* + * 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; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface VascFrontendController { + + public VascFrontend getVascFrontend(String name); + + public VascFrontendHelper getVascFrontendHelper(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendControllerResolver.java b/src/com/idcanet/vasc/core/VascFrontendControllerResolver.java new file mode 100644 index 0000000..89bf347 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascFrontendControllerResolver.java @@ -0,0 +1,38 @@ +/* + * 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; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface VascFrontendControllerResolver { + + public VascFrontendController getVascFrontendController(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascExceptionListener.java b/src/com/idcanet/vasc/core/VascFrontendExceptionHandler.java similarity index 91% rename from src/com/idcanet/vasc/core/VascExceptionListener.java rename to src/com/idcanet/vasc/core/VascFrontendExceptionHandler.java index 3794f18..f7810df 100644 --- a/src/com/idcanet/vasc/core/VascExceptionListener.java +++ b/src/com/idcanet/vasc/core/VascFrontendExceptionHandler.java @@ -34,7 +34,7 @@ import java.util.EventListener; * @author Willem Cazander * @version 1.0 Aug 12, 2007 */ -public interface VascExceptionListener extends EventListener { +public interface VascFrontendExceptionHandler extends EventListener { - public void handleException(Exception e,VascTable table); + public void handleException(Exception e,VascFrontend vascFrontend,VascEntry entry); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascTableController.java b/src/com/idcanet/vasc/core/VascFrontendHelper.java similarity index 62% rename from src/com/idcanet/vasc/core/VascTableController.java rename to src/com/idcanet/vasc/core/VascFrontendHelper.java index 0e5c576..efff7a6 100644 --- a/src/com/idcanet/vasc/core/VascTableController.java +++ b/src/com/idcanet/vasc/core/VascFrontendHelper.java @@ -26,40 +26,41 @@ package com.idcanet.vasc.core; -import com.idcanet.vasc.core.column.VascTableColumn; +import com.idcanet.vasc.core.entry.VascEntryEventListener; + /** * * @author Willem Cazander * @version 1.0 Apr 28, 2007 */ -public interface VascTableController { +public interface VascFrontendHelper { - public void finalizeVascTable(VascTable table) throws Exception; + public void finalizeVascEntry(VascEntry table) throws Exception; - public void finalizeVascColumns(VascTable table) throws Exception; + public void finalizeVascEntryFields(VascEntry table) throws Exception; - public Integer getTotalColumnsWidth(VascTable table); + public Integer getTotalColumnsWidth(VascEntry table); - public void refreshData(VascTable table) throws Exception; + public void refreshData(VascEntry table) throws Exception; - public Object initEditObject(VascTable table,Object object) throws Exception; + public Object initEditObject(VascEntry table,Object object) throws Exception; - public void initEditObjectColumn(VascTableColumn column,Object object) throws Exception; + public void initEditObjectColumn(VascEntryField field,Object object) throws Exception; - public void handleException(Exception e,VascTable table); + public void handleException(Exception e,VascEntry table); - public void addEventListener(VascEventListener e); + public void addEventListener(VascEntryEventListener e); - public void removeEventListener(VascEventListener e); + public void removeEventListener(VascEntryEventListener e); - public void fireVascEvent(VascEventListener.VascEventType type,Object data); + public void fireVascEvent(VascEntryEventListener.VascEventType type,Object data); - public boolean setUIComponentsBeanErrors(VascTable table,Object bean); + public boolean setUIComponentsBeanErrors(VascEntry table,Object bean); - public void addExceptionListener(VascExceptionListener listener); + public void addExceptionListener(VascEntryEventListener listener); - public void removeExceptionListener(VascExceptionListener listener); + public void removeExceptionListener(VascEntryEventListener listener); - public Object mergeObject(VascTable table,Object object); + public Object mergeObject(VascEntry table,Object object); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascDataExporter.java b/src/com/idcanet/vasc/core/VascLinkEntry.java similarity index 90% rename from src/com/idcanet/vasc/core/VascDataExporter.java rename to src/com/idcanet/vasc/core/VascLinkEntry.java index 368d2a9..b925d7b 100644 --- a/src/com/idcanet/vasc/core/VascDataExporter.java +++ b/src/com/idcanet/vasc/core/VascLinkEntry.java @@ -26,15 +26,15 @@ package com.idcanet.vasc.core; -import java.io.OutputStream; - /** * * @author Willem Cazander - * @version 1.0 May 19, 2007 + * @version 1.0 Sep 7, 2008 */ -public interface VascDataExporter { +public interface VascLinkEntry { + + public String getVascEntryName(); + public void setVascEntryName(String vascEntryName); - public void doExport(OutputStream out,VascTable table) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascTable.java b/src/com/idcanet/vasc/core/VascTable.java deleted file mode 100644 index 5e24a77..0000000 --- a/src/com/idcanet/vasc/core/VascTable.java +++ /dev/null @@ -1,344 +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; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.idcanet.vasc.core.actions.ColumnVascAction; -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 VascTable { - - - private String name = null; - private String headerName = null; - private String headerImage = null; - private String headerToolTip = null; - private List tableColumns = null; - private List rowActions = null; - private List columnActions = null; - private List globalActions = null; - private VascDataSource vascDataSource = null; - private List tableData = null; - private Object selectedObject = null; - private VascRecordCreator vascRecordCreator = null; - private VascViewRenderer vascViewRenderer = null; - private VascTextValue vascTextValue = null; - private List userOptions = null; - private String helpId = null; - private VascTableController vascTableController = null; - private Map,Class> uiComponents = null; - private VascTableColumn UIIdentifierVascTableColomn = null; - - public VascTable() { - tableColumns = new ArrayList(6); - rowActions = new ArrayList(6); - columnActions = new ArrayList(6); - globalActions = new ArrayList(6); - tableData = new ArrayList(6); - userOptions = new ArrayList(6); - uiComponents = new HashMap,Class>(6); - } - - /** - * @return the columnActions - */ - public List getColumnActions() { - return columnActions; - } - - /** - * @param columnActions the columnActions to set - */ - public void addColumnActions(ColumnVascAction columnAction) { - columnActions.add(columnAction); - } - - - /** - * @return the globalActions - */ - public List getGlobalActions() { - return globalActions; - } - - /** - * @param globalActions the globalActions to set - */ - public void addGlobalActions(GlobalVascAction globalAction) { - globalActions.add(globalAction); - } - - /** - * @return the headerName - */ - public String getHeaderName() { - return headerName; - } - - /** - * @param headerName the headerName to set - */ - public void setHeaderName(String headerName) { - this.headerName = headerName; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the rowActions - */ - public List getRowActions() { - return rowActions; - } - - /** - * @param rowActions the rowActions to set - */ - public void addRowActions(RowVascAction rowAction) { - rowActions.add(rowAction); - } - - /** - * @return the selectedObject - */ - public Object getSelectedObject() { - return selectedObject; - } - - /** - * @param selectedObject the selectedObject to set - */ - public void setSelectedObject(Object selectedObject) { - this.selectedObject = selectedObject; - } - - /** - * @return the tableColumns - */ - public List getTableColumns() { - return tableColumns; - } - - /** - * @param tableColumns the tableColumns to set - */ - public void addTableColumns(VascTableColumn tableColumn) { - if (tableColumn.getVascTable()!=null) { - if (tableColumn.getVascTable().equals(this) == false) { - throw new IllegalStateException("VascTableColumn already bound to an other VascTable instance."); - } - } - tableColumn.setVascTable(this); - tableColumns.add(tableColumn); - } - - /** - * @return the tableData - */ - public List getTableData() { - return tableData; - } - - /** - * @param tableData the tableData to set - */ - public void setTableData(List tableData) { - this.tableData = tableData; - } - - - /** - * @return the userOptions - */ - public List getUserOptions() { - return userOptions; - } - - /** - * @param userOptions the userOptions to set - */ - public void addUserOptions(VascUserOption userOption) { - userOptions.add(userOption); - } - - /** - * @return the vascDataSource - */ - public VascDataSource getVascDataSource() { - return vascDataSource; - } - - /** - * @param vascDataSource the vascDataSource to set - */ - public void setVascDataSource(VascDataSource vascDataSource) { - this.vascDataSource = vascDataSource; - } - - /** - * @return the vascRecordCreator - */ - public VascRecordCreator getVascRecordCreator() { - return vascRecordCreator; - } - - /** - * @param vascRecordCreator the vascRecordCreator to set - */ - public void setVascRecordCreator(VascRecordCreator vascRecordCreator) { - this.vascRecordCreator = vascRecordCreator; - } - - /** - * @return the vascTextValue - */ - public VascTextValue getVascTextValue() { - return vascTextValue; - } - - /** - * @param vascTextValue the vascTextValue to set - */ - public void setVascTextValue(VascTextValue vascTextValue) { - this.vascTextValue = vascTextValue; - } - - /** - * @return the vascViewRenderer - */ - public VascViewRenderer getVascViewRenderer() { - return vascViewRenderer; - } - - /** - * @param vascViewRenderer the vascViewRenderer to set - */ - public void setVascViewRenderer(VascViewRenderer vascViewRenderer) { - this.vascViewRenderer = vascViewRenderer; - } - - /** - * @return the helpId - */ - public String getHelpId() { - return helpId; - } - - /** - * @param helpId the helpId to set - */ - public void setHelpId(String helpId) { - this.helpId = helpId; - } - - /** - * @return the vascTableController - */ - public VascTableController getVascTableController() { - return vascTableController; - } - - /** - * @param vascTableController the vascTableController to set - */ - public void setVascTableController(VascTableController vascTableController) { - this.vascTableController = vascTableController; - } - - /** - * @return the headerImage - */ - public String getHeaderImage() { - return headerImage; - } - - /** - * @param headerImage the headerImage to set - */ - public void setHeaderImage(String headerImage) { - this.headerImage = headerImage; - } - - /** - * @return the headerToolTip - */ - public String getHeaderToolTip() { - return headerToolTip; - } - - /** - * @param headerToolTip the headerToolTip to set - */ - public void setHeaderToolTip(String headerToolTip) { - this.headerToolTip = headerToolTip; - } - - - public Class getUIComponent(Class classType) { - return uiComponents.get(classType); - } - public void putUIComponent(Class classType,Class comp) { - uiComponents.put(classType, comp); - } - - /** - * @return the uiIdentifierVascTableColomn - */ - public VascTableColumn getUIIdentifierVascTableColomn() { - return UIIdentifierVascTableColomn; - } - - /** - * @param uiIdentifierVascTableColomn the uiIdentifierVascTableColomn to set - */ - public void setUIIdentifierVascTableColomn(VascTableColumn UIIdentifierVascTableColomn) { - this.UIIdentifierVascTableColomn = UIIdentifierVascTableColomn; - } -} diff --git a/src/com/idcanet/vasc/core/actions/ColumnVascAction.java b/src/com/idcanet/vasc/core/actions/ColumnVascAction.java index 5c0e9a6..6f4491d 100644 --- a/src/com/idcanet/vasc/core/actions/ColumnVascAction.java +++ b/src/com/idcanet/vasc/core/actions/ColumnVascAction.java @@ -26,8 +26,8 @@ package com.idcanet.vasc.core.actions; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.column.VascTableColumn; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; /** * @@ -36,5 +36,5 @@ import com.idcanet.vasc.core.column.VascTableColumn; */ public interface ColumnVascAction extends VascAction { - public void doColumnAction(VascTable table,VascTableColumn column) throws Exception; + public void doColumnAction(VascEntry table,VascEntryField column) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/actions/GlobalVascAction.java b/src/com/idcanet/vasc/core/actions/GlobalVascAction.java index 24e1900..dc33b67 100644 --- a/src/com/idcanet/vasc/core/actions/GlobalVascAction.java +++ b/src/com/idcanet/vasc/core/actions/GlobalVascAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** * @@ -35,5 +35,5 @@ import com.idcanet.vasc.core.VascTable; */ public interface GlobalVascAction extends VascAction { - public void doGlobalAction(VascTable table) throws Exception; + public void doGlobalAction(VascEntry vascEntry) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/actions/RowVascAction.java b/src/com/idcanet/vasc/core/actions/RowVascAction.java index 0d79934..add03d4 100644 --- a/src/com/idcanet/vasc/core/actions/RowVascAction.java +++ b/src/com/idcanet/vasc/core/actions/RowVascAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** * @@ -35,5 +35,5 @@ import com.idcanet.vasc.core.VascTable; */ public interface RowVascAction extends VascAction { - public void doRowAction(VascTable table,Object rowObject) throws Exception; + public void doRowAction(VascEntry vascEntry,Object rowObject) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/actions/VascAction.java b/src/com/idcanet/vasc/core/actions/VascAction.java index dde2163..6012d2b 100644 --- a/src/com/idcanet/vasc/core/actions/VascAction.java +++ b/src/com/idcanet/vasc/core/actions/VascAction.java @@ -34,13 +34,18 @@ package com.idcanet.vasc.core.actions; public interface VascAction { public String getName(); - public void setName(String name); - public String getToolTip(); - public void setToolTip(String toolTip); - public String getImage(); - public void setImage(String image); - public String getHelpId(); - public void setHelpId(String helpId); - //public Object createActionObject(VascTable table); + public void setName(String name); + + public String getToolTip(); + + public void setToolTip(String toolTip); + + public String getImage(); + + public void setImage(String image); + + public String getHelpId(); + + public void setHelpId(String helpId); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEventListener.java b/src/com/idcanet/vasc/core/entry/VascEntryEventListener.java similarity index 95% rename from src/com/idcanet/vasc/core/VascEventListener.java rename to src/com/idcanet/vasc/core/entry/VascEntryEventListener.java index db8c40c..e938b76 100644 --- a/src/com/idcanet/vasc/core/VascEventListener.java +++ b/src/com/idcanet/vasc/core/entry/VascEntryEventListener.java @@ -24,7 +24,7 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core; +package com.idcanet.vasc.core.entry; /** @@ -32,7 +32,7 @@ package com.idcanet.vasc.core; * @author Willem Cazander * @version 1.0 Aug 02, 2007 */ -public interface VascEventListener { +public interface VascEntryEventListener { public enum VascEventType { DATA_UPDATE,OPTION_UPDATE,CLOSE_WINDOW,BEAN_MERGE,BEAN_INIT } diff --git a/src/com/idcanet/vasc/core/entry/VascEntryExporter.java b/src/com/idcanet/vasc/core/entry/VascEntryExporter.java new file mode 100644 index 0000000..0947e23 --- /dev/null +++ b/src/com/idcanet/vasc/core/entry/VascEntryExporter.java @@ -0,0 +1,47 @@ +/* + * 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.entry; + +import java.io.OutputStream; + +import com.idcanet.vasc.core.VascEntry; + + +/** + * + * @author Willem Cazander + * @version 1.0 May 19, 2007 + */ +public interface VascEntryExporter { + + public void doExport(OutputStream out,VascEntry vascEntry) throws Exception; + + public String getMineType(); + + public String getType(); + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/entry/VascEntryFieldEventChannel.java b/src/com/idcanet/vasc/core/entry/VascEntryFieldEventChannel.java new file mode 100644 index 0000000..d1f8a20 --- /dev/null +++ b/src/com/idcanet/vasc/core/entry/VascEntryFieldEventChannel.java @@ -0,0 +1,41 @@ +/* + * 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.entry; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 04, 2008 + */ +public interface VascEntryFieldEventChannel { + + public void setChannel(String channel); + public String getChannel(); + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascDataSource.java b/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java similarity index 76% rename from src/com/idcanet/vasc/core/VascDataSource.java rename to src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java index 4363689..e2eb493 100644 --- a/src/com/idcanet/vasc/core/VascDataSource.java +++ b/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java @@ -24,27 +24,20 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core; +package com.idcanet.vasc.core.entry; -import java.util.List; -import java.util.Set; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.x4o.element.ElementParameterException; +import com.idcanet.x4o.element.ElementParameterNotFoundException; /** * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascDataSource { +public interface VascEntryFieldValue { - public void setDataParameter(String key,Object data); - public Object getDataParameter(String key); - public Set getDataParameterKeys(); + public Object getValue(VascEntryField field,Object record) throws ElementParameterException,ElementParameterNotFoundException; - public List execute() throws Exception; - - public void persist(Object object) throws Exception; - - public Object merge(Object object) throws Exception; - - public void delete(Object object) throws Exception; + public void setValue(VascEntryField field,Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/entry/VascEntryRecordCreator.java b/src/com/idcanet/vasc/core/entry/VascEntryRecordCreator.java new file mode 100644 index 0000000..37565d1 --- /dev/null +++ b/src/com/idcanet/vasc/core/entry/VascEntryRecordCreator.java @@ -0,0 +1,42 @@ +/* + * 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.entry; + +import com.idcanet.vasc.core.VascEntry; + + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascEntryRecordCreator { + + public Object newRecord(VascEntry entry) throws Exception; + + public Class getObjectClass(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascTextValue.java b/src/com/idcanet/vasc/core/entry/VascEntryResourceResolver.java similarity index 95% rename from src/com/idcanet/vasc/core/VascTextValue.java rename to src/com/idcanet/vasc/core/entry/VascEntryResourceResolver.java index 1ce655f..737a90c 100644 --- a/src/com/idcanet/vasc/core/VascTextValue.java +++ b/src/com/idcanet/vasc/core/entry/VascEntryResourceResolver.java @@ -24,7 +24,7 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core; +package com.idcanet.vasc.core.entry; /** @@ -32,7 +32,7 @@ package com.idcanet.vasc.core; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascTextValue { +public interface VascEntryResourceResolver { public String getTextValue(String key,Object...params); diff --git a/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java b/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java index f194049..0cf6d7d 100644 --- a/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java +++ b/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** * @@ -37,7 +37,7 @@ abstract public class AbstractVascUIComponent implements VascUIComponent { private VascUIComponent wrapper = null; - abstract public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception; + abstract public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception; /** * @return the wrapper diff --git a/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java b/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java index db0cdd0..c9ae359 100644 --- a/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java +++ b/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.column.VascTableColumn; +import com.idcanet.vasc.core.VascEntryField; import com.idcanet.x4o.element.ElementParameterException; import com.idcanet.x4o.element.ElementParameterNotFoundException; @@ -38,18 +38,19 @@ import com.idcanet.x4o.element.ElementParameterNotFoundException; */ public class VascColumnValueModelListener implements VascValueModelListener { - private VascTableColumn vascTableColumn = null; + private VascEntryField vascTableColumn = null; private Object bean = null; public VascColumnValueModelListener() { } - public VascColumnValueModelListener(VascTableColumn vascTableColumn,Object bean) { + public VascColumnValueModelListener(VascEntryField vascTableColumn,Object bean) { setVascTableColumn(vascTableColumn); setBean(bean); } public void valueUpdate(VascValueModel model) throws ElementParameterException,ElementParameterNotFoundException { - vascTableColumn.getVascColumnValue().setValue(vascTableColumn, bean, model.getValue()); + //vascTableColumn.getVascColumnValue().setValue(VascEntryField, bean, model.getValue()); + //TODO } @@ -57,7 +58,7 @@ public class VascColumnValueModelListener implements VascValueModelListener { /** * @return the vascTableColumn */ - public VascTableColumn getVascTableColumn() { + public VascEntryField getVascTableColumn() { return vascTableColumn; } @@ -66,7 +67,7 @@ public class VascColumnValueModelListener implements VascValueModelListener { /** * @param vascTableColumn the vascTableColumn to set */ - public void setVascTableColumn(VascTableColumn vascTableColumn) { + public void setVascTableColumn(VascEntryField vascTableColumn) { this.vascTableColumn = vascTableColumn; } /** diff --git a/src/com/idcanet/vasc/core/ui/VascList.java b/src/com/idcanet/vasc/core/ui/VascList.java index 764a500..1afecff 100644 --- a/src/com/idcanet/vasc/core/ui/VascList.java +++ b/src/com/idcanet/vasc/core/ui/VascList.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** @@ -38,8 +38,8 @@ public class VascList extends VascUIComponentImplLoader { private VascSelectItemModel vascSelectItemModel = null; - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - return loadAndCreateComponent(this, table, model, gui); + public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception { + return loadAndCreateComponent(this, entry, model, gui); } /** diff --git a/src/com/idcanet/vasc/core/ui/VascToggle.java b/src/com/idcanet/vasc/core/ui/VascToggle.java deleted file mode 100644 index 3a04c64..0000000 --- a/src/com/idcanet/vasc/core/ui/VascToggle.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.ui; - -import com.idcanet.vasc.core.VascTable; - - -/** - * - * @author Willem Cazander - * @version 1.0 Aug 12, 2007 - */ -public class VascToggle extends VascUIComponentImplLoader implements VascUIComponent { - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - return loadAndCreateComponent(this, table, model, gui); - } -} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/VascUIComponent.java b/src/com/idcanet/vasc/core/ui/VascUIComponent.java index b63ffaf..edf0939 100644 --- a/src/com/idcanet/vasc/core/ui/VascUIComponent.java +++ b/src/com/idcanet/vasc/core/ui/VascUIComponent.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** * @@ -38,7 +38,7 @@ public interface VascUIComponent { public void setWrapper(VascUIComponent wrapper); public VascUIComponent getWrapper(); - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception; + public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception; public void setErrorText(String text); public String getErrorText(); diff --git a/src/com/idcanet/vasc/core/ui/VascUIComponentImplLoader.java b/src/com/idcanet/vasc/core/ui/VascUIComponentImplLoader.java index a60c636..6fde2bd 100644 --- a/src/com/idcanet/vasc/core/ui/VascUIComponentImplLoader.java +++ b/src/com/idcanet/vasc/core/ui/VascUIComponentImplLoader.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; /** * @@ -37,10 +37,12 @@ abstract public class VascUIComponentImplLoader extends AbstractVascUIComponent private VascUIComponent realComponent = null; - public Object loadAndCreateComponent(VascUIComponent wrapper,VascTable table,VascValueModel model,Object gui) throws Exception { - realComponent = (VascUIComponent)table.getUIComponent(wrapper.getClass()).newInstance(); - realComponent.setWrapper(wrapper); - return realComponent.createComponent(table, model, gui); + public Object loadAndCreateComponent(VascUIComponent wrapper,VascEntry entry,VascValueModel model,Object gui) throws Exception { + //realComponent = (VascUIComponent)entry.getUIComponent(wrapper.getClass()).newInstance(); + //realComponent.setWrapper(wrapper); + //return realComponent.createComponent(entry, model, gui); + //TODO + return null; } diff --git a/src/com/idcanet/vasc/core/ui/VascValueModel.java b/src/com/idcanet/vasc/core/ui/VascValueModel.java index 5d13e9a..1e31aee 100644 --- a/src/com/idcanet/vasc/core/ui/VascValueModel.java +++ b/src/com/idcanet/vasc/core/ui/VascValueModel.java @@ -29,7 +29,7 @@ package com.idcanet.vasc.core.ui; import java.util.ArrayList; import java.util.List; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; import com.idcanet.x4o.element.ElementParameterException; import com.idcanet.x4o.element.ElementParameterNotFoundException; @@ -45,7 +45,7 @@ public class VascValueModel { private List listeners = null; //private VascTable table = null; - public VascValueModel(VascTable table) { + public VascValueModel(VascEntry entry) { listeners = new ArrayList(2); //this.table=table; } diff --git a/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java new file mode 100644 index 0000000..b353425 --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java @@ -0,0 +1,857 @@ +/* + * 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.frontends.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.VascEntry; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascFrontend; +import com.idcanet.vasc.core.actions.GlobalVascAction; +import com.idcanet.vasc.core.actions.RowVascAction; +import com.idcanet.vasc.core.entry.VascEntryExporter; +import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType; +import com.idcanet.vasc.core.ui.VascColumnValueModelListener; +import com.idcanet.vasc.core.ui.VascList; +import com.idcanet.vasc.core.ui.VascUIComponent; +import com.idcanet.vasc.core.ui.VascValueModel; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class SwingVascFrontend implements VascFrontend { + + private String name = null; + private Logger logger = null; + private JComponent parent = null; + private VascEntry entry = null; + + public SwingVascFrontend(JComponent parent) { + logger = Logger.getLogger(SwingVascFrontend.class.getName()); + this.parent=parent; + } + + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + public void initEntry(VascEntry entry) throws Exception { + if (entry.getVascFrontend()==null) { + entry.setVascFrontend(this); + } else { + if (entry.getVascFrontend()!=this) { + throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected"); + } + } + entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntry(entry); + entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntryFields(entry); + entry.getVascFrontendController().getVascFrontendHelper().refreshData(entry); + /* + entry.putUIComponent(VascTextField.class, SwingTextField.class); + entry.putUIComponent(VascList.class, SwingList.class); + entry.putUIComponent(VascToggle.class, SwingToggle.class); + entry.putUIComponent(VascDate.class, SwingDate.class); + entry.putUIComponent(VascColorChooser.class, SwingColorChooser.class); + */ + this.entry=entry; + } + + + public ImageIcon getImageIcon(String imageResource) { + /// TODO hack beter + String key = entry.getVascEntryResourceResolver().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.VascEntry, java.lang.Object) + */ + public void renderEdit(Object rowBean) throws Exception { + logger.fine("Rending Edit View"); + + + + rowBean = entry.getVascFrontendController().getVascFrontendHelper().initEditObject(entry, rowBean); + String beanValue = rowBean.toString(); + if (entry.getDisplayNameField()!=null) { + Object vv = entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean); + if (vv==null) { + beanValue=""; + } else { + beanValue=""+vv; + } + if (beanValue.length()>30) { + beanValue=beanValue.substring(0, 30); + } + } + SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.title"),entry.getVascTextValue().getTextValue("vasc.dialog.edit.message",beanValue)); + Object result = dialog.openDialog(); + logger.finest("OPEN closed : "+result); + if(result==null) { + return; + } + entry.getVascFrontendController().getVascFrontendHelper().mergeObject(entry, result); + } + + public void renderDelete(Object rowBean) throws Exception { + String beanValue = rowBean.toString(); + if (entry.getUIIdentifierVascEntryColomn()!=null) { + beanValue = ""+entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean); + if (beanValue.length()>30) { + beanValue=beanValue.substring(0, 30); + } + } + int response = JOptionPane.showOptionDialog( + parent // Center in window. + , entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.message",beanValue) // Message + , entry.getVascEntryResourceResolver().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) { + entry.getVascBackend().delete(rowBean); + entry.getEntryDataList().remove(rowBean); + entry.setEntryDataObject(null); + entry.getVascFrontendController().getVascFrontendHelper().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,VascEntry entry,Object bean,String title,String headerText) throws Exception { + super(); + this.headerText = headerText; + this.bean = bean; + + setTitle(entry.getVascEntryResourceResolver().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(entry.getVascEntryResourceResolver().getTextValue(headerText)); + l.setFont(new Font(null,Font.BOLD, 14)); + //l.setToolTipText(entry.getVascTextValue().getTextValue(headerText)); + header.add(l); + } + + public void createBody(JPanel body) throws Exception { + body.setLayout(new SpringLayout()); + int column = 0; + for(VascEntryField c:entry.getVascEntryFields()) { + entry.getVascFrontendController().getVascFrontendHelper().initEditObjectColumn(c, bean); + if (c.isEdit()==false) { + continue; + } + column++; + + JLabel l = new JLabel(); + l.setHorizontalAlignment(JLabel.TRAILING); + + l.setText(entry.getVascEntryResourceResolver().getTextValue(c.getName())); + if(c.getDescription()!=null) { + l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(c.getDescription())); + } + body.add(l); + + if (c.isEditReadOnly()==true) { + JLabel valueLabel = new JLabel(); + valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); + c.setColumnEditor(valueLabel); + body.add(valueLabel); + continue; + } + + if(c.getVascEntryFieldType().getVascUIComponent()==null) { + JLabel valueLabel = new JLabel(); + valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); + c.setColumnEditor(valueLabel); + body.add(valueLabel); + } else { + VascUIComponent comp = c.getVascEntryFieldType().getVascUIComponent(); + VascValueModel model = new VascValueModel(entry); + model.setValue(c.getVascEntryFieldValue().getValue(c, bean)); + model.addListener(new VascColumnValueModelListener(c,bean)); + comp.createComponent(entry, 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(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name")); + saveButton.setToolTipText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip")); + saveButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + if(entry.getVascFrontendController().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) { + return; + } + result = bean; + setVisible(false); + } + }); + footer.add(saveButton); + + JButton cancelButton = new JButton(); + cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image")); + cancelButton.setText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name")); + cancelButton.setToolTipText(entry.getVascEntryResourceResolver().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.VascEntry, com.idcanet.vasc.core.VascDataExporter) + */ + public void renderExport(VascEntryExporter 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, entry); + } catch (Exception e) { + entry.getVascFrontendController().getVascFrontendHelper().handleException(e, entry); + } finally { + if (out!=null) { + out.close(); + } + } + } + + + /** + * @see com.idcanet.vasc.core.VascViewRenderer#renderView(com.idcanet.vasc.core.VascEntry) + */ + 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(entry.getHeaderImage()!=null) { + JLabel l = new JLabel(); + // TODO: hack images working + l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH))); + if (entry.getHeaderDescription()!=null) { + l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); + } + header.add(l,BorderLayout.WEST); + } + + if(entry.getHeaderName()!=null) { + JLabel l = new JLabel(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderName())); + l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + l.setFont(new Font(null,Font.BOLD, 18)); + if (entry.getHeaderDescription()!=null) { + l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); + } + header.add(l,BorderLayout.CENTER); + } + + JPanel top = new JPanel(); + //top.setBackground(Color.BLUE); + for (GlobalVascAction action:entry.getGlobalActions()) { + JButton but = new JButton(); + but.setText(entry.getVascEntryResourceResolver().getTextValue(action.getName())); + but.setToolTipText(entry.getVascEntryResourceResolver().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:entry.getUserOptions()) { + // option.createUserOptionRenderer(entry); + //} + + //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(); + //TODO: entry.getVascEntryController().addEventListener(model); + + JTable table = 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(table.getTableHeader()); + tableSorter.setTableModel(model); + + + table.setModel(tableSorter); + table.getTableHeader().setReorderingAllowed(false); + + // remove auto columns :( + int cols = table.getColumnModel().getColumnCount(); + for (int i=0;i list = new ArrayList(); + for(VascEntryField c:entry.getVascEntryFields()) { + if (c.isList()==false) { + continue; + + } + list.add(c); + } + + VascEntryField vtc = list.get(columnIndex); + try { + //if (vtc.getVascColumnRenderer()!=null) { +// return vtc.getVascColumnRenderer().rendererColumn(vtc,bean); + //} else { + return ""+vtc.getVascEntryFieldValue().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/frontends/swing/TableSorter.java b/src/com/idcanet/vasc/frontends/swing/TableSorter.java new file mode 100644 index 0000000..060680d --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/TableSorter.java @@ -0,0 +1,492 @@ +/* + * + * + * THIS FILE IS FROM: + * http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting + */ + +package com.idcanet.vasc.frontends.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/frontends/swing/ui/SwingColorChooser.java b/src/com/idcanet/vasc/frontends/swing/ui/SwingColorChooser.java new file mode 100644 index 0000000..a107594 --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/ui/SwingColorChooser.java @@ -0,0 +1,131 @@ +/* + * 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/frontends/swing/ui/SwingDate.java b/src/com/idcanet/vasc/frontends/swing/ui/SwingDate.java new file mode 100644 index 0000000..d9cc6df --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/ui/SwingDate.java @@ -0,0 +1,107 @@ +/* + * 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/frontends/swing/ui/SwingList.java b/src/com/idcanet/vasc/frontends/swing/ui/SwingList.java new file mode 100644 index 0000000..ca5d095 --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/ui/SwingList.java @@ -0,0 +1,140 @@ +/* + * 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/frontends/swing/ui/SwingTextField.java b/src/com/idcanet/vasc/frontends/swing/ui/SwingTextField.java new file mode 100644 index 0000000..b76f03c --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/ui/SwingTextField.java @@ -0,0 +1,129 @@ +/* + * 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/frontends/swing/ui/SwingToggle.java b/src/com/idcanet/vasc/frontends/swing/ui/SwingToggle.java new file mode 100644 index 0000000..3c27653 --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swing/ui/SwingToggle.java @@ -0,0 +1,106 @@ +/* + * 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/frontends/swt/SwtVascFrontend.java b/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java new file mode 100644 index 0000000..8f82bcf --- /dev/null +++ b/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java @@ -0,0 +1,714 @@ +/* + * 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.frontends.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.VascEntry; +import com.idcanet.vasc.core.actions.GlobalVascAction; +import com.idcanet.vasc.core.actions.RowVascAction; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class SwtVascFrontend implements VascFrontend { + + private Logger logger = null; + private Composite parent = null; + private VascEntry table = null; + + public SwtVascFrontend(Composite parent) { + logger = Logger.getLogger(SwtVascFrontend.class.getName()); + this.parent=parent; + } + + public void initTable(VascEntry table) throws Exception { + if (table.VascEntry()==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 vascFields = null; + private List entryDataList = null; + private Object entryDataObject = null; + private VascBackend vascBackend = null; + private VascFrontend vascFrontend = null; + + private VascBackendController vascBackendController = null; + private VascEntryController vascEntryController = null; + private VascFrontendController vascFrontendController = null; + private VascEntryResourceResolver vascEntryResourceResolver = null; + + private List rowActions = null; + private List columnActions = null; + private List globalActions = null; + + private List vascEntryFieldSets = null; + private List vascLinkEntries = null; + private Map entryParameters = null; + + + public DefaultVascEntry() { + vascFields = new ArrayList(10); + entryDataList = new ArrayList(0); + + rowActions = new ArrayList(10); + columnActions = new ArrayList(10); + globalActions = new ArrayList(10); + + vascEntryFieldSets = new ArrayList(10); + vascLinkEntries = new ArrayList(10); + entryParameters = new HashMap(); + } + + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @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 headerName + */ + public String getHeaderName() { + return headerName; + } + + /** + * @param headerName the headerName to set + */ + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + /** + * @return the headerImage + */ + public String getHeaderImage() { + return headerImage; + } + + /** + * @param headerImage the headerImage to set + */ + public void setHeaderImage(String headerImage) { + this.headerImage = headerImage; + } + + /** + * @return the headerDescription + */ + public String getHeaderDescription() { + return headerDescription; + } + + /** + * @param headerDescription the headerDescription to set + */ + public void setHeaderDescription(String headerDescription) { + this.headerDescription = headerDescription; + } + + /** + * @return the primaryKeyField + */ + public String getPrimaryKeyField() { + return primaryKeyField; + } + + /** + * @param primaryKeyField the primaryKeyField to set + */ + public void setPrimaryKeyField(String primaryKeyField) { + this.primaryKeyField = primaryKeyField; + } + + /** + * @return the displayNameField + */ + public String getDisplayNameField() { + return displayNameField; + } + + /** + * @param displayNameField the displayNameField to set + */ + public void setDisplayNameField(String displayNameField) { + this.displayNameField = displayNameField; + } + + /** + * @return the vascAdmimList + */ + public boolean isVascAdmimList() { + return vascAdmimList; + } + + /** + * @param vascAdmimList the vascAdmimList to set + */ + public void setVascAdmimList(boolean vascAdmimList) { + this.vascAdmimList = vascAdmimList; + } + + /** + * @return the vascAdmimEdit + */ + public boolean isVascAdmimEdit() { + return vascAdmimEdit; + } + + /** + * @param vascAdmimEdit the vascAdmimEdit to set + */ + public void setVascAdmimEdit(boolean vascAdmimEdit) { + this.vascAdmimEdit = vascAdmimEdit; + } + + /** + * @return the vascAdmimCreate + */ + public boolean isVascAdmimCreate() { + return vascAdmimCreate; + } + + /** + * @param vascAdmimCreate the vascAdmimCreate to set + */ + public void setVascAdmimCreate(boolean vascAdmimCreate) { + this.vascAdmimCreate = vascAdmimCreate; + } + + /** + * @return the vascAdmimDelete + */ + public boolean isVascAdmimDelete() { + return vascAdmimDelete; + } + + /** + * @param vascAdmimDelete the vascAdmimDelete to set + */ + public void setVascAdmimDelete(boolean vascAdmimDelete) { + this.vascAdmimDelete = vascAdmimDelete; + } + + /** + * @return the vascFields + */ + public List getVascEntryFields() { + return vascFields; + } + + /** + * @param vascField the vascFields to add + */ + public void addVascEntryField(VascEntryField vascField) { + vascFields.add(vascField); + } + + /** + * @param vascField the vascFields to remove + */ + public void removeVascEntryField(VascEntryField vascField) { + vascFields.remove(vascField); + } + + /** + * @return the entryDataList + */ + public List getEntryDataList() { + return entryDataList; + } + + /** + * @param entryDataList the entryDataList to set + */ + public void setEntryDataList(List entryDataList) { + this.entryDataList = entryDataList; + } + + /** + * @return the entryDataObject + */ + public Object getEntryDataObject() { + return entryDataObject; + } + + /** + * @param entryDataObject the entryDataObject to set + */ + public void setEntryDataObject(Object entryDataObject) { + this.entryDataObject = entryDataObject; + } + + /** + * @return the vascBackend + */ + public VascBackend getVascBackend() { + return vascBackend; + } + + /** + * @param vascBackend the vascBackend to set + */ + public void setVascBackend(VascBackend vascBackend) { + this.vascBackend = vascBackend; + } + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend() { + return vascFrontend; + } + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(VascFrontend vascFrontend) { + this.vascFrontend = vascFrontend; + } + + /** + * @return the vascBackendController + */ + public VascBackendController getVascBackendController() { + return vascBackendController; + } + + /** + * @param vascBackendController the vascBackendController to set + */ + public void setVascBackendController(VascBackendController vascBackendController) { + this.vascBackendController = vascBackendController; + } + + /** + * @return the vascEntryController + */ + public VascEntryController getVascEntryController() { + return vascEntryController; + } + + /** + * @param vascEntryController the vascEntryController to set + */ + public void setVascEntryController(VascEntryController vascEntryController) { + this.vascEntryController = vascEntryController; + } + + /** + * @return the vascFrontendController + */ + public VascFrontendController getVascFrontendController() { + return vascFrontendController; + } + + /** + * @param vascFrontendController the vascFrontendController to set + */ + public void setVascFrontendController(VascFrontendController vascFrontendController) { + this.vascFrontendController = vascFrontendController; + } + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver() { + return vascEntryResourceResolver; + } + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) { + this.vascEntryResourceResolver = vascEntryResourceResolver; + } + + /** + * @return the rowActions + */ + public List getRowActions() { + return rowActions; + } + + /** + * @param rowAction the rowAction to add + */ + public void addRowAction(RowVascAction rowAction) { + rowActions.add(rowAction); + } + + /** + * @param rowAction the rowAction to remove + */ + public void removeRowAction(RowVascAction rowAction) { + rowActions.remove(rowAction); + } + + /** + * @return the columnActions + */ + public List getColumnActions() { + return columnActions; + } + + /** + * @param columnAction the columnActions to add + */ + public void addColumnAction(ColumnVascAction columnAction) { + columnActions.add(columnAction); + } + + /** + * @param columnAction the columnActions to remove + */ + public void removeColumnAction(ColumnVascAction columnAction) { + columnActions.remove(columnAction); + } + + /** + * @return the globalActions + */ + public List getGlobalActions() { + return globalActions; + } + + /** + * @param globalAction the globalAction to add + */ + public void addGlobalAction(GlobalVascAction globalAction) { + globalActions.add(globalAction); + } + + /** + * @param globalAction the globalAction to remove + */ + public void removeGlobalAction(GlobalVascAction globalAction) { + globalActions.remove(globalAction); + } + + /** + * @return the vascEntryFieldSets + */ + public List getVascEntryFieldSets() { + return vascEntryFieldSets; + } + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void addVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet) { + vascEntryFieldSets.add(vascEntryFieldSet); + } + + /** + * @param vascEntryFieldSet the vascEntryFieldSet to add + */ + public void removeVascEntryFieldSet(VascEntryFieldSet vascEntryFieldSet) { + vascEntryFieldSets.remove(vascEntryFieldSet); + } + + /** + * @return the vascLinkEntries + */ + public List getVascLinkEntries() { + return vascLinkEntries; + } + + /** + * @param vascLinkEntry the vascLinkEntry to set + */ + public void addVascLinkEntry(VascLinkEntry vascLinkEntry) { + vascLinkEntries.add(vascLinkEntry); + } + + /** + * @param vascLinkEntry the vascLinkEntry to remove + */ + public void removeVascLinkEntry(VascLinkEntry vascLinkEntry) { + vascLinkEntries.remove(vascLinkEntry); + } + + + /** + * @see com.idcanet.vasc.core.VascEntry#getEntryParameter(java.lang.String) + */ + public Object getEntryParameter(String key) { + return entryParameters.get(key); + } + + + /** + * @see com.idcanet.vasc.core.VascEntry#getEntryParameterKeys() + */ + public List getEntryParameterKeys() { + return new ArrayList(entryParameters.keySet()); + } + + + /** + * @see com.idcanet.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object) + */ + public void setEntryParameter(String key, Object value) { + entryParameters.put(key, value); + } + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryField.java b/src/com/idcanet/vasc/impl/DefaultVascEntryField.java new file mode 100644 index 0000000..9a7f3a8 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascEntryField.java @@ -0,0 +1,475 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.List; + +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascEntryFieldType; +import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.validators.VascValidator; + + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class DefaultVascEntryField implements VascEntryField { + + private VascEntry vascEntry = null; + + /** The vasc id for this field */ + private String id = null; + + /** The vasc Field Type for this field entry. */ + private VascEntryFieldType vascEntryFieldType = null; + + /** The backendName, default to the name. **/ + private String backendName = null; + + private VascEntryFieldValue vascEntryFieldValue = null; + + private VascEntryFieldEventChannel vascEntryFieldEventChannel = null; + + private List vascValidators = null; + + /** Some VascField fields**/ + private String name = null; + private String description = null; + private String helpId = null; + private String image = null; + private Object defaultValue = null; + private Integer sizeList = null; + private Integer sizeEdit = null; + private String styleList = null; + private String styleEdit = null; + + private String choices = null; + + /** Defines if this columns is used in interface list,create,edit **/ + private boolean view = true; + private boolean optional = false; + + /** Defines per view state of this field **/ + private boolean create = true; + private boolean edit = true; + private boolean editReadOnly = false; + private boolean list = true; + + /** Defines the roles stuff if all up is true **/ + private String rolesCreate = null; + private String rolesEdit = null; + private String rolesEditReadOnly = null; + private String rolesList = null; + + public DefaultVascEntryField() { + vascValidators = new ArrayList(5); + } + + public VascEntry getVascEntry() { + return vascEntry; + } + + public void setVascEntry(VascEntry vascEntry) { + this.vascEntry=vascEntry; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the vascEntryFieldType + */ + public VascEntryFieldType getVascEntryFieldType() { + return vascEntryFieldType; + } + + /** + * @param vascEntryFieldType the vascEntryFieldType to set + */ + public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType) { + this.vascEntryFieldType = vascEntryFieldType; + } + + /** + * @return the backendName + */ + public String getBackendName() { + return backendName; + } + + /** + * @param backendName the backendName to set + */ + public void setBackendName(String backendName) { + this.backendName = backendName; + } + + /** + * @return the vascEntryFieldValue + */ + public VascEntryFieldValue getVascEntryFieldValue() { + return vascEntryFieldValue; + } + + /** + * @param vascEntryFieldValue the vascEntryFieldValue to set + */ + public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) { + this.vascEntryFieldValue = vascEntryFieldValue; + } + + /** + * @return the vascEntryFieldEventChannel + */ + public VascEntryFieldEventChannel getVascEntryFieldEventChannel() { + return vascEntryFieldEventChannel; + } + + /** + * @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set + */ + public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) { + this.vascEntryFieldEventChannel = vascEntryFieldEventChannel; + } + + /** + * @return the vascValidators + */ + public List getVascValidators() { + return vascValidators; + } + + /** + * @param vascValidators the vascValidators to add + */ + public void addVascValidator(VascValidator vascValidator) { + this.vascValidators.add(vascValidator); + } + + /** + * @param vascValidators the vascValidators to remove + */ + public void removeVascValidator(VascValidator vascValidator) { + this.vascValidators.remove(vascValidator); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @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 defaultValue + */ + public Object getDefaultValue() { + return defaultValue; + } + + /** + * @param defaultValue the defaultValue to set + */ + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * @return the sizeList + */ + public Integer getSizeList() { + return sizeList; + } + + /** + * @param sizeList the sizeList to set + */ + public void setSizeList(Integer sizeList) { + this.sizeList = sizeList; + } + + /** + * @return the sizeEdit + */ + public Integer getSizeEdit() { + return sizeEdit; + } + + /** + * @param sizeEdit the sizeEdit to set + */ + public void setSizeEdit(Integer sizeEdit) { + this.sizeEdit = sizeEdit; + } + + /** + * @return the styleList + */ + public String getStyleList() { + return styleList; + } + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList) { + this.styleList = styleList; + } + + /** + * @return the styleEdit + */ + public String getStyleEdit() { + return styleEdit; + } + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit) { + this.styleEdit = styleEdit; + } + + /** + * @return the choices + */ + public String getChoices() { + return choices; + } + + /** + * @param choices the choices to set + */ + public void setChoices(String choices) { + this.choices = choices; + } + + /** + * @return the view + */ + public boolean isView() { + return view; + } + + /** + * @param view the view to set + */ + public void setView(boolean view) { + this.view = view; + } + + /** + * @return the optional + */ + public boolean isOptional() { + return optional; + } + + /** + * @param optional the optional to set + */ + public void setOptional(boolean optional) { + this.optional = optional; + } + + /** + * @return the create + */ + public boolean isCreate() { + return create; + } + + /** + * @param create the create to set + */ + public void setCreate(boolean create) { + this.create = create; + } + + /** + * @return the edit + */ + public boolean isEdit() { + return edit; + } + + /** + * @param edit the edit to set + */ + public void setEdit(boolean edit) { + this.edit = edit; + } + + /** + * @return the editReadOnly + */ + public boolean isEditReadOnly() { + return editReadOnly; + } + + /** + * @param editReadOnly the editReadOnly to set + */ + public void setEditReadOnly(boolean editReadOnly) { + this.editReadOnly = editReadOnly; + } + + /** + * @return the list + */ + public boolean isList() { + return list; + } + + /** + * @param list the list to set + */ + public void setList(boolean list) { + this.list = list; + } + + /** + * @return the rolesCreate + */ + public String getRolesCreate() { + return rolesCreate; + } + + /** + * @param rolesCreate the rolesCreate to set + */ + public void setRolesCreate(String rolesCreate) { + this.rolesCreate = rolesCreate; + } + + /** + * @return the rolesEdit + */ + public String getRolesEdit() { + return rolesEdit; + } + + /** + * @param rolesEdit the rolesEdit to set + */ + public void setRolesEdit(String rolesEdit) { + this.rolesEdit = rolesEdit; + } + + /** + * @return the rolesEditReadOnly + */ + public String getRolesEditReadOnly() { + return rolesEditReadOnly; + } + + /** + * @param rolesEditReadOnly the rolesEditReadOnly to set + */ + public void setRolesEditReadOnly(String rolesEditReadOnly) { + this.rolesEditReadOnly = rolesEditReadOnly; + } + + /** + * @return the rolesList + */ + public String getRolesList() { + return rolesList; + } + + /** + * @param rolesList the rolesList to set + */ + public void setRolesList(String rolesList) { + this.rolesList = rolesList; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java b/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java new file mode 100644 index 0000000..1a9b6af --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java @@ -0,0 +1,201 @@ +/* + * 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; + +import java.util.List; + +import com.idcanet.vasc.core.VascEntryFieldSet; + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class DefaultVascEntryFieldSet implements VascEntryFieldSet { + + private String id = null; + + private String name = null; + private String description = null; + private String helpId = null; + private String image = null; + + private String styleList = null; + private String styleEdit = null; + + private boolean collapsed = false; + private boolean optional = false; + + private List vascEntryFieldIds = null; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @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 styleList + */ + public String getStyleList() { + return styleList; + } + + /** + * @param styleList the styleList to set + */ + public void setStyleList(String styleList) { + this.styleList = styleList; + } + + /** + * @return the styleEdit + */ + public String getStyleEdit() { + return styleEdit; + } + + /** + * @param styleEdit the styleEdit to set + */ + public void setStyleEdit(String styleEdit) { + this.styleEdit = styleEdit; + } + + /** + * @return the collapsed + */ + public boolean isCollapsed() { + return collapsed; + } + + /** + * @param collapsed the collapsed to set + */ + public void setCollapsed(boolean collapsed) { + this.collapsed = collapsed; + } + + /** + * @return the optional + */ + public boolean isOptional() { + return optional; + } + + /** + * @param optional the optional to set + */ + public void setOptional(boolean optional) { + this.optional = optional; + } + + /** + * @return the vascEntryFieldIds + */ + public List getVascEntryFieldIds() { + return vascEntryFieldIds; + } + + /** + * @param vascEntryFieldIds the vascEntryFieldIds to set + */ + public void addVascEntryFieldId(String vascEntryFieldId) { + vascEntryFieldIds.add(vascEntryFieldId); + } + + /** + * @param vascEntryFieldIds the vascEntryFieldIds to set + */ + public void removeVascEntryFieldId(String vascEntryFieldId) { + vascEntryFieldIds.remove(vascEntryFieldId); + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/AddRowAction.java b/src/com/idcanet/vasc/impl/actions/AddRowAction.java index 5db3ed7..613c029 100644 --- a/src/com/idcanet/vasc/impl/actions/AddRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/AddRowAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.impl.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.RowVascAction; @@ -43,7 +43,7 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction { setImage("vasc.action.add.image"); } - public void doRowAction(VascTable table,Object rowObject) throws Exception { - table.getVascViewRenderer().renderEdit(null); + public void doRowAction(VascEntry enty,Object rowObject) throws Exception { + enty.getVascFrontend().renderEdit(null); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java b/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java index 4cee71d..14901b5 100644 --- a/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java @@ -29,18 +29,18 @@ package com.idcanet.vasc.impl.actions; import java.io.OutputStream; import java.io.PrintWriter; -import com.idcanet.vasc.core.VascDataExporter; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.entry.VascEntryExporter; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction; -import com.idcanet.vasc.core.column.VascTableColumn; /** * * @author Willem Cazander * @version 1.0 Mar 30, 2007 */ -public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascDataExporter { +public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter { public CSVExportGlobalAction() { setName("vasc.action.csv.name"); @@ -48,20 +48,20 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV setImage("vasc.action.csv.image"); } - public void doGlobalAction(VascTable table) throws Exception { - table.getVascViewRenderer().renderExport(this); + public void doGlobalAction(VascEntry entry) throws Exception { + entry.getVascFrontend().renderExport(this); } - public void doExport(OutputStream out,VascTable table) throws Exception { + public void doExport(OutputStream out,VascEntry entry) throws Exception { PrintWriter p = new PrintWriter(out); p.write("# csv\n"); - for (VascTableColumn c:table.getTableColumns()) { + for (VascEntryField c:entry.getVascEntryFields()) { p.write(c.getName()+"\t"); } p.write("\n"); - for (Object o:table.getTableData()) { - for (VascTableColumn c:table.getTableColumns()) { - p.write(c.getVascColumnValue().getValue(c, o)+"\t"); + for (Object o:entry.getEntryDataList()) { + for (VascEntryField c:entry.getVascEntryFields()) { + p.write(c.getVascEntryFieldValue().getValue(c, o)+"\t"); } p.write("\n"); p.flush(); @@ -69,4 +69,12 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV p.write("# end\n"); p.flush(); } + + public String getMineType() { + return "csv"; + } + + public String getType() { + return "csv"; + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java index d1d665f..5734e1d 100644 --- a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.impl.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.RowVascAction; @@ -43,10 +43,10 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction setImage("vasc.action.del.image"); } - public void doRowAction(VascTable table,Object rowObject) throws Exception { + public void doRowAction(VascEntry entry,Object rowObject) throws Exception { if (rowObject==null) { return; } - table.getVascViewRenderer().renderDelete(rowObject); + entry.getVascFrontend().renderDelete(rowObject); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/EditRowAction.java b/src/com/idcanet/vasc/impl/actions/EditRowAction.java index 70f70dc..eafab35 100644 --- a/src/com/idcanet/vasc/impl/actions/EditRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/EditRowAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.impl.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.RowVascAction; @@ -44,10 +44,10 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction { } - public void doRowAction(VascTable table,Object rowObject) throws Exception { + public void doRowAction(VascEntry entry,Object rowObject) throws Exception { if (rowObject==null) { return; } - table.getVascViewRenderer().renderEdit(rowObject); + entry.getVascFrontend().renderEdit(rowObject); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java b/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java index 2d1542f..e7390a9 100644 --- a/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java @@ -26,7 +26,7 @@ package com.idcanet.vasc.impl.actions; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction; @@ -44,7 +44,7 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa } - public void doGlobalAction(VascTable table) throws Exception { - table.getVascTableController().refreshData(table); // this wil also fire the event + public void doGlobalAction(VascEntry entry) throws Exception { + entry.get.refreshData(table); // this wil also fire the event } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java b/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java index 73a9853..599c5c7 100644 --- a/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java @@ -29,18 +29,18 @@ package com.idcanet.vasc.impl.actions; import java.io.OutputStream; import java.io.PrintWriter; -import com.idcanet.vasc.core.VascDataExporter; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.actions.AbstractVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction; -import com.idcanet.vasc.core.column.VascTableColumn; +import com.idcanet.vasc.core.entry.VascEntryExporter; /** * * @author Willem Cazander * @version 1.0 Mar 30, 2007 */ -public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascDataExporter { +public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter { public XMLExportGlobalAction() { setName("vasc.action.xml.name"); @@ -48,18 +48,18 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV setImage("vasc.action.xml.image"); } - public void doGlobalAction(VascTable table) throws Exception { - table.getVascViewRenderer().renderExport(this); + public void doGlobalAction(VascEntry entry) throws Exception { + entry.getVascFrontend().renderExport(this); } - public void doExport(OutputStream out,VascTable table) throws Exception { + public void doExport(OutputStream out,VascEntry entry) throws Exception { PrintWriter p = new PrintWriter(out); p.write("\n"); p.write("\n"); - for (Object o:table.getTableData()) { - for (VascTableColumn c:table.getTableColumns()) { + for (Object o:entry.getEntryDataList()) { + for (VascEntryField c:entry.getVascEntryFields()) { p.write(""); - p.write(""+c.getVascColumnValue().getValue(c, o)); + p.write(""+c.getVascEntryFieldValue().getValue(c, o)); p.write("\n"); } p.flush(); @@ -67,4 +67,12 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV p.write("\n"); p.flush(); } + + public String getMineType() { + return "text/xml"; + } + + public String getType() { + return "xml"; + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java b/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java new file mode 100644 index 0000000..e717e0b --- /dev/null +++ b/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java @@ -0,0 +1,95 @@ +/* + * 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.entry; + +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +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 BeanPropertyVascEntryFieldValue implements VascEntryFieldValue { + + private String property = null; + + private DefaultElementParameterHelper helper = null; + + public BeanPropertyVascEntryFieldValue() { + helper = new DefaultElementParameterHelper(); + } + public BeanPropertyVascEntryFieldValue(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(VascEntryField 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(VascEntryField 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/BeanVascRecordCreator.java b/src/com/idcanet/vasc/impl/entry/BeanVascEntryRecordCreator.java similarity index 83% rename from src/com/idcanet/vasc/impl/BeanVascRecordCreator.java rename to src/com/idcanet/vasc/impl/entry/BeanVascEntryRecordCreator.java index 2a23dde..4075f11 100644 --- a/src/com/idcanet/vasc/impl/BeanVascRecordCreator.java +++ b/src/com/idcanet/vasc/impl/entry/BeanVascEntryRecordCreator.java @@ -24,28 +24,28 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.impl; +package com.idcanet.vasc.impl.entry; -import com.idcanet.vasc.core.VascRecordCreator; -import com.idcanet.vasc.core.VascTable; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.entry.VascEntryRecordCreator; /** * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class BeanVascRecordCreator implements VascRecordCreator { +public class BeanVascEntryRecordCreator implements VascEntryRecordCreator { private Class objectClass = null; - public BeanVascRecordCreator() { + public BeanVascEntryRecordCreator() { } - public BeanVascRecordCreator(Class objectClass) { + public BeanVascEntryRecordCreator(Class objectClass) { setObjectClass(objectClass); } - public Object newRecord(VascTable table) throws Exception { + public Object newRecord(VascEntry entry) throws Exception { return objectClass.newInstance(); } diff --git a/src/com/idcanet/vasc/impl/DefaultVascTextValue.java b/src/com/idcanet/vasc/impl/entry/DefaultVascEntryResourceResolver.java similarity index 90% rename from src/com/idcanet/vasc/impl/DefaultVascTextValue.java rename to src/com/idcanet/vasc/impl/entry/DefaultVascEntryResourceResolver.java index 1d31606..7290869 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascTextValue.java +++ b/src/com/idcanet/vasc/impl/entry/DefaultVascEntryResourceResolver.java @@ -24,16 +24,16 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.impl; +package com.idcanet.vasc.impl.entry; -import com.idcanet.vasc.core.VascTextValue; +import com.idcanet.vasc.core.entry.VascEntryResourceResolver; /** * * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class DefaultVascTextValue implements VascTextValue { +public class DefaultVascEntryResourceResolver implements VascEntryResourceResolver { public String getKeyMapping(String key) { return key; diff --git a/src/com/idcanet/vasc/validators/VascDateFuture.java b/src/com/idcanet/vasc/validators/VascDateFuture.java new file mode 100644 index 0000000..3a23479 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascDateFuture.java @@ -0,0 +1,45 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascDateFuture { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/VascDate.java b/src/com/idcanet/vasc/validators/VascDateFutureValidator.java similarity index 80% rename from src/com/idcanet/vasc/core/ui/VascDate.java rename to src/com/idcanet/vasc/validators/VascDateFutureValidator.java index 5961a1d..6d84a05 100644 --- a/src/com/idcanet/vasc/core/ui/VascDate.java +++ b/src/com/idcanet/vasc/validators/VascDateFutureValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007 IDCA. All rights reserved. + * Copyright 2004-2008 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: @@ -24,19 +24,20 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core.ui; - -import com.idcanet.vasc.core.VascTable; - +package com.idcanet.vasc.validators; /** + * Validates * * @author Willem Cazander - * @version 1.0 Aug 12, 2007 + * @version 1.0 Sep 5, 2008 */ -public class VascDate extends VascUIComponentImplLoader { - - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - return loadAndCreateComponent(this, table, model, gui); +public class VascDateFutureValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascDatePast.java b/src/com/idcanet/vasc/validators/VascDatePast.java new file mode 100644 index 0000000..de2912c --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascDatePast.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascDatePast { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascDatePastValidator.java b/src/com/idcanet/vasc/validators/VascDatePastValidator.java new file mode 100644 index 0000000..97963e8 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascDatePastValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascDatePastValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascIntSize.java b/src/com/idcanet/vasc/validators/VascIntSize.java new file mode 100644 index 0000000..f96d5d5 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascIntSize.java @@ -0,0 +1,56 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascIntSize { + + /** + * The minimal size + * @return + */ + int min() default 0; + + /** + * The maximum size + * @return + */ + int max() default 0; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascIntSizeValidator.java b/src/com/idcanet/vasc/validators/VascIntSizeValidator.java new file mode 100644 index 0000000..86aee99 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascIntSizeValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascIntSizeValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascLongSize.java b/src/com/idcanet/vasc/validators/VascLongSize.java new file mode 100644 index 0000000..aa11134 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascLongSize.java @@ -0,0 +1,56 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascLongSize { + + /** + * The minimal size + * @return + */ + long min() default 0; + + /** + * The maximum size + * @return + */ + long max() default 0; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascLongSizeValidator.java b/src/com/idcanet/vasc/validators/VascLongSizeValidator.java new file mode 100644 index 0000000..12bb5a7 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascLongSizeValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascLongSizeValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascObjectNotNull.java b/src/com/idcanet/vasc/validators/VascObjectNotNull.java new file mode 100644 index 0000000..fbffd31 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascObjectNotNull.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2006 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascObjectNotNull { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascObjectNotNullValidator.java b/src/com/idcanet/vasc/validators/VascObjectNotNullValidator.java new file mode 100644 index 0000000..838f1fe --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascObjectNotNullValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascObjectNotNullValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascObjectNull.java b/src/com/idcanet/vasc/validators/VascObjectNull.java new file mode 100644 index 0000000..5a0bbab --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascObjectNull.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascObjectNull { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascObjectNullValidator.java b/src/com/idcanet/vasc/validators/VascObjectNullValidator.java new file mode 100644 index 0000000..43fba5f --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascObjectNullValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascObjectNullValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringEmail.java b/src/com/idcanet/vasc/validators/VascStringEmail.java new file mode 100644 index 0000000..60a0e9a --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringEmail.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascStringEmail { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringEmailValidator.java b/src/com/idcanet/vasc/validators/VascStringEmailValidator.java new file mode 100644 index 0000000..5ef301d --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringEmailValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascStringEmailValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringLength.java b/src/com/idcanet/vasc/validators/VascStringLength.java new file mode 100644 index 0000000..bb2b1e3 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringLength.java @@ -0,0 +1,56 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascStringLength { + + /** + * The minimal length + * @return + */ + int min() default 0; + + /** + * The maximum length + * @return + */ + int max() default 0; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringLengthValidator.java b/src/com/idcanet/vasc/validators/VascStringLengthValidator.java new file mode 100644 index 0000000..3a16c7f --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringLengthValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascStringLengthValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringRegex.java b/src/com/idcanet/vasc/validators/VascStringRegex.java new file mode 100644 index 0000000..2824a83 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringRegex.java @@ -0,0 +1,50 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Mar 14, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascStringRegex { + + /** + * The regex to match on the String field + * @return + */ + String regex(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringRegexValidator.java b/src/com/idcanet/vasc/validators/VascStringRegexValidator.java new file mode 100644 index 0000000..0ec23e6 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringRegexValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascStringRegexValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringZipCode.java b/src/com/idcanet/vasc/validators/VascStringZipCode.java new file mode 100644 index 0000000..309389a --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringZipCode.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2008 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.validators; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * An annotation to validate an field of a bean. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascStringZipCode { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringZipCodeValidator.java b/src/com/idcanet/vasc/validators/VascStringZipCodeValidator.java new file mode 100644 index 0000000..73086dd --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascStringZipCodeValidator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2008 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.validators; + +/** + * Validates + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascStringZipCodeValidator implements VascValidator { + + /** + * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) + */ + public boolean isObjectValid(Object object) throws VascValidatorException { + return false; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascValidator.java b/src/com/idcanet/vasc/validators/VascValidator.java new file mode 100644 index 0000000..44c7fd6 --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascValidator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2004-2008 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.validators; + + +/** + * The VascValidator interface + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public interface VascValidator { + + public boolean isObjectValid(Object object) throws VascValidatorException; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascValidatorException.java b/src/com/idcanet/vasc/validators/VascValidatorException.java new file mode 100644 index 0000000..f9e4fef --- /dev/null +++ b/src/com/idcanet/vasc/validators/VascValidatorException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2004-2008 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.validators; + + +/** + * The VascValidator interface + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class VascValidatorException extends Exception { + + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/VascTextField.java b/src/com/idcanet/vasc/validators/VascValidatorField.java similarity index 78% rename from src/com/idcanet/vasc/core/ui/VascTextField.java rename to src/com/idcanet/vasc/validators/VascValidatorField.java index f268122..b4893f2 100644 --- a/src/com/idcanet/vasc/core/ui/VascTextField.java +++ b/src/com/idcanet/vasc/validators/VascValidatorField.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007 IDCA. All rights reserved. + * Copyright 2004-2008 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: @@ -24,19 +24,24 @@ * should not be interpreted as representing official policies, either expressed or implied, of IDCA. */ -package com.idcanet.vasc.core.ui; - -import com.idcanet.vasc.core.VascTable; +package com.idcanet.vasc.validators; /** + * The VascValidator interface * * @author Willem Cazander - * @version 1.0 Aug 12, 2007 + * @version 1.0 Sep 5, 2008 */ -public class VascTextField extends VascUIComponentImplLoader implements VascUIComponent { +public class VascValidatorField { + + final private String propertyName = null; + final private String message = null; + final private Object value = null; + final private Class beanClass = null; + final private Object beanObject = null; - public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception { - return loadAndCreateComponent(this, table, model, gui); + public VascValidatorField() { + } } \ No newline at end of file diff --git a/tests/com/idcanet/vasc/SwingTest.java b/tests/com/idcanet/vasc/SwingTest.java index 2d985b0..95607c3 100644 --- a/tests/com/idcanet/vasc/SwingTest.java +++ b/tests/com/idcanet/vasc/SwingTest.java @@ -32,8 +32,7 @@ import java.util.logging.LogManager; import javax.swing.JFrame; import javax.swing.JPanel; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.impl.swing.SwingVascViewRenderer; +import com.idcanet.vasc.core.VascEntry; import junit.framework.TestCase; @@ -55,6 +54,15 @@ public class SwingTest extends TestCase { public void tearDown() throws Exception { } + /* + + - default view field + - Admin fields and order + - Admin field groups -> 'collapse + - List filters auto by type + - search fields + + */ public void testAll() throws Exception { JFrame.setDefaultLookAndFeelDecorated(false); @@ -75,6 +83,8 @@ public class SwingTest extends TestCase { // render render.initTable(table); + //table.getTableColumns().get(0).set + //render.renderEdit(table.getTableData().get(0)); render.renderView(); diff --git a/tests/com/idcanet/vasc/TestModelVascDataSource.java b/tests/com/idcanet/vasc/TestModelVascDataSource.java index 97847e9..f35198e 100644 --- a/tests/com/idcanet/vasc/TestModelVascDataSource.java +++ b/tests/com/idcanet/vasc/TestModelVascDataSource.java @@ -30,7 +30,11 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.idcanet.vasc.core.AbstractVascDataSource; +import com.idcanet.vasc.core.AbstractVascBackend; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.core.entry.VascEntryRecordCreator; import com.idcanet.vasc.core.ui.VascSelectItem; import com.idcanet.vasc.core.ui.VascSelectItemModel; import com.idcanet.vasc.models.TestModel; @@ -40,7 +44,7 @@ import com.idcanet.vasc.models.TestModel; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class TestModelVascDataSource extends AbstractVascDataSource implements VascSelectItemModel { +public class TestModelVascDataSource extends AbstractVascBackend implements VascSelectItemModel { private List testModels = null; @@ -93,4 +97,12 @@ public class TestModelVascDataSource extends AbstractVascDataSource implements V } return res; } + + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { + return null; + } + + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { + return null; + } } \ No newline at end of file diff --git a/tests/com/idcanet/vasc/TestTable.java b/tests/com/idcanet/vasc/TestTable.java index e6f0971..597763f 100644 --- a/tests/com/idcanet/vasc/TestTable.java +++ b/tests/com/idcanet/vasc/TestTable.java @@ -28,13 +28,11 @@ package com.idcanet.vasc; import java.util.Date; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.column.VascAnnotationTableColumn; -import com.idcanet.vasc.core.column.VascTableColumn; -import com.idcanet.vasc.core.ui.VascColorChooser; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.ui.VascList; -import com.idcanet.vasc.core.ui.VascTextField; -import com.idcanet.vasc.impl.BeanVascRecordCreator; +import com.idcanet.vasc.impl.DefaultVascEntry; +import com.idcanet.vasc.impl.DefaultVascEntryField; import com.idcanet.vasc.impl.DefaultVascTableController; import com.idcanet.vasc.impl.actions.AddRowAction; import com.idcanet.vasc.impl.actions.CSVExportGlobalAction; @@ -42,7 +40,8 @@ import com.idcanet.vasc.impl.actions.DeleteRowAction; import com.idcanet.vasc.impl.actions.EditRowAction; import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction; import com.idcanet.vasc.impl.actions.XMLExportGlobalAction; -import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue; +import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator; +import com.idcanet.vasc.impl.entry.BeanPropertyVascEntryFieldValue; import com.idcanet.vasc.models.TestModel; @@ -53,7 +52,7 @@ import com.idcanet.vasc.models.TestModel; */ public class TestTable { - static public VascTable getVascTable() throws Exception { + static public VascEntry getVascTable() throws Exception { // define query /* @@ -67,69 +66,70 @@ public class TestTable { TestModelVascDataSource data = new TestModelVascDataSource(); // config table - VascTable table = new VascTable(); - table.setName("Testje"); - table.setHeaderName("Test Table enzo"); - table.setHeaderToolTip("Met een hele coole tooltip"); - table.setHeaderImage("/resources/images/gabelfresser.gif"); - table.setHelpId("someKey"); - table.setVascTableController(new DefaultVascTableController()); - table.setVascDataSource(data); + VascEntry entry = new DefaultVascEntry(); + entry.setName("Testje"); + entry.setHeaderName("Test Table enzo"); + entry.setHeaderDescription("Met een hele coole tooltip"); + entry.setHeaderImage("/resources/images/gabelfresser.gif"); + entry.setHelpId("someKey"); + //entry.setVascTableController(new DefaultVascTableController()); + entry.setVascBackend(data); //table.setVascTextValue(new DefaultVascTextValue()); - table.setVascTextValue(new VascI18nTextValue()); - table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class)); - table.addRowActions(new AddRowAction()); - table.addRowActions(new EditRowAction()); - table.addRowActions(new DeleteRowAction()); + entry.setVascEntryResourceResolver(new VascI18nTextValue()); + + // entry.setVascEntryRecordCreator(new BeanVascEntryRecordCreator(TestModel.class)); + entry.addRowAction(new AddRowAction()); + entry.addRowAction(new EditRowAction()); + entry.addRowAction(new DeleteRowAction()); - table.addGlobalActions(new XMLExportGlobalAction()); - table.addGlobalActions(new CSVExportGlobalAction()); + entry.addGlobalAction(new XMLExportGlobalAction()); + entry.addGlobalAction(new CSVExportGlobalAction()); //table.addGlobalActions(new HTMLExportGlobalAction()); - table.addGlobalActions(new RefreshDataGlobalAction()); + entry.addGlobalAction(new RefreshDataGlobalAction()); //table.addUserOptions(userOption); //table.addColumnActions(new GraphColumnAction()); - VascTableColumn column = new VascTableColumn(); - column.setName("test"); - column.setToolTip("tooltip"); - column.setDefaultValue("DEFFFFFF"); - column.setHelpId("helpColumnKey"); - column.setImage("/META-INF/images/silk/png/tick.png"); - column.setWidth(400); - column.setVascUIComponent(new VascTextField()); - // column.setVascColumnRenderer(new DefaultVascColumnRenderer()); - column.setVascColumnValue(new BeanPropertyVascColumnValue("name")); - table.addTableColumns(column); + VascEntryField field = new DefaultVascEntryField(); + field.setName("test"); + field.setDescription("tooltip"); + field.setDefaultValue("DEFFFFFF"); + field.setHelpId("helpColumnKey"); + field.setImage("/META-INF/images/silk/png/tick.png"); + field.setVascEntryFieldType(vascEntryFieldType) + field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name")); + entry.addVascEntryField(field); - column = new VascAnnotationTableColumn("description"); - table.addTableColumns(column); + /* + field = new VascAnnotationTableColumn("description"); + entry.addVascField(field); - column = new VascAnnotationTableColumn("active"); - column.setDefaultValue(true); - table.addTableColumns(column); + field = new VascAnnotationTableColumn("active"); + field.setDefaultValue(true); + entry.addVascField(field); - column = new VascAnnotationTableColumn("date"); - column.setDefaultValue(new Date()); - table.addTableColumns(column); + field = new VascAnnotationTableColumn("date"); + field.setDefaultValue(new Date()); + entry.addVascField(field); - column = new VascAnnotationTableColumn("testModel"); + field = new VascAnnotationTableColumn("testModel"); VascList list = new VascList(); list.setVascSelectItemModel(data); - column.setVascUIComponent(list); - table.addTableColumns(column); + field.setVascUIComponent(list); + entry.addVascField(field); - column = new VascAnnotationTableColumn("hexColor"); - column.setDefaultValue("#FF3355"); - VascColorChooser ui = new VascColorChooser(); - ui.setHexSwingEncoding(true); - column.setVascUIComponent(ui); - table.addTableColumns(column); + field = new VascAnnotationTableColumn("hexColor"); + field.setDefaultValue("#FF3355"); + //VascColorChooser ui = new VascColorChooser(); + //ui.setHexSwingEncoding(true); + //field.setVascUIComponent(ui); + entry.addVascField(field); + */ - return table; + return entry; } } \ No newline at end of file diff --git a/tests/com/idcanet/vasc/VascI18nTextValue.java b/tests/com/idcanet/vasc/VascI18nTextValue.java index 5567731..a796a7c 100644 --- a/tests/com/idcanet/vasc/VascI18nTextValue.java +++ b/tests/com/idcanet/vasc/VascI18nTextValue.java @@ -31,14 +31,15 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.logging.Logger; -import com.idcanet.vasc.core.VascTextValue; +import com.idcanet.vasc.core.entry.VascEntryResourceResolver; + /** * * @author Willem Cazander * @version 1.0 Aug 2, 2007 */ -public class VascI18nTextValue implements VascTextValue { +public class VascI18nTextValue implements VascEntryResourceResolver { private String getKeyMapping(String key) { diff --git a/tests/com/idcanet/vasc/models/TestModel.java b/tests/com/idcanet/vasc/models/TestModel.java index 8640982..ece5fcb 100644 --- a/tests/com/idcanet/vasc/models/TestModel.java +++ b/tests/com/idcanet/vasc/models/TestModel.java @@ -31,6 +31,7 @@ import java.util.Date; import org.hibernate.validator.NotNull; import org.hibernate.validator.Max; +import org.w3c.dom.Node; import com.idcanet.vasc.annotations.VascColumnWidth; import com.idcanet.vasc.annotations.VascDefaultValue; @@ -39,6 +40,9 @@ import com.idcanet.vasc.annotations.VascImage; import com.idcanet.vasc.annotations.VascModelReference; import com.idcanet.vasc.annotations.VascName; import com.idcanet.vasc.annotations.VascToolTip; +import com.idcanet.vasc.validator.VascDateFuture; +import com.idcanet.vasc.validator.VascObjectNotNull; +import com.idcanet.vasc.validator.VascStringLength; /** * TestModel @@ -57,10 +61,12 @@ public class TestModel { private Date date = null; private TestModel testModel = null; private String hexColor = null; + private Node nonEditorField = null; /** * @return the date */ + @VascDateFuture public Date getDate() { return date; } @@ -83,6 +89,8 @@ public class TestModel { @VascImage(image="/resources/images/gabelfresser.gif") @NotNull @Max(value=10) + @VascObjectNotNull + @VascStringLength(max=10) public String getDescription() { return description; } @@ -125,7 +133,7 @@ public class TestModel { @VascImage(image="/resources/images/gabelfresser.gif") @VascModelReference @NotNull - @Max(value=10) + @VascObjectNotNull public TestModel getTestModel() { return testModel; } diff --git a/tests/resources/vasc/tables.xml b/tests/resources/vasc/tables.xml new file mode 100644 index 0000000..73610a8 --- /dev/null +++ b/tests/resources/vasc/tables.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + select id,name,blog_status_id,description,slug from blog_post + update (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=? + instert into (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=? + delete from blog_post where id=? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (&(objectClass=sudoRole)) + ${baseDn},cn=%s + sudoRole,top + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + LIMIT + + + + + + OFFSET + + + + + + + + + + SELECT + USERS.USERNAME AS USERNAME + USERS.PASSWD AS PASSWORD + FROM + USERS + + Bla bla + Also see this site http://www.google.com + + + + + + + + + AND role is in + + + + + + + +
\ No newline at end of file