115 lines
3.7 KiB
Java
115 lines
3.7 KiB
Java
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.project;
|
|
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.MainCodeDescription;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.ImportCodeDescription;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
|
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.google.gwt.event.shared.EventBus;
|
|
import com.sencha.gxt.core.client.dom.XDOM;
|
|
|
|
|
|
|
|
/**
|
|
*
|
|
* @author giancarlo
|
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class ProjectManager {
|
|
private EventBus eventBus;
|
|
private String projectFolderId;
|
|
|
|
public ProjectManager(EventBus eventBus){
|
|
this.eventBus=eventBus;
|
|
}
|
|
|
|
public void createProject(){
|
|
/*
|
|
List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
|
selectableTypes.add(ItemType.FOLDER);
|
|
List<ItemType> showableTypes = new ArrayList<ItemType>();
|
|
showableTypes.addAll(Arrays.asList(ItemType.FOLDER));
|
|
*/
|
|
/*
|
|
List<String> allowedMimeTypes = Arrays.asList("text/csv",
|
|
"application/zip", "application/x-zip",
|
|
"application/x-zip-compressed", "application/octet-stream",
|
|
"application/x-compress", "application/x-compressed",
|
|
"multipart/x-zip");
|
|
List<String> allowedFileExtensions = Arrays.asList("csv", "zip");
|
|
|
|
FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,
|
|
allowedFileExtensions, new HashMap<String, String>());
|
|
*/
|
|
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
|
"Select Project Folder",true);
|
|
|
|
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
|
|
if (item.getType() == ItemType.FOLDER) {
|
|
createProjectOnWorkspace(item);
|
|
|
|
} else {
|
|
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
throwable.printStackTrace();
|
|
}
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
|
}
|
|
};
|
|
|
|
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
|
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
|
wselectDialog.show();
|
|
}
|
|
|
|
protected void createProjectOnWorkspace(Item item){
|
|
Log.debug("Item selected: "+item);
|
|
projectFolderId=item.getId();
|
|
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.OPEN, projectFolderId);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired");
|
|
|
|
}
|
|
|
|
public void importCode(ImportCodeDescription importCodeDesc) {
|
|
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.UPDATE, projectFolderId);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired");
|
|
|
|
}
|
|
|
|
public void setMainCode(MainCodeDescription mainCodeDescription) {
|
|
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.UPDATE, projectFolderId);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|