StarUML

3.0.0

Core

These are core classes.

AppContext

Application Context

new AppContext()

Extends EventEmitter

Instance Members
type
menu
contextMenu
keymaps
commands
project
metamodels
repository
validator
preferences
selections
clipboard
engine
factory
diagrams
extensionLoader
sidebar
navigator
workingDiagrams
toolbox
modelExplorer
styleEditor
propertyEditor
documentationEditor
toolbar
statusbar
quickedits
dialogs
toast
panelManager
elementPickerDialog
elementListPickerDialog
elementListEditorDialog

ProjectManager

Project Manager

This module dispatches these events:

  • projectCreated: (project)
  • projectSaved: (filename, project)
  • projectLoaded: (filename, project)
  • beforeProjectClose: (filename, project);
  • projectClosed:
  • imported: (filename, element)
  • exported: (filename, element)
new ProjectManager()

Extends EventEmitter

Instance Members
repository
getProject()
getFilename()
newProject()
closeProject()
save(fullPath)
load(fullPath)
loadAsTemplate(fullPath)
loadFromJson(data)
importFromFile(parent, fullPath)
importFromJson(parent, data)
exportToFile(elem, fullPath)

CommandManager

Manages global application commands that can be called from menu items, key bindings, or subparts of the application.

This module dispatches these event(s):

  • commandRegistered -- when a new command is registered
  • beforeExecuteCommand -- before dispatching a command
new CommandManager()

Extends EventEmitter

Instance Members
commands
register(id, commandFn)
execute(id, args)

KeymapManager

Keymap Manager

new KeymapManager()
Instance Members
keymap
globalKeydownHooks
commandManager
add(keys)
translateKeyboardEvent(event)

Menu Manager

new MenuManager()
Instance Members

ContextMenuManager

Context Menu Manager

new ContextMenuManager()
Instance Members
templatesBySelector
keymapManager
add(templatesBySelector)
popup(selector)
setup()

MetamodelManager

Metamodel Manager

new MetamodelManager()
Instance Members
register(metamodel)
getMetaAttributes(typeName)
isKindOf(child, parent)
getViewTypeOf(typeName)
getAvailableViewTypes(diagramTypeName)

Repository

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)
new Repository()

Extends EventEmitter

Instance Members
operationBuilder
extractChanged(operation)
doOperation(operation)
undo()
redo()
clear()
isModified()
isElement(elem)
select(selector)
get(id)
getInstancesOf(_typeName)
find(predicate)
findAll(predicate)
search(keyword, typeFilter)
lookupAndFind(namespace, name, typeFilter)
getRefsTo(elem, iterator)
getRelationshipsOf(model, iterator)
getViewsOf(model)
getEdgeViewsOf(view)
getConnectedNodeViews(view, edgeType, predicate)
getConnectedHeadNodeViews(view, edgeType)
getConnectedTailNodeViews(view, edgeType)
getIdMap()
getOperationBuilder()
bypassInsert(parent, field, elem)
bypassFieldAssign(elem, field, val)

Engine

Engine

new Engine()
Instance Members
repository
addModel(parent, field, model)
addViews(diagram, views)
addModelAndView(diagram, model, view, parent, parentField, containerView)
setProperty(elem, field, value)
setProperties(elem, fieldValueMap)
setElemsProperty(elems, field, value, views)
deleteElements(models, views)
addItem(elem, field, val)
removeItem(elem, field, val)
moveUp(parent, field, elem)
moveDown(parent, field, elem)
relocate(elem, newOwner, field)
moveViews(editor, views, dx, dy)
moveParasiticView(editor, view, alpha, distance)
resizeNode(editor, node, left, top, right, bottom)
modifyEdge(editor, edge, points)
reconnectEdge(editor, edge, points, newParticipant, isTailSide)
moveViewsChangingContainer(editor, views, dx, dy, containerView, containerModel)
setFillColor(editor, views, color)
setLineColor(editor, views, color)
setFont(editor, views, face, size, color)
setFontColor(editor, views, color)
setFontFace(editor, views, fontFace)
setFontSize(editor, views, fontSize)
setStereotypeDisplay(editor, views, stereotypeDisplay)
setLineStyle(editor, views, lineStyle)
setAutoResize(editor, views, autoResize)
layoutDiagram(editor, diagram, direction, separations, edgeLineStyle)

SelectionManager

This module dispatches these events:

  • selectionChanged: (selectedModels, selectedViews)
new SelectionManager()

Extends EventEmitter

Instance Members
getSelectedModels()
getSelectedViews()
deselectAll()
select(models, views)
selectModel(model)
selectViews(views)
getSelected()

PreferenceManager

PreferenceManager only works in browser (it uses global localStorage object).

new PreferenceManager()

Extends EventEmitter

Instance Members
schemaMap
itemMap
validate(schema)
register(preferenceDef, prefs)
get(key, defaultValue)
set(key, value)
getViewState(id, context)
setViewState(id, value, context, doNotSave?)

ClipboardManager

Clipboard Manager

new ClipboardManager()
Instance Members
clipboardData
repository
writeToClipboard()
readFromClipboard()
setModel(model)
setViews(views)
getModel()
getViews()
hasModel()
hasViews()
getElementType()
getCopyContext()

Factory

Factory creates model, view and diagram elements

This module dispatches these events:

  • diagramCreated: (diagram)
  • elementCreated: (model, view)
new Factory()

Extends EventEmitter

Instance Members
metamodelManager
repository
engine
diagramManager
createDiagram(options)
createModel(options)
createModelAndView(options)
createViewOf(options)
getDiagramIds()
getModelIds()
getModelAndViewIds()
registerDiagramFn(id, fn)
registerModelFn(id, fn)
registerModelAndViewFn(id, fn, defaultOptions)
registerViewOfFn(diagramType, fn)
defaultDiagramFn(parent, options)
defaultModelFn(parent, field, options)
defaultModelAndViewFn(parent, diagram, options)
defaultUndirectedRelationshipFn(parent, diagram, options)
defaultDirectedRelationshipFn(parent, diagram, options)
defaultViewOnlyFn(parent, diagram, options)
defaultEdgeViewOnlyFn(parent, diagram, options)
createViewAndRelationships(editor, x, y, model, containerView)
defaultViewOnDiagramFn(model, diagram, options)

DiagramManager

This module dispatches these events: - workingDiagramAdd: (diagram) - workingDiagramRemove: (diagram) - workingDiagramUpdate: (diagram) - currentDiagramChanged: (editor) - repaint: (editor) - mouseDown: (mouseEvent) - selectionChanged: (views) - viewDoubleClicked: (view, x, y) - viewMoved: (views, dx, dy) - parasiticViewMoved: (view, alpha, distance) - containerViewChanged: (views, dx, dy, containerView) - nodeResized: (node, left, top, right, bottom) - edgeModified: (edge, points) - edgeReconnected: (edge, points, newParticipant, isTailSide)

new DiagramManager()

Extends EventEmitter

Instance Members
openDiagram(diagram)
updateDiagram(diagram)
closeDiagram(diagram)
getWorkingDiagrams()
saveWorkingDiagrams()
restoreWorkingDiagrams()
closeOthers()
closeAll()
setCurrentDiagram(diagram, skipEvent)
getCurrentDiagram()
nextDiagram()
previousDiagram()
setActiveHandler(handler)
getEditor()
getHiddenEditor()
selectAll()
deselectAll()
selectInDiagram(view)
repaint()
setZoomLevel(value)
getZoomLevel()
toggleGrid()
showGrid()
hideGrid()
isGridVisible()
getViewportSize(x)
scrollTo(x, y, animation)
getScrollPosition()
getDiagramArea()
Events
module:workspace/diagram-manager.currentDiagramChanged
module:workspace/diagram-manager.selectionChanged
module:workspace/diagram-manager.viewDoubleClicked
module:workspace/diagram-manager.viewMoved

Elements

These are core elements.

Element

Element

