428: TDM - Support the new Workspace Explorer

Task-Url: https://support.d4science.org/issues/428

Updated support to workspace explorer

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@117578 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-07-30 16:36:55 +00:00
parent a5edf9072b
commit 9465360319
6 changed files with 190 additions and 123 deletions

20
pom.xml
View File

@ -43,13 +43,13 @@
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<configDirectory>config</configDirectory> <configDirectory>config</configDirectory>
<!-- Next --> <!-- Next -->
<gwtVersion>2.6.1</gwtVersion> <gwtVersion>2.6.1</gwtVersion>
<gwtLogVersion>3.3.2</gwtLogVersion> <gwtLogVersion>3.3.2</gwtLogVersion>
<gxtVersion>3.1.1</gxtVersion> <gxtVersion>3.1.1</gxtVersion>
<KEYS>${env.KEYS}</KEYS> <KEYS>${env.KEYS}</KEYS>
<!-- GWT needs at least java 1.5 --> <!-- GWT needs at least java 1.5 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -115,7 +115,7 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- tabular-data-monitor-widget --> <!-- tabular-data-monitor-widget -->
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
@ -140,6 +140,14 @@
<version>[2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-explorer</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
@ -162,7 +170,7 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<!-- JUnit --> <!-- JUnit -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
/** /**
@ -10,6 +11,8 @@ import com.google.web.bindery.event.shared.EventBus;
public class CSVImportWizardTD extends WizardWindow { public class CSVImportWizardTD extends WizardWindow {
protected CSVImportSession importSession; protected CSVImportSession importSession;
protected String WIZARDWIDTH = "712px";
protected String WIZARDHEIGHT = "520px";
//private CSVImportWizardTD wizard; //private CSVImportWizardTD wizard;
/** /**
@ -19,6 +22,7 @@ public class CSVImportWizardTD extends WizardWindow {
public CSVImportWizardTD(String title, EventBus eventBus) { public CSVImportWizardTD(String title, EventBus eventBus) {
super(title,eventBus); super(title,eventBus);
setWidth(WIZARDWIDTH);
importSession= new CSVImportSession(); importSession= new CSVImportSession();
//this.wizard=this; //this.wizard=this;

View File

@ -3,23 +3,30 @@
*/ */
package org.gcube.portlets.user.td.csvimportwidget.client; package org.gcube.portlets.user.td.csvimportwidget.client;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import java.util.ArrayList;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import java.util.Arrays;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import java.util.HashMap;
import org.gcube.portlets.user.td.csvimportwidget.client.workspace.WorkspacePanel; import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.widgets.lighttree.client.Item; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.widgets.lighttree.client.ItemType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionHandler; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectPanel;
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.MarginData; import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/** /**
* *
@ -28,76 +35,105 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
* *
*/ */
public class CSVWorkSpaceSelectionCard extends WizardCard { public class CSVWorkSpaceSelectionCard extends WizardCard {
protected CSVImportSession importSession; protected CSVImportSession importSession;
protected CSVWorkSpaceSelectionCard thisCard; protected CSVWorkSpaceSelectionCard thisCard;
protected ItemType item;
protected Item item;
protected VerticalLayoutContainer p; protected VerticalLayoutContainer p;
protected WorkspacePanel wpanel; protected WorkspaceExplorerSelectPanel wpanel;
public CSVWorkSpaceSelectionCard(final CSVImportSession importSession) { public CSVWorkSpaceSelectionCard(final CSVImportSession importSession) {
super("CSV Import From Workspace", ""); super("CSV Import From Workspace", "");
this.importSession = importSession; this.importSession = importSession;
thisCard = this; thisCard = this;
p=new VerticalLayoutContainer(); p = new VerticalLayoutContainer();
Log.debug("Set Workspace Panel"); Log.debug("Set Workspace Panel");
wpanel=new WorkspacePanel(); List<ItemType> selectableTypes = new ArrayList<ItemType>();
wpanel.setSpWidth("536px"); selectableTypes.add(ItemType.EXTERNAL_FILE);
wpanel.setSpHeight("384px"); List<ItemType> showableTypes = new ArrayList<ItemType>();
//wpanel.setShowableTypes(ItemType.EXTERNAL_FILE); showableTypes.addAll(Arrays.asList(ItemType.values()));
wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE);
wpanel.getSelectableTypes().remove(ItemType.ROOT); List<String> allowedMimeTypes = Arrays.asList("text/csv",
wpanel.getSelectableTypes().remove(ItemType.FOLDER); "application/zip", "application/x-zip",
wpanel.setAllowedMimeTypes("text/csv", "application/zip", "application/x-zip", "application/x-zip-compressed", "application/octet","application/octet-stream"); "application/x-zip-compressed", "application/octet",
wpanel.addSelectionHandler(new ItemSelectionHandler() { "application/octet-stream");
List<String> allowedFileExtensions = Arrays.asList("csv", "zip");
public void onSelection(ItemSelectionEvent event) { FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,
item=event.getSelectedItem(); allowedFileExtensions, new HashMap<String,String>());
Log.debug("Selected Item:"+item);
if(item.getType()==ItemType.EXTERNAL_FILE){ wpanel = new WorkspaceExplorerSelectPanel(new String(
String filename=item.getName(); "Workspace Selection"), filterCriteria);
if(filename!=null&&!filename.isEmpty()){
Log.debug("Item name: "+filename); // wpanel.setSpWidth("536px");
Log.debug("Item path: "+item.getPath()); // wpanel.setSpHeight("384px");
// wpanel.setShowableTypes(ItemType.EXTERNAL_FILE);
importSession.setItemId(item.getId()); // wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE);
getWizardWindow().setEnableNextButton(true); // wpanel.getSelectableTypes().remove(ItemType.ROOT);
// wpanel.getSelectableTypes().remove(ItemType.FOLDER);
// wpanel.setAllowedMimeTypes("text/csv", "application/zip",
// "application/x-zip", "application/x-zip-compressed",
// "application/octet","application/octet-stream");
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
@Override
public void onSelectedItem(Item item) {
Log.debug("Selected Item:" + item);
if (item.getType() == ItemType.EXTERNAL_FILE) {
String filename = item.getName();
if (filename != null && !filename.isEmpty()) {
Log.debug("Item name: " + filename);
Log.debug("Item path: " + item.getPath());
importSession.setItemId(item.getId());
getWizardWindow().setEnableNextButton(true);
} else { } else {
Log.debug("Item name null or empty"); Log.debug("Item name null or empty");
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
} }
} else { } else {
Log.debug("Item type:"+item.getType()); Log.debug("Item type:" + item.getType());
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
} }
} }
});
p.add(wpanel); @Override
wpanel.loadTree(); public void onFailed(Throwable throwable) {
Log.error("Error in workspaceExplorer: "
+ throwable.getLocalizedMessage());
throwable.printStackTrace();
}
@Override
public void onAborted() {
Log.debug("WorkspaceExplorer Aborted");
}
};
wpanel.addWorkspaceExplorerSelectNotificationListener(handler);
p.add(wpanel, new VerticalLayoutData(1, 1, new Margins(0)));
setCenterWidget(p, new MarginData(0)); setCenterWidget(p, new MarginData(0));
} }
@Override @Override
public void setup() { public void setup() {
Log.debug("CSVWorkSpaceSelectionCard Call Setup "); Log.debug("CSVWorkSpaceSelectionCard Call Setup ");
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
Log.debug("CSVWorkSpaceSelectionCard Call sayNextCard wpanel:"+wpanel); Log.debug("CSVWorkSpaceSelectionCard Call sayNextCard wpanel:"
wpanel.disable(); + wpanel);
wpanel.startWaiting();
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false); getWizardWindow().setEnableBackButton(false);
getFileFromWorkspace(); getFileFromWorkspace();
@ -123,39 +159,41 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
} }
protected void getFileFromWorkspace(){
TDGWTServiceAsync tdGwtServiceAsync=TDGWTServiceAsync.INSTANCE;
tdGwtServiceAsync.getFileFromWorkspace(importSession, new AsyncCallback<Void>(){
public void onFailure(Throwable caught) { protected void getFileFromWorkspace() {
wpanel.endWaiting(); TDGWTServiceAsync tdGwtServiceAsync = TDGWTServiceAsync.INSTANCE;
if (caught instanceof TDGWTSessionExpiredException) { tdGwtServiceAsync.getFileFromWorkspace(importSession,
getEventBus().fireEvent(new SessionExpiredEvent( new AsyncCallback<Void>() {
SessionExpiredType.EXPIREDONSERVER));
} else { public void onFailure(Throwable caught) {
thisCard.showErrorAndHide("Error", "Error retrieving the file from the workspace.", if (caught instanceof TDGWTSessionExpiredException) {
caught.getLocalizedMessage(), caught); getEventBus()
} .fireEvent(
} new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
thisCard.showErrorAndHide(
"Error",
"Error retrieving the file from the workspace.",
caught.getLocalizedMessage(), caught);
}
}
public void onSuccess(Void result) {
goForward();
}
});
}
protected void goForward() {
CSVConfigCard csvConfigCard = new CSVConfigCard(importSession);
getWizardWindow().addCard(csvConfigCard);
Log.info("NextCard CSVConfigCard");
getWizardWindow().nextCard();
public void onSuccess(Void result) {
wpanel.endWaiting();
goForward();
}
});
}
protected void goForward(){
CSVConfigCard csvConfigCard = new CSVConfigCard(importSession);
getWizardWindow().addCard(csvConfigCard);
Log.info("NextCard CSVConfigCard");
getWizardWindow().nextCard();
} }
} }

