Caplin Trader 5.1.0

Interface: module:ct-layout/LayoutService

module:ct-layout/LayoutService

The LayoutService provides access to the user's module:ct-layout/Layouts and module:ct-layout/LayoutTemplates.

This service can be accessed from the module:ct-core/ServiceRegistry, using the alias caplin.layout-service. There is no default implementation for this service.

This interface uses emitr allowing services implementing this interface to trigger events.

Members

(static) EVENT_NAMES

A map of events that services implementing this interface will trigger.

Contains the following events:

SELECTED

Triggered when a layout is selected.

PARAMETERS
module:ct-layout/Layout layout The selected layout.
CLOSED
Triggered when a layout is closed.
PARAMETERS
module:ct-layout/Layout layout The closed layout.
OPENED
Triggered when a layout is opened.
PARAMETERS
module:ct-layout/Layout layout The opened layout.
Number index The index of the opened layout.
DISPOSED
Triggered when a layout is disposed.
PARAMETERS
module:ct-layout/Layout layout The disposed layout.
CREATED
Triggered when a new layout is created.
PARAMETERS
module:ct-layout/Layout layout The created layout.

Methods

clone(layout, name)

Clones the given layout. This creates a copy of the layout in its current state and then adds the copy to the list of open layouts. The copied layout is neither saved nor closed by this action.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to be cloned.

name String

The desired name for the newly created layout.

close(layout)

Closes the given layout, removing it from the view and from the list of open layouts. This is where the implementation would typically trigger module:ct-layout/LayoutService.EVENT_NAMES.SELECTED on a different layout, if the current selected layout is being closed.

Method will raise a module:ct-layout/LayoutService.EVENT_NAMES.CLOSED event with the closed layout as the only argument.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to close.

dispose(layout)

Disposes the given layout, removing it from the list of available layouts.

Will raise a module:ct-layout/LayoutService.EVENT_NAMES.DISPOSED event with the disposed layout as the only argument.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to disposed.

getAvailable() → {Array}

Returns an array of all layouts that the user has available to them.

Returns:

The user's available layouts.

Type
Array

getOpen() → {Array}

Returns an array of all layouts that the user currently has open.

Returns:

The user's currently open layouts.

Type
Array

getSelected() → {module:ct-layout/Layout}

Returns the currently selected layout.

Returns:

The currently selected layout.

Type
module:ct-layout/Layout

getTemplates() → {Array}

Returns an array of all templates that are available to the user.

Returns:

The user's currently open layouts.

Type
Array

open(layout)

Opens the given layout, adding it to the application and the list of open layouts.

Method will raise a module:ct-layout/LayoutService.EVENT_NAMES.OPENED event with the opened layout as the only argument.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to open.

openNew(layoutTemplateopt)

Creates and opens a new layout, adding it to the application and the list of open layouts. This new layout will not be in the list of available layouts until it has been saved. This method will create a blank layout by default, but may optionally be passed a module:ct-layout/LayoutTemplate which the new layout will be a copy of.

Parameters:
Name Type Attributes Description
layoutTemplate module:ct-layout/LayoutTemplate <optional>

The template that will be copied to create a new layout

save(layout)

Saves the given layout. Raises an error if called with a layout that isn't writable (see module:ct-layout/Layout#isWritable).

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to be saved.

saveAs(layout, name)

Saves the given layout under a new name. This creates a copy of the given layout in its current state, reverts the original back to its last saved state, and then swaps the new layout for the old layout in the list of open layouts.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to be saved.

name String

The desired name for the newly created layout.

select(layout)

Selects the given layout. This will typically bring it to the front, and allow context sensitive actions to be performed on it.

Method will raise a module:ct-layout/LayoutService.EVENT_NAMES.SELECTED event with the selected layout as the only argument.

Parameters:
Name Type Description
layout module:ct-layout/Layout

The layout to select.