Updated CSVWorkSpaceSelectionCard
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@85388 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d47259651d
commit
93d6b9daf6
|
@ -3,9 +3,6 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
|
|||
import org.gcube.portlets.user.td.csvimportwidget.client.general.WizardWindow;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Command;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -13,7 +10,7 @@ import com.google.gwt.user.client.Command;
|
|||
public class CSVImportWizardTD extends WizardWindow {
|
||||
|
||||
protected CSVImportSession importSession;
|
||||
private CSVImportWizardTD wizard;
|
||||
//private CSVImportWizardTD wizard;
|
||||
|
||||
/**
|
||||
* The id of the {@link CSVTarget} to use.
|
||||
|
@ -26,44 +23,11 @@ public class CSVImportWizardTD extends WizardWindow {
|
|||
setHeight(520);
|
||||
|
||||
importSession= new CSVImportSession();
|
||||
this.wizard=this;
|
||||
//this.wizard=this;
|
||||
|
||||
SourceSelectionCard sourceSelection= new SourceSelectionCard(importSession);
|
||||
addCard(sourceSelection);
|
||||
|
||||
|
||||
|
||||
Command sayNextCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
String sourceId = importSession.getSource().getId();
|
||||
if (sourceId == null || sourceId.isEmpty()) {
|
||||
Log.error("CSV Import Source Id: " + sourceId);
|
||||
wizard.showErrorAndHide("CSV Import Source Id is"+sourceId,"Error in source selection", "Error in source Selection",new Throwable("CSV Import Source Id is"+sourceId));
|
||||
} else {
|
||||
if (sourceId.compareTo("File") == 0) {
|
||||
CSVUploadFileCard csvUploadFileCard = new CSVUploadFileCard(importSession);
|
||||
wizard.addCard(csvUploadFileCard);
|
||||
Log.info("NextCard CSVUploadFileCard");
|
||||
wizard.nextCard();
|
||||
} else {
|
||||
if (sourceId.compareTo("Workspace") == 0) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
wizard.showErrorAndHide("CSV Import error creating next card","CSV Import error creating next card", "CSV Import error creating next card",e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.setNextButtonCommand(sayNextCard);
|
||||
|
||||
|
||||
sourceSelection.setup();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,25 +6,14 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
|
|||
import org.gcube.portlets.user.td.csvimportwidget.client.general.WizardCard;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.workspace.WorkspacePanel;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||
import org.gcube.portlets.widgets.lighttree.client.Item;
|
||||
import org.gcube.portlets.widgets.lighttree.client.ItemType;
|
||||
import org.gcube.portlets.widgets.lighttree.client.WorkspaceLightTreePanel;
|
||||
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent;
|
||||
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionHandler;
|
||||
import org.gcube.portlets.widgets.lighttree.client.event.PopupEvent;
|
||||
import org.gcube.portlets.widgets.lighttree.client.event.PopupHandler;
|
||||
import org.gcube.portlets.widgets.lighttree.client.load.WorkspaceLightTreeLoadPopup;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -37,10 +26,8 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
|||
protected CSVImportSession importSession;
|
||||
protected CSVWorkSpaceSelectionCard thisCard;
|
||||
|
||||
protected TextField inputField;
|
||||
protected TextButton browseButton;
|
||||
protected String workspaceItemId;
|
||||
|
||||
protected Item item;
|
||||
protected VerticalLayoutContainer p;
|
||||
|
||||
public CSVWorkSpaceSelectionCard(final CSVImportSession importSession) {
|
||||
|
@ -50,74 +37,51 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
|
|||
thisCard = this;
|
||||
|
||||
p=new VerticalLayoutContainer();
|
||||
/*
|
||||
* HorizontalLayoutContainer c = new HorizontalLayoutContainer();
|
||||
|
||||
inputField = new TextField();
|
||||
inputField.setWidth("150px");
|
||||
inputField.setReadOnly(true);
|
||||
inputField.setAllowBlank(false);
|
||||
inputField.setToolTip("Select the csv file to import from your workspace");
|
||||
inputField.setEmptyText("a CSV file...");
|
||||
inputField.setWidth("100%");
|
||||
|
||||
browseButton = new TextButton("Browse");
|
||||
browseButton.addSelectHandler(new SelectHandler(){
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
c.add(new FieldLabel(inputField, "File"));
|
||||
c.add(browseButton);
|
||||
p.add(c,new VerticalLayoutData(-1,-1,new Margins(10)));
|
||||
*/
|
||||
|
||||
Log.debug("Set Workspace Panel");
|
||||
WorkspacePanel wpanel=new WorkspacePanel();
|
||||
wpanel.setSpWidth("536px");
|
||||
wpanel.setSpHeight("384px");
|
||||
//wpanel.setFoldersNonSelectable();
|
||||
/*wpanel.setShowableTypes(ItemType.EXTERNAL_FILE);
|
||||
//wpanel.setShowableTypes(ItemType.EXTERNAL_FILE);
|
||||
wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE);
|
||||
wpanel.setAllowedMimeTypes("text/csv", "application/zip", "application/x-zip", "application/x-zip-compressed", "application/octet-stream", "application/x-compress", "application/x-compressed", "multipart/x-zip");
|
||||
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");
|
||||
wpanel.addSelectionHandler(new ItemSelectionHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelection(ItemSelectionEvent event) {
|
||||
Log.debug("Selected Item:"+event.getSelectedItem());
|
||||
item=event.getSelectedItem();
|
||||
Log.debug("Selected Item:"+item);
|
||||
if(item.getType()==ItemType.EXTERNAL_FILE){
|
||||
String filename=item.getName();
|
||||
if(filename!=null&&!filename.isEmpty()){
|
||||
if(filename.compareToIgnoreCase("empty")!=0){
|
||||
Log.debug("Item name: "+filename);
|
||||
Log.debug("Item path: "+item.getPath());
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
} else {
|
||||
Log.debug("Item"+filename);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
}
|
||||
} else {
|
||||
Log.debug("Item name null or empty");
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.debug("Item type:"+item.getType());
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
p.add(wpanel);
|
||||
wpanel.loadTree();
|
||||
setContent(p);
|
||||
|
||||
}
|
||||
|
||||
void showWorkSpacePopup() {
|
||||
WorkspaceLightTreeLoadPopup loadPopup = new WorkspaceLightTreeLoadPopup("Select a CSV file", false, true);
|
||||
loadPopup.setFoldersNonSelectable();
|
||||
loadPopup.setShowableTypes(ItemType.EXTERNAL_FILE);
|
||||
loadPopup.setSelectableTypes(ItemType.EXTERNAL_FILE);
|
||||
loadPopup.setAllowedMimeTypes("text/csv", "application/zip", "application/x-zip", "application/x-zip-compressed", "application/octet-stream", "application/x-compress", "application/x-compressed", "multipart/x-zip");
|
||||
|
||||
loadPopup.addPopupHandler(new PopupHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onPopup(PopupEvent event) {
|
||||
if (!event.isCanceled()) {
|
||||
inputField.setValue(event.getSelectedItem().getName());
|
||||
workspaceItemId = event.getSelectedItem().getId();
|
||||
}
|
||||
}
|
||||
});
|
||||
loadPopup.setPopupPosition(this.getAbsoluteLeft()+10, this.getAbsoluteTop()+20);
|
||||
loadPopup.show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue