Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@91633 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b9ae9f564b
commit
ae21165fab
|
@ -2,11 +2,11 @@ eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.5
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<faceted-project>
|
<faceted-project>
|
||||||
<installed facet="jst.utility" version="1.0"/>
|
<installed facet="jst.utility" version="1.0"/>
|
||||||
<installed facet="java" version="1.5"/>
|
<installed facet="java" version="1.7"/>
|
||||||
</faceted-project>
|
</faceted-project>
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.event.shared.EventBus;
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
|
||||||
import com.google.gwt.http.client.RequestBuilder;
|
import com.google.gwt.http.client.RequestBuilder;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
import com.sencha.gxt.core.client.Style.SelectionMode;
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||||
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
@ -60,6 +61,7 @@ import com.sencha.gxt.widget.core.client.event.HeaderContextMenuEvent.HeaderCont
|
||||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||||
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.GridViewConfig;
|
||||||
import com.sencha.gxt.widget.core.client.grid.LiveGridView;
|
import com.sencha.gxt.widget.core.client.grid.LiveGridView;
|
||||||
import com.sencha.gxt.widget.core.client.grid.LiveToolItem;
|
import com.sencha.gxt.widget.core.client.grid.LiveToolItem;
|
||||||
import com.sencha.gxt.widget.core.client.menu.Item;
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
||||||
|
@ -269,7 +271,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
||||||
Collections.sort(columns, new ColumnPositionComparator(false));
|
Collections.sort(columns, new ColumnPositionComparator(false));
|
||||||
|
|
||||||
for (ColumnDefinition columnDefinition : columns) {
|
for (ColumnDefinition columnDefinition : columns) {
|
||||||
if (columnDefinition.getType() == ColumnType.USER)
|
if (columnDefinition.getType() != ColumnType.SYSTEM)
|
||||||
columnsConfig.add(ColumnConfigGenerator
|
columnsConfig.add(ColumnConfigGenerator
|
||||||
.generateConfiguration(columnDefinition));
|
.generateConfiguration(columnDefinition));
|
||||||
}
|
}
|
||||||
|
@ -303,6 +305,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
||||||
|
|
||||||
liveGridView = new ExtendedLiveGridView();
|
liveGridView = new ExtendedLiveGridView();
|
||||||
liveGridView.setRowHeight(21);
|
liveGridView.setRowHeight(21);
|
||||||
|
|
||||||
grid = new Grid<DataRow>(store, columnModel);
|
grid = new Grid<DataRow>(store, columnModel);
|
||||||
grid.setLoadMask(true);
|
grid.setLoadMask(true);
|
||||||
grid.setLoader(loader);
|
grid.setLoader(loader);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package org.gcube.portlets.user.tdwx.client.config;
|
package org.gcube.portlets.user.tdwx.client.config;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
||||||
|
@ -27,10 +28,12 @@ public class TabularDataGridViewConfig implements GridViewConfig<DataRow> {
|
||||||
|
|
||||||
protected RowStyleProvider rowStyleProvider;
|
protected RowStyleProvider rowStyleProvider;
|
||||||
protected Row row;
|
protected Row row;
|
||||||
|
protected TableDefinition definition;
|
||||||
|
|
||||||
public TabularDataGridViewConfig(TableViewConfig config, TableDefinition definition)
|
public TabularDataGridViewConfig(TableViewConfig config, TableDefinition definition)
|
||||||
{
|
{
|
||||||
this.rowStyleProvider = config.getRowStyleProvider();
|
this.rowStyleProvider = config.getRowStyleProvider();
|
||||||
|
this.definition=definition;
|
||||||
|
|
||||||
Map<String, ColumnKey> keys = new HashMap<String, ColumnKey>();
|
Map<String, ColumnKey> keys = new HashMap<String, ColumnKey>();
|
||||||
for (ColumnDefinition column:definition.getColumnsAsList()) keys.put(column.getLabel(), column.getKey());
|
for (ColumnDefinition column:definition.getColumnsAsList()) keys.put(column.getLabel(), column.getKey());
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.gcube.portlets.user.tdwx.client.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ValidationRowStyleProvider implements RowStyleProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRowStyle(Row row) {
|
||||||
|
/*
|
||||||
|
Collection<ColumnKey> keys=row.keys.values();
|
||||||
|
DataRow r=row.dataRow;
|
||||||
|
|
||||||
|
for(ColumnKey k:keys){
|
||||||
|
Object b = r.get(k);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,8 @@ package org.gcube.portlets.user.tdwx.client.model.grid;
|
||||||
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
||||||
import org.gcube.portlets.user.tdwx.shared.model.DataRow;
|
import org.gcube.portlets.user.tdwx.shared.model.DataRow;
|
||||||
|
|
||||||
|
import com.google.gwt.cell.client.AbstractCell;
|
||||||
|
import com.google.gwt.cell.client.Cell;
|
||||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,4 +32,14 @@ public class DataRowColumnConfig<N> extends ColumnConfig<DataRow, N> {
|
||||||
public ColumnDefinition getDefinition() {
|
public ColumnDefinition getDefinition() {
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void setCell(AbstractCell<Boolean> cell) {
|
||||||
|
Cell<N> cell2 = (Cell<N>) cell;
|
||||||
|
super.setCell(cell2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cell<N> getCell() {
|
||||||
|
return super.getCell();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ import java.util.Date;
|
||||||
|
|
||||||
import org.gcube.portlets.user.tdwx.client.model.grid.DataRowColumnConfig;
|
import org.gcube.portlets.user.tdwx.client.model.grid.DataRowColumnConfig;
|
||||||
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
import org.gcube.portlets.user.tdwx.shared.model.ColumnDefinition;
|
||||||
|
import org.gcube.portlets.user.tdwx.shared.model.ColumnType;
|
||||||
import org.gcube.portlets.user.tdwx.shared.model.DataRow;
|
import org.gcube.portlets.user.tdwx.shared.model.DataRow;
|
||||||
|
|
||||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
import com.google.gwt.cell.client.AbstractCell;
|
||||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.CheckBox;
|
import com.sencha.gxt.widget.core.client.form.CheckBox;
|
||||||
import com.sencha.gxt.widget.core.client.form.DateField;
|
import com.sencha.gxt.widget.core.client.form.DateField;
|
||||||
import com.sencha.gxt.widget.core.client.form.NumberField;
|
import com.sencha.gxt.widget.core.client.form.NumberField;
|
||||||
|
@ -22,75 +22,158 @@ import com.sencha.gxt.widget.core.client.grid.editing.AbstractGridEditing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ColumnConfigGenerator {
|
public class ColumnConfigGenerator {
|
||||||
|
|
||||||
public static DataRowColumnConfig<?> generateConfiguration(ColumnDefinition columnDefinition)
|
public static DataRowColumnConfig<?> generateConfiguration(
|
||||||
{
|
ColumnDefinition columnDefinition) {
|
||||||
DataRowColumnConfig<?> columnConfig = null;
|
DataRowColumnConfig<?> columnConfig = null;
|
||||||
switch (columnDefinition.getValueType()) {
|
switch (columnDefinition.getValueType()) {
|
||||||
case BOOLEAN: columnConfig = ColumnConfigGenerator.<Boolean>create(columnDefinition); break;
|
case BOOLEAN:
|
||||||
case DATE: columnConfig = ColumnConfigGenerator.<Date>create(columnDefinition); break;
|
columnConfig = ColumnConfigGenerator
|
||||||
case DOUBLE: columnConfig = ColumnConfigGenerator.<Double>create(columnDefinition); break;
|
.<Boolean> create(columnDefinition);
|
||||||
case FLOAT: columnConfig = ColumnConfigGenerator.<Float>create(columnDefinition); break;
|
if (columnDefinition.getType() == ColumnType.VALIDATION) {
|
||||||
case INTEGER: columnConfig = ColumnConfigGenerator.<Integer>create(columnDefinition); break;
|
columnConfig.setCell(new AbstractCell<Boolean>(){
|
||||||
case LONG: columnConfig = ColumnConfigGenerator.<Long>create(columnDefinition); break;
|
|
||||||
case STRING: {
|
|
||||||
|
|
||||||
columnConfig = ColumnConfigGenerator.<String>create(columnDefinition);
|
|
||||||
/*column.setCell(new SimpleSafeHtmlCell<String>(new AbstractSafeHtmlRenderer<String>() {
|
|
||||||
@Override
|
@Override
|
||||||
public SafeHtml render(String object) {
|
public void render(Context context, Boolean value,
|
||||||
return SafeHtmlUtils.fromString(object);
|
SafeHtmlBuilder sb) {
|
||||||
|
String style = "style='color: " + (value ? "green" : "red")
|
||||||
|
+ "'";
|
||||||
|
String v = String.valueOf(value);
|
||||||
|
sb.appendHtmlConstant("<span " + style
|
||||||
|
+ " qtitle='Change' qtip='" + v + "'>" + v
|
||||||
|
+ "</span>");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
);*/
|
}
|
||||||
|
break;
|
||||||
|
case DATE:
|
||||||
|
columnConfig = ColumnConfigGenerator
|
||||||
|
.<Date> create(columnDefinition);
|
||||||
|
break;
|
||||||
|
case DOUBLE:
|
||||||
|
columnConfig = ColumnConfigGenerator
|
||||||
|
.<Double> create(columnDefinition);
|
||||||
|
break;
|
||||||
|
case FLOAT:
|
||||||
|
columnConfig = ColumnConfigGenerator
|
||||||
|
.<Float> create(columnDefinition);
|
||||||
|
break;
|
||||||
|
case INTEGER:
|
||||||
|
columnConfig = ColumnConfigGenerator
|
||||||
|
.<Integer> create(columnDefinition);
|
||||||
|
break;
|
||||||
|
case LONG:
|
||||||
|
columnConfig = ColumnConfigGenerator
|
||||||
|
.<Long> create(columnDefinition);
|
||||||
|
break;
|
||||||
|
case STRING: {
|
||||||
|
|
||||||
} break;
|
columnConfig = ColumnConfigGenerator
|
||||||
default: return null;
|
.<String> create(columnDefinition);
|
||||||
|
/*
|
||||||
|
* column.setCell(new SimpleSafeHtmlCell<String>(new
|
||||||
|
* AbstractSafeHtmlRenderer<String>() {
|
||||||
|
*
|
||||||
|
* @Override public SafeHtml render(String object) { return
|
||||||
|
* SafeHtmlUtils.fromString(object); } }) );
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
columnConfig.setHidden(!columnDefinition.isVisible());
|
columnConfig.setHidden(!columnDefinition.isVisible());
|
||||||
SafeHtmlBuilder tooltipMessage= new SafeHtmlBuilder();
|
SafeHtmlBuilder tooltipMessage = new SafeHtmlBuilder();
|
||||||
tooltipMessage.appendHtmlConstant("<p align='Left'><bold style='font-weight:bold;'>"+columnDefinition.getLabel()+"</bold><BR>"+
|
tooltipMessage
|
||||||
"<em style='text-decoration:underline;'>"+columnDefinition.getColumnTypeName()+"</em><BR>"+
|
.appendHtmlConstant("<p align='Left'><bold style='font-weight:bold;'>"
|
||||||
"<em>"+columnDefinition.getColumnDataType()+"</em><BR>"+
|
+ columnDefinition.getLabel()
|
||||||
columnDefinition.getTooltipMessage()+"</p>");
|
+ "</bold><BR>"
|
||||||
|
+ "<em style='text-decoration:underline;'>"
|
||||||
|
+ columnDefinition.getColumnTypeName()
|
||||||
|
+ "</em><BR>"
|
||||||
|
+ "<em>"
|
||||||
|
+ columnDefinition.getColumnDataType()
|
||||||
|
+ "</em><BR>"
|
||||||
|
+ columnDefinition.getTooltipMessage()
|
||||||
|
+ "</p>");
|
||||||
columnConfig.setToolTip(tooltipMessage.toSafeHtml());
|
columnConfig.setToolTip(tooltipMessage.toSafeHtml());
|
||||||
|
|
||||||
return columnConfig;
|
return columnConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> DataRowColumnConfig<T> create(ColumnDefinition columnDefinition)
|
protected static <T> DataRowColumnConfig<T> create(
|
||||||
{
|
ColumnDefinition columnDefinition) {
|
||||||
return new DataRowColumnConfig<T>(columnDefinition);
|
return new DataRowColumnConfig<T>(columnDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setEditor(AbstractGridEditing<DataRow> editableGrid, ColumnConfig<DataRow,?> columnConfig)
|
public static void setEditor(AbstractGridEditing<DataRow> editableGrid,
|
||||||
{
|
ColumnConfig<DataRow, ?> columnConfig) {
|
||||||
if (!(columnConfig instanceof DataRowColumnConfig<?>)) throw new IllegalArgumentException("Expected ColumnConfig type JSonValueColumnConfig");
|
if (!(columnConfig instanceof DataRowColumnConfig<?>))
|
||||||
setEditor(editableGrid, (DataRowColumnConfig<?>)columnConfig);
|
throw new IllegalArgumentException(
|
||||||
|
"Expected ColumnConfig type JSonValueColumnConfig");
|
||||||
|
setEditor(editableGrid, (DataRowColumnConfig<?>) columnConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void setEditor(AbstractGridEditing<DataRow> editableGrid, DataRowColumnConfig<?> columnConfig)
|
public static void setEditor(AbstractGridEditing<DataRow> editableGrid,
|
||||||
{
|
DataRowColumnConfig<?> columnConfig) {
|
||||||
if (columnConfig.getDefinition().isEditable()) {
|
if (columnConfig.getDefinition().isEditable()) {
|
||||||
switch (columnConfig.getDefinition().getValueType()) {
|
switch (columnConfig.getDefinition().getValueType()) {
|
||||||
case BOOLEAN: editableGrid.addEditor((ColumnConfig<DataRow, Boolean>) columnConfig, new CheckBox()); break;
|
case BOOLEAN:
|
||||||
case DATE: editableGrid.addEditor((ColumnConfig<DataRow, Date>) columnConfig, new DateField()); break;
|
editableGrid.addEditor(
|
||||||
case DOUBLE: editableGrid.addEditor((ColumnConfig<DataRow, Double>) columnConfig, new NumberField<Double>(new NumberPropertyEditor.DoublePropertyEditor())); break;
|
(ColumnConfig<DataRow, Boolean>) columnConfig,
|
||||||
case FLOAT: editableGrid.addEditor((ColumnConfig<DataRow, Float>) columnConfig, new NumberField<Float>(new NumberPropertyEditor.FloatPropertyEditor())); break;
|
new CheckBox());
|
||||||
case INTEGER: editableGrid.addEditor((ColumnConfig<DataRow, Integer>) columnConfig, new NumberField<Integer>(new NumberPropertyEditor.IntegerPropertyEditor())); break;
|
break;
|
||||||
case LONG: editableGrid.addEditor((ColumnConfig<DataRow, Long>) columnConfig, new NumberField<Long>(new NumberPropertyEditor.LongPropertyEditor())); break;
|
case DATE:
|
||||||
case STRING: editableGrid.addEditor((ColumnConfig<DataRow, String>) columnConfig, new TextField()); break;
|
editableGrid.addEditor(
|
||||||
default: break;
|
(ColumnConfig<DataRow, Date>) columnConfig,
|
||||||
|
new DateField());
|
||||||
|
break;
|
||||||
|
case DOUBLE:
|
||||||
|
editableGrid
|
||||||
|
.addEditor(
|
||||||
|
(ColumnConfig<DataRow, Double>) columnConfig,
|
||||||
|
new NumberField<Double>(
|
||||||
|
new NumberPropertyEditor.DoublePropertyEditor()));
|
||||||
|
break;
|
||||||
|
case FLOAT:
|
||||||
|
editableGrid
|
||||||
|
.addEditor(
|
||||||
|
(ColumnConfig<DataRow, Float>) columnConfig,
|
||||||
|
new NumberField<Float>(
|
||||||
|
new NumberPropertyEditor.FloatPropertyEditor()));
|
||||||
|
break;
|
||||||
|
case INTEGER:
|
||||||
|
editableGrid
|
||||||
|
.addEditor(
|
||||||
|
(ColumnConfig<DataRow, Integer>) columnConfig,
|
||||||
|
new NumberField<Integer>(
|
||||||
|
new NumberPropertyEditor.IntegerPropertyEditor()));
|
||||||
|
break;
|
||||||
|
case LONG:
|
||||||
|
editableGrid.addEditor(
|
||||||
|
(ColumnConfig<DataRow, Long>) columnConfig,
|
||||||
|
new NumberField<Long>(
|
||||||
|
new NumberPropertyEditor.LongPropertyEditor()));
|
||||||
|
break;
|
||||||
|
case STRING:
|
||||||
|
editableGrid.addEditor(
|
||||||
|
(ColumnConfig<DataRow, String>) columnConfig,
|
||||||
|
new TextField());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,17 @@ public class ColumnDefinition implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3736483086021088831L;
|
private static final long serialVersionUID = 3736483086021088831L;
|
||||||
|
|
||||||
protected String id;
|
protected String id; //Column Name on service
|
||||||
protected String label;
|
protected String columnLocalId; //ColumnLocalId on service
|
||||||
|
protected String label; //Label
|
||||||
|
public String getColumnLocalId() {
|
||||||
|
return columnLocalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumnLocalId(String columnLocalId) {
|
||||||
|
this.columnLocalId = columnLocalId;
|
||||||
|
}
|
||||||
|
|
||||||
protected ValueType valueType;
|
protected ValueType valueType;
|
||||||
protected int width;
|
protected int width;
|
||||||
protected boolean editable;
|
protected boolean editable;
|
||||||
|
@ -37,8 +46,9 @@ public class ColumnDefinition implements Serializable {
|
||||||
* @param id the column id.
|
* @param id the column id.
|
||||||
* @param label the column label.
|
* @param label the column label.
|
||||||
*/
|
*/
|
||||||
public ColumnDefinition(String id, String label) {
|
public ColumnDefinition(String id, String columnLocalId,String label) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.columnLocalId=columnLocalId;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.type = ColumnType.USER;
|
this.type = ColumnType.USER;
|
||||||
this.position = -1;
|
this.position = -1;
|
||||||
|
@ -55,8 +65,8 @@ public class ColumnDefinition implements Serializable {
|
||||||
* @param visible flag for visibility.
|
* @param visible flag for visibility.
|
||||||
* @param type the column type.
|
* @param type the column type.
|
||||||
*/
|
*/
|
||||||
public ColumnDefinition(String id, String label, ValueType valueType, int width, boolean editable, boolean visible, ColumnType type) {
|
public ColumnDefinition(String id, String columnLocalId, String label, ValueType valueType, int width, boolean editable, boolean visible, ColumnType type) {
|
||||||
this(id, label);
|
this(id, columnLocalId, label);
|
||||||
this.valueType = valueType;
|
this.valueType = valueType;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.editable = editable;
|
this.editable = editable;
|
||||||
|
@ -203,14 +213,17 @@ public class ColumnDefinition implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ColumnDefinition [id=" + id + ", label=" + label
|
return "ColumnDefinition [id=" + id + ", label=" + label
|
||||||
+ ", valueType=" + valueType + ", width=" + width
|
+ ", columnLocalId=" + columnLocalId + ", valueType="
|
||||||
+ ", editable=" + editable + ", visible=" + visible + ", type="
|
+ valueType + ", width=" + width + ", editable=" + editable
|
||||||
+ type + ", position=" + position + ", tooltipMessage="
|
+ ", visible=" + visible + ", type=" + type + ", position="
|
||||||
+ tooltipMessage + ", columnTypeName=" + columnTypeName
|
+ position + ", tooltipMessage=" + tooltipMessage
|
||||||
+ ", columnDataType=" + columnDataType + ", key=" + key + "]";
|
+ ", columnTypeName=" + columnTypeName + ", columnDataType="
|
||||||
|
+ columnDataType + ", key=" + key + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,6 @@ package org.gcube.portlets.user.tdwx.shared.model;
|
||||||
public enum ColumnType {
|
public enum ColumnType {
|
||||||
|
|
||||||
USER,
|
USER,
|
||||||
|
VALIDATION,
|
||||||
SYSTEM;
|
SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,38 +23,38 @@ public class TestSorting {
|
||||||
@Test
|
@Test
|
||||||
public void testSorting() {
|
public void testSorting() {
|
||||||
List<ColumnDefinition> cols = new ArrayList<ColumnDefinition>();
|
List<ColumnDefinition> cols = new ArrayList<ColumnDefinition>();
|
||||||
ColumnDefinition col = new ColumnDefinition("id1", "label1");
|
ColumnDefinition col = new ColumnDefinition("id1","columnLocalId1", "label1");
|
||||||
col.setPosition(1);
|
col.setPosition(1);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
col = new ColumnDefinition("id2", "label2");
|
col = new ColumnDefinition("id2","columnLocalId2", "label2");
|
||||||
col.setPosition(2);
|
col.setPosition(2);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
col = new ColumnDefinition("id3", "label3");
|
col = new ColumnDefinition("id3","columnLocalId3", "label3");
|
||||||
col.setPosition(3);
|
col.setPosition(3);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
col = new ColumnDefinition("id4", "label4");
|
col = new ColumnDefinition("id4","columnLocalId4", "label4");
|
||||||
col.setPosition(4);
|
col.setPosition(4);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
col = new ColumnDefinition("id5", "label5");
|
col = new ColumnDefinition("id5","columnLocalId5", "label5");
|
||||||
col.setPosition(5);
|
col.setPosition(5);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
|
|
||||||
col = new ColumnDefinition("id6-1", "label6-1");
|
col = new ColumnDefinition("id6-1","columnLocalId6-1", "label6-1");
|
||||||
col.setPosition(6);
|
col.setPosition(6);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
|
|
||||||
col = new ColumnDefinition("id6-2", "label6-2");
|
col = new ColumnDefinition("id6-2","columnLocalId6-2", "label6-2");
|
||||||
col.setPosition(6);
|
col.setPosition(6);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
col = new ColumnDefinition("id7", "label7");
|
col = new ColumnDefinition("id7-1","columnLocalId7-1", "label7-1");
|
||||||
col.setPosition(7);
|
col.setPosition(7);
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
|
|
||||||
|
|
||||||
col = new ColumnDefinition("idNoPos1", "labelNoPos1");
|
col = new ColumnDefinition("idNoPos1", "columnLocalNoPos1", "labelNoPos1");
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
|
|
||||||
col = new ColumnDefinition("idNoPos2", "labelNoPos2");
|
col = new ColumnDefinition("idNoPos2", "columnLocalNoPos2","labelNoPos2");
|
||||||
cols.add(col);
|
cols.add(col);
|
||||||
Collections.sort(cols, new ColumnPositionComparator(false));
|
Collections.sort(cols, new ColumnPositionComparator(false));
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ public class TestSpeed {
|
||||||
protected static void testWriter() throws IOException
|
protected static void testWriter() throws IOException
|
||||||
{
|
{
|
||||||
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
||||||
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("date", "date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("double", "double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("float", "float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("long", "long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("string", "string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
||||||
|
|
||||||
|
|
||||||
long startFreeMemory = Runtime.getRuntime().freeMemory();
|
long startFreeMemory = Runtime.getRuntime().freeMemory();
|
||||||
|
@ -96,12 +96,12 @@ public class TestSpeed {
|
||||||
protected static void testBuilder() throws IOException
|
protected static void testBuilder() throws IOException
|
||||||
{
|
{
|
||||||
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
||||||
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("date", "date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("double", "double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("float", "float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("long", "long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("string", "string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
||||||
|
|
||||||
|
|
||||||
TableJSonBuilder gridJSonWriter = new TableJSonBuilder(tableDefinition);
|
TableJSonBuilder gridJSonWriter = new TableJSonBuilder(tableDefinition);
|
||||||
|
|
|
@ -25,12 +25,12 @@ public class TestTableJSonBuilder {
|
||||||
public void testTableJSonBuilder()
|
public void testTableJSonBuilder()
|
||||||
{
|
{
|
||||||
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
||||||
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("date", "date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("double", "double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("float", "float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("long", "long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("string", "string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
||||||
|
|
||||||
TableJSonBuilder gridJSonWriter = new TableJSonBuilder(tableDefinition);
|
TableJSonBuilder gridJSonWriter = new TableJSonBuilder(tableDefinition);
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,12 @@ public class TestTableJSonWriter {
|
||||||
public void testTableJSonWriter()
|
public void testTableJSonWriter()
|
||||||
{
|
{
|
||||||
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
TableDefinition tableDefinition = new TableDefinition(new TableId("", "id"), "name", "jsonDataField", "jsonTotalLengthField", "jsonOffsetField");
|
||||||
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("boolean", "boolean", "boolean", ValueType.BOOLEAN, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("date", "date", "date", ValueType.DATE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("double", "double", "double", ValueType.DOUBLE, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("float", "float", "float", ValueType.FLOAT, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("long", "long", "long", ValueType.LONG, 1, true, true, ColumnType.USER));
|
||||||
tableDefinition.addColumn(new ColumnDefinition("string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
tableDefinition.addColumn(new ColumnDefinition("string", "string", "string", ValueType.STRING, 1, true, true, ColumnType.USER));
|
||||||
|
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
Loading…
Reference in New Issue