Class: WorkspaceClient

Workspace Client

The Workspace Client manages all calls to load, save, rename, and delete workspaces. For an overview, please read the Workspace tutorial.

Members

activeWorkspace

Reference to the activeWorkspace object

workspaces

List of all workspaces within the application.

Methods

addWorkspaceTemplateDefinition
(params, callback)
clients/workspaceClient.js, line 688

Adds a template definition. This adds to the template choices available when creating a new workspace. The definition will persistent until removed with removeWorkspaceTemplateDefinition().

Name Type Description
params object
Name Type Description
workspaceTemplateDefinition object

JSON template definition typically from getWorkspaceTemplateDefinition() or convertWorkspaceDefinitionToTemplate()

force boolean optional

if true an existing template with the same name will be overwritten

callback function optional

autoArrange
(params, cb)
clients/workspaceClient.js, line 64

AutoArranges windows.

Name Type Description
params object optional

Parameters

Name Type Description
monitor string optional

Same options as LauncherClient#showWindow. Default is monitor of calling window.

cb function optional

Callback

Example
FSBL.Clients.WorkspaceClient.autoArrange(function(err, response){
		//do something after the autoarrange, maybe make all of the windows flash or notify the user that their monitor is now tidy.
});

bringWindowsToFront
(params, cb)
clients/workspaceClient.js, line 103

Brings all windows to the front.

Name Type Description
params object
Name Type Description
monitor string optional

Same options as LauncherClient#showWindow except that "all" will work for all monitors. Defaults to the monitor for the current window.

cb function optional

Callback.

Example
FSBL.Clients.WorkspaceClient.bringWindowsToFront();

clone
(params, Callback)
clients/workspaceClient.js, line 301

Makes a clone (i.e. copy) of the workspace. The active workspace is not affected.

Name Type Description
params object
Name Type Description
name string

Name of workspace to clone.

Callback function

cb(err,response) with response set to the name of the cloned workspace if no error

Example

This method is used to clone workspaces.

FSBL.Clients.WorkspaceClient.clone({
		name: 'The best workspace'
	  }, function(err, response){
				//Do something.
	  });

convertWorkspaceDefinitionToTemplate
(params)
clients/workspaceClient.js, line 648

Convert a workspace JSON definition to a template JSON definition

Name Type Description
params object
Name Type Description
newTemplateName string

template name for the new converted definition

workspaceDefinition object

a workspace JSON definition return from getWorkspaceDefinition()

Returns:
the new template definition. If null then an error occurred because workspaceDefinition wasn't a legal JSON definition for a workspace

createNewWorkspace
(workspaceName, params, Callback)
clients/workspaceClient.js, line 491

Creates a new workspace. After creation the new workspace becomes the active workspace.

Name Type Description
workspaceName String

name for new workspace

params Object optional

optional params

Name Type Default Description
templateName string

name of template to use when creating workspace; if no template then empty workspace will be created

switchAfterCreation boolean true optional

Whether to switch to the new workspace after creating it.

Callback function optional

cb(err,response) with response set to new workspace object if no error

Example

This function creates the workspace 'My Workspace'.

FSBL.Clients.WorkspaceClient.createNewWorkspace(function(err, response){
		if (!err) {}
			//Do something like notify the user that the workspace has been created.
		}
});

getActiveWorkspace
(cb)
clients/workspaceClient.js, line 127

Gets the currently active workspace.

Name Type Description
cb function

Callback

Example

This function is useful for setting the initial state of a menu or dialog. It is used in the toolbar component to set the initial state.

FSBL.Clients.WorkspaceClient.getActiveWorkspace(function (err, response) {
		//setState is a React component method.
		self.setState({
			workspaces: response
		});
	});

getTemplates
(callback)
clients/workspaceClient.js, line 763

Gets all workspace template definitions from workspace service.

Name Type Description
callback function

callback(templateDefinitions) where templateDefinitions is an object containing all known template definitions; each property in templateDefinitions is a template

getWorkspaceDefinition
(params, callback)
clients/workspaceClient.js, line 539

Gets a workspace definition in JSON form.

Name Type Description
params object
Name Type Description
workspaceName string

the workspace name

callback function

callback(error,workspaceDefinition)

getWorkspaces
(cb)
clients/workspaceClient.js, line 147

Returns the list of saved workspaces.

Name Type Description
cb function

Callback

Example

This function is useful for setting the initial state of a menu or dialog.

FSBL.Clients.WorkspaceClient.getWorkspaces(function (err, response) {
		//setState is a React component method.
		self.setState({
			workspaces: response
		});
	});

getWorkspaceTemplateDefinition
(params, callback)
clients/workspaceClient.js, line 666

Get a template definition in JSON format.

Name Type Description
params object
Name Type Description
templateName string

name of template

callback function

isWorkspaceDirty
(Callback)
clients/workspaceClient.js, line 418

