From 60a6c072a2a2f1e875545a997383158914162970 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 29 Jun 2015 12:34:49 +0000 Subject: [PATCH] Fixed TimeZone git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-codelistmapping-import-widget@115601 82a268e6-3cf1-43bd-a215-b396298e98cf --- ...erties.java => TabResourceProperties.java} | 6 +- .../client/TabResourcesSelectionPanel.java | 91 ++++++++++--------- 2 files changed, 52 insertions(+), 45 deletions(-) rename src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/{TabResourcesProperties.java => TabResourceProperties.java} (84%) diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesProperties.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourceProperties.java similarity index 84% rename from src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesProperties.java rename to src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourceProperties.java index 754fdd9..663f6ac 100644 --- a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesProperties.java +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourceProperties.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client; +import java.util.Date; + import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import com.google.gwt.editor.client.Editor.Path; @@ -13,7 +15,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(); @@ -21,7 +23,7 @@ public interface TabResourcesProperties extends PropertyAccess { ValueProvider name(); ValueProvider tabResourceType(); ValueProvider agency(); - ValueProvider date(); + ValueProvider date(); ValueProvider tableTypeName(); ValueProvider ownerLogin(); diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesSelectionPanel.java index f892424..efbccb0 100644 --- a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/TabResourcesSelectionPanel.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Date; import java.util.List; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; @@ -16,6 +16,7 @@ import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundl import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; +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; @@ -25,6 +26,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.user.client.rpc.AsyncCallback; import com.sencha.gxt.core.client.IdentityValueProvider; import com.sencha.gxt.core.client.Style.SelectionMode; @@ -57,30 +59,17 @@ import com.sencha.gxt.widget.core.client.menu.Menu; import com.sencha.gxt.widget.core.client.menu.MenuItem; import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; import com.sencha.gxt.widget.core.client.toolbar.ToolBar; + //Next in GXT 3.1.1 public class TabResourcesSelectionPanel extends ContentPanel implements HasSelectionHandlers { + private static final DateTimeFormat sdf = DateTimeFormat + .getFormat("yyyy-MM-dd HH:mm"); - private static final TabResourcesProperties properties = GWT - .create(TabResourcesProperties.class); - - protected static final ColumnConfig nameColumn = new ColumnConfig( - properties.name(), 90, "Name"); - protected static final ColumnConfig typeColumn = new ColumnConfig( - properties.tabResourceType(), 30, "Type"); - protected static final ColumnConfig tableTypeNameColumn = new ColumnConfig( - properties.tableTypeName(), 30, "Table Type"); - protected static final ColumnConfig agencyColumn = new ColumnConfig( - properties.agency(), 60, "Agency"); - protected static final ColumnConfig ownerColumn = new ColumnConfig( - properties.ownerLogin(), 70, "Owner"); - protected static final ColumnConfig dateColumn = new ColumnConfig( - properties.date(), 50, "Creation Date"); - - protected Grid grid; - protected ResourceBundle res; - protected Menu contextMenu; + private Grid grid; + private ResourceBundle res; + private Menu contextMenu; private TabResource removableTR; @@ -93,15 +82,7 @@ public class TabResourcesSelectionPanel extends ContentPanel implements init(); try { createContextMenu(); - } catch (Throwable e) { - Log.debug("Error In CreateContextMenu:" + e.getMessage()); - e.printStackTrace(); - } - try { - buildPanel(properties.id(), - Arrays.> asList(nameColumn, - typeColumn, tableTypeNameColumn, ownerColumn, - agencyColumn, dateColumn), nameColumn); + buildPanel(); } catch (Throwable e) { Log.debug("Error building panel:" + e.getMessage()); @@ -115,9 +96,7 @@ public class TabResourcesSelectionPanel extends ContentPanel implements } - protected void buildPanel(ModelKeyProvider keyProvider, - List> columns, - ColumnConfig autoexpandColumn) { + protected void buildPanel() { ToolBar toolBar = new ToolBar(); toolBar.add(new LabelToolItem("Search: ")); @@ -134,10 +113,36 @@ public class TabResourcesSelectionPanel extends ContentPanel implements final CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); + TabResourceProperties properties = GWT + .create(TabResourceProperties.class); + + ColumnConfig nameColumn = new ColumnConfig( + properties.name(), 90, "Name"); + ColumnConfig typeColumn = new ColumnConfig( + properties.tabResourceType(), 30, "Type"); + ColumnConfig tableTypeNameColumn = new ColumnConfig( + properties.tableTypeName(), 30, "Table Type"); + ColumnConfig agencyColumn = new ColumnConfig( + properties.agency(), 60, "Agency"); + ColumnConfig ownerColumn = new ColumnConfig( + properties.ownerLogin(), 70, "Owner"); + ColumnConfig dateColumn = new ColumnConfig( + properties.date(), 50, "Creation Date"); + + dateColumn.setCell(new DateCell(sdf)); + + List> columns = new ArrayList>(); + columns.add(nameColumn); + columns.add(typeColumn); + columns.add(tableTypeNameColumn); + columns.add(agencyColumn); + columns.add(ownerColumn); + columns.add(dateColumn); + ColumnModel cm = new ColumnModel(columns); final ExtendedListStore store = new ExtendedListStore( - keyProvider); + properties.id()); searchField.addKeyUpHandler(new KeyUpHandler() { @@ -189,7 +194,7 @@ public class TabResourcesSelectionPanel extends ContentPanel implements sm.setSelectionMode(SelectionMode.SINGLE); grid.setLoader(loader); grid.setSelectionModel(sm); - grid.getView().setAutoExpandColumn(autoexpandColumn); + grid.getView().setAutoExpandColumn(nameColumn); grid.getView().setStripeRows(true); grid.getView().setColumnLines(true); grid.getView().setAutoFill(true); @@ -251,10 +256,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())) @@ -277,18 +278,22 @@ public class TabResourcesSelectionPanel extends ContentPanel implements if (caught instanceof TDGWTIsLockedException) { Log.error(caught.getLocalizedMessage()); parent.showErrorAndHide("Error Locked", - caught.getLocalizedMessage(), "", caught); + caught.getLocalizedMessage(), "", + caught); } else { if (caught instanceof TDGWTIsFinalException) { Log.error(caught.getLocalizedMessage()); parent.showErrorAndHide("Error Final", - caught.getLocalizedMessage(), - "", caught); + caught.getLocalizedMessage(), "", + caught); } else { Log.debug("Error retrieving tabular resource: " + caught.getLocalizedMessage()); - parent.showErrorAndHide("Error", - "Error retrieving tabular resources on server: ",caught.getLocalizedMessage(),caught); + parent.showErrorAndHide( + "Error", + "Error retrieving tabular resources on server: ", + caught.getLocalizedMessage(), + caught); } } }