Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
95e12767
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95e12767
编写于
9月 18, 2009
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6840086: JFileChooser lacks icons on top right when running on Windows 7
Reviewed-by: peterz, uta
上级
faf9c616
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
138 addition
and
133 deletion
+138
-133
src/share/classes/sun/awt/shell/ShellFolderManager.java
src/share/classes/sun/awt/shell/ShellFolderManager.java
+3
-2
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
+1
-29
src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
...ndows/classes/sun/awt/shell/Win32ShellFolderManager2.java
+45
-29
src/windows/native/sun/windows/ShellFolder2.cpp
src/windows/native/sun/windows/ShellFolder2.cpp
+23
-73
test/javax/swing/JFileChooser/6840086/bug6840086.java
test/javax/swing/JFileChooser/6840086/bug6840086.java
+66
-0
未找到文件。
src/share/classes/sun/awt/shell/ShellFolderManager.java
浏览文件 @
95e12767
...
@@ -57,8 +57,9 @@ class ShellFolderManager {
...
@@ -57,8 +57,9 @@ class ShellFolderManager {
* folders, such as Desktop, Documents, History, Network, Home, etc.
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
* and Windows Me.
* "fileChooserIcon nn":
* "fileChooserIcon <icon>":
* Returns an <code>Image</code> - icon nn from resource 124 in comctl32.dll (Windows only).
* Returns an <code>Image</code> - icon can be ListView, DetailsView, UpFolder, NewFolder or
* ViewMenu (Windows only).
*
*
* @return An Object matching the key string.
* @return An Object matching the key string.
*/
*/
...
...
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
浏览文件 @
95e12767
...
@@ -922,7 +922,7 @@ final class Win32ShellFolder2 extends ShellFolder {
...
@@ -922,7 +922,7 @@ final class Win32ShellFolder2 extends ShellFolder {
// Dispose the HICON
// Dispose the HICON
private
static
native
void
disposeIcon
(
long
hIcon
);
private
static
native
void
disposeIcon
(
long
hIcon
);
public
static
native
int
[]
getFileChooserBitmapBits
(
);
static
native
int
[]
getStandardViewButton0
(
int
iconIndex
);
// Should be called from the COM thread
// Should be called from the COM thread
private
long
getIShellIcon
()
{
private
long
getIShellIcon
()
{
...
@@ -933,34 +933,6 @@ final class Win32ShellFolder2 extends ShellFolder {
...
@@ -933,34 +933,6 @@ final class Win32ShellFolder2 extends ShellFolder {
return
pIShellIcon
;
return
pIShellIcon
;
}
}
static
int
[]
fileChooserBitmapBits
=
null
;
static
Image
[]
fileChooserIcons
=
new
Image
[
47
];
static
Image
getFileChooserIcon
(
int
i
)
{
if
(
fileChooserIcons
[
i
]
!=
null
)
{
return
fileChooserIcons
[
i
];
}
else
{
if
(
fileChooserBitmapBits
==
null
)
{
fileChooserBitmapBits
=
getFileChooserBitmapBits
();
}
if
(
fileChooserBitmapBits
!=
null
)
{
int
nImages
=
fileChooserBitmapBits
.
length
/
(
16
*
16
);
int
[]
bitmapBits
=
new
int
[
16
*
16
];
for
(
int
y
=
0
;
y
<
16
;
y
++)
{
for
(
int
x
=
0
;
x
<
16
;
x
++)
{
bitmapBits
[
y
*
16
+
x
]
=
fileChooserBitmapBits
[
y
*
(
nImages
*
16
)
+
(
i
*
16
)
+
x
];
}
}
BufferedImage
img
=
new
BufferedImage
(
16
,
16
,
BufferedImage
.
TYPE_INT_ARGB
);
img
.
setRGB
(
0
,
0
,
16
,
16
,
bitmapBits
,
0
,
16
);
fileChooserIcons
[
i
]
=
img
;
}
}
return
fileChooserIcons
[
i
];
}
private
static
Image
makeIcon
(
long
hIcon
,
boolean
getLargeIcon
)
{
private
static
Image
makeIcon
(
long
hIcon
,
boolean
getLargeIcon
)
{
if
(
hIcon
!=
0L
&&
hIcon
!=
-
1L
)
{
if
(
hIcon
!=
0L
&&
hIcon
!=
-
1L
)
{
// Get the bits. This has the side effect of setting the imageHash value for this object.
// Get the bits. This has the side effect of setting the imageHash value for this object.
...
...
src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
浏览文件 @
95e12767
...
@@ -25,7 +25,8 @@
...
@@ -25,7 +25,8 @@
package
sun.awt.shell
;
package
sun.awt.shell
;
import
java.awt.Toolkit
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
...
@@ -33,6 +34,7 @@ import java.io.IOException;
...
@@ -33,6 +34,7 @@ import java.io.IOException;
import
java.security.AccessController
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedAction
;
import
java.util.*
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
import
sun.security.action.LoadLibraryAction
;
import
sun.security.action.LoadLibraryAction
;
...
@@ -98,6 +100,29 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
...
@@ -98,6 +100,29 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
return
parent
;
return
parent
;
}
}
private
static
final
int
VIEW_LIST
=
2
;
private
static
final
int
VIEW_DETAILS
=
3
;
private
static
final
int
VIEW_PARENTFOLDER
=
8
;
private
static
final
int
VIEW_NEWFOLDER
=
11
;
private
static
final
Image
[]
STANDARD_VIEW_BUTTONS
=
new
Image
[
12
];
private
static
Image
getStandardViewButton
(
int
iconIndex
)
{
Image
result
=
STANDARD_VIEW_BUTTONS
[
iconIndex
];
if
(
result
!=
null
)
{
return
result
;
}
BufferedImage
img
=
new
BufferedImage
(
16
,
16
,
BufferedImage
.
TYPE_INT_ARGB
);
img
.
setRGB
(
0
,
0
,
16
,
16
,
Win32ShellFolder2
.
getStandardViewButton0
(
iconIndex
),
0
,
16
);
STANDARD_VIEW_BUTTONS
[
iconIndex
]
=
img
;
return
img
;
}
// Special folders
// Special folders
private
static
Win32ShellFolder2
desktop
;
private
static
Win32ShellFolder2
desktop
;
private
static
Win32ShellFolder2
drives
;
private
static
Win32ShellFolder2
drives
;
...
@@ -105,12 +130,6 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
...
@@ -105,12 +130,6 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
private
static
Win32ShellFolder2
network
;
private
static
Win32ShellFolder2
network
;
private
static
Win32ShellFolder2
personal
;
private
static
Win32ShellFolder2
personal
;
private
static
final
boolean
USE_SHELL32_ICONS
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Boolean
>()
{
public
Boolean
run
()
{
return
OSInfo
.
getWindowsVersion
().
compareTo
(
OSInfo
.
WINDOWS_XP
)
>=
0
;
}
});
static
Win32ShellFolder2
getDesktop
()
{
static
Win32ShellFolder2
getDesktop
()
{
if
(
desktop
==
null
)
{
if
(
desktop
==
null
)
{
try
{
try
{
...
@@ -206,9 +225,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
...
@@ -206,9 +225,9 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
* folders, such as Desktop, Documents, History, Network, Home, etc.
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
* and Windows Me.
* "fileChooserIcon
nn
":
* "fileChooserIcon
<icon>
":
* Returns an <code>Image</code> - icon
nn from resource 216 in shell32.dll,
* Returns an <code>Image</code> - icon
can be ListView, DetailsView, UpFolder, NewFolder or
*
or if not found there from resource 124 in comctl32.dll
(Windows only).
*
ViewMenu
(Windows only).
* "optionPaneIcon iconName":
* "optionPaneIcon iconName":
* Returns an <code>Image</code> - icon from the system icon list
* Returns an <code>Image</code> - icon from the system icon list
*
*
...
@@ -303,26 +322,23 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
...
@@ -303,26 +322,23 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
}
}
return
folders
.
toArray
(
new
File
[
folders
.
size
()]);
return
folders
.
toArray
(
new
File
[
folders
.
size
()]);
}
else
if
(
key
.
startsWith
(
"fileChooserIcon "
))
{
}
else
if
(
key
.
startsWith
(
"fileChooserIcon "
))
{
int
i
=
-
1
;
String
name
=
key
.
substring
(
key
.
indexOf
(
" "
)
+
1
);
String
name
=
key
.
substring
(
key
.
indexOf
(
" "
)+
1
);
try
{
int
iconIndex
;
i
=
Integer
.
parseInt
(
name
);
}
catch
(
NumberFormatException
ex
)
{
if
(
name
.
equals
(
"ListView"
)
||
name
.
equals
(
"ViewMenu"
))
{
if
(
name
.
equals
(
"ListView"
))
{
iconIndex
=
VIEW_LIST
;
i
=
(
USE_SHELL32_ICONS
)
?
21
:
2
;
}
else
if
(
name
.
equals
(
"DetailsView"
))
{
}
else
if
(
name
.
equals
(
"DetailsView"
))
{
i
=
(
USE_SHELL32_ICONS
)
?
23
:
3
;
iconIndex
=
VIEW_DETAILS
;
}
else
if
(
name
.
equals
(
"UpFolder"
))
{
}
else
if
(
name
.
equals
(
"UpFolder"
))
{
i
=
(
USE_SHELL32_ICONS
)
?
28
:
8
;
iconIndex
=
VIEW_PARENTFOLDER
;
}
else
if
(
name
.
equals
(
"NewFolder"
))
{
}
else
if
(
name
.
equals
(
"NewFolder"
))
{
i
=
(
USE_SHELL32_ICONS
)
?
31
:
11
;
iconIndex
=
VIEW_NEWFOLDER
;
}
else
if
(
name
.
equals
(
"ViewMenu"
))
{
}
else
{
i
=
(
USE_SHELL32_ICONS
)
?
21
:
2
;
return
null
;
}
}
if
(
i
>=
0
)
{
return
Win32ShellFolder2
.
getFileChooserIcon
(
i
);
}
}
return
getStandardViewButton
(
iconIndex
);
}
else
if
(
key
.
startsWith
(
"optionPaneIcon "
))
{
}
else
if
(
key
.
startsWith
(
"optionPaneIcon "
))
{
Win32ShellFolder2
.
SystemIcon
iconType
;
Win32ShellFolder2
.
SystemIcon
iconType
;
if
(
key
==
"optionPaneIcon Error"
)
{
if
(
key
==
"optionPaneIcon Error"
)
{
...
...
src/windows/native/sun/windows/ShellFolder2.cpp
浏览文件 @
95e12767
...
@@ -256,7 +256,6 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolderManager2_uninitializeC
...
@@ -256,7 +256,6 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolderManager2_uninitializeC
static
IShellIcon
*
getIShellIcon
(
IShellFolder
*
pIShellFolder
)
{
static
IShellIcon
*
getIShellIcon
(
IShellFolder
*
pIShellFolder
)
{
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
HRESULT
hres
;
HRESULT
hres
;
HICON
hIcon
=
NULL
;
IShellIcon
*
pIShellIcon
;
IShellIcon
*
pIShellIcon
;
if
(
pIShellFolder
!=
NULL
)
{
if
(
pIShellFolder
!=
NULL
)
{
hres
=
pIShellFolder
->
QueryInterface
(
IID_IShellIcon
,
(
void
**
)
&
pIShellIcon
);
hres
=
pIShellFolder
->
QueryInterface
(
IID_IShellIcon
,
(
void
**
)
&
pIShellIcon
);
...
@@ -965,89 +964,40 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits
...
@@ -965,89 +964,40 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits
/*
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Class: sun_awt_shell_Win32ShellFolder2
* Method: get
FileChooserBitmapBits
* Method: get
StandardViewButton0
* Signature: ()[I
* Signature: (
I
)[I
*/
*/
JNIEXPORT
jintArray
JNICALL
Java_sun_awt_shell_Win32ShellFolder2_get
FileChooserBitmapBits
JNIEXPORT
jintArray
JNICALL
Java_sun_awt_shell_Win32ShellFolder2_get
StandardViewButton0
(
JNIEnv
*
env
,
jclass
cls
)
(
JNIEnv
*
env
,
jclass
cls
,
jint
iconIndex
)
{
{
HBITMAP
hBitmap
=
NULL
;
jintArray
result
=
NULL
;
BITMAP
bm
;
HINSTANCE
libComCtl32
;
HINSTANCE
libShell32
;
libShell32
=
LoadLibrary
(
TEXT
(
"shell32.dll"
));
// Create a toolbar
if
(
libShell32
!=
NULL
)
{
HWND
hWndToolbar
=
::
CreateWindowEx
(
0
,
TOOLBARCLASSNAME
,
NULL
,
hBitmap
=
(
HBITMAP
)
LoadImage
(
libShell32
,
0
,
0
,
0
,
0
,
0
,
IS_WINVISTA
?
TEXT
(
"IDB_TB_SH_DEF_16"
)
:
MAKEINTRESOURCE
(
216
),
NULL
,
NULL
,
NULL
,
NULL
);
IMAGE_BITMAP
,
0
,
0
,
LR_CREATEDIBSECTION
);
if
(
hBitmap
==
NULL
)
{
if
(
hWndToolbar
!=
NULL
)
{
// version of shell32.dll doesn't match OS version.
SendMessage
(
hWndToolbar
,
TB_LOADIMAGES
,
(
WPARAM
)
IDB_VIEW_SMALL_COLOR
,
(
LPARAM
)
HINST_COMMCTRL
);
// So we either are in a Vista Compatibility Mode
// or shell32.dll was copied from OS of another version
hBitmap
=
(
HBITMAP
)
LoadImage
(
libShell32
,
IS_WINVISTA
?
MAKEINTRESOURCE
(
216
)
:
TEXT
(
"IDB_TB_SH_DEF_16"
),
IMAGE_BITMAP
,
0
,
0
,
LR_CREATEDIBSECTION
);
}
}
if
(
hBitmap
==
NULL
)
{
libComCtl32
=
LoadLibrary
(
TEXT
(
"comctl32.dll"
));
if
(
libComCtl32
!=
NULL
)
{
hBitmap
=
(
HBITMAP
)
LoadImage
(
libComCtl32
,
MAKEINTRESOURCE
(
124
),
IMAGE_BITMAP
,
0
,
0
,
LR_CREATEDIBSECTION
);
}
}
if
(
hBitmap
==
NULL
)
{
return
NULL
;
}
GetObject
(
hBitmap
,
sizeof
(
bm
),
(
LPSTR
)
&
bm
);
HIMAGELIST
hImageList
=
(
HIMAGELIST
)
SendMessage
(
hWndToolbar
,
TB_GETIMAGELIST
,
0
,
0
);
// Get the screen DC
if
(
hImageList
!=
NULL
)
{
HDC
dc
=
GetDC
(
NULL
);
HICON
hIcon
=
ImageList_GetIcon
(
hImageList
,
iconIndex
,
ILD_TRANSPARENT
);
if
(
dc
==
NULL
)
{
return
NULL
;
}
// Set up BITMAPINFO
if
(
hIcon
!=
NULL
)
{
BITMAPINFO
bmi
;
result
=
Java_sun_awt_shell_Win32ShellFolder2_getIconBits
(
env
,
cls
,
ptr_to_jlong
(
hIcon
),
16
);
memset
(
&
bmi
,
0
,
sizeof
(
BITMAPINFO
));
bmi
.
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bmi
.
bmiHeader
.
biWidth
=
bm
.
bmWidth
;
bmi
.
bmiHeader
.
biHeight
=
-
bm
.
bmHeight
;
bmi
.
bmiHeader
.
biPlanes
=
1
;
bmi
.
bmiHeader
.
biBitCount
=
32
;
bmi
.
bmiHeader
.
biCompression
=
BI_RGB
;
// Extract the color bitmap
int
numPixels
=
bm
.
bmWidth
*
bm
.
bmHeight
;
//long colorBits[192 * 16];
long
*
colorBits
=
(
long
*
)
safe_Malloc
(
numPixels
*
sizeof
(
long
));
if
(
GetDIBits
(
dc
,
hBitmap
,
0
,
bm
.
bmHeight
,
colorBits
,
&
bmi
,
DIB_RGB_COLORS
)
==
0
)
{
return
NULL
;
}
// Release DC
DestroyIcon
(
hIcon
);
ReleaseDC
(
NULL
,
dc
);
}
// The color of the first pixel defines the transparency, according
ImageList_Destroy
(
hImageList
);
// to the documentation for LR_LOADTRANSPARENT at
// http://msdn.microsoft.com/library/psdk/winui/resource_9fhi.htm
long
transparent
=
colorBits
[
0
];
for
(
int
i
=
0
;
i
<
numPixels
;
i
++
)
{
if
(
colorBits
[
i
]
!=
transparent
)
{
colorBits
[
i
]
|=
0xff000000
;
}
}
DestroyWindow
(
hWndToolbar
);
}
}
// Create java array
return
result
;
jintArray
bits
=
env
->
NewIntArray
(
numPixels
);
// Copy values to java array
env
->
SetIntArrayRegion
(
bits
,
0
,
numPixels
,
colorBits
);
// Fix 4745575 GDI Resource Leak
::
DeleteObject
(
hBitmap
);
::
FreeLibrary
(
libComCtl32
);
return
bits
;
}
}
/*
/*
...
...
test/javax/swing/JFileChooser/6840086/bug6840086.java
0 → 100644
浏览文件 @
95e12767
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6840086
@summary JFileChooser lacks icons on top right when running on Windows 7
@author Pavel Porvatov
@run main bug6840086
*/
import
sun.awt.OSInfo
;
import
sun.awt.shell.ShellFolder
;
import
java.awt.*
;
public
class
bug6840086
{
private
static
final
String
[]
KEYS
=
{
"fileChooserIcon ListView"
,
"fileChooserIcon ViewMenu"
,
"fileChooserIcon DetailsView"
,
"fileChooserIcon UpFolder"
,
"fileChooserIcon NewFolder"
,
};
public
static
void
main
(
String
[]
args
)
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
)
{
System
.
out
.
println
(
"The test was skipped because it is sensible only for Windows."
);
return
;
}
for
(
String
key
:
KEYS
)
{
Image
image
=
(
Image
)
ShellFolder
.
get
(
key
);
if
(
image
==
null
)
{
throw
new
RuntimeException
(
"The image '"
+
key
+
"' not found."
);
}
if
(
image
!=
ShellFolder
.
get
(
key
))
{
throw
new
RuntimeException
(
"The image '"
+
key
+
"' is not cached."
);
}
}
System
.
out
.
println
(
"The test passed."
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录