Checks to see if the workspace is dirty. If it's already dirty, the window doesn't need to compare its state to the saved state.

Name Type Description
Callback function

cb(err,response) with response set to true if dirty and false otherwise (when no error)

Example

This function will let you know if the activeWorkspace is dirty.

FSBL.Clients.WorkspaceClient.isWorkspaceDirty(function(err, response){
				//Do something like prompt the user if they'd like to save the currently loaded workspace before switching.
	  });

minimizeAll
(params, cb)
clients/workspaceClient.js, line 84

Minimizes all windows.

Name Type Description
params object
Name Type Default Description
monitor string all optional

Same options as LauncherClient#showWindow except that "all" will work for all monitors. Defaults to all.

cb function optional

Callback.

Example
FSBL.Clients.WorkspaceClient.bringWindowsToFront();

remove
(params, cb)
clients/workspaceClient.js, line 192

Removes a workspace. Either the workspace object or its name must be provided.

Name Type Description
params object
Name Type Default Description
persist Boolean false optional

Whether to persist the change.

workspace Object optional

Workspace

name string optional

Workspace Name

cb function optional

Callback to fire after 'Finsemble.WorkspaceService.update' is transmitted.

Example

This function removes 'My Workspace' from the main menu and the default storage tied to the applicaton.

FSBL.Clients.WorkspaceClient.remove({
		name: 'My Workspace',
		persist: true
	  }, function(err, response){
	 		//You typically won't do anything here. If you'd like to do something when a workspace change happens, we suggest listening on the `Finsemble.WorkspaceService.update` channel.
	  });

removeWindow
(params, cb)
clients/workspaceClient.js, line 234

Removes window from active workspace.

Name Type Description
params object
Name Type Description
name string

Window name

cb function optional

Callback

Example

This method removes a window from a workspace. It is rarely called by the developer. It is called when a window that is using the window manager is closed. That way, the next time the app is loaded, that window is not spawned.

FSBL.Clients.WorkspaceClient.removeWindow({name:windowName}, function(err, response){
		 //do something after removing the window.
	 });

removeWorkspaceTemplateDefinition
(params, callback)
clients/workspaceClient.js, line 726

Removes template definition (keep in mind if the template is defined in config then it will automatically be recreated on each startup)

Name Type Description
params object
Name Type Description
workspaceTemplateName string
callback function optional

callback(err) is invoked on completion. If !err then the operation was successful; otherwise, err carries diagnostics

rename
(params, cb)
clients/workspaceClient.js, line 268

Renames the workspace with the provided name. Also removes all references in storage to the old workspace's name.

Name Type Description
params object
Name Type Default Description
oldName string

Name of workspace to rename.

newName string

What to rename the workspace to.

removeOldWorkspace boolean true optional

Whether to remove references to old workspace after renaming.

overwriteExisting boolean false optional

Whether to overwrite an existing workspace.

cb function optional

Callback

Example

This method is used to rename workspaces. It is used in the main Menu component.

FSBL.Clients.WorkspaceClient.rename({
		oldName: 'My Workspace',
		newName: 'The best workspace',
		removeOldWorkspace: true,
	  }, function(err, response){
	 		//Do something.
	  });

save
(cb)
clients/workspaceClient.js, line 325

Saves the currently active workspace. It does not overwrite the saved instance of the workspace. It simply overwrites the activeWorkspace key in storage.

Name Type Description
cb function

Callback

Example

This function persists the currently active workspace.

FSBL.Clients.WorkspaceClient.save(function(err, response){
				//Do something.
	  });

saveAs
(params, cb)
clients/workspaceClient.js, line 357

Saves the currently active workspace with the provided name.

Name Type Description
params object
Name Type Default Description
name string

new name to save workspace under.

force string false optional

Whether to overwrite a workspace already saved with the provided name.

cb function

Callback

Example

This function persists the currently active workspace with the provided name.

FSBL.Clients.WorkspaceClient.saveAs({
		name: 'My Workspace',
	  }, function(err, response){
				//Do something.
	  });

saveWorkspaceTemplateToConfigFile
(params)
clients/workspaceClient.js, line 741

Saves one mor more template defintions in a selected file. Note the end user is prompted to identify file location during this save operation. The file can optionally be imported during config initialization (see importConfig) although this requires administration support on the configuration/server side. The file can also be read using readWorkspaceTemplateFromConfigFile();

Name Type Description
params object
Name Type Description
workspaceTemplateDefinition object

legal template definition returned by either getWorkspaceTemplateDefinition() or convertWorkspaceDefinitionToTemplate()

switchTo
(params, cb)
clients/workspaceClient.js, line 391

Switches to a workspace.

Name Type Description
params object
Name Type Description
name string

Workspace Name

cb function

Callback

Example

This function loads the workspace 'My Workspace' from the storage tied to the application.

FSBL.Clients.WorkspaceClient.switchTo({
		name: 'My Workspace',
	  }, function(err, response){
				//Do something.
	  });