package org.expeditee.gio; import java.io.File; import java.util.List; import org.expeditee.core.Image; /** * In charge of getting/setting the OS clipboard. Any Object can be * set on the clipboard, but typically only other instances of Expeditee * will be able to read this. Similarly generic data will only be available * to get if it has been set by another Expeditee instance. Additionally, * the clipboard data can have an image- or string-representation, which * external applications that can copy/paste image/string data will be able * to set/get. * * @author cts16 */ public abstract class ClipboardManager { /** * Sets the clipboard to the given data. If data is null, should leave * the clipboard unchanged (however, if data is not null but all of its * fields are null, this will clear the clipboard). */ public abstract void set(ClipboardData data); /** Gets the data that is currently on the clipboard. */ public abstract ClipboardData get(); /** Representation of the data on the clipboard. */ public static class ClipboardData { /** Any generic data on the clipboard (for Expeditee use only). */ public Object data; /** * An image representation of the clipboard data * (for use when copy/pasting to/from image applications). */ public Image imageRepresentation; /** * A string representation of the clipboard data * (for use when copy/pasting to/from text applications). */ public String stringRepresentation; /** * A List representation of the clipboard data * (for use when copy/pasting to/from directories), */ public List fileRepresentation; /** Default constructor. */ public ClipboardData() { this(null, null, null); } /** Standard constructor. */ public ClipboardData(Object data, Image imageRepresentation, String stringRepresentation) { this.data = data; this.imageRepresentation = imageRepresentation; this.stringRepresentation = stringRepresentation; } /** Instantiator for purely-image data. */ public static ClipboardData fromImage(Image image) { return new ClipboardData(null, image, null); } /** Instantiator for purely-string data. */ public static ClipboardData fromString(String string) { return new ClipboardData(null, null, string); } } }