1 | package org.expeditee.gio;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import org.expeditee.core.Image;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * In charge of getting/setting the OS clipboard. Any Object can be
|
---|
10 | * set on the clipboard, but typically only other instances of Expeditee
|
---|
11 | * will be able to read this. Similarly generic data will only be available
|
---|
12 | * to get if it has been set by another Expeditee instance. Additionally,
|
---|
13 | * the clipboard data can have an image- or string-representation, which
|
---|
14 | * external applications that can copy/paste image/string data will be able
|
---|
15 | * to set/get.
|
---|
16 | *
|
---|
17 | * @author cts16
|
---|
18 | */
|
---|
19 | public abstract class ClipboardManager {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Sets the clipboard to the given data. If data is null, should leave
|
---|
23 | * the clipboard unchanged (however, if data is not null but all of its
|
---|
24 | * fields are null, this will clear the clipboard).
|
---|
25 | */
|
---|
26 | public abstract void set(ClipboardData data);
|
---|
27 |
|
---|
28 | /** Gets the data that is currently on the clipboard. */
|
---|
29 | public abstract ClipboardData get();
|
---|
30 |
|
---|
31 | /** Representation of the data on the clipboard. */
|
---|
32 | public static class ClipboardData {
|
---|
33 |
|
---|
34 | /** Any generic data on the clipboard (for Expeditee use only). */
|
---|
35 | public Object data;
|
---|
36 | /**
|
---|
37 | * An image representation of the clipboard data
|
---|
38 | * (for use when copy/pasting to/from image applications).
|
---|
39 | */
|
---|
40 | public Image imageRepresentation;
|
---|
41 | /**
|
---|
42 | * A string representation of the clipboard data
|
---|
43 | * (for use when copy/pasting to/from text applications).
|
---|
44 | */
|
---|
45 | public String stringRepresentation;
|
---|
46 | /**
|
---|
47 | * A List representation of the clipboard data
|
---|
48 | * (for use when copy/pasting to/from directories),
|
---|
49 | */
|
---|
50 | public List<File> fileRepresentation;
|
---|
51 |
|
---|
52 | /** Default constructor. */
|
---|
53 | public ClipboardData()
|
---|
54 | {
|
---|
55 | this(null, null, null);
|
---|
56 | }
|
---|
57 |
|
---|
58 | /** Standard constructor. */
|
---|
59 | public ClipboardData(Object data, Image imageRepresentation, String stringRepresentation)
|
---|
60 | {
|
---|
61 | this.data = data;
|
---|
62 | this.imageRepresentation = imageRepresentation;
|
---|
63 | this.stringRepresentation = stringRepresentation;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /** Instantiator for purely-image data. */
|
---|
67 | public static ClipboardData fromImage(Image image)
|
---|
68 | {
|
---|
69 | return new ClipboardData(null, image, null);
|
---|
70 | }
|
---|
71 |
|
---|
72 | /** Instantiator for purely-string data. */
|
---|
73 | public static ClipboardData fromString(String string)
|
---|
74 | {
|
---|
75 | return new ClipboardData(null, null, string);
|
---|
76 | }
|
---|
77 |
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|