package org.gcube.portlets.user.workspace.client.view.toolbars;
//
//import org.gcube.portlets.user.workspace.client.AppController;
//import org.gcube.portlets.user.workspace.client.ConstantsPortlet;
//import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeInResult;
//import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
//import org.gcube.portlets.user.workspace.client.event.DeleteItemEvent;
//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.event.RenameItemEvent;
//import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
//import org.gcube.portlets.user.workspace.client.model.FileGridModel;
//import org.gcube.portlets.user.workspace.client.resources.Resources;
//import org.gcube.portlets.user.workspace.client.view.GxtListView;
//import org.gcube.portlets.user.workspace.client.view.grids.GxtGridFilterGroupPanel;
//import org.gcube.portlets.user.workspace.client.view.grids.GxtGridMessagesFilterPanel;
//
//import com.extjs.gxt.ui.client.Style.ButtonArrowAlign;
//import com.extjs.gxt.ui.client.Style.ButtonScale;
//import com.extjs.gxt.ui.client.Style.IconAlign;
//import com.extjs.gxt.ui.client.event.ButtonEvent;
//import com.extjs.gxt.ui.client.event.SelectionListener;
//import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
//import com.extjs.gxt.ui.client.widget.button.Button;
//import com.extjs.gxt.ui.client.widget.button.ToggleButton;
//import com.extjs.gxt.ui.client.widget.layout.CardLayout;
//import com.extjs.gxt.ui.client.widget.layout.FitLayout;
//import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
//import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
//import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
//import com.google.gwt.user.client.Element;
//  
/**
 * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
 * THIS CLASS IS NOT USED
 */
