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 1032

Ejects the window from the docking group

fitToDOM
(params, cb)
clients/windowClient.js, line 1105

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 543

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 1075

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 1062

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 222

Retrieves the window's title.

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

headerCommandChannel
(commandChannel)
clients/windowClient.js, line 1025

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
(params)
clients/windowClient.js, line 825

The Finsemble Window Title Bar is injected if FSBLHeader: true or FSBLHeader is an object with the same items as the properties of params below as this function is in the component's config. If you want to inject the Finsemble header later, you can do so by calling this function

Name Type Description
params object
Name Type Description
component string

Component to inject. Default is "windowTitleBar"

bumpElements object
Name Type Description
fixed string

Either false, "all" or "0Positioned". If all, all fixed elements are moved. 0Positioned only moves elements that have top 0. Default is all.

absolute string

Either false, "all" or "0Positioned". If all, all fixed elements are moved. 0Positioned only moves elements that have top 0. Only applies to children of the body. Default is all.

bumpBy string

default is "32px".

bodyMarginTop string

Sets the body margin. Default is "30px".

forceHeaderHeight string

Sets a height to the main FSBLHeader div.

maximize
(cb)
clients/windowClient.js, line 452

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 380

Minmizes window.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.minimize();

removeFinWindowEventListeners
()
clients/windowClient.js, line 478

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

restore
(cb)
clients/windowClient.js, line 402

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 321

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 1084

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 619

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 1052

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 1013

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