Class: Window

Window()

This abstract class represents an internal window.

If you want to display a window in Adaptyst Analyser, you must implement a new class inheriting from this class and implementing its abstract methods.

Constructor

new Window()

Constructs a Window object. This doesn't do anything else, including displaying a window: you need to call init() for this unless the window is deserialized (i.e. created by Window.deserialize(), this will be indicated by the first argument to the subclass constructor set to true).

Source:

Members

instances

Static dictionary storing all instances of a Window class (or one of its subclasses) under their IDs as returned by getId().

Source:

modules_loaded

Static dictionary storing all modules loaded in the client side of Adaptyst Analyser.

Source:

system_graph_view

Static variable storing an instance of Sigma for displaying a system graph of the current session.

Source:

Methods

_exportData()

Returns window content data to be used by serialize(). The extent to which the contents are saved in _exportData() is decided by your implementation.

When Window.deserialize() is called with a dictionary produced by serialize(), the part there generated by _exportData() is passed to _importData() to restore the window.

There are no specific guidelines on the format of the return data as long as it is JSON-compatible and accepted by the implementation of _importData().

The default implementation returns undefined. You should override this method if you want a different behaviour.

Source:
Returns:

Serialised content data of the window.

_importData(dataopt)

Restores the window content using data produced by _exportData(). This is used by Window.deserialize(), called e.g. when a user opens a window arrangement saved by another user of the same Adaptyst Analyser instance.

If used, this is guaranteed to be called after the window is constructed and _setup() is executed.

The default implementation does nothing. You should override this method if you want a different behaviour.

Parameters:
Name Type Attributes Description
data <optional>

Serialised content data of the window to be restored.

Source:

(abstract) _setup(data, existing_window)

Sets up a window. This is always called when the window is opened or refreshed. Use getContent() to get a jQuery object for manipulating the window content.

Important: This function must call hideLoading() at some point. Otherwise, there will be a loading indicator in the window instead of a desired content.

Parameters:
Name Type Description
data

Arbitrary data passed to the constructor, e.g. a dictionary.

existing_window bool

Whether a window is already displayed.

Source:

downloadSvg(class_nameopt, cssopt)

Downloads a given SVG object in a window as an SVG file.

Parameters:
Name Type Attributes Description
class_name String <optional>

The class name of an SVG object. It is expected that the object has a unique class name within the window. Otherwise, the behaviour is undefined.

css String <optional>

The path to a CSS stylesheet to be applied to the SVG before downloading.

Source:

(abstract) finishResize()

Called when a user finishes resizing a window.

Source:

focus()

Focuses a window.

Source:

getAnalysableId() → {String}

Gets the ID of the analysable of a window. It can be undefined.

Source:
Returns:

ID of the analysable of a window.

Type
String

getConstructorArgs()

Gets the array of arguments passed to the constructor (not init()) except for the first argument indicating whether the window is being deserialised. This is useful for serialising/deserialising a window.

The default implementation returns an empty array. undefined should never be returned.

Source:
Returns:

Array of constructor arguments, starting from the second one.

getContent() → {Object}

Gets the content of a window in form of a jQuery object. The return value of this function is based on your implementation of getContentCode().

Source:
Returns:

jQuery object representing the content of a window.

Type
Object

(abstract) getContentCode() → {String}

Gets the content of a window in form of an HTML code.

Window header and border rendering along with basic window operations except resizing is fully handled by Adaptyst Analyser and you shouldn't implement it yourself. Resizing is partially handled by Adaptyst Analyser and should also not be implemented here, see startResize() and finishResize() instead.

A padding of 5 pixels is applied to the content of all windows in Adaptyst Analyser.

Source:
Returns:

HTML code of the content of a window.

Type
String

getCurrentTitle() → {String}

Gets the title of a window.

Source:
Returns:

Title of a window.

Type
String

getData() → {Object}

Gets the dictionary of a window. It can be filled with arbitrary data.

Source:
Returns:

Dictionary of a window.

Type
Object

getDependencies() → {Array}

Gets an array containing the ID strings of all windows this window depends on, e.g. for obtaining data.

This method returns an empty array if no window dependencies have been provided in the constructor.

undefined should never be returned.

Source:
Returns:

Array of window dependencies in form of ID strings.

Type
Array

getDependencyObjects() → {Array}

