mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[github] Extract data provider interface to separate file
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ import org.jetbrains.plugins.github.api.GithubServerPath
|
||||
import org.jetbrains.plugins.github.api.data.GithubRepoDetailed
|
||||
import org.jetbrains.plugins.github.api.data.GithubSearchedIssue
|
||||
import org.jetbrains.plugins.github.pullrequest.GithubPullRequestsComponentFactory
|
||||
import org.jetbrains.plugins.github.pullrequest.data.GithubPullRequestsDataLoader
|
||||
import org.jetbrains.plugins.github.pullrequest.data.GithubPullRequestDataProvider
|
||||
|
||||
object GithubPullRequestKeys {
|
||||
@JvmStatic
|
||||
@@ -22,7 +22,7 @@ object GithubPullRequestKeys {
|
||||
val SELECTED_PULL_REQUEST = DataKey.create<GithubSearchedIssue>("org.jetbrains.plugins.github.pullrequest.selected")
|
||||
@JvmStatic
|
||||
val SELECTED_PULL_REQUEST_DATA_PROVIDER =
|
||||
DataKey.create<GithubPullRequestsDataLoader.DataProvider>("org.jetbrains.plugins.github.pullrequest.selected.dataprovider")
|
||||
DataKey.create<GithubPullRequestDataProvider>("org.jetbrains.plugins.github.pullrequest.selected.dataprovider")
|
||||
@JvmStatic
|
||||
val REPOSITORY = DataKey.create<GitRepository>("org.jetbrains.plugins.github.pullrequest.repository")
|
||||
@JvmStatic
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.github.pullrequest.data
|
||||
|
||||
import com.intellij.openapi.util.Couple
|
||||
import com.intellij.openapi.vcs.changes.Change
|
||||
import git4idea.GitCommit
|
||||
import org.jetbrains.plugins.github.api.data.GithubPullRequestDetailedWithHtml
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
interface GithubPullRequestDataProvider {
|
||||
val detailsRequest: CompletableFuture<GithubPullRequestDetailedWithHtml>
|
||||
val branchFetchRequest: CompletableFuture<Couple<String>>
|
||||
val logCommitsRequest: CompletableFuture<List<GitCommit>>
|
||||
val changesRequest: CompletableFuture<List<Change>>
|
||||
}
|
||||
+2
-9
@@ -63,7 +63,7 @@ class GithubPullRequestsDataLoader(private val project: Project,
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
fun getDataProvider(githubSearchedIssue: GithubSearchedIssue): DataProvider {
|
||||
fun getDataProvider(githubSearchedIssue: GithubSearchedIssue): GithubPullRequestDataProvider {
|
||||
if (isDisposed) throw IllegalStateException("Already disposed")
|
||||
|
||||
return cache.get(githubSearchedIssue.number) {
|
||||
@@ -78,7 +78,7 @@ class GithubPullRequestsDataLoader(private val project: Project,
|
||||
invalidationEventDispatcher.addListener(listener, disposable)
|
||||
|
||||
private inner class DataTask(private val url: String, private val progressIndicator: ProgressIndicator)
|
||||
: Task.Backgroundable(project, "Load Pull Request Data", true), DataProvider {
|
||||
: Task.Backgroundable(project, "Load Pull Request Data", true), GithubPullRequestDataProvider {
|
||||
|
||||
override val detailsRequest = CompletableFuture<GithubPullRequestDetailedWithHtml>()
|
||||
override val branchFetchRequest = CompletableFuture<Couple<String>>()
|
||||
@@ -153,13 +153,6 @@ class GithubPullRequestsDataLoader(private val project: Project,
|
||||
isDisposed = true
|
||||
}
|
||||
|
||||
interface DataProvider {
|
||||
val detailsRequest: CompletableFuture<GithubPullRequestDetailedWithHtml>
|
||||
val branchFetchRequest: CompletableFuture<Couple<String>>
|
||||
val logCommitsRequest: CompletableFuture<List<GitCommit>>
|
||||
val changesRequest: CompletableFuture<List<Change>>
|
||||
}
|
||||
|
||||
interface ProviderChangedListener : EventListener {
|
||||
fun providerChanged(pullRequestNumber: Long)
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package org.jetbrains.plugins.github.pullrequest.ui
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.ui.OnePixelSplitter
|
||||
import org.jetbrains.plugins.github.pullrequest.data.GithubPullRequestsDataLoader
|
||||
import org.jetbrains.plugins.github.pullrequest.data.GithubPullRequestDataProvider
|
||||
|
||||
class GithubPullRequestPreviewComponent(private val changes: GithubPullRequestChangesComponent,
|
||||
private val details: GithubPullRequestDetailsComponent)
|
||||
@@ -20,7 +20,7 @@ class GithubPullRequestPreviewComponent(private val changes: GithubPullRequestCh
|
||||
firstComponent = changes
|
||||
}
|
||||
|
||||
fun setPreviewDataProvider(provider: GithubPullRequestsDataLoader.DataProvider?) {
|
||||
fun setPreviewDataProvider(provider: GithubPullRequestDataProvider?) {
|
||||
changes.loadAndShow(provider?.changesRequest)
|
||||
details.loadAndShow(provider?.detailsRequest)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user