Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public String getConstraints(IComponent pComponent) {
    Node node = (Node) pComponent.getResource();

    if (resource.getBottom() == node) {
      return SOUTH;
    } else if (resource.getCenter() == node) {
      return CENTER;
    } else if (resource.getLeft() == node) {
      return WEST;
    } else if (resource.getRight() == node) {
      return EAST;
    } else if (resource.getTop() == node) {
      return NORTH;
    }

    return null;
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void add(IComponent pComponent, Object pConstraints, int pIndex) {
    if (pConstraints == null || CENTER.equals(pConstraints)) {
      resource.setCenter((Node) pComponent.getResource());
    } else if (EAST.equals(pConstraints)) {
      resource.setRight((Node) pComponent.getResource());
    } else if (NORTH.equals(pConstraints)) {
      resource.setTop((Node) pComponent.getResource());
    } else if (SOUTH.equals(pConstraints)) {
      resource.setBottom((Node) pComponent.getResource());
    } else if (WEST.equals(pConstraints)) {
      resource.setLeft((Node) pComponent.getResource());
    } else {
      resource.setCenter((Node) pComponent.getResource());
    }

    BorderPane.setAlignment((Node) pComponent.getResource(), Pos.CENTER);

    updateGaps();
  }
Ejemplo n.º 3
0
  /**
   * Tries to remove the given {@link IComponent}, and returns {@code true} if that succeeded.
   *
   * @param pComponent the {@link IComponent} to remove.
   * @return {@code true} if the given {@link IComponent} has been removed.
   */
  private boolean tryRemove(IComponent pComponent) {
    Node nodeToRemove = (Node) pComponent.getResource();

    if (resource.getBottom() == nodeToRemove) {
      resource.setBottom(null);
      return true;
    } else if (resource.getCenter() == nodeToRemove) {
      resource.setCenter(null);
      return true;
    } else if (resource.getLeft() == nodeToRemove) {
      resource.setLeft(null);
      return true;
    } else if (resource.getRight() == nodeToRemove) {
      resource.setRight(null);
      return true;
    } else if (resource.getTop() == nodeToRemove) {
      resource.setTop(null);
      return true;
    }

    return false;
  }