2
0
Fork 0

basic slit in multi module project

This commit is contained in:
willem.cazander 2010-09-19 22:02:05 +02:00
parent 029ad96a10
commit f79378dacb
239 changed files with 46 additions and 25213 deletions

View file

@ -0,0 +1,128 @@
/*
* 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 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 testNull() throws Exception {
assertEquals(true, true);
}
public static void main(String[] argu){
JFrame.setDefaultLookAndFeelDecorated(false);
try {
VascEntry entry = TestTable.getVascTable();
SwingTest s = new SwingTest();
JFrame frame = s.viewEntry(entry);
while (frame.isVisible()) {
Thread.sleep(100000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
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().getVascEntryController().getVascEntryIds()) {
JMenuItem item = new JMenuItem(id);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
VascEntry ee = entry.getVascFrontendData().getVascController().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();
// get data
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
// view
frame.pack();
frame.setVisible(true);
return frame;
}
}

View file

@ -0,0 +1,171 @@
/*
* 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.util.Date;
//import org.hibernate.validator.NotNull;
//import org.hibernate.validator.Max;
import com.idcanet.vasc.annotations.VascEntry;
import com.idcanet.vasc.annotations.VascStyle;
import com.idcanet.vasc.annotations.VascDefaultValue;
import com.idcanet.vasc.annotations.VascModelReference;
import com.idcanet.vasc.annotations.VascI18n;
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
*/
@VascEntry(headerName="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
*/
@VascI18n( name="omscheiving",
description="De omscrijving",
image="/resources/images/gabelfresser.gif",
helpId="help.id")
@VascDefaultValue(value="xxxxx")
@VascStyle(sizeList=200)
// @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;
}
// @NotNull
@VascObjectNotNull
@VascModelReference
@VascI18n(image="/resources/images/gabelfresser.gif")
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;
}
}

View file

@ -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;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.idcanet.vasc.core.AbstractVascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
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;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class TestModelVascDataSource extends AbstractVascBackend implements VascSelectItemModel {
private List<Object> testModels = null;
private String nullLabel = null;
private String nullKeyValue = 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(VascBackendState state) throws VascException {
return testModels;
}
public void persist(Object object) throws VascException {
testModels.add(object);
}
public Object merge(Object object) throws VascException {
if(testModels.contains(object)==false) {
testModels.add(object);
}
return object;
}
public void delete(Object object) throws VascException {
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(VascEntry entry) {
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;
}
/**
* @return the nullLabel
*/
public String getNullLabel() {
return nullLabel;
}
/**
* @param nullLabel the nullLabel to set
*/
public void setNullLabel(String nullLabel) {
this.nullLabel = nullLabel;
}
/**
* @return the nullKeyValue
*/
public String getNullKeyValue() {
return nullKeyValue;
}
/**
* @param nullKeyValue the nullKeyValue to set
*/
public void setNullKeyValue(String nullKeyValue) {
this.nullKeyValue = nullKeyValue;
}
}

View file

@ -0,0 +1,152 @@
/*
* 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.File;
import java.io.FileOutputStream;
import java.lang.reflect.Method;
import java.util.Locale;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendControllerLocal;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
import com.idcanet.vasc.impl.DefaultVascFactory;
import com.idcanet.vasc.impl.DefaultVascFrontendData;
import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
import com.idcanet.vasc.impl.VascBackendProxyPaged;
import com.idcanet.vasc.impl.VascBackendProxySearch;
import com.idcanet.vasc.impl.VascBackendProxySort;
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.x4o.VascParser;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
public class TestTable {
static VascController getDefaultVascController() throws Exception {
VascController c = DefaultVascFactory.getDefaultVascController(2288L,"idca.nl","user","admin");
// for test
TestModelVascDataSource backend = new TestModelVascDataSource();
backend.setId("testBackend1");
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
return c;
}
static public void fill(VascEntry entry,VascController vascController) {
VascFrontendData frontendData = DefaultVascFactory.getDefaultVascFrontendData("i18n.vasc", Locale.getDefault());
frontendData.setVascController(vascController);
entry.setVascFrontendData(frontendData);
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
frontendData.getVascEntryState().setVascBackend(backend);
frontendData.getVascEntryState().setVascEntry(entry);
entry.addRowAction(new AddRowAction());
entry.addRowAction(new EditRowAction());
entry.addRowAction(new DeleteRowAction());
entry.addGlobalAction(new XMLExportGlobalAction());
entry.addGlobalAction(new CSVExportGlobalAction());
entry.addGlobalAction(new RefreshDataGlobalAction());
// hackje om deze manuale actions van i18n keys te voorzien;
// this is temp untill x4o templaing
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
try {
f.finalizeVascEntry(entry, vascController);
} catch (VascException e) {
e.printStackTrace();
}
}
static public VascEntry getVascTable() throws Exception {
VascController c = getDefaultVascController();
VascParser parser = new VascParser(c);
File f = File.createTempFile("test-vasc", ".xml");
parser.setDebugOutputStream(new FileOutputStream(f));
parser.parseResource("vasc/tables.xml");
VascEntry entry = parser.getVascController().getVascEntryController().getVascEntryById("test1");
fill(entry,c);
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));
}
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));
}
}
}
}