Class: WorkspaceClient

Workspace Client

The workspace client manages all calls to load, save, rename, and delete workspaces. Before reading this, please check out workspaces.

Members

activeWorkspaceWorkspaceClient

Reference to the activeWorkspace object

workspacesWorkspaceClient

List of all workspaces within the application.

Methods

autoArrange
(params, cb)

clients/workspaceClient.js, line 63

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 83

Brings all windows to the front.

TODO
  • rename to something like bringToFront and put the 'Only affects visible windows' bit in the documentation.
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 265

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

createNewWorkspace
(Callback)

clients/workspaceClient.js, line 397

Creates a new workspace. If the name is already saved, we increment the name. After creation the new workspace becomes the active workspace.

Name Type Description
Callback function

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 107

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

getWorkspaces
(cb)

clients/workspaceClient.js, line 126

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 383

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

remove
(params, cb)

clients/workspaceClient.js, line 157

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 199

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 232

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 290

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 323

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

switchTo
(params, cb)

clients/workspaceClient.js, line 356

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