@@ -48,6 +48,7 @@ private const val PLACEHOLDER_HTML = """
4848 <body>
4949 <div class="spinner"></div>
5050 <h1>Starting BAML Playground…</h1>
51+ <p>You may need to open a BAML file if this does not load.</p>
5152 </body>
5253 </html>
5354"""
@@ -72,21 +73,21 @@ class BamlToolWindowFactory : ToolWindowFactory {
7273 addActionListener {
7374 val currentTime = java.time.LocalDateTime .now()
7475 val savedPort = project.getService(BamlGetPortService ::class .java).port
75- System . out . println (" reload button clicked at ${currentTime} , port is ${ savedPort} " )
76+ println (" playground reload at ${currentTime} , port is $savedPort " )
7677 if (savedPort != null ) {
7778 browser.loadURL(BamlIdeConfig .getPlaygroundUrl(savedPort))
7879 } else {
7980 browser.loadHTML(" <p>Port not ready</p>" )
8081 }
81- System . out . println (" finished loading " )
82+ println (" playground reload done " )
8283 }
8384 }
8485
8586 // Create lorem ipsum button
8687 val loremButton = JButton (" Lorem Ipsum" ).apply {
8788 addActionListener {
8889 val currentTime = java.time.LocalDateTime .now()
89- System . out . println (" lorem button clicked at ${currentTime} " )
90+ println (" lorem button clicked at ${currentTime} " )
9091 browser.loadHTML("""
9192 <!DOCTYPE html>
9293 <html>
@@ -144,47 +145,4 @@ class BamlToolWindowFactory : ToolWindowFactory {
144145 }
145146
146147 override fun shouldBeAvailable (project : Project ) = true
147-
148- class BamlToolWindow (toolWindow : ToolWindow ) {
149-
150- private val browser = JBCefBrowser ()
151-
152- init {
153- browser.loadHTML(
154- PLACEHOLDER_HTML .trimIndent()
155- )
156-
157- }
158-
159- fun getContent (): JPanel {
160- return JPanel (BorderLayout ()).apply {
161- add(browser.component, BorderLayout .CENTER )
162- }
163- }
164-
165- // This approach doesn't work.
166- // We need to follow instructions here and implement resource loaders
167- // https://plugins.jetbrains.com/docs/intellij/embedded-browser-jcef.html#loading-resources-from-plugin-distribution
168- private fun loadHtmlFromResources (): String {
169- // Load the HTML file from the `resources/web-panel/index.html`
170- val stylesUri = javaClass.getResource(" /web-panel/index.css" )!! .toURI()
171- val scriptUri = javaClass.getResource(" /web-panel/index.js" )!! .toURI()
172-
173- val htmlContent = """
174- <!DOCTYPE html>
175- <html lang="en">
176- <head>
177- <meta charset="UTF-8" />
178- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
179- <title>Hello World</title>
180- </head>
181- <body>
182- <div id="root">Waiting for react (unimplemented)</div>
183- </body>
184- </html>
185- """ .trimIndent()
186-
187- return htmlContent;
188- }
189- }
190148}
0 commit comments