2
0
Fork 0

[svn r364] WIP for move to maven2

This commit is contained in:
willemc 2008-12-07 06:17:48 +01:00
parent 8fc495c6b6
commit 818ed10649
173 changed files with 275 additions and 45 deletions

View file

@ -0,0 +1,64 @@
/*
* 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;
import java.io.InputStream;
import java.util.logging.LogManager;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.impl.type.FieldTypeParser;
import junit.framework.TestCase;
/**
* Tests a simple x4o xml language.
*
* @author Willem Cazander
* @version 1.0 Jul 24, 2006
*/
public class FieldTypesTest extends TestCase {
public void setUp() throws Exception {
// enable all logs
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
LogManager.getLogManager().readConfiguration( loggingProperties );
loggingProperties.close();
}
public void tearDown() throws Exception {
}
public void testParse() throws Exception {
FieldTypeParser p = new FieldTypeParser();
p.parseVascFieldTypes();
System.out.println("Got types;");
for (VascEntryFieldType t:p.getTypes()) {
System.out.println("t= "+t.getId());
}
}
}

View file

@ -0,0 +1,86 @@
/*
* 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;
import java.io.InputStream;
import java.util.logging.LogManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.idcanet.vasc.frontends.swt.SwtVascFrontend;
import junit.framework.TestCase;
/**
* Tests a simple x4o xml language.
*
* @author Willem Cazander
* @version 1.0 Jul 24, 2006
*/
public class SWTTest extends TestCase {
public void setUp() throws Exception {
// enable all logs
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
LogManager.getLogManager().readConfiguration( loggingProperties );
loggingProperties.close();
// load xtes queries
}
public void tearDown() throws Exception {
}
public void testAll() throws Exception {
// get GUI
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Vasc Test - Swt");
// define redering and render
SwtVascFrontend render = new SwtVascFrontend(shell);
render.initEntry(TestTable.getVascTable());
render.renderView();
// view
shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in event queue
display.sleep();
}
}
display.dispose();
}
}

View file

@ -0,0 +1,117 @@
/*
* 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;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.InputStream;
import java.util.logging.LogManager;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.frontends.swing.SwingVascFrontend;
import junit.framework.TestCase;
/**
* Tests a simple x4o xml language.
*
* @author Willem Cazander
* @version 1.0 Jul 24, 2006
*/
public class SwingTest extends TestCase {
public void setUp() throws Exception {
// enable all logs
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
LogManager.getLogManager().readConfiguration( loggingProperties );
loggingProperties.close();
}
public void tearDown() throws Exception {
}
public void testAll() throws Exception {
JFrame.setDefaultLookAndFeelDecorated(false);
VascEntry entry = TestTable.getVascTable();
JFrame frame = viewEntry(entry);
while (frame.isVisible()) {
Thread.sleep(1000);
}
}
public JFrame viewEntry(final VascEntry entry) throws Exception {
// get GUI
JFrame frame = new JFrame();
frame.setTitle("Vasc Test - Swing - "+entry.getName());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null);
JMenuBar menubar = new JMenuBar();
JMenu vascMenu = new JMenu("Vasc Entries");
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryIds()) {
JMenuItem item = new JMenuItem(id);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(id);
TestTable.fill(ee,entry.getVascFrontendData().getVascController());
viewEntry(ee);
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
vascMenu.add(item);
}
menubar.add(vascMenu);
frame.setJMenuBar(menubar);
// define redering
JPanel panel = new JPanel();
SwingVascFrontend render = new SwingVascFrontend(panel);
frame.add(panel);
// render
render.initEntry(entry);
render.renderView();
// view
frame.pack();
frame.setVisible(true);
return frame;
}
}

View file

