author | never |
Mon, 12 Jul 2010 22:27:18 -0700 | |
changeset 5926 | a36f90d986b6 |
parent 5506 | 202f599c92aa |
child 20127 | a3a34675d847 |
permissions | -rw-r--r-- |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
4 |
* |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
10 |
* |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
15 |
* accompanied this code). |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
16 |
* |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
24 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
25 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
26 |
package sun.swing; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
27 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
28 |
import sun.misc.Unsafe; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
29 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
30 |
import java.awt.Point; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
31 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
32 |
import javax.swing.text.JTextComponent; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
33 |
import javax.swing.TransferHandler; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
34 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
35 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
36 |
* The SwingAccessor utility class. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
37 |
* The main purpose of this class is to enable accessing |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
38 |
* private and package-private fields of classes from |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
39 |
* different classes/packages. See sun.misc.SharedSecretes |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
40 |
* for another example. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
41 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
42 |
public final class SwingAccessor { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
43 |
private static final Unsafe unsafe = Unsafe.getUnsafe(); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
44 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
45 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
46 |
* We don't need any objects of this class. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
47 |
* It's rather a collection of static methods |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
48 |
* and interfaces. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
49 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
50 |
private SwingAccessor() { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
51 |
} |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
52 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
53 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
54 |
* An accessor for the JTextComponent class. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
55 |
* Note that we intentionally introduce the JTextComponentAccessor, |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
56 |
* and not the JComponentAccessor because the needed methods |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
57 |
* aren't override methods. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
58 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
59 |
public interface JTextComponentAccessor { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
60 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
61 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
62 |
* Calculates a custom drop location for the text component, |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
63 |
* representing where a drop at the given point should insert data. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
64 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
65 |
TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
66 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
67 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
68 |
* Called to set or clear the drop location during a DnD operation. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
69 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
70 |
Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location, |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
71 |
Object state, boolean forDrop); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
72 |
} |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
73 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
74 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
75 |
* The javax.swing.text.JTextComponent class accessor object. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
76 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
77 |
private static JTextComponentAccessor jtextComponentAccessor; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
78 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
79 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
80 |
* Set an accessor object for the javax.swing.text.JTextComponent class. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
81 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
82 |
public static void setJTextComponentAccessor(JTextComponentAccessor jtca) { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
83 |
jtextComponentAccessor = jtca; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
84 |
} |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
85 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
86 |
/** |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
87 |
* Retrieve the accessor object for the javax.swing.text.JTextComponent class. |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
88 |
*/ |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
89 |
public static JTextComponentAccessor getJTextComponentAccessor() { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
90 |
if (jtextComponentAccessor == null) { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
91 |
unsafe.ensureClassInitialized(JTextComponent.class); |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
92 |
} |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
93 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
94 |
return jtextComponentAccessor; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
95 |
} |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
diff
changeset
|
96 |
} |