The Workspace Container

Class Description: This class instantiates the Layout container and the workspace menus. It has to be noted that this class gets instantiated by the workspace manager, when a workspace gets activated, and hence it is internally dependent on the library to get instantiated.

Called By: canvas.core.WSManager

Meta data to be considered: canvas.menuitems.metadata.getMenuTools(workspaceId) → This API returns a list of all the Workspace menus that are applicable for the workspace. The component developers may utilize this meta data to construct the workspace menus according to their UI.



What developers are expected to do: The developers are expected to create separate containers for Workspace Menus and Layout Containers respectively. The rendition of workspace menus is left to the component developers. However, the layout containers require the involvement of the core layer and the developers are expected to call the Layout Manager on the container where the sub workspaces are to be rendered.

APIs to be supported: NA

Registry Signature:

CLCR.registerCmp({'COMP_TYPE':'WORKSPACE_CONTAINER'}, <<Your workspace container class here>>); 

Scope: The workspace manager passes the workspace ID and other workspace related info about the workspace that has been activated.

Sample Code Snippet:

canvas.lib.workspaceContainer = Class(canvas.core.Component, 
{
	workspaceID: '',
	proportion: '',
	containerObj : null,
	constructor: function(config) 
	{
		canvas.lib.workspaceContainer.$super.call(this);
		this.workspaceID = config.WORKSPACE_ID;
		this.createContainer();
		if($("#"+this.workspaceID)[0])
		{
			$("#"+this.workspaceID)[0].style.display="block";
			this.createItems();
			$("#"+this.workspaceID).children().remove();
			$("#"+this.workspaceID).append(this.containerObj);
		}
		else
		{
			LOGGER.error("The workspace trying to be enabled is not a valid "
			+ "workspace for this channel.."
			+ " WORKSPACE ID: "+this.workspaceID);
		}
	},
	//Returns Workspace container object
	getWSContainer: function() 
	{
		return this.getItem(0);
	},

	createContainer : function()
	{
		var wsContainerConfig =
		{
			"eleType":"div",
			"id":this.workspaceID+"_WORKSPACE_CONTAINER"
		};
		var container = new canvas.lib.layer(wsContainerConfig).getLayer();
		$(this.workspaceID).append(container);
		this.containerObj = container;
		this.addItem(this.containerObj)
	},
	createItems: function() 
	{
		var menuContainerConfig = 
		{
			"eleType":"div",
			"class":this.workspaceID+"_MENU_CONTAINER",
			"id":this.workspaceID+"_MENU_CONTAINER"
		}
		var menuContainer = new canvas.lib.layer(menuContainerConfig).getLayer();
		var menuItems = canvas.menuitems.metadata.getMenuTools(this.workspaceID);
		var layoutContainerConfig = 
		{
			"eleType":"div",
			"class":this.workspaceID+"_LAYOUT_CONTAINER",
			"id":this.workspaceID+"_LAYOUT_CONTAINER"
		}
		var subWorkspaceConf = 
		{
			"elem":layoutContainerParent,
			"workspaceId":this.workspaceID
		}

		// Instantiate layout manager on this Container 
		this.layoutManager = new canvas.core.LayoutManager(subWorkspaceConf); 
	},

	getLayoutManagerObject: function() 
	{
		return this.layoutManager; 
	},
	
	getLayoutManagerDOM: function() 
	{
		return this.layoutManager.getContainer();
	},

	getWorkspaceWidgets: function() 
	{
		return this.layoutManager.getWidgetContainerComponent();
	},

	getWidgetContainer : function()
	{
		return this.layoutManager.widgetContainer;
	},

	getLayoutContainer : function()
	{
		return this.layoutManager.widgetContainer;
	}
});
CLCR.registerCmp({'COMP_TYPE':'WORKSPACE_CONTAINER'}, canvas.lib.workspaceContainer);