new Element()
Static Members
AK_PRIM
AK_ENUM
AK_REF
AK_REFS
AK_OBJ
AK_OBJS
AK_VAR
AK_CUSTOM
getSuperType(subType)
getCommonType(elems)
getNewName(array, prefix)
mergeProps(elems, prop)
Instance Members
_id
_parent
getDisplayClassName()
getClass()
getClassName()
getMetaClass()
getMetaAttributes()
getParentField()
getNodeIcon()
getNodeText(options)
getOrdering(index)
getChildNodes(sort)
getChildren()
traverse(fun)
traverseDepthFirst(fun)
traverseField(field, fun)
traverseFieldDepthFirst(field, fun)
traverseUp(fun)
load(reader)
save(writer)
assignTo(memento)
assignFrom(memento)
diff(memento)
lookup(name, typeFilter, namespace)
findByName(name)
lookdown(pathName)
isOneOfTheContainers(elem)
canContainKind(kind)
canContain(elem)
canCopy()
canDelete()
canPaste(kind, copyContext)

Model

Model

new Model()

Extends Element

Instance Members
name
ownedElements
getViewType()
getPath(base)
getPathname()
canContain(elem)
canContainDiagramKind(kind)
canContainDiagram(diagram)
canRelocateTo(model)

Tag

Tag

new Tag()

Extends Model

Static Members
TK_STRING
TK_REFERENCE
TK_BOOLEAN
TK_NUMBER
TK_HIDDEN
Instance Members
kind
value
reference
checked
number

Hyperlink

new Hyperlink()

Extends Model

Instance Members
reference
url

ExtensibleModel

ExtensibleModel

new ExtensibleModel()

Extends Model

Instance Members
documentation
tags
hasTag(tagName)
getTag(tagName)
getTagValue(tagName)

Relationship

Relationship

new Relationship()

Extends ExtensibleModel

DirectedRelationship

DirectedRelationship

new DirectedRelationship()

Extends Relationship

Instance Members
target
source

RelationshipEnd

RelationshipEnd

new RelationshipEnd()

Extends ExtensibleModel

Instance Members
reference

UndirectedRelationship

UndirectedRelationship

new UndirectedRelationship()

Extends Relationship

Instance Members
end1
end2

View

View

new View()

Extends Element

Static Members
SK_NO
SK_YES
SK_PROPAGATE
Instance Members
model
subViews
containerView
containedViews
visible
enabled
selected
selectable
lineColor
fillColor
fontColor
font
parentStyle
showShadow
containerChangeable
containerExtending
zIndex
traverse(fun)
traverseDepthFirst(fun)
assignStyleToCanvas(canvas)
delimitContainingBoundary(canvas)
initialize(canvas, x1, y1, x2, y2)
move(canvas, dx, dy)
moveObject(canvas, dx, dy)
setup(canvas)
update(canvas)
size(canvas)
sizeObject(canvas)
arrange(canvas)
arrangeObject(canvas)
drawShadow(canvas)
draw(canvas)
drawObject(canvas)
drawSelection(canvas)
getViewAt(canvas, x, y)
getDiagram()
getBoundingBox(canvas)
containsPoint(canvas, x, y)
overlapRect(canvas, rect)
addSubView(view)
removeSubView(view)
addContainedView(view)
removeContainedView(view)
isOneOfTheContainerViews(view)
canContainViewKind(kind)
canContainView(view)
drawContainingBox(canvas)
eraseContainingBox(canvas)

NodeView

NodeView

new NodeView()

Extends View

Static Members
SZ_NONE
SZ_HORZ
SZ_VERT
SZ_RATIO
SZ_FREE
MM_NONE
MM_HORZ
MM_VERT
MM_FREE
Instance Members
left
top
width
height
minWidth
minHeight
sizable
movable
autoResize
getRight()
setRight(value)
getBottom()
setBottom(value)
getCenter()
moveObject(canvas, dx, dy)
initialize(canvas, x1, y1, x2, y2)
sizeObject(canvas)
arrangeObject(canvas)
drawObject(canvas)
drawSelection(canvas)
getBoundingBox(canvas)

EdgeView

EdgeView

new EdgeView()

Extends View

Static Members
LM_SOLID
LM_DOT
LS_RECTILINEAR
LS_OBLIQUE
LS_ROUNDRECT
LS_CURVE
ES_FLAT
ES_STICK_ARROW
ES_SOLID_ARROW
ES_TRIANGLE
ES_FILLED_TRIANGLE
ES_DIAMOND
ES_FILLED_DIAMOND
ES_ARROW_DIAMOND
ES_ARROW_FILLED_DIAMOND
ES_PLUS
ES_CIRCLE
ES_CIRCLE_PLUS
ES_CROWFOOT_ONE
ES_CROWFOOT_MANY
ES_CROWFOOT_ZERO_ONE
ES_CROWFOOT_ZERO_MANY
Instance Members
head
tail
lineStyle
reducePoints(canvas)
recalcOblique(canvas)
recalcRectilinear(canvas)
drawLineEnd(canvas, edgeEndStyle, isHead)
initialize(canvas, x1, y1, x2, y2)
moveObject(canvas, dx, dy)
recalcPoints(canvas)
arrangeObject(canvas)
drawObject(canvas)
drawSelection(canvas)
getBoundingBox(canvas)
containsPoint(canvas, x, y)
disToPoint(p1, p2)
disToOrthoLine(lh, lt, p)
containedIndex(canvas, p)
selectedPoint(canvas, p)
canConnectTo(view, isTail)

LabelView

LabelView

new LabelView()

Extends NodeView

Static Members
DK_HORZ
DK_VERT
Instance Members
underline
text
horizontalAlignment
verticalAlignment
direction
wordWrap
sizeObject(canvas)
arrange(canvas)
draw(canvas)
canCopy()
canDelete()

ParasiticView

ParasiticView

new ParasiticView()

Extends NodeView

Instance Members
alpha
distance
canCopy()
canDelete()

NodeParasiticView

NodeParasiticView

new NodeParasiticView()

Extends ParasiticView

Instance Members
hostNode

EdgeParasiticView

EdgeParasiticView

new EdgeParasiticView()

Extends ParasiticView

Static Members
EP_HEAD
EP_MIDDLE
EP_TAIL
Instance Members
hostEdge
edgePosition

NodeLabelView

NodeLabelView

new NodeLabelView()

Extends NodeParasiticView

Instance Members
underline
wordWrap

EdgeLabelView

EdgeLabelView

new EdgeLabelView()

Extends EdgeParasiticView

Instance Members
underline
wordWrap

NodeNodeView

NodeNodeView

new NodeNodeView()

Extends NodeParasiticView

EdgeNodeView

EdgeNodeView

new EdgeNodeView()

Extends EdgeParasiticView

Diagram

Diagram

new Diagram()

Extends ExtensibleModel

Static Members
LD_TB
LD_BT
LD_LR
LD_RL
Instance Members
visible
defaultDiagram
ownedViews
selectedViews
drawDiagram(canvas, drawSelection)
getViewAt(canvas, x, y, shallow, viewType)
getBottomViewAt(canvas, x, y)
getViewOf(model, viewType)
canCopyViews()
canDeleteViews()
canPasteViews(views)
canAcceptModel(model)
layout(direction, separations, edgeLineStyle)

Project

Project

new Project()

Extends ExtensibleModel

Etc

These are etc elements.

MAX_STACK_SIZE

Maximum size of undo/redo stack

MAX_STACK_SIZE

Type: number

Operator

Operator constants

Operator

Stack

Size-limited Stack

new Stack(maxSize: any)
Parameters
maxSize (any)
Instance Members
clear()
push(item)
pop()
size()

Reader

Reader Class

new Reader(data: Object, ctors: Object<string, constructor>)
Parameters
data (Object)
Instance Members
read(name)
readObj(name)
readObjArray(name)
readRef(name)
readRefArray(name)
readVariant(name)
readCustom(typeName, name)

Writer

Writer Class for storing Elements into JSON data.

new Writer()
Instance Members
current
write(name, value)
writeObj(name, value)
writeObjArray(name, value)
writeRef(name, value)
writeRefArray(name, value)
writeVariant(name, value)
writeCustom(name, value)

OperationBuilder

OperationBuilder is used to build an operation

This module dispatches these events: - insert: (elem) - remove: (elem) - fieldAssign: (elem, field, val) - fieldInsert: (elem, field, val) - fieldInsertAt: (elem, field, val, pos) - fieldRemove: (elem, field, val) - fieldRemoveAt: (elem, field, val, pos) - fieldReorder: (elem, field, val, newPos) - fieldRelocate: (elem, field, oldParent, newParent)

new OperationBuilder()

Extends EventEmitter

