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:
parent
9fef37b20a
commit
3034d7e122
|
@ -1,39 +1,35 @@
|
||||||
package org.gcube.portlets.user.td.csvexportwidget.client;
|
package org.gcube.portlets.user.td.csvexportwidget.client;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||||
|
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CSVExportWizardTD extends WizardWindow {
|
public class CSVExportWizardTD extends WizardWindow {
|
||||||
|
|
||||||
protected CSVExportSession exportSession;
|
protected CSVExportSession exportSession;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the {@link CSVTarget} to use.
|
* The id of the {@link CSVTarget} to use.
|
||||||
|
*
|
||||||
* @param targetId
|
* @param targetId
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CSVExportWizardTD(String title, EventBus eventBus) {
|
public CSVExportWizardTD(String title, EventBus eventBus) {
|
||||||
super(title,eventBus);
|
super(title, eventBus);
|
||||||
|
|
||||||
exportSession= new CSVExportSession();
|
exportSession = new CSVExportSession();
|
||||||
|
|
||||||
CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession);
|
CSVExportConfigCard csvExportConfigCard = new CSVExportConfigCard(
|
||||||
|
exportSession);
|
||||||
addCard(csvExportConfigCard);
|
addCard(csvExportConfigCard);
|
||||||
csvExportConfigCard.setup();
|
csvExportConfigCard.setup();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -53,10 +53,18 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
||||||
p = new VerticalLayoutContainer();
|
p = new VerticalLayoutContainer();
|
||||||
formPanel.setWidget(p);
|
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 = new TextField();
|
||||||
fileName.setAllowBlank(false);
|
fileName.setAllowBlank(false);
|
||||||
fileName.setWidth("410px");
|
fileName.setWidth("410px");
|
||||||
fileName.setValue("filename.csv");
|
fileName.setValue(fileN+".csv");
|
||||||
p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1,
|
p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1,
|
||||||
-1));
|
-1));
|
||||||
|
|
||||||
|
@ -78,7 +86,6 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
||||||
wpanel.setSelectableTypes(lItemType);
|
wpanel.setSelectableTypes(lItemType);
|
||||||
wpanel.addSelectionHandler(new ItemSelectionHandler() {
|
wpanel.addSelectionHandler(new ItemSelectionHandler() {
|
||||||
|
|
||||||
|
|
||||||
public void onSelection(ItemSelectionEvent event) {
|
public void onSelection(ItemSelectionEvent event) {
|
||||||
item = event.getSelectedItem();
|
item = event.getSelectedItem();
|
||||||
Log.debug("Selected Item:" + item);
|
Log.debug("Selected Item:" + item);
|
||||||
|
@ -122,11 +129,11 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
||||||
|
|
||||||
if (exportSession.getItemId() != null) {
|
if (exportSession.getItemId() != null) {
|
||||||
exportSession.setFileName(fileName.getCurrentValue());
|
exportSession.setFileName(fileName.getCurrentValue());
|
||||||
exportSession.setFileDescription(fileDescription.getCurrentValue());
|
exportSession.setFileDescription(fileDescription
|
||||||
|
.getCurrentValue());
|
||||||
goNext();
|
goNext();
|
||||||
} else {
|
} else {
|
||||||
d = new AlertMessageBox("Attention",
|
d = new AlertMessageBox("Attention", "No folder selected");
|
||||||
"No folder selected");
|
|
||||||
d.addHideHandler(hideHandler);
|
d.addHideHandler(hideHandler);
|
||||||
d.setModal(false);
|
d.setModal(false);
|
||||||
d.show();
|
d.show();
|
||||||
|
@ -182,11 +189,12 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void goNext() {
|
protected void goNext() {
|
||||||
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(exportSession);
|
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(
|
||||||
|
exportSession);
|
||||||
getWizardWindow().addCard(csvOperationInProgressCard);
|
getWizardWindow().addCard(csvOperationInProgressCard);
|
||||||
Log.info("NextCard CSVOperationInProgressCard");
|
Log.info("NextCard CSVOperationInProgressCard");
|
||||||
getWizardWindow().nextCard();
|
getWizardWindow().nextCard();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.csv.CSVExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.destination.FileDestination;
|
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.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 org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
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.ui.HasValue;
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||||
|
@ -37,9 +44,16 @@ public class DestinationSelectionCard extends WizardCard {
|
||||||
super("CSV destination selection", "");
|
super("CSV destination selection", "");
|
||||||
thisCard=this;
|
thisCard=this;
|
||||||
this.exportSession = exportSession;
|
this.exportSession = exportSession;
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
exportSession.setDestination(workspaceDestination);
|
exportSession.setDestination(workspaceDestination);
|
||||||
|
|
||||||
|
|
||||||
|
retrieveTabularResource();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create(){
|
||||||
VerticalPanel destinationSelectionPanel = new VerticalPanel();
|
VerticalPanel destinationSelectionPanel = new VerticalPanel();
|
||||||
destinationSelectionPanel.setStylePrimaryName(res.wizardCSS()
|
destinationSelectionPanel.setStylePrimaryName(res.wizardCSS()
|
||||||
.getImportSelectionSources());
|
.getImportSelectionSources());
|
||||||
|
@ -98,10 +112,51 @@ public class DestinationSelectionCard extends WizardCard {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setContent(destinationSelectionPanel);
|
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
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
Loading…
Reference in New Issue