Skip to content

Commit

Permalink
fixed deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
dkandalov committed Sep 12, 2024
1 parent e5a40c2 commit ba4a7cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.util.proxy.CommonProxy
import com.intellij.util.net.JdkProxyProvider
import liveplugin.implementation.LivePluginPaths.livePluginsPath
import liveplugin.implementation.actions.gist.GistApi.FailedRequest
import liveplugin.implementation.actions.gist.GistApi.Gist
Expand All @@ -18,7 +18,7 @@ import liveplugin.implementation.common.IdeUtil.showInputDialog
import liveplugin.implementation.common.createFile
import liveplugin.implementation.common.inputValidator
import java.io.IOException
import java.net.URL
import java.net.URI

class AddPluginFromGistAction : AnAction("Copy from Gist", "Copy from Gist", AllIcons.Vcs.Vendors.Github), DumbAware {

Expand Down Expand Up @@ -60,7 +60,7 @@ class AddPluginFromGistAction : AnAction("Copy from Gist", "Copy from Gist", All
object : Task.Backgroundable(project, "Fetching gist…", true, ALWAYS_BACKGROUND) {
override fun run(indicator: ProgressIndicator) {
try {
val proxy = CommonProxy.getInstance().select(URL("https://api.github.com/gists")).firstOrNull()
val proxy = JdkProxyProvider.getInstance().proxySelector.select(URI("https://api.github.com/gists")).firstOrNull()
val gist = GistApiHttp(proxy).getGist(extractGistIdFrom(gistUrl)!!)
runLaterOnEdt { onSuccess(gist) }
} catch (e: FailedRequest) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package liveplugin.implementation.actions.gist

import com.intellij.collaboration.auth.AccountManagerBase
import com.intellij.icons.AllIcons
import com.intellij.ide.BrowserUtil
import com.intellij.notification.NotificationListener.URL_OPENING_LISTENER
Expand All @@ -21,18 +20,18 @@ import com.intellij.ui.dsl.builder.Align
import com.intellij.ui.dsl.builder.AlignY
import com.intellij.ui.dsl.builder.RowLayout.LABEL_ALIGNED
import com.intellij.ui.dsl.builder.panel
import com.intellij.util.proxy.CommonProxy
import com.intellij.util.net.JdkProxyProvider
import kotlinx.coroutines.runBlocking
import liveplugin.implementation.actions.gist.GistApi.*
import liveplugin.implementation.common.IdeUtil.runLaterOnEdt
import liveplugin.implementation.common.IdeUtil.showError
import liveplugin.implementation.common.livePluginNotificationGroup
import liveplugin.implementation.livePlugins
import org.jetbrains.plugins.github.authentication.GHAccountsUtil
import org.jetbrains.plugins.github.authentication.accounts.GithubAccount
import org.jetbrains.plugins.github.authentication.accounts.GHAccountManager
import java.awt.datatransfer.StringSelection
import java.io.IOException
import java.net.URL
import java.net.URI
import javax.swing.JTextArea

class SharePluginAsGistAction : AnAction("Share as Gist", "Share as plugin files as a Gist", AllIcons.Vcs.Vendors.Github), DumbAware {
Expand All @@ -53,7 +52,7 @@ class SharePluginAsGistAction : AnAction("Share as Gist", "Share as plugin files
public = !dialog.isSecret,
files = livePlugin.path.allFiles().associate { it.name to GistFile(it.readText()) }
)
val proxy = CommonProxy.getInstance().select(URL("https://api.github.com/gists")).firstOrNull()
val proxy = JdkProxyProvider.getInstance().proxySelector.select(URI("https://api.github.com/gists")).firstOrNull()
val newGist = GistApiHttp(proxy).create(gist, authToken)
runLaterOnEdt {
if (dialog.isCopyURL) {
Expand Down Expand Up @@ -84,10 +83,8 @@ class SharePluginAsGistAction : AnAction("Share as Gist", "Share as plugin files
}.queue()
}

@Suppress("UNCHECKED_CAST")
private fun githubAccountManager() =
ApplicationManager.getApplication().getService(Class.forName("org.jetbrains.plugins.github.authentication.accounts.GHAccountManager"))
as AccountManagerBase<GithubAccount, String>
ApplicationManager.getApplication().getService(GHAccountManager::class.java)

override fun update(event: AnActionEvent) {
event.presentation.isEnabled = event.livePlugins().isNotEmpty()
Expand Down

0 comments on commit ba4a7cf

Please sign in to comment.