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.

new WorkspaceClient
()
clients/workspaceClient.js, line 22

You don't need to ever invoke the constructor. This is done for you when WindowClient is added to the FSBL object.

Members

activeWorkspaceobject

Reference to the activeWorkspace object

workspacesArray.<Object>

List of all workspaces within the application.

Methods

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

AutoArranges windows.

Name Type Description
params object optional

Parameters

Name Type Default Description
monitor string "mine" 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 102

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, cb)
clients/workspaceClient.js, line 297

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.

cb function optional

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 636

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, cb)
clients/workspaceClient.js, line 482

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 optional

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.

cb 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 125

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
		});
	});

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

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 145

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
		});
	});

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

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 190

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 232

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.
	 });

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

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 320

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 optional

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 351

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 optional

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.
	  });

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

Switches to a workspace.

Name Type Description
params object
Name Type Description
name string

Workspace Name

cb function optional

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.
	  });