//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//  THIS FILE IS GENERATED BY EASY BINDINGS, DO NOT MODIFY IT
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

import Cocoa

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Derived selection controller AutoLayoutPackageDocument mPackageDimensionSelectionController
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class SelectionController_AutoLayoutPackageDocument_mPackageDimensionSelectionController : EBSwiftBaseObject {

  //····················································································································
  //   Selection observable property: y1
  //····················································································································

  let y1_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: x2
  //····················································································································

  let x2_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: y2
  //····················································································································

  let y2_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: xDimension
  //····················································································································

  let xDimension_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: yDimension
  //····················································································································

  let yDimension_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: x1Unit
  //····················································································································

  let x1Unit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: y1Unit
  //····················································································································

  let y1Unit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: x2Unit
  //····················································································································

  let x2Unit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: y2Unit
  //····················································································································

  let y2Unit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: xDimensionUnit
  //····················································································································

  let xDimensionUnit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: yDimensionUnit
  //····················································································································

  let yDimensionUnit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: distanceUnit
  //····················································································································

  let distanceUnit_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: drawDimensionBackground
  //····················································································································

  let drawDimensionBackground_property = EBPropertyProxy_Bool ()
  //····················································································································
  //   Selection observable property: x1
  //····················································································································

  let x1_property = EBPropertyProxy_Int ()
  //····················································································································
  //   Selection observable property: distanceInCanariUnit
  //····················································································································

  let distanceInCanariUnit_property = EBTransientProperty_Int ()

  //····················································································································
  //   Selection observable property: objectDisplay
  //····················································································································

  let objectDisplay_property = EBTransientProperty_EBShape ()

  //····················································································································
  //   Selection observable property: selectionDisplay
  //····················································································································

  let selectionDisplay_property = EBTransientProperty_EBShape ()

  //····················································································································
  //   Selection observable property: issues
  //····················································································································

  let issues_property = EBTransientProperty_CanariIssueArray ()

  //····················································································································
  //   Selected array (not observable)
  //····················································································································

  var selectedArray : EBReferenceArray <PackageDimension> { return self.selectedArray_property.propval }

  //····················································································································
  //   BIND SELECTION
  //····················································································································

   let selectedArray_property = TransientArrayOfSuperOf_PackageDimension <PackageObject> ()

  //····················································································································

  final func bind_selection (model : ReadOnlyArrayOf_PackageObject) {
    self.selectedArray_property.setDataProvider (model)
    self.bind_property_y1 ()
    self.bind_property_x2 ()
    self.bind_property_y2 ()
    self.bind_property_xDimension ()
    self.bind_property_yDimension ()
    self.bind_property_x1Unit ()
    self.bind_property_y1Unit ()
    self.bind_property_x2Unit ()
    self.bind_property_y2Unit ()
    self.bind_property_xDimensionUnit ()
    self.bind_property_yDimensionUnit ()
    self.bind_property_distanceUnit ()
    self.bind_property_drawDimensionBackground ()
    self.bind_property_x1 ()
    self.bind_property_distanceInCanariUnit ()
    self.bind_property_objectDisplay ()
    self.bind_property_selectionDisplay ()
    self.bind_property_issues ()
  }

  //····················································································································
  //   UNBIND SELECTION
  //····················································································································

  final func unbind_selection () {
    self.selectedArray_property.setDataProvider (nil)
  //--- y1
    self.y1_property.mReadModelFunction = nil 
    self.y1_property.mWriteModelFunction = nil 
    self.y1_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_y1 (self.y1_property)
  //--- x2
    self.x2_property.mReadModelFunction = nil 
    self.x2_property.mWriteModelFunction = nil 
    self.x2_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_x2 (self.x2_property)
  //--- y2
    self.y2_property.mReadModelFunction = nil 
    self.y2_property.mWriteModelFunction = nil 
    self.y2_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_y2 (self.y2_property)
  //--- xDimension
    self.xDimension_property.mReadModelFunction = nil 
    self.xDimension_property.mWriteModelFunction = nil 
    self.xDimension_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_xDimension (self.xDimension_property)
  //--- yDimension
    self.yDimension_property.mReadModelFunction = nil 
    self.yDimension_property.mWriteModelFunction = nil 
    self.yDimension_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_yDimension (self.yDimension_property)
  //--- x1Unit
    self.x1Unit_property.mReadModelFunction = nil 
    self.x1Unit_property.mWriteModelFunction = nil 
    self.x1Unit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_x1Unit (self.x1Unit_property)
  //--- y1Unit
    self.y1Unit_property.mReadModelFunction = nil 
    self.y1Unit_property.mWriteModelFunction = nil 
    self.y1Unit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_y1Unit (self.y1Unit_property)
  //--- x2Unit
    self.x2Unit_property.mReadModelFunction = nil 
    self.x2Unit_property.mWriteModelFunction = nil 
    self.x2Unit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_x2Unit (self.x2Unit_property)
  //--- y2Unit
    self.y2Unit_property.mReadModelFunction = nil 
    self.y2Unit_property.mWriteModelFunction = nil 
    self.y2Unit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_y2Unit (self.y2Unit_property)
  //--- xDimensionUnit
    self.xDimensionUnit_property.mReadModelFunction = nil 
    self.xDimensionUnit_property.mWriteModelFunction = nil 
    self.xDimensionUnit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_xDimensionUnit (self.xDimensionUnit_property)
  //--- yDimensionUnit
    self.yDimensionUnit_property.mReadModelFunction = nil 
    self.yDimensionUnit_property.mWriteModelFunction = nil 
    self.yDimensionUnit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_yDimensionUnit (self.yDimensionUnit_property)
  //--- distanceUnit
    self.distanceUnit_property.mReadModelFunction = nil 
    self.distanceUnit_property.mWriteModelFunction = nil 
    self.distanceUnit_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_distanceUnit (self.distanceUnit_property)
  //--- drawDimensionBackground
    self.drawDimensionBackground_property.mReadModelFunction = nil 
    self.drawDimensionBackground_property.mWriteModelFunction = nil 
    self.drawDimensionBackground_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_drawDimensionBackground (self.drawDimensionBackground_property)
  //--- x1
    self.x1_property.mReadModelFunction = nil 
    self.x1_property.mWriteModelFunction = nil 
    self.x1_property.mValidateAndWriteModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_x1 (self.x1_property)
  //--- distanceInCanariUnit
    self.distanceInCanariUnit_property.mReadModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_distanceInCanariUnit (self.distanceInCanariUnit_property)
  //--- objectDisplay
    self.objectDisplay_property.mReadModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_objectDisplay (self.objectDisplay_property)
  //--- selectionDisplay
    self.selectionDisplay_property.mReadModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_selectionDisplay (self.selectionDisplay_property)
  //--- issues
    self.issues_property.mReadModelFunction = nil 
    self.selectedArray_property.removeEBObserverOf_issues (self.issues_property)
  }

  //····················································································································
  //    Explorer
  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    private var mValueExplorer : NSButton?
    private var mExplorerWindow : NSWindow?
  #endif

  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    final func addExplorer (name : String, y : inout CGFloat, view : NSView) {
      let font = NSFont.boldSystemFont (ofSize: NSFont.smallSystemFontSize)
      let tf = NSTextField (frame:secondColumn (y))
      tf.isEnabled = true
      tf.isEditable = false
      tf.stringValue = name
      tf.font = font
      view.addSubview (tf)
      let valueExplorer = NSButton (frame: thirdColumn (y))
      valueExplorer.font = font
      valueExplorer.title = self.explorerIndexString + " " + String (describing: type (of: self))
      valueExplorer.target = self
      valueExplorer.action = #selector(SelectionController_AutoLayoutPackageDocument_mPackageDimensionSelectionController.showObjectWindowFromExplorerButton(_:))
      view.addSubview (valueExplorer)
      self.mValueExplorer = valueExplorer
      y += EXPLORER_ROW_HEIGHT
    }
  #endif

  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    func buildExplorerWindow () {
    //-------------------------------------------------- Create Window
      let r = NSRect (x: 20.0, y: 20.0, width: 10.0, height: 10.0)
      self.mExplorerWindow = NSWindow (contentRect: r, styleMask: [.titled, .closable], backing: .buffered, defer: true, screen: nil)
    //-------------------------------------------------- Adding properties
      let view = NSView (frame: r)
      var y : CGFloat = 0.0
      createEntryForPropertyNamed (
        "y1",
        object: self.y1_property,
        y: &y,
        view: view,
        observerExplorer: &self.y1_property.mObserverExplorer,
        valueExplorer: &self.y1_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "x2",
        object: self.x2_property,
        y: &y,
        view: view,
        observerExplorer: &self.x2_property.mObserverExplorer,
        valueExplorer: &self.x2_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "y2",
        object: self.y2_property,
        y: &y,
        view: view,
        observerExplorer: &self.y2_property.mObserverExplorer,
        valueExplorer: &self.y2_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "xDimension",
        object: self.xDimension_property,
        y: &y,
        view: view,
        observerExplorer: &self.xDimension_property.mObserverExplorer,
        valueExplorer: &self.xDimension_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "yDimension",
        object: self.yDimension_property,
        y: &y,
        view: view,
        observerExplorer: &self.yDimension_property.mObserverExplorer,
        valueExplorer: &self.yDimension_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "x1Unit",
        object: self.x1Unit_property,
        y: &y,
        view: view,
        observerExplorer: &self.x1Unit_property.mObserverExplorer,
        valueExplorer: &self.x1Unit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "y1Unit",
        object: self.y1Unit_property,
        y: &y,
        view: view,
        observerExplorer: &self.y1Unit_property.mObserverExplorer,
        valueExplorer: &self.y1Unit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "x2Unit",
        object: self.x2Unit_property,
        y: &y,
        view: view,
        observerExplorer: &self.x2Unit_property.mObserverExplorer,
        valueExplorer: &self.x2Unit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "y2Unit",
        object: self.y2Unit_property,
        y: &y,
        view: view,
        observerExplorer: &self.y2Unit_property.mObserverExplorer,
        valueExplorer: &self.y2Unit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "xDimensionUnit",
        object: self.xDimensionUnit_property,
        y: &y,
        view: view,
        observerExplorer: &self.xDimensionUnit_property.mObserverExplorer,
        valueExplorer: &self.xDimensionUnit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "yDimensionUnit",
        object: self.yDimensionUnit_property,
        y: &y,
        view: view,
        observerExplorer: &self.yDimensionUnit_property.mObserverExplorer,
        valueExplorer: &self.yDimensionUnit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "distanceUnit",
        object: self.distanceUnit_property,
        y: &y,
        view: view,
        observerExplorer: &self.distanceUnit_property.mObserverExplorer,
        valueExplorer: &self.distanceUnit_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "drawDimensionBackground",
        object: self.drawDimensionBackground_property,
        y: &y,
        view: view,
        observerExplorer: &self.drawDimensionBackground_property.mObserverExplorer,
        valueExplorer: &self.drawDimensionBackground_property.mValueExplorer
      )
      createEntryForPropertyNamed (
        "x1",
        object: self.x1_property,
        y: &y,
        view: view,
        observerExplorer: &self.x1_property.mObserverExplorer,
        valueExplorer: &self.x1_property.mValueExplorer
      )
    //-------------------------------------------------- Finish Window construction
    //--- Resize View
      let viewFrame = NSRect (x: 0.0, y: 0.0, width: EXPLORER_ROW_WIDTH, height: y)
      view.frame = viewFrame
    //--- Set content size
      self.mExplorerWindow?.setContentSize (NSSize (width: EXPLORER_ROW_WIDTH + 16.0, height: fmin (600.0, y)))
    //--- Set close button as 'remove window' button
      let closeButton : NSButton? = self.mExplorerWindow?.standardWindowButton (.closeButton)
      closeButton?.target = self
      closeButton?.action = #selector(SelectionController_AutoLayoutPackageDocument_mPackageDimensionSelectionController.deleteSelectionControllerWindowAction(_:))
    //--- Set window title
      let windowTitle = self.explorerIndexString + " " + String (describing: type (of: self))
      self.mExplorerWindow!.title = windowTitle
    //--- Add Scroll view
      let frame = NSRect (x: 0.0, y: 0.0, width: EXPLORER_ROW_WIDTH, height: y)
      let sw = NSScrollView (frame: frame)
      sw.hasVerticalScroller = true
      sw.documentView = view
      self.mExplorerWindow!.contentView = sw
    }
  #endif
  
  //····················································································································
  //   showObjectWindowFromExplorerButton
  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    @objc func showObjectWindowFromExplorerButton (_ : Any) {
      if self.mExplorerWindow == nil {
        self.buildExplorerWindow ()
      }
      self.mExplorerWindow?.makeKeyAndOrderFront (nil)
    }
  #endif
  
  //····················································································································
  //   deleteSelectionControllerWindowAction
  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    @objc func deleteSelectionControllerWindowAction (_ : Any) {
      self.clearObjectExplorer ()
    }
  #endif

  //····················································································································
  //   clearObjectExplorer
  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    func clearObjectExplorer () {
      if let closeButton = self.mExplorerWindow?.standardWindowButton (.closeButton) {
        closeButton.target = nil
      }
      self.mExplorerWindow?.orderOut (nil)
      self.mExplorerWindow = nil
    }
  #endif

  //····················································································································

  private final func bind_property_y1 () {
    self.selectedArray_property.addEBObserverOf_y1 (self.y1_property)
    self.y1_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.y1_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.y1_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.y1_property.setProp (inValue)
          }
        }
      }
    }
    self.y1_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.y1_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_x2 () {
    self.selectedArray_property.addEBObserverOf_x2 (self.x2_property)
    self.x2_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.x2_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.x2_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.x2_property.setProp (inValue)
          }
        }
      }
    }
    self.x2_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.x2_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_y2 () {
    self.selectedArray_property.addEBObserverOf_y2 (self.y2_property)
    self.y2_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.y2_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.y2_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.y2_property.setProp (inValue)
          }
        }
      }
    }
    self.y2_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.y2_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_xDimension () {
    self.selectedArray_property.addEBObserverOf_xDimension (self.xDimension_property)
    self.xDimension_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.xDimension_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.xDimension_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.xDimension_property.setProp (inValue)
          }
        }
      }
    }
    self.xDimension_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.xDimension_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_yDimension () {
    self.selectedArray_property.addEBObserverOf_yDimension (self.yDimension_property)
    self.yDimension_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.yDimension_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.yDimension_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.yDimension_property.setProp (inValue)
          }
        }
      }
    }
    self.yDimension_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.yDimension_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_x1Unit () {
    self.selectedArray_property.addEBObserverOf_x1Unit (self.x1Unit_property)
    self.x1Unit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.x1Unit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.x1Unit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.x1Unit_property.setProp (inValue)
          }
        }
      }
    }
    self.x1Unit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.x1Unit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_y1Unit () {
    self.selectedArray_property.addEBObserverOf_y1Unit (self.y1Unit_property)
    self.y1Unit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.y1Unit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.y1Unit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.y1Unit_property.setProp (inValue)
          }
        }
      }
    }
    self.y1Unit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.y1Unit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_x2Unit () {
    self.selectedArray_property.addEBObserverOf_x2Unit (self.x2Unit_property)
    self.x2Unit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.x2Unit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.x2Unit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.x2Unit_property.setProp (inValue)
          }
        }
      }
    }
    self.x2Unit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.x2Unit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_y2Unit () {
    self.selectedArray_property.addEBObserverOf_y2Unit (self.y2Unit_property)
    self.y2Unit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.y2Unit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.y2Unit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.y2Unit_property.setProp (inValue)
          }
        }
      }
    }
    self.y2Unit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.y2Unit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_xDimensionUnit () {
    self.selectedArray_property.addEBObserverOf_xDimensionUnit (self.xDimensionUnit_property)
    self.xDimensionUnit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.xDimensionUnit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.xDimensionUnit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.xDimensionUnit_property.setProp (inValue)
          }
        }
      }
    }
    self.xDimensionUnit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.xDimensionUnit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_yDimensionUnit () {
    self.selectedArray_property.addEBObserverOf_yDimensionUnit (self.yDimensionUnit_property)
    self.yDimensionUnit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.yDimensionUnit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.yDimensionUnit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.yDimensionUnit_property.setProp (inValue)
          }
        }
      }
    }
    self.yDimensionUnit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.yDimensionUnit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_distanceUnit () {
    self.selectedArray_property.addEBObserverOf_distanceUnit (self.distanceUnit_property)
    self.distanceUnit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.distanceUnit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.distanceUnit_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.distanceUnit_property.setProp (inValue)
          }
        }
      }
    }
    self.distanceUnit_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.distanceUnit_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_drawDimensionBackground () {
    self.selectedArray_property.addEBObserverOf_drawDimensionBackground (self.drawDimensionBackground_property)
    self.drawDimensionBackground_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Bool> ()
          var isMultipleSelection = false
          for object in v {
            switch object.drawDimensionBackground_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.drawDimensionBackground_property.mWriteModelFunction = { [weak self] (inValue : Bool) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.drawDimensionBackground_property.setProp (inValue)
          }
        }
      }
    }
    self.drawDimensionBackground_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Bool, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.drawDimensionBackground_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_x1 () {
    self.selectedArray_property.addEBObserverOf_x1 (self.x1_property)
    self.x1_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.x1_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
    self.x1_property.mWriteModelFunction = { [weak self] (inValue : Int) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          break
        case .single (let v) :
          for object in v {
            object.x1_property.setProp (inValue)
          }
        }
      }
    }
    self.x1_property.mValidateAndWriteModelFunction = { [weak self] (candidateValue : Int, windowForSheet : NSWindow?) in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty, .multiple :
          return false
        case .single (let v) :
          for object in v {
            let result = object.x1_property.validateAndSetProp (candidateValue, windowForSheet:windowForSheet)
            if !result {
              return false
            }
          }
          return true
        }
      }else{
        return false
      }
    }
  }
  //····················································································································

  private final func bind_property_distanceInCanariUnit () {
    self.selectedArray_property.addEBObserverOf_distanceInCanariUnit (self.distanceInCanariUnit_property)
    self.distanceInCanariUnit_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <Int> ()
          var isMultipleSelection = false
          for object in v {
            switch object.distanceInCanariUnit_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
  }
  //····················································································································

  private final func bind_property_objectDisplay () {
    self.selectedArray_property.addEBObserverOf_objectDisplay (self.objectDisplay_property)
    self.objectDisplay_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <EBShape> ()
          var isMultipleSelection = false
          for object in v {
            switch object.objectDisplay_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
  }
  //····················································································································

  private final func bind_property_selectionDisplay () {
    self.selectedArray_property.addEBObserverOf_selectionDisplay (self.selectionDisplay_property)
    self.selectionDisplay_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <EBShape> ()
          var isMultipleSelection = false
          for object in v {
            switch object.selectionDisplay_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
  }
  //····················································································································

  private final func bind_property_issues () {
    self.selectedArray_property.addEBObserverOf_issues (self.issues_property)
    self.issues_property.mReadModelFunction = { [weak self] in
      if let model = self?.selectedArray_property {
        switch model.selection {
        case .empty :
          return .empty
        case .multiple :
          return .multiple
        case .single (let v) :
          var s = Set <CanariIssueArray> ()
          var isMultipleSelection = false
          for object in v {
            switch object.issues_property.selection {
            case .empty :
              return .empty
            case .multiple :
              isMultipleSelection = true
            case .single (let vProp) :
              s.insert (vProp)
            }
          }
          if isMultipleSelection {
            return .multiple
          }else if s.count == 0 {
            return .empty
          }else if s.count == 1 {
            return .single (s.first!)
          }else{
            return .multiple
          }
        }
      }else{
        return .empty
      }
    }
  }


  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

