141 lines
3.5 KiB
Java
141 lines
3.5 KiB
Java
/**
|
|
*
|
|
*/
|
|
|
|
package org.gcube.portlets.user.workspaceexplorerapp.client;
|
|
|
|
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
|
import org.gcube.portlets.user.workspaceexplorerapp.client.grid.DisplayField;
|
|
import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
import com.google.gwt.event.dom.client.ContextMenuEvent;
|
|
import com.google.gwt.event.dom.client.ContextMenuHandler;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
import com.google.gwt.user.client.Window;
|
|
import com.google.gwt.user.client.ui.RootPanel;
|
|
|
|
/**
|
|
* The Class WorkspaceExplorerAppController.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* @Oct 8, 2014
|
|
*/
|
|
public class WorkspaceExplorerAppController {
|
|
|
|
// private VerticalPanel mainPanel = new VerticalPanel();
|
|
|
|
private WorkspaceExplorerAppPanel mainPanel;
|
|
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
|
|
private final HandlerManager eventBus = new HandlerManager(null);
|
|
|
|
/**
|
|
* Instantiates a new workspace explorer app controller.
|
|
*/
|
|
public WorkspaceExplorerAppController() {
|
|
}
|
|
|
|
/**
|
|
* Go.
|
|
*
|
|
* @param rootPanel the root panel
|
|
*/
|
|
public void go(final RootPanel rootPanel) {
|
|
RootPanel.getBodyElement().getStyle().setPadding(0, Unit.PX);
|
|
// mainPanel.setWidth("100%");
|
|
|
|
try {
|
|
String folderId = Window.Location.getParameter("folderId");
|
|
|
|
//TODO CHECK FOLDER ID
|
|
if(folderId==null)
|
|
Window.alert("Folder Id not found, it is not possible to retrieve a folder without a valid id");
|
|
|
|
RootPanel.get().addDomHandler(new ContextMenuHandler() {
|
|
|
|
@Override
|
|
public void onContextMenu(ContextMenuEvent event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
}, ContextMenuEvent.getType());
|
|
|
|
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(eventBus, folderId, false);
|
|
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
|
|
GWT.log("Listener Selected Item " + item);
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
|
|
GWT.log("There are networks problem, please check your connection.");
|
|
}
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
|
|
}
|
|
};
|
|
wsResourcesExplorerPanel.addWorkspaceExplorerSelectNotificationListener(listener);
|
|
|
|
/*new com.google.gwt.user.client.Timer() {
|
|
|
|
@Override
|
|
public void run() {
|
|
|
|
//TODO //IS A TEST REMOVE
|
|
ArrayList<Item> tests = new ArrayList<Item>();
|
|
for (int i = 0; i < 50; i++) {
|
|
tests.add(new Item(i+""+Random.nextInt(), "name"+i, false));
|
|
}
|
|
wsResourcesExplorerPanel.getWsExplorer().updateExplorer(tests);
|
|
}
|
|
}.schedule(1000);*/
|
|
|
|
mainPanel = new WorkspaceExplorerAppPanel(wsResourcesExplorerPanel);
|
|
}
|
|
catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the main panel.
|
|
*
|
|
* @return the mainPanel
|
|
*/
|
|
public WorkspaceExplorerAppPanel getMainPanel() {
|
|
return mainPanel;
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the event bus.
|
|
*
|
|
* @return the event bus
|
|
*/
|
|
public HandlerManager getEventBus(){
|
|
return eventBus;
|
|
}
|
|
|
|
/**
|
|
* Gets the display fields.
|
|
*
|
|
* @return the display fields
|
|
*/
|
|
public DisplayField[] getDisplayFields(){
|
|
return wsResourcesExplorerPanel.getDisplayFields();
|
|
}
|
|
}
|