package org.gcube.portlets.user.reportgenerator.client;

import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType;
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.SimplePanel;

/**
 *
 * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
 */

public class ToolboxPanel extends SimplePanel {
	private AppControllerExplorer appController;
	private AsyncTreePanel tp;
	/**
	 * 
	 */
	public static final int TOOLBOX_WIDTH = 235;
	/**
	 * 
	 */
	public static final int TOOLBOX_HEIGHT= 800;

	public ToolboxPanel(AppControllerExplorer appController) {
		this.appController = appController;
//		AsyncTreePanel tp = appController.getTree(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
//		this.tp = tp;
//		add(tp);
//		this.appController.hideSharingFacilities(); //sharing disabled we have problems from Reports
	}

	public void showExportedVersion(String id, String fileName) {
		GWT.log("showExportedVersion");
		AppControllerExplorer.getEventBus().fireEvent(new FileDownloadEvent(id, fileName, DownloadType.SHOW));
	}
	/**
	 * refresh the root
	 */
	public void refreshRoot() {		
		appController.refreshRoot();
	}
	/**
	 * show upload file popup
	 */
	public void showUploadFile() {		
		AppControllerExplorer.getEventBus().fireEvent(new FileUploadEvent(tp.getRootItem(), UploadType.FILE));
	}
	/**
	 * lalala
	 * @return the toolbox height
	 */
	public int getTreePanelHeight() {
		return TOOLBOX_HEIGHT;
	}
}
