2
0
Fork 0

[svn r251] fixed annotations , made export stuff work , made edit with simple text element work

This commit is contained in:
willemc 2007-05-19 20:02:27 +02:00
parent 1c47fbffa3
commit 4f25dd082d
21 changed files with 438 additions and 64 deletions

View file

@ -14,5 +14,6 @@
<classpathentry kind="lib" path="lib/idcanet-jmx-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/idcanet-fff-bin.jar"/>
<classpathentry kind="lib" path="lib/hibernate-annotations.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Binary file not shown.

View file

@ -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;
import java.io.OutputStream;
/**
*
* @author Willem Cazander
* @version 1.0 May 19, 2007
*/
public interface VascDataExporter {
public void doExport(OutputStream out,VascTable table) throws Exception;
}

View file

@ -193,6 +193,12 @@ public class VascTable {
* @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);
}

View file

@ -41,6 +41,8 @@ public interface VascTableController {
public void refreshData(VascTable table) throws Exception;
public void handleException(Exception e,VascTable table);
public Object initEditObject(VascTable table,Object object) throws Exception;
public void handleException(Exception e,VascTable table);
}

View file

@ -26,6 +26,8 @@
package com.idcanet.vasc.core;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
@ -37,4 +39,10 @@ public interface VascViewRenderer {
public void renderView(VascTable table) throws Exception;
public void renderEdit(VascTable table,Object rowBean) throws Exception;
public void renderExport(VascTable table,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

@ -33,5 +33,5 @@ package com.idcanet.vasc.core.column;
*/
public interface VascColumnEditor {
public Object createColumnEditor(VascTableColumn column);
public Object createColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception;
}

View file

@ -33,5 +33,5 @@ package com.idcanet.vasc.core.column;
*/
public interface VascColumnRenderer {
public Object createColumnRender(VascTableColumn column);
public Object createColumnRenderer(VascTableColumn column,Object gui) throws Exception;
}

View file

@ -33,5 +33,7 @@ package com.idcanet.vasc.core.column;
*/
public interface VascColumnValue {
public Object getValue(VascTableColumn column,Object record);
public Object getValue(VascTableColumn column,Object record) throws Exception;
public void setValue(VascTableColumn column,Object record,Object value) throws Exception;
}

View file

@ -26,6 +26,8 @@
package com.idcanet.vasc.core.column;
import com.idcanet.vasc.core.VascTable;
/**
* Defines an VascTableColumn
*
@ -50,6 +52,8 @@ public class VascTableColumn {
private Object columnRenderer = null;
private Object columnEditor = null;
private VascTable vascTable = null;
/**
* @return the defaultValue
*/
@ -190,4 +194,18 @@ public class VascTableColumn {
public void setImage(String image) {
this.image = image;
}
/**
* @return the vascTable
*/
public VascTable getVascTable() {
return vascTable;
}
/**
* @param vascTable the vascTable to set
*/
public void setVascTable(VascTable vascTable) {
this.vascTable = vascTable;
}
}

View file

@ -35,6 +35,8 @@ import com.idcanet.vasc.core.VascTableController;
import com.idcanet.vasc.core.column.VascAnnotationTableColumn;
import com.idcanet.vasc.core.column.VascTableColumn;
import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue;
import com.idcanet.vasc.impl.column.DefaultVascColumnEditor;
import com.idcanet.vasc.impl.column.DefaultVascColumnRenderer;
/**
*
@ -75,9 +77,12 @@ public class DefaultVascTableController implements VascTableController {
if (c.getVascColumnValue()==null) {
c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty()));
}
if (c.getVascColumnEditor()==null) {
//c.setVascColumnEditor(new AutoVascColumnEditor(column.getBeanProperty()));
}
}
if (c.getVascColumnEditor()==null) {
c.setVascColumnEditor(new DefaultVascColumnEditor());
}
if (c.getVascColumnRenderer()==null) {
c.setVascColumnRenderer(new DefaultVascColumnRenderer());
}
}
}
@ -103,6 +108,19 @@ public class DefaultVascTableController implements VascTableController {
return result;
}
/**
* @see com.idcanet.vasc.core.VascTableController#initEditObject(com.idcanet.vasc.core.VascTable, java.lang.Object)
*/
public Object initEditObject(VascTable table, Object object) throws Exception {
if (object!=null) {
return object;
}
object = table.getVascRecordCreator().newRecord(table);
return object;
}
/**
* @see com.idcanet.vasc.core.VascTableController#refreshData()
*/

View file

@ -0,0 +1,72 @@
/*
* 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.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.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 CSVExportGlobalAction() {
setName("generic.crud.export.csv.name");
setToolTip("generic.crud.export.csv.tooltip");
setImage("/META-INF/images/silk/png/page_white_excel.png");
}
public void doGlobalAction(VascTable table) throws Exception {
table.getVascViewRenderer().renderExport(table,this);
}
public void doExport(OutputStream out,VascTable table) throws Exception {
PrintWriter p = new PrintWriter(out);
p.write("# csv file\n");
for (VascTableColumn c:table.getTableColumns()) {
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");
}
p.write("\n");
p.flush();
}
p.write("# end\n");
p.flush();
}
}

View file

@ -44,7 +44,7 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa
}
public void doGlobalAction(VascTable table) {
//table.getVascViewRenderer().render
public void doGlobalAction(VascTable table) throws Exception {
table.getVascTableController().refreshData(table);
}
}

View file

@ -26,16 +26,21 @@
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.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 XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction {
public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascDataExporter {
public XMLExportGlobalAction() {
setName("generic.crud.export.xml.name");
@ -43,8 +48,23 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
setImage("/META-INF/images/silk/png/page_white_excel.png");
}
public void doGlobalAction(VascTable table) throws Exception {
table.getVascViewRenderer().renderExport(table,this);
}
public void doGlobalAction(VascTable table) {
//table.getVascViewRenderer().render
public void doExport(OutputStream out,VascTable table) throws Exception {
PrintWriter p = new PrintWriter(out);
p.write("<xml version=\"1.0\"/>\n");
p.write("<data>\n");
for (Object o:table.getTableData()) {
for (VascTableColumn c:table.getTableColumns()) {
p.write("<column name=\""+c.getName()+"\">");
p.write(""+c.getVascColumnValue().getValue(c, o));
p.write("</column>\n");
}
p.flush();
}
p.write("</data>\n");
p.flush();
}
}

View file

@ -39,29 +39,42 @@ public class BeanPropertyVascColumnValue implements VascColumnValue {
private String property = null;
private DefaultElementParameterHelper helper = null;
public BeanPropertyVascColumnValue() {
helper = new DefaultElementParameterHelper();
}
public BeanPropertyVascColumnValue(String property) {
this();
setProperty(property);
}
public Object getValue(VascTableColumn column,Object record) {
/**
* @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
*/
public Object getValue(VascTableColumn column,Object record) throws Exception {
if(getProperty()==null) {
return null;
}
if(getProperty().equals("")) {
return "";
}
DefaultElementParameterHelper helper = new DefaultElementParameterHelper();
try {
return helper.getParameter(record, getProperty());
} catch (Exception e) {
e.printStackTrace();
return "Err";
}
return helper.getParameter(record, getProperty());
}
/**
* @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object)
*/
public void setValue(VascTableColumn column, Object record,Object value) throws Exception {
if(getProperty()==null) {
return;
}
if(getProperty().equals("")) {
return;
}
helper.setParameter(record, getProperty(),value);
}
/**
* @return the property
*/

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.impl.column;
import com.idcanet.vasc.core.column.VascColumnEditor;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class DefaultVascColumnEditor implements VascColumnEditor {
public Object createColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception {
return column.getVascTable().getVascViewRenderer().defaultColumnEditor(column,bean, 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.impl.column;
import com.idcanet.vasc.core.column.VascColumnRenderer;
import com.idcanet.vasc.core.column.VascTableColumn;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class DefaultVascColumnRenderer implements VascColumnRenderer {
public Object createColumnRenderer(VascTableColumn column,Object gui) throws Exception {
return column.getVascTable().getVascViewRenderer().defaultColumnRenderer(column, gui);
}
}

View file

@ -36,7 +36,18 @@ import com.idcanet.vasc.core.column.VascTableColumn;
*/
public class NullVascColumnValue implements VascColumnValue {
public Object getValue(VascTableColumn column,Object record) {
/**
* @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object)
*/
public Object getValue(VascTableColumn column, Object record) throws Exception {
return null;
}
/**
* @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object)
*/
public void setValue(VascTableColumn column, Object record, Object value) throws Exception {
}
}

View file

@ -26,9 +26,13 @@
package com.idcanet.vasc.impl.swt;
import java.awt.TextField;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@ -47,18 +51,22 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.idcanet.fff.SwingImageHelper;
import com.idcanet.vasc.core.VascDataExporter;
import com.idcanet.vasc.core.VascTable;
import com.idcanet.vasc.core.VascUserOption;
import com.idcanet.vasc.core.VascViewRenderer;
@ -82,19 +90,41 @@ public class SwtVascViewRenderer implements VascViewRenderer {
this.parent=parent;
}
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(VascTable table,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(VascTable table,Object object) throws Exception {
logger.info("Rending Edit View");
if (object==null) {
try {
object = table.getVascRecordCreator().newRecord(table);
logger.finest("created: "+object);
} catch (Exception e) {
table.getVascTableController().handleException(e, table);
return;
}
}
table.getVascTableController().initEditObject(table, object);
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Edit","TOITO");
Object result = dialog.open();
@ -216,39 +246,36 @@ public class SwtVascViewRenderer implements VascViewRenderer {
l.setToolTipText(c.getToolTip());
}
if(c.getVascColumnEditor()==null) {
Label valueLabel = new Label(body, SWT.WRAP);
valueLabel.setText(""+c.getVascColumnValue().getValue(c, bean));
} else {
c.getVascColumnEditor().createColumnEditor(c);
}
// SWTComponentFactory.createLabel(body,ba.getValueModel(c.getObjectProperty()),SWT.WRAP);
// continue;
//}
//ValueModel vm = ba.getValueModel(c.getObjectProperty());
//c.getVascColumnEditor().createColumnEditor(c);
try {
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);
}
// set the default value before creating property
/*
if(vm.getValue()==null & c.getDefaultValue()!=null) {
if(c.getVascColumnValue()==null & c.getDefaultValue()!=null) {
try {
logger.finer("Setting default value for: "+c.getName()+" def: "+c.getDefaultValue());
vm.setValue(c.getDefaultValue());
c.getVascColumnValue().setValue(c, bean, c.getDefaultValue());
} catch (Exception e) {
logger.log(Level.WARNING,"Error in setting default value: '"+c.getDefaultValue()+"' error: "+e.getMessage(),e);
}
}
*/
//Control editor = c.getPropertyEditor().createPropertyEditor(body,vm);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
//editor.setLayoutData(gridData);
//c.setTempObjectPropertyControl(editor);
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
@ -279,6 +306,45 @@ public class SwtVascViewRenderer implements VascViewRenderer {
}
}
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(VascTable table) throws Exception {
@ -589,7 +655,12 @@ public class SwtVascViewRenderer implements VascViewRenderer {
public String getColumnText(Object bean, int columnNumber) {
VascTableColumn vtc = table.getTableColumns().get(columnNumber);
if (vtc.getColumnRenderer()==null) {
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
try {
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
} catch (Exception e) {
logger.log(Level.WARNING,"Error in get value: '"+vtc.getVascColumnValue()+"' error: "+e.getMessage(),e);
return "Err";
}
}
// see custem column renderer, so this code will never be called
return "CUSTEM_RENDER";

View file

@ -39,11 +39,14 @@ import com.idcanet.vasc.impl.BeanVascRecordCreator;
import com.idcanet.vasc.impl.DefaultVascTableController;
import com.idcanet.vasc.impl.DefaultVascTextValue;
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.column.BeanPropertyVascColumnValue;
import com.idcanet.vasc.impl.serv5.Serv5HibernateVascDataSource;
import com.idcanet.vasc.impl.column.DefaultVascColumnEditor;
import com.idcanet.vasc.impl.column.DefaultVascColumnRenderer;
import com.idcanet.vasc.impl.swt.SwtVascViewRenderer;
import com.idcanet.vasc.tests.models.TestModel;
import com.idcanet.xtes.core.TemplateStore;
@ -102,9 +105,9 @@ public class SWTTest extends TestCase {
table.addRowActions(new DeleteRowAction());
table.addGlobalActions(new XMLExportGlobalAction());
//table.addGlobalActions(new CSVExportGlobalAction());
table.addGlobalActions(new CSVExportGlobalAction());
//table.addGlobalActions(new HTMLExportGlobalAction());
//table.addGlobalActions(new RefreshGlobalAction());
table.addGlobalActions(new RefreshDataGlobalAction());
//table.addUserOptions(userOption);
@ -116,8 +119,8 @@ public class SWTTest extends TestCase {
column.setDefaultValue("DEFFFFFF");
column.setHelpId("helpColumnKey");
column.setWidth(400);
//column.setVascColumnEditor(new AutoVascColumnEditor("name"));
//column.setVascColumnRenderer(vascColumnRenderer);
column.setVascColumnEditor(new DefaultVascColumnEditor());
column.setVascColumnRenderer(new DefaultVascColumnRenderer());
column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
table.addTableColumns(column);

View file

@ -29,6 +29,9 @@ package com.idcanet.vasc.tests.models;
import java.util.Date;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Max;
import com.idcanet.vasc.annotations.VascColumnWidth;
import com.idcanet.vasc.annotations.VascDefaultValue;
import com.idcanet.vasc.annotations.VascHelpId;
@ -71,6 +74,8 @@ public class TestModel {
@VascHelpId(helpId="help.id")
@VascDefaultValue(defaultValue="xxxxx")
@VascColumnWidth(width=200)
@NotNull
@Max(value=10)
public String getDescription() {
return description;
}