         return no  unless restrictions
         return no  if source.joint in restrictions
       [source, target] = [target, source]
+
     return yes
+
+  connect:(source, target)->
+    return if not allowedToConnect source, target
+    log "Connecting #{source.dia.id} to #{target.dia.id}"
+    @emit "ConnectionCreated", source, target
+    @connections.push {source, target}
+    @highlightLines target.dia
 
   updateScene:->
 

            joint = conn.dia.joints[conn.joint]
            if joint not in @activeJoints
              joint.showDeleteButton()
              joint.on 'DeleteRequested', @bound 'disconnectHelper'
              @activeJoints.push joint

  handleLineRequest:(joint)->
    @_trackJoint = joint

  # Needs refactoring ~ GG
  disconnectHelper:(dia, joint)->
    return  if @activeDias.length isnt 1

    isEqual = (connection)=>
      (dia is connection.dia) and (joint is connection.joint)

    activeDia = @activeDias.first
    connectionsToDelete = []
    for conn in @connections
      if ((isEqual conn.source) or (isEqual conn.target)) and \
         ((conn.source.dia is activeDia) or (conn.target.dia is activeDia))
        connectionsToDelete.push conn

    @connections = (c for c in @connections when c not in connectionsToDelete)
    @highlightLines @activeDias

  disconnect:(dia)->

    newConnections = []
    for connection in @connections


    return  unless targetId

    source = @getDia sourceId
    target = @getDia targetId
    target.joint = @guessJoint target, source  unless target.joint
