From ce0fa99266fe91437c5f57c83eb583563cec04f0 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 29 Jun 2015 12:36:21 +0000 Subject: [PATCH] Fixed TimeZone git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-open-widget@115607 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/TabResourceInfoDialog.java | 38 ++++------- ...erties.java => TabResourceProperties.java} | 6 +- .../client/TabResourcesSelectionPanel.java | 68 ++++++------------- .../resources/ResourceBundleTDOpen.java | 1 - 4 files changed, 37 insertions(+), 76 deletions(-) rename src/main/java/org/gcube/portlets/user/td/openwidget/client/{TabResourcesProperties.java => TabResourceProperties.java} (84%) diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceInfoDialog.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceInfoDialog.java index fb986ab..4ea57b9 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceInfoDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceInfoDialog.java @@ -1,7 +1,6 @@ package org.gcube.portlets.user.td.openwidget.client; import java.util.ArrayList; -import java.util.Date; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; @@ -16,9 +15,9 @@ import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; -import com.google.web.bindery.event.shared.EventBus; 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.core.client.util.Margins; import com.sencha.gxt.widget.core.client.Dialog; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; @@ -41,7 +40,7 @@ import com.sencha.gxt.widget.core.client.form.TextField; public class TabResourceInfoDialog extends Dialog { private static final int HEIGHT = 500; private static final int WIDTH = 500; - private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); + private static final DateTimeFormat sdf=DateTimeFormat.getFormat("yyyy-MM-dd HH:mm"); private TabResource tabResource; private TabResourcesInfoDialogPropertiesMessages msgs; private EventBus eventBus; @@ -122,7 +121,12 @@ public class TabResourceInfoDialog extends Dialog { 1, -1, new Margins(0))); TextField trCreationDate = new TextField(); - trCreationDate.setValue(tabResource.getDate()); + try { + trCreationDate.setValue(sdf.format(tabResource.getDate())); + } catch(Throwable e){ + Log.error("Error parsing creation date: "+e.getLocalizedMessage()); + } + trCreationDate.setReadOnly(true); FieldLabel trCreationDateLabel = new FieldLabel(trCreationDate, msgs.dateLabel()); @@ -148,19 +152,10 @@ public class TabResourceInfoDialog extends Dialog { trValidFromField.setReadOnly(true); FieldLabel trValidFromLabel=new FieldLabel(trValidFromField, msgs.validFromLabel()); trValidFromField.clear(); - if (tabResource.getValidFrom() == null - || tabResource.getValidFrom().isEmpty()) { + if (tabResource.getValidFrom() == null) { Log.debug("ValidFrom null or empty"); } else { - Date vFrom; - try { - vFrom = sdf.parse(tabResource.getValidFrom()); - trValidFromField.setValue(vFrom); - } catch (IllegalArgumentException e) { - Log.error("Error Parsing Valid From for Tabular Resource: " - + tabResource); - e.printStackTrace(); - } + trValidFromField.setValue(tabResource.getValidFrom()); } configurationFieldSetLayout.add(trValidFromLabel, new VerticalLayoutData(1, -1, new Margins(0))); @@ -171,19 +166,10 @@ public class TabResourceInfoDialog extends Dialog { FieldLabel trValidUntilToLabel= new FieldLabel(trValidUntilToField, msgs.validUntilToLabel()); trValidUntilToField.clear(); - if (tabResource.getValidUntilTo() == null - || tabResource.getValidUntilTo().isEmpty()) { + if (tabResource.getValidUntilTo() == null) { Log.debug("ValidUntilTo null or empty"); } else { - Date vUntilTo; - try { - vUntilTo = sdf.parse(tabResource.getValidUntilTo()); - trValidUntilToField.setValue(vUntilTo); - } catch (IllegalArgumentException e) { - Log.error("Error Parsing Valid Until To for Tabular Resource: " - + tabResource); - e.printStackTrace(); - } + trValidUntilToField.setValue(tabResource.getValidUntilTo()); } configurationFieldSetLayout.add(trValidUntilToLabel, new VerticalLayoutData(1, -1, new Margins(0))); diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesProperties.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceProperties.java similarity index 84% rename from src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesProperties.java rename to src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceProperties.java index 6fa0771..5981099 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesProperties.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourceProperties.java @@ -3,6 +3,8 @@ */ package org.gcube.portlets.user.td.openwidget.client; +import java.util.Date; + import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import com.google.gwt.editor.client.Editor.Path; @@ -16,7 +18,7 @@ import com.sencha.gxt.data.shared.PropertyAccess; * g.panichi@isti.cnr.it * */ -public interface TabResourcesProperties extends PropertyAccess { +public interface TabResourceProperties extends PropertyAccess { @Path("id") ModelKeyProvider id(); @@ -24,7 +26,7 @@ public interface TabResourcesProperties extends PropertyAccess { ValueProvider name(); ValueProvider tabResourceType(); ValueProvider agency(); - ValueProvider date(); + ValueProvider date(); ValueProvider tableTypeName(); ValueProvider ownerLogin(); ValueProvider locked(); diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java index 46bdeef..333f2ff 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java @@ -4,6 +4,7 @@ package org.gcube.portlets.user.td.openwidget.client; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; @@ -20,6 +21,7 @@ import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.cell.client.AbstractCell; +import com.google.gwt.cell.client.DateCell; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; @@ -29,6 +31,7 @@ import com.google.gwt.event.logical.shared.HasSelectionHandlers; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -76,6 +79,9 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; public class TabResourcesSelectionPanel extends ContentPanel implements HasSelectionHandlers { + private static final DateTimeFormat sdf = DateTimeFormat + .getFormat("yyyy-MM-dd HH:mm"); + interface NameTooltipTemplates extends XTemplates { @XTemplate("{value}") SafeHtml format(String value, String desc); @@ -132,8 +138,8 @@ public class TabResourcesSelectionPanel extends ContentPanel implements final CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - TabResourcesProperties properties = GWT - .create(TabResourcesProperties.class); + TabResourceProperties properties = GWT + .create(TabResourceProperties.class); final ExtendedListStore store = new ExtendedListStore( properties.id()); @@ -161,26 +167,6 @@ public class TabResourcesSelectionPanel extends ContentPanel implements ColumnConfig nameColumn = new ColumnConfig( properties.name(), 90, "Name"); - - /* - * nameColumn.setCell( new AbstractCell() { - * - * @Override public void render(Context context, String value, - * SafeHtmlBuilder sb) { TabResource - * tabResource=store.get(context.getIndex()); - * - * final NameTooltipTemplates nameToolTipTemplates = GWT - * .create(NameTooltipTemplates.class); String valueSafe=""; String - * descriptionSafe=""; - * - * if(value!=null){ valueSafe=SafeHtmlUtils.htmlEscape(value); } - * if(tabResource!=null && tabResource.getAgency()!=null){ - * descriptionSafe=SafeHtmlUtils.htmlEscape(tabResource.getAgency()); } - * sb.append(nameToolTipTemplates.format(valueSafe, descriptionSafe)); - * - * } }); - */ - ColumnConfig typeColumn = new ColumnConfig( properties.tabResourceType(), 30, "Type"); ColumnConfig tableTypeNameColumn = new ColumnConfig( @@ -191,21 +177,11 @@ public class TabResourcesSelectionPanel extends ContentPanel implements properties.agency(), 60, "Agency"); ColumnConfig ownerColumn = new ColumnConfig( properties.ownerLogin(), 70, "Owner"); - ColumnConfig dateColumn = new ColumnConfig( + ColumnConfig dateColumn = new ColumnConfig( properties.date(), 50, "Creation Date"); - - /*dateColumn.setCell(new AbstractCell(){ - @Override - public void render(com.google.gwt.cell.client.Cell.Context context, - String value, SafeHtmlBuilder sb) { - if(value!=null){ - String d=TimeZoneUtils.getLocalFormat(value); - sb.appendHtmlConstant(d); - } - - } - });*/ + dateColumn.setCell(new DateCell(sdf)); + lockedColumn.setCell(new AbstractCell() { @Override @@ -360,11 +336,12 @@ public class TabResourcesSelectionPanel extends ContentPanel implements } protected void requestInfo(TabResource tabResource) { - if(tabResource.isLocked()){ - UtilsGXT3.alert("Attention", "Tabular Resource is locked no info available!"); + if (tabResource.isLocked()) { + UtilsGXT3.alert("Attention", + "Tabular Resource is locked no info available!"); return; } - + TDGWTServiceAsync.INSTANCE.getTabResourceInformation( tabResource.getTrId(), new AsyncCallback() { @@ -384,15 +361,16 @@ public class TabResourcesSelectionPanel extends ContentPanel implements Log.error("Tabular Resource is Locked: " + caught.getLocalizedMessage()); parent.showErrorAndHide("Error", - caught.getLocalizedMessage(), "", caught); - - + caught.getLocalizedMessage(), "", + caught); + } else { Log.error("Error: " + caught.getLocalizedMessage()); parent.showErrorAndHide("Error", - caught.getLocalizedMessage(), "", caught); - + caught.getLocalizedMessage(), "", + caught); + } } @@ -414,10 +392,6 @@ public class TabResourcesSelectionPanel extends ContentPanel implements && item.getAgency().toLowerCase() .contains(searchTerm.toLowerCase())) return true; - if (item.getDate() != null - && item.getDate().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; if (item.getOwnerLogin() != null && item.getOwnerLogin().toLowerCase() .contains(searchTerm.toLowerCase())) diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java index 4231c31..7f88ddf 100644 --- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java +++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java @@ -3,7 +3,6 @@ package org.gcube.portlets.user.td.openwidget.client.resources; import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.resources.client.ClientBundle.Source; /** *