From 54e4d2bb403210c7b4c31dbb7223dba71695440d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 13 May 2014 15:33:14 +0000 Subject: [PATCH] Fixed Date support git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@95642 82a268e6-3cf1-43bd-a215-b396298e98cf --- .gwt/.gwt-log | 256 ++++++++++++++++++ .../client/batch/SingleValueReplacePanel.java | 15 +- .../dimension/ConnectCodelistDialog.java | 5 + .../DimensionRowSelectionDialog.java | 5 + .../client/replace/ReplacePanel.java | 92 +++++-- 5 files changed, 352 insertions(+), 21 deletions(-) diff --git a/.gwt/.gwt-log b/.gwt/.gwt-log index dbdaa52..49a2e3b 100644 --- a/.gwt/.gwt-log +++ b/.gwt/.gwt-log @@ -3098,3 +3098,259 @@ Compiling... Compilation completed in 0.00 seconds Removing invalidated units Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 20% complete (ETR: 13 seconds) + 20% complete (ETR: 13 seconds) + 20% complete (ETR: 13 seconds) + 30% complete (ETR: 12 seconds) + 40% complete (ETR: 9 seconds) + 50% complete (ETR: 7 seconds) + 60% complete (ETR: 5 seconds) + 70% complete (ETR: 4 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 14.07 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 10% complete (ETR: 20 seconds) + 10% complete (ETR: 20 seconds) + 20% complete (ETR: 20 seconds) + 30% complete (ETR: 15 seconds) + 40% complete (ETR: 11 seconds) + 50% complete (ETR: 8 seconds) + 60% complete (ETR: 6 seconds) + 70% complete (ETR: 4 seconds) + 80% complete (ETR: 3 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 17.02 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 70% complete (ETR: 2 seconds) + 80% complete (ETR: 1 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 9.01 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 40% complete (ETR: 6 seconds) + 40% complete (ETR: 6 seconds) + 40% complete (ETR: 6 seconds) + 40% complete (ETR: 6 seconds) + 40% complete (ETR: 6 seconds) + 50% complete (ETR: 5 seconds) + 60% complete (ETR: 4 seconds) + 70% complete (ETR: 3 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 16.10 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 20% complete (ETR: 13 seconds) + 20% complete (ETR: 13 seconds) + 20% complete (ETR: 13 seconds) + 30% complete (ETR: 12 seconds) + 40% complete (ETR: 9 seconds) + 50% complete (ETR: 6 seconds) + 60% complete (ETR: 4 seconds) + 70% complete (ETR: 3 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 14.87 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.01 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 40% complete (ETR: 9 seconds) + 50% complete (ETR: 7 seconds) + 60% complete (ETR: 5 seconds) + 70% complete (ETR: 4 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 17.46 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 30% complete (ETR: 9 seconds) + 30% complete (ETR: 9 seconds) + 30% complete (ETR: 9 seconds) + 30% complete (ETR: 9 seconds) + 40% complete (ETR: 8 seconds) + 50% complete (ETR: 6 seconds) + 60% complete (ETR: 4 seconds) + 70% complete (ETR: 3 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 19.66 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 20% complete (ETR: 18 seconds) + 20% complete (ETR: 18 seconds) + 20% complete (ETR: 18 seconds) + 30% complete (ETR: 14 seconds) + 40% complete (ETR: 11 seconds) + 50% complete (ETR: 8 seconds) + 60% complete (ETR: 6 seconds) + 70% complete (ETR: 5 seconds) + 80% complete (ETR: 3 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 17.76 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes +Public resources found in... +Translatable source found in... +Found 2719 cached/archived units. Used 2719 / 2719 units from cache. +Compiling... + Compilation completed in 0.00 seconds +Removing invalidated units +Finding entry point classes diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/SingleValueReplacePanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/SingleValueReplacePanel.java index e27710b..70e1754 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/SingleValueReplacePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/SingleValueReplacePanel.java @@ -1,6 +1,8 @@ package org.gcube.portlets.user.td.columnwidget.client.batch; -import java.sql.Date; + + +import java.util.Date; import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3; @@ -9,6 +11,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession; import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.util.Margins; @@ -149,7 +152,15 @@ public class SingleValueReplacePanel extends FramedPanel { checked = b.toString(); } else { if (column.getDataTypeName().compareTo("Date") == 0) { - Date d = Date.valueOf(rValue); + DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd"); + Date d = null; + try { + d = sdf.parse(rValue); + } catch (Exception e) { + Log.error("Unparseable using " + sdf); + return null; + } + if (d != null) { checked = rValue; } diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/ConnectCodelistDialog.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/ConnectCodelistDialog.java index 19db4a3..c519132 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/ConnectCodelistDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/ConnectCodelistDialog.java @@ -38,6 +38,11 @@ import com.sencha.gxt.widget.core.client.form.ComboBox; import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.info.Info; +/** + * + * @author "Giancarlo Panichi" + * + */ public class ConnectCodelistDialog extends Window implements CodelistSelectionListener { protected String WIDTH = "500px"; diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/DimensionRowSelectionDialog.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/DimensionRowSelectionDialog.java index 14a9570..6bed4c5 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/DimensionRowSelectionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/dimension/DimensionRowSelectionDialog.java @@ -27,6 +27,11 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.info.Info; +/** + * + * @author "Giancarlo Panichi" + * + */ public class DimensionRowSelectionDialog extends Window { protected static final int WIDTH = 550; protected static final int HEIGHT = 520; diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/replace/ReplacePanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/replace/ReplacePanel.java index 1c1e786..1566559 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/replace/ReplacePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/replace/ReplacePanel.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.td.columnwidget.client.replace; -import java.sql.Date; + +import java.util.Date; import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog; import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener; @@ -17,6 +18,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; @@ -37,6 +39,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.event.TriggerClickEvent; import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler; import com.sencha.gxt.widget.core.client.form.ComboBox; +import com.sencha.gxt.widget.core.client.form.DateField; import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.TextField; @@ -56,6 +59,7 @@ public class ReplacePanel extends FramedPanel implements protected ReplaceDialog parent; protected ColumnData column; + protected DimensionRow dimensionRow; protected ReplaceColumnSession replaceColumnSession; @@ -63,7 +67,9 @@ public class ReplacePanel extends FramedPanel implements private FieldLabel comboDimensionTypeLabel; private TextField value; + private DateField valueDate; private TextField replaceValue; + private DateField replaceValueDate; private TextButton btnApply; private TextButton btnClose; private boolean isDimension; @@ -117,12 +123,32 @@ public class ReplacePanel extends FramedPanel implements } protected void create() { - value = new TextField(); - value.setValue(cellData.getValue()); - value.setReadOnly(true); + if(column.getDataTypeName().compareTo("Date") == 0){ + valueDate = new DateField(); + Date d = null; + DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd"); + Log.debug("Date value: "+cellData.getValue()); + try { + d = sdf.parse(cellData.getValue()); + } catch (Exception e) { + Log.error("Unparseable using " + sdf); + } + if(d!=null){ + valueDate.setValue(d); + } + valueDate.setReadOnly(true); - replaceValue = new TextField(); + replaceValueDate = new DateField(); + + } else { + value = new TextField(); + value.setValue(cellData.getValue()); + value.setReadOnly(true); + replaceValue = new TextField(); + } + + btnApply = new TextButton("Replace"); btnApply.setIcon(ResourceBundle.INSTANCE.replace()); btnApply.setIconAlign(IconAlign.RIGHT); @@ -157,9 +183,15 @@ public class ReplacePanel extends FramedPanel implements flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.add(new FieldLabel(value, "Value"), new VerticalLayoutData(1, -1)); - v.add(new FieldLabel(replaceValue, "Replace"), new VerticalLayoutData( + if(column.getDataTypeName().compareTo("Date") == 0){ + v.add(new FieldLabel(valueDate, "Value"), new VerticalLayoutData(1, -1)); + v.add(new FieldLabel(replaceValueDate, "Replace"), new VerticalLayoutData( + 1, -1)); + } else { + v.add(new FieldLabel(value, "Value"), new VerticalLayoutData(1, -1)); + v.add(new FieldLabel(replaceValue, "Replace"), new VerticalLayoutData( 1, -1)); + } v.add(flowButton, new VerticalLayoutData(-1, 36, new Margins(5, 2, 5, 2))); add(v); @@ -235,19 +267,34 @@ public class ReplacePanel extends FramedPanel implements } protected void replaceValue() { - String rValue = replaceValue.getCurrentValue(); - if (rValue == null || rValue.isEmpty()) { - UtilsGXT3.alert("Attention", "Insert a valid replace value"); - } else { - String checkedValue = checkTypeData(rValue); - if (checkedValue != null && !checkedValue.isEmpty()) { - callReplaceValue(rValue); - } else { - UtilsGXT3.alert("Attention", - "Insert a valid replace value for this column"); + String rValue; + + if(column.getDataTypeName().compareTo("Date") == 0){ + Date d=replaceValueDate.getCurrentValue(); + if(d==null){ + UtilsGXT3.alert("Attention", "Insert a valid replace value"); + return; + } else{ + Long data = d.getTime(); + rValue = data.toString(); } + + } else { + rValue = replaceValue.getCurrentValue(); + if (rValue == null || rValue.isEmpty()) { + UtilsGXT3.alert("Attention", "Insert a valid replace value"); + return; + } else { + String checkedValue = checkTypeData(rValue); + if (checkedValue == null || checkedValue.isEmpty()) { + UtilsGXT3.alert("Attention", + "Insert a valid replace value for this column"); + return; + } + } } - + callReplaceValue(rValue); + } protected void replaceValueForDimension() { @@ -268,7 +315,14 @@ public class ReplacePanel extends FramedPanel implements checked = b.toString(); } else { if (column.getDataTypeName().compareTo("Date") == 0) { - Date d = Date.valueOf(rValue); + Date d = null; + DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd"); + try { + d = sdf.parse(value.getValue()); + } catch (Exception e) { + Log.error("Unparseable using " + sdf); + return null; + } if (d != null) { Long data = d.getTime(); checked = data.toString();