Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
bafc6e8b
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看板
提交
bafc6e8b
编写于
8月 27, 2008
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6351074: JFileChooser removes leading space in filename
Summary: Removed trimming of leading spaces in filename Reviewed-by: alexp
上级
363ab66c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
82 addition
and
82 deletion
+82
-82
src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
...re/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
+82
-82
未找到文件。
src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
浏览文件 @
bafc6e8b
...
...
@@ -36,6 +36,7 @@ import java.awt.datatransfer.*;
import
java.beans.*
;
import
java.io.*
;
import
java.util.*
;
import
java.util.List
;
import
java.util.regex.*
;
import
sun.awt.shell.ShellFolder
;
import
sun.swing.*
;
...
...
@@ -829,11 +830,17 @@ public class BasicFileChooserUI extends FileChooserUI {
File
dir
=
chooser
.
getCurrentDirectory
();
if
(
filename
!=
null
)
{
// Remove whitespace from beginning and end of filename
filename
=
filename
.
trim
();
// Remove whitespaces from end of filename
int
i
=
filename
.
length
()
-
1
;
while
(
i
>=
0
&&
filename
.
charAt
(
i
)
<=
' '
)
{
i
--;
}
filename
=
filename
.
substring
(
0
,
i
+
1
);
}
if
(
filename
==
null
||
filename
.
equals
(
""
)
)
{
if
(
filename
==
null
||
filename
.
length
()
==
0
)
{
// no file selected, multiple selection off, therefore cancel the approve action
resetGlobFilter
();
return
;
...
...
@@ -842,100 +849,93 @@ public class BasicFileChooserUI extends FileChooserUI {
File
selectedFile
=
null
;
File
[]
selectedFiles
=
null
;
if
(
filename
!=
null
&&
!
filename
.
equals
(
""
))
{
// Unix: Resolve '~' to user's home directory
if
(
File
.
separatorChar
==
'/'
)
{
if
(
filename
.
startsWith
(
"~/"
))
{
filename
=
System
.
getProperty
(
"user.home"
)
+
filename
.
substring
(
1
);
}
else
if
(
filename
.
equals
(
"~"
))
{
filename
=
System
.
getProperty
(
"user.home"
);
}
// Unix: Resolve '~' to user's home directory
if
(
File
.
separatorChar
==
'/'
)
{
if
(
filename
.
startsWith
(
"~/"
))
{
filename
=
System
.
getProperty
(
"user.home"
)
+
filename
.
substring
(
1
);
}
else
if
(
filename
.
equals
(
"~"
))
{
filename
=
System
.
getProperty
(
"user.home"
);
}
}
if
(
chooser
.
isMultiSelectionEnabled
()
&&
filename
.
startsWith
(
"\""
))
{
ArrayList
<
File
>
fList
=
new
ArrayList
<
File
>();
if
(
chooser
.
isMultiSelectionEnabled
()
&&
filename
.
length
()
>
1
&&
filename
.
charAt
(
0
)
==
'"'
&&
filename
.
charAt
(
filename
.
length
()
-
1
)
==
'"'
)
{
List
<
File
>
fList
=
new
ArrayList
<
File
>();
filename
=
filename
.
substring
(
1
);
if
(
filename
.
endsWith
(
"\""
))
{
filename
=
filename
.
substring
(
0
,
filename
.
length
()-
1
);
}
File
[]
children
=
null
;
int
childIndex
=
0
;
do
{
String
str
;
int
i
=
filename
.
indexOf
(
"\" \""
);
if
(
i
>
0
)
{
str
=
filename
.
substring
(
0
,
i
);
filename
=
filename
.
substring
(
i
+
3
);
}
else
{
str
=
filename
;
filename
=
""
;
String
[]
files
=
filename
.
substring
(
1
,
filename
.
length
()
-
1
).
split
(
"\" \""
);
// Optimize searching files by names in "children" array
Arrays
.
sort
(
files
);
File
[]
children
=
null
;
int
childIndex
=
0
;
for
(
String
str
:
files
)
{
File
file
=
fs
.
createFileObject
(
str
);
if
(!
file
.
isAbsolute
())
{
if
(
children
==
null
)
{
children
=
fs
.
getFiles
(
dir
,
false
);
Arrays
.
sort
(
children
);
}
File
file
=
fs
.
createFileObject
(
str
);
if
(!
file
.
isAbsolute
())
{
if
(
children
==
null
)
{
children
=
fs
.
getFiles
(
dir
,
false
);
Arrays
.
sort
(
children
);
}
for
(
int
k
=
0
;
k
<
children
.
length
;
k
++)
{
int
l
=
(
childIndex
+
k
)
%
children
.
length
;
if
(
children
[
l
].
getName
().
equals
(
str
))
{
file
=
children
[
l
];
childIndex
=
l
+
1
;
break
;
}
for
(
int
k
=
0
;
k
<
children
.
length
;
k
++)
{
int
l
=
(
childIndex
+
k
)
%
children
.
length
;
if
(
children
[
l
].
getName
().
equals
(
str
))
{
file
=
children
[
l
];
childIndex
=
l
+
1
;
break
;
}
}
fList
.
add
(
file
);
}
while
(
filename
.
length
()
>
0
);
if
(
fList
.
size
()
>
0
)
{
selectedFiles
=
fList
.
toArray
(
new
File
[
fList
.
size
()]);
}
resetGlobFilter
();
}
else
{
selectedFile
=
fs
.
createFileObject
(
filename
);
if
(!
selectedFile
.
isAbsolute
())
{
selectedFile
=
fs
.
getChild
(
dir
,
filename
);
fList
.
add
(
file
);
}
if
(!
fList
.
isEmpty
())
{
selectedFiles
=
fList
.
toArray
(
new
File
[
fList
.
size
()]);
}
resetGlobFilter
();
}
else
{
selectedFile
=
fs
.
createFileObject
(
filename
);
if
(!
selectedFile
.
isAbsolute
())
{
selectedFile
=
fs
.
getChild
(
dir
,
filename
);
}
// check for wildcard pattern
FileFilter
currentFilter
=
chooser
.
getFileFilter
();
if
(!
selectedFile
.
exists
()
&&
isGlobPattern
(
filename
))
{
changeDirectory
(
selectedFile
.
getParentFile
());
if
(
globFilter
==
null
)
{
globFilter
=
new
GlobFilter
();
}
// check for wildcard pattern
FileFilter
currentFilter
=
chooser
.
getFileFilter
();
if
(!
selectedFile
.
exists
()
&&
isGlobPattern
(
filename
))
{
changeDirectory
(
selectedFile
.
getParentFile
());
if
(
globFilter
==
null
)
{
globFilter
=
new
GlobFilter
();
}
try
{
globFilter
.
setPattern
(
selectedFile
.
getName
());
if
(!(
currentFilter
instanceof
GlobFilter
))
{
actualFileFilter
=
currentFilter
;
}
chooser
.
setFileFilter
(
null
);
chooser
.
setFileFilter
(
globFilter
);
return
;
}
catch
(
PatternSyntaxException
pse
)
{
// Not a valid glob pattern. Abandon filter.
try
{
globFilter
.
setPattern
(
selectedFile
.
getName
());
if
(!(
currentFilter
instanceof
GlobFilter
))
{
actualFileFilter
=
currentFilter
;
}
chooser
.
setFileFilter
(
null
);
chooser
.
setFileFilter
(
globFilter
);
return
;
}
catch
(
PatternSyntaxException
pse
)
{
// Not a valid glob pattern. Abandon filter.
}
}
resetGlobFilter
();
resetGlobFilter
();
// Check for directory change action
boolean
isDir
=
(
selectedFile
!=
null
&&
selectedFile
.
isDirectory
());
boolean
isTrav
=
(
selectedFile
!=
null
&&
chooser
.
isTraversable
(
selectedFile
));
boolean
isDirSelEnabled
=
chooser
.
isDirectorySelectionEnabled
();
boolean
isFileSelEnabled
=
chooser
.
isFileSelectionEnabled
();
boolean
isCtrl
=
(
e
!=
null
&&
(
e
.
getModifiers
()
&
ActionEvent
.
CTRL_MASK
)
!=
0
);
// Check for directory change action
boolean
isDir
=
(
selectedFile
!=
null
&&
selectedFile
.
isDirectory
());
boolean
isTrav
=
(
selectedFile
!=
null
&&
chooser
.
isTraversable
(
selectedFile
));
boolean
isDirSelEnabled
=
chooser
.
isDirectorySelectionEnabled
();
boolean
isFileSelEnabled
=
chooser
.
isFileSelectionEnabled
();
boolean
isCtrl
=
(
e
!=
null
&&
(
e
.
getModifiers
()
&
ActionEvent
.
CTRL_MASK
)
!=
0
);
if
(
isDir
&&
isTrav
&&
(
isCtrl
||
!
isDirSelEnabled
))
{
changeDirectory
(
selectedFile
);
return
;
}
else
if
((
isDir
||
!
isFileSelEnabled
)
&&
(!
isDir
||
!
isDirSelEnabled
)
&&
(!
isDirSelEnabled
||
selectedFile
.
exists
()))
{
selectedFile
=
null
;
}
if
(
isDir
&&
isTrav
&&
(
isCtrl
||
!
isDirSelEnabled
))
{
changeDirectory
(
selectedFile
);
return
;
}
else
if
((
isDir
||
!
isFileSelEnabled
)
&&
(!
isDir
||
!
isDirSelEnabled
)
&&
(!
isDirSelEnabled
||
selectedFile
.
exists
()))
{
selectedFile
=
null
;
}
}
if
(
selectedFiles
!=
null
||
selectedFile
!=
null
)
{
if
(
selectedFiles
!=
null
||
chooser
.
isMultiSelectionEnabled
())
{
if
(
selectedFiles
==
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录