Fixed filename on export

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@102050 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-12-15 11:17:42 +00:00
parent 9fef37b20a
commit 3034d7e122
3 changed files with 87 additions and 28 deletions

View File

@ -1,39 +1,35 @@
package org.gcube.portlets.user.td.csvexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import com.google.web.bindery.event.shared.EventBus;
/**
*
*/
public class CSVExportWizardTD extends WizardWindow {
public class CSVExportWizardTD extends WizardWindow {
protected CSVExportSession exportSession;
/**
* The id of the {@link CSVTarget} to use.
*
* @param targetId
*/
public CSVExportWizardTD(String title, EventBus eventBus) {
super(title,eventBus);
exportSession= new CSVExportSession();
CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession);
public CSVExportWizardTD(String title, EventBus eventBus) {
super(title, eventBus);
exportSession = new CSVExportSession();
CSVExportConfigCard csvExportConfigCard = new CSVExportConfigCard(
exportSession);
addCard(csvExportConfigCard);
csvExportConfigCard.setup();
}
}

View File

@ -53,10 +53,18 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
p = new VerticalLayoutContainer();
formPanel.setWidget(p);
String fileN = "Name";
if (exportSession.getTabResource() != null
&& exportSession.getTabResource().getName() != null &&
!exportSession.getTabResource().getName().isEmpty()) {
fileN=exportSession.getTabResource().getName();
fileN=fileN.trim();
}
fileName = new TextField();
fileName.setAllowBlank(false);
fileName.setWidth("410px");
fileName.setValue("filename.csv");
fileName.setValue(fileN+".csv");
p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1,
-1));
@ -78,7 +86,6 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
wpanel.setSelectableTypes(lItemType);
wpanel.addSelectionHandler(new ItemSelectionHandler() {
public void onSelection(ItemSelectionEvent event) {
item = event.getSelectedItem();
Log.debug("Selected Item:" + item);
@ -122,11 +129,11 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
if (exportSession.getItemId() != null) {
exportSession.setFileName(fileName.getCurrentValue());
exportSession.setFileDescription(fileDescription.getCurrentValue());
exportSession.setFileDescription(fileDescription
.getCurrentValue());
goNext();
} else {
d = new AlertMessageBox("Attention",
"No folder selected");
d = new AlertMessageBox("Attention", "No folder selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
@ -182,11 +189,12 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
}
protected void goNext() {
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(exportSession);
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(
exportSession);
getWizardWindow().addCard(csvOperationInProgressCard);
Log.info("NextCard CSVOperationInProgressCard");
Log.info("NextCard CSVOperationInProgressCard");
getWizardWindow().nextCard();
}
}

View File

@ -5,15 +5,22 @@ package org.gcube.portlets.user.td.csvexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.destination.FileDestination;
import org.gcube.portlets.user.td.gwtservice.shared.destination.WorkspaceDestination;
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.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.core.client.util.ToggleGroup;
@ -37,9 +44,16 @@ public class DestinationSelectionCard extends WizardCard {
super("CSV destination selection", "");
thisCard=this;
this.exportSession = exportSession;
// Default
exportSession.setDestination(workspaceDestination);
retrieveTabularResource();
}
protected void create(){
VerticalPanel destinationSelectionPanel = new VerticalPanel();
destinationSelectionPanel.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSources());
@ -98,10 +112,51 @@ public class DestinationSelectionCard extends WizardCard {
}
});
setContent(destinationSelectionPanel);
forceLayout();
}
protected void retrieveTabularResource() {
TDGWTServiceAsync.INSTANCE
.getTabResourceInformation(new AsyncCallback<TabResource>() {
public void onSuccess(TabResource result) {
Log.info("Retrived TR: " + result.getTrId());
exportSession.setTabResource(result);
create();
}
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), "",
caught);
} else {
showErrorAndHide(
"Error",
"Error retrienving tabular resource info: ",
caught.getLocalizedMessage(), caught);
}
}
}
});
}
@Override
public void setup() {