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"?>
|
||||
<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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -28,5 +28,5 @@
|
|||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</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>
|
||||
|
|
|
@ -37,7 +37,7 @@ public class DataRowColumnConfig<N> extends ColumnConfig<DataRow, N> {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setCell(AbstractCell<Boolean> cell) {
|
||||
public void setCellBoolean(AbstractCell<Boolean> cell) {
|
||||
Cell<N> cell2 = (Cell<N>) cell;
|
||||
super.setCell(cell2);
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ public class DataRowColumnConfig<N> extends ColumnConfig<DataRow, N> {
|
|||
super.setCell(cell2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setCellAbstract(AbstractCell<?> cell) {
|
||||
Cell<N> cell2 = (Cell<N>) cell;
|
||||
super.setCell(cell2);
|
||||
}
|
||||
|
||||
|
||||
public Cell<N> 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 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.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safecss.shared.SafeStylesBuilder;
|
||||
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.DateField;
|
||||
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 static DataRowColumnConfig<?> generateConfiguration(
|
||||
ColumnDefinition columnDefinition) {
|
||||
DataRowColumnConfig<?> columnConfig = null;
|
||||
|
||||
SafeStyles safeStyle;
|
||||
SafeStylesBuilder ssb= new SafeStylesBuilder();
|
||||
|
||||
switch (columnDefinition.getValueType()) {
|
||||
case BOOLEAN:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Boolean> create(columnDefinition);
|
||||
if (columnDefinition.getType() == ColumnType.VALIDATION) {
|
||||
|
||||
columnConfig.setCell(new AbstractCell<Boolean>(){
|
||||
columnConfig.setCellBoolean(new AbstractCell<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, Boolean value,
|
||||
SafeHtmlBuilder sb) {
|
||||
//int rowIndex = context.getIndex();
|
||||
//store.get(rowIndex);
|
||||
// int rowIndex = context.getIndex();
|
||||
// store.get(rowIndex);
|
||||
|
||||
String style = "style='color: " + (value ? "green" : "black")
|
||||
+ "'";
|
||||
String v = String.valueOf(value);
|
||||
sb.appendHtmlConstant("<span " + style
|
||||
+ " title='"+v+"'>" + v
|
||||
+ "</span>");
|
||||
String style = "style='color: "
|
||||
+ (value ? "green" : "black") + "'";
|
||||
|
||||
sb.appendHtmlConstant("<span " + style + " title='"+value+"'>"+
|
||||
value+"</span>");
|
||||
}
|
||||
});
|
||||
}
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.CENTER);
|
||||
break;
|
||||
case DATE:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Date> create(columnDefinition);
|
||||
columnConfig.setCellDate(new AbstractCell<Date>(){
|
||||
columnConfig.setCellDate(new AbstractCell<Date>() {
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
com.google.gwt.cell.client.Cell.Context context,
|
||||
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));
|
||||
sb.appendHtmlConstant(v);
|
||||
sb.appendEscaped(v);
|
||||
|
||||
}});
|
||||
}
|
||||
});
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.CENTER);
|
||||
break;
|
||||
case DOUBLE:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Double> create(columnDefinition);
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.RIGHT);
|
||||
break;
|
||||
case FLOAT:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Float> create(columnDefinition);
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.RIGHT);
|
||||
break;
|
||||
case INTEGER:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Integer> create(columnDefinition);
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.RIGHT);
|
||||
break;
|
||||
case LONG:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<Long> create(columnDefinition);
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
ssb.textAlign(TextAlign.RIGHT);
|
||||
break;
|
||||
case GEOMETRY:
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<String> create(columnDefinition);
|
||||
.<String> create(columnDefinition);
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
break;
|
||||
case STRING:
|
||||
|
||||
columnConfig = ColumnConfigGenerator
|
||||
.<String> create(columnDefinition);
|
||||
/*
|
||||
* column.setCell(new SimpleSafeHtmlCell<String>(new
|
||||
* AbstractSafeHtmlRenderer<String>() {
|
||||
*
|
||||
* @Override public SafeHtml render(String object) { return
|
||||
* SafeHtmlUtils.fromString(object); } }) );
|
||||
*/
|
||||
|
||||
|
||||
safeStyle= columnConfig.getColumnStyle();
|
||||
ssb.append(safeStyle);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
if (columnDefinition.getType() == ColumnType.VIEWCOLUMN) {
|
||||
SafeStyles safeStyle=columnConfig.getColumnStyle();
|
||||
SafeStylesBuilder ssb=new SafeStylesBuilder();
|
||||
ssb.append(safeStyle);
|
||||
ssb.trustedBackgroundColor("#c3e1fc");
|
||||
columnConfig.setColumnStyle(ssb.toSafeStyles());
|
||||
}
|
||||
columnConfig.setColumnStyle(ssb.toSafeStyles());
|
||||
|
||||
columnConfig.setHidden(!columnDefinition.isVisible());
|
||||
SafeHtmlBuilder tooltipMessage = new SafeHtmlBuilder();
|
||||
String local="";
|
||||
if(columnDefinition.getLocale()!=null && !columnDefinition.getLocale().isEmpty()){
|
||||
local=" ["+columnDefinition.getLocale()+"] ";
|
||||
String local = "";
|
||||
if (columnDefinition.getLocale() != null
|
||||
&& !columnDefinition.getLocale().isEmpty()) {
|
||||
local = " [" + columnDefinition.getLocale() + "] ";
|
||||
}
|
||||
|
||||
tooltipMessage
|
||||
.appendHtmlConstant("<p align='Left'><bold style='font-weight:bold;'>"
|
||||
+ columnDefinition.getLabel()
|
||||
+ SafeHtmlUtils.htmlEscape(columnDefinition.getLabel())
|
||||
+ "</bold><BR>"
|
||||
+ "<em style='text-decoration:underline;'>"
|
||||
+ columnDefinition.getColumnTypeName()
|
||||
+ "</em><bold>"+local+"</bold><BR>"
|
||||
+ SafeHtmlUtils.htmlEscape(columnDefinition.getColumnTypeName())
|
||||
+ "</em><bold>"
|
||||
+ SafeHtmlUtils.htmlEscape(local)
|
||||
+ "</bold><BR>"
|
||||
+ "<em>"
|
||||
+ columnDefinition.getColumnDataType()
|
||||
+ SafeHtmlUtils.htmlEscape(columnDefinition.getColumnDataType())
|
||||
+ "</em><BR>"
|
||||
+ columnDefinition.getTooltipMessage()
|
||||
+ "</p>");
|
||||
+ SafeHtmlUtils.htmlEscape(columnDefinition.getTooltipMessage()) + "</p>");
|
||||
columnConfig.setToolTip(tooltipMessage.toSafeHtml());
|
||||
|
||||
return columnConfig;
|
||||
}
|
||||
|
||||
|
||||
protected static <T> DataRowColumnConfig<T> create(
|
||||
ColumnDefinition columnDefinition) {
|
||||
return new DataRowColumnConfig<T>(columnDefinition);
|
||||
|
@ -218,6 +232,4 @@ public class ColumnConfigGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue