Skip to content

Commit 0792fdc

Browse files
Merge pull request #10958 from srnagar/fix-cancel
Fix azd install cancel button
2 parents 6077343 + 8fdd58e commit 0792fdc

File tree

3 files changed

+14
-5
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij

3 files changed

+14
-5
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/TerminalUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public static void executeInTerminal(@Nonnull Project project, @Nonnull String c
4949
}, AzureTask.Modality.ANY);
5050
}
5151

52+
public static void executeInTerminal(TerminalWidget terminalWidget, String command) {
53+
AzureTaskManager.getInstance().runLater(() -> {
54+
AzureTaskManager.getInstance().runInBackground(OperationBundle.description("boundary/common.execute_in_terminal.command", command), () -> {
55+
terminalWidget.getTtyConnectorAccessor().executeWithTtyConnector((connector) -> {
56+
terminalWidget.sendCommandToExecute(command);
57+
});
58+
});
59+
}, AzureTask.Modality.ANY);
60+
}
61+
5262
@Nonnull
5363
public static TerminalWidget createTerminalWidget(@Nonnull Project project, @Nullable Path workingDir, String terminalTabTitle) {
5464
final TerminalToolWindowManager manager = TerminalToolWindowManager.getInstance(project);
@@ -57,7 +67,7 @@ public static TerminalWidget createTerminalWidget(@Nonnull Project project, @Nul
5767
}
5868

5969
@Nonnull
60-
private static TerminalWidget getOrCreateTerminalWidget(@Nonnull Project project, @Nullable Path workingDir, String terminalTabTitle) {
70+
public static TerminalWidget getOrCreateTerminalWidget(@Nonnull Project project, @Nullable Path workingDir, String terminalTabTitle) {
6171
final TerminalToolWindowManager manager = TerminalToolWindowManager.getInstance(project);
6272
final String workingDirectory = Optional.ofNullable(workingDir).map(Path::toString).orElse(null);
6373
return manager.getTerminalWidgets().stream()

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-service-explorer/src/main/java/com/microsoft/azure/toolkit/intellij/explorer/azd/AzdNode.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,10 @@ public void addChildren() {
5555
final String command;
5656
if (System.getProperties().getProperty("os.name").toLowerCase().contains("windows")) {
5757
command = "winget install microsoft.azd";
58-
TerminalUtils.executeInTerminal(project, "winget install microsoft.azd", "azd");
5958
} else if (System.getProperties().getProperty("os.name").toLowerCase().contains("linux")) {
6059
command = "curl -fsSL https://aka.ms/install-azd.sh | bash";
61-
TerminalUtils.executeInTerminal(project, "curl -fsSL https://aka.ms/install-azd.sh | bash", "azd");
6260
} else {
6361
command = "brew tap azure/azd && brew install azd";
64-
TerminalUtils.executeInTerminal(project, "brew tap azure/azd && brew install azd", "azd");
6562
}
6663
final ConfirmAndRunDialog installDialog = new ConfirmAndRunDialog(project, "Install azd", "Do you want to install Azure Developer CLI (azd)?", command);
6764
installDialog.setOkButtonText("Install");

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-service-explorer/src/main/java/com/microsoft/azure/toolkit/intellij/explorer/azd/ConfirmAndRunDialog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.intellij.openapi.project.Project;
44
import com.intellij.openapi.ui.DialogWrapper;
5+
import com.intellij.terminal.ui.TerminalWidget;
56
import com.microsoft.azure.toolkit.intellij.common.TerminalUtils;
67
import org.jetbrains.annotations.NotNull;
78
import org.jetbrains.annotations.Nullable;
@@ -53,7 +54,8 @@ public void setOkButtonText(String okButtonText) {
5354
protected void doOKAction() {
5455
AzdUtils.logTelemetryEvent("azd-" + eventName + "-ok");
5556
super.doOKAction();
56-
TerminalUtils.executeInTerminal(project, command, "azd");
57+
final TerminalWidget azdTerminal = TerminalUtils.getOrCreateTerminalWidget(project, null, "azd");
58+
TerminalUtils.executeInTerminal(azdTerminal, command);
5759
}
5860

5961
@Override

0 commit comments

Comments
 (0)