Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Replaced 'cbx' and 'ct' with 'canvas'.

Class Description: This class is expected to render the application container and create the workspaces configured as per the meta data.

Called By: cbx canvas.core.WSManager

Meta data to be considered: ct canvas.metadata.getWorkspaces() → Returns an array of configured workspaces. The application container has to have that many child items as the length of this array

...

Code Block
languagejs
CLCR.registerCmp({'COMP_TYPE':'APPLICATION_CONTAINER'}, <<Application container class>>);

      

Scope: The core layer passes on view port container element to this class, so that it does not have to query the DOM to get the parent element on which it has to be appended.

Sample Code Snippet:

Code Block
languagejs
canvas.lib.ApplicationContainer = Class(canvas.core.Component, 
{
	layoutManager: '',
	constructor: function(config)
	{
		this.wsManagerConfig = config;
		canvas.lib.ApplicationContainer.$super.call(this);
		this.createItems();
	},
	createItems: function() 
	{
		var appContainerConfig = 
		{
			"eleType":"div",
			"id":"application-container"
		};
		var appContainerObj = new canvas.lib.layer(appContainerConfig).getLayer();
		this.addItem(appContainerObj);
		delete appContainerConfig;
		// Start process of creating the workspace and layout
		var wsContainerConfig;
		var wsArr = canvas.core.ws.metadata.getWorkspaces();
		canvas.lib.workspacehandler.createWorkspaces(wsArr,this);
		 
	},
	// Return the object of app container containing the workspaces
	getAppContainer: function() 
	{
		return this.getItem(0);
	}
});
CLCR.registerCmp({'COMP_TYPE':'APPLICATION_CONTAINER'},canvas.lib.ApplicationContainer);

It has to be noted in the above snippet that canvas.lib.workspacehandler.createWorkspaces() is a utility API which creates the workspace elements for the array of the workspaces passed, and finally appends to the parent element. Here is what this utility API is supposed to do.

Code Block
languagejs
var workspaceContainerConfig = 
{
	"eleType": "div",
	"id" : wsArray[index].WORKSPACE_ID,
	"class": "workspace "+wsArray[index].WORKSPACE_ID,
	"style": 
	{
		"display":"none"
	}
};
var wcContainerObject = new canvas.lib.layer(workspaceContainerConfig).getLayer();
$(this.appContainer.getItem(0)).append($(wcContainerObject));

The following code snippet shows the usage of workspace selection handler:

Code Block
languagejs
activateWorkspace: function(workspaceId,index,callBackFn,scope)
{
	callBackFn = canvas.isFunction(callBackFn)?callBackFn:canvas.emptyFn;
	scope = scope?scope: this;
	var config = 
	{
		WORKSPACE_ID:workspaceId,
		SYSTEM_WORKSPACE_IND:SYSTEM_WORKSPACE_IND
	};

	// Pre workspace activate operations here

	canvas.core.ws.metadata.getWorkspaceManager().wsSelectionHandler(config,null,function(wsContainer)
	{
		// Post workspace activate operations here
	},scope);
}