Same as getDependencies(), but an array of Window objects is returned instead of an array of window ID strings.

Source:
Returns:

Array of window dependencies in form of Window objects.

Type
Array

getEntityId() → {String}

Gets the entity ID of a window. It can be undefined.

Source:
Returns:

Entity ID of a window.

Type
String

getId() → {String}

Gets the ID of a window.

Source:
Returns:

ID of a window.

Type
String

getLastFocusTime()

Gets the last time a window was focused.

Source:
Returns:

Last time a window was focused, as a number representing a Unix timestamp in milliseconds.

getModuleName() → {String}

Gets the module name of a window. It can be undefined.

Source:
Returns:

Module name of a window.

Type
String

getSession() → {Object}

Gets the performance session a window is part of.

Source:
Returns:

Session of a window.

Type
Object

(abstract) getTitle(dataopt) → {String}

Gets the expected title of a window. A user is free to change it by using the "edit title" feature.

Parameters:
Name Type Attributes Description
data <optional>

Arbitrary data passed to the constructor, e.g. a dictionary.

Source:
Returns:

Expected title of a window.

Type
String

(abstract) getType() → {String}

Gets the type of a window. This is used in the ID of a window, an HTML class of the window (i.e. <type>_window), and an HTML class of the window content (i.e. <type>_content).

Source:
Returns:

Type of a window.

Type
String

getZIndex()

Gets the value of the z-index CSS property of a window.

Source:
Returns:

Value of z-index of a window.

hideLoading()

Hides the loading indicator in a window.

Source:

init(instanceopt, sessionopt, entity_idopt, analysable_idopt, module_nameopt, dataopt, xopt, yopt, window_dependenciesopt, custom_idopt, widthopt, heightopt, ready_handleropt)

Initialises a Window object and displays a window corresponding to the object. This function must be called by all subclasses from their constructor, with the first argument being JavaScript "this".

The method should not be overridden: otherwise, the serialising/deserialising feature won't work properly if at all.

Parameters:
Name Type Attributes Description
instance Object <optional>

A Window subclass object referred to by JavaScript "this" inside the subclass constructor.

session Object <optional>

Session object corresponding to a window. This is provided by a parameter of createRootWindow(). It can be undefined.

entity_id String <optional>

The ID of an entity corresponding to a window. This is provided by a parameter of createRootWindow(). It can be undefined.

analysable_id String <optional>

The ID of an analysable corresponding to a window. This is provided by a parameter of createRootWindow(). It can be undefined.

module_name String <optional>

The name of a module within a node corresponding to a window. It can be undefined.

data <optional>

Arbitrary data to be passed to _setup() and getTitle(). It can be undefined. If window serialisation should be supported, the provided value must be either undefined or serialisable to JSON.

x float <optional>

x-part of the initial upper-left corner position of a window. If undefined, the value of y will be ignored and the window will be centered. This is always ignored in the compact mode.

y float <optional>

y-part of the initial upper-left corner position of a window. If undefined, the value of x will be ignored and the window will be centered. This is always ignored in the compact mode.

window_dependencies Array <optional>

Array of all Window objects or string IDs this window depends on, e.g. for obtaining data. It can be undefined.

custom_id String <optional>

The ID to be assigned to a window. All whitespaces are automatically replaced with an underscore. Leave this undefined unless you know what you're doing.

width float <optional>

Width of a window. It cannot be smaller than the minimum width specified in the CSS stylesheet of the module. If undefined, the default value will be used. This is always ignored in the compact mode.

height float <optional>

Height of a window. It cannot be smaller than the minimum height specified in the CSS stylesheet of the module. If undefined, the default value will be used. This is always ignored in the compact mode.

ready_handler function <optional>

Function to be called when a window finishes loading. It should have one parameter corresponding to the loaded Window subclass object and no return value. This is not run if an error occurs. It can be undefined.

Source:

inst()

Gets a Window subclass object. This is equivalent to the "this"/"self" keyword in an object-oriented programming (OOP) language.

Please note that JavaScript's "this" is NOT equivalent and you should not rely on it unless you know the difference between JavaScript and an OOP language in handling the "this" keyword.

Source:

(abstract) prepareClose()

Called when a user closes a window, before it is actually closed.

Source:

(abstract) prepareRefresh(data)

Called when a user refreshes a window, before the proper refresh process with the content resetup takes place.

