public static void loadPagesAndDrawers(
      Workspace workspace, Element root, FactoryManager manager) {
    List<Page> pageList = new ArrayList<Page>();
    // pagesToAdd is needed so that we can add pages all at once
    // to the page bar once all the the pages been loaded
    // Before adding all the pages, this method makes a check
    // if there is only one page with an empty name - if so, it will just
    // add the page to the workspace/block canvas but not add it to this
    // LinkedHashMap<Page, PageBlockDrawer> pagesToAdd = new LinkedHashMap<Page, PageBlockDrawer>();
    LinkedHashMap<String, ArrayList<RenderableBlock>> blocksForDrawers =
        new LinkedHashMap<String, ArrayList<RenderableBlock>>();
    LinkedHashMap<Page, ArrayList<RenderableBlock>> blocksForPages =
        new LinkedHashMap<Page, ArrayList<RenderableBlock>>();

    NodeList pagesRoot = root.getElementsByTagName("Pages");
    if (pagesRoot != null) {
      // isBlankPage denotes if the page being loaded is a default blank page
      // in other words, the project did not specify any pages for their environment.
      // EvoBeaker does this
      boolean isBlankPage = false;
      Node pagesNode = pagesRoot.item(0);
      if (pagesNode == null) {
        return; // short-circuit exit if there's nothing to load
      }
      Node opt_item = pagesNode.getAttributes().getNamedItem("drawer-with-page");
      if (opt_item != null) {
        Matcher nameMatcher = attrExtractor.matcher(opt_item.toString());
        if (nameMatcher.find()) // will be true
        {
          Workspace.everyPageHasDrawer = nameMatcher.group(1).equals("yes") ? true : false;
        }
      }
      opt_item = pagesNode.getAttributes().getNamedItem("is-blank-page");
      if (opt_item != null) {
        Matcher nameMatcher = attrExtractor.matcher(opt_item.toString());
        if (nameMatcher.find()) // will be true
        {
          isBlankPage = nameMatcher.group(1).equals("yes") ? true : false;
        }
      }

      // whether pages should show a control to collapse them or not
      boolean collapsiblePages = getBooleanValue(pagesNode, "collapsible-pages");

      Page page;
      NodeList pages = pagesNode.getChildNodes();
      Node pageNode;
      String pageName = "";
      String pageDrawer = null;
      Color pageColor = null;
      boolean pageInFullView = true;
      int pageWidth = -1;
      String pageId = null;
      for (int i = 0; i < pages.getLength(); i++) { // find them
        pageNode = pages.item(i);
        if (pageNode.getNodeName().equals("Page")) { // a page entry
          pageName = getNodeValue(pageNode, "page-name");
          pageColor = getColorValue(pageNode, "page-color");
          pageWidth = getIntValue(pageNode, "page-width");
          pageDrawer = getNodeValue(pageNode, "page-drawer");
          pageInFullView = getBooleanValue(pageNode, "page-infullview");
          pageId = getNodeValue(pageNode, "page-id");
          page =
              new Page(
                  workspace,
                  pageName,
                  pageWidth,
                  0,
                  pageDrawer,
                  pageInFullView,
                  pageColor,
                  collapsiblePages);
          page.setPageId(pageId);

          NodeList pageNodes = pageNode.getChildNodes();
          String drawer = null;
          if (Workspace.everyPageHasDrawer) {
            // create drawer instance
            manager.addDynamicDrawer(page.getPageDrawer());
            ArrayList<RenderableBlock> drawerBlocks = new ArrayList<RenderableBlock>();

            for (int k = 0; k < pageNodes.getLength(); k++) {
              Node drawerNode = pageNodes.item(k);
              if (drawerNode.getNodeName().equals("PageDrawer")) {
                NodeList genusMembers = drawerNode.getChildNodes();
                String genusName;
                for (int j = 0; j < genusMembers.getLength(); j++) {
                  Node genusMember = genusMembers.item(j);
                  if (genusMember.getNodeName().equals("BlockGenusMember")) {
                    genusName = genusMember.getTextContent();
                    assert BlockGenus.getGenusWithName(genusName) != null
                        : "Unknown BlockGenus: " + genusName;
                    Block block = new Block(workspace, genusName);
                    drawerBlocks.add(
                        new FactoryRenderableBlock(workspace, manager, block.getBlockID()));
                  }
                }
                blocksForDrawers.put(drawer, drawerBlocks);
                break; // there can only be one drawer for this page
              }
            }
          }

          if (isBlankPage) {
            // place a blank page as the first page
            workspace.putPage(page, 0);
            // if the system uses blank pages, then we expect only one page
            break; // we anticipate only one page
          } else {
            // we add to the end of the set of pages
            int position = pageList.size();
            // add to workspace
            if (position == 0) {
              // replace the blank default page
              workspace.putPage(page, 0);
            } else {
              workspace.addPage(page, position);
            }
            pageList.add(position, page);
          }

          blocksForPages.put(page, page.loadPageFrom(pageNode, false));
        }
      }
      // add blocks in drawers
      for (String d : blocksForDrawers.keySet()) {
        manager.addDynamicBlocks(blocksForDrawers.get(d), d);
      }
      // blocks in pages
      for (Page p : blocksForPages.keySet()) {
        p.addLoadedBlocks(blocksForPages.get(p), false);
      }
    }
  }