Instance Members
getTimestamp()
begin(name, bypass, opName)
end()
discard()
getOperation()
insert(elem)
remove(elem)
fieldAssign(elem, field, val)
fieldInsert(elem, field, val)
fieldInsertAt(elem, field, val, pos)
fieldRemove(elem, field, val)
fieldRemoveAt(elem, field, val, pos, value)
fieldReorder(elem, field, val, pos)
fieldRelocate(elem, field, oldParent, newParent)

Validator

Validator

new Validator()
Instance Members
repository
addRules(rules)
validate()

DK_MODEL

Clipboard Data Kinds

DK_MODEL

Type: string

STAT_UNREGISTERED

STAT_UNREGISTERED

Type: string

getStatus

Get Registration Status

getStatus(): string
Returns
string:

setStatus

Set Registration Status

setStatus(newStat: any): string
Parameters
newStat (any)
Returns
string:

getLicenseInfo

Get License Infomation

getLicenseInfo(): Object
Returns
Object:

register

Register LicenseKey

register(name: any, licenseKey: string): $.Promise
Parameters
name (any)
licenseKey (string)
Returns
$.Promise:

validate

Validate LicenseKey

validate(): $.Promise
Returns
$.Promise:

SidebarView

SidebarView

This contains ToolboxView and WorkingDiagramView

new SidebarView()
Instance Members
toggle()
show()
hide()
isVisible()

toggle

Toggle NavigatorView

toggle()

show

Show NavigatorView

show()

hide

Hide NavigatorView

hide()

isVisible

Return whether NavigatorView is visible or not

isVisible(): booean
Returns
booean:

WorkingDiagramsView

WorkingDiagramsView

new WorkingDiagramsView()

_updateScrollerShadow

Positions shadow background elements to indicate vertical scrolling.

_updateScrollerShadow($displayElement: !DOMElement, $scrollElement: !Object, $shadowTop: !DOMElement, $shadowBottom: !DOMElement, isPositionFixed: boolean)
Parameters
$displayElement (!DOMElement) the DOMElement that displays the shadow
$scrollElement (!Object) the object that is scrolled
$shadowTop (!DOMElement) div .scroller-shadow.top
$shadowBottom (!DOMElement) div .scroller-shadow.bottom
isPositionFixed (boolean) When using absolute position, top remains at 0.

addScrollerShadow

Installs event handlers for updatng shadow background elements to indicate vertical scrolling.

addScrollerShadow(displayElement: !DOMElement, scrollElement: Object?, showBottom: boolean?)
Parameters
displayElement (!DOMElement) the DOMElement that displays the shadow. Must fire "contentChanged" events when the element is resized or repositioned.
scrollElement (Object?) the object that is scrolled. Must fire "scroll" events when the element is scrolled. If null, the displayElement is used.
showBottom (boolean?) optionally show the bottom shadow

removeScrollerShadow

Remove scroller-shadow effect.

removeScrollerShadow(displayElement: !DOMElement, scrollElement: Object?)
Parameters
displayElement (!DOMElement) the DOMElement that displays the shadow
scrollElement (Object?) the object that is scrolled

toggleClass

Utility function to replace jQuery.toggleClass when used with the second argument, which needs to be a true boolean for jQuery

toggleClass($domElement: !jQueryObject, className: !string, addClass: !boolean)
Parameters
$domElement (!jQueryObject) The jQueryObject to toggle the Class on
className (!string) Class name or names (separated by spaces) to toggle
addClass (!boolean) A truthy value to add the class and a falsy value to remove the class

sidebarList

Within a scrolling DOMElement, creates and positions a styled selection div to align a single selected list item from a ul list element.

Assumptions:

  • scrollerElement is a child of the #sidebar div
  • ul list element fires a "selectionChanged" event after the selectedClassName is assigned to a new list item
sidebarList($scrollerElement: any, selectedClassName: !string, leafClassName: any, scrollElement: !DOMElement)
Parameters
$scrollerElement (any)
selectedClassName (!string) A CSS class name on at most one list item in the contained list
leafClassName (any)
scrollElement (!DOMElement) A DOMElement containing a ul list element

getElementClipSize

Determine how much of an element rect is clipped in view.

getElementClipSize($view: !DOMElement, elementRect: !{top: number, left: number, height: number, width: number}): {top: number, right: number, bottom: number, left: number}
Parameters
$view (!DOMElement) A jQuery scrolling container
elementRect (!{top: number, left: number, height: number, width: number}) rectangle of element's default position/size
Returns
{top: number, right: number, bottom: number, left: number}: amount element rect is clipped in each direction

scrollElementIntoView

Within a scrolling DOMElement, if necessary, scroll element into viewport.

To Perform the minimum amount of scrolling necessary, cases should be handled as follows:

  • element already completely in view : no scrolling
  • element above viewport : scroll view so element is at top
  • element left of viewport : scroll view so element is at left
  • element below viewport : scroll view so element is at bottom
  • element right of viewport : scroll view so element is at right

Assumptions:

  • $view is a scrolling container
scrollElementIntoView($view: !DOMElement, $element: !DOMElement, scrollHorizontal: boolean?)
Parameters
$view (!DOMElement) A jQuery scrolling container
$element (!DOMElement) A jQuery element
scrollHorizontal (boolean?) whether to also scroll horizontally

getFileEntryDisplay

HTML formats a file entry name for display in the sidebar.

getFileEntryDisplay(entry: !File): string
Parameters
entry (!File) File entry to display
Returns
string: HTML formatted string

getDirNamesForDuplicateFiles

Determine the minimum directory path to distinguish duplicate file names for each file in list.

getDirNamesForDuplicateFiles(files: Array<File>): Array<string>
Parameters
files (Array<File>) list of Files with the same filename
Returns
Array<string>: directory paths to match list of files

ToolboxView

This module dispatches these events: - elementCreated: (id, editor, x1, y1, x2, y2) - activeHandlerChanged: (handler)

new ToolboxView()

Extends EventEmitter

Instance Members
items
idByhtmlId
repository
diagramManager
commandManager
quickeditManager
add(template)
addGroup(groupId, title, diagramTypes, autoExpands)
addItem(id, groupId, title, iconClass, rubberband, command, commandArg)
setActiveItemLock(locked, itemId)
setDiagram(diagram)
selectItem(itemId)
expandGroup(groupId)
collapseGroup(groupId)
getHandler(id)
toggle()
show()
hide()
isVisible()
htmlReady()
_appReady()

MouseEvent

MouseEvent

new MouseEvent(x: any, y: any, button: any, count: any, shiftDown: any, altDown: any, ctrlDown: any)
Parameters
x (any)
y (any)
button (any)
count (any)
shiftDown (any)
altDown (any)
ctrlDown (any)

Handler

Handler

new Handler()
Instance Members
mouseDown(editor, canvas, e)
mouseUp(editor, canvas, e)
mouseMove(editor, canvas, e)

ManipulatorBinder

ManipulatorBinder

new ManipulatorBinder(selectHandler: any)
Parameters
selectHandler (any)
Instance Members
bind(view)

ManipulatableNotifier

ManipulatableNotifier

new ManipulatableNotifier()

ContainmentHandlingProxy

ContainmentHandlingProxy

new ContainmentHandlingProxy()

SM_NONE

SelectHandler Constants

SM_NONE

Type: number

SelectHandler

SelectHandler

new SelectHandler()

Extends Handler

Instance Members
hasTheSameContainerView(viewSet)
isPointInSelectionLine(canvas, view, x, y)
mouseDown(editor, canvas, e)
mouseMove(editor, canvas, e)
mouseUp(editor, canvas, e)

CreateHandler

CreateHandler

new CreateHandler(id: any, skeletonKind: any, callback: any)

Extends Handler

Parameters
id (any)
skeletonKind (any)
callback (any)
Instance Members
mouseDown(editor, canvas, e)
mouseMove(editor, canvas, e)
mouseUp(editor, canvas, e)

Manipulator

Manipulator

new Manipulator()
Instance Members
beginManipulate(editor, canvas, view, x, y)
drawSkeleton(editor, canvas)
eraseSkeleton(editor, canvas)
moveSkeleton(editor, canvas, view, delta)
endManipulate(editor, canvas, view, dx, dy)

NodeManipulator

NodeManipulator

new NodeManipulator()

Extends Manipulator

SL_TAIL

EdgeManipulator Constants

SL_TAIL

Type: number

EdgeManipulator

EdgeManipulator

new EdgeManipulator()

Extends Manipulator

Instance Members
beginManipulate(editor, canvas, view, x, y)
endManipulate(editor, canvas, view, dx, dy)
gridFitX(canvas, x, y)
gridFitY(canvas, y)
putPointBoundsOnCanvas(editor, p)
moveSkeleton(editor, canvas, view, delta)
drawSkeleton(editor, canvas)
eraseSkeleton(editor, canvas)

ParasiticManipulator

ParasiticManipulator

new ParasiticManipulator()

Extends NodeManipulator

Instance Members
endManipulate(editor, canvas, view, dx, dy)

DiagramEditor

Diagram Editor

This class dispatches theses events: - selectionChanged: (views) - mouseDown: - viewDoubleClicked: (view, x, y) - viewMoved: (views, dx, dy) - parasiticViewMoved: (view, alpha, distance) - containerViewChanged: (views, dx, dy, containerView) - nodeResized: (node, left, top, right, bottom) - edgeModified: (edge, points) - edgeReconnected: (edge, points, newParticipant, isTailSide)

new DiagramEditor(config: any)

Extends EventEmitter

Parameters
config (any)
Instance Members
getDiagram()
setDiagramWidth(width)
getDiagramWidth()
setDiagramHeight(height)
getDiagramHeight()
getZoomFactor()
getGridFactor()
setCursor(cursor)
convertPosition(point)

ModelExplorerView

This module dispatches these events: - selected: (elem) - doubleClicked: (elem) - dragOver: ({source, target, allow}); - dragOverDiagram: ({source, diagram, allow}); - drop: (source, target) - dropOnDiagram (source, diagram)

new ModelExplorerView()

Extends EventEmitter

Instance Members
expand(elem, expandAllParents)
collapse(elem)
select(elem, scrollTo)
deselect()

EditorsHolderView

EditorsHolder

This contains StyleEditorView, PropertyEditorView, and DocumentationEditorView

new EditorsHolderView()
Instance Members
toggle()
show()
hide()
isVisible()

show

Show styles of a given a list of views

show(views: Array<View>)
Parameters
views (Array<View>)

PropertyEditorView

This module dispatches these events: - propertyChanged: (element, field, value)

new PropertyEditorView()

Extends EventEmitter

Instance Members
_destroyedBeforeShowing
show(elems, elem)

DocumentationEditorView

This module dispatches these events: - documentationChanged: (element, documentation)

new DocumentationEditorView()

Extends EventEmitter

Instance Members
show(elem)

ToolbarView

Toolbar

new ToolbarView()
Instance Members
toggle()
show()
hide()
isVisible()

StatusbarView

StatusBar

new StatusbarView()
Instance Members
toggle()
show()
hide()
isVisible()

merge

merge(template: Array, item: object)
Parameters
template (Array)
item (object)

findById

Find a template item by a given id

findById(template: Array, id: string)
Parameters
template (Array)
id (string)

translateTemplate

Translate templates to Electron's menu template format

translateTemplate(template: any, keystrokesByCommand: any)
Parameters
template (any)
keystrokesByCommand (any)

acceleratorForCommand

acceleratorForCommand(command: any, keystrokesByCommand: any)
Parameters
command (any)
keystrokesByCommand (any)

flattenMenuItems

flattenMenuItems(menu: Menu)
Parameters
menu (Menu)

updateStates

updateStates(itemsById: Map<string, MenuItem>, visibleStates: Map<string, boolean>, enabledStates: Map<string, boolean>, checkedStates: Map<string, boolean>)
Parameters
itemsById (Map<string, MenuItem>)
visibleStates (Map<string, boolean>)
enabledStates (Map<string, boolean>)
checkedStates (Map<string, boolean>)

SELECTOR_ALIAS

Pre-defined alias for context menu selectors

SELECTOR_ALIAS

Color

Color Object

Color

Point

Point class

new Point(x: number, y: number)
Parameters
x (number)
y (number)
Instance Members
x
y
copy()
add(p)
setPoint(x, y)
setPoint2(p)
quantize(p)

Rect

Rect Class

new Rect(x1: number, y1: number, x2: number, y2: number)
Parameters
x1 (number)
y1 (number)
x2 (number)
y2 (number)
Instance Members
copy()
add(p)
setRect(x1, y1, x2, y2)
setRect2(r)
setRect3(p1, p2)
expand(delta)
union(r)
getCenter()
getWidth()
getHeight()
getRatioPercent()
quantize()

Font

Font

new Font(face: any, size: any, style: any)
Parameters
face (any)
size (any)
style (any)
Static Members
FS_NORMAL
FS_BOLD
FS_ITALIC
FS_BOLD_ITALIC
Instance Members
set(face, size, style)
assign(font)
copy()

ZoomFactor

ZoomFactor

new ZoomFactor(numer: any, denom: any)
Parameters
numer (any)
denom (any)
Instance Members
setScale(value)
getScale()

GridFactor

GridFactor

new GridFactor(width: any, height: any)
Parameters
width (any)
height (any)

Points

Points

new Points()
Instance Members
clear()
copy()
assign(pts)
add(p)
insert(index, p)
remove(index)
setPoint(index, p)
setPoint2(index, x, y)
getPoint(index)
getXPoints()
getYPoints()
count()
reduceOrthoLine()
reduceLine()
isRectilinear()
convObliqueToRectilinear()
getBoundingRect()
quantize()

Coord

Coordination utility object

Coord
Static Members
valueTransform(zf, value)
coordTransform(zf, gf, p)
coordTransform2(zf, gf, r)
coordRevTransform(zf, gf, p)
ptInRect(x, y, rect)
ptInRect2(p, rect)
ptInLine(line, p)
ptsInLine(p1, p2, p3)
rectInRect(rect1, rect2)
getCenter(rect)
equalRect(r1, r2)
equalPt(p1, p2)
equalPt2(p1, p2, d)
normalizeRect(rect)
normalizeRect2(p1, p2)
unionRect(r1, r2)
junction(r, pt)
orthoJunction(r, p)
makeOrthoPt(p1, p2)
getPointAwayLine(tailPoint, headPoint, alpha, distance)
getPolar(line, p)
getAngle(x1, y1, x2, y2)
toRadian(degree)
toDegree(radian, radin)

Canvas

Canvas

new Canvas(context: any)
Parameters
context (any)
Static Members
AL_LEFT
AL_RIGHT
AL_CENTER
AL_TOP
AL_BOTTOM
AL_MIDDLE
Instance Members
storeState()
restoreState()
transform()
restoreTransform()
putPixel(x, y, c)
line(x1, y1, x2, y2, dashPattern)
rect(x1, y1, x2, y2, dashPattern)
fillRect(x1, y1, x2, y2)
roundRect(x1, y1, x2, y2, radius, dashPattern)
fillRoundRect(x1, y1, x2, y2, radius)
ellipse(x1, y1, x2, y2, dashPattern)
fillEllipse(x1, y1, x2, y2)
polyline(points, dashPattern)
roundRectLine(points, dashPattern)
curveLine(points, dashPattern)
polygon(points)
fillPolygon(points)
arc(x, y, r, startAngle, endAngle, counterClockwise)
fillArc(x, y, r, startAngle, endAngle, counterClockwise)
path(commands)
fillPath(commands, doStroke)
wordWrap(text, width)
textOut(x, y, text, rotation, wordWrap, underline, rotate)
textOut2(rect, text, horizontalAlignment, verticalAlignment, rotate, wordWrap, underline)
textExtent(text, wordWrapWidth)
drawImage(image, x, y, width, height)

GraphicUtils

Graphic Utilities

new GraphicUtils()

components

Component definitions

components

quickedits

Quickedit definitions

quickedits

activeQuickedit

Active Quickedit

activeQuickedit

keymap

Keymap

keymap

keydownHook

KeydownHook

keydownHook

diagramManager

A reference to an instance of DiagramManager

diagramManager

engine

A reference to an instance of Engine

engine

keymapManager

A reference to an instance of KeymapManager

keymapManager

commandManager

A reference to an instance of CommandManager

commandManager

add

Add a quickedit template

add(template: any)
Parameters
template (any)

open

Open a corresponding quickedit for the given view

open(view: View, x: Number, y: Number)
Parameters
view (View)
x (Number) Double-clicked x position (optional)
y (Number) Double-clicked y position (optional)

getEdgeViewEnd

Get the clicked end of EdgeView

getEdgeViewEnd(edgeView: EdgeView, x: number, y: number): string
Parameters
edgeView (EdgeView)
x (number)
y (number)
Returns
string: 'end1' | 'end2' | null

