From b53d91d6733331b43e8fe84c4b466a8943e61782 Mon Sep 17 00:00:00 2001 From: mcmics Date: Sun, 23 Jul 2023 21:23:43 +0200 Subject: [PATCH] remove deprecated API methods --- .../tools/jenkins/StartupJenkinsService.java | 29 +++++++++++-------- .../tools/jenkins/view/BuildParamDialog.java | 2 +- .../jenkins/view/action/SelectViewAction.java | 2 +- .../view/action/UploadPatchToJobAction.java | 2 +- src/main/resources/META-INF/plugin.xml | 1 + 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/StartupJenkinsService.java b/src/main/java/org/codinjutsu/tools/jenkins/StartupJenkinsService.java index 2a3d1b80..f8ef336f 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/StartupJenkinsService.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/StartupJenkinsService.java @@ -7,27 +7,20 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.project.Project; -import com.intellij.openapi.startup.StartupActivity; +import com.intellij.openapi.startup.ProjectActivity; import com.intellij.ui.AppUIUtil; import com.intellij.util.messages.MessageBusConnection; +import kotlin.Unit; +import kotlin.coroutines.Continuation; import org.codinjutsu.tools.jenkins.logic.BrowserPanelAuthenticationHandler; import org.codinjutsu.tools.jenkins.logic.LoginService; import org.codinjutsu.tools.jenkins.logic.RssAuthenticationActionHandler; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class StartupJenkinsService implements StartupActivity.Background, DynamicPluginListener { +public class StartupJenkinsService implements ProjectActivity, DynamicPluginListener { private static final Logger LOG = Logger.getInstance(JenkinsTree.class); - @Override - public void runActivity(@NotNull Project project) { - RssAuthenticationActionHandler.getInstance(project).subscribe(); - BrowserPanelAuthenticationHandler.getInstance(project).subscribe(); - final LoginService loginService = LoginService.getInstance(project); - AppUIUtil.invokeLaterIfProjectAlive(project, loginService::performAuthentication); - final MessageBusConnection busConnection = ApplicationManager.getApplication().getMessageBus().connect(); - busConnection.subscribe(DynamicPluginListener.TOPIC, this); - } - @Override public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { if (isJenkinsPlugin(pluginDescriptor)) { @@ -45,4 +38,16 @@ public void checkUnloadPlugin(@NotNull IdeaPluginDescriptor pluginDescriptor) th private static boolean isJenkinsPlugin(@NotNull IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getPluginId() == PluginId.getId(Version.PLUGIN_ID); } + + @Nullable + @Override + public Object execute(@NotNull Project project, @NotNull Continuation continuation) { + RssAuthenticationActionHandler.getInstance(project).subscribe(); + BrowserPanelAuthenticationHandler.getInstance(project).subscribe(); + final LoginService loginService = LoginService.getInstance(project); + AppUIUtil.invokeLaterIfProjectAlive(project, loginService::performAuthentication); + final MessageBusConnection busConnection = ApplicationManager.getApplication().getMessageBus().connect(); + busConnection.subscribe(DynamicPluginListener.TOPIC, this); + return project; + } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/BuildParamDialog.java b/src/main/java/org/codinjutsu/tools/jenkins/view/BuildParamDialog.java index 0c2d930e..ea15dd37 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/BuildParamDialog.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/BuildParamDialog.java @@ -88,7 +88,7 @@ public static void showDialog(@NotNull Project project, final Job job, final Jen dialog.onOK(); } dialog.saveLastSize(); - }, ModalityState.NON_MODAL); + }, ModalityState.nonModal()); } private void restoreLastWidth() { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/action/SelectViewAction.java b/src/main/java/org/codinjutsu/tools/jenkins/view/action/SelectViewAction.java index 150d48ea..1df155e8 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/action/SelectViewAction.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/action/SelectViewAction.java @@ -142,7 +142,7 @@ public void mouseClicked(MouseEvent e) { JBPopup popup = new PopupChooserBuilder<>(viewList) .setMovable(false) .setCancelKeyEnabled(true) - .setItemChoosenCallback(() -> { + .setItemChosenCallback(() -> { final View view = viewList.getSelectedValue(); if (view == null || view.hasNestedView()) return; browserPanel.loadView(view); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/action/UploadPatchToJobAction.java b/src/main/java/org/codinjutsu/tools/jenkins/view/action/UploadPatchToJobAction.java index 9bb0d071..80f0c7c8 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/action/UploadPatchToJobAction.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/action/UploadPatchToJobAction.java @@ -71,7 +71,7 @@ private void actionPerformed(Project project, BrowserPanel browserPanel) { ApplicationManager.getApplication().invokeLater( () -> RunBuildWithPatch.getInstance(project).runBuild(project, job, selectedFile, this::logError), - ModalityState.NON_MODAL); + ModalityState.nonModal()); } } else { message = String.format("Job \"%s\" should has parameter with name \"%s\"", job.getNameToRenderSingleJob(), diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 2b59f9c2..0c54e666 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -65,6 +65,7 @@ +