Skip to content

Commit

Permalink
remove deprecated API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMicS committed Jul 24, 2023
1 parent c0eb31b commit 21fcfd0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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<? super Unit> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<aboutPopupDescriptionProvider implementation="org.codinjutsu.tools.jenkins.view.JenkinsAbout" />
<notificationGroup displayType="NONE" id="Jenkins Rss" />
<notificationGroup displayType="TOOL_WINDOW" id="Jenkins Notification" toolWindowId="Jenkins"/>
<backgroundPostStartupActivity implementation="org.codinjutsu.tools.jenkins.StartupJenkinsService" />
</extensions>

<actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ public void setUp() throws IOException {
configuration = new JenkinsAppSettings();
jenkinsSettings = new JenkinsSettings();
when(project.getService(UrlBuilder.class)).thenReturn(urlBuilderMock);
// final PicoContainer container = mock(PicoContainer.class);
// when(project.getPicoContainer()).thenReturn(container);
// when(container.getComponentInstance(UrlBuilder.class.getName())).thenReturn(urlBuilderMock);
requestManager = new RequestManager(project);
requestManager.setSecurityClient(securityClientMock);
requestManager.setJenkinsServer(jenkinsServer);
Expand Down

0 comments on commit 21fcfd0

Please sign in to comment.