ファイル整理用ツールのPrism+WPFサンプル実装
Revisión | f5a5b5a1044e418083638adc24ea9a4050085a1c (tree) |
---|---|
Tiempo | 2022-07-31 02:09:29 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] FileSystemSourceFiles, FileSystemTargetFolder が保持するパスを TargetPath と RelativePath に分けたまま持つように修正
@@ -5,8 +5,8 @@ namespace FolderCategorizer2.Domain.Boundary.Service | ||
5 | 5 | { |
6 | 6 | public interface IFileListService |
7 | 7 | { |
8 | - FileListDiff ReplaceFileListDiff(string tabId, IEnumerable<(string treeId, string path)> targets); | |
8 | + FileListDiff ReplaceFileListDiff(string tabId, IEnumerable<(string treeId, string targetPath, string relativePath)> targets); | |
9 | 9 | FileListDiff RestoreFileListDiff(string tabId); |
10 | - FileListDiff RefreshFileListDiff(string tabId, IEnumerable<(string TreeID, string Path)> enumerable); | |
10 | + FileListDiff RefreshFileListDiff(string tabId, IEnumerable<(string TreeID, string targetPath, string relativePath)> enumerable); | |
11 | 11 | } |
12 | 12 | } |
@@ -1,4 +1,5 @@ | ||
1 | -using System; | |
1 | +using CleanAuLait.Core.IO; | |
2 | +using System; | |
2 | 3 | using System.Collections.Generic; |
3 | 4 | |
4 | 5 | namespace FolderCategorizer2.Domain.Model.Entity |
@@ -7,14 +8,17 @@ namespace FolderCategorizer2.Domain.Model.Entity | ||
7 | 8 | { |
8 | 9 | public string TreeID { get; init; } |
9 | 10 | public string TargetPath { get; init; } |
11 | + public string RelativePath { get; init; } | |
12 | + public string AbsolutePath => PathHelper.CreateCanonicalPath(TargetPath, RelativePath); | |
10 | 13 | public IEnumerable<FileListRow> Rows { get; init; } |
11 | 14 | |
12 | 15 | private bool disposedValue; |
13 | 16 | |
14 | - public FileList(string treeId, string targetPath, IEnumerable<FileListRow> rows) | |
17 | + public FileList(string treeId, string targetPath, string relativePath, IEnumerable<FileListRow> rows) | |
15 | 18 | { |
16 | 19 | this.TreeID = treeId; |
17 | 20 | this.TargetPath = targetPath; |
21 | + this.RelativePath = relativePath; | |
18 | 22 | this.Rows = rows; |
19 | 23 | |
20 | 24 | foreach (var row in rows) |
@@ -1,11 +1,14 @@ | ||
1 | -using System.Collections.Generic; | |
1 | +using CleanAuLait.Core.IO; | |
2 | +using System.Collections.Generic; | |
2 | 3 | |
3 | 4 | namespace FolderCategorizer2.Domain.Service.Dto |
4 | 5 | { |
5 | 6 | public record class FileSystemSourceFiles( |
6 | 7 | string TreeID, |
7 | - string Path, // TODO AbsolutePath | |
8 | + string TargetPath, | |
9 | + string RelativePath, | |
8 | 10 | IList<string> Names |
9 | 11 | ){ |
12 | + public string AbsolutePath = PathHelper.CreateCanonicalPath(TargetPath, RelativePath); | |
10 | 13 | } |
11 | 14 | } |
@@ -1,21 +1,28 @@ | ||
1 | 1 | using CleanAuLait.Core.IO; |
2 | 2 | using FolderCategorizer2.Domain.Model.Entity; |
3 | +using System.IO; | |
3 | 4 | |
4 | 5 | namespace FolderCategorizer2.Domain.Service.Dto |
5 | 6 | { |
6 | 7 | public record class FileSystemTargetFolder( |
7 | 8 | string TreeID, |
8 | - string Path // TODO AbsolutePath | |
9 | + string TargetPath, | |
10 | + string RelativePath | |
9 | 11 | ) { |
12 | + public string AbsolutePath => PathHelper.CreateCanonicalPath(TargetPath, RelativePath); | |
13 | + | |
10 | 14 | public FileSystemTargetFolder(FileList fileList, string name) : this( |
11 | 15 | TreeID: fileList.TreeID, |
12 | - Path: PathHelper.CreateCanonicalPath(fileList.TargetPath, name) | |
13 | - ) { | |
16 | + TargetPath: fileList.TargetPath, | |
17 | + RelativePath: Path.Combine(fileList.RelativePath, name) | |
18 | + ) | |
19 | + { | |
14 | 20 | } |
15 | 21 | |
16 | 22 | public FileSystemTargetFolder(FolderTree folderTree, string name) : this( |
17 | 23 | TreeID: folderTree.ID, |
18 | - Path: PathHelper.CreateCanonicalPath(folderTree.TargetPath, name) | |
24 | + TargetPath: folderTree.TargetPath, | |
25 | + RelativePath: name | |
19 | 26 | ) { |
20 | 27 | } |
21 | 28 | } |
@@ -1,4 +1,5 @@ | ||
1 | -using FolderCategorizer2.Domain.Boundary.Repository; | |
1 | +using CleanAuLait.Core.IO; | |
2 | +using FolderCategorizer2.Domain.Boundary.Repository; | |
2 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
3 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
4 | 5 | using FolderCategorizer2.Domain.Translator; |
@@ -58,7 +59,7 @@ namespace FolderCategorizer2.Domain.Service | ||
58 | 59 | |
59 | 60 | #endregion |
60 | 61 | |
61 | - public FileListDiff ReplaceFileListDiff(string tabId, IEnumerable<(string treeId, string path)> targets) | |
62 | + public FileListDiff ReplaceFileListDiff(string tabId, IEnumerable<(string treeId, string targetPath, string relativePath)> targets) | |
62 | 63 | { |
63 | 64 | FileListDiff diff = CreateFileListDiff(targets); |
64 | 65 |
@@ -74,20 +75,22 @@ namespace FolderCategorizer2.Domain.Service | ||
74 | 75 | return diff; |
75 | 76 | } |
76 | 77 | |
77 | - public FileListDiff RefreshFileListDiff(string tabId, IEnumerable<(string TreeID, string Path)> targets) | |
78 | + public FileListDiff RefreshFileListDiff(string tabId, IEnumerable<(string TreeID, string targetPath, string relativePath)> targets) | |
78 | 79 | { |
79 | 80 | return ReplaceFileListDiff(tabId, targets); |
80 | 81 | } |
81 | 82 | |
82 | - private FileListDiff CreateFileListDiff(IEnumerable<(string treeId, string path)> targets) | |
83 | + private FileListDiff CreateFileListDiff(IEnumerable<(string treeId, string targetPath, string relativePath)> targets) | |
83 | 84 | { |
84 | 85 | IList<FileList> fileLists = new List<FileList>(); |
85 | 86 | |
86 | - foreach (var (treeId, path) in targets) | |
87 | + foreach (var (treeId, targetPath, relativePath) in targets) | |
87 | 88 | { |
89 | + string path = PathHelper.CreateCanonicalPath(targetPath, relativePath); | |
90 | + | |
88 | 91 | IList<FileListRow> rows = fileSystem.SearchFileList(path).Select(e => rowTranslator.Translate(e)).ToList(); |
89 | 92 | |
90 | - FileList fileList = new(treeId, path, rows); | |
93 | + FileList fileList = new(treeId, targetPath, relativePath, rows); | |
91 | 94 | |
92 | 95 | fileLists.Add(fileList); |
93 | 96 | } |
@@ -28,7 +28,7 @@ namespace FolderCategorizer2.Domain.Service | ||
28 | 28 | |
29 | 29 | foreach(FileSystemTargetFolder targetFolder in targetFolders) |
30 | 30 | { |
31 | - FileEntryType type = localFileSystem.GetFileEntryType(targetFolder.Path); | |
31 | + FileEntryType type = localFileSystem.GetFileEntryType(targetFolder.AbsolutePath); | |
32 | 32 | |
33 | 33 | if (type != FileEntryType.FOLDER) |
34 | 34 | { |
@@ -62,7 +62,7 @@ namespace FolderCategorizer2.Domain.Service | ||
62 | 62 | |
63 | 63 | foreach (string name in sourceFiles.Names) |
64 | 64 | { |
65 | - FileEntryType type = localFileSystem.GetFileEntryType(Path.Combine(sourceFiles.Path, name)); | |
65 | + FileEntryType type = localFileSystem.GetFileEntryType(Path.Combine(sourceFiles.AbsolutePath, name)); | |
66 | 66 | |
67 | 67 | switch (type) |
68 | 68 | { |
@@ -76,7 +76,7 @@ namespace FolderCategorizer2.Domain.Service | ||
76 | 76 | } |
77 | 77 | |
78 | 78 | return errorFiles.Any() |
79 | - ? new FileSystemSourceFiles(sourceFiles.TreeID, sourceFiles.Path, errorFiles) | |
79 | + ? new FileSystemSourceFiles(sourceFiles.TreeID, sourceFiles.TargetPath, sourceFiles.RelativePath, errorFiles) | |
80 | 80 | : null; |
81 | 81 | } |
82 | 82 |
@@ -121,11 +121,7 @@ namespace FolderCategorizer2.Domain.Service | ||
121 | 121 | $"absolute path {absolutePath} must be under tree target path {tree.TargetPath}"); |
122 | 122 | } |
123 | 123 | |
124 | - string relativePath = Path.GetRelativePath(tree.TargetPath, absolutePath); | |
125 | - | |
126 | - return relativePath == FileSystemConst.RELATIVE_PATH_TOP | |
127 | - ? relativePath | |
128 | - : Path.Combine(FileSystemConst.RELATIVE_PATH_TOP, relativePath); | |
124 | + return PathHelper.EnsureLeadingDotPath(Path.GetRelativePath(tree.TargetPath, absolutePath)); | |
129 | 125 | } |
130 | 126 | |
131 | 127 | public void SelectNode(string treeId, string relativePath) |
@@ -162,7 +158,7 @@ namespace FolderCategorizer2.Domain.Service | ||
162 | 158 | node.IsExpanded.Value = isExpanded; |
163 | 159 | } |
164 | 160 | |
165 | - private FolderTreeNode FindNodeByRelativePath(FolderTree tree, string relativePath) | |
161 | + private static FolderTreeNode FindNodeByRelativePath(FolderTree tree, string relativePath) | |
166 | 162 | { |
167 | 163 | if (relativePath == FileSystemConst.RELATIVE_PATH_TOP) |
168 | 164 | { |
@@ -7,7 +7,7 @@ namespace FolderCategorizer2.UseCase.FileListOperation.Request | ||
7 | 7 | { |
8 | 8 | public record class ReplaceFileListRequest( |
9 | 9 | string TabId, |
10 | - IEnumerable<(string treeId, string path)> Targets) : UseCaseRequest | |
10 | + IEnumerable<(string treeId, string targetPath, string relativePath)> Targets) : UseCaseRequest | |
11 | 11 | { |
12 | 12 | public override Type GetInteractorType() |
13 | 13 | { |
@@ -47,7 +47,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
47 | 47 | string msg = "【仮】コピー先フォルダが見つかりません"; |
48 | 48 | foreach (FileSystemTargetFolder errorFolder in errorFolders) |
49 | 49 | { |
50 | - msg += "\nコピー先:" + errorFolder.Path; | |
50 | + msg += "\nコピー先:" + errorFolder.AbsolutePath; | |
51 | 51 | } |
52 | 52 | return UseCaseResponse.Abort<FileSystemCopyOperationResponse>(msg); |
53 | 53 | } |
@@ -61,7 +61,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
61 | 61 | string msg = "【仮】コピー元ファイルが見つかりません"; |
62 | 62 | foreach (FileSystemSourceFiles errorFiles in errorFilesList) |
63 | 63 | { |
64 | - msg += "\nコピー元:" + errorFiles.Path; | |
64 | + msg += "\nコピー元:" + errorFiles.AbsolutePath; | |
65 | 65 | foreach (string name in errorFiles.Names) |
66 | 66 | { |
67 | 67 | msg += "\n・" + name; |
@@ -77,12 +77,12 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
77 | 77 | string msg = "【仮】コピーしてもよろしいですか"; |
78 | 78 | foreach (FileSystemSourceTargetEntry sourceTargetEntry in sourceTargetEntries) |
79 | 79 | { |
80 | - msg += "\n\nコピー元:" + sourceTargetEntry.SourceFiles.Path; | |
80 | + msg += "\n\nコピー元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
81 | 81 | foreach (string name in sourceTargetEntry.SourceFiles.Names) |
82 | 82 | { |
83 | 83 | msg += "\n・" + name; |
84 | 84 | } |
85 | - msg += "\n↓\nコピー先:" + sourceTargetEntry.TargetFolder.Path; | |
85 | + msg += "\n↓\nコピー先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
86 | 86 | } |
87 | 87 | |
88 | 88 | IDialogResult result = this.dialog.ShowYesNoDialog("ファイルのコピー - 確認", msg, MessageBoxImage.Question); |
@@ -95,13 +95,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
95 | 95 | |
96 | 96 | foreach (FileSystemSourceTargetEntry sourceTargetEntry in sourceTargetEntries) |
97 | 97 | { |
98 | - string targetPath = PathHelper.CreateCanonicalPath(sourceTargetEntry.TargetFolder.Path); | |
99 | - string sourcePath = PathHelper.CreateCanonicalPath(sourceTargetEntry.SourceFiles.Path); | |
98 | + string targetFolderPath = sourceTargetEntry.TargetFolder.AbsolutePath; | |
99 | + string sourceFolderPath = sourceTargetEntry.SourceFiles.AbsolutePath; | |
100 | 100 | |
101 | 101 | foreach (string name in sourceTargetEntry.SourceFiles.Names) |
102 | 102 | { |
103 | - string sourceFullPath = PathHelper.CreateCanonicalPath(sourcePath, name); | |
104 | - string targetFullPath = PathHelper.CreateCanonicalPath(targetPath, name); | |
103 | + string sourceFullPath = PathHelper.CreateCanonicalPath(sourceFolderPath, name); | |
104 | + string targetFullPath = PathHelper.CreateCanonicalPath(targetFolderPath, name); | |
105 | 105 | |
106 | 106 | Retry: |
107 | 107 | try |
@@ -112,7 +112,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
112 | 112 | { |
113 | 113 | string msg = string.Format( |
114 | 114 | "ファイルのコピー中に次のエラーが発生しました。\n{0}\n\nコピー元:{1}\nコピー先:{2}", |
115 | - e.Message, sourceFullPath, targetPath); | |
115 | + e.Message, sourceFullPath, targetFolderPath); | |
116 | 116 | |
117 | 117 | IDialogResult result = this.dialog.ShowAbortRetryIgnoreDialog("ファイルのコピー - エラー", msg, MessageBoxImage.Hand); |
118 | 118 |
@@ -131,14 +131,8 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
131 | 131 | |
132 | 132 | string treeId = sourceTargetEntry.TreeID; |
133 | 133 | |
134 | - string sourceRelativePath = this.folderTree.ConvertTreeRelativePath( | |
135 | - treeId, sourceTargetEntry.SourceFiles.Path); | |
136 | - | |
137 | - string targetRelativePath = this.folderTree.ConvertTreeRelativePath( | |
138 | - treeId, sourceTargetEntry.TargetFolder.Path); | |
139 | - | |
140 | - this.folderTree.RefreshFolderTree(treeId, sourceRelativePath); | |
141 | - this.folderTree.RefreshFolderTree(treeId, targetRelativePath); | |
134 | + this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath); | |
135 | + this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath); | |
142 | 136 | } |
143 | 137 | |
144 | 138 | { |
@@ -146,10 +140,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
146 | 140 | |
147 | 141 | string treeId = sourceTargetEntry.TreeID; |
148 | 142 | |
149 | - string targetRelativePath = this.folderTree.ConvertTreeRelativePath( | |
150 | - treeId, sourceTargetEntry.TargetFolder.Path); | |
151 | - | |
152 | - this.folderTree.SelectNode(treeId, targetRelativePath); | |
143 | + this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath); | |
153 | 144 | } |
154 | 145 | |
155 | 146 | return new FileSystemCopyOperationResponse(); |
@@ -52,7 +52,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
52 | 52 | string msg = "【仮】削除してもよろしいですか"; |
53 | 53 | foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) |
54 | 54 | { |
55 | - msg += "\n\n削除元:" + sourceFiles.Path; | |
55 | + msg += "\n\n削除元:" + sourceFiles.AbsolutePath; | |
56 | 56 | foreach (string name in sourceFiles.Names) |
57 | 57 | { |
58 | 58 | msg += "\n・" + name; |
@@ -69,7 +69,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
69 | 69 | |
70 | 70 | foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) |
71 | 71 | { |
72 | - string sourcePath = PathHelper.CreateCanonicalPath(sourceFiles.Path); | |
72 | + string sourcePath = PathHelper.CreateCanonicalPath(sourceFiles.AbsolutePath); | |
73 | 73 | |
74 | 74 | foreach (string name in sourceFiles.Names) |
75 | 75 | { |
@@ -103,17 +103,14 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
103 | 103 | |
104 | 104 | string treeId = sourceFiles.TreeID; |
105 | 105 | |
106 | - string sourceRelativePath = this.folderTree.ConvertTreeRelativePath( | |
107 | - treeId, sourceFiles.Path); | |
108 | - | |
109 | - this.folderTree.RefreshFolderTree(treeId, sourceRelativePath); | |
106 | + this.folderTree.RefreshFolderTree(treeId, sourceFiles.RelativePath); | |
110 | 107 | } |
111 | 108 | |
112 | 109 | { |
113 | 110 | // TODO implement extract tab id function |
114 | 111 | string tabId = sourceFilesList.First().TreeID.Split('/').First(); |
115 | 112 | |
116 | - FileListDiff newDiff = this.fileList.RefreshFileListDiff( tabId, sourceFilesList.Select(v => (v.TreeID, v.Path)) ); | |
113 | + FileListDiff newDiff = this.fileList.RefreshFileListDiff( tabId, sourceFilesList.Select(v => (v.TreeID, v.TargetPath, v.RelativePath)) ); | |
117 | 114 | |
118 | 115 | FileSystemDeleteOperationResponse res = new(newDiff); |
119 | 116 |
@@ -47,7 +47,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
47 | 47 | string msg = "【仮】移動先フォルダが見つかりません"; |
48 | 48 | foreach (FileSystemTargetFolder errorFolder in errorFolders) |
49 | 49 | { |
50 | - msg += "\n移動先:" + errorFolder.Path; | |
50 | + msg += "\n移動先:" + errorFolder.AbsolutePath; | |
51 | 51 | } |
52 | 52 | return UseCaseResponse.Abort<FileSystemMoveOperationResponse>(msg); |
53 | 53 | } |
@@ -61,7 +61,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
61 | 61 | string msg = "【仮】移動元ファイルが見つかりません"; |
62 | 62 | foreach (FileSystemSourceFiles errorFiles in errorFilesList) |
63 | 63 | { |
64 | - msg += "\n移動元:" + errorFiles.Path; | |
64 | + msg += "\n移動元:" + errorFiles.AbsolutePath; | |
65 | 65 | foreach (string name in errorFiles.Names) |
66 | 66 | { |
67 | 67 | msg += "\n・" + name; |
@@ -77,12 +77,12 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
77 | 77 | string msg = "【仮】移動してもよろしいですか"; |
78 | 78 | foreach (FileSystemSourceTargetEntry sourceTargetEntry in sourceTargetEntries) |
79 | 79 | { |
80 | - msg += "\n\n移動元:" + sourceTargetEntry.SourceFiles.Path; | |
80 | + msg += "\n\n移動元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
81 | 81 | foreach (string name in sourceTargetEntry.SourceFiles.Names) |
82 | 82 | { |
83 | 83 | msg += "\n・" + name; |
84 | 84 | } |
85 | - msg += "\n↓\n移動先:" + sourceTargetEntry.TargetFolder.Path; | |
85 | + msg += "\n↓\n移動先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
86 | 86 | } |
87 | 87 | |
88 | 88 | IDialogResult result = this.dialog.ShowYesNoDialog("ファイルの移動 - 確認", msg, MessageBoxImage.Question); |
@@ -95,13 +95,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
95 | 95 | |
96 | 96 | foreach (FileSystemSourceTargetEntry sourceTargetEntry in sourceTargetEntries) |
97 | 97 | { |
98 | - string targetPath = PathHelper.CreateCanonicalPath(sourceTargetEntry.TargetFolder.Path); | |
99 | - string sourcePath = PathHelper.CreateCanonicalPath(sourceTargetEntry.SourceFiles.Path); | |
98 | + string targetFolderPath = sourceTargetEntry.TargetFolder.AbsolutePath; | |
99 | + string sourceFolderPath = sourceTargetEntry.SourceFiles.AbsolutePath; | |
100 | 100 | |
101 | 101 | foreach (string name in sourceTargetEntry.SourceFiles.Names) |
102 | 102 | { |
103 | - string sourceFullPath = PathHelper.CreateCanonicalPath(sourcePath, name); | |
104 | - string targetFullPath = PathHelper.CreateCanonicalPath(targetPath, name); | |
103 | + string sourceFullPath = PathHelper.CreateCanonicalPath(sourceFolderPath, name); | |
104 | + string targetFullPath = PathHelper.CreateCanonicalPath(targetFolderPath, name); | |
105 | 105 | |
106 | 106 | Retry: |
107 | 107 | try |
@@ -112,7 +112,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
112 | 112 | { |
113 | 113 | string msg = string.Format( |
114 | 114 | "ファイルの移動中に次のエラーが発生しました。\n{0}\n\n移動元:{1}\n移動先:{2}", |
115 | - e.Message, sourceFullPath, targetPath); | |
115 | + e.Message, sourceFullPath, targetFolderPath); | |
116 | 116 | |
117 | 117 | IDialogResult result = this.dialog.ShowAbortRetryIgnoreDialog("ファイルの移動 - エラー", msg, MessageBoxImage.Hand); |
118 | 118 |
@@ -131,25 +131,17 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
131 | 131 | |
132 | 132 | string treeId = sourceTargetEntry.TreeID; |
133 | 133 | |
134 | - string sourceRelativePath = this.folderTree.ConvertTreeRelativePath( | |
135 | - treeId, sourceTargetEntry.SourceFiles.Path); | |
136 | - | |
137 | - string targetRelativePath = this.folderTree.ConvertTreeRelativePath( | |
138 | - treeId, sourceTargetEntry.TargetFolder.Path); | |
139 | - | |
140 | - this.folderTree.RefreshFolderTree(treeId, sourceRelativePath); | |
141 | - this.folderTree.RefreshFolderTree(treeId, targetRelativePath); | |
134 | + this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath); | |
135 | + this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath); | |
142 | 136 | } |
143 | 137 | |
138 | + if (false) | |
144 | 139 | { |
145 | 140 | FileSystemSourceTargetEntry sourceTargetEntry = sourceTargetEntries.First(); |
146 | 141 | |
147 | 142 | string treeId = sourceTargetEntry.TreeID; |
148 | 143 | |
149 | - string targetRelativePath = this.folderTree.ConvertTreeRelativePath( | |
150 | - treeId, sourceTargetEntry.TargetFolder.Path); | |
151 | - | |
152 | - this.folderTree.SelectNode(treeId, targetRelativePath); | |
144 | + this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath); | |
153 | 145 | } |
154 | 146 | |
155 | 147 | return new FileSystemMoveOperationResponse(); |
@@ -10,6 +10,7 @@ namespace FolderCategorizer2.Adaptor.Boundary.ViewModel.Child | ||
10 | 10 | public interface IFolderTreeNodeViewModel |
11 | 11 | { |
12 | 12 | ReadOnlyReactivePropertySlim<string> Text { get; } |
13 | + ReadOnlyReactivePropertySlim<string> RelativePath { get; } | |
13 | 14 | ReadOnlyReactivePropertySlim<ImageSource> ItemImage { get; } |
14 | 15 | ReactivePropertySlim<bool> IsExpanded { get; } |
15 | 16 | ReactivePropertySlim<bool> IsSelected { get; } |
@@ -108,7 +108,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
108 | 108 | { |
109 | 109 | if (target != null) |
110 | 110 | { |
111 | - logger.Trace("FileListRowViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.Path); | |
111 | + logger.Trace("FileListRowViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.AbsolutePath); | |
112 | 112 | } |
113 | 113 | } |
114 | 114 |
@@ -118,14 +118,6 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
118 | 118 | _ = this.ParentVm.WindowController.Execute(req); |
119 | 119 | } |
120 | 120 | |
121 | - private IEnumerable<FileSystemTargetFolder> CreateTargetFolders() | |
122 | - { | |
123 | - // TODO LINKの場合 | |
124 | - return this.Source.Sources | |
125 | - .Where(row => row.Type.Value == FileEntryType.FOLDER) | |
126 | - .Select(row => new FileSystemTargetFolder(row.Parent, this.Name.Value)); | |
127 | - } | |
128 | - | |
129 | 121 | public void NotifyMoveFileListDropped(DnDSourceFileInfo draggedFileList) |
130 | 122 | { |
131 | 123 | // TODO LINKの場合 |
@@ -137,7 +129,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
137 | 129 | { |
138 | 130 | if (target != null) |
139 | 131 | { |
140 | - logger.Trace("FileListRowViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.Path); | |
132 | + logger.Trace("FileListRowViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.AbsolutePath); | |
141 | 133 | } |
142 | 134 | } |
143 | 135 |
@@ -147,6 +139,14 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
147 | 139 | _ = this.ParentVm.WindowController.Execute(req); |
148 | 140 | } |
149 | 141 | |
142 | + private IEnumerable<FileSystemTargetFolder> CreateTargetFolders() | |
143 | + { | |
144 | + // TODO LINKの場合 | |
145 | + return this.Source.Sources | |
146 | + .Where(row => row.Type.Value == FileEntryType.FOLDER) | |
147 | + .Select(row => new FileSystemTargetFolder(row.Parent, this.Name.Value)); | |
148 | + } | |
149 | + | |
150 | 150 | #endregion |
151 | 151 | |
152 | 152 | #region IEditableObject |
@@ -1,11 +1,14 @@ | ||
1 | -using FolderCategorizer2.Adaptor.Boundary.ViewModel; | |
1 | +using CleanAuLait.Core.IO; | |
2 | +using FolderCategorizer2.Adaptor.Boundary.ViewModel; | |
2 | 3 | using FolderCategorizer2.Adaptor.Boundary.ViewModel.Child; |
3 | 4 | using FolderCategorizer2.Adaptor.Gateway.ViewModel.Dto; |
5 | +using FolderCategorizer2.Domain.Model.Const; | |
4 | 6 | using FolderCategorizer2.Domain.Service.Dto; |
5 | 7 | using GongSolutions.Wpf.DragDrop; |
6 | 8 | using NLog; |
7 | 9 | using System; |
8 | 10 | using System.Collections.Generic; |
11 | +using System.IO; | |
9 | 12 | using System.Windows; |
10 | 13 | |
11 | 14 | namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child |
@@ -19,7 +22,9 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
19 | 22 | /// <inheritdoc/> |
20 | 23 | public bool CanStartDrag(IDragInfo dragInfo) |
21 | 24 | { |
22 | - return true; | |
25 | + var item = (IFolderTreeNodeViewModel)dragInfo.SourceItem; | |
26 | + | |
27 | + return item.RelativePath.Value != FileSystemConst.RELATIVE_PATH_TOP; | |
23 | 28 | } |
24 | 29 | |
25 | 30 | /// <inheritdoc/> |
@@ -41,8 +46,12 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
41 | 46 | foreach (IFolderTreeViewModel vm |
42 | 47 | in treeNaviVm.InterVmStore.FindTreeViewModelsByTabId(treeVm.TabID)) |
43 | 48 | { |
49 | + string relativePath = PathHelper.EnsureLeadingDotPath( | |
50 | + PathHelper.CreateCanonicalRelativePath( | |
51 | + item.RelativePath.Value, FileSystemConst.RELATIVE_PATH_UPWARDS)); | |
52 | + | |
44 | 53 | sourceFilesList.Add(new FileSystemSourceFiles( |
45 | - vm.TreeID, vm.TargetPath, new string[] { item.Text.Value })); | |
54 | + vm.TreeID, vm.TargetPath, relativePath, new string[] { item.Text.Value })); | |
46 | 55 | } |
47 | 56 | |
48 | 57 | dragInfo.Data = new DnDSourceFileInfo(draggedImages, sourceFilesList); |
@@ -45,12 +45,12 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
45 | 45 | { get; private set; } = Level; |
46 | 46 | public ReadOnlyReactivePropertySlim<string> RelativePath |
47 | 47 | { get; private set; } = RelativePath; |
48 | + public ReadOnlyReactivePropertySlim<ImageSource> ItemImage | |
49 | + { get; private set; } = ItemImage; | |
48 | 50 | public ReactivePropertySlim<bool> IsExpanded |
49 | 51 | { get; private set; } = IsExpanded; |
50 | 52 | public ReactivePropertySlim<bool> IsSelected |
51 | 53 | { get; private set; } = IsSelected; |
52 | - public ReadOnlyReactivePropertySlim<ImageSource> ItemImage | |
53 | - { get; private set; } = ItemImage; | |
54 | 54 | |
55 | 55 | public string AbsolutePath => PathHelper.CreateCanonicalPath(this.ParentVm.TargetPath, this.RelativePath.Value); |
56 | 56 | public INotifyCollectionChangedSynchronizedSingleView<FolderTreeNode, IFolderTreeNodeViewModel> Children |
@@ -92,16 +92,18 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
92 | 92 | if (this.Children?.Count > 0) |
93 | 93 | { |
94 | 94 | logger.Trace("OnExpandedChanged: {0}, SerchLevel {1}, RelativePath [{2}]", |
95 | - Text.Value, Level.Value, RelativePath.Value); | |
95 | + this.Text.Value, this.Level.Value, this.RelativePath.Value); | |
96 | 96 | |
97 | 97 | // TODO Notify のイベント化 |
98 | - this.ParentVm.NotifyExpandedFolderChanged(RelativePath.Value, Level.Value, IsExpanded.Value); | |
98 | + this.ParentVm.NotifyExpandedFolderChanged( | |
99 | + this.RelativePath.Value, this.Level.Value, this.IsExpanded.Value); | |
99 | 100 | } |
100 | 101 | } |
101 | 102 | |
102 | 103 | public bool IsDroppableTarget(DnDSourceFileInfo draggedFileList) |
103 | 104 | { |
104 | - FileSystemTargetFolder targetFolder = new(this.ParentVm.TreeID, this.AbsolutePath); | |
105 | + FileSystemTargetFolder targetFolder = new( | |
106 | + this.ParentVm.TreeID, this.ParentVm.TargetPath, this.RelativePath.Value); | |
105 | 107 | |
106 | 108 | FileSystemSourceFiles sourceFiles = draggedFileList.SourceFilesList |
107 | 109 | .Where(list => list.TreeID == this.ParentVm.TreeID).FirstOrDefault(); |
@@ -131,7 +133,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
131 | 133 | { |
132 | 134 | if (target != null) |
133 | 135 | { |
134 | - logger.Trace("FolderTreeNodeViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.Path); | |
136 | + logger.Trace("FolderTreeNodeViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.AbsolutePath); | |
135 | 137 | } |
136 | 138 | } |
137 | 139 |
@@ -158,7 +160,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Child | ||
158 | 160 | { |
159 | 161 | if (target != null) |
160 | 162 | { |
161 | - logger.Trace("FolderTreeNodeViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.Path); | |
163 | + logger.Trace("FolderTreeNodeViewModel: TargetTree {0}, TargetPath {1}", target.TreeID, target.AbsolutePath); | |
162 | 164 | } |
163 | 165 | } |
164 | 166 |
@@ -16,8 +16,8 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
16 | 16 | public static bool IsDroppableTarget( |
17 | 17 | FileSystemTargetFolder targetFolder, FileSystemSourceFiles sourceFiles) |
18 | 18 | { |
19 | - string targetFolderFullPath = targetFolder.Path; | |
20 | - string sourceFolderFullPath = sourceFiles.Path; | |
19 | + string targetFolderFullPath = targetFolder.AbsolutePath; | |
20 | + string sourceFolderFullPath = sourceFiles.AbsolutePath; | |
21 | 21 | |
22 | 22 | //logger.Trace("CheckFileListDragOver: target {0}, source {1}", targetFolderFullPath, sourceFolderFullPath); |
23 | 23 |
@@ -30,7 +30,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
30 | 30 | { |
31 | 31 | string sourceFullPath = PathHelper.CreateCanonicalPath(sourceFolderFullPath, name); |
32 | 32 | |
33 | - if (PathHelper.IsSameOrChild(sourceFullPath, targetFolder.Path)) | |
33 | + if (PathHelper.IsSameOrChild(sourceFullPath, targetFolder.AbsolutePath)) | |
34 | 34 | { |
35 | 35 | return false; |
36 | 36 | } |
@@ -16,7 +16,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel.Dto | ||
16 | 16 | { |
17 | 17 | foreach (FileSystemSourceFiles sourceFiles in SourceFilesList) |
18 | 18 | { |
19 | - logger.Trace("DnDSourceFileInfo: SourceTree {0}, SourcePath {1}", sourceFiles.TreeID, sourceFiles.Path); | |
19 | + logger.Trace("DnDSourceFileInfo: SourceTree {0}, SourcePath {1}", sourceFiles.TreeID, sourceFiles.AbsolutePath); | |
20 | 20 | |
21 | 21 | foreach (string name in sourceFiles.Names) |
22 | 22 | { |
@@ -1,4 +1,5 @@ | ||
1 | -using FolderCategorizer2.Adaptor.Boundary.Controller; | |
1 | +using CleanAuLait.Core.IO; | |
2 | +using FolderCategorizer2.Adaptor.Boundary.Controller; | |
2 | 3 | using FolderCategorizer2.Adaptor.Boundary.ViewModel; |
3 | 4 | using FolderCategorizer2.Adaptor.Boundary.ViewModel.Child; |
4 | 5 | using FolderCategorizer2.Adaptor.Gateway.ViewModel.Dto; |
@@ -6,12 +7,14 @@ using FolderCategorizer2.Adaptor.Translator; | ||
6 | 7 | using FolderCategorizer2.Domain.Model.Entity; |
7 | 8 | using FolderCategorizer2.Domain.Service.Dto; |
8 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
10 | +using FolderCategorizer2.UseCase.FolderTreeOperation.Request; | |
9 | 11 | using GongSolutions.Wpf.DragDrop; |
10 | 12 | using NLog; |
11 | 13 | using ObservableCollections; |
12 | 14 | using Prism.Navigation; |
13 | 15 | using Reactive.Bindings; |
14 | 16 | using Reactive.Bindings.Extensions; |
17 | +using System; | |
15 | 18 | using System.Collections.Generic; |
16 | 19 | using System.ComponentModel; |
17 | 20 | using System.Linq; |
@@ -102,8 +105,8 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
102 | 105 | |
103 | 106 | public IList<FileSystemSourceFiles> CreateSelectedSourceFilesList() |
104 | 107 | { |
105 | - IDictionary<(string id, string path), IList<string>> map = | |
106 | - new Dictionary<(string, string), IList<string>>(); | |
108 | + IDictionary<(string id, string targetPath, string relativePath), IList<string>> map = | |
109 | + new Dictionary<(string, string, string), IList<string>>(); | |
107 | 110 | |
108 | 111 | foreach (var vmRow in this.internalRows.Where(x => x.IsSelected.Value)) |
109 | 112 | { |
@@ -111,7 +114,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
111 | 114 | |
112 | 115 | foreach (var key in vmRow.Source.Sources |
113 | 116 | .Select(s => s.Parent).Where(p => p != null) |
114 | - .Select(s => (s.TreeID, s.TargetPath))) | |
117 | + .Select(s => (s.TreeID, s.TargetPath, s.RelativePath))) | |
115 | 118 | { |
116 | 119 | if (!map.TryGetValue(key, out var names)) |
117 | 120 | { |
@@ -127,7 +130,7 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
127 | 130 | |
128 | 131 | foreach (var key in map.Keys.OrderBy(k => k)) |
129 | 132 | { |
130 | - sourceFilesList.Add(new FileSystemSourceFiles(key.id, key.path, map[key])); | |
133 | + sourceFilesList.Add(new FileSystemSourceFiles(key.id, key.targetPath, key.relativePath, map[key])); | |
131 | 134 | } |
132 | 135 | |
133 | 136 | return sourceFilesList; |
@@ -345,19 +345,12 @@ namespace FolderCategorizer2.Adaptor.Gateway.ViewModel | ||
345 | 345 | { |
346 | 346 | string tabId = this.SelectedTabId.Value; |
347 | 347 | |
348 | - string fullPath1 = !string.IsNullOrEmpty(this.TargetPath1.Value) | |
349 | - ? PathHelper.CreateCanonicalPath(this.TargetPath1.Value, relativePath) | |
350 | - : string.Empty; | |
351 | - string fullPath2 = !string.IsNullOrEmpty(this.TargetPath2.Value) | |
352 | - ? PathHelper.CreateCanonicalPath(this.TargetPath2.Value, relativePath) | |
353 | - : string.Empty; | |
354 | - | |
355 | 348 | ReplaceFileListRequest req = new( |
356 | 349 | tabId, |
357 | - new (string treeId, string targetPath)[] | |
350 | + new (string treeId, string targetPath, string relativePath)[] | |
358 | 351 | { |
359 | - (TranslateTreeId(REGION_NAME_TREE_VIEW_PANE0, tabId), fullPath1), | |
360 | - (TranslateTreeId(REGION_NAME_TREE_VIEW_PANE1, tabId), fullPath2), | |
352 | + (TranslateTreeId(REGION_NAME_TREE_VIEW_PANE0, tabId), this.TargetPath1.Value, relativePath), | |
353 | + (TranslateTreeId(REGION_NAME_TREE_VIEW_PANE1, tabId), this.TargetPath2.Value, relativePath), | |
361 | 354 | } |
362 | 355 | ); |
363 | 356 |