Caplin Trader 4.8.0

Interface: module:caplin/layout/LayoutService

module:caplin/layout/LayoutService

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

This service can be accessed from the module:caplin/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.

Implementations:

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:caplin/layout/Layout layout The selected layout.
CLOSED
Triggered when a layout is closed.
PARAMETERS
module:caplin/layout/Layout layout The closed layout.
OPENED
Triggered when a layout is opened.
PARAMETERS
module:caplin/layout/Layout layout The opened layout.
Number index The index of the opened layout.
DISPOSED
Triggered when a layout is disposed.
PARAMETERS
module:caplin/layout/Layout layout The disposed layout.
CREATED
Triggered when a new layout is created.
PARAMETERS
module:caplin/layout/Layout layout The created layout.
Implementations:

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:caplin/layout/Layout The layout to be cloned.
name String The desired name for the newly created layout.
Implementations:

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:caplin/layout/LayoutService.EVENT_NAMES.SELECTED on a different layout, if the current selected layout is being closed.

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

Parameters:
Name Type Description
layout module:caplin/layout/Layout The layout to close.
Implementations:

dispose(layout)

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

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

Parameters:
Name Type Description
layout module:caplin/layout/Layout The layout to disposed.
Implementations:

getAvailable() → {Array}

Returns an array of all layouts that the user has available to them.
Implementations:
Returns:
The user's available layouts.
Type
Array

getOpen() → {Array}

Returns an array of all layouts that the user currently has open.
Implementations:
Returns:
The user's currently open layouts.
Type
Array

getSelected() → {module:caplin/layout/Layout}

Returns the currently selected layout.
Implementations:
Returns:
The currently selected layout.
Type
module:caplin/layout/Layout

getTemplates() → {Array}

Returns an array of all templates that are available to the user.
Implementations:
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:caplin/layout/LayoutService.EVENT_NAMES.OPENED event with the opened layout as the only argument.

Parameters:
Name Type Description
layout module:caplin/layout/Layout The layout to open.
Implementations:

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:caplin/layout/LayoutTemplate which the new layout will be a copy of.
Parameters:
Name Type Attributes Description
layoutTemplate module:caplin/layout/LayoutTemplate <optional>
The template that will be copied to create a new layout
Implementations:

save(layout)

Saves the given layout. Raises an error if called with a layout that isn't writable (see module:caplin/layout/Layout#isWritable).
Parameters:
Name Type Description
layout module:caplin/layout/Layout The layout to be saved.
Implementations:

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:caplin/layout/Layout The layout to be saved.
name String The desired name for the newly created layout.
Implementations:

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:caplin/layout/LayoutService.EVENT_NAMES.SELECTED event with the selected layout as the only argument.

Parameters:
Name Type Description
layout module:caplin/layout/Layout The layout to select.
Implementations: