Skip to content

Commit

Permalink
Resolved merging conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorFilimonov committed Oct 8, 2024
2 parents ee54464 + 2235480 commit a719683
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class TestsController(val openedAutomaton: Automaton) : Controller() {
mode = mode,
owner = testsWindow.currentWindow,
initialFileName = openedAutomaton.name + "_tests"
).firstOrNull()
).firstOrNull()?.let { file ->
if (mode == FileChooserMode.Save && file.extension.isEmpty())
File(file.path + ".json")
else file
}

private fun defaultDirectory() = runCatching {
File("${System.getProperty("user.home")}/Documents/automaton-constructor").takeIf { it.isDirectory || it.mkdirs() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class HellingsAlgoController(
it.rightSide.size == 1 && it.rightSide[0] is Terminal && it.rightSide[0].getSymbol() == transition.propetiesText
}
productions.forEach {
val newHellingsTransition = HellingsTransition(it.leftSide, transition.source,
val newHellingsTransition = HellingsTransition(
it.leftSide, transition.source,
transition.target, SimpleBooleanProperty(false)
)
currentTransitions.add(newHellingsTransition)
Expand All @@ -52,7 +53,8 @@ class HellingsAlgoController(
}
if (grammar.productions.any { it.leftSide == grammar.initialNonterminal && it.rightSide.isEmpty() }) {
openedAutomaton.vertices.forEach {
val newHellingsTransition = HellingsTransition(grammar.initialNonterminal, it, it,
val newHellingsTransition = HellingsTransition(
grammar.initialNonterminal, it, it,
SimpleBooleanProperty(false)
)
currentTransitions.add(newHellingsTransition)
Expand All @@ -66,10 +68,12 @@ class HellingsAlgoController(
val allTransitions = observableListOf<HellingsTransition>()
prepareForExecution(currentTransitions, allTransitions)

val hellingsAlgoExecutionWindow = find<HellingsAlgoExecutionView>(mapOf(
HellingsAlgoExecutionView::currentTransitions to currentTransitions,
HellingsAlgoExecutionView::allTransitions to allTransitions
)).apply { title = I18N.messages.getString("HellingsAlgorithm.Execution.Title") }
val hellingsAlgoExecutionWindow = find<HellingsAlgoExecutionView>(
mapOf(
HellingsAlgoExecutionView::currentTransitions to currentTransitions,
HellingsAlgoExecutionView::allTransitions to allTransitions
)
).apply { title = I18N.messages.getString("HellingsAlgorithm.Execution.Title") }
hellingsAlgoExecutionWindow.openWindow()
find<CFGView>(mapOf(CFGView::grammar to grammar)).apply {
title = I18N.messages.getString("CFGView.Title")
Expand All @@ -82,4 +86,4 @@ class HellingsAlgoController(
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,100 +1,14 @@
package automaton.constructor.view

import automaton.constructor.model.element.AutomatonVertex
import automaton.constructor.model.element.BuildingBlock
import automaton.constructor.model.module.hasProblems
import automaton.constructor.model.module.hasProblemsBinding
import automaton.constructor.utils.I18N
import automaton.constructor.utils.Setting
import automaton.constructor.utils.SettingGroup
import javafx.beans.property.SimpleIntegerProperty
import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.CheckBox
import javafx.scene.control.TextField
import javafx.scene.paint.Color
import tornadofx.*

open class AutomatonBasicVertexView(val vertex: AutomatonVertex) : AutomatonElementView(vertex) {
val colourProperty = SimpleStringProperty("none")
private var colour by colourProperty
init {
hbox {
label {
textProperty().bind(vertex.nameProperty)
textFill = Color.BLACK
}
val startFinalCount = SimpleIntegerProperty(0)
if (vertex.isInitial) {
startFinalCount.set(1)
}
if (vertex.isFinal) {
startFinalCount.set(startFinalCount.value + 1)
}
val startFinalLabel = label {
if (startFinalCount.value == 1) {
if (vertex.isInitial) {
text = " (start)"
} else {
text = " (final)"
}
text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
}
if (startFinalCount.value == 2) {
text = " (start, final)"
}
textFill = Color.BLACK
isVisible = vertex.isInitial || vertex.isFinal
}
vertex.isInitialProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
vertex.isFinalProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
startFinalCount.addListener { _, _, newValue ->
when (newValue) {
0 -> startFinalLabel.isVisible = false
1 -> {
startFinalLabel.text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
startFinalLabel.isVisible = true
}
else -> {
startFinalLabel.text = " (start, final)"
startFinalLabel.isVisible = true
}
}
}
}
if (vertex is BuildingBlock) {
if (vertex.subAutomaton.hasProblems) {
colour = "red"
}
vertex.subAutomaton.hasProblemsBinding.addListener(ChangeListener { _, _, newValue ->
colour = if (newValue) {
"red"
} else {
"none"
}
})
}
}

override fun getSettings() = listOf(
SettingGroup(
I18N.messages.getString("StateView.State").toProperty(), listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package automaton.constructor.view

import automaton.constructor.model.element.AutomatonVertex
import automaton.constructor.model.element.BuildingBlock
import automaton.constructor.model.module.hasProblems
import automaton.constructor.model.module.hasProblemsBinding
import javafx.beans.property.SimpleIntegerProperty
import javafx.beans.property.SimpleStringProperty
import javafx.scene.paint.Color
import tornadofx.*

class AutomatonTableVertexView(vertex: AutomatonVertex): AutomatonBasicVertexView(vertex) {
val colourProperty = SimpleStringProperty("none")
private var colour by colourProperty
init {
hbox {
label {
textProperty().bind(vertex.nameProperty)
textFill = Color.BLACK
}
val startFinalCount = SimpleIntegerProperty(0)
if (vertex.isInitial) {
startFinalCount.set(1)
}
if (vertex.isFinal) {
startFinalCount.set(startFinalCount.value + 1)
}
val startFinalLabel = label {
if (startFinalCount.value == 1) {
if (vertex.isInitial) {
text = " (start)"
} else {
text = " (final)"
}
text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
}
if (startFinalCount.value == 2) {
text = " (start, final)"
}
textFill = Color.BLACK
isVisible = vertex.isInitial || vertex.isFinal
}
vertex.isInitialProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
vertex.isFinalProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
startFinalCount.addListener { _, _, newValue ->
when (newValue) {
0 -> startFinalLabel.isVisible = false
1 -> {
startFinalLabel.text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
startFinalLabel.isVisible = true
}
else -> {
startFinalLabel.text = " (start, final)"
startFinalLabel.isVisible = true
}
}
}
}
if (vertex is BuildingBlock) {
if (vertex.subAutomaton.hasProblems) {
colour = "red"
}
vertex.subAutomaton.hasProblemsBinding.addListener(ChangeListener { _, _, newValue ->
colour = if (newValue) {
"red"
} else {
"none"
}
})
}
}
}
10 changes: 3 additions & 7 deletions src/main/kotlin/automaton/constructor/view/AutomatonView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import tornadofx.*
// TODO extract AutomatonDescriptionProviderView and ProblemDetectorView
class AutomatonView(val automaton: Automaton, automatonViewContext: AutomatonViewContext) : Pane() {
val automatonGraphView = AutomatonGraphView(automaton, automatonViewContext)
val tablePrefWidth = SimpleDoubleProperty()
val tablePrefHeight = SimpleDoubleProperty()
private val tablePrefWidth = SimpleDoubleProperty().also { it.bind(this.widthProperty()) }
val tablePrefHeight = SimpleDoubleProperty().also { it.bind(this.heightProperty() - 48.0) }
private val automatonTransitionTableView = AutomatonTransitionTableView(
automaton, automatonViewContext, tablePrefWidth, tablePrefHeight)
private val automatonAdjacencyMatrixView = AutomatonAdjacencyMatrixView(
Expand Down Expand Up @@ -69,10 +69,6 @@ class AutomatonView(val automaton: Automaton, automatonViewContext: AutomatonVie
add(matrixPane)
}
selectionModel.selectedItemProperty().addListener { _, _, newValue ->
if (!tablePrefWidth.isBound && !tablePrefHeight.isBound) {
tablePrefWidth.bind(automatonViewContext.tablePrefWidthByContext)
tablePrefHeight.bind(automatonViewContext.tablePrefHeightByContext)
}
if (newValue == tableTab) {
automatonTransitionTableView.enableProperResizing()
}
Expand All @@ -93,7 +89,7 @@ class AutomatonView(val automaton: Automaton, automatonViewContext: AutomatonVie
})
editingDisabledProperty.bind(not(automaton.allowsModificationsByUserProperty))
visibleWhen(automaton.isOutputOfTransformationProperty.booleanBinding { it == null })
layoutY = 23.5
layoutY = 23.8
}
add(settingsEditor)
label {
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/automaton/constructor/view/MainWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class MainWindow(
fileController.onOpen()
}
item(I18N.messages.getString("MainView.Examples")).action {
find<ExamplesView>(mapOf(ExamplesView::fileController to fileController)).openModal()
find<ExamplesView>(mapOf(ExamplesView::fileController to fileController)).apply {
title = I18N.automatonExamples.getString("ExamplesFragment.Title")
}.openModal()
}
shortcutItem(I18N.messages.getString("MainView.File.Save"), "Shortcut+S") {
fileController.onSave()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ class HellingsRightSideCell(
}
padding = Insets(0.0, 3.0, 0.0, 0.0)
}
add(ComboBox<String>().apply {
add(ChoiceBox<String>().apply {
items = observableListOf(
I18N.messages.getString("HellingsAlgorithm.Grammar.Terminal"),
I18N.messages.getString("HellingsAlgorithm.Grammar.Nonterminal")
)
promptText = "+"
value = "+"
setOnAction {
val productionRightSide = productions[index].rightSide.value
if (value == items[0]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import automaton.constructor.model.element.Transition
import automaton.constructor.utils.I18N
import automaton.constructor.view.AdjacencyMatrixTransitionView
import automaton.constructor.view.AutomatonViewContext
import javafx.beans.property.SimpleDoubleProperty
import javafx.beans.property.ReadOnlyDoubleProperty
import javafx.beans.property.SimpleObjectProperty
import javafx.collections.ListChangeListener
import javafx.collections.SetChangeListener
Expand All @@ -20,7 +20,7 @@ class AdjacencyMatrixTransitionMap(

class AutomatonAdjacencyMatrixView(
automaton: Automaton, automatonViewContext: AutomatonViewContext,
tablePrefWidth: SimpleDoubleProperty, tablePrefHeight: SimpleDoubleProperty
tablePrefWidth: ReadOnlyDoubleProperty, tablePrefHeight: ReadOnlyDoubleProperty
): AutomatonTableView<AdjacencyMatrixTransitionView, AdjacencyMatrixTransitionMap>(
automaton, automatonViewContext, tablePrefWidth, tablePrefHeight
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import javafx.collections.MapChangeListener
import javafx.collections.SetChangeListener
import javafx.scene.layout.Pane
import tornadofx.add
import tornadofx.div
import tornadofx.fitToParentSize
import kotlin.collections.set

Expand Down Expand Up @@ -59,8 +58,7 @@ class AutomatonGraphView(val automaton: Automaton, private val automatonViewCont
maxHeight = this@AutomatonGraphView.scene.window.height / 1.5
val subAutomatonView = automatonViewContext.getAutomatonView(vertex.subAutomaton)
add(subAutomatonView)
subAutomatonView.tablePrefWidth.bind(automatonViewContext.tablePrefWidthByContext / 1.4)
subAutomatonView.tablePrefHeight.bind(automatonViewContext.tablePrefHeightByContext)
subAutomatonView.tablePrefHeight.bind(subAutomatonView.heightProperty())
subAutomatonView.fitToParentSize()
}
}
Expand Down
Loading

0 comments on commit a719683

Please sign in to comment.