01: /*
02: * @(#)PPCClipboard.java 1.8 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package sun.awt.pocketpc;
28:
29: import java.awt.datatransfer.*;
30:
31: import java.awt.AWTException;
32: import java.awt.datatransfer.*;
33:
34: /**
35: * A class which interfaces with the Windows clipboard in order
36: * to support data transfer via clipboard operations.
37: */
38: public class PPCClipboard extends Clipboard {
39:
40: static {
41: initIDs();
42: init();
43: }
44:
45: private static native void initIDs();
46:
47: public PPCClipboard() {
48: super ("System");
49: }
50:
51: public synchronized void setContents(Transferable contents,
52: ClipboardOwner owner) {
53: super .setContents(contents, owner);
54:
55: if (contents instanceof StringSelection) {
56: setClipboardText((StringSelection) contents);
57: }
58: }
59:
60: public synchronized Transferable getContents(Object requestor) {
61: String s = getClipboardText();
62: return (s == null) ? null : new StringSelection(s);
63: }
64:
65: public synchronized void lostSelectionOwnership() {
66: if (this .owner != null) {
67: this .owner.lostOwnership(this , this .contents);
68: this .owner = null;
69: }
70:
71: // fix 4177171 : always clear cached contents when losing ownership
72: this .contents = null;
73: }
74:
75: // Register Java String clipboard format.
76: static private native void init();
77:
78: // Replace the current clipboard contents with ss.
79: private native void setClipboardText(StringSelection ss);
80:
81: // Get the current clipboard contents.
82: private native String getClipboardText();
83: }
|