From 8957f19d4cbf0091e120b24bcd938beb12a8e763 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 16 Jan 2015 16:48:03 +0000 Subject: [PATCH] Fixed error when tabular resource has not name git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-mainbox-widget@111408 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/mainboxwidget/client/MainBox.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBox.java b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBox.java index 464ce6b..f0b4348 100644 --- a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBox.java +++ b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBox.java @@ -21,6 +21,8 @@ import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.EventBus; @@ -213,6 +215,7 @@ public class MainBox extends TabPanel { if (dataView instanceof TabularResourceDataView) { TabularResourceDataView tabularResourceDataView = (TabularResourceDataView) dataView; + boolean found = false; for (TDXPanel tdxPanel : tdxPanelList) { @@ -226,7 +229,8 @@ public class MainBox extends TabPanel { } } if (!found) { - addTDXPanel(tabularResourceDataView); + retrieveTRName(tabularResourceDataView); + // addTDXPanel(tabularResourceDataView); } } @@ -255,9 +259,16 @@ public class MainBox extends TabPanel { protected void addContentTDXPanel( TabularResourceDataView tabularResourceDataView, TabResource tabResource) { - + SafeHtml nameTR; + if(tabResource!=null && (tabResource.getName()==null + ||tabResource.getName().isEmpty())){ + nameTR=SafeHtmlUtils.fromString("NoName"); + } else { + nameTR=SafeHtmlUtils.fromString(tabResource.getName()); + } + TabItemConfig tdxPanelItemConf = new TabItemConfig( - tabResource.getName(), true); + nameTR.asString(), true); tdxPanelItemConf.setIcon(MainboxResources.INSTANCE.tabularResource()); final TDXPanel tdxPanel = new TDXPanel(eventBus); tdxPanel.open(tabularResourceDataView); @@ -338,7 +349,7 @@ public class MainBox extends TabPanel { } return rowsId; } - + /** * Retrieve ColumnName of column selected * @@ -355,20 +366,20 @@ public class MainBox extends TabPanel { } return columnName; } - + /** * Retrieve ColumnLocalId of column selected * * @param columnSelected * @return */ - public String getColumnLocalId(int columnSelected){ + public String getColumnLocalId(int columnSelected) { String columnName = null; Widget active = getActiveWidget(); if (active instanceof TDXPanel) { TDXPanel tdxPanel = (TDXPanel) active; - columnName = tdxPanel.getTabularData() - .getColumnLocalId(columnSelected); + columnName = tdxPanel.getTabularData().getColumnLocalId( + columnSelected); } return columnName; }