・プラグインにキー割り当てを可能にした
・SCFiler2固有の関連付け実行が、プラグインからの呼び出しでは正しく実行しなかったのを修正
@@ -5,6 +5,7 @@ | ||
5 | 5 | using SCFiler2.FileSystem; |
6 | 6 | using SCFiler2.ViewInterface; |
7 | 7 | using SCFiler2.ItemInterface; |
8 | +using SCFiler2.PluginInterface; | |
8 | 9 | |
9 | 10 | namespace SCFiler2 { |
10 | 11 | /// <summary> |
@@ -67,53 +68,43 @@ | ||
67 | 68 | } |
68 | 69 | |
69 | 70 | /// <summary> |
70 | - /// 外部ツールの実行 | |
71 | + /// ビューで選択中のアイテムを外部ツールで実行 | |
71 | 72 | /// </summary> |
72 | 73 | public void Execute() { |
73 | - MainForm mainForm = MainForm.Instance; | |
74 | + IFilerItem targetItem = null; | |
75 | + //ビューの選択ファイルファイルを取得して実行 | |
76 | + if (this.toolArgumentStr.IndexOf(@"%%%SELECTED_FILE%%%") >= 0) { | |
77 | + if (ViewInterfaces.LastFocusedFileView.SelectedFilerItems.Count == 0) { | |
78 | + SCFiler2System.ShowTempMessage("ファイルが選択されていません"); | |
79 | + return; | |
80 | + } | |
81 | + targetItem = ViewInterfaces.LastFocusedFileView.SelectedFilerItems[0]; | |
82 | + } | |
83 | + this.Execute(targetItem); | |
84 | + } | |
74 | 85 | |
86 | + /// <summary> | |
87 | + /// 外部ツールで実行 | |
88 | + /// </summary> | |
89 | + /// <param name="target"></param> | |
90 | + public void Execute(IFilerItem target) { | |
75 | 91 | //登録された実行ファイルが実行時になかったらエラーを返して終了 |
76 | 92 | if (!System.IO.File.Exists(this.toolPathStr)) { |
77 | - SCFiler2System.ShowHistoryMessage("[error]外部ツール『"+toolTitle+"』が登録されたパスに見つかりません"); | |
93 | + SCFiler2System.ShowHistoryMessage("[error]外部ツール『" + toolTitle + "』が登録されたパスに見つかりません"); | |
78 | 94 | return; |
79 | 95 | } |
80 | - | |
81 | 96 | ProcessStartInfo startInfo = new ProcessStartInfo(); |
97 | + StringBuilder builder = new StringBuilder(this.toolArgumentStr); | |
82 | 98 | |
83 | - IFilerItem targetItem = null; | |
84 | - startInfo.WorkingDirectory = mainForm.GetLastFocusedFileView().CurrentPath; | |
85 | - //ビューの選択ファイルファイルを取得して実行 | |
86 | - if (ViewInterfaces.CurrentItemView.Type == ViewType.FileView) { | |
87 | - if (this.toolArgumentStr.IndexOf(@"%%%SELECTED_FILE%%%") >= 0) { | |
88 | - if (ViewInterfaces.LastFocusedFileView.SelectedFilerItems.Count == 0) { | |
89 | - SCFiler2System.ShowTempMessage("ファイルが選択されていません"); | |
90 | - return; | |
91 | - } | |
92 | - targetItem = ViewInterfaces.LastFocusedFileView.SelectedFilerItems[0]; | |
93 | - } | |
94 | - | |
95 | - } else if (ViewInterfaces.CurrentItemView.Type == ViewType.HistoryView) { | |
96 | - | |
97 | - if (this.toolArgumentStr.IndexOf(@"%%%SELECTED_FILE%%%") >= 0) { | |
98 | - if (ViewInterfaces.CurrentItemView.SelectedFilerItems.Count == 0) { | |
99 | - SCFiler2System.ShowTempMessage("ファイルが選択されていません"); | |
100 | - return; | |
101 | - } | |
102 | - targetItem = mainForm.GetLastFocusedHistoryView().SelectedFilerItems[0]; | |
103 | - startInfo.WorkingDirectory = targetItem.Path; | |
104 | - } | |
99 | + if (target != null) { | |
100 | + startInfo.WorkingDirectory = target.Path; | |
101 | + builder.Replace(@"%%%SELECTED_FILE%%%", "\"" + target.FullName + "\"");//とりあえず1個だけ対応 | |
102 | + builder.Replace(@"%%%CURRENT_PATH%%%", "\"" + target.Path + "\""); | |
105 | 103 | } else { |
106 | - SCFiler2System.ShowTempMessage(Messages.COMMAND_IS_NOT_VALID_IN_THIS_VIEW); | |
107 | - return; | |
104 | + startInfo.WorkingDirectory = ViewInterfaces.LastFocusedFileView.CurrentPath; | |
105 | + builder.Replace(@"%%%SELECTED_FILE%%%", ""); | |
106 | + builder.Replace(@"%%%CURRENT_PATH%%%", "\"" + ViewInterfaces.LastFocusedFileView.CurrentPath + "\""); | |
108 | 107 | } |
109 | - | |
110 | - StringBuilder builder = new StringBuilder(this.toolArgumentStr); | |
111 | - if (startInfo != null) { | |
112 | - builder.Replace(@"%%%CURRENT_PATH%%%", "\"" + startInfo.WorkingDirectory + "\""); | |
113 | - } | |
114 | - if (targetItem != null) { | |
115 | - builder.Replace(@"%%%SELECTED_FILE%%%", "\"" + targetItem.FullName + "\"");//とりあえず1個だけ対応 | |
116 | - } | |
117 | 108 | startInfo.Arguments = builder.ToString(); |
118 | 109 | |
119 | 110 | startInfo.FileName = toolPathStr; |
@@ -120,12 +111,11 @@ | ||
120 | 111 | Process.Start(startInfo); |
121 | 112 | |
122 | 113 | //実行されたアイテムは履歴ビューの最新にする |
123 | - if (targetItem != null) { | |
114 | + if (target != null) { | |
124 | 115 | foreach (HistoryManager manager in MainForm.Instance.AllHistoryManager) { |
125 | - manager.NotifyItemExecuted(targetItem); | |
116 | + manager.NotifyItemExecuted(target); | |
126 | 117 | } |
127 | 118 | } |
128 | 119 | } |
129 | - | |
130 | 120 | } |
131 | 121 | } |
@@ -80,10 +80,11 @@ | ||
80 | 80 | foreach (Item item in Items) { |
81 | 81 | //正規表現に合致したら外部ツールで起動する |
82 | 82 | if (item.expression.IsMatch(target.FullName)) { |
83 | - ActionManager.CreateAction(externalToolActions[item.num]).Execute(); | |
83 | + ExternalToolManager.Instance.GetItem(item.num + 1).Execute(target); | |
84 | 84 | return; |
85 | 85 | } |
86 | 86 | } |
87 | + //見つからなければ通常実行 | |
87 | 88 | this.ExecuteByNormalRelation(target); |
88 | 89 | } |
89 | 90 |
@@ -1,8 +1,10 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Text; |
4 | +using SCFiler2.PluginInterface; | |
4 | 5 | |
5 | 6 | namespace SCFiler2.ViewInterface { |
7 | + //ViewInterfacesと統合した方がいいかもしれないが、昔からあるので一応残す。SCFiler内からアクセスされる用 | |
6 | 8 | class ViewInterfaces { |
7 | 9 | private static MainForm mainForm = MainForm.Instance; |
8 | 10 | /// <summary> |
@@ -60,5 +62,15 @@ | ||
60 | 62 | public static void CheckUpdateAllView() { |
61 | 63 | mainForm.CheckUpdateAllView(); |
62 | 64 | } |
65 | + | |
66 | + public static List<IHistoryView> HistoryViews{ | |
67 | + get { | |
68 | + List<IHistoryView> list = new List<IHistoryView>(); | |
69 | + foreach (IHistoryView view in MainForm.Instance.AllHistoryView) { | |
70 | + list.Add(view); | |
71 | + } | |
72 | + return list; | |
73 | + } | |
74 | + } | |
63 | 75 | } |
64 | 76 | } |
@@ -63,11 +63,7 @@ | ||
63 | 63 | |
64 | 64 | public List<IHistoryView> HistoryViews { |
65 | 65 | get { |
66 | - List<IHistoryView> list = new List<IHistoryView>(); | |
67 | - foreach (IHistoryView view in MainForm.Instance.AllHistoryView) { | |
68 | - list.Add(view); | |
69 | - } | |
70 | - return list; | |
66 | + return ViewInterfaces.HistoryViews; | |
71 | 67 | } |
72 | 68 | } |
73 | 69 |
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | ■0.37 |
4 | 4 | ・プラグインにキー割り当てを可能にした |
5 | +・SCFiler2固有の関連付け実行が、プラグインからの呼び出しでは正しく実行しなかったのを修正 | |
5 | 6 | |
6 | 7 | ■0.36 |
7 | 8 | ・ジャンプフォルダの削除機能を実装し忘れていたので実装 |