示例#1
0
  public void addLoadedBlocks(Collection<RenderableBlock> loadedBlocks, boolean importingPage) {
    for (RenderableBlock rb : loadedBlocks) {
      if (rb != null) {
        // add graphically
        getRBParent().addToBlockLayer(rb);
        rb.setHighlightParent(this.getRBParent());
        // System.out.println("loading rb to canvas: "+rb+" at: "+rb.getBounds());
        // add internallly
        workspace.notifyListeners(
            new WorkspaceEvent(workspace, this, rb.getBlockID(), WorkspaceEvent.BLOCK_ADDED));
        if (importingPage) {
          workspace.getEnv().getBlock(rb.getBlockID()).setFocus(false);
          rb.resetHighlight();
          rb.clearBufferedImage();
        }
      }
    }

    // now we need to redraw all the blocks now that all renderable blocks
    // within this page have been loaded, to update the socket dimensions of
    // blocks, etc.
    for (RenderableBlock rb : this.getTopLevelBlocks()) {
      rb.redrawFromTop();
      if (rb.isCollapsed()) {
        // This insures that blocks connected to a collapsed top level block
        // are located properly and have the proper visibility set.
        // This doesn't work until all blocks are loaded and dimensions are set.
        rb.updateCollapse();
      }
    }
    this.pageJComponent.revalidate();
    this.pageJComponent.repaint();
  }