diff --git a/build.sbt b/build.sbt index 96b86d9..b9978b5 100644 --- a/build.sbt +++ b/build.sbt @@ -34,7 +34,7 @@ lazy val root = project name := "GUInep-root", publish / skip := true ) - .aggregate((guinep.projectRefs ++ swing.projectRefs ++ web.projectRefs): _*) + .aggregate((guinep.projectRefs ++ web.projectRefs): _*) lazy val guinep = projectMatrix .in(file("guinep")) @@ -54,14 +54,3 @@ lazy val web = projectMatrix ) .dependsOn(guinep) .jvmPlatform(scalaVersions = List(scala3)) - -lazy val swing = projectMatrix - .in(file("swing")) - .settings( - name := "GUInep-swing", - libraryDependencies ++= Seq( - "org.scala-lang.modules" %% "scala-swing" % "3.0.0" - ) - ) - .dependsOn(guinep) - .jvmPlatform(scalaVersions = List(scala3)) diff --git a/swing/src/main/scala/Main.scala b/swing/src/main/scala/Main.scala deleted file mode 100644 index 98c7f12..0000000 --- a/swing/src/main/scala/Main.scala +++ /dev/null @@ -1,19 +0,0 @@ -package guinep.testrun - -def personsAge(name: String): Int = name match { - case "Bartek" => 20 - case _ => 0 -} - -def upperCaseText(text: String): String = - text.toUpperCase - -def add(a: Int, b: Int) = - a + b - -def concat(a: String, b: String) = - a + b - -@main -def run: Unit = - guinep.swing(personsAge, upperCaseText, add, concat) diff --git a/swing/src/main/scala/api.scala b/swing/src/main/scala/api.scala deleted file mode 100644 index 51b39f4..0000000 --- a/swing/src/main/scala/api.scala +++ /dev/null @@ -1,11 +0,0 @@ -package guinep - -inline def swing(inline scripts: Any*): Unit = - val scriptInfos = internal.scriptInfos(scripts) - val scriptInfosMap = scriptInfos.groupBy(_.name) - if scriptInfosMap.exists(_._2.size > 1) then - println( - s"""|Duplicate script names found: ${scriptInfosMap.filter(_._2.size > 1).keys.mkString(", ")} - |Ignoring duplicates""".stripMargin - ) - internal.genSwing(scriptInfosMap.mapValues(_.head).toMap) diff --git a/swing/src/main/scala/gui.scala b/swing/src/main/scala/gui.scala deleted file mode 100644 index eb47843..0000000 --- a/swing/src/main/scala/gui.scala +++ /dev/null @@ -1,83 +0,0 @@ -package guinep.internal - -import scala.swing._ -import scala.swing.event._ -import java.awt.Color - -def genSwing(scripts: Map[String, Script]): Unit = { - Swing.onEDT(genSwingGo(scripts)) -} - -def genSwingGo(scripts: Map[String, Script]): Unit = { - // GUI Components - val scriptList = new ListView(scripts.keys.toList) - val mainPanel = new BoxPanel(Orientation.Vertical) - val runButton = new Button("Run") - val nameLabel = new Label("Choose a script") - var selectedScript = "" - - def updateMainPanel(scriptName: String): Unit = { - selectedScript = scriptName - mainPanel.contents.clear() - nameLabel.text = scriptName - val inputPanel = new BorderPanel { - layout(nameLabel) = BorderPanel.Position.North - layout(new BoxPanel(Orientation.Vertical) { - border = Swing.EmptyBorder(10, 10, 10, 10) - scripts.get(scriptName).foreach { script => - script.inputs.foreach { _ => - contents += new TextField { columns = 1 } - preferredSize = new Dimension(100, 1) - } - } - contents += Swing.VStrut(10) // Add vertical space - contents += runButton - }) = BorderPanel.Position.Center - } - mainPanel.contents += inputPanel - - // Add a filler panel to fill the remaining space - val filler = new BoxPanel(Orientation.Vertical) { - background = Color.WHITE - preferredSize = new Dimension(0, Int.MaxValue) - } - mainPanel.contents += filler - - - mainPanel.revalidate() - mainPanel.repaint() - } - - val frame = new MainFrame { - title = "GUInep" - contents = new BorderPanel { - layout(new ScrollPane(scriptList)) = BorderPanel.Position.West - layout(mainPanel) = BorderPanel.Position.Center - } - minimumSize = new Dimension(600, 450) - - // Handle script list selection - scriptList.selection.reactions += { - case ListSelectionChanged(_, _, _) => - updateMainPanel(scriptList.selection.items.headOption.getOrElse("")) - } - - def getAllFieldInputs(panel: Panel): List[String] = { - panel.contents.collect { - case panel: Panel => getAllFieldInputs(panel) - case textField: TextField => List(textField.text) - }.toList.flatten - } - - // Handle button click - runButton.reactions += { - case ButtonClicked(_) => - val inputs = getAllFieldInputs(mainPanel) - val result = scripts.get(selectedScript).map(_.run(inputs)).getOrElse("Script not found") - Dialog.showMessage(contents.head, result, "Result") - } - } - - frame.pack() - frame.visible = true -}