Пример #1
0
  public CombinerTarget prepare(final CombinerSource source, boolean force) {
    DockableDisplayer displayer = source.getOldDisplayer();
    if (displayer != null) {
      DisplayerCombinerTarget operation = displayer.prepareCombination(source, force);
      if (operation != null) {
        return new DisplayerTarget(operation);
      }
    }

    if (!force) {
      return null;
    }

    return new CombinerTarget() {
      public void paint(
          Graphics g,
          Component component,
          StationPaint paint,
          Rectangle stationBounds,
          Rectangle dockableBounds) {
        paint.drawInsertion(g, source.getParent(), stationBounds, dockableBounds);
      }

      public DisplayerCombinerTarget getDisplayerCombination() {
        return null;
      }
    };
  }
  @Override
  protected void showDisplayer(DockableDisplayer displayer) {
    if (this.displayer != displayer) {
      if (this.displayer != null) {
        getDisplayerParent().remove(this.displayer.getComponent());
      }

      this.displayer = displayer;

      if (displayer != null) {
        getDisplayerParent().add(displayer.getComponent());
      }
    }

    validate();
  }
  /**
   * Makes a guess how big the insets of the {@link Dockable} compared to the whole dialog are.
   *
   * @return the insets, only a guess
   */
  public Insets getDockableInsets() {
    Container parent = getDisplayerParent();
    Insets parentInsets = parent.getInsets();
    if (parentInsets == null) parentInsets = new Insets(0, 0, 0, 0);

    Point zero = new Point(0, 0);
    zero = SwingUtilities.convertPoint(parent, zero, window);

    parentInsets.left += zero.x;
    parentInsets.top += zero.y;
    parentInsets.right += window.getWidth() - parent.getWidth() - zero.x;
    parentInsets.bottom += window.getHeight() - parent.getHeight() - zero.y;

    if (displayer == null) return parentInsets;

    Insets insets = displayer.getDockableInsets();
    parentInsets.top += insets.top;
    parentInsets.bottom += insets.bottom;
    parentInsets.left += insets.left;
    parentInsets.right += insets.right;

    return parentInsets;
  }