generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Rework tool window populating, fixing crash in some cases (Fixes #26) - Make loggers static
- Loading branch information
1 parent
2baddad
commit 7f1baaa
Showing
13 changed files
with
91 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
16 changes: 8 additions & 8 deletions
16
...in/kotlin/com/github/warningimhack3r/intellijshadcnplugin/listeners/ToolWindowListener.kt
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
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/ui/ISPPanelPopulator.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.github.warningimhack3r.intellijshadcnplugin.ui | ||
|
||
import com.github.warningimhack3r.intellijshadcnplugin.backend.SourceScanner | ||
import com.github.warningimhack3r.intellijshadcnplugin.backend.helpers.FileManager | ||
import com.intellij.openapi.application.runReadAction | ||
import com.intellij.openapi.diagnostic.logger | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.ui.components.JBLabel | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.SupervisorJob | ||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.future.asCompletableFuture | ||
import javax.swing.JComponent | ||
import javax.swing.SwingConstants | ||
|
||
class ISPPanelPopulator(private val project: Project) { | ||
companion object { | ||
private val log = logger<ISPPanelPopulator>() | ||
} | ||
|
||
fun populateToolWindowPanel(panel: JComponent) { | ||
log.info("Initializing tool window content") | ||
CoroutineScope(SupervisorJob() + Dispatchers.Default).async { | ||
return@async Pair(runReadAction { | ||
SourceScanner.findShadcnImplementation(project) | ||
}, runReadAction { | ||
FileManager(project).getVirtualFilesByName("package.json") | ||
}.size) | ||
}.asCompletableFuture().thenApplyAsync { (source, packageJsonCount) -> | ||
log.info("Shadcn implementation detected: $source, package.json count: $packageJsonCount") | ||
panel.removeAll() | ||
if (source == null) { | ||
panel.add(JBLabel("No shadcn/ui implementation detected.", SwingConstants.CENTER)) | ||
} else if (packageJsonCount > 1) { | ||
panel.add(JBLabel("Multiple projects detected, not supported yet.", SwingConstants.CENTER)) | ||
} else { | ||
panel.add(ISPWindowContents(source).panel()) | ||
} | ||
panel.revalidate() | ||
} | ||
log.info("Tool window content initialized") | ||
} | ||
} |
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
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