diff --git a/idea-plugin/gradle.properties b/idea-plugin/gradle.properties index 69e3fa0179..077072f910 100644 --- a/idea-plugin/gradle.properties +++ b/idea-plugin/gradle.properties @@ -11,5 +11,5 @@ plugin.until.build=212.* plugin.verifier.ide.versions=2020.3.2, 2021.1 platform.type=IC -platform.version=2020.3.2 +platform.version=2021.1 platform.download.sources=true diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewFloatingToolbarProvider.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewFloatingToolbarProvider.kt index edc9dcf105..f029ea8a68 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewFloatingToolbarProvider.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewFloatingToolbarProvider.kt @@ -26,14 +26,20 @@ class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_E override fun register(toolbar: FloatingToolbarComponent, parentDisposable: Disposable) { try { // todo: use provided data context once 2020.3 is no longer supported - val toolbarImpl = toolbar as? FloatingToolbarComponentImpl ?: return - val editor = toolbarImpl.getData(CommonDataKeys.EDITOR.name) as? Editor ?: return + val toolbarClass = FloatingToolbarComponentImpl::class.java + val getDataMethod = toolbarClass.getMethod("getData", String::class.java) + val editor = getDataMethod.invoke(toolbar, CommonDataKeys.EDITOR.name) as? Editor ?: return registerComponent(toolbar, editor, parentDisposable) } catch (e: Exception) { LOG.error(e) } } + override fun register(dataContext: DataContext, component: FloatingToolbarComponent, parentDisposable: Disposable) { + val editor = dataContext.getData(CommonDataKeys.EDITOR) ?: return + registerComponent(component, editor, parentDisposable) + } + private fun registerComponent( component: FloatingToolbarComponent, editor: Editor,