Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
肾齐团队
Hosts
提交
765e5687
Hosts
项目概览
肾齐团队
/
Hosts
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Hosts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
765e5687
编写于
5月 11, 2022
作者:
C
chenjianqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
区分盘符
上级
6270df93
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
15 deletion
+10
-15
src/main/java/com/lishihe/hosts/frame/HostsFrame.java
src/main/java/com/lishihe/hosts/frame/HostsFrame.java
+9
-14
src/main/resources/META-INF/plugin.xml
src/main/resources/META-INF/plugin.xml
+1
-1
未找到文件。
src/main/java/com/lishihe/hosts/frame/HostsFrame.java
浏览文件 @
765e5687
...
...
@@ -16,16 +16,16 @@ import java.io.File;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
import
java.util.StringJoiner
;
import
java.util.stream.Collectors
;
public
class
HostsFrame
{
//页面数据
//--系统环境是linux?
private
Boolean
linuxIs
;
//--文件名和文件路径Map
private
Map
<
String
,
String
>
fileNameAndPathMap
;
//页面组件
//--主面板
...
...
@@ -68,8 +68,8 @@ public class HostsFrame {
String
hosts
=
parseHostsFileAndPath
(
oldFileName
);
FileUtils
.
writeInFile
(
hosts
,
content
.
toString
());
//更新文件名
if
(!
oldFileName
.
equals
(
newFileName
))
{
FileUtils
.
singleChange
(
new
File
(
hosts
),
new
File
(
parseHostsFileAndPath
(
newFileName
)));
if
(!
oldFileName
.
equals
(
newFileName
))
{
FileUtils
.
singleChange
(
new
File
(
hosts
),
new
File
(
parseHostsFileAndPath
(
newFileName
)));
}
});
btn_other_save
.
addActionListener
(
eventE
->
{
...
...
@@ -239,16 +239,10 @@ public class HostsFrame {
* @return 文件路径文件名称
*/
private
String
parseHostsFileAndPath
(
String
fileName
)
{
String
hostFileLocation
;
if
(
fileName
==
null
)
{
fileName
=
"hosts"
;
}
if
(
linuxIs
)
{
hostFileLocation
=
"/etc/"
;
}
else
{
hostFileLocation
=
System
.
getenv
(
"windir"
)
+
"\\system32\\drivers\\etc\\"
;
}
return
hostFileLocation
.
concat
(
fileName
);
return
fileNameAndPathMap
.
get
(
fileName
);
}
/**
...
...
@@ -319,6 +313,7 @@ public class HostsFrame {
* @return 符合条件的文件列表
*/
private
String
[]
findHostNameList
()
{
fileNameAndPathMap
=
new
HashMap
<>(
100
);
List
<
String
>
collect
=
parseFiles
(
parseHostsPath
());
if
(!
linuxIs
)
{
collect
.
addAll
(
parseFiles
(
HostsConstant
.
Systems
.
WIN_D_DIR_AREA_LOCATION
));
...
...
@@ -341,8 +336,8 @@ public class HostsFrame {
.
map
(
File:
:
getName
)
.
filter
(
f
->
StringUtils
.
isNotBlank
(
f
)
&&
f
.
startsWith
(
HostsConstant
.
Systems
.
MAIN_HOSTS_FILE_NAME
)
&&
!
f
.
endsWith
(
HostsConstant
.
Systems
.
MAIN_HOSTS_FILE_NAME_NOT_SHOW
)
)
&&
!
f
.
endsWith
(
HostsConstant
.
Systems
.
MAIN_HOSTS_FILE_NAME_NOT_SHOW
)
)
.
peek
(
p
->
fileNameAndPathMap
.
put
(
p
,
hostLocation
.
concat
(
"\\"
+
p
))
)
.
collect
(
Collectors
.
toList
());
}
}
...
...
src/main/resources/META-INF/plugin.xml
浏览文件 @
765e5687
...
...
@@ -24,7 +24,7 @@
<depends>
com.intellij.modules.platform
</depends>
<extensions
defaultExtensionNs=
"com.intellij"
>
<toolWindow
id=
"Hosts"
anchor=
"
right
"
factoryClass=
"com.lishihe.hosts.factory.ToolWindowsFactory"
<toolWindow
id=
"Hosts"
anchor=
"
bottom
"
factoryClass=
"com.lishihe.hosts.factory.ToolWindowsFactory"
secondary=
"true"
canCloseContents=
"false"
/>
</extensions>
</idea-plugin>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录