Interface
caplin.layout

LayoutService

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

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

Constructor Summary

Attributes Name and Description
caplin.layout.LayoutService()

Field Summary

Attributes Name and Description
<static> caplin.layout.LayoutService.EVENT_NAMES

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

Method Summary

Attributes Name and Description
void close(caplin.layout.Layout layout)

Closes the given layout, removing it from the view and from the list of open layouts.

void dispose(caplin.layout.Layout layout)

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

Array getAvailable()

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

Array getOpen()

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

caplin.layout.Layout getSelected()

Returns the currently selected layout.

Array getTemplates()

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

void open(caplin.layout.Layout layout)

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

void openNew(caplin.layout.LayoutTemplate layoutTemplate)

Creates and opens a new layout, adding it to the application and the list of open layouts.

void save(caplin.layout.Layout layout)

Saves the given layout.

void saveAs(caplin.layout.Layout layout, String name)

Saves the given layout under a new name.

void select(caplin.layout.Layout layout)

Selects the given layout.

Constructor Detail

caplin.layout.LayoutService()

Field Detail

<static> caplin.layout.LayoutService.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
caplin.layout.LayoutlayoutThe selected layout.
CLOSED
Triggered when a layout is closed.
PARAMETERS
caplin.layout.LayoutlayoutThe closed layout.
OPENED
Triggered when a layout is opened.
PARAMETERS
caplin.layout.LayoutlayoutThe opened layout.
NumberindexThe index of the opened layout.
DISPOSED
Triggered when a layout is disposed.
PARAMETERS
caplin.layout.LayoutlayoutThe disposed layout.
CREATED
Triggered when a new layout is created.
PARAMETERS
caplin.layout.LayoutlayoutThe created layout.
SAVED
Triggered when a layout is saved.
PARAMETERS
caplin.layout.LayoutlayoutThe saved layout.

Method Detail

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

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

Parameters
caplin.layout.Layout layout The layout to close.

void dispose(caplin.layout.Layout layout)

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

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

Parameters
caplin.layout.Layout layout The layout to disposed.

Array getAvailable()

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

Returns
{Array} The user's available layouts.

Array getOpen()

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

Returns
{Array} The user's currently open layouts.

caplin.layout.Layout getSelected()

Returns the currently selected layout.

Returns
{caplin.layout.Layout} The currently selected layout.

Array getTemplates()

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

Returns
{Array} The user's currently open layouts.

void open(caplin.layout.Layout layout)

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

Method will raise a caplin.layout.LayoutService.EVENT_NAMES.OPENED event with the opened layout as the only argument.

Parameters
caplin.layout.Layout layout The layout to open.

void openNew(caplin.layout.LayoutTemplate layoutTemplate)

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 caplin.layout.LayoutTemplate which the new layout will be a copy of.

Parameters
caplin.layout.LayoutTemplate layoutTemplate (optional) The template that will be copied to create a new layout

void save(caplin.layout.Layout layout)

Saves the given layout. Raises an error if called with a layout that isn't writable (see caplin.layout.Layout#isWritable).

Parameters
caplin.layout.Layout layout The layout to be saved.

void saveAs(caplin.layout.Layout layout, String 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
caplin.layout.Layout layout The layout to be saved.
String name The desired name for the newly created layout.

void select(caplin.layout.Layout 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 caplin.layout.LayoutService.EVENT_NAMES.SELECTED event with the selected layout as the only argument.

Parameters
caplin.layout.Layout layout The layout to select.