Skip to content

Loading dock state doesn't work in examples #21

Description

@skalkin

Here is a modified code of the dock_spawn_demo_simple.dart, the only thing I've changed is added the button that invokes dockManager.loadState(dockManager.saveState()). When user clicks the button, the null pointer exception is raised. Am I using the loadState/saveState methods in the right way?

import 'dart:html';
import 'package:dock_spawn/dock_spawn.dart';

void main() {
  new DockManagerDemo();
}


class DockManagerDemo {
  DockManager dockManager;

  DockManagerDemo() {
    // Convert a div to the dock manager.  Panels can then be docked on to it
    dockManager = new DockManager(query("#my_dock_manager"));
    dockManager.initialize();

    // Let the dock manager element fill in the entire screen
    window.onResize.listen(onResized);
    onResized(null);

    query("#solution_window").children.add(new ButtonElement()
      ..text="Reload"
      ..onClick.listen((_) => dockManager.loadState(dockManager.saveState())));

    // Convert existing elements on the page into "Panels". 
    // They can then be docked on to the dock manager 
    // Panels get a titlebar and a close button, and can also be 
    // converted to a floating dialog box which can be dragged / resized 
    var solution = new PanelContainer(query("#solution_window"), dockManager);
    var output = new PanelContainer(query("#output_window"), dockManager);
    var properties = new PanelContainer(query("#properties_window"), dockManager);
    var toolbox = new PanelContainer(query("#toolbox_window"), dockManager);
    var outline = new PanelContainer(query("#outline_window"), dockManager);
    var problems = new PanelContainer(query("#problems_window"), dockManager);
    var editor1 = new PanelContainer(query("#editor1_window"), dockManager);
    var editor2 = new PanelContainer(query("#editor2_window"), dockManager);

    // Dock the panels on the dock manager
    DockNode documentNode = dockManager.context.model.documentManagerNode;
    DockNode solutionNode = dockManager.dockLeft(documentNode, solution, 0.20);
    DockNode outlineNode = dockManager.dockFill(solutionNode, outline);
    DockNode propertiesNode = dockManager.dockDown(outlineNode, properties, 0.6);
    DockNode outputNode = dockManager.dockDown(documentNode, output, 0.4);
    DockNode problemsNode = dockManager.dockRight(outputNode, problems, 0.40);
    DockNode toolboxNode = dockManager.dockRight(documentNode, toolbox, 0.20);

    DockNode editor1Node = dockManager.dockFill(documentNode, editor1);
    DockNode editor2Node = dockManager.dockFill(documentNode, editor2);
  }

  void onResized(Event event) {
    dockManager.resize(window.innerWidth, window.innerHeight);
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions