55import static java .lang .Math .acos ;
66import static java .lang .Math .toDegrees ;
77import static java .lang .ThreadLocal .withInitial ;
8+ import static java .util .stream .Collectors .toList ;
89import com .jme3 .math .Vector2f ;
910import com .jme3 .math .Vector3f ;
1011import com .jme3 .renderer .Camera ;
12+ import com .jme3 .system .JmeSystem ;
13+ import com .jme3 .system .Platform ;
1114import com .ss .editor .JFXApplication ;
1215import com .ss .editor .analytics .google .GAnalytics ;
1316import com .ss .editor .annotation .FXThread ;
3033import javafx .scene .control .DialogPane ;
3134import javafx .scene .control .TextArea ;
3235import javafx .scene .input .Clipboard ;
36+ import javafx .scene .input .ClipboardContent ;
3337import javafx .scene .input .DataFormat ;
3438import javafx .scene .layout .VBox ;
3539import org .apache .commons .lang3 .SystemUtils ;
4044import java .net .MalformedURLException ;
4145import java .net .URL ;
4246import java .net .URLClassLoader ;
47+ import java .nio .ByteBuffer ;
4348import java .nio .file .Path ;
4449import java .text .SimpleDateFormat ;
4550import java .util .ArrayList ;
@@ -62,10 +67,53 @@ public abstract class EditorUtil {
6267 @ NotNull
6368 public static final DataFormat JAVA_PARAM = new DataFormat ("SSEditor.javaParam" );
6469
70+ /**
71+ * Represents a List of Files.
72+ */
73+ public static final DataFormat GNOME_FILES = new DataFormat ("x-special/gnome-copied-files" );
74+
6575 @ NotNull
6676 private static final ThreadLocal <SimpleDateFormat > LOCATE_DATE_FORMAT = withInitial (() ->
6777 new SimpleDateFormat ("HH:mm:ss:SSS" ));
6878
79+ /**
80+ * Added files like files to copy to clipboard content.
81+ *
82+ * @param paths the list of files.
83+ * @param content the content to store.
84+ */
85+ public static void addCopiedFile (@ NotNull final Array <Path > paths , @ NotNull final ClipboardContent content ) {
86+
87+ final List <File > files = paths .stream ()
88+ .map (Path ::toFile )
89+ .collect (toList ());
90+
91+ content .putFiles (files );
92+ content .put (EditorUtil .JAVA_PARAM , "copy" );
93+
94+ final Platform platform = JmeSystem .getPlatform ();
95+
96+ if (platform == Platform .Linux64 || platform == Platform .Linux32 ) {
97+
98+ final StringBuilder builder = new StringBuilder ("copy\n " );
99+
100+ paths .forEach (builder , (path , b ) ->
101+ b .append (path .toUri ().toASCIIString ()).append ('\n' ));
102+
103+ builder .delete (builder .length () - 1 , builder .length ());
104+
105+ final ByteBuffer buffer = ByteBuffer .allocate (builder .length ());
106+
107+ for (int i = 0 , length = builder .length (); i < length ; i ++) {
108+ buffer .put ((byte ) builder .charAt (i ));
109+ }
110+
111+ buffer .flip ();
112+
113+ content .put (GNOME_FILES , buffer );
114+ }
115+ }
116+
69117 /**
70118 * Check exists boolean.
71119 *
0 commit comments