@ -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;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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.impl.entry.BeanPropertyVascEntryFieldValue;
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
import com.idcanet.vasc.models.TestModel;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class TestModelVascDataSource extends AbstractVascBackend implements VascSelectItemModel {
private List<Object> testModels = null;
public TestModelVascDataSource() {
testModels = new ArrayList<Object>(2);
TestModel t = new TestModel();
t.setDate(new Date());
t.setDescription("yoyo test");
t.setName("this Name");
t.setPrice(34.1f);
t.setActive(true);
t.setHexColor("#FF66EE");
testModels.add(t);
t = new TestModel();
t.setDate(new Date());
t.setDescription("Model2 test");
t.setName("BeanSourde");
t.setPrice(19.2f);
t.setActive(false);
t.setTestModel((TestModel)testModels.get(0));
testModels.add(t);
}
public TestModelVascDataSource(List<Object> testModels) {
this.testModels=testModels;
}
public List<Object> execute() throws Exception {
return testModels;
}
public void persist(Object object) throws Exception {
testModels.add(object);
}
public Object merge(Object object) throws Exception {
if(testModels.contains(object)==false) {
testModels.add(object);
}
return object;
}
public void delete(Object object) throws Exception {
testModels.remove(object);
}
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
}
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
return new BeanVascEntryRecordCreator(TestModel.class);
}
// --- VascSelectItemModel interface
public List<VascSelectItem> getVascSelectItems() {
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
for (Object o:testModels) {
TestModel t = (TestModel)o;
VascSelectItem i = new VascSelectItem(t.getName(),t);
res.add(i);
}
return res;
}
}

View file

@ -0,0 +1,211 @@
/*
* 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;
import java.lang.reflect.Method;
import java.util.Date;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
import com.idcanet.vasc.impl.DefaultVascBackendController;
import com.idcanet.vasc.impl.DefaultVascBackendControllerResolver;
import com.idcanet.vasc.impl.DefaultVascEntryController;
import com.idcanet.vasc.impl.DefaultVascEntryControllerResolver;
import com.idcanet.vasc.impl.DefaultVascFrontendEntryFinalizer;
import com.idcanet.vasc.impl.DefaultVascController;
import com.idcanet.vasc.impl.DefaultVascEntry;
import com.idcanet.vasc.impl.DefaultVascEntryField;
import com.idcanet.vasc.impl.DefaultVascFrontendData;
import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
import com.idcanet.vasc.impl.actions.AddRowAction;
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
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.type.DefaultVascEntryFieldTypeController;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeControllerResolver;
import com.idcanet.vasc.impl.x4o.VascParser;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
public class TestTable {
static VascController getDefaultVascController() throws Exception {
// for test
TestModelVascDataSource backend = new TestModelVascDataSource();
backend.setId("testBackend1");
// config full controller for local jvm use
DefaultVascController c = new DefaultVascController();
DefaultVascBackendControllerResolver vascBackendControllerResolver = new DefaultVascBackendControllerResolver();
DefaultVascBackendController vascBackendController = new DefaultVascBackendController();
vascBackendController.addVascBackend(backend);
vascBackendControllerResolver.setVascBackendController(vascBackendController);
c.setVascBackendControllerResolver(vascBackendControllerResolver);
DefaultVascEntryControllerResolver vascEntryControllerResolver = new DefaultVascEntryControllerResolver();
DefaultVascEntryController vascEntryController = new DefaultVascEntryController();
vascEntryControllerResolver.setVascEntryController(vascEntryController);
c.setVascEntryControllerResolver(vascEntryControllerResolver);
DefaultVascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = new DefaultVascEntryFieldTypeControllerResolver();
DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController();
//vascEntryFieldTypeController.
vascEntryFieldTypeControllerResolver.setVascEntryFieldTypeController(vascEntryFieldTypeController);
c.setVascEntryFieldTypeControllerResolver(vascEntryFieldTypeControllerResolver);
return c;
}
static public void fill(VascEntry entry,VascController c) {
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData();
vascFrontendData.setVascController(c);
VascI18nTextValue vascEntryResourceResolver = new VascI18nTextValue();// new DefaultVascEntryResourceResolver();
vascFrontendData.setVascEntryResourceResolver(vascEntryResourceResolver);
DefaultVascFrontendHelper vascFrontendHelper = new DefaultVascFrontendHelper();
vascFrontendData.setVascFrontendHelper(vascFrontendHelper);
entry.setVascFrontendData(vascFrontendData);
entry.addRowAction(new AddRowAction());
entry.addRowAction(new EditRowAction());
entry.addRowAction(new DeleteRowAction());
entry.addGlobalAction(new XMLExportGlobalAction());
entry.addGlobalAction(new CSVExportGlobalAction());
entry.addGlobalAction(new RefreshDataGlobalAction());
}
static public VascEntry getVascTable() throws Exception {
VascController c = getDefaultVascController();
VascParser parser = new VascParser(c);
parser.parseResource("resources/vasc/tables.xml");
VascEntry entry = parser.getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById("test1");
fill(entry,c);
// config table
//VascEntry entry = new DefaultVascEntry();
//entry.setId("test1");
//entry.setBackendId("testBackend");
/*
//table.addUserOptions(userOption);
//table.addColumnActions(new GraphColumnAction());
VascEntryField field = new DefaultVascEntryField("name");
field.setImage("/META-INF/images/silk/png/tick.png");
entry.addVascEntryField(field);
field = new DefaultVascEntryField("description");
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("EmailField"));
entry.addVascEntryField(field);
field = new DefaultVascEntryField("active");
field.setDefaultValue(true);
entry.addVascEntryField(field);
field = new DefaultVascEntryField("date");
field.setDefaultValue(new Date());
entry.addVascEntryField(field);
field = new DefaultVascEntryField("testModel");
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
field.getVascEntryFieldType().setDataObject(c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend"));
entry.addVascEntryField(field);
field = new DefaultVascEntryField("hexColor");
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ColorField"));
field.setDefaultValue("#FF3355");
entry.addVascEntryField(field);
printEntry(entry);
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
entry = f.finalizeVascEntry(entry,c);
printEntry(entry);
DefaultVascFrontendEntryFinalizer f2 = new DefaultVascFrontendEntryFinalizer();
entry = f2.finalizeVascEntry(entry,c);
//printEntry(entry);
*/
return entry;
}
static void printEntry(VascEntry e) throws Exception {
System.out.println("");
System.out.println("=== Printing entry ===");
System.out.println("");
for (Method m:e.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e, null));
}
System.out.println("");
System.out.println("=== Fields ===");
for (VascEntryField vef:e.getVascEntryFields()) {
System.out.println("=== Field: "+vef.getId());
for (Method m:vef.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef, null));
}
}
}
}