public class GxtToolBarFunctionsPanel extends LayoutContainer {  
//  
////	private GxtGridFilterPanel gridFilterViewContainer = null;
//	private Button btnAddFolder = null;
//	private Button btnRemoveItem = null;
//	private Button btnRenameItem = null;
//	private Button btnUploadFile = null;
//	private Button btnUploadArchive = null;
//	private Button btnDownloadFile = null;
//	private GxtListView iconsViewContainer = null;
//	private ToggleButton toggleGroup = new ToggleButton();
//	private ToggleButton toggleList = new ToggleButton();
//	private ToggleButton toggleIcon = new ToggleButton();
//	private GxtGridFilterGroupPanel gridGroupViewContainer;
//	private GxtPathPanel toolBarPathContainer;
//	private GxtGridMessagesFilterPanel messagesPanelContainer;
//	private GxtGridFilterGroupPanel gridFilterViewContainer; 
//	private ToolBar toolBar = new ToolBar();  
//	private CardLayout cardLayout = new CardLayout();
//	private Button btnAccessFromDesktop = null;
//	
//	public GxtToolBarFunctionsPanel(GxtPathPanel toolBarPath,
//			GxtGridFilterGroupPanel gridFilterContainer,
//			GxtGridFilterGroupPanel gridFilterGroupContainer,
//			GxtListView listViewContainer,
//			GxtGridMessagesFilterPanel messagesPanelContainer) {
//		
//		  this.gridFilterViewContainer = gridFilterContainer;
//		  this.iconsViewContainer = listViewContainer;
//		  this.gridGroupViewContainer = gridFilterGroupContainer;
//		  this.toolBarPathContainer = toolBarPath;
//		  this.messagesPanelContainer = messagesPanelContainer;
//	}
//
//	@Override
//	protected void onRender(Element parent, int pos) {
//		super.onRender(parent, pos);
//		setLayout(new FitLayout());
//		
//		ContentPanel cp = createStandardToolbarPanel(cardLayout);
//		// ContentPanel cp = new ContentPanel();
//
//		addSelectionListenersOnToolBar();
//		cp.add(gridGroupViewContainer);
////		cp.add(gridFilterViewContainer);
////		cp.add(iconsViewContainer);
//		
//		cp.add(messagesPanelContainer);
//		
//		cardLayout.setActiveItem(gridGroupViewContainer);
//		
//		add(cp);
//
//	};
//	
//
//
//  public void setActivePanel(ViewSwitchTypeInResult type){
//	  
//	  
//	  if(type.equals(ViewSwitchTypeInResult.Group)){
//		  cardLayout.setActiveItem(gridGroupViewContainer);
//		  toolBar.setEnabled(true);
//	  }
//	  else if(type.equals(ViewSwitchTypeInResult.Icons)){
//		  cardLayout.setActiveItem(iconsViewContainer);
//		  toolBar.setEnabled(true);
//	  }
//	  else if(type.equals(ViewSwitchTypeInResult.Messages)){
//		  cardLayout.setActiveItem(messagesPanelContainer); 
//		  toolBar.setEnabled(false);
//	  }
////	  else if(type.equals(ViewSwitchTypeInResult.List))
////		  cardLayout.setActiveItem(gridFilterViewContainer);  
//  }
//  
//  private ContentPanel createStandardToolbarPanel(CardLayout cardLayout) {  
//    ContentPanel panel = new ContentPanel(); 
//	panel.setLayout(cardLayout);
////	panel.setLayout(new FitLayout());
//    panel.setBodyStyle("padding: 1px");  
//    panel.setHeaderVisible(false);
//  
//    btnAddFolder = new Button(ConstantsPortlet.ADDFOLDER, Resources.getIconAddFolder());  
//    
//    btnAddFolder.setScale(ButtonScale.SMALL);  
//    btnAddFolder.setIconAlign(IconAlign.TOP);  
//    btnAddFolder.setArrowAlign(ButtonArrowAlign.BOTTOM);  
//    
//    toolBar.add(btnAddFolder);  
//    toolBar.add(new SeparatorToolItem());  
//    toolBar.add(new SeparatorToolItem()); 
//    
//    btnRemoveItem = new Button(ConstantsPortlet.REMOVEITEM, Resources.getIconDeleteItem());  
//    btnRemoveItem.setScale(ButtonScale.SMALL);  
//    btnRemoveItem.setIconAlign(IconAlign.TOP);  
//    btnRemoveItem.setArrowAlign(ButtonArrowAlign.BOTTOM);  
//    
//    toolBar.add(btnRemoveItem);  
//    toolBar.add(new SeparatorToolItem()); 
//    toolBar.add(new SeparatorToolItem()); 
//  
//    btnRenameItem = new Button(ConstantsPortlet.RENAMEITEM, Resources.getIconRenameItem()); 
//    btnRenameItem.setScale(ButtonScale.SMALL);  
//    btnRenameItem.setIconAlign(IconAlign.TOP);  
//    btnRenameItem.setArrowAlign(ButtonArrowAlign.BOTTOM); 
//    toolBar.add(btnRenameItem);  
//    
//    toolBar.add(new SeparatorToolItem()); 
//    toolBar.add(new SeparatorToolItem()); 
//
//    btnUploadFile = new Button(ConstantsPortlet.UPLOADFILE, Resources.getIconFileUpload()); 
//    btnUploadFile.setScale(ButtonScale.SMALL);  
//    btnUploadFile.setIconAlign(IconAlign.TOP);  
//    btnUploadFile.setArrowAlign(ButtonArrowAlign.BOTTOM); 
//
//    toolBar.add(btnUploadFile);  
//    
//    toolBar.add(new SeparatorToolItem()); 
//    toolBar.add(new SeparatorToolItem()); 
//    
//    btnUploadArchive = new Button(ConstantsPortlet.UPLOADARCHIVE, Resources.getIconArchiveUpload()); 
//    btnUploadArchive.setScale(ButtonScale.SMALL);  
//    btnUploadArchive.setIconAlign(IconAlign.TOP);  
//    btnUploadArchive.setArrowAlign(ButtonArrowAlign.BOTTOM); 
//
//    toolBar.add(btnUploadArchive);  
//    toolBar.add(new SeparatorToolItem()); 
//    toolBar.add(new SeparatorToolItem()); 
//    
//    btnDownloadFile = new Button(ConstantsPortlet.DOWNLOADITEM, Resources.getIconDownload()); 
//    btnDownloadFile.setScale(ButtonScale.SMALL);  
//    btnDownloadFile.setIconAlign(IconAlign.TOP);  
//    btnDownloadFile.setArrowAlign(ButtonArrowAlign.BOTTOM); 
//
//    toolBar.add(btnDownloadFile);  
//    
//    toolBar.add(new FillToolItem());  
//    
//    btnAccessFromDesktop = new Button(ConstantsPortlet.TITLEACCESSWEBDAV, Resources.getIconWebDav());
//    btnAccessFromDesktop.setScale(ButtonScale.SMALL);  
//    btnAccessFromDesktop.setIconAlign(IconAlign.TOP);  
//    btnAccessFromDesktop.setArrowAlign(ButtonArrowAlign.BOTTOM); 
//    
//    toolBar.add(btnAccessFromDesktop);  
//    
//    toggleGroup = new ToggleButton();
//    toggleGroup.setIcon(Resources.getIconToggleGroup());
//    toggleGroup.setToggleGroup("viewgrid");
//    toggleGroup.toggle(true);
//  
//    toggleIcon = new ToggleButton();
//    toggleIcon.setIcon(Resources.getIconToggleIcon());
//    toggleIcon.setToggleGroup("viewgrid");
//
//    toggleList = new ToggleButton();
//    toggleList.setIcon(Resources.getIconToggleList());
//    toggleList.setToggleGroup("viewgrid");
//
//    switchView(ViewSwitchTypeInResult.Group);
//    
//    this.activeButtonsOnSelect(false);
//    
//    panel.setTopComponent(toolBar);  //Add toolBar
//  
//    return panel;  
//  }  
//  
//  private void addSelectionListenersOnToolBar(){
//	  
//	    btnAddFolder.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
//				
////				final FileGridModel fileGridModel = gridFilterContainer.getSelectedItem();
//				
//				AppController.getEventBus().fireEvent(new AddFolderEvent(gridGroupViewContainer.getCurrentFolderView(),null));
//			}
//	    });
//	    
//	    btnRemoveItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
//				
//				final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
//				
//				AppController.getEventBus().fireEvent(new DeleteItemEvent(fileGridModel));
//			}
//	    });
//	    
//	    btnRenameItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
//				
//				final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
//				
//				AppController.getEventBus().fireEvent(new RenameItemEvent(fileGridModel));
//				
//			}
//		});
//	    
//	    btnUploadFile.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
////				AppController.getEventBus().fireEvent(event)
////				new DialogUpload(ConstantsExplorer.FILEUPLOADHEADER, toolBarPathContainer.getLastParent().getName(), ConstantsExplorer.FILE);
//				AppController.getEventBus().fireEvent(new FileUploadEvent(null, UploadType.FILE));
//			}
//	    });
//	    
//	    btnUploadArchive.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
////				new DialogUpload(ConstantsExplorer.ARCHIVEUPLOADHEADER, , ConstantsExplorer.ARCHIVE);
//				AppController.getEventBus().fireEvent(new FileUploadEvent(null, UploadType.ARCHIVE));
//			}
//	    });
//	    
//	    btnDownloadFile.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
//				
//				final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
//				
//				AppController.getEventBus().fireEvent(new FileDownloadEvent(fileGridModel.getIdentifier(), fileGridModel.getName(), DownloadType.DOWNLOAD));
//				
////				com.google.gwt.user.client.Window.open(GWT.getModuleBaseURL()+"DownloadService?id="+contextItem.getId(), "", "");
////				break;
//			}
//	    });
//	    
//	    btnAccessFromDesktop.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
//			@Override
//			public void componentSelected(ButtonEvent ce) {
//				
//				AppController.getEventBus().fireEvent(new WebDavUrlEvent(null));
//			}
//		});
//	    
//	    toggleGroup.addSelectionListener(new SelectionListener<ButtonEvent>(){
//	        @Override
//	        public void componentSelected(ButtonEvent ce) {
//	            if(toggleGroup.isPressed()){
//	            	switchView(ViewSwitchTypeInResult.Group);
//	            	
//	            }
////	            Window.alert("ViewSwitchTypeInResult.Group");
//	        }
//	    });
//	    
//	    toggleList.addSelectionListener(new SelectionListener<ButtonEvent>(){
//	        @Override
//	        public void componentSelected(ButtonEvent ce) {
//	            if(toggleList.isPressed()){
//	            	switchView(ViewSwitchTypeInResult.List);
//	            }
////	            Window.alert("ViewSwitchTypeInResult.List");
//	        }
//	    });
//	    
//	    toggleIcon.addSelectionListener(new SelectionListener<ButtonEvent>(){
//	        @Override
//	        public void componentSelected(ButtonEvent ce) {
//	            if(toggleIcon.isPressed()){
//	            	switchView(ViewSwitchTypeInResult.Icons);
//	            }
//	        }
//	    });
//	    
//  }
//  
//	private void switchView(ViewSwitchTypeInResult type) {
//
//		if (type.compareTo(ViewSwitchTypeInResult.Icons) == 0) {
//			this.gridFilterViewContainer.setVisible(false);
//			this.gridGroupViewContainer.setVisible(false);
//			this.iconsViewContainer.setVisible(true);
////			toggleGroup.toggle(false);
////			toggleList.toggle(false);
////			toggleIcon.toggle(true);
//
//		} else{ 
//			if (type.compareTo(ViewSwitchTypeInResult.List) == 0) {
//		
//				this.iconsViewContainer.setVisible(false);
//				this.gridGroupViewContainer.setVisible(false);
//				this.gridFilterViewContainer.setVisible(true);
////				toggleGroup.toggle(false);
////				toggleList.toggle(true);
////				toggleIcon.toggle(false);
//			}
//			else{
//				this.iconsViewContainer.setVisible(false);
//				this.gridFilterViewContainer.setVisible(false);
//				this.gridGroupViewContainer.setVisible(true);
////				toggleGroup.toggle(true);
////				toggleList.toggle(false);
////				toggleIcon.toggle(false);
//			}
//		}
//				
//	}
//  
//  public void activeButtonsOnSelect(boolean active){
//	  
//	  if(!active){
////		  this.btnAddFolder.disable();
//		  this.btnRemoveItem.disable();
//		  this.btnRenameItem.disable();
//		  this.btnDownloadFile.disable();
//	  }
//	  else{
////		  this.btnAddFolder.enable();
//		  this.btnRemoveItem.enable();
//		  this.btnRenameItem.enable();
//		  this.btnDownloadFile.enable();
//		  
//	  }  
//  }
//  
//  public void activeAllButtons(boolean active){
//	  
//	  if(!active){
//		  this.btnAddFolder.disable();
//		  this.btnRemoveItem.disable();
//		  this.btnRenameItem.disable();
//		  this.btnDownloadFile.disable();
//		  this.btnUploadArchive.disable();
//	  }
//	  else{
//		  this.btnAddFolder.enable();
//		  this.btnRemoveItem.enable();
//		  this.btnRenameItem.enable();
//		  this.btnDownloadFile.enable();
//		  this.btnUploadArchive.enable();
//	  }
//  }
//
//public GxtGridMessagesFilterPanel getMessagesPanelContainer() {
//	return messagesPanelContainer;
//}
} 