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>
<artifactId>common-scope-maps</artifactId>
<version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId>
<scope>provided</scope>
</dependency>
@ -148,27 +151,9 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-widgetx-tdx-source</artifactId>
<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>
</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 -->
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>
@ -356,5 +341,4 @@
</dependencies>
</dependencyManagement>
<packaging>war</packaging>
</project>

View File

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

View File

@ -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<TDXPanel> tdxPanelList;
public MainBox(String name, EventBus eventBus, MainBoxPanel mainBoxPanel) {
super(GWT.<TabPanelAppearance> create(BlueTabPanelBottomAppearance.class));
super(
GWT.<TabPanelAppearance> 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<TDXPanel>();
// setResizeTabs(true);
addSelectionHandler(new SelectionHandler<Widget>() {
@Override
public void onSelection(SelectionEvent<Widget> 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<Widget>() {
public void onBeforeClose(BeforeCloseEvent<Widget> 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<Widget>() {
public void onBeforeClose(BeforeCloseEvent<Widget> event) {
if (welcomePanel == event.getItem()) {
remove(welcomePanel);
tdxPanelList.remove(welcomePanel);
}
}
@ -202,4 +226,60 @@ public class MainBox extends TabPanel {
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;
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<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) {
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;
}
}

View File

@ -16,17 +16,18 @@
<inherits name="org.gcube.portlets.user.tdwx.TabularDataWidgetX" />
<inherits
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.resourceswidget.ResourcesWidget' />
<!-- <inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' /> -->
<!-- <inherits name='org.gcube.portlets.user.td.resourceswidget.ResourcesWidget' /> -->
<!-- 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 -->
<source path='client' />