Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellij plugin doesn't need IDE restart anymore #416

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Optional;
import java.util.Properties;

public class GradleJdksEnablement {
public final class GradleJdksEnablement {

public static final String MINIMUM_SUPPORTED_GRADLE_VERSION = "7.6";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.platform.ide.progress.TaskCancellation;
import com.intellij.platform.ide.progress.TasksKt;
import com.intellij.platform.util.progress.StepsKt;
import com.intellij.ui.content.Content;
Expand All @@ -56,7 +57,7 @@
import org.jetbrains.plugins.gradle.settings.GradleSettings;

@Service(Service.Level.PROJECT)
public final class GradleJdksProjectService {
public final class GradleJdksProjectService implements Disposable {

private final Logger logger = Logger.getInstance(GradleJdksProjectService.class);
private static final String TOOL_WINDOW_NAME = "Gradle JDK Setup";
Expand All @@ -81,7 +82,6 @@ private ConsoleView initConsoleView() {
ContentFactory contentFactory = ContentFactory.getInstance();
Content content = contentFactory.createContent(newConsoleView.getComponent(), "", false);
toolWindow.getContentManager().addContent(content);
Disposer.register(project, newConsoleView);
});

return newConsoleView;
Expand Down Expand Up @@ -111,6 +111,7 @@ public void maybeSetupGradleJdks() {
TasksKt.withBackgroundProgress(
project,
"Gradle JDK Setup",
TaskCancellation.nonCancellable(),
Copy link
Contributor Author

@crogoz crogoz Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the user had a button "x" to cancel the background task, but even if they clicked the button nothing would happen until the ./gradle-jdks-setup script finished running.
Now, the button won't be shown anymore.
Screenshot 2024-09-17 at 12 12 05 PM

(_coroutineScope, continuation) -> {
StepsKt.withProgressText(
"`Gradle JDK Setup` is running. Logs in the `Gradle JDK Setup` window ...",
Expand Down Expand Up @@ -191,4 +192,12 @@ private void updateGradleJvm() {
}
}
}

@Override
public void dispose() {
ConsoleView view = consoleView.get();
if (view != null) {
view.dispose();
}
}
}
2 changes: 1 addition & 1 deletion idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<idea-plugin url="https://github.com/palantir/gradle-jdks">
<idea-plugin url="https://github.com/palantir/gradle-jdks" require-restart="false">
<id>palantir-gradle-jdks</id>
<name>palantir-gradle-jdks</name>
<vendor url="https://github.com/palantir/gradle-jdks">
Expand Down