Updated Multi Tab

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-mainbox-widget@100687 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-14 17:35:25 +00:00 committed by Giancarlo Panichi
parent 05a5f9cee7
commit 6a6dfc2788
6 changed files with 165 additions and 82 deletions

24
pom.xml
View File

@ -96,22 +96,25 @@
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId> <artifactId>common-scope-maps</artifactId>
<version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId> <artifactId>accesslogger</artifactId>
<scope>provided</scope>
</dependency> </dependency>
@ -148,27 +151,9 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-widgetx-tdx-source</artifactId> <artifactId>tabular-data-widgetx-tdx-source</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<!-- tabular-data-monitor-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-monitor-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- tabular-data-resources-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-resources-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- LOGGING --> <!-- LOGGING -->
<dependency> <dependency>
<groupId>com.allen-sauer.gwt.log</groupId> <groupId>com.allen-sauer.gwt.log</groupId>
@ -356,5 +341,4 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<packaging>war</packaging>
</project> </project>

View File

@ -7,26 +7,27 @@
<inherits name='com.sencha.gxt.ui.GXT' /> <inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> --> <!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!-- We need the JUnit module in the main module, --> <!-- We need the JUnit module in the main module, -->
<!-- otherwise eclipse complains (Google plugin bug?) --> <!-- otherwise eclipse complains (Google plugin bug?) -->
<inherits name='com.google.gwt.junit.JUnit' /> <inherits name='com.google.gwt.junit.JUnit' />
<inherits name="org.gcube.portlets.user.tdwx.TabularDataWidgetX" /> <inherits name="org.gcube.portlets.user.tdwx.TabularDataWidgetX" />
<inherits <inherits
name='org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent' /> name='org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent' />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' /> <!-- <inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD'
<inherits name='org.gcube.portlets.user.td.resourceswidget.ResourcesWidget' /> /> -->
<!-- <inherits name='org.gcube.portlets.user.td.resourceswidget.ResourcesWidget'
/> -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.td.mainboxwidget.client.MainBoxEntry' <!-- <entry-point
/> class='org.gcube.portlets.user.td.mainboxwidget.client.MainBoxEntry' /> -->
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />

View File

