Created
December 9, 2022 10:42
-
-
Save dkandalov/c8a64a11933d3010406e74612cce3304 to your computer and use it in GitHub Desktop.
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
import com.intellij.ui.JBColor | |
import com.intellij.util.ui.JBUI | |
import liveplugin.allSuperClasses | |
import java.awt.Color | |
import java.util.function.Supplier | |
inline fun <reified T> Any.setField(name: String, value: T) { | |
val allFields = javaClass.allSuperClasses().flatMap { it.declaredFields.toList() } | |
val fieldClass = T::class.java | |
val field = allFields.find { it.name == name && (fieldClass.isAssignableFrom(it.type)) } | |
?: throw IllegalStateException("Didn't find field '${name}' (in class ${fieldClass.canonicalName})") | |
field.isAccessible = true | |
field.set(this, value) | |
} | |
(JBUI.CurrentTheme.RunWidget.BACKGROUND as JBColor).setField("func", Supplier { Color(55, 55, 55) }) | |
(JBUI.CurrentTheme.RunWidget.RUNNING_BACKGROUND as JBColor).setField("func", Supplier { Color(88, 88, 88) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment