-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV2-2807: Explanatory IDE indications in status bar (#530)
- Loading branch information
Assaf Sapir
authored
May 25, 2023
1 parent
1c16e25
commit 823122a
Showing
22 changed files
with
254 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...SelfHosted/src/main/java/com/tabnineSelfHosted/binary/lifecycle/UserInfoChangeNotifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.tabnineSelfHosted.binary.lifecycle | ||
|
||
import com.intellij.util.messages.Topic | ||
import com.tabnineSelfHosted.binary.requests.userInfo.UserInfoResponse | ||
|
||
fun interface UserInfoChangeNotifier { | ||
companion object { | ||
val USER_INFO_CHANGED_TOPIC: Topic<UserInfoChangeNotifier> = Topic.create( | ||
"User Info Changed Notifier", | ||
UserInfoChangeNotifier::class.java | ||
) | ||
} | ||
|
||
fun stateChanged(state: UserInfoResponse) | ||
} |
38 changes: 38 additions & 0 deletions
38
TabnineSelfHosted/src/main/java/com/tabnineSelfHosted/binary/lifecycle/UserInfoService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.tabnineSelfHosted.binary.lifecycle | ||
|
||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.util.concurrency.AppExecutorUtil | ||
import com.intellij.util.messages.MessageBus | ||
import com.tabnineCommon.general.DependencyContainer | ||
import com.tabnineSelfHosted.binary.requests.userInfo.UserInfoRequest | ||
import com.tabnineSelfHosted.binary.requests.userInfo.UserInfoResponse | ||
import java.util.concurrent.TimeUnit | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
|
||
class UserInfoService { | ||
private val scheduler = AppExecutorUtil.getAppScheduledExecutorService() | ||
private val messageBus: MessageBus = ApplicationManager.getApplication().messageBus | ||
private val updateLoopStarted = AtomicBoolean(false) | ||
private val binaryRequestFacade = DependencyContainer.instanceOfBinaryRequestFacade() | ||
var lastUserInfoResponse: UserInfoResponse? = null | ||
|
||
fun startUpdateLoop() { | ||
if (updateLoopStarted.getAndSet(true)) { | ||
return | ||
} | ||
|
||
scheduler.scheduleWithFixedDelay(Runnable { updateState() }, 0, 2, TimeUnit.SECONDS) | ||
} | ||
|
||
private fun updateState() { | ||
val userInfoResponse = binaryRequestFacade.executeRequest(UserInfoRequest()) | ||
if (userInfoResponse != null) { | ||
if (userInfoResponse != this.lastUserInfoResponse) { | ||
messageBus | ||
.syncPublisher(UserInfoChangeNotifier.USER_INFO_CHANGED_TOPIC) | ||
.stateChanged(userInfoResponse) | ||
} | ||
this.lastUserInfoResponse = userInfoResponse | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...elfHosted/src/main/java/com/tabnineSelfHosted/binary/requests/userInfo/UserInfoRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.tabnineSelfHosted.binary.requests.userInfo | ||
|
||
import com.tabnineCommon.binary.BinaryRequest | ||
|
||
class UserInfoRequest : BinaryRequest<UserInfoResponse> { | ||
override fun response(): Class<UserInfoResponse> { | ||
return UserInfoResponse::class.java | ||
} | ||
|
||
override fun serialize(): Any { | ||
return mapOf("UserInfo" to this) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...lfHosted/src/main/java/com/tabnineSelfHosted/binary/requests/userInfo/UserInfoResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.tabnineSelfHosted.binary.requests.userInfo | ||
|
||
import com.tabnineCommon.binary.BinaryResponse | ||
|
||
data class UserInfoResponse( | ||
var email: String = "", | ||
var team: Team? = null, | ||
var isLoggedIn: Boolean = false, | ||
var verified: Boolean = false, | ||
) : BinaryResponse | ||
|
||
data class Team( | ||
val name: String = "", | ||
val role: Role = Role.Member | ||
) | ||
|
||
enum class Role { | ||
Admin, | ||
Member | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.