Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
幽默龙
luyten
提交
75d5603b
L
luyten
项目概览
幽默龙
/
luyten
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
luyten
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
75d5603b
编写于
4月 15, 2019
作者:
D
Deathmarine
提交者:
GitHub
4月 15, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #149 from refactormachine/feature/refactored-file-dialog
Refactored the file dialog preferences
上级
f1ccf991
13678d9a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
63 deletion
+77
-63
src/us/deathmarine/luyten/DirPreferences.java
src/us/deathmarine/luyten/DirPreferences.java
+62
-0
src/us/deathmarine/luyten/FileDialog.java
src/us/deathmarine/luyten/FileDialog.java
+15
-63
未找到文件。
src/us/deathmarine/luyten/DirPreferences.java
0 → 100644
浏览文件 @
75d5603b
package
us.deathmarine.luyten
;
import
javax.swing.*
;
import
java.io.File
;
class
DirPreferences
{
private
LuytenPreferences
luytenPrefs
;
public
DirPreferences
(
LuytenPreferences
luytenPrefs
)
{
this
.
luytenPrefs
=
luytenPrefs
;
}
void
retrieveOpenDialogDir
(
JFileChooser
fc
)
{
try
{
String
currentDirStr
=
luytenPrefs
.
getFileOpenCurrentDirectory
();
if
(
currentDirStr
!=
null
&&
currentDirStr
.
trim
().
length
()
>
0
)
{
File
currentDir
=
new
File
(
currentDirStr
);
if
(
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
fc
.
setCurrentDirectory
(
currentDir
);
}
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
void
saveOpenDialogDir
(
JFileChooser
fc
)
{
try
{
File
currentDir
=
fc
.
getCurrentDirectory
();
if
(
currentDir
!=
null
&&
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
luytenPrefs
.
setFileOpenCurrentDirectory
(
currentDir
.
getAbsolutePath
());
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
void
retrieveSaveDialogDir
(
JFileChooser
fc
)
{
try
{
String
currentDirStr
=
luytenPrefs
.
getFileSaveCurrentDirectory
();
if
(
currentDirStr
!=
null
&&
currentDirStr
.
trim
().
length
()
>
0
)
{
File
currentDir
=
new
File
(
currentDirStr
);
if
(
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
fc
.
setCurrentDirectory
(
currentDir
);
}
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
void
saveSaveDialogDir
(
JFileChooser
fc
)
{
try
{
File
currentDir
=
fc
.
getCurrentDirectory
();
if
(
currentDir
!=
null
&&
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
luytenPrefs
.
setFileSaveCurrentDirectory
(
currentDir
.
getAbsolutePath
());
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
}
\ No newline at end of file
src/us/deathmarine/luyten/FileDialog.java
浏览文件 @
75d5603b
...
...
@@ -9,9 +9,9 @@ import javax.swing.filechooser.FileFilter;
* FileChoosers for Open and Save
*/
public
class
FileDialog
{
private
ConfigSaver
configSaver
;
private
LuytenPreferences
luytenPrefs
;
private
Component
parent
;
private
final
DirPreferences
dirPreferences
;
private
ConfigSaver
configSaver
;
private
Component
parent
;
private
JFileChooser
fcOpen
;
private
JFileChooser
fcSave
;
private
JFileChooser
fcSaveAll
;
...
...
@@ -19,9 +19,10 @@ public class FileDialog {
public
FileDialog
(
Component
parent
)
{
this
.
parent
=
parent
;
configSaver
=
ConfigSaver
.
getLoadedInstance
();
luytenPrefs
=
configSaver
.
getLuytenPreferences
();
LuytenPreferences
luytenPrefs
=
configSaver
.
getLuytenPreferences
();
dirPreferences
=
new
DirPreferences
(
luytenPrefs
);
new
Thread
()
{
new
Thread
()
{
public
void
run
()
{
try
{
initOpenDialog
();
...
...
@@ -40,9 +41,9 @@ public class FileDialog {
File
selectedFile
=
null
;
initOpenDialog
();
retrieveOpenDialogDir
(
fcOpen
);
dirPreferences
.
retrieveOpenDialogDir
(
fcOpen
);
int
returnVal
=
fcOpen
.
showOpenDialog
(
parent
);
saveOpenDialogDir
(
fcOpen
);
dirPreferences
.
saveOpenDialogDir
(
fcOpen
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
selectedFile
=
fcOpen
.
getSelectedFile
();
...
...
@@ -54,10 +55,10 @@ public class FileDialog {
File
selectedFile
=
null
;
initSaveDialog
();
retrieveSaveDialogDir
(
fcSave
);
dirPreferences
.
retrieveSaveDialogDir
(
fcSave
);
fcSave
.
setSelectedFile
(
new
File
(
recommendedFileName
));
int
returnVal
=
fcSave
.
showSaveDialog
(
parent
);
saveSaveDialogDir
(
fcSave
);
dirPreferences
.
saveSaveDialogDir
(
fcSave
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
selectedFile
=
fcSave
.
getSelectedFile
();
...
...
@@ -69,10 +70,10 @@ public class FileDialog {
File
selectedFile
=
null
;
initSaveAllDialog
();
retrieveSaveDialogDir
(
fcSaveAll
);
dirPreferences
.
retrieveSaveDialogDir
(
fcSaveAll
);
fcSaveAll
.
setSelectedFile
(
new
File
(
recommendedFileName
));
int
returnVal
=
fcSaveAll
.
showSaveDialog
(
parent
);
saveSaveDialogDir
(
fcSaveAll
);
dirPreferences
.
saveSaveDialogDir
(
fcSaveAll
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
selectedFile
=
fcSaveAll
.
getSelectedFile
();
...
...
@@ -83,21 +84,21 @@ public class FileDialog {
public
synchronized
void
initOpenDialog
()
{
if
(
fcOpen
==
null
)
{
fcOpen
=
createFileChooser
(
"*.jar"
,
"*.zip"
,
"*.class"
);
retrieveOpenDialogDir
(
fcOpen
);
dirPreferences
.
retrieveOpenDialogDir
(
fcOpen
);
}
}
public
synchronized
void
initSaveDialog
()
{
if
(
fcSave
==
null
)
{
fcSave
=
createFileChooser
(
"*.txt"
,
"*.java"
);
retrieveSaveDialogDir
(
fcSave
);
dirPreferences
.
retrieveSaveDialogDir
(
fcSave
);
}
}
public
synchronized
void
initSaveAllDialog
()
{
if
(
fcSaveAll
==
null
)
{
fcSaveAll
=
createFileChooser
(
"*.jar"
,
"*.zip"
);
retrieveSaveDialogDir
(
fcSaveAll
);
dirPreferences
.
retrieveSaveDialogDir
(
fcSaveAll
);
}
}
...
...
@@ -131,53 +132,4 @@ public class FileDialog {
}
}
private
void
retrieveOpenDialogDir
(
JFileChooser
fc
)
{
try
{
String
currentDirStr
=
luytenPrefs
.
getFileOpenCurrentDirectory
();
if
(
currentDirStr
!=
null
&&
currentDirStr
.
trim
().
length
()
>
0
)
{
File
currentDir
=
new
File
(
currentDirStr
);
if
(
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
fc
.
setCurrentDirectory
(
currentDir
);
}
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
private
void
saveOpenDialogDir
(
JFileChooser
fc
)
{
try
{
File
currentDir
=
fc
.
getCurrentDirectory
();
if
(
currentDir
!=
null
&&
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
luytenPrefs
.
setFileOpenCurrentDirectory
(
currentDir
.
getAbsolutePath
());
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
private
void
retrieveSaveDialogDir
(
JFileChooser
fc
)
{
try
{
String
currentDirStr
=
luytenPrefs
.
getFileSaveCurrentDirectory
();
if
(
currentDirStr
!=
null
&&
currentDirStr
.
trim
().
length
()
>
0
)
{
File
currentDir
=
new
File
(
currentDirStr
);
if
(
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
fc
.
setCurrentDirectory
(
currentDir
);
}
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
private
void
saveSaveDialogDir
(
JFileChooser
fc
)
{
try
{
File
currentDir
=
fc
.
getCurrentDirectory
();
if
(
currentDir
!=
null
&&
currentDir
.
exists
()
&&
currentDir
.
isDirectory
())
{
luytenPrefs
.
setFileSaveCurrentDirectory
(
currentDir
.
getAbsolutePath
());
}
}
catch
(
Exception
e
)
{
Luyten
.
showExceptionDialog
(
"Exception!"
,
e
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录