close

Close QuickEdit

close(applyChanges: boolean)
Parameters
applyChanges (boolean)

module:workspace/quick-edit.change

Change Event

module:workspace/quick-edit.change
Parameters
id (any)
itemId (any)
view (any)
value (any)
feedback (any)
Properties
id (string) : QuickEdit Id.
itemId (string) : Item Id.
view (View) : View
value (any) : Value

module:workspace/quick-edit.click

Click Event

module:workspace/quick-edit.click
Parameters
id (any)
itemId (any)
view (any)
Properties
id (string) : QuickEdit Id.
itemId (string) : Item Id.
view (View) : View
value (any) : Value

module:workspace/quick-edit.keydown

Keydown Event

module:workspace/quick-edit.keydown
Parameters
id (any)
itemId (any)
view (any)
event (any)
Properties
id (string) : QuickEdit Id.
itemId (string) : Item Id.
view (View) : View
event (JQuery.Event)

module:workspace/quick-edit.open

Open Event

module:workspace/quick-edit.open
Parameters
editor (any)
view (any)
Properties
editor (Editor) : Diagram Editor
view (View) : View
x (number)
y (number)

module:workspace/quick-edit.close

Close Event

module:workspace/quick-edit.close

getTopPosition

Get a new position at the top of a given area. The new position should be placed at the right most of given already existing nodes.

getTopPosition(area: Rect, existingNodes: Array<Node>, margin: number)
Parameters
area (Rect)
existingNodes (Array<Node>)
margin (number)

getBottomPosition

Get a new position at the bottom of a given area. The new position should be placed at the right most of given already existing nodes.

getBottomPosition(area: Rect, existingNodes: Array<Node>, margin: number)
Parameters
area (Rect)
existingNodes (Array<Node>)
margin (number)

getLeftPosition

Get a new position at the left of a given area. The new position should be placed at the bottom most of given already existing nodes.

getLeftPosition(area: Rect, existingNodes: Array<Node>, margin: number)
Parameters
area (Rect)
existingNodes (Array<Node>)
margin (number)

getRightPosition

Get a new position at the right of a given area. The new position should be placed at the bottom most of given already existing nodes.

getRightPosition(area: Rect, existingNodes: Array<Node>, margin: number)
Parameters
area (Rect)
existingNodes (Array<Node>)
margin (number)

register

register QuickEdit

register(data: Object)
Parameters
data (Object)

Resizer

Manages layout of panels surrounding the editor area, and size of the editor area (but not its contents).

Updates panel sizes when the window is resized. Maintains the max resizing limits for panels, based on currently available window size.

Events:

  • editorAreaResize -- When editor-holder's size changes for any reason (including panel show/hide panel resize, or the window resize). The 2nd arg is the new editor-holder height. The 3rd arg is a refreshHint flag for internal EditorManager use.
Resizer

$windowContent

$windowContent

$editorHolder

$editorHolder

windowResizing

windowResizing

calcEditorHeight

Calculates the available height for the full-size Editor (or the no-editor placeholder), accounting for the current size of all visible panels, toolbar, & status bar.

calcEditorHeight(): number
Returns
number:

updateResizeLimits

Updates panel resize limits to disallow making panels big enough to shrink editor area below 0

updateResizeLimits()

triggerEditorResize

Calculates a new size for editor-holder and resizes it accordingly, then and dispatches the "editorAreaResize" event. (The editors within are resized by EditorManager, in response to that event).

triggerEditorResize(refreshHint: string?)
Parameters
refreshHint (string?) One of "skip", "force", or undefined. See EditorManager docs.

handleWindowResize

Trigger editor area resize whenever the window is resized

handleWindowResize()

listenToResize

Trigger editor area resize whenever the given panel is shown/hidden/resized

listenToResize($panel: any)
Parameters
$panel (any)

Panel

Represents a panel below the editor area (a child of ".content").

new Panel($panel: !jQueryObject, minSize: number?)
Parameters
$panel (!jQueryObject) The entire panel, including any chrome, already in the DOM.
minSize (number?) Minimum height of panel in px.
Instance Members
$panel

PanelManager

PanelManager

new PanelManager()
Instance Members
createBottomPanel(id, $panel, minSize?)
_notifyLayoutChange(refreshHint)

ToastManager

ToastManager

new ToastManager()
Instance Members
info(message)
warning(message)
error(message)

dataSource

DataSource for ListView

dataSource

fs

The ExtensionManager fetches/caches the extension registry and provides information about the status of installed extensions. ExtensionManager raises the following events: statusChange - indicates that an extension has been installed/uninstalled or its status has otherwise changed. Second parameter is the id of the extension. registryUpdate - indicates that an existing extension was synchronized with new data from the registry.

fs

ENABLED

Extension status constants.

ENABLED

Type: string

LOCATION_DEFAULT

Extension location constants.

LOCATION_DEFAULT

Type: string

_idsToRemove

Requested changes to the installed extensions.

_idsToRemove

downloadRegistry

Downloads the registry of Brackets extensions and stores the information in our extension info.

downloadRegistry(): $.Promise
Returns
$.Promise: a promise that's resolved with the registry JSON data or rejected if the server can't be reached.

getCompatibilityInfoForVersion

Determines if the given versions[] entry is compatible with the given Brackets API version, and if not specifies why.

getCompatibilityInfoForVersion(extVersion: Object, apiVersion: string): {isCompatible: boolean, requiresNewer: boolean?, compatibleVersion: string?}
Parameters
extVersion (Object)
apiVersion (string)
Returns
{isCompatible: boolean, requiresNewer: boolean?, compatibleVersion: string?}:

getCompatibilityInfo

Finds the newest version of the entry that is compatible with the given Brackets API version, if any.

getCompatibilityInfo(entry: Object, apiVersion: string): {isCompatible: boolean, requiresNewer: boolean?, compatibleVersion: string?, isLatestVersion: boolean}
Parameters
entry (Object) The registry entry to check.
apiVersion (string) The Brackets API version to check against.
Returns
{isCompatible: boolean, requiresNewer: boolean?, compatibleVersion: string?, isLatestVersion: boolean}: Result contains an "isCompatible" member saying whether it's compatible. If compatible, "compatibleVersion" specifies the newest version that is compatible and "isLatestVersion" indicates if this is the absolute latest version of the extension or not. If !isCompatible or !isLatestVersion, "requiresNewer" says whether the latest version is incompatible due to requiring a newer (vs. older) version of Brackets.

getExtensionURL

Given an extension id and version number, returns the URL for downloading that extension from the repository. Does not guarantee that the extension exists at that URL.

getExtensionURL(id: string, version: string): string
Parameters
id (string) The extension's name from the metadata.
version (string) The version to download.
Returns
string: The URL to download the extension from.

remove

Removes the installed extension with the given id.

remove(id: string): $.Promise
Parameters
id (string) The id of the extension to remove.
Returns
$.Promise: A promise that's resolved when the extension is removed or rejected with an error if there's a problem with the removal.

remove

Removes the extension at the given path.

remove(path: string): $.Promise
Parameters
path (string) The absolute path to the extension to remove.
Returns
$.Promise: A promise that's resolved when the extension is removed, or rejected if there was an error.

remove

Implements the remove extension command.

remove(extensionDir: any, callback: any)
Parameters
extensionDir (any)
callback (any)

update

Updates an installed extension with the given package file.

update(id: string, packagePath: string): $.Promise
Parameters
id (string) of the extension
packagePath (string) path to the package file
Returns
$.Promise: A promise that's resolved when the extension is updated or rejected with an error if there's a problem with the update.

update

Implements the "update" command in the "extensions" domain.

Currently, this just wraps _cmdInstall, but will remove the existing directory first.

There is no need to call validate independently. Validation is the first thing that is done here.

After the extension is validated, it is installed in destinationDirectory unless the extension is already present there. If it is already present, a determination is made about whether the package being installed is an update. If it does appear to be an update, then result.installationStatus is set to NEEDS_UPDATE. If not, then it's set to ALREADY_INSTALLED.

If the installation succeeds, then result.installationStatus is set to INSTALLED.

The extension is unzipped into a directory in destinationDirectory with the name of the extension (the name is derived either from package.json or the name of the zip file).

The destinationDirectory will be created if it does not exist.

