Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Remove custom open window helper (#80)
Browse files Browse the repository at this point in the history
* Remove custom open

* Use tornado openWindow

* Fix tests
  • Loading branch information
andrewinci authored Oct 12, 2020
1 parent da078bf commit 3205eeb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 171 deletions.
18 changes: 1 addition & 17 deletions src/main/kotlin/insulator/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import insulator.views.style.ScrollBarStyle
import insulator.views.style.ScrollPaneStyle
import insulator.views.style.TableViewStyle
import insulator.views.style.TextStyle
import javafx.scene.Scene
import javafx.stage.Stage
import javafx.stage.Window
import tornadofx.* // ktlint-disable no-wildcard-imports

class Insulator : App(
Expand All @@ -33,20 +30,7 @@ class Insulator : App(
ScrollPaneStyle::class,
MainViewStyle::class,
ScrollBarStyle::class
) {

override fun createPrimaryScene(view: UIComponent): Scene {
FX.primaryStage.setOnCloseRequest { stop() }
return super.createPrimaryScene(view)
}

override fun stop() {
Window.getWindows().map { it as? Stage }
.filter { it != FX.primaryStage }
.forEach { it?.close() }
super.stop()
}
}
)

fun main(args: Array<String>) {
FX.dicontainer = DIContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import insulator.lib.helpers.map
import insulator.lib.kafka.AdminApi
import insulator.viewmodel.common.InsulatorViewModel
import insulator.views.common.StringScope
import insulator.views.common.customOpenWindow
import insulator.views.main.topic.CreateTopicView
import insulator.views.main.topic.TopicView
import javafx.beans.property.SimpleStringProperty
Expand Down Expand Up @@ -55,10 +54,8 @@ class ListTopicViewModel : InsulatorViewModel() {
.let { topicView -> setMainContent(selectedTopicName, topicView) }
}

fun createNewTopic() =
with(StringScope("CreateNewTopic").withComponent(CreateTopicViewModel())) {
find<CreateTopicView>(this).also {
it.whenUndockedOnce { refresh(); this.close() }
}.customOpenWindow(StageStyle.UTILITY, Modality.WINDOW_MODAL)
}
fun createNewTopic() = StringScope("CreateNewTopic")
.withComponent(CreateTopicViewModel())
.let { scope -> find<CreateTopicView>(scope).also { it.whenUndockedOnce { refresh(); scope.close() } } }
.openWindow(StageStyle.UTILITY, Modality.WINDOW_MODAL)
}
11 changes: 6 additions & 5 deletions src/main/kotlin/insulator/viewmodel/main/topic/TopicViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import insulator.lib.kafka.Consumer
import insulator.lib.kafka.DeserializationFormat
import insulator.viewmodel.common.InsulatorViewModel
import insulator.views.common.StringScope
import insulator.views.common.customOpenWindow
import insulator.views.main.topic.ProducerView
import javafx.beans.binding.Bindings
import javafx.beans.property.SimpleBooleanProperty
Expand All @@ -23,6 +22,8 @@ import javafx.beans.value.ObservableValue
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import javafx.scene.input.Clipboard
import javafx.stage.Modality
import javafx.stage.StageStyle
import tornadofx.* // ktlint-disable no-wildcard-imports
import java.util.LinkedList

Expand Down Expand Up @@ -122,10 +123,10 @@ class TopicViewModel(val topicName: String) : InsulatorViewModel() {
}
}

fun showProduceView() =
with(StringScope(topicName).withComponent(ProducerViewModel(topicName))) {
find<ProducerView>(this).customOpenWindow(owner = null)
}
fun showProduceView() = StringScope("producer-$topicName")
.withComponent(ProducerViewModel(topicName))
.let { find<ProducerView>(it) }
.openWindow(modality = Modality.WINDOW_MODAL, stageStyle = StageStyle.UTILITY)

fun configureFilteredRecords(comparator: ObservableValue<Comparator<RecordViewModel>>) {
filteredRecords.set(
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/insulator/views/common/Assets.kt

This file was deleted.

77 changes: 0 additions & 77 deletions src/main/kotlin/insulator/views/common/CustomOpenModal.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import insulator.lib.configuration.model.Cluster
import insulator.lib.update.VersionChecker
import insulator.viewmodel.configurations.ListClusterViewModel
import insulator.views.common.InsulatorView
import insulator.views.common.customOpenWindow
import insulator.views.component.action
import insulator.views.component.h1
import insulator.views.component.h2
Expand Down Expand Up @@ -55,7 +54,7 @@ class ListClusterView : InsulatorView<ListClusterViewModel>("Insulator", ListClu
if (wasVersionChecked.compareAndSet(false, true))
VersionChecker().getCurrentVersion().map {
if (it.latestRelease != null)
UpdateInfoView(it.latestRelease).customOpenWindow(modality = Modality.WINDOW_MODAL)
UpdateInfoView(it.latestRelease).openWindow(modality = Modality.WINDOW_MODAL)
}
}

Expand Down
62 changes: 0 additions & 62 deletions src/test/kotlin/insulator/InsulatorTest.kt

This file was deleted.

0 comments on commit 3205eeb

Please sign in to comment.