Skip to content

Commit

Permalink
smaller fixes ide
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Dec 10, 2023
1 parent a0192be commit 906ccdb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 42 deletions.
3 changes: 3 additions & 0 deletions ide/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ dependencies {
implementation group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.5'
implementation 'org.kordamp.ikonli:ikonli-fontawesome5-pack:12.0.0'
implementation 'org.kordamp.ikonli:ikonli-javafx:12.0.0'

implementation 'org.jfxtras:jmetro:11.6.15'
implementation 'com.pixelduke:fxribbon:1.2.2'
}

repositories {
Expand Down
16 changes: 6 additions & 10 deletions ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object Editors {
fun getLanguageForFilename(file: File) = getEditorForSuffix(file.extension)
fun getEditorForSuffix(suffix: String): Language? =

Check notice on line 42 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Function 'getEditorForSuffix' could be private
when (suffix) {
".tt", ".gtt" -> TTLanguage
"tt", "gtt" -> TTLanguage
"st", "iec" -> StLanguage
"smv" -> SmvLanguage
"smt" -> SmtLanguage
Expand All @@ -51,7 +51,7 @@ object Editors {


open class Editor : View() {
override val root = CodeArea("")
final override val root = CodeArea("")
val dirtyProperty = SimpleBooleanProperty(this, "dirty", false)

Check notice on line 55 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Leaking 'this' in constructor

Leaking 'this' in constructor of non-final class Editor

Check notice on line 55 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'dirtyProperty' could be private
val dirty by dirtyProperty

Check warning on line 56 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "dirty" is never used
val filenameProperty = SimpleObjectProperty<File>(this, "filename", null)

Check notice on line 57 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/editor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Leaking 'this' in constructor

Leaking 'this' in constructor of non-final class Editor
Expand Down Expand Up @@ -153,7 +153,7 @@ open class Editor : View() {
val tok = lexer.nextToken()
if (tok.type == -1) break
val typ = language.getStyleClass(tok.type)// lexer.vocabulary.getSymbolicName(tok.type)
spansBuilder.add(Collections.singleton(typ), tok.text.length);
spansBuilder.add(Collections.singleton(typ), tok.text.length)
} while (tok.type != -1)
return spansBuilder.create()
}
Expand Down Expand Up @@ -199,7 +199,7 @@ object StLanguage : Language() {

override fun lexerFactory(input: CharStream): Lexer = IEC61131Lexer(input)
override fun parseFile(fromString: CharStream): List<Problem> {
val (pous, errors) = IEC61131Facade.fileResolve(fromString, true)
val (_, errors) = IEC61131Facade.fileResolve(fromString, true)
return errors
}

Expand All @@ -224,7 +224,7 @@ object StLanguage : Language() {
END_CONFIGURATION,
END_FUNCTION_BLOCK,
FUNCTION_BLOCK,
IEC61131Lexer.FUNCTION,
FUNCTION,
END_FUNCTION,
END_INTERFACE,
END_METHOD,
Expand Down Expand Up @@ -308,7 +308,7 @@ object TTLanguage : Language() {
override val name: String = "TestTables"

override fun lexerFactory(input: CharStream): Lexer = TestTableLanguageLexer(input)
override fun parseFile(fromString: CharStream): List<Problem>? {
override fun parseFile(fromString: CharStream): List<Problem> {
val p = GetetaFacade.createParser(fromString)
p.file()
return p.errorReporter.errors.map {
Expand Down Expand Up @@ -378,8 +378,4 @@ object SmtLanguage : Language() {
override val name: String = "SMT"
override fun lexerFactory(input: CharStream): Lexer = SmtLibv2Lexer(input)
override fun parseFile(fromString: CharStream): List<Problem>? = null
}

enum class StyleNames {

}
16 changes: 12 additions & 4 deletions ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/fx.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import javafx.scene.input.KeyCombination
import javafx.scene.paint.Color
import javafx.scene.text.FontWeight
import javafx.stage.FileChooser
import javafx.stage.Stage
import jfxtras.styles.jmetro.JMetro
import jfxtras.styles.jmetro.Style
import org.kordamp.ikonli.javafx.FontIcon
import org.kordamp.ikonli.javafx.IkonResolver
import tornadofx.*
Expand Down Expand Up @@ -116,11 +119,16 @@ class IdeStyle : Stylesheet() {


class IdeFx : App(IdeView::class, IdeStyle::class) {
//override val configBasePath = Paths.get("/etc/myapp/conf")

init {

Check notice on line 122 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/fx.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant empty initializer block

Redundant empty initializer block
reloadStylesheetsOnFocus()
dumpStylesheets()
//reloadStylesheetsOnFocus()
//dumpStylesheets()

}

override fun start(stage: Stage) {
super.start(stage)
val jMetro = JMetro(Style.LIGHT)
jMetro.scene = stage.scene
}
}

Expand Down
105 changes: 77 additions & 28 deletions ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ import javafx.collections.FXCollections
import javafx.collections.ObservableList
import javafx.event.ActionEvent
import javafx.event.EventHandler
import javafx.scene.Node
import javafx.scene.control.*
import javafx.scene.control.cell.TextFieldTreeCell
import javafx.scene.input.KeyCombination
import javafx.scene.paint.Color.*
import javafx.util.StringConverter
import org.kordamp.ikonli.Ikon

Check warning on line 14 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import org.kordamp.ikonli.Ikonli

Check warning on line 15 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon
import org.kordamp.ikonli.javafx.IkonResolver
import tornadofx.View
import tornadofx.contextmenu
import tornadofx.separator
import java.awt.Color

Check warning on line 22 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import java.awt.Desktop
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.extension
import kotlin.io.path.isDirectory
import kotlin.io.path.name
import tornadofx.item as titem

Expand All @@ -42,32 +50,36 @@ class FileNavigator(main: IdeView) : View("Navigator") {


val contextMenu: ContextMenu = contextmenu {

Check notice on line 52 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'contextMenu' could be private
item("tree-open-file", "ENTER", null) {
item("Open file", "ENTER", null) {
markFolderUnderMouse(it)
treeFile.selectionModel.selectedItem?.let {
main.open(it.value.toFile())

Check notice on line 56 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Nested lambda has shadowed implicit parameter

Implicit parameter 'it' of enclosing lambda is shadowed
}
}
item("refresh") {}
item("expand-tree") {
markFolderUnderMouse(it)
}
separator()
item("go-up") {

item("Open in explorer") {
markFolderUnderMouse(it)
(treeFile.root.value as? Path)?.let { file ->
treeFile.root = SimpleFileTreeItem(file.parent.toAbsolutePath())
treeFile.root.isExpanded = true
(treeFile.selectionModel.selectedItem)?.let { file ->
try {
Desktop.getDesktop()?.browseFileDirectory(file.value.toFile())
} catch (e: UnsupportedOperationException) {
ProcessBuilder("explorer", "/select,${file.value}").start()
}
}
}
item("go-into") {
item("System open") {
markFolderUnderMouse(it)
(treeFile.selectionModel.selectedItem)?.let { file ->
treeFile.root = SimpleFileTreeItem(file.value.toAbsolutePath())
treeFile.root.isExpanded = true
try {
Desktop.getDesktop()?.open(file.value.toFile())
} catch (e: UnsupportedOperationException) {
ProcessBuilder("explorer", "/select,${file.value}").start()
}
}
}

separator()

item("tree-new-file") {
markFolderUnderMouse(it)
treeFile.selectionModel.selectedItem?.let { item ->
Expand Down Expand Up @@ -110,29 +122,38 @@ class FileNavigator(main: IdeView) : View("Navigator") {
}
}
}
item("tree-rename-file") { }
item("tree-delete-file") {}
separator()
item("open-in-explorer") {


item("Refresh") {}

item("Expand Tree") {
markFolderUnderMouse(it)
(treeFile.selectionModel.selectedItem)?.let { file ->
try {
Desktop.getDesktop()?.browseFileDirectory(file.value.toFile())
} catch (e: UnsupportedOperationException) {
ProcessBuilder("explorer", "/select,${file.value}").start()
}
}

separator()

item("Go up") {
markFolderUnderMouse(it)
treeFile.root.value?.let { file ->
treeFile.root = SimpleFileTreeItem(file.parent.toAbsolutePath())
treeFile.root.isExpanded = true
}
}
item("xdg-open") {
item("Go into") {
markFolderUnderMouse(it)
(treeFile.selectionModel.selectedItem)?.let { file ->
try {
Desktop.getDesktop()?.open(file.value.toFile())
} catch (e: UnsupportedOperationException) {
ProcessBuilder("explorer", "/select,${file.value}").start()
}
treeFile.root = SimpleFileTreeItem(file.value.toAbsolutePath())
treeFile.root.isExpanded = true
}
}

separator()

item("Rename file") { }
item("Delete file") {}

separator()
}

fun refresh(): Unit {

Check notice on line 159 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Function 'refresh' could be private
Expand Down Expand Up @@ -175,6 +196,10 @@ class SimpleFileTreeItem(f: Path) : TreeItem<Path>(f) {
private var isFirstTimeLeaf = true
private var isLeaf = false

init {
graphic = NavigationIconFinder.find(f)
}

override fun getChildren(): ObservableList<TreeItem<Path>> {
if (isFirstTimeChildren) {
isFirstTimeChildren = false
Expand Down Expand Up @@ -204,3 +229,27 @@ class SimpleFileTreeItem(f: Path) : TreeItem<Path>(f) {
return FXCollections.emptyObservableList()
}
}

object NavigationIconFinder {
private val resolver = IkonResolver.getInstance()
private val DIRECTORY = FontAwesomeSolid.FOLDER
private val FILE = FontAwesomeSolid.FILE
private val FILE_CODE = FontAwesomeSolid.FILE_CODE

private fun get(ref: String): FontIcon? {

Check warning on line 239 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "get" is never used
return resolver.resolve(ref).resolve(ref)?.let { FontIcon(it) }!!
}

fun find(p: Path): Node? {

Check warning on line 243 in ide/src/main/kotlin/edu/kit/iti/formal/automation/fx/navigator.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant nullable return type

'find' always returns non-null type
if (p.isDirectory()) {
return FontIcon(DIRECTORY)
}

return when (p.extension) {
"gtt", "rtt", "st" -> FontIcon(FILE_CODE)
else -> FontIcon(FILE).also {
it.iconColor = LIGHTGREY
}
}
}
}

0 comments on commit 906ccdb

Please sign in to comment.