update(packagePath: any, destinationDirectory: any, options: any, callback: function, Absolute: string, the: string, additional: {disabledDirectory: !string, apiVersion: !string, nameHint: string?, systemExtensionDirectory: !string})
Parameters
packagePath (any)
destinationDirectory (any)
options (any)
callback (function) (err, result)
Absolute (string) path to the package zip file
the (string) destination directory
additional ({disabledDirectory: !string, apiVersion: !string, nameHint: string?, systemExtensionDirectory: !string}) settings to control the installation

cleanupUpdates

Deletes any temporary files left behind by extensions that were marked for update.

cleanupUpdates()

unmarkAllForRemoval

Unmarks all extensions marked for removal.

unmarkAllForRemoval()

markForRemoval

Marks an extension for later removal, or unmarks an extension previously marked.

markForRemoval(id: string, mark: boolean)
Parameters
id (string) The id of the extension to mark for removal.
mark (boolean) Whether to mark or unmark it.

isMarkedForRemoval

Returns true if an extension is marked for removal.

isMarkedForRemoval(id: string): boolean
Parameters
id (string) The id of the extension to check.
Returns
boolean: true if it's been marked for removal, false otherwise.

hasExtensionsToRemove

Returns true if there are any extensions marked for removal.

hasExtensionsToRemove(): boolean
Returns
boolean: true if there are extensions to remove

updateFromDownload

If a downloaded package appears to be an update, mark the extension for update. If an extension was previously marked for removal, marking for update will turn off the removal mark.

updateFromDownload(installationResult: Object)
Parameters
installationResult (Object) info about the install provided by the Package.download function

removeUpdate

Removes the mark for an extension to be updated on restart. Also deletes the downloaded package file.

removeUpdate(id: string)
Parameters
id (string) The id of the extension for which the update is being removed

isMarkedForUpdate

Returns true if an extension is marked for update.

isMarkedForUpdate(id: string): boolean
Parameters
id (string) The id of the extension to check.
Returns
boolean: true if it's been marked for update, false otherwise.

hasExtensionsToUpdate

Returns true if there are any extensions marked for update.

hasExtensionsToUpdate(): boolean
Returns
boolean: true if there are extensions to update

removeMarkedExtensions

Removes extensions previously marked for removal.

removeMarkedExtensions(): $.Promise
Returns
$.Promise: A promise that's resolved when all extensions are removed, or rejected if one or more extensions can't be removed. When rejected, the argument will be an array of error objects, each of which contains an "item" property with the id of the failed extension and an "error" property with the actual error.

updateExtensions

Updates extensions previously marked for update.

updateExtensions(): $.Promise
Returns
$.Promise: A promise that's resolved when all extensions are updated, or rejected if one or more extensions can't be updated. When rejected, the argument will be an array of error objects, each of which contains an "item" property with the id of the failed extension and an "error" property with the actual error.

_uniqueId

_uniqueId

validate

TODO: can this go away now that we never call it directly?

Validates the package at the given path. The actual validation is handled by the Node server.

The promise is resolved with an object: { errors: Array.<{string}>, metadata: { name:string, version:string, ... } } metadata is pulled straight from package.json and will be undefined if there are errors or null if the extension did not include package.json.

validate(path: any, options: any, Absolute: string, validation: {requirePackageJSON: boolean?}): $.Promise
Parameters
path (any)
options (any)
Absolute (string) path to the package zip file
validation ({requirePackageJSON: boolean?}) options
Returns
$.Promise: A promise that is resolved with information about the package

validate

Implements the "validate" command in the "extensions" domain. Validates the zipped package at path.

The "err" parameter of the callback is only set if there was an unexpected error. Otherwise, errors are reported in the result.

The result object has an "errors" property. It is an array of arrays of strings. Each array in the array is a set of parameters that can be passed to StringUtils.format for internationalization. The array will be empty if there are no errors.

The result will have a "metadata" property if the metadata was read successfully from package.json in the zip file.

validate(path: string, options: {requirePackageJSON: boolean?, disallowedWords: Array<string>?}, callback: function)
Parameters
path (string) Absolute path to the package zip file
options ({requirePackageJSON: boolean?, disallowedWords: Array<string>?}) for validation
callback (function) (err, result)

install

Validates and installs the package at the given path. Validation and installation is handled by the Node process.

The extension will be installed into the user's extensions directory. If the user already has the extension installed, it will instead go into their disabled extensions directory.

The promise is resolved with an object: { errors: Array.<{string}>, metadata: { name:string, version:string, ... }, disabledReason:string, installedTo:string, commonPrefix:string } metadata is pulled straight from package.json and is likely to be undefined if there are errors. It is null if there was no package.json.

disabledReason is either null or the reason the extension was installed disabled.

install(path: string, nameHint: string?, _doUpdate: boolean?): $.Promise
Parameters
path (string) Absolute path to the package zip file
nameHint (string?) Hint for the extension folder's name (used in favor of path's filename if present, and if no package metadata present).
_doUpdate (boolean?) private argument used to signal an update
Returns
$.Promise: A promise that is resolved with information about the package (which may include errors, in which case the extension was disabled), or rejected with an error object.

install

Implements the "install" command in the "extensions" domain.

There is no need to call validate independently. Validation is the first thing that is done here.

After the extension is validated, it is installed in destinationDirectory unless the extension is already present there. If it is already present, a determination is made about whether the package being installed is an update. If it does appear to be an update, then result.installationStatus is set to NEEDS_UPDATE. If not, then it's set to ALREADY_INSTALLED.

If the installation succeeds, then result.installationStatus is set to INSTALLED.

The extension is unzipped into a directory in destinationDirectory with the name of the extension (the name is derived either from package.json or the name of the zip file).

The destinationDirectory will be created if it does not exist.

install(packagePath: any, destinationDirectory: any, options: any, callback: function, _doUpdate: boolean, Absolute: string, the: string, additional: {disabledDirectory: !string, apiVersion: !string, nameHint: string?, systemExtensionDirectory: !string})
Parameters
packagePath (any)
destinationDirectory (any)
options (any)
callback (function) (err, result)
_doUpdate (boolean) private argument to signal that an update should be performed
Absolute (string) path to the package zip file
the (string) destination directory
additional ({disabledDirectory: !string, apiVersion: !string, nameHint: string?, systemExtensionDirectory: !string}) settings to control the installation

githubURLFilter

Special case handling to make the common case of downloading from GitHub easier; modifies 'urlInfo' as needed. Converts a bare GitHub repo URL to the corresponding master ZIP URL; or if given a direct master ZIP URL already, sets a nicer download filename (both cases use the repo name).

githubURLFilter(urlInfo: {url: string, parsed: Array<string>, filenameHint: string})
Parameters
urlInfo ({url: string, parsed: Array<string>, filenameHint: string})

download

Downloads from the given URL to a temporary location. On success, resolves with the path of the downloaded file (typically in a temp folder) and a hint for the real filename. On failure, rejects with an error object.

download(url: string, downloadId: number): $.Promise
Parameters
url (string) URL of the file to be downloaded
downloadId (number) Unique number to identify this request
Returns
$.Promise:

cancelDownload

Attempts to synchronously cancel the given pending download. This may not be possible, e.g. if the download has already finished.

cancelDownload(downloadId: number)
Parameters
downloadId (number) Identifier previously passed to download()

installFromURL

On success, resolves with an extension metadata object; at that point, the extension has already started running in Brackets. On failure (including validation errors), rejects with an error object.

An error object consists of either a string error code OR an array where the first entry is the error code and the remaining entries are further info. The error code string is one of either ExtensionsDomain.Errors or Package.Errors. Use formatError() to convert an error object to a friendly, localized error message.

The returned cancel() function will attempt to cancel installation, but it is not guaranteed to succeed. If cancel() succeeds, the Promise is rejected with a CANCELED error code. If we're unable to cancel, the Promise is resolved or rejected normally, as if cancel() had never been called.

installFromURL(url: any): {promise: $.Promise, cancel: function (): boolean}
Parameters
url (any)
Returns
{promise: $.Promise, cancel: function (): boolean}:

formatError

Converts an error object as returned by install() or installFromURL() into a flattened, localized string.

formatError(error: (string | Array<string>)): string
Parameters
error ((string | Array<string>))
Returns
string:

installUpdate

Install an extension update located at path. This assumes that the installation was previously attempted and an installationStatus of "ALREADY_INSTALLED", "NEEDS_UPDATE", "SAME_VERSION", or "OLDER_VERSION" was the result.

