source: trunk/src/org/expeditee/gio/ClipboardManager.java@ 1436

Last change on this file since 1436 was 1436, checked in by bnemhaus, 5 years ago

Added the ability to copy/paste recognised files (mostly images) into Expeditee. This functionality already existed when drag n dropping, but now also works when using copy/paste.

At this stage, recognised files get imported as a approapriate Text Item. For example, a image will create a @i Text Item and attach it to your cursor. Ideally this would be the image directly. Unfortunately, items attached to the cursor (FreeItems) are not currently parsed. This is something I will discuss with David as there are confounding issues to consider. For example: surrogates...

Attached to the bottom of this commit message are my current thoughts.

Also made it so when creating a @i through DND or Copy/Paste, that @i is as relative as possible. The users image directories setting is used to achieve this.


  • FreeItems need to be parsed...we would need to deal with primaries/surrogates in them...
  • Do we want FreeItems to be parsed? If I attach an item to my cursor and then enter surrogate mode, should it change?
  • My gut says no. Both because it would be work, and also because it kind of feels like a free win if we do not.
  • But we do want to replace @i with images etc. Therefore, we want an old style parse for FreeItems?
File size: 2.3 KB
Line 
1package org.expeditee.gio;
2
3import java.io.File;
4import java.util.List;
5
6import 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 */
19public 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}
Note: See TracBrowser for help on using the repository browser.