View file

@ -0,0 +1,67 @@
/*
* 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;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
public class VascI18nTextValue implements VascEntryResourceResolver {
private String getKeyMapping(String key) {
return key;
}
public String getTextValue(String key,Object...params) {
return i18n(getKeyMapping(key),params);
}
static private String i18n(String key,Object...params) {
if (key==null) { throw new NullPointerException("key may not be null"); }
try {
String text = ResourceBundle.getBundle("resources.i18n.vasc").getString(key);
if (params != null) {
MessageFormat mf = new MessageFormat(text);
text = mf.format(params, new StringBuffer(), null).toString();
}
return text;
} catch(MissingResourceException e){
Logger.getAnonymousLogger().finer("Missing i18n or non i18n key: "+key);
return key;
}
}
}

View file

@ -0,0 +1,172 @@
/*
* 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.models;
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;
import com.idcanet.vasc.annotations.VascHelpId;
import com.idcanet.vasc.annotations.VascImage;
import com.idcanet.vasc.annotations.VascModelReference;
import com.idcanet.vasc.annotations.VascName;
import com.idcanet.vasc.annotations.VascDescription;
import com.idcanet.vasc.validators.VascDateFuture;
import com.idcanet.vasc.validators.VascObjectNotNull;
import com.idcanet.vasc.validators.VascStringLength;
/**
* TestModel
*
*
* @author Willem Cazander
* @version 1.0 Mar 28, 2007
*/
@VascDescription(key="En een tooltip op het model")
public class TestModel {
private String name = null;
private String description = null;
private Float price = null;
private Boolean active = null;
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;
}
/**
* @param date the date to set
*/
public void setDate(Date date) {
this.date = date;
}
/**
* @return the description
*/
@VascName(key="omscheiving")
@VascDescription(key="De omscheiving")
@VascHelpId(helpId="help.id")
@VascDefaultValue(defaultValue="xxxxx")
@VascColumnWidth(width=200)
@VascImage(image="/resources/images/gabelfresser.gif")
@NotNull
@Max(value=10)
@VascObjectNotNull
@VascStringLength(max=10)
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the price
*/
public Float getPrice() {
return price;
}
/**
* @param price the price to set
*/
public void setPrice(Float price) {
this.price = price;
}
@VascImage(image="/resources/images/gabelfresser.gif")
@VascModelReference
@NotNull
@VascObjectNotNull
public TestModel getTestModel() {
return testModel;
}
public void setTestModel(TestModel testModel) {
this.testModel = testModel;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the hexColor
*/
public String getHexColor() {
return hexColor;
}
/**
* @param hexColor the hexColor to set
*/
public void setHexColor(String hexColor) {
this.hexColor = hexColor;
}
}