This workflow ensures that there should not generally be validation errors because the first pass at installation the extension looked at the metadata and installed packages.

installUpdate(path: string, nameHint: string?): $.Promise
Parameters
path (string) to package file
nameHint (string?) Hint for the extension folder's name (used in favor of path's filename if present, and if no package metadata present).
Returns
$.Promise: A promise that is resolved when the extension is successfully installed or rejected if there is a problem.

pendingDownloads

Maps unique download ID to info about the pending download. No entry if download no longer pending. outStream is only present if we've started receiving the body.

pendingDownloads

_removeFailedInstallation

Private function to remove the installation directory if the installation fails. This does not call any callbacks. It's assumed that the callback has already been called and this cleanup routine will do its best to complete in the background. If there's a problem here, it is simply logged with console.error.

_removeFailedInstallation(installDirectory: string)
Parameters
installDirectory (string) Directory to remove

_performInstall

Private function to unzip to the correct directory.

_performInstall(packagePath: any, installDirectory: any, validationResult: any, callback: Function, Absolute: string, Absolute: string, the: Object)
Parameters
packagePath (any)
installDirectory (any)
validationResult (any)
callback (Function) function that is called at the end of the unzipping
Absolute (string) path to the package zip file
Absolute (string) path to the destination directory for unzipping
the (Object) return value with the useful information for the client

_removeAndInstall

Private function to remove the target directory and then install.

_removeAndInstall(packagePath: any, installDirectory: any, validationResult: any, callback: Function, Absolute: string, Absolute: string, the: Object)
Parameters
packagePath (any)
installDirectory (any)
validationResult (any)
callback (Function) function that is called at the end of the unzipping
Absolute (string) path to the package zip file
Absolute (string) path to the destination directory for unzipping
the (Object) return value with the useful information for the client

legacyPackageCheck

A "legacy package" is an extension that was installed based on the GitHub name without a package.json file. Checking for the presence of these legacy extensions will help users upgrade if the extension developer puts a different name in package.json than the name of the GitHub project.

legacyPackageCheck(legacyDirectory: string)
Parameters
legacyDirectory (string) directory to check for old-style extension.

_endDownload

Wrap up after the given download has terminated (successfully or not). Closes connections, calls back the client's callback, and IF there was an error, delete any partially-downloaded file.

_endDownload(downloadId: string, error: string?)
Parameters
downloadId (string) Unique id originally passed to _cmdDownloadFile()
error (string?) If null, download was treated as successful

downloadFile

Implements "downloadFile" command, asynchronously.

downloadFile(downloadId: any, url: any, proxy: any, callback: any)
Parameters
downloadId (any)
url (any)
proxy (any)
callback (any)

abortDownload

Implements "abortDownload" command, synchronously.

abortDownload(downloadId: any)
Parameters
downloadId (any)

validateName

Returns true if the name presented is acceptable as a package name. This enforces the requirement as presented in the CommonJS spec: http://wiki.commonjs.org/wiki/Packages/1.0 which states:

"This must be a unique, lowercase alpha-numeric name without spaces. It may include "." or "_" or "-" characters."

We add the additional requirement that the first character must be a letter or number (there's a security implication to allowing a name like "..", because the name is used in directory names).

validateName(name: string): boolean
Parameters
name (string) to test
Returns
boolean: true if the name is valid

parsePersonString

Normalizes person fields from package.json.

These fields can be an object with name, email and url properties or a string of the form "name ". This does a tolerant parsing of the data to try to return an object with name and optional email and url. If the string does not match the format, the string is returned as the name on the resulting object.

If an object other than a string is passed in, it's returned as is.

parsePersonString(obj: any, null: any): Object
Parameters
obj (any)
null (any) <String|Object> obj to normalize
Returns
Object: person object with name and optional email and url

containsWords

Determines if any of the words in wordlist appear in str.

containsWords(wordlist: Array<String>, str: String): Array<String>
Parameters
wordlist (Array<String>) list of words to check
str (String) to check for words
Returns
Array<String>: words that matched

findCommonPrefix

Finds the common prefix, if any, for the files in a package file.

In some package files, all of the files are contained in a subdirectory, and this function will identify that directory if it exists.

findCommonPrefix(extractDir: string, callback: function (Error, string))
Parameters
extractDir (string) directory into which the package was extracted
callback (function (Error, string)) function to accept err, commonPrefix (which will be "" if there is none)

validatePackageJSON

Validates the contents of package.json.

validatePackageJSON(path: string, packageJSON: string, options: Object, callback: any)
Parameters
path (string) path to package file (used in error reporting)
packageJSON (string) path to the package.json file to check
options (Object) validation options passed to validate()
callback (any)

extractAndValidateFiles

Extracts the package into the given directory and then validates it.

extractAndValidateFiles(zipPath: string, extractDir: string, options: Object, callback: function (Error, {errors: Array, metadata: Object, commonPrefix: string, extractDir: string}))
Parameters
zipPath (string) path to package zip file
extractDir (string) directory to extract package into
options (Object) validation options
callback (function (Error, {errors: Array, metadata: Object, commonPrefix: string, extractDir: string})) function to call with the result

doInParallel

Utilities for working with Promise, and other asynchronous processes.

Further ideas for Async utilities...

  • Utilities for blocking UI until a Promise completes?
  • A "SuperDeferred" could feature some very useful enhancements:

    • API for cancellation (non guaranteed, best attempt)
    • Easier way to add a timeout clause (withTimeout() wrapper below is more verbose)
    • Encapsulate the task kickoff code so you can start it later, e.g. superDeferred.start()
  • Deferred/Promise are unable to do anything akin to a 'finally' block. It'd be nice if we could harvest exceptions across all steps of an async process and pipe them to a handler, so that we don't leave UI-blocking overlays up forever, etc. But this is hard: we'd have wrap every async callback (including low-level native ones that don't use [Super]Deferred) to catch exceptions, and then understand which Deferred(s) the code would have resolved/ rejected had it run to completion.
doInParallel(items: any, beginProcessItem: any, failFast: any)
Parameters
items (any)
beginProcessItem (any)
failFast (any)

doInParallel

Executes a series of tasks in parallel, returning a "master" Promise that is resolved once all the tasks have resolved. If one or more tasks fail, behavior depends on the failFast flag:

  • If true, the master Promise is rejected as soon as the first task fails. The remaining tasks continue to completion in the background.
  • If false, the master Promise is rejected after all tasks have completed.

If nothing fails: (M = master promise; 1-4 = tasks; d = done; F = fail) M ------------d 1 >---d . 2 >------d . 3 >---------d . 4 >------------d

With failFast = false: M ------------F 1 >---d . . 2 >------d . . 3 >---------F . 4 >------------d

