From e2221229e1c632fd67593699c3e34ba12dd690f1 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 29 Jun 2015 12:37:11 +0000 Subject: [PATCH] Fixed TimeZone git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget@115612 82a268e6-3cf1-43bd-a215-b396298e98cf --- ...erties.java => TabResourceProperties.java} | 6 +- .../client/TabResourcesSelectionPanel.java | 112 +++++++++--------- 2 files changed, 57 insertions(+), 61 deletions(-) rename src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/{TabResourcesProperties.java => TabResourceProperties.java} (83%) diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourceProperties.java similarity index 83% rename from src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java rename to src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourceProperties.java index 533f85e..251f844 100644 --- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourceProperties.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.td.unionwizardwidget.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/unionwizardwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java index 4dca5fd..071399a 100644 --- a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.td.unionwizardwidget.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; @@ -15,6 +15,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; @@ -24,6 +25,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; @@ -59,26 +61,11 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; public class TabResourcesSelectionPanel extends ContentPanel implements HasSelectionHandlers { - - 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 static final DateTimeFormat sdf = DateTimeFormat + .getFormat("yyyy-MM-dd HH:mm"); + private Grid grid; + private ResourceBundle res; + private Menu contextMenu; private TabResource removableTR; @@ -91,15 +78,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()); @@ -113,9 +92,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: ")); @@ -131,11 +108,36 @@ public class TabResourcesSelectionPanel extends ContentPanel implements IdentityValueProvider identity = new IdentityValueProvider(); 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() { @@ -187,7 +189,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); @@ -249,10 +251,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())) @@ -319,9 +317,9 @@ public class TabResourcesSelectionPanel extends ContentPanel implements removableTR = tabResource; final ConfirmMessageBox mb = new ConfirmMessageBox("Delete", "Would you like to delete this tabular resource?"); - - /*Next in GXT 3.1.1 */ - + + /* Next in GXT 3.1.1 */ + mb.addDialogHideHandler(new DialogHideHandler() { @Override @@ -339,23 +337,19 @@ public class TabResourcesSelectionPanel extends ContentPanel implements } }); - - /* GXT 3.0.1 - mb.addHideHandler(new HideHandler() { - public void onHide(HideEvent event) { - - - if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES - .name())) { - callDeleteTabularResource(); - } else if (mb.getHideButton() == mb - .getButtonById(PredefinedButton.NO.name())) { - // perform NO action - } - - } - }); - */ + + /* + * GXT 3.0.1 mb.addHideHandler(new HideHandler() { public void + * onHide(HideEvent event) { + * + * + * if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES + * .name())) { callDeleteTabularResource(); } else if + * (mb.getHideButton() == mb .getButtonById(PredefinedButton.NO.name())) + * { // perform NO action } + * + * } }); + */ mb.setWidth(300); mb.show();