Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
33d7f099
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33d7f099
编写于
4月 17, 2013
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
b315e54c
77e0a7f8
变更
35
显示空白变更内容
内联
并排
Showing
35 changed file
with
1788 addition
and
763 deletion
+1788
-763
src/macosx/classes/sun/lwawt/LWComponentPeer.java
src/macosx/classes/sun/lwawt/LWComponentPeer.java
+1
-1
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
+8
-0
src/macosx/classes/sun/lwawt/macosx/CCursorManager.java
src/macosx/classes/sun/lwawt/macosx/CCursorManager.java
+0
-36
src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
+6
-9
src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java
...cosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java
+58
-42
src/macosx/classes/sun/lwawt/macosx/CDropTarget.java
src/macosx/classes/sun/lwawt/macosx/CDropTarget.java
+6
-15
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
+8
-0
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+15
-0
src/macosx/native/sun/awt/CClipboard.m
src/macosx/native/sun/awt/CClipboard.m
+22
-5
src/macosx/native/sun/awt/CDragSource.h
src/macosx/native/sun/awt/CDragSource.h
+16
-9
src/macosx/native/sun/awt/CDragSource.m
src/macosx/native/sun/awt/CDragSource.m
+28
-36
src/macosx/native/sun/awt/CDragSourceContextPeer.m
src/macosx/native/sun/awt/CDragSourceContextPeer.m
+20
-25
src/macosx/native/sun/awt/CDropTarget.m
src/macosx/native/sun/awt/CDropTarget.m
+13
-14
src/macosx/native/sun/awt/CTextPipe.m
src/macosx/native/sun/awt/CTextPipe.m
+13
-1
src/share/classes/java/awt/datatransfer/DataFlavor.java
src/share/classes/java/awt/datatransfer/DataFlavor.java
+80
-18
src/share/classes/java/awt/datatransfer/SystemFlavorMap.java
src/share/classes/java/awt/datatransfer/SystemFlavorMap.java
+147
-117
src/share/classes/java/awt/dnd/InvalidDnDOperationException.java
...re/classes/java/awt/dnd/InvalidDnDOperationException.java
+1
-1
src/share/classes/sun/awt/datatransfer/DataTransferer.java
src/share/classes/sun/awt/datatransfer/DataTransferer.java
+234
-238
src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
+1
-5
src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
+5
-2
src/share/classes/sun/swing/JLightweightFrame.java
src/share/classes/sun/swing/JLightweightFrame.java
+3
-1
src/solaris/classes/sun/awt/X11/XDataTransferer.java
src/solaris/classes/sun/awt/X11/XDataTransferer.java
+9
-15
src/solaris/classes/sun/awt/X11/XFramePeer.java
src/solaris/classes/sun/awt/X11/XFramePeer.java
+7
-1
src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java
src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java
+65
-0
src/solaris/classes/sun/awt/X11/XToolkit.java
src/solaris/classes/sun/awt/X11/XToolkit.java
+3
-1
src/windows/classes/sun/awt/windows/WDataTransferer.java
src/windows/classes/sun/awt/windows/WDataTransferer.java
+200
-169
test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
.../awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
+188
-0
test/java/awt/datatransfer/HTMLDataFlavors/HtmlTransferable.java
...va/awt/datatransfer/HTMLDataFlavors/HtmlTransferable.java
+113
-0
test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.html
...atatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.html
+20
-0
test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.java
...atatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.java
+292
-0
test/java/awt/datatransfer/HTMLDataFlavors/PutAllHtmlFlavorsOnClipboard.java
...ransfer/HTMLDataFlavors/PutAllHtmlFlavorsOnClipboard.java
+34
-0
test/java/awt/datatransfer/HTMLDataFlavors/PutOnlyAllHtmlFlavorOnClipboard.java
...sfer/HTMLDataFlavors/PutOnlyAllHtmlFlavorOnClipboard.java
+35
-0
test/java/awt/datatransfer/HTMLDataFlavors/PutSelectionAndFragmentHtmlFlavorsOnClipboard.java
...lavors/PutSelectionAndFragmentHtmlFlavorsOnClipboard.java
+34
-0
test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java
...t/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java
+97
-0
test/javax/swing/JPopupMenu/6827786/bug6827786.java
test/javax/swing/JPopupMenu/6827786/bug6827786.java
+6
-2
未找到文件。
src/macosx/classes/sun/lwawt/LWComponentPeer.java
浏览文件 @
33d7f099
...
@@ -336,7 +336,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
...
@@ -336,7 +336,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return
peerTreeLock
;
return
peerTreeLock
;
}
}
final
T
getTarget
()
{
public
final
T
getTarget
()
{
return
target
;
return
target
;
}
}
...
...
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
浏览文件 @
33d7f099
...
@@ -110,4 +110,12 @@ public class CClipboard extends SunClipboard {
...
@@ -110,4 +110,12 @@ public class CClipboard extends SunClipboard {
public
native
void
declareTypes
(
long
[]
formats
,
SunClipboard
newOwner
);
public
native
void
declareTypes
(
long
[]
formats
,
SunClipboard
newOwner
);
public
native
void
setData
(
byte
[]
data
,
long
format
);
public
native
void
setData
(
byte
[]
data
,
long
format
);
/**
* Invokes native check whether a change count on the general pasteboard is different
* than when we set it. The different count value means the current owner lost
* pasteboard ownership and someone else put data on the clipboard.
* @since 1.7
*/
public
native
void
checkPasteboard
();
}
}
src/macosx/classes/sun/lwawt/macosx/CCursorManager.java
浏览文件 @
33d7f099
...
@@ -51,15 +51,6 @@ final class CCursorManager extends LWCursorManager {
...
@@ -51,15 +51,6 @@ final class CCursorManager extends LWCursorManager {
@Override
@Override
protected
Point
getCursorPosition
()
{
protected
Point
getCursorPosition
()
{
synchronized
(
this
)
{
if
(
isDragging
)
{
// during the drag operation, the appkit thread is blocked,
// so nativeGetCursorPosition invocation may cause a deadlock.
// In order to avoid this, we returns last know cursor position.
return
new
Point
(
dragPos
);
}
}
final
Point2D
nativePosition
=
nativeGetCursorPosition
();
final
Point2D
nativePosition
=
nativeGetCursorPosition
();
return
new
Point
((
int
)
nativePosition
.
getX
(),
(
int
)
nativePosition
.
getY
());
return
new
Point
((
int
)
nativePosition
.
getX
(),
(
int
)
nativePosition
.
getY
());
}
}
...
@@ -101,31 +92,4 @@ final class CCursorManager extends LWCursorManager {
...
@@ -101,31 +92,4 @@ final class CCursorManager extends LWCursorManager {
// do something special
// do something special
throw
new
RuntimeException
(
"Unimplemented"
);
throw
new
RuntimeException
(
"Unimplemented"
);
}
}
// package private methods to handle cursor change during drag-and-drop
private
boolean
isDragging
=
false
;
private
Point
dragPos
=
null
;
synchronized
void
startDrag
(
int
x
,
int
y
)
{
if
(
isDragging
)
{
throw
new
RuntimeException
(
"Invalid Drag state in CCursorManager!"
);
}
isDragging
=
true
;
dragPos
=
new
Point
(
x
,
y
);
}
synchronized
void
updateDragPosition
(
int
x
,
int
y
)
{
if
(!
isDragging
)
{
throw
new
RuntimeException
(
"Invalid Drag state in CCursorManager!"
);
}
dragPos
.
move
(
x
,
y
);
}
synchronized
void
stopDrag
()
{
if
(!
isDragging
)
{
throw
new
RuntimeException
(
"Invalid Drag state in CCursorManager!"
);
}
isDragging
=
false
;
dragPos
=
null
;
}
}
}
src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
浏览文件 @
33d7f099
...
@@ -174,7 +174,7 @@ public class CDataTransferer extends DataTransferer {
...
@@ -174,7 +174,7 @@ public class CDataTransferer extends DataTransferer {
bytes
=
Normalizer
.
normalize
(
new
String
(
bytes
,
"UTF8"
),
Form
.
NFC
).
getBytes
(
"UTF8"
);
bytes
=
Normalizer
.
normalize
(
new
String
(
bytes
,
"UTF8"
),
Form
.
NFC
).
getBytes
(
"UTF8"
);
}
}
return
super
.
translateBytes
OrStream
(
stream
,
bytes
,
flavor
,
format
,
transferable
);
return
super
.
translateBytes
(
bytes
,
flavor
,
format
,
transferable
);
}
}
...
@@ -257,16 +257,13 @@ public class CDataTransferer extends DataTransferer {
...
@@ -257,16 +257,13 @@ public class CDataTransferer extends DataTransferer {
private
native
byte
[]
imageDataToPlatformImageBytes
(
int
[]
rData
,
int
nW
,
int
nH
);
private
native
byte
[]
imageDataToPlatformImageBytes
(
int
[]
rData
,
int
nW
,
int
nH
);
/**
/**
* Translates either a byte array or an input stream which contain
* Translates a byte array which contains
* platform-specific image data in the given format into an Image.
* platform-specific image data in the given format into an Image.
*/
*/
protected
Image
platformImageBytesOrStreamToImage
(
InputStream
stream
,
byte
[]
bytes
,
long
format
)
throws
IOException
{
protected
Image
platformImageBytesToImage
(
byte
[]
bytes
,
long
format
)
byte
[]
imageData
=
bytes
;
throws
IOException
{
if
(
imageData
==
null
)
return
getImageForByteStream
(
bytes
);
imageData
=
inputStreamToByteArray
(
stream
);
return
getImageForByteStream
(
imageData
);
}
}
private
native
Image
getImageForByteStream
(
byte
[]
bytes
);
private
native
Image
getImageForByteStream
(
byte
[]
bytes
);
...
...
src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java
浏览文件 @
33d7f099
...
@@ -38,8 +38,12 @@ import javax.swing.text.*;
...
@@ -38,8 +38,12 @@ import javax.swing.text.*;
import
javax.accessibility.*
;
import
javax.accessibility.*
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.Callable
;
import
sun.awt.dnd.*
;
import
sun.awt.dnd.*
;
import
sun.lwawt.LWComponentPeer
;
import
sun.lwawt.LWComponentPeer
;
import
sun.lwawt.LWWindowPeer
;
import
sun.lwawt.PlatformWindow
;
public
final
class
CDragSourceContextPeer
extends
SunDragSourceContextPeer
{
public
final
class
CDragSourceContextPeer
extends
SunDragSourceContextPeer
{
...
@@ -104,13 +108,8 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -104,13 +108,8 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
}
//It sure will be LWComponentPeer instance as rootComponent is a Window
//It sure will be LWComponentPeer instance as rootComponent is a Window
LWComponentPeer
peer
=
(
LWComponentPeer
)
rootComponent
.
getPeer
();
PlatformWindow
platformWindow
=
((
LWComponentPeer
)
rootComponent
.
getPeer
()).
getPlatformWindow
();
//Get a pointer to a native window
long
nativeViewPtr
=
CPlatformWindow
.
getNativeViewPtr
(
platformWindow
);
CPlatformWindow
platformWindow
=
(
CPlatformWindow
)
peer
.
getPlatformWindow
();
long
nativeWindowPtr
=
platformWindow
.
getNSWindowPtr
();
// Get drag cursor:
Cursor
cursor
=
this
.
getCursor
();
// If there isn't any drag image make one of default appearance:
// If there isn't any drag image make one of default appearance:
if
(
fDragImage
==
null
)
if
(
fDragImage
==
null
)
...
@@ -139,19 +138,15 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -139,19 +138,15 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
try
{
try
{
// Create native dragging source:
// Create native dragging source:
final
long
nativeDragSource
=
createNativeDragSource
(
component
,
peer
,
nativeWindo
wPtr
,
transferable
,
triggerEvent
,
final
long
nativeDragSource
=
createNativeDragSource
(
component
,
nativeVie
wPtr
,
transferable
,
triggerEvent
,
(
int
)
(
dragOrigin
.
getX
()),
(
int
)
(
dragOrigin
.
getY
()),
extModifiers
,
(
int
)
(
dragOrigin
.
getX
()),
(
int
)
(
dragOrigin
.
getY
()),
extModifiers
,
clickCount
,
timestamp
,
cursor
,
fDragCImage
,
dragImageOffset
.
x
,
dragImageOffset
.
y
,
clickCount
,
timestamp
,
fDragCImage
,
dragImageOffset
.
x
,
dragImageOffset
.
y
,
getDragSourceContext
().
getSourceActions
(),
formats
,
formatMap
);
getDragSourceContext
().
getSourceActions
(),
formats
,
formatMap
);
if
(
nativeDragSource
==
0
)
if
(
nativeDragSource
==
0
)
throw
new
InvalidDnDOperationException
(
""
);
throw
new
InvalidDnDOperationException
(
""
);
setNativeContext
(
nativeDragSource
);
setNativeContext
(
nativeDragSource
);
CCursorManager
.
getInstance
().
startDrag
(
(
int
)
(
dragOrigin
.
getX
()),
(
int
)
(
dragOrigin
.
getY
()));
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
...
@@ -160,6 +155,8 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -160,6 +155,8 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
SunDropTargetContextPeer
.
setCurrentJVMLocalSourceTransferable
(
transferable
);
SunDropTargetContextPeer
.
setCurrentJVMLocalSourceTransferable
(
transferable
);
CCursorManager
.
getInstance
().
setCursor
(
getCursor
());
// Create a new thread to run the dragging operation since it's synchronous, only coming back
// Create a new thread to run the dragging operation since it's synchronous, only coming back
// after dragging is finished. This leaves the AWT event thread free to handle AWT events which
// after dragging is finished. This leaves the AWT event thread free to handle AWT events which
// are posted during dragging by native event handlers.
// are posted during dragging by native event handlers.
...
@@ -173,8 +170,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -173,8 +170,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
CCursorManager
.
getInstance
().
stopDrag
();
releaseNativeDragSource
(
nativeDragSource
);
releaseNativeDragSource
(
nativeDragSource
);
fDragImage
=
null
;
fDragImage
=
null
;
if
(
fDragCImage
!=
null
)
{
if
(
fDragCImage
!=
null
)
{
...
@@ -189,8 +184,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -189,8 +184,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
CCursorManager
.
getInstance
().
stopDrag
();
final
long
nativeDragSource
=
getNativeContext
();
final
long
nativeDragSource
=
getNativeContext
();
setNativeContext
(
0
);
setNativeContext
(
0
);
releaseNativeDragSource
(
nativeDragSource
);
releaseNativeDragSource
(
nativeDragSource
);
...
@@ -416,13 +409,24 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -416,13 +409,24 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
final
int
modifiers
,
final
int
modifiers
,
final
int
x
,
final
int
y
)
{
final
int
x
,
final
int
y
)
{
CCursorManager
.
getInstance
().
updateDragPosition
(
x
,
y
);
try
{
Component
componentAt
=
LWCToolkit
.
invokeAndWait
(
new
Callable
<
Component
>()
{
@Override
public
Component
call
()
{
LWWindowPeer
mouseEventComponent
=
LWWindowPeer
.
getWindowUnderCursor
();
if
(
mouseEventComponent
==
null
)
{
return
null
;
}
Component
root
=
SwingUtilities
.
getRoot
(
mouseEventComponent
.
getTarget
());
if
(
root
==
null
)
{
return
null
;
}
Point
rootLocation
=
root
.
getLocationOnScreen
();
return
getDropTargetAt
(
root
,
x
-
rootLocation
.
x
,
y
-
rootLocation
.
y
);
}
},
getComponent
());
Component
rootComponent
=
SwingUtilities
.
getRoot
(
getComponent
());
if
(
rootComponent
!=
null
)
{
Point
componentPoint
=
new
Point
(
x
,
y
);
SwingUtilities
.
convertPointFromScreen
(
componentPoint
,
rootComponent
);
Component
componentAt
=
SwingUtilities
.
getDeepestComponentAt
(
rootComponent
,
componentPoint
.
x
,
componentPoint
.
y
);
if
(
componentAt
!=
hoveringComponent
)
{
if
(
componentAt
!=
hoveringComponent
)
{
if
(
hoveringComponent
!=
null
)
{
if
(
hoveringComponent
!=
null
)
{
dragExit
(
x
,
y
);
dragExit
(
x
,
y
);
...
@@ -432,20 +436,36 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -432,20 +436,36 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
}
hoveringComponent
=
componentAt
;
hoveringComponent
=
componentAt
;
}
}
}
postDragSourceDragEvent
(
targetActions
,
modifiers
,
x
,
y
,
postDragSourceDragEvent
(
targetActions
,
modifiers
,
x
,
y
,
DISPATCH_MOUSE_MOVED
);
DISPATCH_MOUSE_MOVED
);
}
catch
(
Exception
e
)
{
throw
new
InvalidDnDOperationException
(
"Failed to handle DragMouseMoved event"
);
}
}
}
/**
//Returns the first lightweight or heavyweight Component which has a dropTarget ready to accept the drag
* upcall from native code
//Should be called from the EventDispatchThread
*/
private
static
Component
getDropTargetAt
(
Component
root
,
int
x
,
int
y
)
{
private
void
dragEnter
(
final
int
targetActions
,
if
(!
root
.
contains
(
x
,
y
)
||
!
root
.
isEnabled
()
||
!
root
.
isVisible
())
{
final
int
modifiers
,
return
null
;
final
int
x
,
final
int
y
)
{
}
CCursorManager
.
getInstance
().
updateDragPosition
(
x
,
y
);
postDragSourceDragEvent
(
targetActions
,
modifiers
,
x
,
y
,
DISPATCH_ENTER
);
if
(
root
.
getDropTarget
()
!=
null
&&
root
.
getDropTarget
().
isActive
())
{
return
root
;
}
if
(
root
instanceof
Container
)
{
for
(
Component
comp
:
((
Container
)
root
).
getComponents
())
{
Point
loc
=
comp
.
getLocation
();
Component
dropTarget
=
getDropTargetAt
(
comp
,
x
-
loc
.
x
,
y
-
loc
.
y
);
if
(
dropTarget
!=
null
)
{
return
dropTarget
;
}
}
}
return
null
;
}
}
/**
/**
...
@@ -455,19 +475,15 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
...
@@ -455,19 +475,15 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
hoveringComponent
=
null
;
hoveringComponent
=
null
;
}
}
public
void
setCursor
(
Cursor
c
)
throws
InvalidDnDOperationException
{
@Override
// TODO : BG
protected
void
setNativeCursor
(
long
nativeCtxt
,
Cursor
c
,
int
cType
)
{
//AWTLockAccess.awtLock();
CCursorManager
.
getInstance
().
setCursor
(
c
);
super
.
setCursor
(
c
);
//AWTLockAccess.awtUnlock();
}
}
protected
native
void
setNativeCursor
(
long
nativeCtxt
,
Cursor
c
,
int
cType
);
// Native support:
// Native support:
private
native
long
createNativeDragSource
(
Component
component
,
ComponentPeer
peer
,
long
nativePeer
,
Transferable
transferable
,
private
native
long
createNativeDragSource
(
Component
component
,
long
nativePeer
,
Transferable
transferable
,
InputEvent
triggerEvent
,
int
dragPosX
,
int
dragPosY
,
int
extModifiers
,
int
clickCount
,
long
timestamp
,
InputEvent
triggerEvent
,
int
dragPosX
,
int
dragPosY
,
int
extModifiers
,
int
clickCount
,
long
timestamp
,
C
ursor
cursor
,
C
Image
nsDragImage
,
int
dragImageOffsetX
,
int
dragImageOffsetY
,
CImage
nsDragImage
,
int
dragImageOffsetX
,
int
dragImageOffsetY
,
int
sourceActions
,
long
[]
formats
,
Map
formatMap
);
int
sourceActions
,
long
[]
formats
,
Map
formatMap
);
private
native
void
doDragging
(
long
nativeDragSource
);
private
native
void
doDragging
(
long
nativeDragSource
);
...
...
src/macosx/classes/sun/lwawt/macosx/CDropTarget.java
浏览文件 @
33d7f099
...
@@ -30,6 +30,7 @@ import java.awt.peer.ComponentPeer;
...
@@ -30,6 +30,7 @@ import java.awt.peer.ComponentPeer;
import
java.awt.dnd.DropTarget
;
import
java.awt.dnd.DropTarget
;
import
sun.lwawt.LWComponentPeer
;
import
sun.lwawt.LWComponentPeer
;
import
sun.lwawt.PlatformWindow
;
public
final
class
CDropTarget
{
public
final
class
CDropTarget
{
...
@@ -50,23 +51,13 @@ public final class CDropTarget {
...
@@ -50,23 +51,13 @@ public final class CDropTarget {
fComponent
=
component
;
fComponent
=
component
;
fPeer
=
peer
;
fPeer
=
peer
;
// Make sure the drop target is a ComponentModel:
long
nativePeer
=
CPlatformWindow
.
getNativeViewPtr
(((
LWComponentPeer
)
peer
).
getPlatformWindow
());
if
(!(
peer
instanceof
LWComponentPeer
))
throw
new
IllegalArgumentException
(
"CDropTarget's peer must be a LWComponentPeer."
);
// Get model pointer (CButton.m and such) and its native peer:
LWComponentPeer
model
=
(
LWComponentPeer
)
peer
;
if
(
model
.
getPlatformWindow
()
instanceof
CPlatformWindow
)
{
CPlatformWindow
platformWindow
=
(
CPlatformWindow
)
model
.
getPlatformWindow
();
long
nativePeer
=
platformWindow
.
getNSWindowPtr
();
// Create native dragging destination:
// Create native dragging destination:
fNativeDropTarget
=
this
.
createNativeDropTarget
(
dropTarget
,
component
,
peer
,
nativePeer
);
fNativeDropTarget
=
this
.
createNativeDropTarget
(
dropTarget
,
component
,
peer
,
nativePeer
);
if
(
fNativeDropTarget
==
0
)
{
if
(
fNativeDropTarget
==
0
)
{
throw
new
IllegalStateException
(
"CDropTarget.createNativeDropTarget() failed."
);
throw
new
IllegalStateException
(
"CDropTarget.createNativeDropTarget() failed."
);
}
}
}
}
}
public
DropTarget
getDropTarget
()
{
public
DropTarget
getDropTarget
()
{
return
fDropTarget
;
return
fDropTarget
;
...
...
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
浏览文件 @
33d7f099
...
@@ -112,6 +112,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
...
@@ -112,6 +112,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
public
void
handleFocusEvent
(
boolean
focused
)
{
public
void
handleFocusEvent
(
boolean
focused
)
{
this
.
focused
=
focused
;
this
.
focused
=
focused
;
if
(
focused
)
{
// see bug 8010925
// we can't put this to handleWindowFocusEvent because
// it won't be invoced if focuse is moved to a html element
// on the same page.
CClipboard
clipboard
=
(
CClipboard
)
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
();
clipboard
.
checkPasteboard
();
}
if
(
parentWindowActive
)
{
if
(
parentWindowActive
)
{
responder
.
handleWindowFocusEvent
(
focused
,
null
);
responder
.
handleWindowFocusEvent
(
focused
,
null
);
}
}
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
浏览文件 @
33d7f099
...
@@ -875,6 +875,21 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
...
@@ -875,6 +875,21 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
}
}
}
}
/**
* Helper method to get a pointer to the native view from the PlatformWindow.
*/
static
long
getNativeViewPtr
(
PlatformWindow
platformWindow
)
{
long
nativePeer
=
0L
;
if
(
platformWindow
instanceof
CPlatformWindow
)
{
nativePeer
=
((
CPlatformWindow
)
platformWindow
).
getContentView
().
getAWTView
();
}
else
if
(
platformWindow
instanceof
CViewPlatformEmbeddedFrame
){
nativePeer
=
((
CViewPlatformEmbeddedFrame
)
platformWindow
).
getNSViewPtr
();
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported platformWindow implementation"
);
}
return
nativePeer
;
}
/*************************************************************
/*************************************************************
* Callbacks from the AWTWindow and AWTView objc classes.
* Callbacks from the AWTWindow and AWTView objc classes.
*************************************************************/
*************************************************************/
...
...
src/macosx/native/sun/awt/CClipboard.m
浏览文件 @
33d7f099
...
@@ -371,4 +371,21 @@ JNF_COCOA_EXIT(env);
...
@@ -371,4 +371,21 @@ JNF_COCOA_EXIT(env);
return
returnValue
;
return
returnValue
;
}
}
/*
* Class: sun_lwawt_macosx_CClipboard
* Method: checkPasteboard
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_sun_lwawt_macosx_CClipboard_checkPasteboard
(
JNIEnv
*
env
,
jobject
inObject
)
{
JNF_COCOA_ENTER
(
env
);
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
(){
[[
CClipboard
sharedClipboard
]
checkPasteboard
:
nil
];
}];
JNF_COCOA_EXIT
(
env
);
}
src/macosx/native/sun/awt/CDragSource.h
浏览文件 @
33d7f099
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
@private
@private
NSView
*
fView
;
NSView
*
fView
;
jobject
fComponent
;
jobject
fComponent
;
jobject
fComponentPeer
;
jobject
fDragSourceContextPeer
;
jobject
fDragSourceContextPeer
;
jobject
fTransferable
;
jobject
fTransferable
;
...
@@ -43,8 +42,6 @@
...
@@ -43,8 +42,6 @@
jint
fClickCount
;
jint
fClickCount
;
jint
fModifiers
;
jint
fModifiers
;
jobject
fCursor
;
NSImage
*
fDragImage
;
NSImage
*
fDragImage
;
NSPoint
fDragImageOffset
;
NSPoint
fDragImageOffset
;
...
@@ -59,12 +56,22 @@
...
@@ -59,12 +56,22 @@
+
(
CDragSource
*
)
currentDragSource
;
+
(
CDragSource
*
)
currentDragSource
;
// Common methods:
// Common methods:
-
(
id
)
init
:(
jobject
)
jdragsourcecontextpeer
component
:(
jobject
)
jcomponent
peer
:(
jobject
)
jpeer
control
:(
id
)
control
-
(
id
)
init
:(
jobject
)
jDragSourceContextPeer
transferable
:(
jobject
)
jtransferable
triggerEvent
:(
jobject
)
jtrigger
component
:(
jobject
)
jComponent
dragPosX
:(
jint
)
dragPosX
dragPosY
:(
jint
)
dragPosY
modifiers
:(
jint
)
extModifiers
clickCount
:(
jint
)
clickCount
timeStamp
:(
jlong
)
timeStamp
control
:(
id
)
control
cursor
:(
jobject
)
jcursor
transferable
:(
jobject
)
jTransferable
dragImage
:(
jobject
)
jnsdragimage
dragImageOffsetX
:(
jint
)
jdragimageoffsetx
dragImageOffsetY
:(
jint
)
jdragimageoffsety
triggerEvent
:(
jobject
)
jTrigger
sourceActions
:(
jint
)
jsourceactions
formats
:(
jlongArray
)
jformats
formatMap
:(
jobject
)
jformatmap
;
dragPosX
:(
jint
)
dragPosX
dragPosY
:(
jint
)
dragPosY
modifiers
:(
jint
)
extModifiers
clickCount
:(
jint
)
clickCount
timeStamp
:(
jlong
)
timeStamp
dragImage
:(
jobject
)
jDragImage
dragImageOffsetX
:(
jint
)
jDragImageOffsetX
dragImageOffsetY
:(
jint
)
jDragImageOffsetY
sourceActions
:(
jint
)
jSourceActions
formats
:(
jlongArray
)
jFormats
formatMap
:(
jobject
)
jFormatMap
;
-
(
void
)
removeFromView
:(
JNIEnv
*
)
env
;
-
(
void
)
removeFromView
:(
JNIEnv
*
)
env
;
...
...
src/macosx/native/sun/awt/CDragSource.m
浏览文件 @
33d7f099
...
@@ -84,12 +84,22 @@ static BOOL sNeedsEnter;
...
@@ -84,12 +84,22 @@ static BOOL sNeedsEnter;
return
sCurrentDragSource
;
return
sCurrentDragSource
;
}
}
-
(
id
)
init
:(
jobject
)
jdragsourcecontextpeer
component
:(
jobject
)
jcomponent
peer
:(
jobject
)
jpeer
control
:(
id
)
control
-
(
id
)
init
:(
jobject
)
jDragSourceContextPeer
transferable
:(
jobject
)
jtransferable
triggerEvent
:(
jobject
)
jtrigger
component
:(
jobject
)
jComponent
dragPosX
:(
jint
)
dragPosX
dragPosY
:(
jint
)
dragPosY
modifiers
:(
jint
)
extModifiers
clickCount
:(
jint
)
clickCount
control
:(
id
)
control
timeStamp
:(
jlong
)
timeStamp
cursor
:(
jobject
)
jcursor
transferable
:(
jobject
)
jTransferable
dragImage
:(
jobject
)
jnsdragimage
dragImageOffsetX
:(
jint
)
jdragimageoffsetx
dragImageOffsetY
:(
jint
)
jdragimageoffsety
triggerEvent
:(
jobject
)
jTrigger
sourceActions
:(
jint
)
jsourceactions
formats
:(
jlongArray
)
jformats
formatMap
:(
jobject
)
jformatmap
dragPosX
:(
jint
)
dragPosX
dragPosY
:(
jint
)
dragPosY
modifiers
:(
jint
)
extModifiers
clickCount
:(
jint
)
clickCount
timeStamp
:(
jlong
)
timeStamp
dragImage
:(
jobject
)
jDragImage
dragImageOffsetX
:(
jint
)
jDragImageOffsetX
dragImageOffsetY
:(
jint
)
jDragImageOffsetY
sourceActions
:(
jint
)
jSourceActions
formats
:(
jlongArray
)
jFormats
formatMap
:(
jobject
)
jFormatMap
{
{
self
=
[
super
init
];
self
=
[
super
init
];
DLog2
(
@"[CDragSource init]: %@
\n
"
,
self
);
DLog2
(
@"[CDragSource init]: %@
\n
"
,
self
);
...
@@ -100,27 +110,25 @@ static BOOL sNeedsEnter;
...
@@ -100,27 +110,25 @@ static BOOL sNeedsEnter;
// Construct the object if we have a valid model for it:
// Construct the object if we have a valid model for it:
if
(
control
!=
nil
)
{
if
(
control
!=
nil
)
{
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
fComponent
=
JNFNewGlobalRef
(
env
,
jcomponent
);
fComponent
=
JNFNewGlobalRef
(
env
,
jComponent
);
fComponentPeer
=
JNFNewGlobalRef
(
env
,
jpeer
);
fDragSourceContextPeer
=
JNFNewGlobalRef
(
env
,
jDragSourceContextPeer
);
fDragSourceContextPeer
=
JNFNewGlobalRef
(
env
,
jdragsourcecontextpeer
);
fTransferable
=
JNFNewGlobalRef
(
env
,
jtransferable
);
fTransferable
=
JNFNewGlobalRef
(
env
,
jTransferable
);
fTriggerEvent
=
JNFNewGlobalRef
(
env
,
jtrigger
);
fTriggerEvent
=
JNFNewGlobalRef
(
env
,
jTrigger
);
fCursor
=
JNFNewGlobalRef
(
env
,
jcursor
);
if
(
j
nsdragi
mage
)
{
if
(
j
DragI
mage
)
{
JNF_MEMBER_CACHE
(
nsImagePtr
,
CImageClass
,
"ptr"
,
"J"
);
JNF_MEMBER_CACHE
(
nsImagePtr
,
CImageClass
,
"ptr"
,
"J"
);
jlong
imgPtr
=
JNFGetLongField
(
env
,
j
nsdragi
mage
,
nsImagePtr
);
jlong
imgPtr
=
JNFGetLongField
(
env
,
j
DragI
mage
,
nsImagePtr
);
fDragImage
=
(
NSImage
*
)
jlong_to_ptr
(
imgPtr
);
// Double-casting prevents compiler 'd$|//
fDragImage
=
(
NSImage
*
)
jlong_to_ptr
(
imgPtr
);
// Double-casting prevents compiler 'd$|//
[
fDragImage
retain
];
[
fDragImage
retain
];
}
}
fDragImageOffset
=
NSMakePoint
(
j
dragimageoffsetx
,
jdragimageoffsety
);
fDragImageOffset
=
NSMakePoint
(
j
DragImageOffsetX
,
jDragImageOffsetY
);
fSourceActions
=
j
sourcea
ctions
;
fSourceActions
=
j
SourceA
ctions
;
fFormats
=
JNFNewGlobalRef
(
env
,
j
f
ormats
);
fFormats
=
JNFNewGlobalRef
(
env
,
j
F
ormats
);
fFormatMap
=
JNFNewGlobalRef
(
env
,
j
formatm
ap
);
fFormatMap
=
JNFNewGlobalRef
(
env
,
j
FormatM
ap
);
fTriggerEventTimeStamp
=
timeStamp
;
fTriggerEventTimeStamp
=
timeStamp
;
fDragPos
=
NSMakePoint
(
dragPosX
,
dragPosY
);
fDragPos
=
NSMakePoint
(
dragPosX
,
dragPosY
);
...
@@ -129,9 +137,8 @@ static BOOL sNeedsEnter;
...
@@ -129,9 +137,8 @@ static BOOL sNeedsEnter;
// Set this object as a dragging source:
// Set this object as a dragging source:
AWTView
*
awtView
=
[((
NSWindow
*
)
control
)
contentView
];
fView
=
[(
AWTView
*
)
control
retain
];
fView
=
[
awtView
retain
];
[
fView
setDragSource
:
self
];
[
awtView
setDragSource
:
self
];
// Let AWTEvent know Java drag is getting underway:
// Let AWTEvent know Java drag is getting underway:
[
NSEvent
javaDraggingBegin
];
[
NSEvent
javaDraggingBegin
];
...
@@ -158,11 +165,6 @@ static BOOL sNeedsEnter;
...
@@ -158,11 +165,6 @@ static BOOL sNeedsEnter;
fComponent
=
NULL
;
fComponent
=
NULL
;
}
}
if
(
fComponentPeer
!=
NULL
)
{
JNFDeleteGlobalRef
(
env
,
fComponentPeer
);
fComponentPeer
=
NULL
;
}
if
(
fDragSourceContextPeer
!=
NULL
)
{
if
(
fDragSourceContextPeer
!=
NULL
)
{
JNFDeleteGlobalRef
(
env
,
fDragSourceContextPeer
);
JNFDeleteGlobalRef
(
env
,
fDragSourceContextPeer
);
fDragSourceContextPeer
=
NULL
;
fDragSourceContextPeer
=
NULL
;
...
@@ -178,11 +180,6 @@ static BOOL sNeedsEnter;
...
@@ -178,11 +180,6 @@ static BOOL sNeedsEnter;
fTriggerEvent
=
NULL
;
fTriggerEvent
=
NULL
;
}
}
if
(
fCursor
!=
NULL
)
{
JNFDeleteGlobalRef
(
env
,
fCursor
);
fCursor
=
NULL
;
}
if
(
fFormats
!=
NULL
)
{
if
(
fFormats
!=
NULL
)
{
JNFDeleteGlobalRef
(
env
,
fFormats
);
JNFDeleteGlobalRef
(
env
,
fFormats
);
fFormats
=
NULL
;
fFormats
=
NULL
;
...
@@ -586,11 +583,6 @@ static BOOL sNeedsEnter;
...
@@ -586,11 +583,6 @@ static BOOL sNeedsEnter;
{
{
AWT_ASSERT_NOT_APPKIT_THREAD
;
AWT_ASSERT_NOT_APPKIT_THREAD
;
// Set the drag cursor (or not 3839999)
//JNIEnv *env = [ThreadUtilities getJNIEnv];
//jobject gCursor = JNFNewGlobalRef(env, fCursor);
//[EventFactory setJavaCursor:gCursor withEnv:env];
[
self
performSelectorOnMainThread
:
@selector
(
doDrag
)
withObject
:
nil
waitUntilDone
:
YES
];
// AWT_THREADING Safe (called from unique asynchronous thread)
[
self
performSelectorOnMainThread
:
@selector
(
doDrag
)
withObject
:
nil
waitUntilDone
:
YES
];
// AWT_THREADING Safe (called from unique asynchronous thread)
}
}
...
...
src/macosx/native/sun/awt/CDragSourceContextPeer.m
浏览文件 @
33d7f099
...
@@ -34,12 +34,13 @@
...
@@ -34,12 +34,13 @@
/*
/*
* Class: sun_lwawt_macosx_CDragSourceContextPeer
* Class: sun_lwawt_macosx_CDragSourceContextPeer
* Method: createNativeDragSource
* Method: createNativeDragSource
* Signature: (Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJLjava/awt/Cursor;IJIII[JLjava/util/Map;)J
* Signature: (Ljava/awt/Component;JLjava/awt/datatransfer/Transferable;
Ljava/awt/event/InputEvent;IIIIJIJIII[JLjava/util/Map;)J
*/
*/
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
(JNIEnv *env, jobject jthis, jobject jcomponent, j
object jpeer, j
long jnativepeer, jobject jtransferable,
(JNIEnv *env, jobject jthis, jobject jcomponent, jlong jnativepeer, jobject jtransferable,
jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
jobject j
cursor, jobject j
nsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
jint jsourceactions, jlongArray jformats, jobject jformatmap)
jint jsourceactions, jlongArray jformats, jobject jformatmap)
{
{
id controlObj = (id) jlong_to_ptr(jnativepeer);
id controlObj = (id) jlong_to_ptr(jnativepeer);
...
@@ -47,12 +48,22 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativ
...
@@ -47,12 +48,22 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativ
JNF_COCOA_ENTER(env);
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj
dragSource = [[CDragSource alloc] init:jthis
transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
component:jcomponent
dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
control:controlObj
cursor:jcursor dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx
transferable:jtransferable
dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions
triggerEvent:jtrigger
formats:jformats formatMap:jformatmap];
dragPosX:jdragposx
dragPosY:jdragposy
modifiers:jextmodifiers
clickCount:jclickcount
timeStamp:jtimestamp
dragImage:jnsdragimage
dragImageOffsetX:jdragimageoffsetx
dragImageOffsetY:jdragimageoffsety
sourceActions:jsourceactions
formats:jformats
formatMap:jformatmap];
}];
}];
JNF_COCOA_EXIT(env);
JNF_COCOA_EXIT(env);
...
@@ -94,19 +105,3 @@ JNF_COCOA_ENTER(env);
...
@@ -94,19 +105,3 @@ JNF_COCOA_ENTER(env);
[dragSource removeFromView:env];
[dragSource removeFromView:env];
JNF_COCOA_EXIT(env);
JNF_COCOA_EXIT(env);
}
}
/*
* Class: sun_lwawt_macosx_CDragSourceContextPeer
* Method: setNativeCursor
* Signature: (JLjava/awt/Cursor;I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor
(JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype)
{
//AWT_ASSERT_NOT_APPKIT_THREAD;
//JNF_COCOA_ENTER(env);
// jobject gCursor = JNFNewGlobalRef(env, jcursor);
// [EventFactory setJavaCursor:gCursor withEnv:env];
//JNF_COCOA_EXIT(env);
}
src/macosx/native/sun/awt/CDropTarget.m
浏览文件 @
33d7f099
...
@@ -81,9 +81,8 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
...
@@ -81,9 +81,8 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
fComponent
=
JNFNewGlobalRef
(
env
,
jcomponent
);
fComponent
=
JNFNewGlobalRef
(
env
,
jcomponent
);
fDropTarget
=
JNFNewGlobalRef
(
env
,
jdropTarget
);
fDropTarget
=
JNFNewGlobalRef
(
env
,
jdropTarget
);
AWTView
*
awtView
=
[((
NSWindow
*
)
control
)
contentView
];
fView
=
[((
AWTView
*
)
control
)
retain
];
fView
=
[
awtView
retain
];
[
fView
setDropTarget
:
self
];
[
awtView
setDropTarget
:
self
];
}
else
{
}
else
{
...
@@ -177,6 +176,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
...
@@ -177,6 +176,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
{
{
DLog2
(
@"[CDropTarget dealloc]: %@
\n
"
,
self
);
DLog2
(
@"[CDropTarget dealloc]: %@
\n
"
,
self
);
if
(
sCurrentDropTarget
==
self
)
{
sCurrentDropTarget
=
nil
;
}
[
fView
release
];
[
fView
release
];
fView
=
nil
;
fView
=
nil
;
...
@@ -490,7 +493,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
...
@@ -490,7 +493,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
JNF_MEMBER_CACHE
(
handleEnterMessageMethod
,
jc_CDropTargetContextPeer
,
"handleEnterMessage"
,
"(Ljava/awt/Component;IIII[JJ)I"
);
JNF_MEMBER_CACHE
(
handleEnterMessageMethod
,
jc_CDropTargetContextPeer
,
"handleEnterMessage"
,
"(Ljava/awt/Component;IIII[JJ)I"
);
if
(
sDraggingError
==
FALSE
)
{
if
(
sDraggingError
==
FALSE
)
{
// Double-casting self gets rid of 'different size' compiler warning:
// Double-casting self gets rid of 'different size' compiler warning:
actions
=
JNFCallIntMethod
(
env
,
fDropTargetContextPeer
,
handleEnterMessageMethod
,
fComponent
,
(
jint
)
javaLocation
.
x
,
(
jint
)
javaLocation
.
y
,
dropAction
,
actions
,
formats
,
ptr_to_jlong
(
self
));
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
actions
=
JNFCallIntMethod
(
env
,
fDropTargetContextPeer
,
handleEnterMessageMethod
,
fComponent
,
(
jint
)
javaLocation
.
x
,
(
jint
)
javaLocation
.
y
,
dropAction
,
actions
,
formats
,
ptr_to_jlong
(
self
));
}
}
if
(
sDraggingError
==
FALSE
)
{
if
(
sDraggingError
==
FALSE
)
{
...
@@ -510,11 +516,6 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
...
@@ -510,11 +516,6 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
// Remember the dragOp for no-op'd update messages:
// Remember the dragOp for no-op'd update messages:
sUpdateOperation
=
dragOp
;
sUpdateOperation
=
dragOp
;
}
}
// If we are in the same process as the sender, make the sender post the appropriate message
if
(
sender
)
{
[[
CDragSource
currentDragSource
]
postDragEnter
];
}
}
}
// 9-11-02 Note: the native event thread would not handle an exception gracefully:
// 9-11-02 Note: the native event thread would not handle an exception gracefully:
...
@@ -608,11 +609,9 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
...
@@ -608,11 +609,9 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
JNF_MEMBER_CACHE
(
handleExitMessageMethod
,
jc_CDropTargetContextPeer
,
"handleExitMessage"
,
"(Ljava/awt/Component;J)V"
);
JNF_MEMBER_CACHE
(
handleExitMessageMethod
,
jc_CDropTargetContextPeer
,
"handleExitMessage"
,
"(Ljava/awt/Component;J)V"
);
if
(
sDraggingError
==
FALSE
)
{
if
(
sDraggingError
==
FALSE
)
{
DLog3
(
@" - dragExit: loc native %f, %f
\n
"
,
sDraggingLocation
.
x
,
sDraggingLocation
.
y
);
DLog3
(
@" - dragExit: loc native %f, %f
\n
"
,
sDraggingLocation
.
x
,
sDraggingLocation
.
y
);
JNFCallVoidMethod
(
env
,
fDropTargetContextPeer
,
handleExitMessageMethod
,
fComponent
,
ptr_to_jlong
(
self
));
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
// If we are in the same process as the sender, make the sender post the appropriate message
JNFCallVoidMethod
(
env
,
fDropTargetContextPeer
,
if
(
sender
)
{
handleExitMessageMethod
,
fComponent
,
ptr_to_jlong
(
self
));
[[
CDragSource
currentDragSource
]
postDragExit
];
}
}
}
// 5-27-03 Note: [Radar 3270455]
// 5-27-03 Note: [Radar 3270455]
...
...
src/macosx/native/sun/awt/CTextPipe.m
浏览文件 @
33d7f099
...
@@ -501,10 +501,22 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc
...
@@ -501,10 +501,22 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc
int
*
uniChars
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
length
);
int
*
uniChars
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
length
);
CGSize
*
advances
=
(
CGSize
*
)
malloc
(
sizeof
(
CGSize
)
*
length
);
CGSize
*
advances
=
(
CGSize
*
)
malloc
(
sizeof
(
CGSize
)
*
length
);
if
(
glyphs
==
NULL
||
advances
==
NULL
)
if
(
glyphs
==
NULL
||
uniChars
==
NULL
||
advances
==
NULL
)
{
{
(
*
env
)
->
DeleteLocalRef
(
env
,
glyphsArray
);
(
*
env
)
->
DeleteLocalRef
(
env
,
glyphsArray
);
[
NSException
raise
:
NSMallocException
format
:
@"%s-%s:%d"
,
THIS_FILE
,
__FUNCTION__
,
__LINE__
];
[
NSException
raise
:
NSMallocException
format
:
@"%s-%s:%d"
,
THIS_FILE
,
__FUNCTION__
,
__LINE__
];
if
(
glyphs
)
{
free
(
glyphs
);
}
if
(
uniChars
)
{
free
(
uniChars
);
}
if
(
advances
)
{
free
(
advances
);
}
return
;
return
;
}
}
...
...
src/share/classes/java/awt/datatransfer/DataFlavor.java
浏览文件 @
33d7f099
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
package
java.awt.datatransfer
;
package
java.awt.datatransfer
;
import
java.awt.Toolkit
;
import
java.io.*
;
import
java.io.*
;
import
java.nio.*
;
import
java.nio.*
;
import
java.util.*
;
import
java.util.*
;
...
@@ -162,6 +161,18 @@ public class DataFlavor implements Externalizable, Cloneable {
...
@@ -162,6 +161,18 @@ public class DataFlavor implements Externalizable, Cloneable {
}
}
}
}
/*
* private initializer
*/
static
private
DataFlavor
initHtmlDataFlavor
(
String
htmlFlavorType
)
{
try
{
return
new
DataFlavor
(
"text/html; class=java.lang.String;document="
+
htmlFlavorType
+
";charset=Unicode"
);
}
catch
(
Exception
e
)
{
return
null
;
}
}
/**
/**
* The <code>DataFlavor</code> representing a Java Unicode String class,
* The <code>DataFlavor</code> representing a Java Unicode String class,
* where:
* where:
...
@@ -245,6 +256,46 @@ public class DataFlavor implements Externalizable, Cloneable {
...
@@ -245,6 +256,46 @@ public class DataFlavor implements Externalizable, Cloneable {
*/
*/
public
static
final
String
javaRemoteObjectMimeType
=
"application/x-java-remote-object"
;
public
static
final
String
javaRemoteObjectMimeType
=
"application/x-java-remote-object"
;
/**
* Represents a piece of an HTML markup. The markup consists of the part
* selected on the source side. Therefore some tags in the markup may be
* unpaired. If the flavor is used to represent the data in
* a {@link Transferable} instance, no additional changes will be made.
* This DataFlavor instance represents the same HTML markup as DataFlavor
* instances which content MIME type does not contain document parameter
* and representation class is the String class.
* <pre>
* representationClass = String
* mimeType = "text/html"
* </pre>
*/
public
static
DataFlavor
selectionHtmlFlavor
=
initHtmlDataFlavor
(
"selection"
);
/**
* Represents a piece of an HTML markup. If possible, the markup received
* from a native system is supplemented with pair tags to be
* a well-formed HTML markup. If the flavor is used to represent the data in
* a {@link Transferable} instance, no additional changes will be made.
* <pre>
* representationClass = String
* mimeType = "text/html"
* </pre>
*/
public
static
DataFlavor
fragmentHtmlFlavor
=
initHtmlDataFlavor
(
"fragment"
);
/**
* Represents a piece of an HTML markup. If possible, the markup
* received from a native system is supplemented with additional
* tags to make up a well-formed HTML document. If the flavor is used to
* represent the data in a {@link Transferable} instance,
* no additional changes will be made.
* <pre>
* representationClass = String
* mimeType = "text/html"
* </pre>
*/
public
static
DataFlavor
allHtmlFlavor
=
initHtmlDataFlavor
(
"all"
);
/**
/**
* Constructs a new <code>DataFlavor</code>. This constructor is
* Constructs a new <code>DataFlavor</code>. This constructor is
* provided only for the purpose of supporting the
* provided only for the purpose of supporting the
...
@@ -949,8 +1000,8 @@ public class DataFlavor implements Externalizable, Cloneable {
...
@@ -949,8 +1000,8 @@ public class DataFlavor implements Externalizable, Cloneable {
return
false
;
return
false
;
}
}
if
(
"text"
.
equals
(
getPrimaryType
())
&&
if
(
"text"
.
equals
(
getPrimaryType
())
)
{
DataTransferer
.
doesSubtypeSupportCharset
(
this
)
&&
if
(
DataTransferer
.
doesSubtypeSupportCharset
(
this
)
&&
representationClass
!=
null
&&
representationClass
!=
null
&&
!(
isRepresentationClassReader
()
||
!(
isRepresentationClassReader
()
||
String
.
class
.
equals
(
representationClass
)
||
String
.
class
.
equals
(
representationClass
)
||
...
@@ -971,6 +1022,17 @@ public class DataFlavor implements Externalizable, Cloneable {
...
@@ -971,6 +1022,17 @@ public class DataFlavor implements Externalizable, Cloneable {
}
}
}
}
}
}
if
(
"html"
.
equals
(
getSubType
())
&&
this
.
getParameter
(
"document"
)
!=
null
)
{
if
(!
this
.
getParameter
(
"document"
).
equals
(
that
.
getParameter
(
"document"
)))
{
return
false
;
}
}
}
}
}
return
true
;
return
true
;
...
...
src/share/classes/java/awt/datatransfer/SystemFlavorMap.java
浏览文件 @
33d7f099
...
@@ -41,7 +41,7 @@ import java.util.ArrayList;
...
@@ -41,7 +41,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Linked
Lis
t
;
import
java.util.Linked
HashSe
t
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -100,6 +100,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -100,6 +100,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
*/
private
static
final
String
TEXT_PLAIN_BASE_TYPE
=
"text/plain"
;
private
static
final
String
TEXT_PLAIN_BASE_TYPE
=
"text/plain"
;
/**
* A String representing text/html MIME type.
*/
private
static
final
String
HTML_TEXT_BASE_TYPE
=
"text/html"
;
/**
/**
* This constant is passed to flavorToNativeLookup() to indicate that a
* This constant is passed to flavorToNativeLookup() to indicate that a
* a native should be synthesized, stored, and returned by encoding the
* a native should be synthesized, stored, and returned by encoding the
...
@@ -113,7 +118,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -113,7 +118,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* text DataFlavors).
* text DataFlavors).
* Do not use the field directly, use getNativeToFlavor() instead.
* Do not use the field directly, use getNativeToFlavor() instead.
*/
*/
private
Map
nativeToFlavor
=
new
HashMap
();
private
final
Map
<
String
,
List
<
DataFlavor
>>
nativeToFlavor
=
new
HashMap
<>
();
/**
/**
* Accessor to nativeToFlavor map. Since we use lazy initialization we must
* Accessor to nativeToFlavor map. Since we use lazy initialization we must
...
@@ -122,7 +127,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -122,7 +127,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*
*
* @return nativeToFlavor
* @return nativeToFlavor
*/
*/
private
Map
getNativeToFlavor
()
{
private
Map
<
String
,
List
<
DataFlavor
>>
getNativeToFlavor
()
{
if
(!
isMapInitialized
)
{
if
(!
isMapInitialized
)
{
initSystemFlavorMap
();
initSystemFlavorMap
();
}
}
...
@@ -134,7 +139,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -134,7 +139,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* native Strings.
* native Strings.
* Do not use the field directly, use getFlavorToNative() instead.
* Do not use the field directly, use getFlavorToNative() instead.
*/
*/
private
Map
flavorToNative
=
new
HashMap
();
private
final
Map
flavorToNative
=
new
HashMap
();
/**
/**
* Accessor to flavorToNative map. Since we use lazy initialization we must
* Accessor to flavorToNative map. Since we use lazy initialization we must
...
@@ -421,14 +426,17 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -421,14 +426,17 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
}
}
}
// For text/* flavors, store mappings in separate maps to
final
LinkedHashSet
<
DataFlavor
>
dfs
=
new
LinkedHashSet
<>();
// enable dynamic mapping generation at a run-time.
dfs
.
add
(
flavor
);
if
(
"text"
.
equals
(
flavor
.
getPrimaryType
()))
{
if
(
"text"
.
equals
(
flavor
.
getPrimaryType
()))
{
store
(
value
,
key
,
getFlavorToNative
());
dfs
.
addAll
(
convertMimeTypeToDataFlavors
(
value
));
store
(
key
,
value
,
getNativeToFlavor
());
}
}
else
{
store
(
flavor
,
key
,
getFlavorToNative
());
for
(
DataFlavor
df
:
dfs
)
{
store
(
key
,
flavor
,
getNativeToFlavor
());
store
(
df
,
key
,
getFlavorToNative
());
store
(
key
,
df
,
getNativeToFlavor
());
}
}
}
}
}
}
...
@@ -530,7 +538,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -530,7 +538,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* only if the specified native is encoded as a Java MIME type.
* only if the specified native is encoded as a Java MIME type.
*/
*/
private
List
nativeToFlavorLookup
(
String
nat
)
{
private
List
nativeToFlavorLookup
(
String
nat
)
{
List
flavors
=
(
List
)
getNativeToFlavor
().
get
(
nat
);
List
<
DataFlavor
>
flavors
=
getNativeToFlavor
().
get
(
nat
);
if
(
nat
!=
null
&&
!
disabledMappingGenerationKeys
.
contains
(
nat
))
{
if
(
nat
!=
null
&&
!
disabledMappingGenerationKeys
.
contains
(
nat
))
{
DataTransferer
transferer
=
DataTransferer
.
getInstance
();
DataTransferer
transferer
=
DataTransferer
.
getInstance
();
...
@@ -625,7 +633,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -625,7 +633,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
getNativesForFlavorCache
.
remove
(
flav
);
getNativesForFlavorCache
.
remove
(
flav
);
getNativesForFlavorCache
.
remove
(
null
);
getNativesForFlavorCache
.
remove
(
null
);
List
flavors
=
(
List
)
getNativeToFlavor
().
get
(
encoded
);
List
<
DataFlavor
>
flavors
=
getNativeToFlavor
().
get
(
encoded
);
if
(
flavors
==
null
)
{
if
(
flavors
==
null
)
{
flavors
=
new
ArrayList
(
1
);
flavors
=
new
ArrayList
(
1
);
getNativeToFlavor
().
put
(
encoded
,
flavors
);
getNativeToFlavor
().
put
(
encoded
,
flavors
);
...
@@ -681,7 +689,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -681,7 +689,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
}
if
(
flav
==
null
)
{
if
(
flav
==
null
)
{
retval
=
new
ArrayList
(
getNativeToFlavor
().
keySet
());
retval
=
new
ArrayList
<
String
>
(
getNativeToFlavor
().
keySet
());
}
else
if
(
disabledMappingGenerationKeys
.
contains
(
flav
))
{
}
else
if
(
disabledMappingGenerationKeys
.
contains
(
flav
))
{
// In this case we shouldn't synthesize a native for this flavor,
// In this case we shouldn't synthesize a native for this flavor,
// since its mappings were explicitly specified.
// since its mappings were explicitly specified.
...
@@ -809,140 +817,162 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
...
@@ -809,140 +817,162 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
}
}
}
LinkedList
retval
=
new
LinkedList
();
final
LinkedHashSet
<
DataFlavor
>
returnValue
=
new
LinkedHashSet
<>();
if
(
nat
==
null
)
{
if
(
nat
==
null
)
{
List
natives
=
getNativesForFlavor
(
null
);
final
List
<
String
>
natives
=
getNativesForFlavor
(
null
);
HashSet
dups
=
new
HashSet
(
natives
.
size
());
for
(
Iterator
natives_iter
=
natives
.
iterator
();
for
(
String
n
:
natives
)
natives_iter
.
hasNext
();
)
{
{
List
flavors
=
final
List
<
DataFlavor
>
flavors
=
getFlavorsForNative
(
n
);
getFlavorsForNative
((
String
)
natives_iter
.
next
());
for
(
Iterator
flavors_iter
=
flavors
.
iterator
();
for
(
DataFlavor
df
:
flavors
)
flavors_iter
.
hasNext
();
)
{
{
Object
flavor
=
flavors_iter
.
next
();
returnValue
.
add
(
df
);
if
(
dups
.
add
(
flavor
))
{
retval
.
add
(
flavor
);
}
}
}
}
}
}
else
{
}
else
{
List
flavors
=
nativeToFlavorLookup
(
nat
);
final
List
<
DataFlavor
>
flavors
=
nativeToFlavorLookup
(
nat
);
if
(
disabledMappingGenerationKeys
.
contains
(
nat
))
{
if
(
disabledMappingGenerationKeys
.
contains
(
nat
))
{
return
flavors
;
return
flavors
;
}
}
HashSet
dups
=
new
HashSet
(
flavors
.
size
());
final
List
<
DataFlavor
>
flavorsAndBaseTypes
=
nativeToFlavorLookup
(
nat
);
List
flavorsAndbaseTypes
=
nativeToFlavorLookup
(
nat
);
for
(
DataFlavor
df
:
flavorsAndBaseTypes
)
{
returnValue
.
add
(
df
);
if
(
"text"
.
equals
(
df
.
getPrimaryType
()))
{
try
{
returnValue
.
addAll
(
convertMimeTypeToDataFlavors
(
new
MimeType
(
df
.
getMimeType
()
).
getBaseType
()));
}
catch
(
MimeTypeParseException
e
)
{
e
.
printStackTrace
();
}
}
}
}
final
ArrayList
arrayList
=
new
ArrayList
(
returnValue
);
getFlavorsForNativeCache
.
put
(
nat
,
new
SoftReference
(
arrayList
));
return
(
List
)
arrayList
.
clone
();
}
private
static
LinkedHashSet
<
DataFlavor
>
convertMimeTypeToDataFlavors
(
final
String
baseType
)
{
final
LinkedHashSet
<
DataFlavor
>
returnValue
=
new
LinkedHashSet
<
DataFlavor
>();
for
(
Iterator
flavorsAndbaseTypes_iter
=
flavorsAndbaseTypes
.
iterator
();
flavorsAndbaseTypes_iter
.
hasNext
();
)
{
Object
value
=
flavorsAndbaseTypes_iter
.
next
();
if
(
value
instanceof
String
)
{
String
baseType
=
(
String
)
value
;
String
subType
=
null
;
String
subType
=
null
;
try
{
try
{
MimeType
mimeType
=
new
MimeType
(
baseType
);
final
MimeType
mimeType
=
new
MimeType
(
baseType
);
subType
=
mimeType
.
getSubType
();
subType
=
mimeType
.
getSubType
();
}
catch
(
MimeTypeParseException
mtpe
)
{
}
catch
(
MimeTypeParseException
mtpe
)
{
// Cannot happen, since we checked all mappings
// Cannot happen, since we checked all mappings
// on load from flavormap.properties.
// on load from flavormap.properties.
assert
(
false
);
assert
(
false
);
}
}
if
(
DataTransferer
.
doesSubtypeSupportCharset
(
subType
,
null
))
{
if
(
DataTransferer
.
doesSubtypeSupportCharset
(
subType
,
null
))
{
if
(
TEXT_PLAIN_BASE_TYPE
.
equals
(
baseType
)
&&
if
(
TEXT_PLAIN_BASE_TYPE
.
equals
(
baseType
))
dups
.
add
(
DataFlavor
.
stringFlavor
))
{
{
retval
.
add
(
DataFlavor
.
stringFlavor
);
returnValue
.
add
(
DataFlavor
.
stringFlavor
);
}
}
for
(
int
i
=
0
;
i
<
UNICODE_TEXT_CLASSES
.
length
;
i
++)
{
for
(
String
unicodeClassName
:
UNICODE_TEXT_CLASSES
)
{
final
String
mimeType
=
baseType
+
";charset=Unicode;class="
+
unicodeClassName
;
final
LinkedHashSet
<
String
>
mimeTypes
=
handleHtmlMimeTypes
(
baseType
,
mimeType
);
for
(
String
mt
:
mimeTypes
)
{
DataFlavor
toAdd
=
null
;
DataFlavor
toAdd
=
null
;
try
{
try
{
toAdd
=
new
DataFlavor
toAdd
=
new
DataFlavor
(
mt
);
(
baseType
+
";charset=Unicode;class="
+
UNICODE_TEXT_CLASSES
[
i
]);
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
}
if
(
dups
.
add
(
toAdd
))
{
returnValue
.
add
(
toAdd
);
retval
.
add
(
toAdd
);
}
}
}
}
for
(
Iterator
charset_iter
=
for
(
String
charset
:
DataTransferer
.
standardEncodings
())
{
DataTransferer
.
standardEncodings
();
charset_iter
.
hasNext
();
)
{
String
charset
=
(
String
)
charset_iter
.
next
();
for
(
int
i
=
0
;
i
<
ENCODED_TEXT_CLASSES
.
length
;
for
(
String
encodedTextClass
:
ENCODED_TEXT_CLASSES
)
{
i
++)
final
String
mimeType
=
{
baseType
+
";charset="
+
charset
+
DataFlavor
toAdd
=
null
;
";class="
+
encodedTextClass
;
try
{
toAdd
=
new
DataFlavor
final
LinkedHashSet
<
String
>
mimeTypes
=
(
baseType
+
";charset="
+
charset
+
handleHtmlMimeTypes
(
baseType
,
mimeType
);
";class="
+
ENCODED_TEXT_CLASSES
[
i
]);
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
for
(
String
mt
:
mimeTypes
)
{
DataFlavor
df
=
null
;
try
{
df
=
new
DataFlavor
(
mt
);
// Check for equality to plainTextFlavor so
// Check for equality to plainTextFlavor so
// that we can ensure that the exact charset of
// that we can ensure that the exact charset of
// plainTextFlavor, not the canonical charset
// plainTextFlavor, not the canonical charset
// or another equivalent charset with a
// or another equivalent charset with a
// different name, is used.
// different name, is used.
if
(
toAdd
.
equals
(
DataFlavor
.
plainTextFlavor
))
{
if
(
df
.
equals
(
DataFlavor
.
plainTextFlavor
))
{
toAdd
=
DataFlavor
.
plainTextFlavor
;
df
=
DataFlavor
.
plainTextFlavor
;
}
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
}
if
(
dups
.
add
(
toAdd
))
{
returnValue
.
add
(
df
);
retval
.
add
(
toAdd
);
}
}
}
}
}
}
if
(
TEXT_PLAIN_BASE_TYPE
.
equals
(
baseType
)
&&
if
(
TEXT_PLAIN_BASE_TYPE
.
equals
(
baseType
))
dups
.
add
(
DataFlavor
.
plainTextFlavor
))
{
{
retval
.
add
(
DataFlavor
.
plainTextFlavor
);
returnValue
.
add
(
DataFlavor
.
plainTextFlavor
);
}
}
}
else
{
}
else
{
// Non-charset text natives should be treated as
// Non-charset text natives should be treated as
// opaque, 8-bit data in any of its various
// opaque, 8-bit data in any of its various
// representations.
// representations.
for
(
int
i
=
0
;
i
<
ENCODED_TEXT_CLASSES
.
length
;
i
++
)
{
for
(
String
encodedTextClassName
:
ENCODED_TEXT_CLASSES
)
{
DataFlavor
toAdd
=
null
;
DataFlavor
toAdd
=
null
;
try
{
try
{
toAdd
=
new
DataFlavor
(
baseType
+
toAdd
=
new
DataFlavor
(
baseType
+
";class="
+
ENCODED_TEXT_CLASSES
[
i
]
);
";class="
+
encodedTextClassName
);
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
catch
(
ClassNotFoundException
cannotHappen
)
{
}
}
returnValue
.
add
(
toAdd
);
if
(
dups
.
add
(
toAdd
))
{
retval
.
add
(
toAdd
);
}
}
}
}
return
returnValue
;
}
}
}
else
{
DataFlavor
flavor
=
(
DataFlavor
)
value
;
private
static
final
String
[]
htmlDocumntTypes
=
if
(
dups
.
add
(
flavor
))
{
new
String
[]
{
"all"
,
"selection"
,
"fragment"
};
retval
.
add
(
flavor
);
}
private
static
LinkedHashSet
<
String
>
handleHtmlMimeTypes
(
}
String
baseType
,
String
mimeType
)
{
LinkedHashSet
<
String
>
returnValues
=
new
LinkedHashSet
<>();
if
(
HTML_TEXT_BASE_TYPE
.
equals
(
baseType
))
{
for
(
String
documentType
:
htmlDocumntTypes
)
{
returnValues
.
add
(
mimeType
+
";document="
+
documentType
);
}
}
}
else
{
returnValues
.
add
(
mimeType
);
}
}
ArrayList
arrayList
=
new
ArrayList
(
retval
);
return
returnValues
;
getFlavorsForNativeCache
.
put
(
nat
,
new
SoftReference
(
arrayList
));
return
(
List
)
arrayList
.
clone
();
}
}
/**
/**
...
...
src/share/classes/java/awt/dnd/InvalidDnDOperationException.java
浏览文件 @
33d7f099
...
@@ -36,7 +36,7 @@ package java.awt.dnd;
...
@@ -36,7 +36,7 @@ package java.awt.dnd;
public
class
InvalidDnDOperationException
extends
IllegalStateException
{
public
class
InvalidDnDOperationException
extends
IllegalStateException
{
private
static
final
long
serialVersionUID
=
51566765002478162
78L
;
private
static
final
long
serialVersionUID
=
-
60625687411939566
78L
;
static
private
String
dft_msg
=
"The operation requested cannot be performed by the DnD system since it is not in the appropriate state"
;
static
private
String
dft_msg
=
"The operation requested cannot be performed by the DnD system since it is not in the appropriate state"
;
...
...
src/share/classes/sun/awt/datatransfer/DataTransferer.java
浏览文件 @
33d7f099
...
@@ -171,12 +171,12 @@ public abstract class DataTransferer {
...
@@ -171,12 +171,12 @@ public abstract class DataTransferer {
* Lazy initialization of Standard Encodings.
* Lazy initialization of Standard Encodings.
*/
*/
private
static
class
StandardEncodingsHolder
{
private
static
class
StandardEncodingsHolder
{
private
static
final
SortedSet
standardEncodings
=
load
();
private
static
final
SortedSet
<
String
>
standardEncodings
=
load
();
private
static
SortedSet
load
()
{
private
static
SortedSet
<
String
>
load
()
{
final
Comparator
comparator
=
final
Comparator
comparator
=
new
CharsetComparator
(
IndexedComparator
.
SELECT_WORST
);
new
CharsetComparator
(
IndexedComparator
.
SELECT_WORST
);
final
SortedSet
tempSet
=
new
TreeSet
(
comparator
);
final
SortedSet
<
String
>
tempSet
=
new
TreeSet
<
String
>
(
comparator
);
tempSet
.
add
(
"US-ASCII"
);
tempSet
.
add
(
"US-ASCII"
);
tempSet
.
add
(
"ISO-8859-1"
);
tempSet
.
add
(
"ISO-8859-1"
);
tempSet
.
add
(
"UTF-8"
);
tempSet
.
add
(
"UTF-8"
);
...
@@ -523,8 +523,8 @@ public abstract class DataTransferer {
...
@@ -523,8 +523,8 @@ public abstract class DataTransferer {
* So as to avoid loading all available character converters, optional,
* So as to avoid loading all available character converters, optional,
* non-standard, character sets are not included.
* non-standard, character sets are not included.
*/
*/
public
static
Iterator
standardEncodings
()
{
public
static
Set
<
String
>
standardEncodings
()
{
return
StandardEncodingsHolder
.
standardEncodings
.
iterator
()
;
return
StandardEncodingsHolder
.
standardEncodings
;
}
}
/**
/**
...
@@ -1068,17 +1068,10 @@ public abstract class DataTransferer {
...
@@ -1068,17 +1068,10 @@ public abstract class DataTransferer {
*
*
* Native to Java string conversion
* Native to Java string conversion
*/
*/
private
String
translateBytesOrStreamToString
(
InputStream
str
,
byte
[]
bytes
,
private
String
translateBytesToString
(
byte
[]
bytes
,
long
format
,
long
format
,
Transferable
localeTransferable
)
Transferable
localeTransferable
)
throws
IOException
throws
IOException
{
{
// A String holds all of its data in memory at one time, so
// we can't avoid reading the entire InputStream at this point.
if
(
bytes
==
null
)
{
bytes
=
inputStreamToByteArray
(
str
);
}
str
.
close
();
Long
lFormat
=
Long
.
valueOf
(
format
);
Long
lFormat
=
Long
.
valueOf
(
format
);
String
charset
=
getBestCharsetForTextFormat
(
lFormat
,
localeTransferable
);
String
charset
=
getBestCharsetForTextFormat
(
lFormat
,
localeTransferable
);
...
@@ -1221,13 +1214,13 @@ search:
...
@@ -1221,13 +1214,13 @@ search:
(
"cannot transfer non-text data as Reader"
);
(
"cannot transfer non-text data as Reader"
);
}
}
Reader
r
=
(
Reader
)
obj
;
StringBuffer
buf
=
new
StringBuffer
();
StringBuffer
buf
=
new
StringBuffer
();
try
(
Reader
r
=
(
Reader
)
obj
)
{
int
c
;
int
c
;
while
((
c
=
r
.
read
())
!=
-
1
)
{
while
((
c
=
r
.
read
())
!=
-
1
)
{
buf
.
append
((
char
)
c
);
buf
.
append
((
char
)
c
);
}
}
r
.
close
();
}
return
translateTransferableString
(
return
translateTransferableString
(
buf
.
toString
(),
buf
.
toString
(),
...
@@ -1309,7 +1302,7 @@ search:
...
@@ -1309,7 +1302,7 @@ search:
return
bytes
;
return
bytes
;
}
}
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
()
;
byte
[]
theByteArray
=
null
;
// Target data is a file list. Source data must be a
// Target data is a file list. Source data must be a
// java.util.List which contains java.io.File or String instances.
// java.util.List which contains java.io.File or String instances.
...
@@ -1324,8 +1317,9 @@ search:
...
@@ -1324,8 +1317,9 @@ search:
final
ArrayList
<
String
>
fileList
=
castToFiles
(
list
,
userProtectionDomain
);
final
ArrayList
<
String
>
fileList
=
castToFiles
(
list
,
userProtectionDomain
);
bos
=
convertFileListToBytes
(
fileList
);
try
(
ByteArrayOutputStream
bos
=
convertFileListToBytes
(
fileList
))
{
theByteArray
=
bos
.
toByteArray
();
}
// Target data is a URI list. Source data must be a
// Target data is a URI list. Source data must be a
// java.util.List which contains java.io.File or String instances.
// java.util.List which contains java.io.File or String instances.
...
@@ -1360,57 +1354,72 @@ search:
...
@@ -1360,57 +1354,72 @@ search:
}
}
byte
[]
eoln
=
"\r\n"
.
getBytes
(
targetCharset
);
byte
[]
eoln
=
"\r\n"
.
getBytes
(
targetCharset
);
try
(
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
())
{
for
(
int
i
=
0
;
i
<
uriList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
uriList
.
size
();
i
++)
{
byte
[]
bytes
=
uriList
.
get
(
i
).
getBytes
(
targetCharset
);
byte
[]
bytes
=
uriList
.
get
(
i
).
getBytes
(
targetCharset
);
bos
.
write
(
bytes
,
0
,
bytes
.
length
);
bos
.
write
(
bytes
,
0
,
bytes
.
length
);
bos
.
write
(
eoln
,
0
,
eoln
.
length
);
bos
.
write
(
eoln
,
0
,
eoln
.
length
);
}
}
theByteArray
=
bos
.
toByteArray
();
}
// Source data is an InputStream. For arbitrary flavors, just grab the
// Source data is an InputStream. For arbitrary flavors, just grab the
// bytes and dump them into a byte array. For text flavors, decode back
// bytes and dump them into a byte array. For text flavors, decode back
// to a String and recur to reencode according to the requested format.
// to a String and recur to reencode according to the requested format.
}
else
if
(
flavor
.
isRepresentationClassInputStream
())
{
}
else
if
(
flavor
.
isRepresentationClassInputStream
())
{
InputStream
is
=
(
InputStream
)
obj
;
try
(
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
())
{
try
(
InputStream
is
=
(
InputStream
)
obj
)
{
boolean
eof
=
false
;
boolean
eof
=
false
;
int
avail
=
is
.
available
();
int
avail
=
is
.
available
();
byte
[]
tmp
=
new
byte
[
avail
>
8192
?
avail
:
8192
];
byte
[]
tmp
=
new
byte
[
avail
>
8192
?
avail
:
8192
];
do
{
do
{
int
ret
;
int
aValue
;
if
(!(
eof
=
(
ret
=
is
.
read
(
tmp
,
0
,
tmp
.
length
))
==
-
1
))
{
if
(!(
eof
=
(
aValue
=
is
.
read
(
tmp
,
0
,
tmp
.
length
))
==
-
1
))
{
bos
.
write
(
tmp
,
0
,
ret
);
bos
.
write
(
tmp
,
0
,
aValue
);
}
}
}
while
(!
eof
);
}
while
(!
eof
);
is
.
close
();
}
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
byte
[]
bytes
=
bos
.
toByteArray
();
byte
[]
bytes
=
bos
.
toByteArray
();
bos
.
close
();
String
sourceEncoding
=
DataTransferer
.
getTextCharset
(
flavor
);
String
sourceEncoding
=
DataTransferer
.
getTextCharset
(
flavor
);
return
translateTransferableString
(
return
translateTransferableString
(
new
String
(
bytes
,
sourceEncoding
),
new
String
(
bytes
,
sourceEncoding
),
format
);
format
);
}
}
theByteArray
=
bos
.
toByteArray
();
}
// Source data is an RMI object
// Source data is an RMI object
}
else
if
(
flavor
.
isRepresentationClassRemote
())
{
}
else
if
(
flavor
.
isRepresentationClassRemote
())
{
Object
mo
=
RMI
.
newMarshalledObject
(
obj
);
Object
mo
=
RMI
.
newMarshalledObject
(
obj
);
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
bos
);
theByteArray
=
convertObjectToBytes
(
mo
);
oos
.
writeObject
(
mo
);
oos
.
close
();
// Source data is Serializable
// Source data is Serializable
}
else
if
(
flavor
.
isRepresentationClassSerializable
())
{
}
else
if
(
flavor
.
isRepresentationClassSerializable
())
{
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
bos
);
oos
.
writeObject
(
obj
);
theByteArray
=
convertObjectToBytes
(
obj
);
oos
.
close
();
}
else
{
}
else
{
throw
new
IOException
(
"data translation failed"
);
throw
new
IOException
(
"data translation failed"
);
}
}
byte
[]
ret
=
bos
.
toByteArray
();
bos
.
close
();
return
ret
;
return
theByteArray
;
}
private
static
byte
[]
convertObjectToBytes
(
Object
object
)
throws
IOException
{
try
(
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
bos
))
{
oos
.
writeObject
(
object
);
return
bos
.
toByteArray
();
}
}
}
protected
abstract
ByteArrayOutputStream
convertFileListToBytes
(
ArrayList
<
String
>
fileList
)
throws
IOException
;
protected
abstract
ByteArrayOutputStream
convertFileListToBytes
(
ArrayList
<
String
>
fileList
)
throws
IOException
;
...
@@ -1565,38 +1574,8 @@ search:
...
@@ -1565,38 +1574,8 @@ search:
long
format
,
Transferable
localeTransferable
)
long
format
,
Transferable
localeTransferable
)
throws
IOException
throws
IOException
{
{
return
translateBytesOrStream
(
null
,
bytes
,
flavor
,
format
,
localeTransferable
);
}
public
Object
translateStream
(
InputStream
str
,
DataFlavor
flavor
,
Object
theObject
=
null
;
long
format
,
Transferable
localeTransferable
)
throws
IOException
{
return
translateBytesOrStream
(
str
,
null
,
flavor
,
format
,
localeTransferable
);
}
/**
* Primary translation function for translating either a byte array or
* an InputStream into an Object, given a source format and a target
* DataFlavor.
*
* One of str/bytes is non-null; the other is null.
* The conversion from byte[] to InputStream is cheap, so do that
* immediately if necessary. The opposite conversion is expensive,
* so avoid it if possible.
*/
protected
Object
translateBytesOrStream
(
InputStream
str
,
byte
[]
bytes
,
DataFlavor
flavor
,
long
format
,
Transferable
localeTransferable
)
throws
IOException
{
if
(
str
==
null
)
{
str
=
new
ByteArrayInputStream
(
bytes
);
}
// Source data is a file list. Use the dragQueryFile native function to
// Source data is a file list. Use the dragQueryFile native function to
// do most of the decoding. Then wrap File objects around the String
// do most of the decoding. Then wrap File objects around the String
...
@@ -1605,12 +1584,8 @@ search:
...
@@ -1605,12 +1584,8 @@ search:
if
(!
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
if
(!
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
throw
new
IOException
(
"data translation failed"
);
throw
new
IOException
(
"data translation failed"
);
}
}
if
(
bytes
==
null
)
{
bytes
=
inputStreamToByteArray
(
str
);
}
String
[]
filenames
=
dragQueryFile
(
bytes
);
String
[]
filenames
=
dragQueryFile
(
bytes
);
if
(
filenames
==
null
)
{
if
(
filenames
==
null
)
{
str
.
close
();
return
null
;
return
null
;
}
}
...
@@ -1619,78 +1594,25 @@ search:
...
@@ -1619,78 +1594,25 @@ search:
for
(
int
i
=
0
;
i
<
filenames
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
filenames
.
length
;
i
++)
{
files
[
i
]
=
new
File
(
filenames
[
i
]);
files
[
i
]
=
new
File
(
filenames
[
i
]);
}
}
str
.
close
();
// Turn the list of Files into a List and return
// Turn the list of Files into a List and return
return
Arrays
.
asList
(
files
);
theObject
=
Arrays
.
asList
(
files
);
// Source data is a URI list. Convert to DataFlavor.javaFileListFlavor
// where possible.
}
else
if
(
isURIListFormat
(
format
)
&&
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
try
{
URI
uris
[]
=
dragQueryURIs
(
str
,
bytes
,
format
,
localeTransferable
);
if
(
uris
==
null
)
{
return
null
;
}
ArrayList
files
=
new
ArrayList
();
for
(
URI
uri
:
uris
)
{
try
{
files
.
add
(
new
File
(
uri
));
}
catch
(
IllegalArgumentException
illegalArg
)
{
// When converting from URIs to less generic files,
// common practice (Wine, SWT) seems to be to
// silently drop the URIs that aren't local files.
}
}
return
files
;
}
finally
{
str
.
close
();
}
// Target data is a String. Strip terminating NUL bytes. Decode bytes
// Target data is a String. Strip terminating NUL bytes. Decode bytes
// into characters. Search-and-replace EOLN.
// into characters. Search-and-replace EOLN.
}
else
if
(
String
.
class
.
equals
(
flavor
.
getRepresentationClass
())
&&
}
else
if
(
String
.
class
.
equals
(
flavor
.
getRepresentationClass
())
&&
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
return
translateBytesOrStreamToString
(
theObject
=
translateBytesToString
(
bytes
,
format
,
localeTransferable
);
str
,
bytes
,
format
,
localeTransferable
);
// Special hack to maintain backwards-compatibility with the brokenness
// of StringSelection. Return a StringReader instead of an InputStream.
// Recur to obtain String and encapsulate.
}
else
if
(
DataFlavor
.
plainTextFlavor
.
equals
(
flavor
))
{
return
new
StringReader
(
translateBytesOrStreamToString
(
str
,
bytes
,
format
,
localeTransferable
));
// Target data is an InputStream. For arbitrary flavors, just return
// the raw bytes. For text flavors, decode to strip terminators and
// search-and-replace EOLN, then reencode according to the requested
// flavor.
}
else
if
(
flavor
.
isRepresentationClassInputStream
())
{
return
translateBytesOrStreamToInputStream
(
str
,
flavor
,
format
,
localeTransferable
);
// Target data is a Reader. Obtain data in InputStream format, encoded
// Target data is a Reader. Obtain data in InputStream format, encoded
// as "Unicode" (utf-16be). Then use an InputStreamReader to decode
// as "Unicode" (utf-16be). Then use an InputStreamReader to decode
// back to chars on demand.
// back to chars on demand.
}
else
if
(
flavor
.
isRepresentationClassReader
())
{
}
else
if
(
flavor
.
isRepresentationClassReader
())
{
if
(!(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
)
))
{
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bytes
))
{
th
row
new
IOException
th
eObject
=
translateStream
(
bais
,
(
"cannot transfer non-text data as Reader"
);
flavor
,
format
,
localeTransferable
);
}
}
InputStream
is
=
(
InputStream
)
translateBytesOrStreamToInputStream
(
str
,
DataFlavor
.
plainTextFlavor
,
format
,
localeTransferable
);
String
unicode
=
DataTransferer
.
getTextCharset
(
DataFlavor
.
plainTextFlavor
);
Reader
reader
=
new
InputStreamReader
(
is
,
unicode
);
return
constructFlavoredObject
(
reader
,
flavor
,
Reader
.
class
);
// Target data is a CharBuffer. Recur to obtain String and wrap.
// Target data is a CharBuffer. Recur to obtain String and wrap.
}
else
if
(
flavor
.
isRepresentationClassCharBuffer
())
{
}
else
if
(
flavor
.
isRepresentationClassCharBuffer
())
{
if
(!(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
)))
{
if
(!(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
)))
{
...
@@ -1698,11 +1620,10 @@ search:
...
@@ -1698,11 +1620,10 @@ search:
(
"cannot transfer non-text data as CharBuffer"
);
(
"cannot transfer non-text data as CharBuffer"
);
}
}
CharBuffer
buffer
=
CharBuffer
.
wrap
(
translateBytesOrStreamToString
(
CharBuffer
buffer
=
CharBuffer
.
wrap
(
str
,
bytes
,
translateBytesToString
(
bytes
,
format
,
localeTransferable
));
format
,
localeTransferable
));
return
constructFlavoredObject
(
buffer
,
flavor
,
CharBuffer
.
class
);
theObject
=
constructFlavoredObject
(
buffer
,
flavor
,
CharBuffer
.
class
);
// Target data is a char array. Recur to obtain String and convert to
// Target data is a char array. Recur to obtain String and convert to
// char array.
// char array.
...
@@ -1712,9 +1633,8 @@ search:
...
@@ -1712,9 +1633,8 @@ search:
(
"cannot transfer non-text data as char array"
);
(
"cannot transfer non-text data as char array"
);
}
}
return
translateBytesOrStreamToString
(
theObject
=
translateBytesToString
(
str
,
bytes
,
bytes
,
format
,
localeTransferable
).
toCharArray
();
format
,
localeTransferable
).
toCharArray
();
// Target data is a ByteBuffer. For arbitrary flavors, just return
// Target data is a ByteBuffer. For arbitrary flavors, just return
// the raw bytes. For text flavors, convert to a String to strip
// the raw bytes. For text flavors, convert to a String to strip
...
@@ -1722,20 +1642,14 @@ search:
...
@@ -1722,20 +1642,14 @@ search:
// the requested flavor.
// the requested flavor.
}
else
if
(
flavor
.
isRepresentationClassByteBuffer
())
{
}
else
if
(
flavor
.
isRepresentationClassByteBuffer
())
{
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
bytes
=
translateBytesOrStreamToString
(
bytes
=
translateBytesToString
(
str
,
bytes
,
bytes
,
format
,
localeTransferable
).
getBytes
(
format
,
localeTransferable
).
getBytes
(
DataTransferer
.
getTextCharset
(
flavor
)
DataTransferer
.
getTextCharset
(
flavor
)
);
);
}
else
{
if
(
bytes
==
null
)
{
bytes
=
inputStreamToByteArray
(
str
);
}
}
}
ByteBuffer
buffer
=
ByteBuffer
.
wrap
(
bytes
);
ByteBuffer
buffer
=
ByteBuffer
.
wrap
(
bytes
);
return
constructFlavoredObject
(
buffer
,
flavor
,
ByteBuffer
.
class
);
theObject
=
constructFlavoredObject
(
buffer
,
flavor
,
ByteBuffer
.
class
);
// Target data is a byte array. For arbitrary flavors, just return
// Target data is a byte array. For arbitrary flavors, just return
// the raw bytes. For text flavors, convert to a String to strip
// the raw bytes. For text flavors, convert to a String to strip
...
@@ -1743,40 +1657,28 @@ search:
...
@@ -1743,40 +1657,28 @@ search:
// the requested flavor.
// the requested flavor.
}
else
if
(
byteArrayClass
.
equals
(
flavor
.
getRepresentationClass
()))
{
}
else
if
(
byteArrayClass
.
equals
(
flavor
.
getRepresentationClass
()))
{
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
if
(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
))
{
return
translateBytesOrStreamToString
(
theObject
=
translateBytesToString
(
str
,
bytes
,
bytes
,
format
,
localeTransferable
format
,
localeTransferable
).
getBytes
(
DataTransferer
.
getTextCharset
(
flavor
));
).
getBytes
(
DataTransferer
.
getTextCharset
(
flavor
)
);
}
else
{
}
else
{
return
(
bytes
!=
null
)
?
bytes
:
inputStreamToByteArray
(
str
)
;
theObject
=
bytes
;
}
}
// Target data is an RMI object
// Target data is an InputStream. For arbitrary flavors, just return
}
else
if
(
flavor
.
isRepresentationClassRemote
())
{
// the raw bytes. For text flavors, decode to strip terminators and
try
{
// search-and-replace EOLN, then reencode according to the requested
byte
[]
ba
=
inputStreamToByteArray
(
str
);
// flavor.
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
ByteArrayInputStream
(
ba
));
}
else
if
(
flavor
.
isRepresentationClassInputStream
())
{
Object
ret
=
RMI
.
getMarshalledObject
(
ois
.
readObject
());
ois
.
close
();
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bytes
))
{
str
.
close
();
theObject
=
translateStream
(
bais
,
flavor
,
format
,
localeTransferable
);
return
ret
;
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
.
getMessage
());
}
}
// Target data is Serializable
// Target data is Serializable
}
else
if
(
flavor
.
isRepresentationClassSerializable
())
{
}
else
if
(
flavor
.
isRepresentationClassSerializable
())
{
try
{
byte
[]
ba
=
inputStreamToByteArray
(
str
);
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bytes
))
{
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
ByteArrayInputStream
(
ba
));
theObject
=
translateStream
(
bais
,
flavor
,
format
,
localeTransferable
);
Object
ret
=
ois
.
readObject
();
ois
.
close
();
str
.
close
();
return
ret
;
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
.
getMessage
());
}
}
// Target data is Image
// Target data is Image
...
@@ -1785,20 +1687,118 @@ search:
...
@@ -1785,20 +1687,118 @@ search:
throw
new
IOException
(
"data translation failed"
);
throw
new
IOException
(
"data translation failed"
);
}
}
Image
image
=
platformImageBytesOrStreamToImage
(
str
,
bytes
,
format
);
theObject
=
platformImageBytesToImage
(
bytes
,
format
);
str
.
close
();
return
image
;
}
}
if
(
theObject
==
null
)
{
throw
new
IOException
(
"data translation failed"
);
throw
new
IOException
(
"data translation failed"
);
}
}
return
theObject
;
}
/**
* Primary translation function for translating
* an InputStream into an Object, given a source format and a target
* DataFlavor.
*/
public
Object
translateStream
(
InputStream
str
,
DataFlavor
flavor
,
long
format
,
Transferable
localeTransferable
)
throws
IOException
{
Object
theObject
=
null
;
// Source data is a URI list. Convert to DataFlavor.javaFileListFlavor
// where possible.
if
(
isURIListFormat
(
format
)
&&
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
URI
uris
[]
=
dragQueryURIs
(
str
,
format
,
localeTransferable
);
if
(
uris
==
null
)
{
return
null
;
}
ArrayList
files
=
new
ArrayList
();
for
(
URI
uri
:
uris
)
{
try
{
files
.
add
(
new
File
(
uri
));
}
catch
(
IllegalArgumentException
illegalArg
)
{
// When converting from URIs to less generic files,
// common practice (Wine, SWT) seems to be to
// silently drop the URIs that aren't local files.
}
}
theObject
=
files
;
// Special hack to maintain backwards-compatibility with the brokenness
// of StringSelection. Return a StringReader instead of an InputStream.
// Recur to obtain String and encapsulate.
}
else
if
(
DataFlavor
.
plainTextFlavor
.
equals
(
flavor
))
{
theObject
=
new
StringReader
(
translateBytesToString
(
inputStreamToByteArray
(
str
),
format
,
localeTransferable
));
// Target data is an InputStream. For arbitrary flavors, just return
// the raw bytes. For text flavors, decode to strip terminators and
// search-and-replace EOLN, then reencode according to the requested
// flavor.
}
else
if
(
flavor
.
isRepresentationClassInputStream
())
{
theObject
=
translateStreamToInputStream
(
str
,
flavor
,
format
,
localeTransferable
);
// Target data is a Reader. Obtain data in InputStream format, encoded
// as "Unicode" (utf-16be). Then use an InputStreamReader to decode
// back to chars on demand.
}
else
if
(
flavor
.
isRepresentationClassReader
())
{
if
(!(
isFlavorCharsetTextType
(
flavor
)
&&
isTextFormat
(
format
)))
{
throw
new
IOException
(
"cannot transfer non-text data as Reader"
);
}
InputStream
is
=
(
InputStream
)
translateStreamToInputStream
(
str
,
DataFlavor
.
plainTextFlavor
,
format
,
localeTransferable
);
String
unicode
=
DataTransferer
.
getTextCharset
(
DataFlavor
.
plainTextFlavor
);
Reader
reader
=
new
InputStreamReader
(
is
,
unicode
);
theObject
=
constructFlavoredObject
(
reader
,
flavor
,
Reader
.
class
);
// Target data is an RMI object
}
else
if
(
flavor
.
isRepresentationClassRemote
())
{
try
(
ObjectInputStream
ois
=
new
ObjectInputStream
(
str
))
{
theObject
=
RMI
.
getMarshalledObject
(
ois
.
readObject
());
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
.
getMessage
());
}
// Target data is Serializable
}
else
if
(
flavor
.
isRepresentationClassSerializable
())
{
try
(
ObjectInputStream
ois
=
new
ObjectInputStream
(
str
))
{
theObject
=
ois
.
readObject
();
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
.
getMessage
());
}
}
return
theObject
;
}
/**
/**
* For arbitrary flavors, just use the raw InputStream. For text flavors,
* For arbitrary flavors, just use the raw InputStream. For text flavors,
* ReencodingInputStream will decode and reencode the InputStream on demand
* ReencodingInputStream will decode and reencode the InputStream on demand
* so that we can strip terminators and search-and-replace EOLN.
* so that we can strip terminators and search-and-replace EOLN.
*/
*/
private
Object
translate
BytesOr
StreamToInputStream
private
Object
translateStreamToInputStream
(
InputStream
str
,
DataFlavor
flavor
,
long
format
,
(
InputStream
str
,
DataFlavor
flavor
,
long
format
,
Transferable
localeTransferable
)
throws
IOException
Transferable
localeTransferable
)
throws
IOException
{
{
...
@@ -2054,7 +2054,6 @@ search:
...
@@ -2054,7 +2054,6 @@ search:
* Decodes URIs from either a byte array or a stream.
* Decodes URIs from either a byte array or a stream.
*/
*/
protected
URI
[]
dragQueryURIs
(
InputStream
stream
,
protected
URI
[]
dragQueryURIs
(
InputStream
stream
,
byte
[]
bytes
,
long
format
,
long
format
,
Transferable
localeTransferable
)
Transferable
localeTransferable
)
throws
IOException
throws
IOException
...
@@ -2067,10 +2066,10 @@ search:
...
@@ -2067,10 +2066,10 @@ search:
* Translates either a byte array or an input stream which contain
* Translates either a byte array or an input stream which contain
* platform-specific image data in the given format into an Image.
* platform-specific image data in the given format into an Image.
*/
*/
protected
abstract
Image
platformImageBytesOrStreamToImage
(
InputStream
str
,
byte
[]
bytes
,
long
format
)
protected
abstract
Image
platformImageBytesToImage
(
throws
IOException
;
byte
[]
bytes
,
long
format
)
throws
IOException
;
/**
/**
* Translates either a byte array or an input stream which contain
* Translates either a byte array or an input stream which contain
...
@@ -2078,13 +2077,9 @@ search:
...
@@ -2078,13 +2077,9 @@ search:
*
*
* @param mimeType image MIME type, such as: image/png, image/jpeg, image/gif
* @param mimeType image MIME type, such as: image/png, image/jpeg, image/gif
*/
*/
protected
Image
standardImageBytesOrStreamToImage
(
InputStream
inputStream
,
protected
Image
standardImageBytesToImage
(
byte
[]
bytes
,
byte
[]
bytes
,
String
mimeType
)
throws
IOException
String
mimeType
)
{
throws
IOException
{
if
(
inputStream
==
null
)
{
inputStream
=
new
ByteArrayInputStream
(
bytes
);
}
Iterator
readerIterator
=
ImageIO
.
getImageReadersByMIMEType
(
mimeType
);
Iterator
readerIterator
=
ImageIO
.
getImageReadersByMIMEType
(
mimeType
);
...
@@ -2097,9 +2092,9 @@ search:
...
@@ -2097,9 +2092,9 @@ search:
while
(
readerIterator
.
hasNext
())
{
while
(
readerIterator
.
hasNext
())
{
ImageReader
imageReader
=
(
ImageReader
)
readerIterator
.
next
();
ImageReader
imageReader
=
(
ImageReader
)
readerIterator
.
next
();
try
{
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bytes
))
{
ImageInputStream
imageInputStream
=
ImageInputStream
imageInputStream
=
ImageIO
.
createImageInputStream
(
inputStream
);
ImageIO
.
createImageInputStream
(
bais
);
try
{
try
{
ImageReadParam
param
=
imageReader
.
getDefaultReadParam
();
ImageReadParam
param
=
imageReader
.
getDefaultReadParam
();
...
@@ -2456,7 +2451,7 @@ search:
...
@@ -2456,7 +2451,7 @@ search:
protected
static
byte
[]
inputStreamToByteArray
(
InputStream
str
)
protected
static
byte
[]
inputStreamToByteArray
(
InputStream
str
)
throws
IOException
throws
IOException
{
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
int
len
=
0
;
int
len
=
0
;
byte
[]
buf
=
new
byte
[
8192
];
byte
[]
buf
=
new
byte
[
8192
];
...
@@ -2466,6 +2461,7 @@ search:
...
@@ -2466,6 +2461,7 @@ search:
return
baos
.
toByteArray
();
return
baos
.
toByteArray
();
}
}
}
/**
/**
* Returns platform-specific mappings for the specified native.
* Returns platform-specific mappings for the specified native.
...
...
src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
浏览文件 @
33d7f099
...
@@ -275,7 +275,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
...
@@ -275,7 +275,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
* upcall from native code
* upcall from native code
*/
*/
pr
ivate
void
dragEnter
(
final
int
targetActions
,
pr
otected
void
dragEnter
(
final
int
targetActions
,
final
int
modifiers
,
final
int
modifiers
,
final
int
x
,
final
int
y
)
{
final
int
x
,
final
int
y
)
{
postDragSourceDragEvent
(
targetActions
,
modifiers
,
x
,
y
,
DISPATCH_ENTER
);
postDragSourceDragEvent
(
targetActions
,
modifiers
,
x
,
y
,
DISPATCH_ENTER
);
...
@@ -353,10 +353,6 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
...
@@ -353,10 +353,6 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
public
static
void
setDragDropInProgress
(
boolean
b
)
public
static
void
setDragDropInProgress
(
boolean
b
)
throws
InvalidDnDOperationException
{
throws
InvalidDnDOperationException
{
if
(
dragDropInProgress
==
b
)
{
throw
new
InvalidDnDOperationException
(
getExceptionMessage
(
b
));
}
synchronized
(
SunDragSourceContextPeer
.
class
)
{
synchronized
(
SunDragSourceContextPeer
.
class
)
{
if
(
dragDropInProgress
==
b
)
{
if
(
dragDropInProgress
==
b
)
{
throw
new
InvalidDnDOperationException
(
getExceptionMessage
(
b
));
throw
new
InvalidDnDOperationException
(
getExceptionMessage
(
b
));
...
...
src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
浏览文件 @
33d7f099
...
@@ -57,7 +57,6 @@ import sun.awt.AppContext;
...
@@ -57,7 +57,6 @@ import sun.awt.AppContext;
import
sun.awt.SunToolkit
;
import
sun.awt.SunToolkit
;
import
sun.awt.datatransfer.DataTransferer
;
import
sun.awt.datatransfer.DataTransferer
;
import
sun.awt.datatransfer.ToolkitThreadBlockedHandler
;
import
sun.awt.datatransfer.ToolkitThreadBlockedHandler
;
import
sun.security.util.SecurityConstants
;
/**
/**
* <p>
* <p>
...
@@ -260,6 +259,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
...
@@ -260,6 +259,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
}
}
final
long
format
=
lFormat
.
longValue
();
final
long
format
=
lFormat
.
longValue
();
Object
ret
=
getNativeData
(
format
);
Object
ret
=
getNativeData
(
format
);
if
(
ret
instanceof
byte
[])
{
if
(
ret
instanceof
byte
[])
{
...
@@ -270,11 +270,14 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
...
@@ -270,11 +270,14 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
throw
new
InvalidDnDOperationException
(
e
.
getMessage
());
throw
new
InvalidDnDOperationException
(
e
.
getMessage
());
}
}
}
else
if
(
ret
instanceof
InputStream
)
{
}
else
if
(
ret
instanceof
InputStream
)
{
InputStream
inputStream
=
(
InputStream
)
ret
;
try
{
try
{
return
DataTransferer
.
getInstance
().
return
DataTransferer
.
getInstance
().
translateStream
(
(
InputStream
)
ret
,
df
,
format
,
this
);
translateStream
(
inputStream
,
df
,
format
,
this
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
InvalidDnDOperationException
(
e
.
getMessage
());
throw
new
InvalidDnDOperationException
(
e
.
getMessage
());
}
finally
{
inputStream
.
close
();
}
}
}
else
{
}
else
{
throw
new
IOException
(
"no native data was transfered"
);
throw
new
IOException
(
"no native data was transfered"
);
...
...
src/share/classes/sun/swing/JLightweightFrame.java
浏览文件 @
33d7f099
...
@@ -72,8 +72,10 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -72,8 +72,10 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
public
JLightweightFrame
()
{
public
JLightweightFrame
()
{
super
();
super
();
add
(
rootPane
,
BorderLayout
.
CENTER
);
add
(
rootPane
,
BorderLayout
.
CENTER
);
setBackground
(
new
Color
(
0
,
0
,
0
,
0
));
setFocusTraversalPolicy
(
new
LayoutFocusTraversalPolicy
());
setFocusTraversalPolicy
(
new
LayoutFocusTraversalPolicy
());
if
(
getGraphicsConfiguration
().
isTranslucencyCapable
())
{
setBackground
(
new
Color
(
0
,
0
,
0
,
0
));
}
}
}
/**
/**
...
...
src/solaris/classes/sun/awt/X11/XDataTransferer.java
浏览文件 @
33d7f099
...
@@ -212,10 +212,9 @@ public class XDataTransferer extends DataTransferer {
...
@@ -212,10 +212,9 @@ public class XDataTransferer extends DataTransferer {
* Translates either a byte array or an input stream which contain
* Translates either a byte array or an input stream which contain
* platform-specific image data in the given format into an Image.
* platform-specific image data in the given format into an Image.
*/
*/
protected
Image
platformImageBytesOrStreamToImage
(
InputStream
inputStream
,
protected
Image
platformImageBytesToImage
(
byte
[]
bytes
,
byte
[]
bytes
,
long
format
)
throws
IOException
long
format
)
{
throws
IOException
{
String
mimeType
=
null
;
String
mimeType
=
null
;
if
(
format
==
PNG_ATOM
.
getAtom
())
{
if
(
format
==
PNG_ATOM
.
getAtom
())
{
mimeType
=
"image/png"
;
mimeType
=
"image/png"
;
...
@@ -235,7 +234,7 @@ public class XDataTransferer extends DataTransferer {
...
@@ -235,7 +234,7 @@ public class XDataTransferer extends DataTransferer {
}
}
}
}
if
(
mimeType
!=
null
)
{
if
(
mimeType
!=
null
)
{
return
standardImageBytes
OrStreamToImage
(
inputStream
,
bytes
,
mimeType
);
return
standardImageBytes
ToImage
(
bytes
,
mimeType
);
}
else
{
}
else
{
String
nativeFormat
=
getNativeForFormat
(
format
);
String
nativeFormat
=
getNativeForFormat
(
format
);
throw
new
IOException
(
"Translation from "
+
nativeFormat
+
throw
new
IOException
(
"Translation from "
+
nativeFormat
+
...
@@ -330,8 +329,8 @@ public class XDataTransferer extends DataTransferer {
...
@@ -330,8 +329,8 @@ public class XDataTransferer extends DataTransferer {
* a valid MIME and return a list of flavors to which the data in this MIME
* a valid MIME and return a list of flavors to which the data in this MIME
* type can be translated by the Data Transfer subsystem.
* type can be translated by the Data Transfer subsystem.
*/
*/
public
List
getPlatformMappingsForNative
(
String
nat
)
{
public
List
<
DataFlavor
>
getPlatformMappingsForNative
(
String
nat
)
{
List
flavors
=
new
ArrayList
();
List
<
DataFlavor
>
flavors
=
new
ArrayList
();
if
(
nat
==
null
)
{
if
(
nat
==
null
)
{
return
flavors
;
return
flavors
;
...
@@ -346,16 +345,14 @@ public class XDataTransferer extends DataTransferer {
...
@@ -346,16 +345,14 @@ public class XDataTransferer extends DataTransferer {
return
flavors
;
return
flavors
;
}
}
Object
value
=
df
;
DataFlavor
value
=
df
;
final
String
primaryType
=
df
.
getPrimaryType
();
final
String
primaryType
=
df
.
getPrimaryType
();
final
String
baseType
=
primaryType
+
"/"
+
df
.
getSubType
();
final
String
baseType
=
primaryType
+
"/"
+
df
.
getSubType
();
// For text formats we map natives to MIME strings instead of data
// For text formats we map natives to MIME strings instead of data
// flavors to enable dynamic text native-to-flavor mapping generation.
// flavors to enable dynamic text native-to-flavor mapping generation.
// See SystemFlavorMap.getFlavorsForNative() for details.
// See SystemFlavorMap.getFlavorsForNative() for details.
if
(
"text"
.
equals
(
primaryType
))
{
if
(
"image"
.
equals
(
primaryType
))
{
value
=
primaryType
+
"/"
+
df
.
getSubType
();
}
else
if
(
"image"
.
equals
(
primaryType
))
{
Iterator
readers
=
ImageIO
.
getImageReadersByMIMEType
(
baseType
);
Iterator
readers
=
ImageIO
.
getImageReadersByMIMEType
(
baseType
);
if
(
readers
.
hasNext
())
{
if
(
readers
.
hasNext
())
{
flavors
.
add
(
DataFlavor
.
imageFlavor
);
flavors
.
add
(
DataFlavor
.
imageFlavor
);
...
@@ -438,16 +435,13 @@ public class XDataTransferer extends DataTransferer {
...
@@ -438,16 +435,13 @@ public class XDataTransferer extends DataTransferer {
}
}
}
}
}
else
if
(
DataTransferer
.
isFlavorCharsetTextType
(
df
))
{
}
else
if
(
DataTransferer
.
isFlavorCharsetTextType
(
df
))
{
final
Iterator
iter
=
DataTransferer
.
standardEncodings
();
// stringFlavor is semantically equivalent to the standard
// stringFlavor is semantically equivalent to the standard
// "text/plain" MIME type.
// "text/plain" MIME type.
if
(
DataFlavor
.
stringFlavor
.
equals
(
df
))
{
if
(
DataFlavor
.
stringFlavor
.
equals
(
df
))
{
baseType
=
"text/plain"
;
baseType
=
"text/plain"
;
}
}
while
(
iter
.
hasNext
())
{
for
(
String
encoding
:
DataTransferer
.
standardEncodings
())
{
String
encoding
=
(
String
)
iter
.
next
();
if
(!
encoding
.
equals
(
charset
))
{
if
(!
encoding
.
equals
(
charset
))
{
natives
.
add
(
baseType
+
";charset="
+
encoding
);
natives
.
add
(
baseType
+
";charset="
+
encoding
);
}
}
...
...
src/solaris/classes/sun/awt/X11/XFramePeer.java
浏览文件 @
33d7f099
...
@@ -642,5 +642,11 @@ class XFramePeer extends XDecoratedPeer implements FramePeer {
...
@@ -642,5 +642,11 @@ class XFramePeer extends XDecoratedPeer implements FramePeer {
return
getBounds
();
return
getBounds
();
}
}
public
void
emulateActivation
(
boolean
doActivate
)
{}
public
void
emulateActivation
(
boolean
doActivate
)
{
if
(
doActivate
)
{
handleWindowFocusIn
(
0
);
}
else
{
handleWindowFocusOut
(
null
,
0
);
}
}
}
}
src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.awt.X11
;
import
java.awt.Graphics
;
import
sun.awt.LightweightFrame
;
public
class
XLightweightFramePeer
extends
XFramePeer
{
XLightweightFramePeer
(
LightweightFrame
target
)
{
super
(
target
);
}
private
LightweightFrame
getLwTarget
()
{
return
(
LightweightFrame
)
target
;
}
@Override
public
Graphics
getGraphics
()
{
return
getLwTarget
().
getGraphics
();
}
@Override
public
void
xSetVisible
(
boolean
visible
)
{
this
.
visible
=
visible
;
}
@Override
protected
void
requestXFocus
(
long
time
,
boolean
timeProvided
)
{
// not sending native focus events to the proxy
}
@Override
public
void
setGrab
(
boolean
grab
)
{
if
(
grab
)
{
getLwTarget
().
grabFocus
();
}
else
{
getLwTarget
().
ungrabFocus
();
}
}
}
src/solaris/classes/sun/awt/X11/XToolkit.java
浏览文件 @
33d7f099
...
@@ -420,7 +420,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
...
@@ -420,7 +420,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
public
FramePeer
createLightweightFrame
(
LightweightFrame
target
)
{
public
FramePeer
createLightweightFrame
(
LightweightFrame
target
)
{
return
null
;
FramePeer
peer
=
new
XLightweightFramePeer
(
target
);
targetCreatedPeer
(
target
,
peer
);
return
peer
;
}
}
public
FramePeer
createFrame
(
Frame
target
)
{
public
FramePeer
createFrame
(
Frame
target
)
{
...
...
src/windows/classes/sun/awt/windows/WDataTransferer.java
浏览文件 @
33d7f099
...
@@ -191,32 +191,60 @@ public class WDataTransferer extends DataTransferer {
...
@@ -191,32 +191,60 @@ public class WDataTransferer extends DataTransferer {
DataFlavor
flavor
,
DataFlavor
flavor
,
long
format
)
throws
IOException
long
format
)
throws
IOException
{
{
byte
[]
bytes
=
super
.
translateTransferable
(
contents
,
flavor
,
format
);
byte
[]
bytes
=
null
;
if
(
format
==
CF_HTML
)
{
if
(
format
==
CF_HTML
)
{
if
(
contents
.
isDataFlavorSupported
(
DataFlavor
.
selectionHtmlFlavor
))
{
// if a user provides data represented by
// DataFlavor.selectionHtmlFlavor format, we use this
// type to store the data in the native clipboard
bytes
=
super
.
translateTransferable
(
contents
,
DataFlavor
.
selectionHtmlFlavor
,
format
);
}
else
if
(
contents
.
isDataFlavorSupported
(
DataFlavor
.
allHtmlFlavor
))
{
// if we cannot get data represented by the
// DataFlavor.selectionHtmlFlavor format
// but the DataFlavor.allHtmlFlavor format is avialable
// we belive that the user knows how to represent
// the data and how to mark up selection in a
// system specific manner. Therefor, we use this data
bytes
=
super
.
translateTransferable
(
contents
,
DataFlavor
.
allHtmlFlavor
,
format
);
}
else
{
// handel other html flavor types, including custom and
// fragment ones
bytes
=
HTMLCodec
.
convertToHTMLFormat
(
bytes
);
bytes
=
HTMLCodec
.
convertToHTMLFormat
(
bytes
);
}
}
}
else
{
// we handle non-html types basing on their
// flavors
bytes
=
super
.
translateTransferable
(
contents
,
flavor
,
format
);
}
return
bytes
;
return
bytes
;
}
}
protected
Object
translateBytesOrStream
(
InputStream
str
,
byte
[]
bytes
,
// The stream is closed as a closable object
public
Object
translateStream
(
InputStream
str
,
DataFlavor
flavor
,
long
format
,
DataFlavor
flavor
,
long
format
,
Transferable
localeTransferable
)
Transferable
localeTransferable
)
throws
IOException
throws
IOException
{
{
if
(
format
==
CF_HTML
&&
flavor
.
isFlavorTextType
())
{
if
(
format
==
CF_HTML
&&
flavor
.
isFlavorTextType
())
{
if
(
str
==
null
)
{
str
=
new
HTMLCodec
(
str
,
str
=
new
ByteArrayInputStream
(
bytes
);
EHTMLReadMode
.
getEHTMLReadMode
(
flavor
)
);
bytes
=
null
;
}
}
return
super
.
translateStream
(
str
,
flavor
,
format
,
localeTransferable
);
str
=
new
HTMLCodec
(
str
,
EHTMLReadMode
.
HTML_READ_SELECTION
);
}
}
public
Object
translateBytes
(
byte
[]
bytes
,
DataFlavor
flavor
,
long
format
,
Transferable
localeTransferable
)
throws
IOException
{
if
(
format
==
CF_FILEGROUPDESCRIPTORA
||
format
==
CF_FILEGROUPDESCRIPTORW
)
{
if
(
format
==
CF_FILEGROUPDESCRIPTORA
||
format
==
CF_FILEGROUPDESCRIPTORW
)
{
if
(
null
!=
str
)
{
str
.
close
();
}
if
(
bytes
==
null
||
!
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
if
(
bytes
==
null
||
!
DataFlavor
.
javaFileListFlavor
.
equals
(
flavor
))
{
throw
new
IOException
(
"data translation failed"
);
throw
new
IOException
(
"data translation failed"
);
}
}
...
@@ -240,26 +268,22 @@ public class WDataTransferer extends DataTransferer {
...
@@ -240,26 +268,22 @@ public class WDataTransferer extends DataTransferer {
if
(
format
==
CFSTR_INETURL
&&
if
(
format
==
CFSTR_INETURL
&&
URL
.
class
.
equals
(
flavor
.
getRepresentationClass
()))
URL
.
class
.
equals
(
flavor
.
getRepresentationClass
()))
{
{
if
(
bytes
==
null
)
{
bytes
=
inputStreamToByteArray
(
str
);
str
=
null
;
}
String
charset
=
getDefaultTextCharset
();
String
charset
=
getDefaultTextCharset
();
if
(
localeTransferable
!=
null
&&
localeTransferable
.
if
(
localeTransferable
!=
null
&&
localeTransferable
.
isDataFlavorSupported
(
javaTextEncodingFlavor
))
isDataFlavorSupported
(
javaTextEncodingFlavor
))
{
{
try
{
try
{
charset
=
new
String
((
byte
[])
localeTransferable
.
charset
=
new
String
((
byte
[])
localeTransferable
.
getTransferData
(
javaTextEncodingFlavor
),
getTransferData
(
javaTextEncodingFlavor
),
"UTF-8"
);
"UTF-8"
);
}
catch
(
UnsupportedFlavorException
cannotHappen
)
{
}
catch
(
UnsupportedFlavorException
cannotHappen
)
{
}
}
}
}
return
new
URL
(
new
String
(
bytes
,
charset
));
return
new
URL
(
new
String
(
bytes
,
charset
));
}
}
return
super
.
translateBytes
OrStream
(
str
,
bytes
,
flavor
,
format
,
return
super
.
translateBytes
(
bytes
,
flavor
,
format
,
localeTransferable
);
localeTransferable
);
}
}
public
boolean
isLocaleDependentTextFormat
(
long
format
)
{
public
boolean
isLocaleDependentTextFormat
(
long
format
)
{
...
@@ -419,9 +443,7 @@ public class WDataTransferer extends DataTransferer {
...
@@ -419,9 +443,7 @@ public class WDataTransferer extends DataTransferer {
* Translates either a byte array or an input stream which contain
* Translates either a byte array or an input stream which contain
* platform-specific image data in the given format into an Image.
* platform-specific image data in the given format into an Image.
*/
*/
protected
Image
platformImageBytesOrStreamToImage
(
InputStream
str
,
protected
Image
platformImageBytesToImage
(
byte
[]
bytes
,
long
format
)
byte
[]
bytes
,
long
format
)
throws
IOException
{
throws
IOException
{
String
mimeType
=
null
;
String
mimeType
=
null
;
if
(
format
==
CF_PNG
)
{
if
(
format
==
CF_PNG
)
{
...
@@ -430,11 +452,7 @@ public class WDataTransferer extends DataTransferer {
...
@@ -430,11 +452,7 @@ public class WDataTransferer extends DataTransferer {
mimeType
=
"image/jpeg"
;
mimeType
=
"image/jpeg"
;
}
}
if
(
mimeType
!=
null
)
{
if
(
mimeType
!=
null
)
{
return
standardImageBytesOrStreamToImage
(
str
,
bytes
,
mimeType
);
return
standardImageBytesToImage
(
bytes
,
mimeType
);
}
if
(
bytes
==
null
)
{
bytes
=
inputStreamToByteArray
(
str
);
}
}
int
[]
imageData
=
platformImageBytesToImageData
(
bytes
,
format
);
int
[]
imageData
=
platformImageBytesToImageData
(
bytes
,
format
);
...
@@ -492,7 +510,22 @@ final class WToolkitThreadBlockedHandler extends Mutex
...
@@ -492,7 +510,22 @@ final class WToolkitThreadBlockedHandler extends Mutex
enum
EHTMLReadMode
{
enum
EHTMLReadMode
{
HTML_READ_ALL
,
HTML_READ_ALL
,
HTML_READ_FRAGMENT
,
HTML_READ_FRAGMENT
,
HTML_READ_SELECTION
HTML_READ_SELECTION
;
public
static
EHTMLReadMode
getEHTMLReadMode
(
DataFlavor
df
)
{
EHTMLReadMode
mode
=
HTML_READ_SELECTION
;
String
parameter
=
df
.
getParameter
(
"document"
);
if
(
"all"
.
equals
(
parameter
))
{
mode
=
HTML_READ_ALL
;
}
else
if
(
"fragment"
.
equals
(
parameter
))
{
mode
=
HTML_READ_FRAGMENT
;
}
return
mode
;
}
}
}
/**
/**
...
@@ -581,8 +614,6 @@ class HTMLCodec extends InputStream {
...
@@ -581,8 +614,6 @@ class HTMLCodec extends InputStream {
htmlSuffix
=
"</BODY>"
+
htmlSuffix
;
htmlSuffix
=
"</BODY>"
+
htmlSuffix
;
};
};
};
};
htmlPrefix
=
htmlPrefix
+
START_FRAGMENT_CMT
;
htmlSuffix
=
END_FRAGMENT_CMT
+
htmlSuffix
;
}
}
String
stBaseUrl
=
DEF_SOURCE_URL
;
String
stBaseUrl
=
DEF_SOURCE_URL
;
...
...
test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 7075105
@summary WIN: Provide a way to format HTML on drop
@author Denis Fokin: area=datatransfer
@build HtmlTransferable PutAllHtmlFlavorsOnClipboard
@build PutOnlyAllHtmlFlavorOnClipboard PutSelectionAndFragmentHtmlFlavorsOnClipboard
@run main HTMLDataFlavorTest
*/
import
java.awt.*
;
import
java.awt.datatransfer.*
;
import
java.io.*
;
import
java.util.HashMap
;
public
class
HTMLDataFlavorTest
{
private
static
HashMap
<
DataFlavor
,
String
>
dataFlavors
=
new
HashMap
<
DataFlavor
,
String
>();
public
static
void
main
(
String
[]
args
)
throws
IOException
,
UnsupportedFlavorException
{
dataFlavors
.
put
(
DataFlavor
.
allHtmlFlavor
,
HtmlTransferable
.
ALL_HTML_AS_STRING
);
dataFlavors
.
put
(
DataFlavor
.
fragmentHtmlFlavor
,
HtmlTransferable
.
FRAGMENT_HTML_AS_STRING
);
dataFlavors
.
put
(
DataFlavor
.
selectionHtmlFlavor
,
HtmlTransferable
.
SELECTION_HTML_AS_STRING
);
Clipboard
clipboard
=
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
();
resetClipboardContent
(
clipboard
);
// 1. Put all three html flavors on clipboard.
// Get the data within the same JVM
// Expect that the resulted html is the selection
// wrapped in all three types
clipboard
.
setContents
(
new
HtmlTransferable
(
HtmlTransferable
.
htmlDataFlavors
),
null
);
// Test local transfer
testClipboardContent
(
clipboard
,
HtmlTransferable
.
htmlDataFlavors
);
resetClipboardContent
(
clipboard
);
// 2. Put only DataFlavor.allHtmlFlavor on clipboard.
// Expect that the resulted html is the all
// wrapped in all three types
putHtmlInAnotherProcess
(
"PutOnlyAllHtmlFlavorOnClipboard"
);
for
(
DataFlavor
df
:
HtmlTransferable
.
htmlDataFlavors
)
{
if
(!
clipboard
.
isDataFlavorAvailable
(
df
))
{
throw
new
RuntimeException
(
"The data should be available."
);
}
}
if
(!
clipboard
.
getData
(
DataFlavor
.
allHtmlFlavor
).
toString
().
equals
(
dataFlavors
.
get
(
DataFlavor
.
allHtmlFlavor
).
toString
()))
{
throw
new
RuntimeException
(
"DataFlavor.allHtmlFlavor data "
+
"should be identical to the data put on the source side."
);
}
resetClipboardContent
(
clipboard
);
// 3. Put all three html flavors on clipboard.
// Expect that the resulted html is the selection
// wrapped in all three types
putHtmlInAnotherProcess
(
"PutAllHtmlFlavorsOnClipboard"
);
for
(
DataFlavor
df
:
HtmlTransferable
.
htmlDataFlavors
)
{
if
(!
clipboard
.
isDataFlavorAvailable
(
df
))
{
throw
new
RuntimeException
(
"The data should be available."
);
}
}
if
(!
clipboard
.
getData
(
DataFlavor
.
selectionHtmlFlavor
).
toString
().
equals
(
dataFlavors
.
get
(
DataFlavor
.
selectionHtmlFlavor
)))
{
throw
new
RuntimeException
(
"DataFlavor.allHtmlFlavor data "
+
"should be identical to the data put on the source side."
);
}
}
private
static
void
resetClipboardContent
(
Clipboard
clipboard
)
{
clipboard
.
setContents
(
new
StringSelection
(
"The data is used to empty the clipboard content"
),
null
);
}
private
static
void
putHtmlInAnotherProcess
(
String
putterCommand
)
{
try
{
String
command
=
System
.
getProperty
(
"java.home"
)
+
"/bin/java -cp "
+
System
.
getProperty
(
"test.classes"
,
"."
)
+
" "
+
putterCommand
;
System
.
out
.
println
(
"Execute process : "
+
command
);
Process
p
=
Runtime
.
getRuntime
().
exec
(
command
);
try
{
p
.
waitFor
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"The data has been set remotely"
);
try
(
BufferedReader
stdstr
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
())))
{
String
s
;
while
((
s
=
stdstr
.
readLine
())
!=
null
)
{
s
=
stdstr
.
readLine
();
System
.
out
.
println
(
s
);
}
}
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getErrorStream
())))
{
String
s
;
while
((
s
=
br
.
readLine
())
!=
null
)
{
s
=
br
.
readLine
();
System
.
err
.
println
(
s
);
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
static
void
testClipboardContent
(
Clipboard
clipboard
,
DataFlavor
[]
expectedDataFlavors
)
throws
UnsupportedFlavorException
,
IOException
{
for
(
DataFlavor
df
:
clipboard
.
getAvailableDataFlavors
())
{
System
.
out
.
println
(
"available df: "
+
df
.
getMimeType
());
}
for
(
DataFlavor
df
:
expectedDataFlavors
)
{
if
(!
clipboard
.
isDataFlavorAvailable
(
df
))
{
throw
new
RuntimeException
(
"The data should be available."
);
}
System
.
out
.
println
(
"Checking \""
+
df
.
getParameter
(
"document"
)
+
"\" for correspondence"
);
if
(!
dataFlavors
.
get
(
df
).
toString
().
equals
(
clipboard
.
getData
(
df
).
toString
()))
{
System
.
err
.
println
(
"Expected data: "
+
dataFlavors
.
get
(
df
).
toString
());
System
.
err
.
println
(
"Actual data: "
+
clipboard
.
getData
(
df
).
toString
());
throw
new
RuntimeException
(
"An html flavor with parameter \""
+
df
.
getParameter
(
"document"
)
+
"\" does not correspond to the transferred data."
);
}
}
}
}
test/java/awt/datatransfer/HTMLDataFlavors/HtmlTransferable.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.datatransfer.Transferable
;
import
java.awt.datatransfer.UnsupportedFlavorException
;
import
java.io.IOException
;
/**
* A transferable that mimic ie html data
*/
class
HtmlTransferable
implements
Transferable
{
final
static
String
SOURCE_HTML
=
"<html><head><title>Simple html content</title></head>"
+
"<body><ol><li>Dasha</li><li>Masha</li><li>Lida</li></ol></body></html>"
;
// Data identical to ie output for the next html without end of lines,
// that is gotten by java system clipboard
// <html>
// <head>
// <title>Simple html content</title>
// </head>
// <body>
// <ol>
// <li>Dasha</li>
// <li>Masha</li>
// <li>Lida</li>
// </ol>
// </body>
// </html>
final
static
String
ALL_HTML_AS_STRING
=
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
+
"\n"
+
"<HTML><HEAD><TITLE>Simple html content</TITLE></HEAD>\n"
+
"\n"
+
"<BODY>\n"
+
"\n"
+
"<OL><!--StartFragment--><LI>Masha\n"
+
"<LI>Lida</LI><!--EndFragment--></OL>\n"
+
"</BODY>\n"
+
"</HTML>"
;
final
static
String
FRAGMENT_HTML_AS_STRING
=
"<LI>Masha\n"
+
"<LI>Lida</LI>"
;
final
static
String
SELECTION_HTML_AS_STRING
=
"<LI>Masha"
+
"<LI>Lida</LI>"
;
private
DataFlavor
[]
supportedDataFlavors
;
final
static
DataFlavor
[]
htmlDataFlavors
=
new
DataFlavor
[]
{
DataFlavor
.
allHtmlFlavor
,
DataFlavor
.
fragmentHtmlFlavor
,
DataFlavor
.
selectionHtmlFlavor
};
@Override
public
DataFlavor
[]
getTransferDataFlavors
()
{
return
supportedDataFlavors
;
}
@Override
public
boolean
isDataFlavorSupported
(
DataFlavor
flavor
)
{
for
(
DataFlavor
supportedDataFlavor
:
supportedDataFlavors
)
{
if
(
supportedDataFlavor
.
equals
(
flavor
))
{
return
true
;
}
}
return
false
;
}
HtmlTransferable
(
DataFlavor
[]
supportedDataFlavors
)
{
this
.
supportedDataFlavors
=
supportedDataFlavors
;
}
@Override
public
Object
getTransferData
(
DataFlavor
flavor
)
throws
UnsupportedFlavorException
,
IOException
{
if
(
isDataFlavorSupported
(
flavor
))
{
if
(
flavor
.
equals
(
DataFlavor
.
allHtmlFlavor
))
{
return
ALL_HTML_AS_STRING
;
}
else
if
(
flavor
.
equals
(
DataFlavor
.
fragmentHtmlFlavor
))
{
return
FRAGMENT_HTML_AS_STRING
;
}
else
if
(
flavor
.
equals
(
DataFlavor
.
selectionHtmlFlavor
))
{
return
SELECTION_HTML_AS_STRING
;
}
}
throw
new
UnsupportedFlavorException
(
flavor
);
}
}
test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.html
0 → 100644
浏览文件 @
33d7f099
<html>
<!--
@test
@bug 7075105
@summary WIN: Provide a way to format HTML on drop
@author Denis Fokin area=datatransfer
@run applet/manual=yesno ManualHTMLDataFlavorTest.html
-->
<head>
<title>
ManualHTMLDataFlavorTest
</title>
</head>
<body>
<h1>
ManualHTMLDataFlavorTest
<br>
Bug ID: 7075105
</h1>
<p>
See the dialog box (usually in upper left corner) for instructions
</p>
<APPLET
CODE=
"ManualHTMLDataFlavorTest.class"
WIDTH=
200
HEIGHT=
200
></APPLET>
</body>
</html>
test/java/awt/datatransfer/HTMLDataFlavors/ManualHTMLDataFlavorTest.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
test
@bug 7075105
@summary WIN: Provide a way to format HTML on drop
@author Denis Fokin: area=datatransfer
@run applet/manual=yesno ManualHTMLDataFlavorTest
*/
import
java.applet.Applet
;
import
java.awt.*
;
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.datatransfer.Transferable
;
import
java.awt.datatransfer.UnsupportedFlavorException
;
import
java.awt.dnd.*
;
import
java.io.IOException
;
public
class
ManualHTMLDataFlavorTest
extends
Applet
{
class
DropPane
extends
Panel
implements
DropTargetListener
{
DropPane
()
{
requestFocus
();
setBackground
(
Color
.
red
);
setDropTarget
(
new
DropTarget
(
this
,
DnDConstants
.
ACTION_COPY
,
this
));
}
@Override
public
Dimension
getPreferredSize
()
{
return
new
Dimension
(
200
,
200
);
}
@Override
public
void
dragEnter
(
DropTargetDragEvent
dtde
)
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY
);
}
@Override
public
void
dragOver
(
DropTargetDragEvent
dtde
)
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY
);
}
@Override
public
void
dropActionChanged
(
DropTargetDragEvent
dtde
)
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY
);
}
@Override
public
void
dragExit
(
DropTargetEvent
dte
)
{}
@Override
public
void
drop
(
DropTargetDropEvent
dtde
)
{
if
(!
dtde
.
isDataFlavorSupported
(
DataFlavor
.
allHtmlFlavor
))
{
Sysout
.
println
(
"DataFlavor.allHtmlFlavor is not present in the system clipboard"
);
dtde
.
rejectDrop
();
return
;
}
else
if
(!
dtde
.
isDataFlavorSupported
(
DataFlavor
.
fragmentHtmlFlavor
))
{
Sysout
.
println
(
"DataFlavor.fragmentHtmlFlavor is not present in the system clipboard"
);
dtde
.
rejectDrop
();
return
;
}
else
if
(!
dtde
.
isDataFlavorSupported
(
DataFlavor
.
selectionHtmlFlavor
))
{
Sysout
.
println
(
"DataFlavor.selectionHtmlFlavor is not present in the system clipboard"
);
dtde
.
rejectDrop
();
return
;
}
dtde
.
acceptDrop
(
DnDConstants
.
ACTION_COPY
);
Transferable
t
=
dtde
.
getTransferable
();
try
{
Sysout
.
println
(
"ALL:"
);
Sysout
.
println
(
t
.
getTransferData
(
DataFlavor
.
allHtmlFlavor
).
toString
());
Sysout
.
println
(
"FRAGMENT:"
);
Sysout
.
println
(
t
.
getTransferData
(
DataFlavor
.
fragmentHtmlFlavor
).
toString
());
Sysout
.
println
(
"SELECTION:"
);
Sysout
.
println
(
t
.
getTransferData
(
DataFlavor
.
selectionHtmlFlavor
).
toString
());
}
catch
(
UnsupportedFlavorException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
public
void
init
()
{
String
[]
instructions
=
{
"1) The test contains a drop-aware panel with a red background"
,
"2) Open some page in a browser, select some text"
,
" Drag and drop it on the red panel"
,
" IMPORTANT NOTE: the page should be stored locally."
,
" otherwise for instance iexplore can prohibit drag and drop from"
,
" the browser to other applications because of"
,
" the protected mode restrictions."
,
"3) Check the data in the output area of this dialog"
,
"5) The output should not contain information that any of"
,
" flavors is not present in the system clipboard"
,
"6) The output should contain data in three different formats"
,
" provided by the system clipboard"
,
" - Data after the \"ALL:\" marker should include the data"
,
" from the the \"SELECTION:\" marker"
,
" - Data after the \"FRAGMENT\" marker should include the data"
,
" from the \"SELECTION:\" marker and may be some closing"
,
" tags could be added to the mark-up"
,
" - Data after the \"SELECTION:\" marker should correspond"
,
" to the data selected in the browser"
,
"7) If the above requirements are met, the test is passed"
};
add
(
new
DropPane
());
Sysout
.
createDialogWithInstructions
(
instructions
);
new
ManualHTMLDataFlavorTest
();
}
public
void
start
()
{
setSize
(
200
,
200
);
setVisible
(
true
);
validate
();
}
// start()
}
/* Place other classes related to the test after this line */
/****************************************************
Standard Test Machinery
DO NOT modify anything below -- it's a standard
chunk of code whose purpose is to make user
interaction uniform, and thereby make it simpler
to read and understand someone else's test.
****************************************************/
/**
This is part of the standard test machinery.
It creates a dialog (with the instructions), and is the interface
for sending text messages to the user.
To print the instructions, send an array of strings to Sysout.createDialog
WithInstructions method. Put one line of instructions per array entry.
To display a message for the tester to see, simply call Sysout.println
with the string to be displayed.
This mimics System.out.println but works within the test harness as well
as standalone.
*/
class
Sysout
{
private
static
TestDialog
dialog
;
public
static
void
createDialogWithInstructions
(
String
[]
instructions
)
{
dialog
=
new
TestDialog
(
new
Frame
(),
"Instructions"
);
dialog
.
printInstructions
(
instructions
);
dialog
.
setVisible
(
true
);
println
(
"Any messages for the tester will display here."
);
}
public
static
void
createDialog
(
)
{
dialog
=
new
TestDialog
(
new
Frame
(),
"Instructions"
);
String
[]
defInstr
=
{
"Instructions will appear here. "
,
""
}
;
dialog
.
printInstructions
(
defInstr
);
dialog
.
setVisible
(
true
);
println
(
"Any messages for the tester will display here."
);
}
public
static
void
printInstructions
(
String
[]
instructions
)
{
dialog
.
printInstructions
(
instructions
);
}
public
static
void
println
(
String
messageIn
)
{
dialog
.
displayMessage
(
messageIn
);
}
}
// Sysout class
/**
This is part of the standard test machinery. It provides a place for the
test instructions to be displayed, and a place for interactive messages
to the user to be displayed.
To have the test instructions displayed, see Sysout.
To have a message to the user be displayed, see Sysout.
Do not call anything in this dialog directly.
*/
class
TestDialog
extends
Dialog
{
TextArea
instructionsText
;
TextArea
messageText
;
int
maxStringLength
=
80
;
//DO NOT call this directly, go through Sysout
public
TestDialog
(
Frame
frame
,
String
name
)
{
super
(
frame
,
name
);
int
scrollBoth
=
TextArea
.
SCROLLBARS_BOTH
;
instructionsText
=
new
TextArea
(
""
,
15
,
maxStringLength
,
scrollBoth
);
add
(
"North"
,
instructionsText
);
messageText
=
new
TextArea
(
""
,
5
,
maxStringLength
,
scrollBoth
);
add
(
"Center"
,
messageText
);
pack
();
setVisible
(
true
);
}
// TestDialog()
//DO NOT call this directly, go through Sysout
public
void
printInstructions
(
String
[]
instructions
)
{
//Clear out any current instructions
instructionsText
.
setText
(
""
);
//Go down array of instruction strings
String
printStr
,
remainingStr
;
for
(
int
i
=
0
;
i
<
instructions
.
length
;
i
++
)
{
//chop up each into pieces maxSringLength long
remainingStr
=
instructions
[
i
];
while
(
remainingStr
.
length
()
>
0
)
{
//if longer than max then chop off first max chars to print
if
(
remainingStr
.
length
()
>=
maxStringLength
)
{
//Try to chop on a word boundary
int
posOfSpace
=
remainingStr
.
lastIndexOf
(
' '
,
maxStringLength
-
1
);
if
(
posOfSpace
<=
0
)
posOfSpace
=
maxStringLength
-
1
;
printStr
=
remainingStr
.
substring
(
0
,
posOfSpace
+
1
);
remainingStr
=
remainingStr
.
substring
(
posOfSpace
+
1
);
}
//else just print
else
{
printStr
=
remainingStr
;
remainingStr
=
""
;
}
instructionsText
.
append
(
printStr
+
"\n"
);
}
// while
}
// for
}
//printInstructions()
//DO NOT call this directly, go through Sysout
public
void
displayMessage
(
String
messageIn
)
{
messageText
.
append
(
messageIn
+
"\n"
);
System
.
out
.
println
(
messageIn
);
}
}
// TestDialog class
test/java/awt/datatransfer/HTMLDataFlavors/PutAllHtmlFlavorsOnClipboard.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.*
;
public
class
PutAllHtmlFlavorsOnClipboard
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"PutAllHtmlFlavorsOnClipboard has been started."
);
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
().
setContents
(
new
HtmlTransferable
(
HtmlTransferable
.
htmlDataFlavors
),
null
);
System
.
out
.
println
(
"Data has been put on clipboard in a separate process"
);
}
}
test/java/awt/datatransfer/HTMLDataFlavors/PutOnlyAllHtmlFlavorOnClipboard.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.*
;
import
java.awt.datatransfer.DataFlavor
;
public
class
PutOnlyAllHtmlFlavorOnClipboard
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"PutOnlyAllHtmlFlavorOnClipboard has been started."
);
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
().
setContents
(
new
HtmlTransferable
(
new
DataFlavor
[]{
DataFlavor
.
allHtmlFlavor
}),
null
);
System
.
out
.
println
(
"Data has been put on clipboard in a separate process"
);
}
}
test/java/awt/datatransfer/HTMLDataFlavors/PutSelectionAndFragmentHtmlFlavorsOnClipboard.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.*
;
import
java.awt.datatransfer.DataFlavor
;
public
class
PutSelectionAndFragmentHtmlFlavorsOnClipboard
{
public
static
void
main
(
String
[]
args
)
{
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
().
setContents
(
new
HtmlTransferable
(
new
DataFlavor
[]{
DataFlavor
.
selectionHtmlFlavor
,
DataFlavor
.
fragmentHtmlFlavor
}),
null
);
}
}
test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java
0 → 100644
浏览文件 @
33d7f099
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test @summary JVM crash if the frame is disposed in DropTargetListener
* @author Petr Pchelko
* @library ../../regtesthelpers
* @build Util
* @compile DisposeFrameOnDragTest.java
* @run main/othervm DisposeFrameOnDragTest
*/
import
java.awt.AWTException
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
java.awt.dnd.DropTargetAdapter
;
import
java.awt.dnd.DropTargetDragEvent
;
import
java.awt.dnd.DropTargetDropEvent
;
import
java.awt.event.InputEvent
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.TooManyListenersException
;
import
javax.swing.JFrame
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingUtilities
;
import
test.java.awt.regtesthelpers.Util
;
public
class
DisposeFrameOnDragTest
{
private
static
JTextArea
textArea
;
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
constructTestUI
();
}
});
Util
.
waitForIdle
(
null
);
try
{
Point
loc
=
textArea
.
getLocationOnScreen
();
Util
.
drag
(
new
Robot
(),
new
Point
((
int
)
loc
.
x
+
3
,
(
int
)
loc
.
y
+
3
),
new
Point
((
int
)
loc
.
x
+
40
,
(
int
)
loc
.
y
+
40
),
InputEvent
.
BUTTON1_MASK
);
}
catch
(
AWTException
ex
)
{
throw
new
RuntimeException
(
"Could not initiate a drag operation"
);
}
Util
.
waitForIdle
(
null
);
}
private
static
void
constructTestUI
()
{
final
JFrame
frame
=
new
JFrame
(
"Test frame"
);
textArea
=
new
JTextArea
(
"Drag Me!"
);
try
{
textArea
.
getDropTarget
().
addDropTargetListener
(
new
DropTargetAdapter
()
{
@Override
public
void
drop
(
DropTargetDropEvent
dtde
)
{
//IGNORE
}
@Override
public
void
dragOver
(
DropTargetDragEvent
dtde
)
{
frame
.
dispose
();
}
});
}
catch
(
TooManyListenersException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
textArea
.
setSize
(
100
,
100
);
textArea
.
setDragEnabled
(
true
);
textArea
.
select
(
0
,
textArea
.
getText
().
length
());
frame
.
add
(
textArea
);
frame
.
setBounds
(
100
,
100
,
100
,
100
);
frame
.
setVisible
(
true
);
}
}
test/javax/swing/JPopupMenu/6827786/bug6827786.java
浏览文件 @
33d7f099
/*
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -65,7 +65,11 @@ public class bug6827786 {
...
@@ -65,7 +65,11 @@ public class bug6827786 {
checkfocus
();
checkfocus
();
// select menu
// select menu
if
(
sun
.
awt
.
OSInfo
.
getOSType
()
==
sun
.
awt
.
OSInfo
.
OSType
.
MACOSX
)
{
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_CONTROL
,
KeyEvent
.
VK_ALT
,
KeyEvent
.
VK_F
);
}
else
{
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_ALT
,
KeyEvent
.
VK_F
);
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_ALT
,
KeyEvent
.
VK_F
);
}
// select submenu
// select submenu
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_S
);
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_S
);
toolkit
.
realSync
();
toolkit
.
realSync
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录