With failFast = true: -- equivalent to $.when() M ---------F 1 >---d . 2 >------d . 3 >---------F 4 >------------d (#4 continues even though master Promise has failed) (Note: if tasks finish synchronously, the behavior is more like failFast=false because you won't get a chance to respond to the master Promise until after all items have been processed)

To perform task-specific work after an individual task completes, attach handlers to each Promise before beginProcessItem() returns it.

Note: don't use this if individual tasks (or their done/fail handlers) could ever show a user- visible dialog: because they run in parallel, you could show multiple dialogs atop each other.

doInParallel(items: !Array<any>, beginProcessItem: !function (any, number): Promise, failFast: !boolean): Promise
Parameters
items (!Array<any>)
beginProcessItem (!function (any, number): Promise)
failFast (!boolean)
Returns
Promise:

doSequentially

Executes a series of tasks in serial (task N does not begin until task N-1 has completed). Returns a "master" Promise that is resolved once all the tasks have resolved. If one or more tasks fail, behavior depends on the failAndStopFast flag:

  • If true, the master Promise is rejected as soon as the first task fails. The remaining tasks are never started (the serial sequence is stopped).
  • If false, the master Promise is rejected after all tasks have completed.

If nothing fails: M ------------d 1 >---d . 2 >--d . 3 >--d . 4 >--d

With failAndStopFast = false: M ------------F 1 >---d . . 2 >--d . . 3 >--F . 4 >--d

With failAndStopFast = true: M ---------F 1 >---d . 2 >--d . 3 >--F 4 (#4 never runs)

To perform task-specific work after an individual task completes, attach handlers to each Promise before beginProcessItem() returns it.

doSequentially(items: !Array<any>, beginProcessItem: !function (any, number): Promise, failAndStopFast: !boolean): $.Promise
Parameters
items (!Array<any>)
beginProcessItem (!function (any, number): Promise)
failAndStopFast (!boolean)
Returns
$.Promise:

doInParallelAggregateErrors

Executes a series of tasks in parallel, saving up error info from any that fail along the way. Returns a Promise that is only resolved/rejected once all tasks are complete. This is essentially a wrapper around doInParallel(..., false).

If one or more tasks failed, the entire "master" promise is rejected at the end - with one argument: an array objects, one per failed task. Each error object contains:

  • item -- the entry in items whose task failed
  • error -- the first argument passed to the fail() handler when the task failed
doInParallelAggregateErrors(items: !Array<any>, beginProcessItem: !function (any, number): Promise): $.Promise
Parameters
items (!Array<any>)
beginProcessItem (!function (any, number): Promise)
Returns
$.Promise:

ERROR_TIMEOUT

Value passed to fail() handlers that have been triggered due to withTimeout()'s timeout

ERROR_TIMEOUT

withTimeout

Adds timeout-driven failure to a Promise: returns a new Promise that is resolved/rejected when the given original Promise is resolved/rejected, OR is rejected after the given delay - whichever happens first.

If the original Promise is resolved/rejected first, done()/fail() handlers receive arguments piped from the original Promise. If the timeout occurs first instead, fail() is called with the token Async.ERROR_TIMEOUT.

withTimeout(promise: $.Promise, timeout: number): $.Promise
Parameters
promise ($.Promise)
timeout (number)
Returns
$.Promise:

format

Format a string by replacing placeholder symbols with passed in arguments.

Example: var formatted = StringUtils.format("Hello {0}", "World");

format(str: string): string
Parameters
str (string) The base string
Returns
string: Formatted string

getLines

Splits the text by new line characters and returns an array of lines

getLines(text: string): Array<string>
Parameters
text (string)
Returns
Array<string>: lines

offsetToLineNum

Returns a line number corresponding to an offset in some text. The text can be specified as a single string or as an array of strings that correspond to the lines of the string.

Specify the text in lines when repeatedly calling the function on the same text in a loop. Use getLines() to divide the text into lines, then repeatedly call this function to compute a line number from the offset.

offsetToLineNum(textOrLines: (string | Array<string>), offset: number): number
Parameters
textOrLines ((string | Array<string>)) string or array of lines from which to compute the line number from the offset
offset (number)
Returns
number: line number

endsWith

Returns true if the given string ends with the given suffix.

endsWith(str: string, suffix: string)
Parameters
str (string)
suffix (string)

_keydownHook

Handles the keyDown event for the dialogs

_keydownHook(e: $.Event, autoDismiss: boolean): boolean
Parameters
e ($.Event)
autoDismiss (boolean)
Returns
boolean:

DialogManager

DialogManager

new DialogManager()
Instance Members
showModalDialogUsingTemplate(template, autoDismiss, beforeClosing)
showModalDialog(dlgClass, title, message, buttons, autoDismiss)
cancelModalDialogIfOpen(dlgClass, buttonId?)
showInputDialog(message, initialValue)
showTextDialog(message, text)
showSelectRadioDialog(message, options, items)
showSelectDropdownDialog(message, options, items)
showColorDialog(color)
showFontDialog(font)
showSimpleDialog(message)
showConfirmDialog(message)
showAlertDialog(message)
showInfoDialog(message)
showOpenDialog(title, defaultPath, filters)
showSaveDialog(title, defaultPath, filters)
showSaveConfirmDialog(filename)
showErrorDialog(message)

ElementPickerDialog

Element Picker Dialog

new ElementPickerDialog()
Instance Members
expand(elem, expandAllParents)
select(elem, scrollTo)
showDialog(title, selected, type)

ElementListPickerDialog

Element List Picker Dialog

new ElementListPickerDialog()
Instance Members
showDialog(title, elems)

ElementListEditorDialog

Element List Editor Dialog

new ElementListEditorDialog()
Instance Members
showDialog(elem, field)

showDialog

Show About Dialog

showDialog(): Dialog
Returns
Dialog:

showDialog

Show Preference Dialog

showDialog(preferenceId: string): Dialog
Parameters
preferenceId (string)
Returns
Dialog:

showDialog

Show License Manager Dialog

showDialog(): Dialog
Returns
Dialog:

showDialog

Show Print Dialog

showDialog(): Dialog
Returns
Dialog:

InstallExtensionDialog

new InstallExtensionDialog(installer: {install: function (url), cancel: function ()}, _isUpdate: any)
Parameters
installer ({install: function (url), cancel: function ()}) The installer backend to use.
_isUpdate (any)
Instance Members
$dlg
$url
$okButton
$cancelButton
$inputArea
$msgArea
$msg
_dialogDeferred
_installer
_state
show(urlToInstall?)

InstallerFacade

Mediates between this module and the Package extension-installation utils. Mockable for unit-testing.

new InstallerFacade()

ExtensionManagerView

new ExtensionManagerView()
Instance Members
initialize(model)
$el
model
_$emptyMessage
filter(query)

lastVersionDate

Gets the last version from the given object and returns the short form of its date. Assumes "this" is the current template context.

lastVersionDate(): string
Returns
string: The formatted date.

formatUserId

Returns a more friendly display form of the owner's internal user id. Assumes "this" is the current template context.

formatUserId(): string
Returns
string: A display version in the form "id (service)".

Given a registry item, returns a URL that represents its owner's page on the auth service. Currently only handles GitHub. Assumes "this" is the current template context.

ownerLink(): string
Returns
string: A link to that user's page on the service.

authorInfo

Given a registry item, formats the author information, including a link to the owner's github page (if available) and the author's name from the metadata.

authorInfo()

sortRegistry

Returns an array of current registry entries, sorted by the publish date of the latest version of each entry.

sortRegistry(registry: object, subkey: string): Array
Parameters
registry (object) The unsorted registry.
subkey (string) The subkey to look for the registry metadata in. If unspecified, assumes we should look at the top level of the object.
Returns
Array: Sorted array of registry entries.

ExtensionManagerViewModel

new ExtensionManagerViewModel()
Instance Members
SOURCE_REGISTRY
SOURCE_INSTALLED
extensions
source
filterSet
sortedFullSet
infoMessage
message
notifyCount
dispose()
initialize()

RegistryViewModel

new RegistryViewModel()
Instance Members
source
_initializeFromSource()

InstalledViewModel

new InstalledViewModel()
Instance Members
source
_initializeFromSource()

path

ExtensionLoader searches the filesystem for extensions, then creates a new context for each one and loads it. This module dispatches the following events: "load" - when an extension is successfully loaded. The second argument is the file path to the extension root. "loadFailed" - when an extension load is unsuccessful. The second argument is the file path to the extension root.

path

getUserExtensionPath

Returns the full path of the default user extensions directory. This is in the users application support directory, which is typically /Users//Application Support/StarUML/extensions/user on the mac, and C:\Users\\AppData\Roaming\StarUML\extensions\user on windows.

getUserExtensionPath()

loadExtension

Loads the extension that lives at baseUrl

loadExtension(name: !string, config: !{baseUrl: string}, entryPoint: !string, extensionFeatures: Array<string>)
Parameters
name (!string) , used to identify the extension
config (!{baseUrl: string}) object with baseUrl property containing absolute path of extension
entryPoint (!string) , name of the main js file to load
extensionFeatures (Array<string>) Extension features to be loaded.

loadAllExtensionsInNativeDirectory

Loads the extension that lives at baseUrl into its own Require.js context

loadAllExtensionsInNativeDirectory(directory: !string, extensionFeatures: Array<string>)
Parameters
directory (!string) , an absolute native path that contains a directory of extensions. each subdirectory is interpreted as an independent extension
extensionFeatures (Array<string>) Extension features to be loaded.

init

Load extensions.

init(paths: any, extensionFeatures: Array<string>?, A: Array<string>?)
Parameters
paths (any)
extensionFeatures (Array<string>?) Extension features to be loaded.
A (Array<string>?) list containing references to extension source location. A source location may be either (a) a folder name inside src/extensions or (b) an absolute path.

UrlParams

Convert between URL querystring and name/value pairs. Decodes and encodes URL parameters.

new UrlParams()
Instance Members
parse(url)
put(name, value)
get(name)
remove(name)
isEmpty(name)
toString()

addEmbeddedStyleSheet

Appends a