feat(Action): add UpdateSolutionReferencesAction
This commit is contained in:
parent
fbca5919e7
commit
15ec12d518
@ -7,8 +7,11 @@ import com.intellij.execution.ui.ConsoleViewContentType;
|
|||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.progress.ProgressIndicator;
|
||||||
|
import com.intellij.openapi.progress.Task;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import groovyjarjarantlr4.v4.runtime.misc.NotNull;
|
||||||
|
|
||||||
public class ReUpdateReferencesByProjectChainAction extends BaseAction {
|
public class ReUpdateReferencesByProjectChainAction extends BaseAction {
|
||||||
|
|
||||||
@ -26,10 +29,19 @@ public class ReUpdateReferencesByProjectChainAction extends BaseAction {
|
|||||||
if (file != null && project != null) {
|
if (file != null && project != null) {
|
||||||
String csprojPath = file.getPath();
|
String csprojPath = file.getPath();
|
||||||
String command = "jenkins reUpdateReferences " + csprojPath;
|
String command = "jenkins reUpdateReferences " + csprojPath;
|
||||||
|
|
||||||
|
if (project != null) {
|
||||||
|
new Task.Backgroundable(project, "Updating Solution References", false) {
|
||||||
|
@Override
|
||||||
|
public void run(@NotNull ProgressIndicator indicator) {
|
||||||
|
// 在这里执行你的CMD命令
|
||||||
CommandHelper.executeCommand(consoleView, command, "nugethelper.exe");
|
CommandHelper.executeCommand(consoleView, command, "nugethelper.exe");
|
||||||
|
printToConsole("========== Finish to ReUpdateReferencesByProjectChainAction. ==========", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||||
|
}
|
||||||
|
}.queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printToConsole("========== Finish to ReUpdateReferencesByProjectChainAction. ==========", ConsoleViewContentType.NORMAL_OUTPUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,8 +6,11 @@ import com.intellij.execution.ui.ConsoleView;
|
|||||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.progress.ProgressIndicator;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.openapi.progress.Task;
|
||||||
|
import groovyjarjarantlr4.v4.runtime.misc.NotNull;
|
||||||
|
|
||||||
public class UpdateReferencesByProjectChainAction extends BaseAction {
|
public class UpdateReferencesByProjectChainAction extends BaseAction {
|
||||||
|
|
||||||
@ -25,10 +28,18 @@ public class UpdateReferencesByProjectChainAction extends BaseAction {
|
|||||||
if (file != null && project != null) {
|
if (file != null && project != null) {
|
||||||
String csprojPath = file.getPath();
|
String csprojPath = file.getPath();
|
||||||
String command = "jenkins updateReferences " + csprojPath;
|
String command = "jenkins updateReferences " + csprojPath;
|
||||||
|
if (project != null) {
|
||||||
|
new Task.Backgroundable(project, "Updating Solution References", false) {
|
||||||
|
@Override
|
||||||
|
public void run(@NotNull ProgressIndicator indicator) {
|
||||||
|
// 在这里执行你的CMD命令
|
||||||
CommandHelper.executeCommand(consoleView, command, "nugethelper.exe");
|
CommandHelper.executeCommand(consoleView, command, "nugethelper.exe");
|
||||||
|
printToConsole("========== Finish to UpdateReferencesByProjectChain. ==========", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||||
|
}
|
||||||
|
}.queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printToConsole("========== Finish to UpdateReferencesByProjectChain. ==========", ConsoleViewContentType.NORMAL_OUTPUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.dida.didanugetextension.action;
|
||||||
|
|
||||||
|
import com.dida.didanugetextension.action.base.BaseAction;
|
||||||
|
import com.dida.didanugetextension.util.CommandHelper;
|
||||||
|
import com.intellij.execution.ui.ConsoleView;
|
||||||
|
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.progress.ProgressIndicator;
|
||||||
|
import com.intellij.openapi.progress.Task;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import groovyjarjarantlr4.v4.runtime.misc.NotNull;
|
||||||
|
|
||||||
|
public class UpdateSolutionReferencesAction extends BaseAction {
|
||||||
|
|
||||||
|
public UpdateSolutionReferencesAction() {
|
||||||
|
super("Update Solution References");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void runAction(Project project, ConsoleView consoleView,AnActionEvent event) {
|
||||||
|
printToConsole("Begin to UpdateSolutionReferencesAction.", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||||
|
|
||||||
|
// 获取选中的项目文件或目录
|
||||||
|
VirtualFile file = event.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE);
|
||||||
|
if (file != null && project != null) {
|
||||||
|
String solutionPath = file.getPath();
|
||||||
|
String command = "jenkins updateReferences " + solutionPath + " VisualStudioExtension";
|
||||||
|
if (project != null) {
|
||||||
|
new Task.Backgroundable(project, "Updating Solution References", false) {
|
||||||
|
@Override
|
||||||
|
public void run(@NotNull ProgressIndicator indicator) {
|
||||||
|
// 在这里执行你的CMD命令
|
||||||
|
CommandHelper.executeCommand(consoleView, command, "nugethelper.exe");
|
||||||
|
printToConsole("========== Finish to UpdateSolutionReferencesAction. ==========", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||||
|
}
|
||||||
|
}.queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(AnActionEvent e) {
|
||||||
|
// 设置动作是否可见和启用
|
||||||
|
VirtualFile selectedFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||||
|
boolean isCsprojFile = selectedFile != null && selectedFile.getName().endsWith(".sln");
|
||||||
|
e.getPresentation().setEnabledAndVisible(isCsprojFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
<group id="DidaNuGetExtension.ActionGroup" text="DidaNuGetExtension" popup="true">
|
<group id="DidaNuGetExtension.ActionGroup" text="DidaNuGetExtension" popup="true">
|
||||||
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
||||||
|
<action id="DidaNuGetExtension.UpdateSolutionReferencesAction" class="com.dida.didanugetextension.action.UpdateSolutionReferencesAction" text="UpdateSolutionReferencesAction"/>
|
||||||
<action id="DidaNuGetExtension.UpdateReferencesByProjectChain" class="com.dida.didanugetextension.action.UpdateReferencesByProjectChainAction" text="UpdateReferencesByProjectChain"/>
|
<action id="DidaNuGetExtension.UpdateReferencesByProjectChain" class="com.dida.didanugetextension.action.UpdateReferencesByProjectChainAction" text="UpdateReferencesByProjectChain"/>
|
||||||
<action id="DidaNuGetExtension.ReUpdateReferencesByProjectChain" class="com.dida.didanugetextension.action.ReUpdateReferencesByProjectChainAction" text="ReUpdateReferencesByProjectChain"/>
|
<action id="DidaNuGetExtension.ReUpdateReferencesByProjectChain" class="com.dida.didanugetextension.action.ReUpdateReferencesByProjectChainAction" text="ReUpdateReferencesByProjectChain"/>
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user