[svn r229] init add vasc
This commit is contained in:
parent
5684546942
commit
d62b09bd3b
39 changed files with 1804 additions and 0 deletions
59
src/com/idcanet/vasc/impl/BeanVascRecordCreator.java
Normal file
59
src/com/idcanet/vasc/impl/BeanVascRecordCreator.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.idcanet.vasc.core.VascRecordCreator;
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class BeanVascRecordCreator implements VascRecordCreator {
|
||||
|
||||
private Class objectClass = null;
|
||||
|
||||
|
||||
public BeanVascRecordCreator() {
|
||||
|
||||
}
|
||||
public BeanVascRecordCreator(Class objectClass) {
|
||||
setObjectClass(objectClass);
|
||||
}
|
||||
|
||||
public Object newRecord(VascTable table) throws Exception {
|
||||
return objectClass.newInstance();
|
||||
}
|
||||
|
||||
public Class getObjectClass() {
|
||||
return objectClass;
|
||||
}
|
||||
public void setObjectClass(Class objectClass) {
|
||||
this.objectClass=objectClass;
|
||||
}
|
||||
}
|
||||
41
src/com/idcanet/vasc/impl/DefaultVascTextValue.java
Normal file
41
src/com/idcanet/vasc/impl/DefaultVascTextValue.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.idcanet.vasc.core.VascTextValue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class DefaultVascTextValue implements VascTextValue {
|
||||
|
||||
public String getTextValue(String text) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.VascColumnValue;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class BeanPropertyVascColumnValue implements VascColumnValue {
|
||||
|
||||
private String property = null;
|
||||
|
||||
public BeanPropertyVascColumnValue() {
|
||||
|
||||
}
|
||||
public BeanPropertyVascColumnValue(String property) {
|
||||
setProperty(property);
|
||||
}
|
||||
|
||||
public Object getValue(VascTableColumn column) {
|
||||
if(getProperty()==null) {
|
||||
return null;
|
||||
}
|
||||
if(getProperty().equals("")) {
|
||||
return "";
|
||||
}
|
||||
return getProperty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the property
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param property the property to set
|
||||
*/
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
42
src/com/idcanet/vasc/impl/column/NullVascColumnValue.java
Normal file
42
src/com/idcanet/vasc/impl/column/NullVascColumnValue.java
Normal 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.VascColumnValue;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class NullVascColumnValue implements VascColumnValue {
|
||||
|
||||
public Object getValue(VascTableColumn column) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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.serv5;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.idcanet.serv5.services.hibernate3.Hibernate3Factory;
|
||||
import com.idcanet.vasc.core.VascDataSource;
|
||||
import com.idcanet.xtes.xpql.query.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class Serv5HibernateVascDataSource implements VascDataSource {
|
||||
|
||||
private String session = null;
|
||||
|
||||
public Serv5HibernateVascDataSource() {
|
||||
|
||||
}
|
||||
public Serv5HibernateVascDataSource(String session) {
|
||||
setSession(session);
|
||||
}
|
||||
|
||||
public List<Object> executeQuery(Query query) throws Exception {
|
||||
try {
|
||||
/*
|
||||
Query q = Hibernate3Factory.getSession("flowstats").createQuery(query.toString());
|
||||
q.setMaxResults(crudTable.getQueryLimit());
|
||||
if(crudTable.getViewOnly()) {
|
||||
q.setReadOnly(true);
|
||||
}
|
||||
for(CrudParameterOption para:crudTable.getQueryParameterOptions().values()) {
|
||||
if(para.getValueHolder().getValue()==null) {
|
||||
logger.finer("Value is null of parameter: "+para.getName());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Object value = para.getValueHolder().getValue();
|
||||
logger.finer("Setting parameter: "+para.getName()+" with: "+value);
|
||||
if(para.getValueProperty()!=null) {
|
||||
q.setParameter(para.getName(),BeanUtils.getValue(value,BeanUtils.getPropertyDescriptor(value,para.getValueProperty())));
|
||||
} else {
|
||||
q.setParameter(para.getName(),value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
List data = q.list();
|
||||
logger.info("Query returned: "+data.size()+" of: "+crudTable.getQueryName());
|
||||
crudTable.getSelectionInList().setList(data);
|
||||
*/
|
||||
return null;
|
||||
} finally {
|
||||
Hibernate3Factory.getSession("flowstats").close(); // close session in threads
|
||||
}
|
||||
}
|
||||
|
||||
public void persist(Object object) throws Exception {
|
||||
try {
|
||||
Hibernate3Factory.getSession(getSession()).persist(object);
|
||||
} finally {
|
||||
Hibernate3Factory.getSession(getSession()).close();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return the session
|
||||
*/
|
||||
public String getSession() {
|
||||
return session;
|
||||
}
|
||||
/**
|
||||
* @param session the session to set
|
||||
*/
|
||||
public void setSession(String session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
236
src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java
Normal file
236
src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* 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.swt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
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.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
|
||||
import com.idcanet.vasc.core.VascTable;
|
||||
import com.idcanet.vasc.core.VascUserOption;
|
||||
import com.idcanet.vasc.core.VascViewRenderer;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||
|
||||
import fr.jayasoft.binding.jface.adapter.JFaceComponentFactory;
|
||||
import fr.jayasoft.binding.jface.utils.table.AbstractColumn;
|
||||
import fr.jayasoft.binding.jface.utils.table.PropertyColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwtVascViewRenderer implements VascViewRenderer {
|
||||
|
||||
private Logger logger = null;
|
||||
private Composite parent = null;
|
||||
private VascTable table = null;
|
||||
|
||||
public SwtVascViewRenderer(Composite parent) {
|
||||
logger = Logger.getLogger(SwtVascViewRenderer.class.getName());
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
public void renderView(VascTable table) {
|
||||
this.table=table;
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
parent.setLayout(layout);
|
||||
|
||||
Composite header = new Composite(parent, SWT.NONE);
|
||||
GridLayout headerLayout = new GridLayout();
|
||||
headerLayout.numColumns = 6;
|
||||
header.setLayout(headerLayout);
|
||||
header.setLayoutData(new GridData(SWT.NONE));
|
||||
|
||||
Composite body = new Composite(parent, SWT.NONE);
|
||||
GridLayout bodyLayout = new GridLayout();
|
||||
bodyLayout.numColumns = 1;
|
||||
body.setLayout(bodyLayout);
|
||||
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite footer = new Composite(parent, 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createHeader(Composite header) {
|
||||
logger.finest("Creating header");
|
||||
|
||||
header.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Color c = new Color(header.getDisplay(),255,255,255);
|
||||
header.setBackground(c);
|
||||
|
||||
if(table.getHeaderName()!=null) {
|
||||
Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD);
|
||||
Label l = new Label(header, SWT.CENTER);
|
||||
l.setFont(headerFont);
|
||||
l.setText(table.getVascTextValue().getTextValue(table.getHeaderName()));
|
||||
l.setBackground(c);
|
||||
}
|
||||
|
||||
// create options
|
||||
for(VascUserOption option:table.getUserOptions()) {
|
||||
|
||||
/*
|
||||
if(option.getLabelText()!=null) {
|
||||
Label l = new Label(header,SWT.WRAP);
|
||||
l.setText(crudTable.i18n(cpo.getLabelText()));
|
||||
l.setBackground(c);
|
||||
}
|
||||
|
||||
// create ValueHolder
|
||||
cpo.setValueHolder(new ValueHolder(null));
|
||||
// create control
|
||||
cpo.setTempObjectPropertyControl(cpo.getPropertyEditor().createPropertyEditor(header,cpo.getValueHolder()));
|
||||
|
||||
cpo.getValueHolder().addPropertyChangeListener(this);
|
||||
*/
|
||||
}
|
||||
}
|
||||
public void createBody(Composite body) {
|
||||
logger.finer("Creating body");
|
||||
|
||||
final TableViewer tableViewer = JFaceComponentFactory.createTableViewer(body,table.getSelectionInList(),getTableColumns(crudTable),false);
|
||||
final Table table2 = tableViewer.getTable();
|
||||
table2.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
table2.setHeaderVisible(true);
|
||||
table2.setLinesVisible(true);
|
||||
|
||||
//Add sort indicator and sort data when column selected
|
||||
Listener sortListener = new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
// determine new sort column and direction
|
||||
TableColumn sortColumn = table2.getSortColumn();
|
||||
TableColumn currentColumn = (TableColumn) e.widget;
|
||||
int dir = table2.getSortDirection();
|
||||
if (sortColumn == currentColumn) {
|
||||
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
|
||||
} else {
|
||||
table2.setSortColumn(currentColumn);
|
||||
dir = SWT.UP;
|
||||
}
|
||||
// sort the data based on column and direction
|
||||
String prop = (String)currentColumn.getData("PROP");
|
||||
|
||||
List l = new ArrayList(10);
|
||||
/*
|
||||
for(int i=0;i<crudTable.getSelectionInList().getSize();i++) {
|
||||
l.add(crudTable.getSelectionInList().getElementAt(i));
|
||||
}
|
||||
BeanPropertyComparator c = new BeanPropertyComparator();
|
||||
c.setAscending(dir!=SWT.DOWN);
|
||||
c.setProperty(prop);
|
||||
Collections.sort(l,c);
|
||||
crudTable.getSelectionInList().setList(l);
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
Integer totalSize = VascTable.getTotalColumnSize(table);
|
||||
logger.finer("Total size: "+totalSize);
|
||||
TableColumn[] columns = table2.getColumns();
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
columns[i].pack();
|
||||
columns[i].setMoveable(true);
|
||||
columns[i].setResizable(true);
|
||||
columns[i].addListener(SWT.Selection, sortListener);
|
||||
//columns[i].setData("PROP",table.getTableColumns().get(i)....);
|
||||
if(totalSize!=null) {
|
||||
Integer cWidth = table.getTableColumns().get(i).getWidth();
|
||||
columns[i].setWidth(cWidth);
|
||||
/*
|
||||
columns[i].setWidth((int)((double)tableWidth/(double)totalSize)*cWidth);
|
||||
logger.finest("Setting column width: "+(int)((double)tableWidth/(double)totalSize)*cWidth+" total: "+totalSize+" c: "+cWidth+" of column: "+i);
|
||||
*/
|
||||
}
|
||||
}
|
||||
logger.fine("Table with columns created: "+table2.getColumnCount());
|
||||
}
|
||||
|
||||
private static AbstractColumn[] getTableColumns(VascTable crudTable) {
|
||||
AbstractColumn[] cols = new AbstractColumn[crudTable.getCrudTableColumns().size()];
|
||||
int i=0;
|
||||
for(VascTableColumn c:crudTable.getTableColumns()) {
|
||||
AbstractColumn ac = new PropertyColumn(crudTable.i18n(c.getName()),c.getObjectProperty());
|
||||
ac.setEditable(false);
|
||||
ac.setReorderable(true);
|
||||
ac.setSortable(true);
|
||||
cols[i]=ac;
|
||||
i++;
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
|
||||
public void createFooter(Composite footer) {
|
||||
logger.finest("Creating footer");
|
||||
for(RowVascAction action:table.getRowActions()) {
|
||||
|
||||
//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.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when all createPartControl is done with creating Parts
|
||||
*/
|
||||
public void partCreated() {
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue