Minor update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@101184 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cb6086d1f3
commit
f0d6d67a4d
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/tabular-data-widgetx-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/tabular-data-widgetx-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-widgetx-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/tabular-data-widgetx-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -28,5 +28,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/tabular-data-widgetx-1.4.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/tabular-data-widgetx-1.5.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DataRowColumnConfig<N> extends ColumnConfig<DataRow, N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void setCell(AbstractCell<Boolean> cell) {
|
public void setCellBoolean(AbstractCell<Boolean> cell) {
|
||||||
Cell<N> cell2 = (Cell<N>) cell;
|
Cell<N> cell2 = (Cell<N>) cell;
|
||||||
super.setCell(cell2);
|
super.setCell(cell2);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,13 @@ public class DataRowColumnConfig<N> extends ColumnConfig<DataRow, N> {
|
||||||
super.setCell(cell2);
|
super.setCell(cell2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void setCellAbstract(AbstractCell<?> cell) {
|
||||||
|
Cell<N> cell2 = (Cell<N>) cell;
|
||||||
|
super.setCell(cell2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Cell<N> getCell() {
|
public Cell<N> getCell() {
|
||||||
return super.getCell();
|
return super.getCell();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,12 @@ 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.cell.client.AbstractCell;
|
import com.google.gwt.cell.client.AbstractCell;
|
||||||
|
import com.google.gwt.dom.client.Style.TextAlign;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.safecss.shared.SafeStyles;
|
import com.google.gwt.safecss.shared.SafeStyles;
|
||||||
import com.google.gwt.safecss.shared.SafeStylesBuilder;
|
import com.google.gwt.safecss.shared.SafeStylesBuilder;
|
||||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||||
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;
|
||||||
|
@ -31,122 +33,134 @@ import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
|
||||||
*/
|
*/
|
||||||
public class ColumnConfigGenerator {
|
public class ColumnConfigGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static DataRowColumnConfig<?> generateConfiguration(
|
public static DataRowColumnConfig<?> generateConfiguration(
|
||||||
ColumnDefinition columnDefinition) {
|
ColumnDefinition columnDefinition) {
|
||||||
DataRowColumnConfig<?> columnConfig = null;
|
DataRowColumnConfig<?> columnConfig = null;
|
||||||
|
|
||||||
|
SafeStyles safeStyle;
|
||||||
|
SafeStylesBuilder ssb= new SafeStylesBuilder();
|
||||||
|
|
||||||
switch (columnDefinition.getValueType()) {
|
switch (columnDefinition.getValueType()) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Boolean> create(columnDefinition);
|
.<Boolean> create(columnDefinition);
|
||||||
if (columnDefinition.getType() == ColumnType.VALIDATION) {
|
if (columnDefinition.getType() == ColumnType.VALIDATION) {
|
||||||
|
|
||||||
columnConfig.setCell(new AbstractCell<Boolean>(){
|
columnConfig.setCellBoolean(new AbstractCell<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Context context, Boolean value,
|
public void render(Context context, Boolean value,
|
||||||
SafeHtmlBuilder sb) {
|
SafeHtmlBuilder sb) {
|
||||||
//int rowIndex = context.getIndex();
|
// int rowIndex = context.getIndex();
|
||||||
//store.get(rowIndex);
|
// store.get(rowIndex);
|
||||||
|
|
||||||
String style = "style='color: " + (value ? "green" : "black")
|
String style = "style='color: "
|
||||||
+ "'";
|
+ (value ? "green" : "black") + "'";
|
||||||
String v = String.valueOf(value);
|
|
||||||
sb.appendHtmlConstant("<span " + style
|
sb.appendHtmlConstant("<span " + style + " title='"+value+"'>"+
|
||||||
+ " title='"+v+"'>" + v
|
value+"</span>");
|
||||||
+ "</span>");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.CENTER);
|
||||||
break;
|
break;
|
||||||
case DATE:
|
case DATE:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Date> create(columnDefinition);
|
.<Date> create(columnDefinition);
|
||||||
columnConfig.setCellDate(new AbstractCell<Date>(){
|
columnConfig.setCellDate(new AbstractCell<Date>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
com.google.gwt.cell.client.Cell.Context context,
|
com.google.gwt.cell.client.Cell.Context context,
|
||||||
Date value, SafeHtmlBuilder sb) {
|
Date value, SafeHtmlBuilder sb) {
|
||||||
|
|
||||||
DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd");
|
DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||||
String v = String.valueOf(sdf.format(value));
|
String v = String.valueOf(sdf.format(value));
|
||||||
sb.appendHtmlConstant(v);
|
sb.appendEscaped(v);
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.CENTER);
|
||||||
break;
|
break;
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Double> create(columnDefinition);
|
.<Double> create(columnDefinition);
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.RIGHT);
|
||||||
break;
|
break;
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Float> create(columnDefinition);
|
.<Float> create(columnDefinition);
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.RIGHT);
|
||||||
break;
|
break;
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Integer> create(columnDefinition);
|
.<Integer> create(columnDefinition);
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.RIGHT);
|
||||||
break;
|
break;
|
||||||
case LONG:
|
case LONG:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<Long> create(columnDefinition);
|
.<Long> create(columnDefinition);
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
|
ssb.textAlign(TextAlign.RIGHT);
|
||||||
break;
|
break;
|
||||||
case GEOMETRY:
|
case GEOMETRY:
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<String> create(columnDefinition);
|
.<String> create(columnDefinition);
|
||||||
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
|
ssb.append(safeStyle);
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
|
|
||||||
columnConfig = ColumnConfigGenerator
|
columnConfig = ColumnConfigGenerator
|
||||||
.<String> create(columnDefinition);
|
.<String> create(columnDefinition);
|
||||||
/*
|
safeStyle= columnConfig.getColumnStyle();
|
||||||
* column.setCell(new SimpleSafeHtmlCell<String>(new
|
ssb.append(safeStyle);
|
||||||
* AbstractSafeHtmlRenderer<String>() {
|
|
||||||
*
|
|
||||||
* @Override public SafeHtml render(String object) { return
|
|
||||||
* SafeHtmlUtils.fromString(object); } }) );
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnDefinition.getType() == ColumnType.VIEWCOLUMN) {
|
if (columnDefinition.getType() == ColumnType.VIEWCOLUMN) {
|
||||||
SafeStyles safeStyle=columnConfig.getColumnStyle();
|
|
||||||
SafeStylesBuilder ssb=new SafeStylesBuilder();
|
|
||||||
ssb.append(safeStyle);
|
|
||||||
ssb.trustedBackgroundColor("#c3e1fc");
|
ssb.trustedBackgroundColor("#c3e1fc");
|
||||||
columnConfig.setColumnStyle(ssb.toSafeStyles());
|
|
||||||
}
|
}
|
||||||
|
columnConfig.setColumnStyle(ssb.toSafeStyles());
|
||||||
|
|
||||||
columnConfig.setHidden(!columnDefinition.isVisible());
|
columnConfig.setHidden(!columnDefinition.isVisible());
|
||||||
SafeHtmlBuilder tooltipMessage = new SafeHtmlBuilder();
|
SafeHtmlBuilder tooltipMessage = new SafeHtmlBuilder();
|
||||||
String local="";
|
String local = "";
|
||||||
if(columnDefinition.getLocale()!=null && !columnDefinition.getLocale().isEmpty()){
|
if (columnDefinition.getLocale() != null
|
||||||
local=" ["+columnDefinition.getLocale()+"] ";
|
&& !columnDefinition.getLocale().isEmpty()) {
|
||||||
|
local = " [" + columnDefinition.getLocale() + "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltipMessage
|
tooltipMessage
|
||||||
.appendHtmlConstant("<p align='Left'><bold style='font-weight:bold;'>"
|
.appendHtmlConstant("<p align='Left'><bold style='font-weight:bold;'>"
|
||||||
+ columnDefinition.getLabel()
|
+ SafeHtmlUtils.htmlEscape(columnDefinition.getLabel())
|
||||||
+ "</bold><BR>"
|
+ "</bold><BR>"
|
||||||
+ "<em style='text-decoration:underline;'>"
|
+ "<em style='text-decoration:underline;'>"
|
||||||
+ columnDefinition.getColumnTypeName()
|
+ SafeHtmlUtils.htmlEscape(columnDefinition.getColumnTypeName())
|
||||||
+ "</em><bold>"+local+"</bold><BR>"
|
+ "</em><bold>"
|
||||||
|
+ SafeHtmlUtils.htmlEscape(local)
|
||||||
|
+ "</bold><BR>"
|
||||||
+ "<em>"
|
+ "<em>"
|
||||||
+ columnDefinition.getColumnDataType()
|
+ SafeHtmlUtils.htmlEscape(columnDefinition.getColumnDataType())
|
||||||
+ "</em><BR>"
|
+ "</em><BR>"
|
||||||
+ columnDefinition.getTooltipMessage()
|
+ SafeHtmlUtils.htmlEscape(columnDefinition.getTooltipMessage()) + "</p>");
|
||||||
+ "</p>");
|
|
||||||
columnConfig.setToolTip(tooltipMessage.toSafeHtml());
|
columnConfig.setToolTip(tooltipMessage.toSafeHtml());
|
||||||
|
|
||||||
return columnConfig;
|
return columnConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static <T> DataRowColumnConfig<T> create(
|
protected static <T> DataRowColumnConfig<T> create(
|
||||||
ColumnDefinition columnDefinition) {
|
ColumnDefinition columnDefinition) {
|
||||||
return new DataRowColumnConfig<T>(columnDefinition);
|
return new DataRowColumnConfig<T>(columnDefinition);
|
||||||
|
@ -218,6 +232,4 @@ public class ColumnConfigGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue