/**
   * Checks whether a node attached to the connection's source or target connector will move when a
   * joint is dragged.
   *
   * <p>This is evaluated based on whether the node and/or joint are selected.
   *
   * @param jointSkin a {@link GJointSkin} that is dragged
   * @param source {@code true} to query source node, {@code false} to query target node
   * @return {@code true} if the node will move when the given joint is dragged
   */
  private boolean isNodeStationary(final GJointSkin jointSkin, final boolean source) {

    final GConnector connector = source ? connection.getSource() : connection.getTarget();
    final GConnectable parent = connector.getParent();

    if (parent instanceof GNode) {
      final GNodeSkin nodeSkin = skinLookup.lookupNode((GNode) parent);
      return !nodeSkin.isSelected() || !jointSkin.isSelected();
    }

    return false;
  }
  /**
   * Deletes all nodes in the current selection and all attached connections.
   *
   * @param model the {@link GModel} currently being edited
   * @param consumer a consumer to allow custom commands to be appended to the delete command
   */
  public void deleteSelection(
      final GModel model, final BiConsumer<List<GNode>, CompoundCommand> consumer) {

    final List<GNode> nodesToDelete = new ArrayList<>();
    final List<GConnection> connectionsToDelete = new ArrayList<>();

    for (final GNode node : model.getNodes()) {
      if (skinLookup.lookupNode(node).isSelected()) {

        nodesToDelete.add(node);

        for (final GConnector connector : node.getConnectors()) {
          for (final GConnection connection : connector.getConnections()) {

            if (connection != null && !connectionsToDelete.contains(connection)) {
              connectionsToDelete.add(connection);
            }
          }
        }
      }
    }

    for (final GConnection connection : model.getConnections()) {
      if (skinLookup.lookupConnection(connection).isSelected()
          && !connectionsToDelete.contains(connection)) {
        connectionsToDelete.add(connection);
      }
    }

    if (!nodesToDelete.isEmpty() || !connectionsToDelete.isEmpty()) {

      final CompoundCommand command =
          modelEditingManager.remove(nodesToDelete, connectionsToDelete);

      if (consumer != null) {
        consumer.accept(nodesToDelete, command);
      }
    }
  }