View File

@ -130,6 +130,7 @@ public class SourceSelectionCard extends WizardCard {
} }
} catch (Exception e) { } catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage()); Log.error("sayNextCard :" + e.getLocalizedMessage());
e.printStackTrace();
} }
} }
}; };

View File

@ -1,36 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='CSVImportWizardTD'> <module rename-to='CSVImportWizardTD'>
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- 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' />
<!-- Inherit the default GWT style sheet. You can change --> <!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting --> <!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. --> <!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' /> <inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <!-- Other module inherits -->
<inherits name='com.sencha.gxt.ui.GXT' /> <inherits name='com.sencha.gxt.ui.GXT' />
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' /> <inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' /> <inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' /> <inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<inherits name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' /> <inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
<inherits
<!-- Specify the app entry point class. --> name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' />
<!-- <entry-point class='org.gcube.portlets.user.SDMXImportWizardTD.client.SDMXImportWizardTDEntry' /> -->
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.SDMXImportWizardTD.client.SDMXImportWizardTDEntry'
/> -->
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- <source path='org.gcube.data.analysis.tabulardata.operation.worker'/> -->
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- <source path='org.gcube.data.analysis.tabulardata.operation.worker'/> -->
</module> </module>

View File

@ -4,13 +4,13 @@
"http://java.sun.com/dtd/web-app_2_3.dtd"> "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app> <web-app>
<!-- Servlets --> <!-- Servlets -->
<servlet> <servlet>
<servlet-name>TDGWTService</servlet-name> <servlet-name>TDGWTService</servlet-name>
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl</servlet-class>
</servlet> </servlet>
<servlet> <servlet>
<servlet-name>jUnitHostImpl</servlet-name> <servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class> <servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
@ -20,8 +20,14 @@
<servlet-name>WorkspaceLightService</servlet-name> <servlet-name>WorkspaceLightService</servlet-name>
<servlet-class>org.gcube.portlets.widgets.lighttree.server.WorkspaceServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.widgets.lighttree.server.WorkspaceServiceImpl</servlet-class>
</servlet> </servlet>
<servlet>
<servlet-name>workspaceExplorer</servlet-name>
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
</servlet>
<!-- Servlets Mapping --> <!-- Servlets Mapping -->
<servlet-mapping> <servlet-mapping>
<servlet-name>TDGWTService</servlet-name> <servlet-name>TDGWTService</servlet-name>
@ -31,13 +37,19 @@
<servlet-name>jUnitHostImpl</servlet-name> <servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>CSVImportWizardTDManagerWidgets/junithost/*</url-pattern> <url-pattern>CSVImportWizardTDManagerWidgets/junithost/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>WorkspaceLightService</servlet-name> <servlet-name>WorkspaceLightService</servlet-name>
<url-pattern>/CSVImportWizardTDManagerWidgets/WorkspaceLightService</url-pattern> <url-pattern>/CSVImportWizardTDManagerWidgets/WorkspaceLightService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>workspaceExplorer</servlet-name>
<url-pattern>/CSVImportWizardTDManagerWidgets/WorkspaceExplorerService</url-pattern>
</servlet-mapping>
<!-- Default page to serve --> <!-- Default page to serve -->
<welcome-file-list> <welcome-file-list>
<welcome-file>CSVImportWizardTD.html</welcome-file> <welcome-file>CSVImportWizardTD.html</welcome-file>