[svn r246] added annotatioins and made some actions
This commit is contained in:
parent
54ca574e58
commit
a4d1ff1c57
|
@ -45,5 +45,7 @@ public @interface VascDefaultValue {
|
|||
/**
|
||||
* The defaultValue of the method
|
||||
*/
|
||||
Class defaultValue();
|
||||
Class defaultValueClass() default Object.class;
|
||||
|
||||
String defaultValue() default "null";
|
||||
}
|
|
@ -42,4 +42,7 @@ public interface VascDataSource {
|
|||
|
||||
public void persist(Object object) throws Exception;
|
||||
|
||||
public Object merge(Object object) throws Exception;
|
||||
|
||||
public void delete(Object object) throws Exception;
|
||||
}
|
|
@ -36,4 +36,5 @@ public interface VascViewRenderer {
|
|||
|
||||
public void renderView(VascTable table);
|
||||
|
||||
public void renderEdit(VascTable table,Object rowBean);
|
||||
}
|
68
src/com/idcanet/vasc/core/actions/AbstractVascAction.java
Normal file
68
src/com/idcanet/vasc/core/actions/AbstractVascAction.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
|
||||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.core.actions;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
abstract public class AbstractVascAction implements VascAction {
|
||||
|
||||
private String name = null;
|
||||
private String toolTip = null;
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* @return the toolTip
|
||||
*/
|
||||
public String getToolTip() {
|
||||
return toolTip;
|
||||
}
|
||||
/**
|
||||
* @param toolTip the toolTip to set
|
||||
*/
|
||||
public void setToolTip(String toolTip) {
|
||||
this.toolTip = toolTip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -36,7 +36,9 @@ import com.idcanet.vasc.core.VascTable;
|
|||
public interface VascAction {
|
||||
|
||||
public String getName();
|
||||
public void setName(String name);
|
||||
public String getToolTip();
|
||||
public void setToolTip(String toolTip);
|
||||
|
||||
public Object createActionObject(VascTable table);
|
||||
//public Object createActionObject(VascTable table);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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.column;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 11, 2007
|
||||
*/
|
||||
public class VascAnnotationTableColumn extends VascTableColumn {
|
||||
|
||||
private String beanProperty = null;
|
||||
|
||||
public VascAnnotationTableColumn() {
|
||||
|
||||
}
|
||||
public VascAnnotationTableColumn(String beanProperty) {
|
||||
setBeanProperty(beanProperty);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the beanProperty
|
||||
*/
|
||||
public String getBeanProperty() {
|
||||
return beanProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param beanProperty the beanProperty to set
|
||||
*/
|
||||
public void setBeanProperty(String beanProperty) {
|
||||
this.beanProperty = beanProperty;
|
||||
}
|
||||
}
|
48
src/com/idcanet/vasc/impl/actions/AddRowAction.java
Normal file
48
src/com/idcanet/vasc/impl/actions/AddRowAction.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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 com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.actions.AbstractVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class AddRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public AddRowAction() {
|
||||
setName("generic.crud.add");
|
||||
setToolTip("generic.toolTip");
|
||||
}
|
||||
|
||||
public void doRowAction(VascTable table,Object rowObject) {
|
||||
table.getVascViewRenderer().renderEdit(table,rowObject);
|
||||
}
|
||||
}
|
52
src/com/idcanet/vasc/impl/actions/DeleteRowAction.java
Normal file
52
src/com/idcanet/vasc/impl/actions/DeleteRowAction.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.actions.AbstractVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public DeleteRowAction() {
|
||||
setName("generic.crud.delete");
|
||||
setToolTip("generic.toolTip");
|
||||
}
|
||||
|
||||
public void doRowAction(VascTable table,Object rowObject) {
|
||||
try {
|
||||
table.getVascDataSource().delete(rowObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
49
src/com/idcanet/vasc/impl/actions/EditRowAction.java
Normal file
49
src/com/idcanet/vasc/impl/actions/EditRowAction.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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 com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.actions.AbstractVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class EditRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public EditRowAction() {
|
||||
setName("generic.crud.edit");
|
||||
setToolTip("generic.toolTip");
|
||||
}
|
||||
|
||||
|
||||
public void doRowAction(VascTable table,Object rowObject) {
|
||||
table.getVascViewRenderer().renderEdit(table,rowObject);
|
||||
}
|
||||
}
|
49
src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java
Normal file
49
src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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 com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.actions.AbstractVascAction;
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction {
|
||||
|
||||
public XMLExportGlobalAction() {
|
||||
setName("generic.crud.export.xml.name");
|
||||
setToolTip("generic.crud.export.xml.tooltip");
|
||||
}
|
||||
|
||||
|
||||
public void doGlobalAction(VascTable table) {
|
||||
//table.getVascViewRenderer().render
|
||||
}
|
||||
}
|
|
@ -77,6 +77,24 @@ public class Serv5HibernateVascDataSource implements VascDataSource {
|
|||
Hibernate3Factory.getSession(getSession()).close();
|
||||
}
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws Exception {
|
||||
try {
|
||||
return Hibernate3Factory.getSession(getSession()).merge(object);
|
||||
} finally {
|
||||
Hibernate3Factory.getSession(getSession()).close();
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Object object) throws Exception {
|
||||
try {
|
||||
Object newObject = Hibernate3Factory.getSession(getSession()).merge(object);
|
||||
Hibernate3Factory.getSession(getSession()).delete(newObject);
|
||||
} finally {
|
||||
Hibernate3Factory.getSession(getSession()).close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the session
|
||||
*/
|
||||
|
|
|
@ -27,32 +27,45 @@
|
|||
package com.idcanet.vasc.impl.swt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.text.TabExpander;
|
||||
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Dialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
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.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.VascUserOption;
|
||||
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;
|
||||
|
||||
|
@ -72,6 +85,177 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
this.parent=parent;
|
||||
}
|
||||
|
||||
public void renderEdit(VascTable table,Object object) {
|
||||
|
||||
logger.info("Rending Edit View");
|
||||
|
||||
if (object==null) {
|
||||
try {
|
||||
object = table.getVascRecordCreator().newRecord(table);
|
||||
logger.finest("created: "+object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//logger.log(Level.WARNING,"Error while creating new: "+crudTable.getRecordClass());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//CrudEditDialog editDialog = new CrudEditDialog(event.display.getActiveShell(),crudTable,element,crudTable.i18n("crud.event.add.title"),crudTable.i18n("crud.event.add.title"));
|
||||
|
||||
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),table,object,"Edit","TOITO");
|
||||
Object result = dialog.open();
|
||||
if(result==null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
result = table.getVascDataSource().merge(object);
|
||||
//FlowstatsPlugin.getDefault().fireModelUpdateListeners(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"EJB Error: "+e.getMessage(),e);
|
||||
} finally {
|
||||
//crudTable.getCrudTableDataSource().fillCrudDataList(crudTable);
|
||||
}
|
||||
}
|
||||
|
||||
public class SwtVascEditDialog extends Dialog {
|
||||
|
||||
private Shell shell = null;
|
||||
private String headerText = null;
|
||||
private String title = null;
|
||||
private Object result = null;
|
||||
private Object bean = null;
|
||||
|
||||
public SwtVascEditDialog (Shell parent,VascTable table,Object bean,String title,String headerText) {
|
||||
super (parent, 0);
|
||||
this.headerText = headerText;
|
||||
this.title = title;
|
||||
this.bean = bean;
|
||||
}
|
||||
public Object open() {
|
||||
shell = new Shell(getParent(), SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
|
||||
shell.setText(title);
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
shell.setLayout(layout);
|
||||
|
||||
Composite header = new Composite(shell, SWT.NONE);
|
||||
GridLayout headerLayout = new GridLayout();
|
||||
headerLayout.numColumns = 6;
|
||||
header.setLayout(headerLayout);
|
||||
header.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite body = new Composite(shell, SWT.NONE);
|
||||
GridLayout bodyLayout = new GridLayout();
|
||||
bodyLayout.numColumns = 1;
|
||||
body.setLayout(bodyLayout);
|
||||
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite footer = new Composite(shell, SWT.NONE);
|
||||
GridLayout footerLayout = new GridLayout();
|
||||
footerLayout.numColumns = 6;
|
||||
footer.setLayout(footerLayout);
|
||||
footer.setLayoutData(new GridData(SWT.NONE));
|
||||
|
||||
//createHeader(header);
|
||||
createBody(body);
|
||||
//createFooter(footer);
|
||||
|
||||
// should be last
|
||||
partCreated();
|
||||
|
||||
shell.pack();
|
||||
shell.open();
|
||||
|
||||
Display display = shell.getDisplay();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
//image.dispose();
|
||||
//closeDialog();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createBody(Composite body) {
|
||||
body.setLayout(new GridLayout(2, true));
|
||||
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
Label l = new Label(body, SWT.WRAP);
|
||||
l.setText(c.getName());
|
||||
|
||||
if(c.getToolTip()!=null) {
|
||||
l.setToolTipText(c.getToolTip());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// set the default value before creating property
|
||||
/*
|
||||
if(vm.getValue()==null & c.getDefaultValue()!=null) {
|
||||
try {
|
||||
logger.finer("Setting default value for: "+c.getName()+" def: "+c.getDefaultValue());
|
||||
vm.setValue(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);
|
||||
}
|
||||
|
||||
// create some spaceing , should replace by seperator
|
||||
new Label(body, SWT.WRAP);
|
||||
new Label(body, SWT.WRAP);
|
||||
|
||||
Button saveButton = new Button(body, SWT.NONE);
|
||||
//saveButton.setImage(crudTable.getImageDescriptor("icons/fam/tick.png").createImage());
|
||||
saveButton.setText("generic.save");
|
||||
saveButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
//if(hasRecordError()) {
|
||||
// return;
|
||||
//}
|
||||
//result = bean;
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
Button cancelButton = new Button(body, SWT.NONE);
|
||||
//cancelButton.setImage(crudTable.getImageDescriptor("icons/fam/cancel.png").createImage());
|
||||
cancelButton.setText("generic.cancel");
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
result = null;
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void renderView(VascTable table) {
|
||||
|
||||
try {
|
||||
|
@ -113,18 +297,50 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
partCreated();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createHeader(Composite header) {
|
||||
logger.finest("Creating header");
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
header.setLayout(layout);
|
||||
header.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Color c = new Color(header.getDisplay(),255,255,255);
|
||||
header.setBackground(c);
|
||||
|
||||
Composite headerBar = new Composite(header, SWT.NONE);
|
||||
//GridLayout headerLayout = new GridLayout();
|
||||
//headerLayout.numColumns = 1;
|
||||
headerBar.setLayout(new FillLayout());
|
||||
//headerBar.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite headerName = new Composite(header, SWT.NONE);
|
||||
GridLayout bodyLayout = new GridLayout();
|
||||
bodyLayout.numColumns = 1;
|
||||
headerName.setLayout(bodyLayout);
|
||||
headerName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
//headerName.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite headerOptions = new Composite(header, SWT.NONE);
|
||||
GridLayout footerLayout = new GridLayout();
|
||||
footerLayout.numColumns = 1;
|
||||
headerOptions.setLayout(footerLayout);
|
||||
//headerOptions.setLayoutData(new GridData(SWT.NONE));
|
||||
headerOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
ToolBar toolBar = new ToolBar(headerBar, SWT.NONE);
|
||||
for (GlobalVascAction action:table.getGlobalActions()) {
|
||||
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
|
||||
item.setText(action.getName());
|
||||
item.setToolTipText(action.getToolTip());
|
||||
item.addSelectionListener(new GlobalActionListener(action));
|
||||
}
|
||||
|
||||
|
||||
Color c = new Color(header.getDisplay(),255,255,255);
|
||||
headerName.setBackground(c);
|
||||
if(table.getHeaderName()!=null) {
|
||||
Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD);
|
||||
Label l = new Label(header, SWT.CENTER);
|
||||
Label l = new Label(headerName, SWT.CENTER);
|
||||
l.setFont(headerFont);
|
||||
l.setText(table.getVascTextValue().getTextValue(table.getHeaderName()));
|
||||
l.setBackground(c);
|
||||
|
@ -149,16 +365,58 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
*/
|
||||
}
|
||||
}
|
||||
class GlobalActionListener extends SelectionAdapter {
|
||||
|
||||
private GlobalVascAction action = null;
|
||||
|
||||
public GlobalActionListener(GlobalVascAction action) {
|
||||
this.action=action;
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
logger.info("Global Action");
|
||||
action.doGlobalAction(table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void createBody(Composite body) {
|
||||
logger.finer("Creating body");
|
||||
|
||||
//final TableViewer tableViewer = JFaceComponentFactory.createTableViewer(body,table.getSelectionInList(),getTableColumns(crudTable),false);
|
||||
// Create the table viewer to display the players
|
||||
final TableViewer tableViewer = new TableViewer(body);
|
||||
final Table table2 = tableViewer.getTable();
|
||||
table2.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
table2.setHeaderVisible(true);
|
||||
table2.setLinesVisible(true);
|
||||
|
||||
table2.addSelectionListener(new SelectionListener() {
|
||||
|
||||
/**
|
||||
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Object data = e.item.getData();
|
||||
logger.info("Slecting data: "+data);
|
||||
table.setSelectedObject(data);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Set the content and label providers
|
||||
tableViewer.setContentProvider(new ListConverterContentProvider());
|
||||
|
@ -187,9 +445,9 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
dir = SWT.UP;
|
||||
}
|
||||
// sort the data based on column and direction
|
||||
String prop = (String)currentColumn.getData("PROP");
|
||||
//String prop = (String)currentColumn.getData("PROP");
|
||||
|
||||
List l = new ArrayList(10);
|
||||
//List l = new ArrayList(10);
|
||||
/*
|
||||
for(int i=0;i<crudTable.getSelectionInList().getSize();i++) {
|
||||
l.add(crudTable.getSelectionInList().getElementAt(i));
|
||||
|
@ -233,13 +491,30 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
//action.createActionObject(table);
|
||||
|
||||
//Button ton = new Button(footer, SWT.NONE);
|
||||
//addButton.setText(crudTable.i18n("generic.add"));
|
||||
//addButton.setImage(crudTable.getImageDescriptor("icons/fam/table_add.png").createImage());
|
||||
//addButton.addSelectionListener(new AddEvent(crudTable));
|
||||
//action.
|
||||
Button actionButton = new Button(footer, SWT.NONE);
|
||||
actionButton.setText(action.getName());
|
||||
actionButton.setToolTipText(action.getToolTip());
|
||||
//actionButton.setImage(crudTable.getImageDescriptor("icons/fam/table_add.png").createImage());
|
||||
actionButton.addSelectionListener(new ActionListener(action));
|
||||
|
||||
}
|
||||
}
|
||||
class ActionListener extends SelectionAdapter {
|
||||
|
||||
private RowVascAction action = null;
|
||||
|
||||
public ActionListener(RowVascAction action) {
|
||||
this.action=action;
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
logger.info("Row Action");
|
||||
action.doRowAction(table, table.getSelectedObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when all createPartControl is done with creating Parts
|
||||
|
@ -256,14 +531,14 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
this.table=table;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||
*/
|
||||
public Image getColumnImage(Object arg0, int arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
public String getColumnText(Object bean, int columnNumber) {
|
||||
|
@ -278,26 +553,26 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void addListener(ILabelProviderListener arg0) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public boolean isLabelProperty(Object arg0, String arg1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void removeListener(ILabelProviderListener arg0) {
|
||||
|
@ -307,20 +582,20 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
|||
|
||||
class ListConverterContentProvider implements IStructuredContentProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
public Object[] getElements(Object obj) {
|
||||
return ((VascTable)obj).getTableData().toArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
|
||||
|
|
|
@ -36,9 +36,14 @@ import com.idcanet.vasc.core.VascTable;
|
|||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
import com.idcanet.vasc.impl.BeanVascRecordCreator;
|
||||
import com.idcanet.vasc.impl.DefaultVascTextValue;
|
||||
import com.idcanet.vasc.impl.actions.AddRowAction;
|
||||
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
||||
import com.idcanet.vasc.impl.actions.EditRowAction;
|
||||
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.swt.SwtVascViewRenderer;
|
||||
import com.idcanet.vasc.tests.models.TestModel;
|
||||
import com.idcanet.xtes.core.TemplateStore;
|
||||
import com.idcanet.xtes.core.XTESParser;
|
||||
import com.idcanet.xtes.xpql.query.Query;
|
||||
|
@ -92,7 +97,19 @@ public class SWTTest extends TestCase {
|
|||
table.setVascTextValue(new DefaultVascTextValue());
|
||||
table.setVascViewRenderer(render);
|
||||
table.setQuery(query);
|
||||
table.setVascRecordCreator(new BeanVascRecordCreator());
|
||||
table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class));
|
||||
table.addRowActions(new AddRowAction());
|
||||
table.addRowActions(new EditRowAction());
|
||||
table.addRowActions(new DeleteRowAction());
|
||||
|
||||
table.addGlobalActions(new XMLExportGlobalAction());
|
||||
//table.addGlobalActions(new CSVExportGlobalAction());
|
||||
//table.addGlobalActions(new HTMLExportGlobalAction());
|
||||
//table.addGlobalActions(new RefreshGlobalAction());
|
||||
|
||||
//table.addUserOptions(userOption);
|
||||
|
||||
//table.addColumnActions(new GraphColumnAction());
|
||||
|
||||
VascTableColumn column = new VascTableColumn();
|
||||
column.setName("test");
|
||||
|
|
|
@ -70,6 +70,12 @@ public class TestModelVascDataSource implements VascDataSource {
|
|||
public void persist(Object object) throws Exception {
|
||||
|
||||
}
|
||||
public Object merge(Object object) throws Exception {
|
||||
return object;
|
||||
}
|
||||
public void delete(Object object) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -29,6 +29,8 @@ package com.idcanet.vasc.tests.models;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import com.idcanet.vasc.annotations.VascDefaultValue;
|
||||
import com.idcanet.vasc.annotations.VascHelpId;
|
||||
import com.idcanet.vasc.annotations.VascName;
|
||||
import com.idcanet.vasc.annotations.VascToolTip;
|
||||
|
||||
|
@ -65,6 +67,8 @@ public class TestModel {
|
|||
*/
|
||||
@VascName(key="omscheiving")
|
||||
@VascToolTip(key="De omscheiving")
|
||||
@VascHelpId(helpId="help.id")
|
||||
@VascDefaultValue(defaultValue="xxxxx")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue