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 windowTitleBar 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 windowTitleBarComponent 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

ejectFromGroup
()

clients/windowClient.js, line 948

Ejects the window from the docking group

fitToDOM
(params, cb)

clients/windowClient.js, line 1021

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 514

Given a field, this function retrieves app state. If no params are given you get the full state

Name Type Description
params object
Name Type Description
field string

field

fields array

fields

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);
});
FSBL.Clients.WindowClient.getComponentState({
	 fields: ['myChartLayout', 'chartType'],
}, function (err, state) {
	if (state === null) {
		return;
	}
	var chartType = state['chartType'];
 var myChartLayout = state['myChartLayout'];
});

getCurrentWindow
(){finWindow}

clients/windowClient.js, line 991

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 978

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 188

Retrieves the window's title.

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

headerCommandChannel
(commandChannel)

clients/windowClient.js, line 941

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

injectHeader
()

clients/windowClient.js, line 778

The Finsemble Window Title Bar is injected if FSBLHeader: true is in the component's config. If you want to inject the Finsemble header later, you can do so by calling this function

maximize
(cb)

clients/windowClient.js, line 421

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 349

Minmizes window.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.minimize();

removeFinWindowEventListeners
()

clients/windowClient.js, line 447

FinWindow destructor (more or less). Removes all of the listeners that we added when the window was created.

restore
(cb)

clients/windowClient.js, line 371

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 290

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 1000

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 590

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

Name Type Description
params object
Name Type Description
field string optional

field

fields array optional

fields

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 });
FSBL.Clients.WindowClient.setComponentState({ fields: [{field:'myChartLayout', value: s }, {field:'chartType', value: 'mountain'}]);

setWindowTitle
(title)

clients/windowClient.js, line 968

This function does two things:

  1. It sets the window's title in the windowTitleBar 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 929

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)

inneronClose
(removeFromWorkspace)

clients/windowClient.js, line 144

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