private static int getSize(Transferable t) {
    if (t instanceof StringSelection) {
      try {
        return StringUtil.length((String)t.getTransferData(DataFlavor.stringFlavor));
      }
      catch (Exception e) {
        LOG.error(e);
      }
    }
    else if (t instanceof Sizeable) {
      int size = ((Sizeable)t).getSize();
      //noinspection ConstantConditions
      if (size >= 0) {
        return size;
      }
      LOG.error("Got negative size (" + size + ") from " + t);
    }
    return 1000; // some value for an unknown type
  }
private static int getSize(Transferable t)