@ -2,10 +2,17 @@ package org.gcube.portlets.user.td.mainboxwidget.client;
import java.util.ArrayList; 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.resources.MainboxResources;
import org.gcube.portlets.user.td.mainboxwidget.client.tdx.TDXPanel; 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.mainboxwidget.client.welcome.WelcomePanel;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.DataViewActiveEvent; 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.DataView;
import org.gcube.portlets.user.td.widgetcommonevent.shared.dataview.TabularResourceDataView; 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.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler; 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.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.theme.blue.client.tabs.BlueTabPanelBottomAppearance; import com.sencha.gxt.theme.blue.client.tabs.BlueTabPanelBottomAppearance;
@ -34,53 +42,56 @@ public class MainBox extends TabPanel {
protected ArrayList<TDXPanel> tdxPanelList; protected ArrayList<TDXPanel> tdxPanelList;
public MainBox(String name, EventBus eventBus, MainBoxPanel mainBoxPanel) { public MainBox(String name, EventBus eventBus, MainBoxPanel mainBoxPanel) {
super(GWT.<TabPanelAppearance> create(BlueTabPanelBottomAppearance.class)); super(
GWT.<TabPanelAppearance> create(BlueTabPanelBottomAppearance.class));
Log.debug("Create MainBox"); Log.debug("Create MainBox");
setId(name); setId(name);
this.eventBus = eventBus; this.eventBus = eventBus;
this.mainBoxPanel = mainBoxPanel; this.mainBoxPanel = mainBoxPanel;
init(); init();
} }
protected void init(){ protected void init() {
setBodyBorder(false); setBodyBorder(false);
setBorders(false); setBorders(false);
setAnimScroll(true); setAnimScroll(true);
setTabScroll(true); setTabScroll(true);
setCloseContextMenu(true); setCloseContextMenu(true);
setResizeTabs(true); setResizeTabs(true);
//setTabWidth(Integer.MAX_VALUE); // setTabWidth(Integer.MAX_VALUE);
setMinTabWidth(20); setMinTabWidth(20);
//setResizeTabs(true); // setResizeTabs(true);
tdxPanelList = new ArrayList<TDXPanel>(); tdxPanelList = new ArrayList<TDXPanel>();
// setResizeTabs(true); // setResizeTabs(true);
addSelectionHandler(new SelectionHandler<Widget>() { addSelectionHandler(new SelectionHandler<Widget>() {
@Override @Override
public void onSelection(SelectionEvent<Widget> event) { public void onSelection(SelectionEvent<Widget> event) {
Widget widget=event.getSelectedItem(); Widget widget = event.getSelectedItem();
if(widget instanceof TDXPanel){ if (widget instanceof TDXPanel) {
TDXPanel tdxPanel=(TDXPanel) widget; TDXPanel tdxPanel = (TDXPanel) widget;
TabularResourceDataView tabularResourceDataView=tdxPanel.getTabularResourceDataView(); TabularResourceDataView tabularResourceDataView = tdxPanel
DataViewActiveEvent dataViewActiveEvent=new DataViewActiveEvent(tabularResourceDataView); .getTabularResourceDataView();
DataViewActiveEvent dataViewActiveEvent = new DataViewActiveEvent(
tabularResourceDataView);
eventBus.fireEvent(dataViewActiveEvent); eventBus.fireEvent(dataViewActiveEvent);
} else { } else {
} }
forceLayout(); forceLayout();
} }
}); });
} }
public void startTabs() { public void startTabs() {
Log.debug("Start MainBox Tabs"); Log.debug("Start MainBox Tabs");
//addWelcomeTab(); // addWelcomeTab();
//setActiveWidget(getWidget(0)); // setActiveWidget(getWidget(0));
} }
public void openTDXTab(DataView dataView) { public void openTDXTab(DataView dataView) {
@ -117,19 +128,21 @@ public class MainBox extends TabPanel {
if (dataView instanceof TabularResourceDataView) { if (dataView instanceof TabularResourceDataView) {
TabularResourceDataView tabularResourceDataView = (TabularResourceDataView) dataView; TabularResourceDataView tabularResourceDataView = (TabularResourceDataView) dataView;
boolean found=false; boolean found = false;
for (TDXPanel tdxPanel : tdxPanelList) { for (TDXPanel tdxPanel : tdxPanelList) {
if(tdxPanel.isDataViewRequest(tabularResourceDataView)){ if (tdxPanel
.isValidDataViewRequest(tabularResourceDataView)) {
tdxPanel.update(tabularResourceDataView); tdxPanel.update(tabularResourceDataView);
found=true; //TabItemConfig tabItemConfig=getConfig(tdxPanel);
found = true;
break; break;
} }
} }
if(!found){ if (!found) {
addTDXPanel(tabularResourceDataView); addTDXPanel(tabularResourceDataView);
} }
} }
forceLayout(); forceLayout();
} catch (Throwable e) { } catch (Throwable e) {
@ -138,8 +151,6 @@ public class MainBox extends TabPanel {
} }
} }
protected void addTDXPanel(TabularResourceDataView tabularResourceDataView) { protected void addTDXPanel(TabularResourceDataView tabularResourceDataView) {
for (TDXPanel tdxPanel : tdxPanelList) { for (TDXPanel tdxPanel : tdxPanelList) {
if (tdxPanel.getTabularResourceDataView().getTrId().getId() if (tdxPanel.getTabularResourceDataView().getTrId().getId()
@ -149,51 +160,64 @@ public class MainBox extends TabPanel {
return; return;
} }
} }
retrieveTRName(tabularResourceDataView);
};
protected void addContentTDXPanel(TabularResourceDataView tabularResourceDataView,TabResource tabResource){
TabItemConfig tdxPanelItemConf = new TabItemConfig( TabItemConfig tdxPanelItemConf = new TabItemConfig(
tabularResourceDataView.getTrId().getId(), true); tabResource.getName(), true);
tdxPanelItemConf.setIcon(MainboxResources.INSTANCE.tabularResource()); tdxPanelItemConf.setIcon(MainboxResources.INSTANCE.tabularResource());
final TDXPanel tdxPanel = new TDXPanel(eventBus); final TDXPanel tdxPanel = new TDXPanel(eventBus);
tdxPanel.open(tabularResourceDataView); tdxPanel.open(tabularResourceDataView);
tdxPanelList.add(tdxPanel); tdxPanelList.add(tdxPanel);
add(tdxPanel, tdxPanelItemConf); add(tdxPanel, tdxPanelItemConf);
addBeforeCloseHandler(new BeforeCloseHandler<Widget>() { addBeforeCloseHandler(new BeforeCloseHandler<Widget>() {
public void onBeforeClose(BeforeCloseEvent<Widget> event) { public void onBeforeClose(BeforeCloseEvent<Widget> event) {
if (tdxPanel == event.getItem()) { if (tdxPanel == event.getItem()) {
remove(tdxPanel); remove(tdxPanel);
tdxPanelList.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); setActiveWidget(tdxPanel);
}; }
protected void addWelcomeTab() { protected void addWelcomeTab() {
TabItemConfig welcomeItemConf = new TabItemConfig("Welcome", false);
TabItemConfig welcomeItemConf = new TabItemConfig(
"Welcome", false);
final WelcomePanel welcomePanel = new WelcomePanel(eventBus); final WelcomePanel welcomePanel = new WelcomePanel(eventBus);
add(welcomePanel, welcomeItemConf); add(welcomePanel, welcomeItemConf);
addBeforeCloseHandler(new BeforeCloseHandler<Widget>() { addBeforeCloseHandler(new BeforeCloseHandler<Widget>() {
public void onBeforeClose(BeforeCloseEvent<Widget> event) { public void onBeforeClose(BeforeCloseEvent<Widget> event) {
if (welcomePanel == event.getItem()) { if (welcomePanel == event.getItem()) {
remove(welcomePanel); remove(welcomePanel);
tdxPanelList.remove(welcomePanel);
} }
} }
@ -202,4 +226,60 @@ public class MainBox extends TabPanel {
setActiveWidget(welcomePanel); setActiveWidget(welcomePanel);
}; };
public ArrayList<String> getSelectedRowsId() {
ArrayList<String> 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<TabResource>() {
@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);
}
});
}
} }

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.td.mainboxwidget.client; 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.DataViewRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType; 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"); Log.debug("MainBoxPanel Updated For Curation");
} }
} }
public ArrayList<String> getSelectedRowsId(){
return mainBox.getSelectedRowsId();
}
public String getColumnName(int columnSelected){
return mainBox.getColumnName(columnSelected);
}
} }

View File

@ -93,7 +93,7 @@ public class TDXPanel extends FramedPanel {
} }
public void update(TabularResourceDataView dataView) { public void update(TabularResourceDataView dataView) {
if (isDataViewRequest(dataView)) { if (isValidDataViewRequest(dataView)) {
tabularResourceDataView = dataView; tabularResourceDataView = dataView;
TableId tableOpening = new TableId( TableId tableOpening = new TableId(
Constants.TDX_DATASOURCE_FACTORY_ID, Constants.TDX_DATASOURCE_FACTORY_ID,
@ -104,19 +104,25 @@ public class TDXPanel extends FramedPanel {
} }
public TabularResourceDataView getTabularResourceDataView() { public boolean isValidDataViewRequest(TabularResourceDataView dataViewRequest) {
return tabularResourceDataView;
}
public boolean isDataViewRequest(TabularResourceDataView dataViewRequest) {
if (dataViewRequest != null if (dataViewRequest != null
&& dataViewRequest.getTrId() != null && dataViewRequest.getTrId() != null
&& dataViewRequest.getTrId().getId() == tabularResourceDataView && dataViewRequest.getTrId().getId().compareTo(tabularResourceDataView
.getTrId().getId()) { .getTrId().getId())==0) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
public TabularDataX getTabularData() {
return tabularData;
}
public TabularResourceDataView getTabularResourceDataView() {
return tabularResourceDataView;
}
} }

View File

@ -16,17 +16,18 @@
<inherits name="org.gcube.portlets.user.tdwx.TabularDataWidgetX" /> <inherits name="org.gcube.portlets.user.tdwx.TabularDataWidgetX" />
<inherits <inherits
name='org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent' /> name='org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent' />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' /> <!-- <inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' /> -->
<inherits name='org.gcube.portlets.user.td.resourceswidget.ResourcesWidget' /> <!-- <inherits name='org.gcube.portlets.user.td.resourceswidget.ResourcesWidget' /> -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.td.mainboxwidget.client.MainBoxEntry' <!-- <entry-point class='org.gcube.portlets.user.td.mainboxwidget.client.MainBoxEntry'
/> /> -->
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />