ViewSystem.js 680 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import {Node, Link, Graph} from '../helpers/graph'
  3. import {TreeNode, Tree} from '../helpers/tree'
  4. function log(...m) {
  5. console.log(...m);
  6. }
  7. export class ViewNode extends TreeNode {
  8. constructor(viewName) {
  9. super(viewName);
  10. this.viewName = viewName;
  11. }
  12. }
  13. export default class ViewSystem {
  14. constructor() {
  15. this.rootNode = new ViewNode('Root');
  16. this.topology = new Tree(this.rootNode);
  17. }
  18. add(node, parent = this.rootNode) {
  19. this.topology.insert(node, parent);
  20. }
  21. move(node, parent = this.rootNode) {
  22. this.topology.changeParent(node, parent);
  23. }
  24. print() {
  25. log("Printing View Tree: ", this.viewName);
  26. this.topology.print()
  27. }
  28. }