Skip to content

Commit 74fca84

Browse files
committed
feat: 添加mv的操作
refactor: 完善readme和plugin介绍内容
1 parent 2793315 commit 74fca84

File tree

4 files changed

+45
-39
lines changed

4 files changed

+45
-39
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# XFTP - SFTP tool for IntelliJ Ultimate Edition IDE, like IDEA, WebStorm, PHPStorm and more.
1+
# XFTP - A SFTP Plugin for IntelliJ Ultimate Edition IDE, like IDEA, WebStorm, PHPStorm and more.
22

33
### [GitHub](https://github.com/allape/Java-IDEAPlugin-XFTP) | [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/16590-xftp)
44

@@ -11,7 +11,8 @@
1111
- ✔️️ Dragging from local file list to remote file list to transfer, and vice versa.
1212
- ✔️️ Open new terminal session in current folder.
1313
- ✔️️️ Memo for history locations.
14-
- ➖️ More operations in context menu: rm, touch, mkdir, cp, mv...
14+
- ✔️️️ Operations in context menu: rm, cp, mv, touch, mkdir.
15+
- ✖️ Copy and Paste actions in both list...
1516
- ✖️ Transferring history list with retry button.
1617
- ✖️ Custom remote file VirtualFile.
1718

src/main/kotlin/net/allape/xftp/ExplorerWindow.kt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ class ExplorerWindow(
498498
val files: List<RemoteFileObject> = getSelectedRemoteFileList()
499499
if (MessageDialogBuilder.yesNo(
500500
"Delete Confirm",
501-
"${files.joinToString(separator = "\n") { it.name() }}\n"
501+
"${files.joinToString(separator = "\n") { it.name() }}\n\n${files.size} item${if (files.size > 1) "s" else ""} will be deleted."
502502
)
503503
.asWarning()
504504
.yesText("Delete")
@@ -577,6 +577,35 @@ class ExplorerWindow(
577577
}
578578
}
579579
}
580+
mv.addActionListener {
581+
val files: List<RemoteFileObject> = getSelectedRemoteFileList()
582+
Assert.assertTrue("mv only accepts one selection", files.size == 1)
583+
584+
val file = files[0]
585+
val isDir = file.isDir()
586+
587+
FileNameTextFieldDialog(project).openDialog(isDir) { filename ->
588+
executeOnPooledThreadWithRemoteUILocked({
589+
val parsedFileName = joinWithCurrentRemotePath(filename.trim())
590+
591+
val folderName = getParentFolderPath(parsedFileName, FILE_SEP)
592+
if (folderName != FILE_SEP) {
593+
sftpClient!!.mkdirs(folderName)
594+
}
595+
596+
executeSync("mv \"${file.path()}\" \"$parsedFileName\"")
597+
598+
setCurrentRemotePath(parsedFileName)
599+
600+
false
601+
}) {
602+
Services.message(
603+
"Error occurred while renaming file: ${it.message}",
604+
MessageType.ERROR
605+
)
606+
}
607+
}
608+
}
580609
mkdirp.addActionListener {
581610
FileNameTextFieldDialog(project).openDialog(true) { filename ->
582611
executeOnPooledThreadWithRemoteUILocked({
@@ -608,9 +637,13 @@ class ExplorerWindow(
608637
}
609638

610639
duplicate.isEnabled = selectedFiles.size == 1
640+
mv.isEnabled = duplicate.isEnabled
611641
if (duplicate.isEnabled) {
612642
duplicate.text = "$CP_TEXT${if (selectedFiles[0].directory) " -R" else ""} ${selectedFiles[0].name} ..."
613643
}
644+
if (mv.isEnabled) {
645+
mv.text = "$MV_TEXT ${selectedFiles[0].name} ..."
646+
}
614647
} else {
615648
setRemoteListContentMenuItems(false)
616649
}

src/main/kotlin/net/allape/xftp/ExplorerWindowUI.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ abstract class ExplorerWindowUI(
126126
protected val rmRf = JBMenuItem(RM_RF_TEXT)
127127
// 克隆
128128
protected val duplicate = JBMenuItem(CP_TEXT)
129+
// 重命名
130+
protected val mv = JBMenuItem(MV_TEXT)
129131
// 新建文件
130132
protected val touch = JBMenuItem(TOUCH_TEXT)
131133
// 新建文件夹
@@ -186,6 +188,7 @@ abstract class ExplorerWindowUI(
186188
resetRemoteListContentMenuItemsText()
187189
remoteFileListPopupMenu.add(rmRf)
188190
remoteFileListPopupMenu.add(duplicate)
191+
remoteFileListPopupMenu.add(mv)
189192
remoteFileListPopupMenu.add(touch)
190193
remoteFileListPopupMenu.add(mkdirp)
191194
remoteFileList.componentPopupMenu = remoteFileListPopupMenu
@@ -227,6 +230,7 @@ abstract class ExplorerWindowUI(
227230
protected fun setRemoteListContentMenuItems(enable: Boolean) {
228231
rmRf.isEnabled = enable
229232
duplicate.isEnabled = enable
233+
mv.isEnabled = enable
230234
touch.isEnabled = enable
231235
mkdirp.isEnabled = enable
232236
}
@@ -237,6 +241,7 @@ abstract class ExplorerWindowUI(
237241
protected fun resetRemoteListContentMenuItemsText() {
238242
rmRf.text = "$RM_RF_TEXT ..."
239243
duplicate.text = "$CP_TEXT ... ..."
244+
mv.text = "$MV_TEXT ... ..."
240245
touch.text = TOUCH_TEXT
241246
mkdirp.text = MKDIR_P_TEXT
242247
}

src/main/resources/META-INF/plugin.xml

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,64 +53,31 @@
5353
</description>
5454

5555
<change-notes><![CDATA[
56-
<h5>2021-12-04</h5>
56+
<h5>2021-10-10 ~ 2021-12-05</h5>
5757
<ul>
58+
<li>Add cp and mv into context menu of remote list.</li>
5859
<li>Add touch and mkdir into context menu of remote list.</li>
5960
<li>Refactor delete warning confirm, default action is "no" now.</li>
60-
</ul>
61-
<h5>2021-11-12</h5>
62-
<ul>
6361
<li>Fix #1.1: Unable to get connections of project-level.</li>
6462
<li>Update Gson.</li>
65-
</ul>
66-
<h5>2021-10-10</h5>
67-
<ul>
6863
<li>Fix #1.</li>
6964
</ul>
70-
<h5>2021-09-07</h5>
65+
<h5>2021-04-28 ~ 2021-09-07</h5>
7166
<ul>
7267
<li>Rewrite code with kotlin.</li>
73-
</ul>
74-
<h5>2021-07-28</h5>
75-
<ul>
7668
<li>Change IDEA version for compatibility.</li>
7769
<li>Add icon.</li>
78-
</ul>
79-
<h5>2021-06-14</h5>
80-
<ul>
8170
<li>Fix buttons' state after failed to connect to a server.</li>
82-
</ul>
83-
<h5>2021-05-18</h5>
84-
<ul>
85-
<li>Fix some bugs.</li>
86-
</ul>
87-
<h5>2021-05-17</h5>
88-
<ul>
89-
<li>Fix some bugs.</li>
9071
<li>Add display/hide local file list button.</li>
9172
<li>Change file list minimum width.</li>
9273
<li>Change title font size in plugin description.</li>
93-
</ul>
94-
<h5>2021-05-13</h5>
95-
<ul>
9674
<li>Change buttons position, put all buttons together for minimizing the mouse operation distance.</li>
97-
</ul>
98-
<h5>2021-05-12</h5>
99-
<ul>
100-
<li>Fix some bugs.</li>
10175
<li>Add remote reload button.</li>
10276
<li>Add a confirmation on closing tab while connected to a server.</li>
103-
</ul>
104-
<h5>2021-04-28</h5>
105-
<ul>
10677
<li>Change all buttons to tool bar.</li>
10778
<li>Add tooltip for all buttons.</li>
10879
<li>Fix remote not reloading after deleting or transferring.</li>
10980
</ul>
110-
<h5>2021-04-17</h5>
111-
<ul>
112-
<li>A first usable Version.</li>
113-
</ul>
11481
<h5>2020-11-02</h5>
11582
<ul>
11683
<li>Project started.</li>

0 commit comments

Comments
 (0)