https://kotlinlang.org logo
#jewel
Title
# jewel
t

Tomasz Głąb

12/06/2023, 10:39 AM
Hi, Lamberto pointed that @seb @HIGAN can help me For the context, I am using jewel-ide-laf-bridge to reimplement the UI of our plugin in compose. Since my issues with importing, with Lamberto's help I managed to work with Jewel! Firstly, I don't know if it is intended that 1.0.0-SNAPSHOT-ij-233 is still published, current snapshot is 1.0.0-ij-233-SNAPSHOT version and at first I used the bad one. I made some progress and have some questions. I am still using the 1.00-ij-233-SNAPSHOT 1. Do you know what am I doing wrong, using even the demo code results with huge amount of warnings regarding colors:
Copy code
2023-11-30 16:06:42,627 [   2523]   WARN - #c.i.i.u.l.LafManagerImpl - VersionControl.Log.Commit.rowHeight = null in LookAndFeelThemeAdapter; it may lead to performance degradation
2023-11-30 16:06:42,873 [   2769]   WARN - #c.i.s.ComponentManagerImpl - com.intellij.psi.search.FilenameIndex initializer requests com.intellij.ide.plugins.PluginUtil instance
2023-11-30 16:06:45,510 [   5406]   WARN - #c.i.s.ComponentManagerImpl - com.intellij.psi.LanguageSubstitutors initializer requests com.intellij.psi.LanguageSubstitutors instance
2023-11-30 16:06:45,527 [   5423]   WARN - #c.i.s.ComponentManagerImpl - org.zmlx.hg4idea.provider.HgChangeProvider initializer requests com.intellij.openapi.vcs.FileStatusFactory instance
2023-11-30 16:07:05,836 [  25732]   WARN - JewelBridge - Color with key "*.focusColor" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,837 [  25733]   WARN - JewelBridge - Color with key "*.infoForeground" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,850 [  25746]   WARN - JewelBridge - Color with key "*.focusColor" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,850 [  25746]   WARN - JewelBridge - Color with key "*.infoForeground" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,861 [  25757]   WARN - JewelBridge - Color with key "MenuItem.disabledBackground" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,862 [  25758]   WARN - JewelBridge - Color with key "PopupMenu.disabledForeground" not found, fallback to 'Color.Unspecified'
2023-11-30 16:07:05,881 [  25777]   WARN - JewelBridge - Color with key "ProgressIcon.color" not found, fallback to 'Color.Unspecified'
2. Is there a way to render an icon using the one implementing the
javax.swing.Icon
interface? Icon class (in our case BspPluginIcons) loads them by:
Copy code
val bsp = IconLoader.getIcon("/icons/bsp.svg", BspPluginIcons::class.java)
Later in demo is showed that it can be used by providing the path once again like:
Copy code
Icon(resource = "icons/bsp.svg", iconClass = BspPluginIcons::class.java, contentDescription = null)
The question can be rewritten as: is there any way I can use the BspPluginIcons.bsp to render an icon with compose? 3. I needed to update the Style of the tree, here is how I did it:
Copy code
val iconFolderPainter = bridgePainterProvider("nodes/folder.svg")  // <- using bridgePainterProvider like this throws a warning
return LazyTreeStyle(
  colors = JewelTheme.Companion.treeStyle.colors,
  metrics = JewelTheme.Companion.treeStyle.metrics,
  icons = LazyTreeIcons(
    chevronCollapsed = iconFolderPainter,
    chevronExpanded = iconFolderPainter,
    chevronSelectedCollapsed = iconFolderPainter,
    chevronSelectedExpanded = iconFolderPainter,
  )
)
By that i get the warning:
Copy code
2023-12-06 11:14:41,821 [   8863] SEVERE - #c.i.u.SlowOperations - Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
	at com.intellij.util.SlowOperations.assertSlowOperationsAreAllowed(SlowOperations.java:101)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.ensureIsUpToDate(WorkspaceFileIndexDataImpl.kt:130)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexDataImpl.getFileInfo(WorkspaceFileIndexDataImpl.kt:75)
	at com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl.getFileInfo(WorkspaceFileIndexImpl.kt:247)
	at com.intellij.openapi.roots.impl.ProjectFileIndexImpl.isUnderIgnored(ProjectFileIndexImpl.java:73)
	at com.intellij.openapi.roots.impl.ProjectFileIndexFacade.isUnderIgnored(ProjectFileIndexFacade.java:71)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.isExcludedOrIgnored(FileManagerImpl.java:419)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.findDirectoryImpl(FileManagerImpl.java:405)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.findDirectory(FileManagerImpl.java:398)
	at com.intellij.psi.impl.PsiManagerImpl.findDirectory(PsiManagerImpl.java:175)
	at com.intellij.psi.AbstractFileViewProvider.shouldCreatePsi(AbstractFileViewProvider.java:89)
	at com.intellij.psi.SingleRootFileViewProvider.createFile(SingleRootFileViewProvider.java:144)
	at com.intellij.psi.SingleRootFileViewProvider.getPsiInner(SingleRootFileViewProvider.java:101)
	at com.intellij.psi.AbstractFileViewProvider.getPsi(AbstractFileViewProvider.java:185)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.areViewProvidersEquivalent(FileManagerImpl.java:535)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.shouldResurrect(FileManagerImpl.java:632)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.evaluateValidity(FileManagerImpl.java:600)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.findCachedViewProvider(FileManagerImpl.java:224)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.getCachedPsiFileInner(FileManagerImpl.java:461)
	at com.intellij.psi.impl.file.impl.FileManagerImpl.getCachedPsiFile(FileManagerImpl.java:377)
	at com.intellij.psi.impl.PsiDocumentManagerBase.getCachedPsiFile(PsiDocumentManagerBase.java:146)
	at com.intellij.psi.impl.PsiDocumentManagerBase.getCachedPsiFile(PsiDocumentManagerBase.java:128)
	at com.intellij.psi.impl.PsiDocumentManagerBase.getPsiFile(PsiDocumentManagerBase.java:91)
	at com.intellij.psi.impl.PsiDocumentManagerImpl.getPsiFile(PsiDocumentManagerImpl.java:63)
	at org.jetbrains.plugins.scala.worksheet.actions.WorksheetFileHook$WorksheetDumbModeListener.$anonfun$initializeButtons$1(WorksheetFileHook.scala:211)
	at org.jetbrains.plugins.scala.worksheet.actions.WorksheetFileHook$WorksheetDumbModeListener.$anonfun$initializeButtons$1$adapted(WorksheetFileHook.scala:210)
	at scala.Option.foreach(Option.scala:437)
	at org.jetbrains.plugins.scala.worksheet.actions.WorksheetFileHook$WorksheetDumbModeListener.initializeButtons(WorksheetFileHook.scala:210)
	at org.jetbrains.plugins.scala.worksheet.actions.WorksheetFileHook$WorksheetDumbModeListener.exitDumbMode(WorksheetFileHook.scala:206)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:697)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:664)
	at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423)
	at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402)
	at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
	at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461)
	at jdk.proxy2/jdk.proxy2.$Proxy63.exitDumbMode(Unknown Source)
	at com.intellij.openapi.project.DumbServiceImpl.publishDumbModeChangedEvent$lambda$7(DumbServiceImpl.kt:250)
	at com.intellij.openapi.project.DumbServiceImpl$Companion.runCatchingIgnorePCE(DumbServiceImpl.kt:578)
	at com.intellij.openapi.project.DumbServiceImpl$Companion.access$runCatchingIgnorePCE(DumbServiceImpl.kt:561)
	at com.intellij.openapi.project.DumbServiceImpl.publishDumbModeChangedEvent(DumbServiceImpl.kt:250)
	at com.intellij.openapi.project.DumbServiceImpl.access$publishDumbModeChangedEvent(DumbServiceImpl.kt:48)
	at com.intellij.openapi.project.DumbServiceImpl$decrementDumbCounter$3.invokeSuspend(DumbServiceImpl.kt:227)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at com.intellij.openapi.application.impl.DispatchedRunnable.run(DispatchedRunnable.kt:43)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
	at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
	at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:843)
	at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:463)
	at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:75)
	at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:67)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1430)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:124)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:44)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:695)
	at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$12(IdeEventQueue.kt:589)
	at com.intellij.openapi.application.impl.RwLockHolder.runWithoutImplicitRead(RwLockHolder.kt:44)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:72)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:355)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:354)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:793)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:354)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:349)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1014)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1014)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:349)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:848)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:391)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Am I doing something wrong, or reading the icon should be somehow optimised in the future?
h

HIGAN

12/06/2023, 10:57 AM
Hi! 1. Those warning happened with some unknown key in Laf, In theory
*.focusColor
must exist, maybe IJ's code breaks some compatibility, I will investigate it later. 2. I don't know what format
BspPluginIcons.bsp
is. If you are referring to
BspPluginIcons.java
, in the future we may provide a more convenient method to draw Icon in Bridge. For now, you can only draw icons by repeating the resource path in IconClass. 3. As far as I know, the time-consuming of creating a Style should be very low. Maybe you can print the time-consuming of this method. Another optimization I know of is that you can surround the
bridgePainterProvider
with
remember
.
💯 1
t

Tomasz Głąb

12/06/2023, 12:40 PM
Thanks! I will try the optimization with remember
3 Views