/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import * as React from 'react'; import { PluginContext } from '../context'; import { StateTree } from './state-tree'; import { Viewport } from './viewport'; import { Controls, _test_CreateTransform } from './controls'; import { Transformer } from 'mol-state'; // TODO: base object with subscribe helpers export class Plugin extends React.Component<{ plugin: PluginContext }, { }> { render() { return

<_test_CurrentObject plugin={this.props.plugin} />
; } } export class _test_CurrentObject extends React.Component<{ plugin: PluginContext }, { }> { componentDidMount() { // TODO: move to constructor? this.props.plugin.behaviors.state.data.currentObject.subscribe(() => this.forceUpdate()); } render() { const ref = this.props.plugin.behaviors.state.data.currentObject.value.ref; // const n = this.props.plugin.state.data.tree.nodes.get(ref)!; const obj = this.props.plugin.state.data.objects.get(ref)!; const type = obj && obj.obj ? obj.obj.type : void 0; const transforms = type ? Transformer.fromType(type) : [] return
Current Ref: {this.props.plugin.behaviors.state.data.currentObject.value.ref}
{ transforms.map((t, i) => <_test_CreateTransform key={`${t.id} ${ref} ${i}`} plugin={this.props.plugin} transformer={t} nodeRef={ref} />) }
; } }