Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d564a218
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看板
提交
d564a218
编写于
4月 09, 2014
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010718: [macosx] JFileChooser current filter nullified by addChoosableFileFilter
Reviewed-by: serb
上级
95eea3ea
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
41 deletion
+47
-41
src/macosx/classes/com/apple/laf/AquaFileChooserUI.java
src/macosx/classes/com/apple/laf/AquaFileChooserUI.java
+47
-41
未找到文件。
src/macosx/classes/com/apple/laf/AquaFileChooserUI.java
浏览文件 @
d564a218
...
@@ -1266,64 +1266,70 @@ public class AquaFileChooserUI extends FileChooserUI {
...
@@ -1266,64 +1266,70 @@ public class AquaFileChooserUI extends FileChooserUI {
/**
/**
* Data model for a type-face selection combo-box.
* Data model for a type-face selection combo-box.
*/
*/
protected
class
FilterComboBoxModel
extends
DefaultListModel
implements
ComboBoxModel
,
PropertyChangeListener
{
protected
class
FilterComboBoxModel
extends
AbstractListModel
<
FileFilter
>
implements
ComboBoxModel
<
FileFilter
>,
int
selectedIndex
=
-
1
;
PropertyChangeListener
{
protected
FileFilter
[]
filters
;
protected
FilterComboBoxModel
()
{
protected
FilterComboBoxModel
()
{
super
();
super
();
final
FileFilter
filters
[]
=
getFileChooser
().
getChoosableFileFilters
();
filters
=
getFileChooser
().
getChoosableFileFilters
();
for
(
int
i
=
0
;
i
<
filters
.
length
;
i
++)
{
this
.
add
(
i
,
filters
[
i
]);
}
}
}
public
void
propertyChange
(
final
PropertyChangeEvent
e
)
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
final
String
prop
=
e
.
getPropertyName
();
String
prop
=
e
.
getPropertyName
();
if
(
prop
==
JFileChooser
.
CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
)
{
if
(
prop
==
JFileChooser
.
CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
)
{
this
.
clear
();
filters
=
(
FileFilter
[])
e
.
getNewValue
();
final
FileFilter
filters
[]
=
(
FileFilter
[])
e
.
getNewValue
();
for
(
int
i
=
0
;
i
<
filters
.
length
;
i
++)
{
this
.
add
(
i
,
filters
[
i
]);
}
fireContentsChanged
(
this
,
-
1
,
-
1
);
fireContentsChanged
(
this
,
-
1
,
-
1
);
}
else
if
(
prop
==
JFileChooser
.
FILE_FILTER_CHANGED_PROPERTY
)
{
}
else
if
(
prop
==
JFileChooser
.
FILE_FILTER_CHANGED_PROPERTY
)
{
final
FileFilter
currentFilter
=
(
FileFilter
)
e
.
getNewValue
();
fireContentsChanged
(
this
,
-
1
,
-
1
);
FileFilter
filters
[]
=
getFileChooser
().
getChoosableFileFilters
();
boolean
found
=
false
;
if
(
currentFilter
!=
null
)
{
for
(
final
FileFilter
element
:
filters
)
{
if
(
element
==
currentFilter
)
{
found
=
true
;
}
}
if
(
found
==
false
)
{
getFileChooser
().
addChoosableFileFilter
(
currentFilter
);
}
}
filters
=
getFileChooser
().
getChoosableFileFilters
();
setSelectedItem
(
e
.
getNewValue
());
}
}
}
}
public
void
setSelectedItem
(
final
Object
filter
)
{
public
void
setSelectedItem
(
Object
filter
)
{
if
(
filter
!=
null
)
{
if
(
filter
!=
null
)
{
selectedIndex
=
this
.
indexOf
(
filter
);
getFileChooser
().
setFileFilter
((
FileFilter
)
filter
);
fireContentsChanged
(
this
,
-
1
,
-
1
);
fireContentsChanged
(
this
,
-
1
,
-
1
);
}
}
}
}
public
Object
getSelectedItem
()
{
public
Object
getSelectedItem
()
{
final
Object
returnValue
=
null
;
// Ensure that the current filter is in the list.
// NOTE: we shouldnt' have to do this, since JFileChooser adds
// the filter to the choosable filters list when the filter
// is set. Lets be paranoid just in case someone overrides
// setFileFilter in JFileChooser.
FileFilter
currentFilter
=
getFileChooser
().
getFileFilter
();
boolean
found
=
false
;
if
(
currentFilter
!=
null
)
{
for
(
FileFilter
filter
:
filters
)
{
if
(
filter
==
currentFilter
)
{
found
=
true
;
}
}
if
(
found
==
false
)
{
getFileChooser
().
addChoosableFileFilter
(
currentFilter
);
}
}
return
getFileChooser
().
getFileFilter
();
}
if
(
this
.
size
()
>
0
)
{
public
int
getSize
()
{
if
((
selectedIndex
!=
-
1
)
&&
(
selectedIndex
<
size
()))
{
return
this
.
get
(
selectedIndex
);
}
if
(
filters
!=
null
)
{
return
filters
.
length
;
}
else
{
return
0
;
}
}
}
return
returnValue
;
public
FileFilter
getElementAt
(
int
index
)
{
if
(
index
>
getSize
()
-
1
)
{
// This shouldn't happen. Try to recover gracefully.
return
getFileChooser
().
getFileFilter
();
}
if
(
filters
!=
null
)
{
return
filters
[
index
];
}
else
{
return
null
;
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录