Skip to content

Commit

Permalink
Rewrites examples to be a single project with more of the logic in co…
Browse files Browse the repository at this point in the history
…mmon layers, adds Desktop Compose example
  • Loading branch information
cjbrooks12 committed Apr 8, 2022
1 parent 78fa1e5 commit ca5729e
Show file tree
Hide file tree
Showing 169 changed files with 4,787 additions and 2,205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: 'Publish Artifacts'
run: './gradlew publishAllPublicationsToMavenCentralRepository --stacktrace -Prelease -PorchidEnvironment=prod'
- name: 'Build example Compose Web site'
run: './gradlew :examples:compose-web:build --stacktrace -Prelease -PorchidEnvironment=prod'
run: './gradlew :examples:build --stacktrace -Prelease -PorchidEnvironment=prod'
- name: 'Publish Documentation'
run: './gradlew :docs:publish --stacktrace -Prelease -PorchidEnvironment=prod'
- name: 'Close Sonatype Staging Repository'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ build/
*.iml
.DS_Store

examples/compose-web/src/jsMain/resources/bgg/hot/*
examples/src/jsMain/resources/bgg/hot/*
docs/src/orchid/resources/assets/example/distributions/**/*
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.15.1 - 2022-04-08

- Fix bug in IntelliJ plugin where settings were not being saved
- Removes "sample" from IntelliJ plugin, as that example and several more are available from the documentation site

## 0.15.0 - 2022-04-06

- Fix several bugs in Debugger UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public class BallastViewModelImpl<Inputs : Any, Events : Any, State : Any>(
coroutineScope: CoroutineScope,
getHost: () -> BallastViewModel<Inputs, Events, State>,
) {
check(!started) { "VM is already started" }
check(!cleared) { "VM is cleared, it cannot be restarted" }
check(!started) { "VM is already started" }
started = true
host = getHost
viewModelScope = coroutineScope + uncaughtExceptionHandler
Expand All @@ -170,8 +170,8 @@ public class BallastViewModelImpl<Inputs : Any, Events : Any, State : Any>(
}

private fun onCleared() {
check(started) { "VM is not started!" }
check(!cleared) { "VM is already cleared" }
check(started) { "VM is not started!" }
started = false
cleared = true

Expand All @@ -195,8 +195,8 @@ public class BallastViewModelImpl<Inputs : Any, Events : Any, State : Any>(
// ---------------------------------------------------------------------------------------------------------------------

private fun checkValidState() {
check(started) { "VM is not started!" }
check(!cleared) { "VM is cleared!" }
check(started) { "VM is not started!" }
}

private fun startInternal() {
Expand Down
202 changes: 0 additions & 202 deletions ballast-debugger-idea-plugin/api/ballast-debugger-idea-plugin.api

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ballast-debugger-idea-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ dependencies {
implementation(project(":ballast-core"))
implementation(project(":ballast-debugger"))
implementation(project(":ballast-saved-state"))
implementation(project(":examples:common"))
}

buildConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,14 @@ package com.copperleaf.ballast.debugger.di

import androidx.compose.runtime.compositionLocalOf
import com.copperleaf.ballast.BallastViewModelConfiguration
import com.copperleaf.ballast.InputStrategy
import com.copperleaf.ballast.core.LoggingInterceptor
import com.copperleaf.ballast.core.PrintlnLogger
import com.copperleaf.ballast.debugger.BallastDebuggerClientConnection
import com.copperleaf.ballast.debugger.BallastDebuggerInterceptor
import com.copperleaf.ballast.debugger.idea.BallastIdeaPlugin
import com.copperleaf.ballast.debugger.idea.settings.IdeaPluginPrefs
import com.copperleaf.ballast.debugger.idea.settings.InMemoryIdeaPluginPrefs
import com.copperleaf.ballast.debugger.idea.settings.IdeaPluginPrefsImpl
import com.copperleaf.ballast.debugger.ui.debugger.DebuggerEventHandler
import com.copperleaf.ballast.debugger.ui.debugger.DebuggerInputHandler
import com.copperleaf.ballast.debugger.ui.debugger.DebuggerSavedStateAdapter
import com.copperleaf.ballast.debugger.ui.debugger.DebuggerViewModel
import com.copperleaf.ballast.debugger.ui.kitchensink.KitchenSinkViewModel
import com.copperleaf.ballast.debugger.ui.samplecontroller.SampleControllerEventHandler
import com.copperleaf.ballast.debugger.ui.samplecontroller.SampleControllerInputHandler
import com.copperleaf.ballast.debugger.ui.samplecontroller.SampleControllerSavedStateAdapter
import com.copperleaf.ballast.debugger.ui.samplecontroller.SampleControllerViewModel
import com.copperleaf.ballast.plusAssign
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindowManager
import io.ktor.client.engine.cio.CIO
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob

val LocalInjector = compositionLocalOf<BallastDebuggerInjector> { error("LocalInjector not provided") }

Expand All @@ -36,15 +18,6 @@ interface BallastDebuggerInjector {
coroutineScope: CoroutineScope,
): DebuggerViewModel

fun sampleControllerViewModel(
coroutineScope: CoroutineScope,
): SampleControllerViewModel

fun kitchenSinkViewModel(
coroutineScope: CoroutineScope,
inputStrategy: InputStrategy,
): KitchenSinkViewModel

companion object {
private val injectors = mutableMapOf<Project, BallastDebuggerInjector>()

Expand All @@ -57,62 +30,16 @@ interface BallastDebuggerInjector {
class BallastDebuggerInjectorImpl(
private val project: Project,
) : BallastDebuggerInjector {
private val ideaPluginLogger: Logger = Logger.getInstance(BallastIdeaPlugin::class.java)
// private val prefs: IdeaPluginPrefs = IdeaPluginPrefsImpl(project)
private val prefs: IdeaPluginPrefs = InMemoryIdeaPluginPrefs
private val toolWindowManager: ToolWindowManager get() = ToolWindowManager.getInstance(project)
private val uncaughtExceptionHandler = CoroutineExceptionHandler { _, _ ->
// ignore
}
private val applicationScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default + uncaughtExceptionHandler)
private val debuggerConnection by lazy {
BallastDebuggerClientConnection(CIO, applicationScope).also { it.connect() }
}

private fun commonBuilder(): BallastViewModelConfiguration.Builder {
return BallastViewModelConfiguration.Builder()
.apply {
// logger = { IntellijPluginBallastLogger(ideaPluginLogger) }
logger = { PrintlnLogger(it) }
this += LoggingInterceptor()
}
}
private val prefs: IdeaPluginPrefs = IdeaPluginPrefsImpl(project)

override fun debuggerViewModel(coroutineScope: CoroutineScope): DebuggerViewModel {
return DebuggerViewModel(
coroutineScope = coroutineScope,
configurationBuilder = commonBuilder(),
configurationBuilder = BallastViewModelConfiguration.Builder(),
inputHandler = DebuggerInputHandler(),
eventHandler = DebuggerEventHandler(),
savedStateAdapter = DebuggerSavedStateAdapter(prefs)
)
}

override fun sampleControllerViewModel(coroutineScope: CoroutineScope): SampleControllerViewModel {
return SampleControllerViewModel(
coroutineScope = coroutineScope,
configurationBuilder = commonBuilder(),
inputHandler = SampleControllerInputHandler(this),
eventHandler = SampleControllerEventHandler(),
savedStateAdapter = SampleControllerSavedStateAdapter(prefs)
)
}

override fun kitchenSinkViewModel(
coroutineScope: CoroutineScope,
inputStrategy: InputStrategy,
): KitchenSinkViewModel {
return KitchenSinkViewModel(
viewModelCoroutineScope = coroutineScope,
configurationBuilder = commonBuilder()
.apply {
this.inputStrategy = inputStrategy
this += BallastDebuggerInterceptor(debuggerConnection)
},
onWindowClosed = {
toolWindowManager.getToolWindow("Ballast Sample")?.hide()
}
)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.copperleaf.ballast.debugger.idea.settings
import com.copperleaf.ballast.debugger.idea.settings.IdeaPluginPrefsImpl.Companion.CONNECTIONS_DEFAULT_VALUE
import com.copperleaf.ballast.debugger.idea.settings.IdeaPluginPrefsImpl.Companion.EVENTS_DEFAULT_VALUE
import com.copperleaf.ballast.debugger.idea.settings.IdeaPluginPrefsImpl.Companion.VIEW_MODELS_DEFAULT_VALUE
import com.copperleaf.ballast.debugger.ui.samplecontroller.InputStrategySelection
import com.copperleaf.ballast.debugger.ui.widgets.ViewModelContentTab
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.project.Project
Expand All @@ -20,15 +19,6 @@ interface IdeaPluginPrefs {
var viewModelsPanePercentage: Float
var eventsPanePercentage: Float
var selectedViewModelContentTab: ViewModelContentTab
var sampleInputStrategy: InputStrategySelection
}

object InMemoryIdeaPluginPrefs : IdeaPluginPrefs {
override var connectionsPanePercentage: Float = CONNECTIONS_DEFAULT_VALUE
override var viewModelsPanePercentage: Float = VIEW_MODELS_DEFAULT_VALUE
override var eventsPanePercentage: Float = EVENTS_DEFAULT_VALUE
override var selectedViewModelContentTab: ViewModelContentTab = ViewModelContentTab.Inputs
override var sampleInputStrategy: InputStrategySelection = InputStrategySelection.Lifo
}

class IdeaPluginPrefsImpl(
Expand Down Expand Up @@ -69,10 +59,4 @@ class IdeaPluginPrefsImpl(
?.let { storedValue -> runCatching { ViewModelContentTab.valueOf(storedValue) }.getOrNull() }
?: ViewModelContentTab.Inputs
set(value) { properties.setValue(SELECTED_VM_CONTENT_TAB_KEY, value.name) }

override var sampleInputStrategy: InputStrategySelection
get() = properties.getValue(SAMPLE_INPUT_STRATEGY_KEY)
?.let { storedValue -> runCatching { InputStrategySelection.valueOf(storedValue) }.getOrNull() }
?: InputStrategySelection.Lifo
set(value) { properties.setValue(SAMPLE_INPUT_STRATEGY_KEY, value.name) }
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ca5729e

Please sign in to comment.