Copied truncate method to UIUtilities class

Fixes travis build error; EditorUtil is not available in
utils build.