Repository

Description

Repository maintains a set of elements.

Reponsibilities:

  • Applies operations. (Undo/Redo)
  • Query for retrieve elements.

This module dispatches these events:

  • created: (elems)
  • updated: (elems)
  • deleted: (elems)
  • reordered: (elem)
  • relocated: (elem, field, oldParent, newParent)
  • beforeExecuteOperation: (operation)
  • operationExecuted: (operation) - after doOperation, undo, redo
  • beforeUndo: (operation)
  • beforeRedo: (operation)

Variables Summary

Functions Summary

Classes Summary

Variables

MAX_STACK_SIZE

Maximum size of undo/redo stack

Functions

Public API

bypassFieldAssign

Assign a value to a field. This will not insert an Operation into UndoStack (bypass = true). Use it carefully.

elem module:core,Core.Element
Field owner.
field string
Field name.
val Core.Element
Value to be assigned to.
Public API

bypassInsert

Insert an element to an array field. This will not insert an Operation into UndoStack (bypass = true). Use it carefully.

parent Core.Element
Field owner.
field string
Field name.
elem Core.Element
An element to be inserted.
Public API

clear

Clear all maps and stacks

Public API

doOperation

Do an Operation If operation.bypass == true, the operation will not be pushed to UndoStack.

operation Operation
Public API

find

Find the first matched element satisfying the predicate.

predicate function(Element):boolean
A function to filter elements.
Returns: Element
A matched element.
Public API

findAll

Find all elements satisfying the predicate.

predicate function(Element):boolean
A function to filter elements.
Returns: Array.<Element>
All matched elements.
Public API

get

Return element by id.

id string
Identifier of element.
Returns: Element
Element of id.
Public API

getEdgeViewsOf

Return all instances of EdgeView linked to the given view.

view Core.View
View element. Typically an instance of NodeView.
Returns: Array<Core.EdgeView>
Instances of EdgeView linked to.
Public API

getInstancesOf

Return instances of a specified type name(s).

_typeName string,Array.<string>
Type name(s) of instances to be returned.
Returns: Array.<Element>
instances of the type name(s).
Public API

getRefsTo

Return all elements referencing to the given element.

elem Core.Element
Element. (model element, view element, or diagram)
iterator nullable function(Element):boolean
if given, returns instances only satisfying iterator function.
Returns: Array<Core.Element>
Elements referencing to.
Public API

getRelationshipsOf

Return all instances of Relationship connected to the given model element.

model Core.Model
Model element.
iterator nullable function(Element):boolean
if given, returns instances only satisfying iterator function.
Returns: Array<Core.Model>
Instances of Relationship.
Public API

getViewsOf

Return all views associated with the given model.

model Core.Model
Model element.
Returns: Array<Core.View>
View elements associated with.
Public API

isElement

Return true if the given parameter is an element in this Repository.

elem Element
Returns: boolean
Public API

isModified

Return whether project is modified or not.

Returns: boolean
Public API

lookupAndFind

Lookup an element and then find. (See Element.prototype.lookup and find).

namespace non-nullable Element
Element to start to lookup.
name string
Name of element to find
typeFilter constructor
Type filter. (e.g. `type.UMLClass`)
Returns: Element
A matched element.
Public API

redo

Redo

Public API

select

Return an array of elements selected by selector expression. This is a quite heavy operation, so you need to concern about performance.

Selector expression

- Children selector
  ex) Package1:: -- all children of Package1

- Type selector: "@<type>"
  ex) Package1::@UMLClass

- Field selector: ".<field>"
  ex) Class1.attributes, Package1.owendElements

- Value selector: "[field=value]"
  ex) Class1.operations[isAbstract=false]     

- Name selector: "<name>" (equivalent to "[name=<name>]")
  ex) Class1, Class1::Attribute1

Selector examples: @UMLClass Package1::Class1.attributes[type=String] Package1::Model1::@UMLInterface.operations[isAbstract=false]

selector string
Returns: Array.<Element>
Public API

undo

Undo

Classes

Constructor

Stack

Size-limited Stack

Methods

Methods

Public API

clear

Clear stack.

pop

Pop an item from the top

Returns: ?
Item on the top.

push

Push an item

item nullable
Item to be stacked.

size

Return size of stack

Returns: number
Size of stack.