Class: WindowClient

Window Client

The WindowClient is primarily responsible for managing the windowState (the window's bounds) and componentState (data inside of your component). It also injects the windowManager component, which contains controls for minimizing, maximizing, closing, and restoring your window. The reference below is provided in case you'd like to manually trigger events.

This is the WindowClient API reference. If you're looking for information about the window header, please see the windowManagerComponent for more information.

Members

optionsWindowClient

A copy of the finWindow's options value. This is where we store information like monitorDimensions, initialization information, and any other data that needs to be passed from the parent application into the created window.

Methods

close
(removeFromWorkspace)

clients/windowClient.js, line 374

Closes Window.

Name Type Description
removeFromWorkspace boolean

whether to remove the window from the workspace. Defaults are to remove the window from the workspace if the user presses the X button, but not if the window is closed via an app-level request (e.g., we need to switch workspaces, so all windows need to close).

Example
//Close window and remove from workspace (e.g., user closes the window).
	FSBL.Clients.WindowClient.close(true);
	//Close window and keep in workspace (e.g., application requests that all windows close themselves).
	FSBL.Clients.WindowClient.close(false);

ejectFromGroup
()

clients/windowClient.js, line 834

Ejects the window from the docking group

fitToDOM
(params, cb)

clients/windowClient.js, line 902

Automatically resizes the height of the window to fit the full DOM.

Name Type Description
params object
Name Type Description
padding object
Name Type Description
height number
width number
cb function optional

Optional callback when complete

getComponentState
(params, cb)

clients/windowClient.js, line 440

Given a field, this function retrieves app state.

Name Type Description
params object
Name Type Description
field string

field

cb function

Callback

Example

The example below shows how we retrieve data to restore the layout in our charts.

FSBL.Clients.WindowClient.getComponentState({
	 field: 'myChartLayout',
}, function (err, state) {
	if (state === null) {
		return;
	}
	importLayout(state);
});

getCurrentWindow
(){finWindow}

clients/windowClient.js, line 877

Returns a reference to the current window for the component. For most components this will just return the finWindow, but for a compound component it will return a CompoundWindow.

Returns:
Type Description
finWindow

getSpawnData
(){object}

clients/windowClient.js, line 864

Retrieves data that was set with LauncherClient#spawn.

Returns:
Type Description
object The data or empty object if no data was set. Note, this will never return null or undefined.

getWindowTitle
(){String}

clients/windowClient.js, line 116

Retrieves the window's title.

Returns:
Type Description
String title
Example
var windowTitle = FSBL.Clients.WindowClient.getWindowTitle();

headerCommandChannel
(commandChannel)

clients/windowClient.js, line 827

Establishes a command channel with a header. The WindowClient can update header state via this channel.

Name Type Description
commandChannel function

A function callback that receives commands

maximize
(cb)

clients/windowClient.js, line 346

Maximizes the window. Also takes into account the application toolbar.

Name Type Description
cb function

Optional callback

Example
FSBL.Clients.WindowClient.maximize();

minimize
(cb)

clients/windowClient.js, line 279

Minmizes window.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.minimize();

restore
(cb)

clients/windowClient.js, line 301

Restores window from a maximized state.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.restore();

saveWindowBounds
(bounds)

clients/windowClient.js, line 216

Saves the window's state. Rarely called manually, as it's called every time your window moves.

Name Type Description
bounds Object

optional param.

Example

The code below is the bulk of our listener for the bounds-changed event from the openFin window. Every time the bounds-changed event is fired (when the window is resized or moved), we save the window's state. The first few lines just prevent the window from being dropped behind the toolbar.

finWindow.addEventListener('disabled-frame-bounds-changed', function (bounds) {
	if (bounds.top < 45) {
		finWindow.moveTo(bounds.left, 45);
		return;
	}
	self.saveWindowBounds(bounds);
});

setActive
(active)

clients/windowClient.js, line 886

Highlights the window as active by creating a border around the window.

Name Type Description
active boolean

Set to false to turn off activity

setComponentState
(params, cb)

clients/windowClient.js, line 489

Given a field, this function sets and persists app state.

Name Type Description
params object
Name Type Description
field string

field

cb function optional

Callback

Example

The example below shows how we save our chart layout when it changes.

var s = stx.exportLayout(true);
//saving layout'
FSBL.Clients.WindowClient.setComponentState({ field: 'myChartLayout', value: s });

setWindowTitle
(title)

clients/windowClient.js, line 853

This function does two things:

  1. It sets the window's title in the windowManager component, and
  2. It sets the title in the DOM.

This is useful if you like to keep the window's title in sync with a piece of data (e.g., a Symbol);

TODO
  • Allow HTML or classes to be injected into the title.
Name Type Description
title String

Window title.

Example

The code shows how you would change your window title.

FSBL.Clients.WindowClient.setWindowTitle("My Component's New Title");

updateHeaderState
(command, state)

clients/windowClient.js, line 815

Sends a command to the header. Commands affect the header state, so that the UI reflects what is going on in the component window.

Name Type Description
command string

The state object to set

state object

The new state (merged with existing)