diff --git a/pom.xml b/pom.xml index f595308..6fdbfac 100644 --- a/pom.xml +++ b/pom.xml @@ -96,22 +96,25 @@ org.gcube.core common-scope-maps [1.0.2-SNAPSHOT,2.0.0-SNAPSHOT) - compile + provided org.gcube.portal custom-portal-handler + provided org.gcube.applicationsupportlayer aslcore + provided org.gcube.applicationsupportlayer accesslogger + provided @@ -148,27 +151,9 @@ org.gcube.portlets.user tabular-data-widgetx-tdx-source [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) - - - - - - org.gcube.portlets.user - tabular-data-monitor-widget - [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) provided - - - - org.gcube.portlets.user - tabular-data-resources-widget - [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) - provided - - - com.allen-sauer.gwt.log @@ -356,5 +341,4 @@ - war diff --git a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml index e8570f4..82938a4 100644 --- a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml +++ b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml @@ -7,26 +7,27 @@ - + - - - - - + + + + - + 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 42379e7..1ecd282 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 @@ -2,10 +2,17 @@ package org.gcube.portlets.user.td.mainboxwidget.client; import java.util.ArrayList; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.mainboxwidget.client.resources.MainboxResources; import org.gcube.portlets.user.td.mainboxwidget.client.tdx.TDXPanel; +import org.gcube.portlets.user.td.mainboxwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.mainboxwidget.client.welcome.WelcomePanel; import org.gcube.portlets.user.td.widgetcommonevent.client.event.DataViewActiveEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.shared.dataview.DataView; import org.gcube.portlets.user.td.widgetcommonevent.shared.dataview.TabularResourceDataView; @@ -13,6 +20,7 @@ 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.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.theme.blue.client.tabs.BlueTabPanelBottomAppearance; @@ -34,53 +42,56 @@ public class MainBox extends TabPanel { protected ArrayList tdxPanelList; public MainBox(String name, EventBus eventBus, MainBoxPanel mainBoxPanel) { - super(GWT. create(BlueTabPanelBottomAppearance.class)); + super( + GWT. create(BlueTabPanelBottomAppearance.class)); Log.debug("Create MainBox"); setId(name); this.eventBus = eventBus; this.mainBoxPanel = mainBoxPanel; init(); - } - - protected void init(){ - + + protected void init() { + setBodyBorder(false); setBorders(false); setAnimScroll(true); setTabScroll(true); setCloseContextMenu(true); setResizeTabs(true); - //setTabWidth(Integer.MAX_VALUE); + // setTabWidth(Integer.MAX_VALUE); setMinTabWidth(20); - //setResizeTabs(true); + // setResizeTabs(true); tdxPanelList = new ArrayList(); // setResizeTabs(true); + addSelectionHandler(new SelectionHandler() { - + @Override public void onSelection(SelectionEvent event) { - Widget widget=event.getSelectedItem(); - if(widget instanceof TDXPanel){ - TDXPanel tdxPanel=(TDXPanel) widget; - TabularResourceDataView tabularResourceDataView=tdxPanel.getTabularResourceDataView(); - DataViewActiveEvent dataViewActiveEvent=new DataViewActiveEvent(tabularResourceDataView); + Widget widget = event.getSelectedItem(); + if (widget instanceof TDXPanel) { + TDXPanel tdxPanel = (TDXPanel) widget; + TabularResourceDataView tabularResourceDataView = tdxPanel + .getTabularResourceDataView(); + DataViewActiveEvent dataViewActiveEvent = new DataViewActiveEvent( + tabularResourceDataView); eventBus.fireEvent(dataViewActiveEvent); } else { - + } forceLayout(); - + } }); } public void startTabs() { Log.debug("Start MainBox Tabs"); - //addWelcomeTab(); - //setActiveWidget(getWidget(0)); + // addWelcomeTab(); + // setActiveWidget(getWidget(0)); } public void openTDXTab(DataView dataView) { @@ -117,19 +128,21 @@ public class MainBox extends TabPanel { if (dataView instanceof TabularResourceDataView) { TabularResourceDataView tabularResourceDataView = (TabularResourceDataView) dataView; - boolean found=false; - + boolean found = false; + for (TDXPanel tdxPanel : tdxPanelList) { - if(tdxPanel.isDataViewRequest(tabularResourceDataView)){ + if (tdxPanel + .isValidDataViewRequest(tabularResourceDataView)) { tdxPanel.update(tabularResourceDataView); - found=true; + //TabItemConfig tabItemConfig=getConfig(tdxPanel); + found = true; break; } } - if(!found){ + if (!found) { addTDXPanel(tabularResourceDataView); } - + } forceLayout(); } catch (Throwable e) { @@ -138,8 +151,6 @@ public class MainBox extends TabPanel { } } - - protected void addTDXPanel(TabularResourceDataView tabularResourceDataView) { for (TDXPanel tdxPanel : tdxPanelList) { if (tdxPanel.getTabularResourceDataView().getTrId().getId() @@ -149,51 +160,64 @@ public class MainBox extends TabPanel { return; } } + + retrieveTRName(tabularResourceDataView); + + + }; + protected void addContentTDXPanel(TabularResourceDataView tabularResourceDataView,TabResource tabResource){ TabItemConfig tdxPanelItemConf = new TabItemConfig( - tabularResourceDataView.getTrId().getId(), true); + tabResource.getName(), true); tdxPanelItemConf.setIcon(MainboxResources.INSTANCE.tabularResource()); final TDXPanel tdxPanel = new TDXPanel(eventBus); tdxPanel.open(tabularResourceDataView); tdxPanelList.add(tdxPanel); - + add(tdxPanel, tdxPanelItemConf); - - - + addBeforeCloseHandler(new BeforeCloseHandler() { public void onBeforeClose(BeforeCloseEvent event) { if (tdxPanel == event.getItem()) { + remove(tdxPanel); tdxPanelList.remove(tdxPanel); + TabularResourceDataView oldDataView = tdxPanel + .getTabularResourceDataView(); + Widget active = getActiveWidget(); + if (active instanceof TDXPanel) { + TDXPanel tdxPanelActive = (TDXPanel) active; + TabularResourceDataView newDataView = tdxPanelActive + .getTabularResourceDataView(); + DataViewActiveEvent dataViewActiveEvent = new DataViewActiveEvent( + newDataView, oldDataView); + eventBus.fireEvent(dataViewActiveEvent); + } + } } }); setActiveWidget(tdxPanel); - }; + } + protected void addWelcomeTab() { - - - - TabItemConfig welcomeItemConf = new TabItemConfig( - "Welcome", false); + + TabItemConfig welcomeItemConf = new TabItemConfig("Welcome", false); final WelcomePanel welcomePanel = new WelcomePanel(eventBus); - + add(welcomePanel, welcomeItemConf); - - - + addBeforeCloseHandler(new BeforeCloseHandler() { public void onBeforeClose(BeforeCloseEvent event) { if (welcomePanel == event.getItem()) { remove(welcomePanel); - tdxPanelList.remove(welcomePanel); + } } @@ -202,4 +226,60 @@ public class MainBox extends TabPanel { setActiveWidget(welcomePanel); }; + public ArrayList getSelectedRowsId() { + ArrayList rowsId = null; + Widget active = getActiveWidget(); + if (active instanceof TDXPanel) { + TDXPanel tdxPanel = (TDXPanel) active; + rowsId = tdxPanel.getTabularData().getGridPanel() + .getSelectedRowsId(); + } + return rowsId; + } + + public String getColumnName(int columnSelected) { + String columnName = null; + Widget active = getActiveWidget(); + if (active instanceof TDXPanel) { + TDXPanel tdxPanel = (TDXPanel) active; + columnName = tdxPanel.getTabularData() + .getColumnName(columnSelected); + } + return columnName; + } + + protected void retrieveTRName(final TabularResourceDataView tabularResourceDataView){ + TDGWTServiceAsync.INSTANCE.getTabResourceInformation(tabularResourceDataView.getTrId(),new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if(caught instanceof TDGWTIsLockedException){ + Log.error("Error: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", caught.getLocalizedMessage()); + } else { + Log.error("Error in get Tabular Resource Information: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", "Error in get Tabular Resource Information: " + + caught.getLocalizedMessage()); + } + } + + } + + @Override + public void onSuccess(TabResource result) { + addContentTDXPanel(tabularResourceDataView, result); + + } + }); + } + + + + } diff --git a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBoxPanel.java b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBoxPanel.java index 3fa7793..734bde2 100644 --- a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBoxPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/MainBoxPanel.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.td.mainboxwidget.client; +import java.util.ArrayList; + import org.gcube.portlets.user.td.widgetcommonevent.client.event.DataViewRequestEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType; @@ -196,5 +198,14 @@ public class MainBoxPanel extends ContentPanel { Log.debug("MainBoxPanel Updated For Curation"); } } - + + + public ArrayList getSelectedRowsId(){ + return mainBox.getSelectedRowsId(); + + } + + public String getColumnName(int columnSelected){ + return mainBox.getColumnName(columnSelected); + } } diff --git a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/tdx/TDXPanel.java b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/tdx/TDXPanel.java index 0fe41c1..8aaaa01 100644 --- a/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/tdx/TDXPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/mainboxwidget/client/tdx/TDXPanel.java @@ -93,7 +93,7 @@ public class TDXPanel extends FramedPanel { } public void update(TabularResourceDataView dataView) { - if (isDataViewRequest(dataView)) { + if (isValidDataViewRequest(dataView)) { tabularResourceDataView = dataView; TableId tableOpening = new TableId( Constants.TDX_DATASOURCE_FACTORY_ID, @@ -104,19 +104,25 @@ public class TDXPanel extends FramedPanel { } - public TabularResourceDataView getTabularResourceDataView() { - return tabularResourceDataView; - } - - public boolean isDataViewRequest(TabularResourceDataView dataViewRequest) { + public boolean isValidDataViewRequest(TabularResourceDataView dataViewRequest) { if (dataViewRequest != null && dataViewRequest.getTrId() != null - && dataViewRequest.getTrId().getId() == tabularResourceDataView - .getTrId().getId()) { + && dataViewRequest.getTrId().getId().compareTo(tabularResourceDataView + .getTrId().getId())==0) { return true; } else { return false; } } + public TabularDataX getTabularData() { + return tabularData; + } + + public TabularResourceDataView getTabularResourceDataView() { + return tabularResourceDataView; + } + + + } diff --git a/src/main/resources/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml index 9d7b916..0c70986 100644 --- a/src/main/resources/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/td/mainboxwidget/MainBox.gwt.xml @@ -16,17 +16,18 @@ + - - + + - +