Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f0684078
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,发现更多精彩内容 >>
提交
f0684078
编写于
11月 25, 2008
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6698013: JFileChooser can no longer navigate non-local file systems.
Summary: ShellFolder is used only if possible Reviewed-by: peterz
上级
5235464d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
193 addition
and
1 deletion
+193
-1
src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
...re/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
+1
-1
src/share/classes/sun/swing/FilePane.java
src/share/classes/sun/swing/FilePane.java
+10
-0
test/javax/swing/JFileChooser/6698013/bug6698013.html
test/javax/swing/JFileChooser/6698013/bug6698013.html
+8
-0
test/javax/swing/JFileChooser/6698013/bug6698013.java
test/javax/swing/JFileChooser/6698013/bug6698013.java
+174
-0
未找到文件。
src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
浏览文件 @
f0684078
...
...
@@ -1132,7 +1132,7 @@ public class BasicFileChooserUI extends FileChooserUI {
private
void
changeDirectory
(
File
dir
)
{
JFileChooser
fc
=
getFileChooser
();
// Traverse shortcuts on Windows
if
(
dir
!=
null
&&
File
.
separatorChar
==
'\\'
&&
dir
.
getPath
().
endsWith
(
".lnk"
))
{
if
(
dir
!=
null
&&
File
Pane
.
usesShellFolder
(
fc
))
{
try
{
File
linkedTo
=
ShellFolder
.
getShellFolder
(
dir
).
getLinkLocation
();
if
(
linkedTo
!=
null
&&
fc
.
isTraversable
(
linkedTo
))
{
...
...
src/share/classes/sun/swing/FilePane.java
浏览文件 @
f0684078
...
...
@@ -1961,6 +1961,16 @@ public class FilePane extends JPanel implements PropertyChangeListener {
}
}
/**
* Returns true if specified FileChooser should use ShellFolder
*/
public
static
boolean
usesShellFolder
(
JFileChooser
chooser
)
{
Boolean
prop
=
(
Boolean
)
chooser
.
getClientProperty
(
"FileChooser.useShellFolder"
);
return
prop
==
null
?
chooser
.
getFileSystemView
().
equals
(
FileSystemView
.
getFileSystemView
())
:
prop
.
booleanValue
();
}
// This interface is used to access methods in the FileChooserUI
// that are not public.
public
interface
FileChooserUIAccessor
{
...
...
test/javax/swing/JFileChooser/6698013/bug6698013.html
0 → 100644
浏览文件 @
f0684078
<html>
<body>
<applet
code=
"bug6698013.class"
width=
200
height=
200
></applet>
1. Go into 'subdir' folder via double click
2. Return to parent directory
3. Go into 'subdir' folder: select 'subdir' folder and press the 'Open' button
</body>
</html>
test/javax/swing/JFileChooser/6698013/bug6698013.java
0 → 100644
浏览文件 @
f0684078
/* @test %W% %E%
@bug 6698013
@summary JFileChooser can no longer navigate non-local file systems.
@author Pavel Porvatov
@run applet/manual=done bug6698013.html
*/
import
javax.swing.*
;
import
javax.swing.filechooser.FileSystemView
;
import
java.io.File
;
public
class
bug6698013
extends
JApplet
{
final
static
VirtualFile
root
=
new
VirtualFile
(
"testdir"
,
true
);
final
static
VirtualFile
rootFile
=
new
VirtualFile
(
"testdir/test.txt"
,
false
);
final
static
VirtualFile
subdir
=
new
VirtualFile
(
"testdir/subdir"
,
true
);
final
static
VirtualFile
subdirFile
=
new
VirtualFile
(
"testdir/subdir/subtest.txt"
,
false
);
public
static
void
main
(
String
[]
args
)
{
JFileChooser
chooser
=
new
JFileChooser
(
new
VirtualFileSystemView
());
chooser
.
setCurrentDirectory
(
root
);
chooser
.
showSaveDialog
(
null
);
}
public
void
init
()
{
JFileChooser
chooser
=
new
JFileChooser
(
new
VirtualFileSystemView
());
chooser
.
setCurrentDirectory
(
root
);
chooser
.
showSaveDialog
(
null
);
}
}
class
VirtualFileSystemView
extends
FileSystemView
{
public
boolean
isRoot
(
File
dir
)
{
return
bug6698013
.
root
.
equals
(
dir
);
}
public
File
createNewFolder
(
File
dir
)
{
return
null
;
}
public
File
[]
getRoots
()
{
return
new
File
[]{
bug6698013
.
root
};
}
public
boolean
isDrive
(
File
dir
)
{
return
false
;
}
public
boolean
isFloppyDrive
(
File
dir
)
{
return
false
;
}
public
File
getParentDirectory
(
File
dir
)
{
if
(
dir
==
null
)
{
return
null
;
}
return
new
VirtualFile
(
dir
.
getPath
(),
true
).
getParentFile
();
}
public
File
[]
getFiles
(
File
dir
,
boolean
hide_hidden
)
{
if
(
dir
.
equals
(
bug6698013
.
root
))
{
return
new
File
[]{
bug6698013
.
rootFile
,
bug6698013
.
subdir
};
}
if
(
dir
.
equals
(
bug6698013
.
subdir
))
{
return
new
File
[]{
bug6698013
.
subdirFile
};
}
return
null
;
}
public
File
getHomeDirectory
()
{
return
bug6698013
.
root
;
}
public
File
getDefaultDirectory
()
{
return
getHomeDirectory
();
}
public
String
getSystemDisplayName
(
File
file
)
{
return
file
.
getName
();
}
public
Boolean
isTraversable
(
File
file
)
{
return
Boolean
.
valueOf
(
file
.
isDirectory
());
}
}
/**
* A Virtual File. Contains a path and a directory flag that
* represents the location of a virtual file to be contained in the
* Virtual FileSystemView.
*/
class
VirtualFile
extends
File
{
private
static
final
long
serialVersionUID
=
0L
;
private
String
path
;
private
boolean
directory
;
public
VirtualFile
(
String
path
,
boolean
directory
)
{
super
(
path
);
this
.
path
=
path
;
this
.
directory
=
directory
;
}
public
File
getParentFile
()
{
int
index
=
path
.
lastIndexOf
(
'/'
);
if
(
index
==
-
1
)
{
return
null
;
}
return
new
VirtualFile
(
path
.
substring
(
0
,
index
),
true
);
}
public
File
getCanonicalFile
()
{
return
this
;
}
public
String
getParent
()
{
File
parent_file
=
getParentFile
();
return
parent_file
==
null
?
null
:
parent_file
.
getPath
();
}
public
String
getName
()
{
int
index
=
path
.
lastIndexOf
(
'/'
);
return
index
==
-
1
?
path
:
path
.
substring
(
index
+
1
);
}
public
String
getPath
()
{
return
path
;
}
public
String
getAbsolutePath
()
{
return
path
;
}
public
String
getCanonicalPath
()
{
return
path
;
}
public
String
toString
()
{
return
path
;
}
public
boolean
equals
(
Object
obj
)
{
return
obj
instanceof
VirtualFile
&&
path
.
equals
(
obj
.
toString
());
}
public
int
hashCode
()
{
return
path
.
hashCode
();
}
public
boolean
canWrite
()
{
return
true
;
}
public
boolean
isDirectory
()
{
return
directory
;
}
public
boolean
exists
()
{
return
true
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录