2
0
Fork 0

[svn r270] added extra ui layer

This commit is contained in:
willemc 2007-08-11 03:26:58 +02:00
parent b1f6e870a3
commit 56c4fad429
23 changed files with 825 additions and 105 deletions

View file

@ -139,6 +139,11 @@ public class VascAnnotationParser {
if(property==null) {
Annotation anno = beanClass.getAnnotation(annotationType);
if (anno==null) {
// no annotation == no default
if (annotationType.equals(VascDefaultValue.class)) {
return null;
}
// no annotion avaible
if (noAnnotationNullReturn) {
return null;

View file

@ -27,12 +27,15 @@
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;
import com.idcanet.vasc.core.ui.VascUIComponent;
/**
*
@ -58,6 +61,7 @@ public class VascTable {
private List<VascUserOption> userOptions = null;
private String helpId = null;
private VascTableController vascTableController = null;
private Map<Class,Class> uiComponents = null;
public VascTable() {
tableColumns = new ArrayList<VascTableColumn>(6);
@ -66,6 +70,7 @@ public class VascTable {
globalActions = new ArrayList<GlobalVascAction>(6);
tableData = new ArrayList<Object>(6);
userOptions = new ArrayList<VascUserOption>(6);
uiComponents = new HashMap<Class,Class>(6);
}
/**
@ -313,4 +318,12 @@ public class VascTable {
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);
}
}

View file

@ -26,8 +26,6 @@
package com.idcanet.vasc.core;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
@ -45,8 +43,4 @@ public interface VascViewRenderer {
public void renderDelete(Object rowBean) throws Exception;
public void renderExport(VascDataExporter exporter) throws Exception;
public Object defaultColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception;
public Object defaultColumnRenderer(VascTableColumn column,Object gui) throws Exception;
}

View file

@ -27,6 +27,7 @@
package com.idcanet.vasc.core.column;
import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.ui.VascUIComponent;
/**
* Defines an VascTableColumn
@ -47,7 +48,7 @@ public class VascTableColumn {
private VascColumnValue vascColumnValue = null;
private VascColumnRenderer vascColumnRenderer = null;
private VascColumnEditor vascColumnEditor = null;
private VascUIComponent vascUIComponent = null;
private Object columnRenderer = null;
private Object columnEditor = null;
@ -93,14 +94,14 @@ public class VascTableColumn {
/**
* @return the vascColumnEditor
*/
public VascColumnEditor getVascColumnEditor() {
return vascColumnEditor;
public VascUIComponent getVascUIComponent() {
return vascUIComponent;
}
/**
* @param vascColumnEditor the vascColumnEditor to set
*/
public void setVascColumnEditor(VascColumnEditor vascColumnEditor) {
this.vascColumnEditor = vascColumnEditor;
public void setVascUIComponent(VascUIComponent vascUIComponent) {
this.vascUIComponent = vascUIComponent;
}
/**
* @return the vascColumnRenderer

View file

@ -0,0 +1,55 @@
/*
* 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
*/
abstract public class AbstractVascUIComponent implements VascUIComponent {
private VascUIComponent wrapper = null;
abstract public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception;
/**
* @return the wrapper
*/
public VascUIComponent getWrapper() {
return wrapper;
}
/**
* @param wrapper the wrapper to set
*/
public void setWrapper(VascUIComponent wrapper) {
this.wrapper = wrapper;
}
}

View file

@ -0,0 +1,89 @@
/*
* 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.column.VascTableColumn;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public class VascColumnValueModelListener implements VascValueModelListener {
private VascTableColumn vascTableColumn = null;
private Object bean = null;
public VascColumnValueModelListener() {
}
public VascColumnValueModelListener(VascTableColumn vascTableColumn,Object bean) {
setVascTableColumn(vascTableColumn);
setBean(bean);
}
public void valueUpdate(VascValueModel model) {
try {
System.out.println("model bean updating: "+bean);
vascTableColumn.getVascColumnValue().setValue(vascTableColumn, bean, model.getValue());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @return the vascTableColumn
*/
public VascTableColumn getVascTableColumn() {
return vascTableColumn;
}
/**
* @param vascTableColumn the vascTableColumn to set
*/
public void setVascTableColumn(VascTableColumn vascTableColumn) {
this.vascTableColumn = vascTableColumn;
}
/**
* @return the bean
*/
public Object getBean() {
return bean;
}
/**
* @param bean the bean to set
*/
public void setBean(Object bean) {
this.bean = bean;
}
}

View file

@ -24,19 +24,19 @@
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.column;
package com.idcanet.vasc.core.ui;
import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.column.VascColumnRenderer;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
* @version 1.0 Aug 12, 2007
*/
public class DefaultVascColumnRenderer implements VascColumnRenderer {
public class VascDate extends VascUIComponentImplLoader {
public Object createColumnRenderer(VascTableColumn column,Object gui) throws Exception {
return column.getVascTable().getVascViewRenderer().defaultColumnRenderer(column, gui);
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
return loadAndCreateComponent(this, table, model, gui);
}
}

View file

@ -0,0 +1,58 @@
/*
* 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 VascList extends VascUIComponentImplLoader {
private VascSelectItemModel vascSelectItemModel = null;
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
return loadAndCreateComponent(this, table, model, gui);
}
/**
* @return the vascSelectItemModel
*/
public VascSelectItemModel getVascSelectItemModel() {
return vascSelectItemModel;
}
/**
* @param vascSelectItemModel the vascSelectItemModel to set
*/
public void setVascSelectItemModel(VascSelectItemModel vascSelectItemModel) {
this.vascSelectItemModel = vascSelectItemModel;
}
}

View file

@ -0,0 +1,75 @@
/*
* 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;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public class VascSelectItem {
private String label = null;
private Object value = null;
public VascSelectItem() {
}
public VascSelectItem(String label,Object value) {
setLabel(label);
setValue(value);
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(String label) {
this.label = label;
}
/**
* @return the value
*/
public Object getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Object value) {
this.value = value;
}
}

View file

@ -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.core.ui;
import java.util.List;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public interface VascSelectItemModel {
public List<VascSelectItem> getVascSelectItems();
}

View file

@ -24,19 +24,19 @@
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.column;
package com.idcanet.vasc.core.ui;
import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.column.VascColumnEditor;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
* @version 1.0 Aug 12, 2007
*/
public class DefaultVascColumnEditor implements VascColumnEditor {
public class VascTextField extends VascUIComponentImplLoader implements VascUIComponent {
public Object createColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception {
return column.getVascTable().getVascViewRenderer().defaultColumnEditor(column,bean, gui);
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
return loadAndCreateComponent(this, table, model, gui);
}
}

View file

@ -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.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);
}
}

View file

@ -0,0 +1,43 @@
/*
* 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 interface VascUIComponent {
public void setWrapper(VascUIComponent wrapper);
public VascUIComponent getWrapper();
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception;
}

View file

@ -0,0 +1,43 @@
/*
* 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
*/
abstract public class VascUIComponentImplLoader extends AbstractVascUIComponent {
public Object loadAndCreateComponent(VascUIComponent wrapper,VascTable table,VascValueModel model,Object gui) throws Exception {
VascUIComponent comp = (VascUIComponent)table.getUIComponent(wrapper.getClass()).newInstance();
comp.setWrapper(wrapper);
return comp.createComponent(table, model, gui);
}
}

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.core.ui;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public class VascValueModel {
private Object value = null;
private List<VascValueModelListener> listeners = null;
public VascValueModel() {
listeners = new ArrayList<VascValueModelListener>(2);
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
fireListeners();
}
public void addListener(VascValueModelListener l) {
listeners.add(l);
}
public void removeListener(VascValueModelListener l) {
listeners.remove(l);
}
private void fireListeners() {
for (VascValueModelListener l:listeners) {
l.valueUpdate(this);
}
}
}

View file

@ -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.core.ui;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public interface VascValueModelListener {
public void valueUpdate(VascValueModel model);
}

View file

@ -37,9 +37,8 @@ import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.VascTableController;
import com.idcanet.vasc.core.column.VascAnnotationTableColumn;
import com.idcanet.vasc.core.column.VascTableColumn;
import com.idcanet.vasc.core.ui.VascTextField;
import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue;
import com.idcanet.vasc.impl.column.DefaultVascColumnEditor;
import com.idcanet.vasc.impl.column.DefaultVascColumnRenderer;
/**
*
@ -91,11 +90,11 @@ public class DefaultVascTableController implements VascTableController {
c.setImage(vap.getVascImage(table.getVascRecordCreator().getObjectClass(),column.getBeanProperty()));
}
}
if (c.getVascColumnEditor()==null) {
c.setVascColumnEditor(new DefaultVascColumnEditor());
if (c.getVascUIComponent()==null) {
c.setVascUIComponent(new VascTextField());
}
if (c.getVascColumnRenderer()==null) {
c.setVascColumnRenderer(new DefaultVascColumnRenderer());
//c.setVascColumnRenderer(new DefaultVascColumnRenderer());
}
}
}

View file

@ -75,6 +75,13 @@ import com.idcanet.vasc.core.VascViewRenderer;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.column.VascTableColumn;
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
import com.idcanet.vasc.core.ui.VascList;
import com.idcanet.vasc.core.ui.VascTextField;
import com.idcanet.vasc.core.ui.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.impl.swing.ui.SwingList;
import com.idcanet.vasc.impl.swing.ui.SwingTextField;
/**
*
@ -104,19 +111,12 @@ public class SwingVascViewRenderer implements VascViewRenderer {
table.getVascTableController().finalizeVascColumns(table);
table.getVascTableController().finalizeVascTable(table);
table.getVascTableController().refreshData(table);
table.putUIComponent(VascTextField.class, SwingTextField.class);
table.putUIComponent(VascList.class, SwingList.class);
this.table=table;
}
/**
* @see com.idcanet.vasc.core.VascViewRenderer#defaultColumnEditor(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object)
*/
public Object defaultColumnEditor(VascTableColumn column, Object bean, Object gui) throws Exception {
JTextField def = new JTextField();
def.setText(""+column.getVascColumnValue().getValue(column, bean));
((JComponent)gui).add(def);
def.getDocument().addDocumentListener(new TextListener(column,bean) );
return def;
}
public ImageIcon getImageIcon(String imageResource) {
/// TODO hack beter
@ -130,59 +130,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
}
}
class TextListener implements DocumentListener {
private VascTableColumn column = null;
private Object bean = null;
public TextListener(VascTableColumn column,Object bean) {
this.column=column;
this.bean=bean;
}
/**
* @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());
logger.finer("Setting value: "+value);
column.getVascColumnValue().setValue(column, bean, value);
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
/**
* @see com.idcanet.vasc.core.VascViewRenderer#defaultColumnRenderer(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
*/
public Object defaultColumnRenderer(VascTableColumn column, Object gui) throws Exception {
return null;
}
/**
* @see com.idcanet.vasc.core.VascViewRenderer#renderEdit(com.idcanet.vasc.core.VascTable, java.lang.Object)
@ -297,13 +245,19 @@ public class SwingVascViewRenderer implements VascViewRenderer {
try {
table.getVascTableController().initEditObjectColumn(c, bean);
if(c.getVascColumnEditor()==null) {
if(c.getVascUIComponent()==null) {
JLabel valueLabel = new JLabel();
valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean));
c.setColumnEditor(valueLabel);
body.add(valueLabel);
} else {
c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
//c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
VascUIComponent comp = c.getVascUIComponent();
VascValueModel model = new VascValueModel();
model.setValue(c.getVascColumnValue().getValue(c, bean));
model.addListener(new VascColumnValueModelListener(c,bean));
comp.createComponent(table, model, body);
c.setColumnEditor(comp);
}
} catch (Exception e) {
logger.log(Level.WARNING,"Error making column editor: '"+c.getVascColumnValue()+"' error: "+e.getMessage(),e);

View file

@ -0,0 +1,87 @@
/*
* 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.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
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.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public class SwingList extends AbstractVascUIComponent {
public Object createComponent(VascTable table,final VascValueModel model,Object gui) throws Exception {
VascList l = (VascList)getWrapper();
final JComboBox def = new JComboBox(l.getVascSelectItemModel().getVascSelectItems().toArray());
((JComponent)gui).add(def);
def.setRenderer(new MyCellRenderer());
def.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VascSelectItem i = (VascSelectItem)def.getSelectedItem();
System.out.println("Setting value: "+i.getLabel()+" value: "+i.getValue());
model.setValue(i.getValue());
}
});
return def;
}
}
class MyCellRenderer extends JLabel implements ListCellRenderer {
public MyCellRenderer() {
setOpaque(true);
}
public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {
VascSelectItem i = (VascSelectItem)value;
setText(i.getLabel());
return this;
}
}

View file

@ -0,0 +1,96 @@
/*
* 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 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.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 12, 2007
*/
public class SwingTextField extends AbstractVascUIComponent {
public Object createComponent(VascTable table,VascValueModel model,Object gui) throws Exception {
JTextField def = new JTextField();
def.setText(""+model.getValue());
((JComponent)gui).add(def);
def.getDocument().addDocumentListener(new TextListener(model) );
return def;
}
}
class TextListener implements DocumentListener {
private VascValueModel model = null;
public TextListener(VascValueModel model) {
this.model=model;
}
/**
* @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());
System.out.println("Setting value: "+value);
model.setValue(value);
} catch (Exception ee) {
ee.printStackTrace();
}
}
}

View file

@ -271,14 +271,16 @@ public class SwtVascViewRenderer implements VascViewRenderer {
try {
table.getVascTableController().initEditObjectColumn(c, bean);
if(c.getVascColumnEditor()==null) {
//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);
}

View file

@ -31,6 +31,8 @@ import java.util.Date;
import java.util.List;
import com.idcanet.vasc.core.AbstractVascDataSource;
import com.idcanet.vasc.core.ui.VascSelectItem;
import com.idcanet.vasc.core.ui.VascSelectItemModel;
import com.idcanet.vasc.models.TestModel;
/**
@ -38,7 +40,7 @@ import com.idcanet.vasc.models.TestModel;
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class TestModelVascDataSource extends AbstractVascDataSource {
public class TestModelVascDataSource extends AbstractVascDataSource implements VascSelectItemModel {
private List<Object> testModels = null;
@ -81,4 +83,14 @@ public class TestModelVascDataSource extends AbstractVascDataSource {
public void delete(Object object) throws Exception {
testModels.remove(object);
}
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

@ -29,6 +29,8 @@ package com.idcanet.vasc;
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.VascList;
import com.idcanet.vasc.core.ui.VascTextField;
import com.idcanet.vasc.impl.BeanVascRecordCreator;
import com.idcanet.vasc.impl.DefaultVascTableController;
import com.idcanet.vasc.impl.DefaultVascTextValue;
@ -39,8 +41,6 @@ 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.column.DefaultVascColumnEditor;
import com.idcanet.vasc.impl.column.DefaultVascColumnRenderer;
import com.idcanet.vasc.models.TestModel;
import com.idcanet.xtes.core.TemplateStore;
import com.idcanet.xtes.core.XTESParser;
@ -64,6 +64,9 @@ public class TestTable {
Query query = store.getQuery("testUsers2");
*/
TestModelVascDataSource data = new TestModelVascDataSource();
// config table
VascTable table = new VascTable();
table.setName("Testje");
@ -72,7 +75,7 @@ public class TestTable {
table.setHeaderImage("/resources/images/gabelfresser.gif");
table.setHelpId("someKey");
table.setVascTableController(new DefaultVascTableController());
table.setVascDataSource(new TestModelVascDataSource());
table.setVascDataSource(data);
//table.setVascTextValue(new DefaultVascTextValue());
table.setVascTextValue(new VascI18nTextValue());
@ -97,8 +100,8 @@ public class TestTable {
column.setHelpId("helpColumnKey");
column.setImage("/META-INF/images/silk/png/tick.png");
column.setWidth(400);
column.setVascColumnEditor(new DefaultVascColumnEditor());
column.setVascColumnRenderer(new DefaultVascColumnRenderer());
column.setVascUIComponent(new VascTextField());
// column.setVascColumnRenderer(new DefaultVascColumnRenderer());
column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
table.addTableColumns(column);
@ -106,7 +109,11 @@ public class TestTable {
table.addTableColumns(column);
column = new VascAnnotationTableColumn("testModel");
//column.setColumnEditor(columnEditor);
VascList list = new VascList();
list.setVascSelectItemModel(data);
column.setVascUIComponent(list);
table.addTableColumns(column);
return table;
}