generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Focus ToolWindow to not use Register that is Internal in 2022.1
- Loading branch information
1 parent
3c30ff7
commit e1d7e7f
Showing
3 changed files
with
53 additions
and
49 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/extensions/FocusToolWindowFactory.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,44 @@ | ||
package br.com.devsrsouza.intellij.dropboxfocus.extensions | ||
|
||
import androidx.compose.ui.awt.ComposePanel | ||
import br.com.devsrsouza.intellij.dropboxfocus.services.FocusGradleSettingsReader | ||
import br.com.devsrsouza.intellij.dropboxfocus.services.FocusService | ||
import br.com.devsrsouza.intellij.dropboxfocus.ui.FocusSelection | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.ToolWindow | ||
import com.intellij.openapi.wm.ToolWindowFactory | ||
import java.awt.Dimension | ||
|
||
class FocusToolWindowFactory : ToolWindowFactory { | ||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { | ||
ApplicationManager.getApplication().invokeLater { | ||
toolWindow.component.add( | ||
ComposePanel().apply { | ||
val focusService = project.service<FocusService>() | ||
preferredSize = Dimension(300, 300) | ||
setContent { | ||
FocusSelection( | ||
currentFocusGradleSettingsState = project.service<FocusGradleSettingsReader>() | ||
.focusGradleSettings, | ||
isLoadingState = focusService.focusOperationState, | ||
syncGradle = focusService::syncGradle, | ||
selectModuleToFocus = { focusGradleSettings, focusModule -> | ||
focusService.focusOn(focusGradleSettings, focusModule.gradleModulePath) | ||
} | ||
) | ||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
override fun isApplicable(project: Project): Boolean { | ||
return true | ||
} | ||
|
||
override fun shouldBeAvailable(project: Project): Boolean { | ||
return project.service<FocusGradleSettingsReader>().focusGradleSettings.value != null | ||
} | ||
} |
55 changes: 6 additions & 49 deletions
55
src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/services/FocusToolWindowService.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
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