Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
[PRJ-112] Fix not configured IDE crash when the client keymap is not …
Browse files Browse the repository at this point in the history
…found
  • Loading branch information
SerVB committed Sep 15, 2020
1 parent 26f1eb4 commit 97071ca
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
package org.jetbrains.projector.server.idea

import org.jetbrains.projector.common.protocol.data.UserKeymap
import org.jetbrains.projector.server.log.Logger
import javax.swing.SwingUtilities

object KeymapSetter {

private val logger = Logger(KeymapSetter::class.simpleName!!)

private fun UserKeymap.toKeyMapManagerFieldName() = when (this) {
UserKeymap.WINDOWS -> "X_WINDOW_KEYMAP"
UserKeymap.MAC -> "MAC_OS_X_10_5_PLUS_KEYMAP"
Expand All @@ -43,11 +46,21 @@ object KeymapSetter {

val keymapManagerExInstance = keymapManagerExClass
.getDeclaredMethod("getInstanceEx")
.invoke(null)!!
.invoke(null)

if (keymapManagerExInstance == null) {
logger.error { "getInstanceEx() == null - skipping setting keymap" }
return@invokeLater
}

val keymapInstance = keymapManagerClass
.getDeclaredMethod("getKeymap", String::class.java)
.invoke(keymapManagerExInstance, userKeymapName)!!
.invoke(keymapManagerExInstance, userKeymapName)

if (keymapInstance == null) {
logger.error { "getKeymap($userKeymapName) == null - skipping setting keymap" }
return@invokeLater
}

val keymapClass = Class.forName("com.intellij.openapi.keymap.Keymap", false, ideaClassLoader)

Expand Down

0 comments on commit 97071ca

Please sign in to comment.