The old window content is still available when this method is called.

Parameters:
Name Type Description
data

Arbitrary data that have been passed to the constructor and will be available in _setup(), e.g. a dictionary.

Source:

sendRequest(data, done_func, fail_func, content_type)

Sends a request to the server side of Adaptyst Analyser. The request will be handled by the Python code of a corresponding Adaptyst Analyser module.

Use this function only if you have constructed your object with all of an entity ID, a node ID, and a module name.

Parameters:
Name Type Description
data Object

Data to be sent in form of JSON.

done_func

Function to be called when the request succeeds. The function must take exactly one argument which is a JSON object returned by the server side.

fail_func

Function to be called when the request fails for any reason. The function must take exactly the arguments described in the "error" entry of "settings" in the jQuery.ajax() documentation here.

content_type String

Content type expected from the server side. Use one of the values explained in the "dataType" entry in "settings" in the jQuery.ajax documentation here. It can be undefined, this is then interpreted as 'json'.

Source:

serialize(xopt, yopt, collapsedopt)

Serialises the window so that it can be reconstructed later using Window.deserialize(). This is useful e.g. for saving the window for opening later or sharing with other users of the same Adaptyst Analyser instance.

The return format is a JSON-able dictionary in the following form:

{
  "id": <window ID: always present>,
  "module": <module name: not always present>,
  "type": <window type: always present>,
  "constr": <array of arguments to be passed to the window constructor: always present>,
  "session": <session ID: not always present>,
  "entity": <entity ID: not always present>,
  "analysable": <ID of analysable: not always present>,
  "init_data": <arbitrary data passed to _setup() and getTitle(): not always present>,
  "x": <x-part of the initial upper-left corner position of the window: not always present>,
  "y": <y-part of the initial upper-left corner position of the window: not always present>,
  "dependencies": <window dependencies as returned by getDependencies(): always present>,
  "collapsed": <whether the window is collapsed: always present>,
  "custom_title": <custom title if any: not always present>,
  "data": <window data returned by _exportData(): not always present>
}

You should not assume that Window.deserialize() will be always called in the standard mode only or in the compact mode only.

Parameters:
Name Type Attributes Description
x int <optional>

x-part of the initial upper-left corner position of the window in case it cannot be extracted automatically (e.g. due to being in the compact mode). If undefined, the window will be centered in a screen when deserialised unless the coordinate can be obtained automatically.

y int <optional>

y-part of the initial upper-left corner position of the window in case it cannot be extracted automatically (e.g. due to being in the compact mode). If undefined, the window will be centered in a screen when deserialised unless the coordinate can be obtained automatically.

collapsed bool <optional>

Whether the window should be serialised in the collapsed state. If undefined, the current collapsed status will be used instead (which is always false if the compact mode is on).

Source:
Returns:

Window serialised in form of a JSON-able dictionary.

showLoading()

Shows the loading indicator in a window.

Source:

(abstract) startResize() → {bool}

Called when a user starts resizing a window.

Source:
Returns:

Whether finishResize() should be called after resizing is complete.

Type
bool

triggerResize()

Triggers window resizing event-wise.

Source:

unfocus()

Unfocuses a window.

Source:

(static) deserialize(jsonopt, ready_handleropt)

Creates a window from a JSON-able dictionary produced by serialize() or an equivalent JSON string.

The resulting window object can be accessed in Window.instances using the ID stored in the JSON string under "id".

Parameters:
Name Type Attributes Description
json <optional>

A JSON-able dictionary produced by serialize() or an equivalent JSON string.

ready_handler function <optional>

Function to be called when a window finishes loading. It should have zero parameters and no return value. This is not run if an error occurs. It can be undefined.

Source:

(static) getDepsPath() → {String}

Gets the path to the server folder where JavaScript and CSS dependencies of modules are stored. Use the value returned by this method for constructing URLs to the dependencies.

Source:
Returns:

Path to the folder with JavaScript and CSS module dependencies.

Type
String

(static) isInCompactMode() → {bool}

Returns whether Adaptyst Analyser is run in compact mode.

Source:
Returns:

Whether compact mode is enabled.

Type
bool

(static) stopPropagation(event)

Stops further propagation of an event. It may be useful e.g. for handling mouse clicks.

Parameters:
Name Type Description
event Object

Event which propagation should be stopped.

Source: