Minor updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@85627 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
64306546d3
commit
97568e7dc4
|
@ -0,0 +1,158 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.csvexportwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.csvexportwidget.client.workspace.WorkspacePanel;
|
||||||
|
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.wizardwidget.client.WizardCard;
|
||||||
|
import org.gcube.portlets.widgets.lighttree.client.Item;
|
||||||
|
import org.gcube.portlets.widgets.lighttree.client.ItemType;
|
||||||
|
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent;
|
||||||
|
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionHandler;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CSVWorkSpaceSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
protected CSVExportSession exportSession;
|
||||||
|
protected CSVWorkSpaceSelectionCard thisCard;
|
||||||
|
|
||||||
|
|
||||||
|
protected Item item;
|
||||||
|
protected VerticalLayoutContainer p;
|
||||||
|
protected WorkspacePanel wpanel;
|
||||||
|
|
||||||
|
public CSVWorkSpaceSelectionCard(final CSVExportSession exportSession) {
|
||||||
|
super("CSV Export in Workspace", "");
|
||||||
|
|
||||||
|
this.exportSession = exportSession;
|
||||||
|
thisCard = this;
|
||||||
|
|
||||||
|
p=new VerticalLayoutContainer();
|
||||||
|
|
||||||
|
Log.debug("Set Workspace Panel");
|
||||||
|
wpanel=new WorkspacePanel();
|
||||||
|
wpanel.setSpWidth("536px");
|
||||||
|
wpanel.setSpHeight("384px");
|
||||||
|
List<ItemType> lItemType= new ArrayList<ItemType>();
|
||||||
|
lItemType.add(ItemType.ROOT);
|
||||||
|
lItemType.add(ItemType.FOLDER);
|
||||||
|
wpanel.setShowableTypes(lItemType);
|
||||||
|
wpanel.setSelectableTypes(lItemType);
|
||||||
|
wpanel.addSelectionHandler(new ItemSelectionHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(ItemSelectionEvent event) {
|
||||||
|
item=event.getSelectedItem();
|
||||||
|
Log.debug("Selected Item:"+item);
|
||||||
|
if(item.getType()==ItemType.FOLDER || item.getType()==ItemType.ROOT){
|
||||||
|
/*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 {
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Log.debug("CSVWorkSpaceSelectionCard Call Setup ");
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
Log.debug("CSVWorkSpaceSelectionCard Call sayNextCard wpanel:"+wpanel);
|
||||||
|
wpanel.disable();
|
||||||
|
wpanel.startWaiting();
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
getFileFromWorkspace();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.debug("Remove CSVWorkSpaceSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getFileFromWorkspace(){
|
||||||
|
TDGWTServiceAsync tdGwtServiceAsync=TDGWTServiceAsync.INSTANCE;
|
||||||
|
/*tdGwtServiceAsync.setFileInWorkspace(exportSession, new AsyncCallback<Void>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
wpanel.endWaiting();
|
||||||
|
thisCard.showErrorAndHide("Error", "Error retrieving the file from the workspace: "+caught.getLocalizedMessage(),
|
||||||
|
caught.toString(), caught);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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();*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue