Exemple #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();
  }
Exemple #2
0
  /** @overrides WorkspaceWidget.addBlock() */
  @Override
  public void addBlock(RenderableBlock block) {
    // update parent widget if dropped block
    WorkspaceWidget oldParent = block.getParentWidget();
    if (oldParent != this) {
      if (oldParent != null) {
        oldParent.removeBlock(block);
        if (block.hasComment()) {
          block.getComment().getParent().remove(block.getComment());
        }
      }
      block.setParentWidget(this);
      if (block.hasComment()) {
        block.getComment().setParent(block.getParentWidget().getJComponent());
      }
    }

    this.getRBParent().addToBlockLayer(block);
    block.setHighlightParent(this.getRBParent());

    // if block has page labels enabled, in other words, if it can, then set page label to this
    if (workspace.getEnv().getBlock(block.getBlockID()).isPageLabelSetByPage()) {
      workspace.getEnv().getBlock(block.getBlockID()).setPageLabel(this.getPageName());
    }

    // notify block to link default args if it has any
    block.linkDefArgs();

    // fire to workspace that block was added to canvas if oldParent != this
    if (oldParent != this) {
      workspace.notifyListeners(
          new WorkspaceEvent(workspace, oldParent, block.getBlockID(), WorkspaceEvent.BLOCK_MOVED));
      workspace.notifyListeners(
          new WorkspaceEvent(
              workspace, this, block.getBlockID(), WorkspaceEvent.BLOCK_ADDED, true));
    }

    // if the block is off the edge, shift everything or grow as needed to fully show it
    this.reformBlockPosition(block);

    this.pageJComponent.setComponentZOrder(block, 0);
  }