public <T extends Object, U extends Object> XDiagram createDiagram(
     final T diagramObject,
     final DiagramMapping<T> diagramMapping,
     final boolean isOnDemand,
     final InterpreterContext context) {
   XDiagram _xblockexpression = null;
   {
     boolean _isApplicable = diagramMapping.isApplicable(diagramObject);
     boolean _not = (!_isApplicable);
     if (_not) {
       return null;
     }
     final IMappedElementDescriptor<T> descriptor =
         this.<T>getDescriptor(diagramObject, diagramMapping);
     boolean _equals = Objects.equal(descriptor, null);
     if (_equals) {
       return null;
     }
     XDiagram _diagram = context.getDiagram();
     DomainObjectDescriptor _domainObjectDescriptor = _diagram.getDomainObjectDescriptor();
     final boolean replaceDiagram = (!Objects.equal(_domainObjectDescriptor, descriptor));
     context.setIsReplaceRootDiagram(replaceDiagram);
     XDiagram _xifexpression = null;
     if (replaceDiagram) {
       _xifexpression = diagramMapping.createDiagram(descriptor);
     } else {
       _xifexpression = context.getDiagram();
     }
     final XDiagram diagram = _xifexpression;
     InterpreterContext _xifexpression_1 = null;
     if (replaceDiagram) {
       _xifexpression_1 = new InterpreterContext(diagram, context);
     } else {
       _xifexpression_1 = context;
     }
     final InterpreterContext newContext = _xifexpression_1;
     if (isOnDemand) {
       diagram.setLayoutOnActivate(true);
       final Procedure1<XDiagram> _function =
           (XDiagram it) -> {
             final Function1<T, Object> _function_1 =
                 (T domainObject) -> {
                   Object _xblockexpression_1 = null;
                   {
                     this.<T>populateDiagram(diagramMapping, domainObject, newContext);
                     newContext.directlyApplyChanges();
                     XRoot _root = CoreExtensions.getRoot(diagram);
                     final CommandStack commandStack = _root.getCommandStack();
                     newContext.executeCommands(commandStack);
                     _xblockexpression_1 = null;
                   }
                   return _xblockexpression_1;
                 };
             descriptor.<Object>withDomainObject(_function_1);
           };
       diagram.setContentsInitializer(_function);
     } else {
       this.<T>populateDiagram(diagramMapping, diagramObject, newContext);
     }
     _xblockexpression = diagram;
   }
   return _xblockexpression;
 }
  public FXDiagramTab(final FXDiagramView view, final CTabFolder tabFolder, final XRoot root) {
    FXCanvas _fXCanvas = new FXCanvas(tabFolder, SWT.NONE);
    this.canvas = _fXCanvas;
    CTabItem _cTabItem = new CTabItem(tabFolder, SWT.CLOSE);
    this.tab = _cTabItem;
    this.tab.setControl(this.canvas);
    SwtToFXGestureConverter _swtToFXGestureConverter = new SwtToFXGestureConverter(this.canvas);
    this.gestureConverter = _swtToFXGestureConverter;
    final IChangeListener _function =
        (IWorkbenchPart it) -> {
          if ((it instanceof IEditorPart)) {
            this.refreshUpdateState();
          }
        };
    this.changeListener = _function;
    ModelChangeBroker _modelChangeBroker = view.getModelChangeBroker();
    _modelChangeBroker.addListener(this.changeListener);
    this.root = root;
    Scene _scene = new Scene(root);
    final Procedure1<Scene> _function_1 =
        (Scene it) -> {
          PerspectiveCamera _perspectiveCamera = new PerspectiveCamera();
          it.setCamera(_perspectiveCamera);
          root.activate();
        };
    Scene _doubleArrow = ObjectExtensions.<Scene>operator_doubleArrow(_scene, _function_1);
    this.canvas.setScene(_doubleArrow);
    final DisposeListener _function_2 =
        (DisposeEvent it) -> {
          this.gestureConverter.dispose();
          ModelChangeBroker _modelChangeBroker_1 = view.getModelChangeBroker();
          _modelChangeBroker_1.removeListener(this.changeListener);
          view.removeTab(this.tab);
        };
    this.tab.addDisposeListener(_function_2);
    StringProperty _fileNameProperty = root.fileNameProperty();
    InitializingListener<String> _initializingListener = new InitializingListener<String>();
    final Procedure1<InitializingListener<String>> _function_3 =
        (InitializingListener<String> it) -> {
          final Procedure1<String> _function_4 =
              (String it_1) -> {
                String _tabName = this.getTabName();
                this.tab.setText(_tabName);
              };
          it.setSet(_function_4);
        };
    InitializingListener<String> _doubleArrow_1 =
        ObjectExtensions.<InitializingListener<String>>operator_doubleArrow(
            _initializingListener, _function_3);
    CoreExtensions.<String>addInitializingListener(_fileNameProperty, _doubleArrow_1);
    BooleanProperty _needsSaveProperty = root.needsSaveProperty();
    final ChangeListener<Boolean> _function_4 =
        (ObservableValue<? extends Boolean> p, Boolean o, Boolean n) -> {
          String _tabName = this.getTabName();
          this.tab.setText(_tabName);
        };
    _needsSaveProperty.addListener(_function_4);
    this.canvas.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(final FocusEvent e) {
            IWorkbenchPartSite _site = view.getSite();
            IBindingService _service = _site.<IBindingService>getService(IBindingService.class);
            ((IBindingService) _service).setKeyFilterEnabled(false);
          }

          @Override
          public void focusLost(final FocusEvent e) {
            IWorkbenchPartSite _site = view.getSite();
            IBindingService _service = _site.<IBindingService>getService(IBindingService.class);
            ((IBindingService) _service).setKeyFilterEnabled(true);
          }
        });
  }