├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── testing
├── commons
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── sample.png
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── hanggrian
│ │ │ └── ktfx
│ │ │ └── test
│ │ │ ├── SampleImage.kt
│ │ │ ├── SampleImageView.kt
│ │ │ └── DialogShowingTest.kt
│ └── build.gradle.kts
├── coroutines
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── sample.mp3
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── hanggrian
│ │ │ └── ktfx
│ │ │ └── test
│ │ │ ├── FakePickResult.kt
│ │ │ └── FakeEventTarget.kt
│ └── build.gradle.kts
├── core
│ ├── src
│ │ └── main
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── hanggrian
│ │ │ └── ktfx
│ │ │ └── test
│ │ │ ├── Toolkit.kt
│ │ │ └── Scene.kt
│ └── build.gradle.kts
└── layouts
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── kotlin
│ └── com
│ └── hanggrian
│ └── ktfx
│ └── test
│ └── LayoutsStyledTest.kt
├── .gitignore
├── ktfx-layouts
├── src
│ ├── main
│ │ └── kotlin
│ │ │ ├── KtfxLayoutDslMarker.kt
│ │ │ └── javafx
│ │ │ └── scene
│ │ │ ├── layout
│ │ │ └── KtfxPane.kt
│ │ │ ├── control
│ │ │ ├── KtfxToolBar.kt
│ │ │ ├── KtfxSplitPane.kt
│ │ │ ├── KtfxTab.kt
│ │ │ ├── KtfxScrollPane.kt
│ │ │ ├── KtfxTitledPane.kt
│ │ │ ├── KtfxAccordion.kt
│ │ │ ├── KtfxTabPane.kt
│ │ │ ├── KtfxMenuBar.kt
│ │ │ ├── KtfxContextMenu.kt
│ │ │ ├── KtfxButtonBar.kt
│ │ │ ├── KtfxMenu.kt
│ │ │ ├── KtfxSplitMenuButton.kt
│ │ │ └── KtfxMenuButton.kt
│ │ │ ├── KtfxGroup.kt
│ │ │ ├── shape
│ │ │ └── KtfxPath.kt
│ │ │ ├── KtfxSubScene.kt
│ │ │ ├── KtfxScene.kt
│ │ │ ├── text
│ │ │ └── KtfxTextFlow.kt
│ │ │ └── SubScene.kt
│ └── test
│ │ └── kotlin
│ │ └── javafx
│ │ └── scene
│ │ ├── shape
│ │ ├── ClosePathTest.kt
│ │ ├── LineTest.kt
│ │ ├── PathTest.kt
│ │ ├── SvgPathTest.kt
│ │ ├── HLineToTest.kt
│ │ ├── VLineToTest.kt
│ │ ├── LineToTest.kt
│ │ ├── MoveToTest.kt
│ │ ├── MeshViewTest.kt
│ │ ├── QuadCurveToTest.kt
│ │ ├── PolygonTest.kt
│ │ ├── PolylineTest.kt
│ │ ├── SphereTest.kt
│ │ ├── BoxTest.kt
│ │ ├── CylinderTest.kt
│ │ ├── CubicCurveToTest.kt
│ │ ├── EllipseTest.kt
│ │ ├── RectangleTest.kt
│ │ ├── CircleTest.kt
│ │ ├── ArcTest.kt
│ │ ├── ArcToTest.kt
│ │ ├── QuadCurveTest.kt
│ │ └── CubicCurveTest.kt
│ │ ├── SceneTest.kt
│ │ ├── layout
│ │ ├── PaneTest.kt
│ │ └── RegionTest.kt
│ │ ├── SubSceneTest.kt
│ │ ├── control
│ │ ├── ScrollBarTest.kt
│ │ ├── SeparatorTest.kt
│ │ ├── SpinnerTest.kt
│ │ ├── PasswordFieldTest.kt
│ │ ├── SeparatorMenuItemTest.kt
│ │ ├── LabelTest.kt
│ │ ├── TextAreaTest.kt
│ │ ├── CheckBoxTest.kt
│ │ ├── DatePickerTest.kt
│ │ ├── TextFieldTest.kt
│ │ ├── RadioButtonTest.kt
│ │ ├── MenuItemTest.kt
│ │ ├── ButtonTest.kt
│ │ ├── HyperlinkTest.kt
│ │ ├── TitledPaneTest2.kt
│ │ ├── TreeViewTest.kt
│ │ ├── MenuTest2.kt
│ │ ├── SliderTest.kt
│ │ ├── ProgressBarTest.kt
│ │ ├── ToggleButtonTest.kt
│ │ ├── ComboBoxTest.kt
│ │ ├── ListViewTest.kt
│ │ ├── CheckMenuItemTest.kt
│ │ ├── ChoiceBoxTest.kt
│ │ ├── ColorPickerTest.kt
│ │ ├── RadioMenuItemTest.kt
│ │ ├── TableViewTest.kt
│ │ ├── TreeTableViewTest.kt
│ │ ├── PaginationTest.kt
│ │ ├── ToolBarTest.kt
│ │ ├── CustomMenuItemTest.kt
│ │ ├── SplitPaneTest.kt
│ │ ├── ProgressIndicatorTest.kt
│ │ ├── MenuBarTest.kt
│ │ ├── TabTest.kt
│ │ ├── TabPaneTest.kt
│ │ ├── ScrollPaneTest.kt
│ │ ├── TitledPaneTest.kt
│ │ └── SplitMenuButtonTest.kt
│ │ ├── text
│ │ ├── TextTest.kt
│ │ └── TextFlowTest.kt
│ │ ├── web
│ │ └── WebViewTest.kt
│ │ ├── image
│ │ └── ImageViewTest.kt
│ │ ├── media
│ │ └── MediaViewTest.kt
│ │ ├── chart
│ │ └── PieChartTest.kt
│ │ ├── canvas
│ │ └── CanvasTest.kt
│ │ └── GroupTest.kt
└── build.gradle.kts
├── ktfx-commons
├── src
│ ├── main
│ │ └── kotlin
│ │ │ └── ktfx
│ │ │ ├── Callback.kt
│ │ │ ├── print
│ │ │ ├── PageRange.kt
│ │ │ └── Printer.kt
│ │ │ ├── internal
│ │ │ └── KtfxInternals.kt
│ │ │ ├── controls
│ │ │ ├── Scene.kt
│ │ │ ├── Node.kt
│ │ │ └── SwingUtils.kt
│ │ │ ├── cells
│ │ │ └── KtfxCell.kt
│ │ │ ├── inputs
│ │ │ ├── Clipboard.kt
│ │ │ ├── MouseEvent.kt
│ │ │ └── KeyCombination.kt
│ │ │ ├── dialogs
│ │ │ └── TextInputDialog.kt
│ │ │ ├── Application.kt
│ │ │ ├── collections
│ │ │ └── ObservableCollections.kt
│ │ │ └── Pair.kt
│ └── test
│ │ └── kotlin
│ │ └── ktfx
│ │ ├── print
│ │ ├── PageRangeTest.kt
│ │ └── PrinterTest.kt
│ │ ├── CallbackTest.kt
│ │ ├── text
│ │ └── FontTest.kt
│ │ ├── bindings
│ │ ├── ArrayBindingsIntegerTest.kt
│ │ └── ArrayBindingsFloatTest.kt
│ │ ├── PairTest.kt
│ │ ├── inputs
│ │ ├── ClipboardTest.kt
│ │ └── KeyCombinationTest.kt
│ │ └── controls
│ │ ├── GridConstraintsTest.kt
│ │ └── SwingUtilsTest.kt
└── build.gradle.kts
├── ktfx-all
└── build.gradle.kts
├── .circleci
└── config.yml
├── thirdparty
├── ktfx-jfoenix-all
│ └── build.gradle.kts
├── ktfx-controlsfx-all
│ └── build.gradle.kts
├── ktfx-jfoenix-layouts
│ ├── src
│ │ ├── main
│ │ │ └── kotlin
│ │ │ │ └── com
│ │ │ │ └── jfoenix
│ │ │ │ └── controls
│ │ │ │ ├── KtfxJfxDrawer.kt
│ │ │ │ ├── KtfxJfxRippler.kt
│ │ │ │ ├── KtfxJfxNodesList.kt
│ │ │ │ ├── KtfxJfxBadge.kt
│ │ │ │ ├── KtfxJfxClippedPane.kt
│ │ │ │ ├── KtfxJfxMasonryPane.kt
│ │ │ │ ├── KtfxJfxScrollPane.kt
│ │ │ │ ├── KtfxJfxTogglePane.kt
│ │ │ │ └── KtfxJfxTabPane.kt
│ │ └── test
│ │ │ └── kotlin
│ │ │ └── ktfx
│ │ │ └── jfoenix
│ │ │ └── layouts
│ │ │ ├── JfxHamburgerTest.kt
│ │ │ ├── JfxDrawersStackTest.kt
│ │ │ ├── JfxToggleButtonTest.kt
│ │ │ ├── JfxChipViewTest.kt
│ │ │ ├── JfxListCellTest.kt
│ │ │ ├── JfxListViewTest.kt
│ │ │ ├── JfxPasswordFieldTest.kt
│ │ │ ├── JfxTreeCellTest.kt
│ │ │ ├── JfxCheckBoxTest.kt
│ │ │ ├── JfxTextAreaTest.kt
│ │ │ ├── JfxButtonTest.kt
│ │ │ ├── JfxTextFieldTest.kt
│ │ │ ├── JfxTimePickerTest.kt
│ │ │ ├── JfxToggleNodeTest.kt
│ │ │ ├── JfxRadioButtonTest.kt
│ │ │ ├── JfxSpinnerTest.kt
│ │ │ ├── JfxTreeViewTest.kt
│ │ │ ├── JfxDatePickerTest.kt
│ │ │ ├── JfxSliderTest.kt
│ │ │ ├── JfxComboBoxTest.kt
│ │ │ ├── JfxColorPickerTest.kt
│ │ │ ├── JfxProgressBarTest.kt
│ │ │ ├── JfxBadgeTest.kt
│ │ │ ├── JfxDrawerTest.kt
│ │ │ ├── JfxRipplerTest.kt
│ │ │ ├── JfxNodesListTest.kt
│ │ │ ├── JfxTabPaneTest.kt
│ │ │ ├── JfxTreeViewPathTest.kt
│ │ │ ├── JfxTogglePaneTest.kt
│ │ │ ├── JfxClippedPaneTest.kt
│ │ │ ├── JfxMasonryPaneTest.kt
│ │ │ └── JfxTreeTableViewTest.kt
│ └── build.gradle.kts
├── ktfx-controlsfx-layouts
│ ├── src
│ │ ├── main
│ │ │ └── kotlin
│ │ │ │ └── org
│ │ │ │ └── controlsfx
│ │ │ │ └── control
│ │ │ │ ├── KtfxSnapshotView.kt
│ │ │ │ ├── KtfxNotificationPane.kt
│ │ │ │ ├── KtfxHiddenSidesPane.kt
│ │ │ │ ├── KtfxInfoOverlay.kt
│ │ │ │ └── KtfxMasterDetailPane.kt
│ │ └── test
│ │ │ └── kotlin
│ │ │ └── ktfx
│ │ │ └── controlsfx
│ │ │ └── layouts
│ │ │ ├── StatusBarTest.kt
│ │ │ ├── MaskerPaneTest.kt
│ │ │ ├── WorldMapViewTest.kt
│ │ │ ├── PlusMinusSliderTest.kt
│ │ │ ├── CustomTextFieldTest.kt
│ │ │ ├── CustomPasswordFieldTest.kt
│ │ │ ├── ListSelectionViewTest.kt
│ │ │ ├── SegmentedBarTest.kt
│ │ │ ├── RatingTest.kt
│ │ │ ├── PrefixSelectionComboBoxTest.kt
│ │ │ ├── TaskProgressViewTest.kt
│ │ │ ├── ToggleSwitchTest.kt
│ │ │ ├── PrefixSelectionChoiceBoxTest.kt
│ │ │ ├── HyperlinkLabelTest.kt
│ │ │ ├── PropertySheetTest.kt
│ │ │ ├── GridViewTest.kt
│ │ │ ├── CheckTreeViewTest.kt
│ │ │ ├── BreadCrumbBarTest.kt
│ │ │ ├── CheckComboBoxTest.kt
│ │ │ ├── CheckListViewTest.kt
│ │ │ ├── RangeSliderTest.kt
│ │ │ ├── SnapshotViewTest.kt
│ │ │ ├── HiddenSidesPaneTest.kt
│ │ │ ├── NotificationPaneTest.kt
│ │ │ └── SegmentedButtonTest.kt
│ └── build.gradle.kts
├── ktfx-controlsfx-commons
│ ├── src
│ │ ├── main
│ │ │ └── kotlin
│ │ │ │ └── ktfx
│ │ │ │ └── controlsfx
│ │ │ │ ├── Platform.kt
│ │ │ │ ├── dialogs
│ │ │ │ ├── ProgressDialog.kt
│ │ │ │ ├── ExceptionDialog.kt
│ │ │ │ └── FontSelector.kt
│ │ │ │ └── text
│ │ │ │ └── GlyphFont.kt
│ │ └── test
│ │ │ └── kotlin
│ │ │ └── ktfx
│ │ │ └── controlsfx
│ │ │ └── controls
│ │ │ └── TextFieldsTest.kt
│ └── build.gradle.kts
├── ktfx-jfoenix-commons
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ └── ktfx
│ │ └── jfoenix
│ │ ├── dialogs
│ │ ├── JfxDialog.kt
│ │ └── JfxAlert.kt
│ │ └── controls
│ │ └── JfxDepthManager.kt
├── ktfx-controlsfx-coroutines
│ ├── build.gradle.kts
│ └── src
│ │ └── test
│ │ └── kotlin
│ │ └── ktfx
│ │ └── controlsfx
│ │ └── coroutines
│ │ └── BreadCrumbBarTest.kt
└── ktfx-jfoenix-coroutines
│ ├── build.gradle.kts
│ └── src
│ └── test
│ └── kotlin
│ └── ktfx
│ └── jfoenix
│ └── coroutines
│ └── JfxAnimationTimerTest.kt
├── sample
└── build.gradle.kts
├── gradle.properties
├── ktfx-coroutines
├── build.gradle.kts
└── src
│ ├── test
│ └── kotlin
│ │ └── javafx
│ │ ├── scene
│ │ ├── media
│ │ │ ├── MediaViewTest.kt
│ │ │ └── MediaTest.kt
│ │ ├── control
│ │ │ ├── TextFieldTest.kt
│ │ │ ├── ContextMenuTest.kt
│ │ │ └── ButtonBaseTest.kt
│ │ └── transform
│ │ │ └── TransformTest.kt
│ │ ├── collections
│ │ ├── ObservableSetTest.kt
│ │ ├── ObservableMapTest.kt
│ │ └── ObservableArrayTest.kt
│ │ ├── beans
│ │ └── ObservableTest.kt
│ │ └── animation
│ │ └── AnimationTest.kt
│ └── main
│ └── kotlin
│ ├── ktfx
│ └── coroutines
│ │ ├── _Media.kt
│ │ ├── _PopupWindow.kt
│ │ ├── _TextField.kt
│ │ ├── _Animation.kt
│ │ └── _ButtonBase.kt
│ └── javafx
│ ├── collections
│ ├── ObservableSet.kt
│ ├── ObservableList.kt
│ └── ObservableMap.kt
│ ├── beans
│ └── Observable.kt
│ └── scene
│ └── control
│ └── MenuItem.kt
├── settings.gradle.kts
├── codegen
├── build.gradle.kts
└── src
│ └── main
│ └── kotlin
│ └── com
│ └── hanggrian
│ └── ktfx
│ └── codegen
│ └── Generator.kt
└── .editorconfig
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanggrian/ktfx/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/testing/commons/src/main/resources/sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanggrian/ktfx/HEAD/testing/commons/src/main/resources/sample.png
--------------------------------------------------------------------------------
/testing/coroutines/src/main/resources/sample.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanggrian/ktfx/HEAD/testing/coroutines/src/main/resources/sample.mp3
--------------------------------------------------------------------------------
/testing/commons/src/main/kotlin/com/hanggrian/ktfx/test/SampleImage.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.scene.image.Image
4 |
5 | class SampleImage : Image("/sample.png")
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # macOS
2 | .DS_Store
3 | ._*
4 |
5 | # Gradle
6 | .gradle/
7 | build/
8 | local.properties
9 |
10 | # IntelliJ
11 | *.iml
12 | .idea/
13 | out/
14 |
15 | # VSCode
16 | bin/
17 |
--------------------------------------------------------------------------------
/testing/core/src/main/kotlin/com/hanggrian/ktfx/test/Toolkit.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import com.sun.javafx.application.PlatformImpl
4 |
5 | fun initToolkit() = PlatformImpl.startup {}
6 |
--------------------------------------------------------------------------------
/testing/commons/src/main/kotlin/com/hanggrian/ktfx/test/SampleImageView.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.scene.image.ImageView
4 |
5 | class SampleImageView : ImageView("sample.png")
6 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/KtfxLayoutDslMarker.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | /** Delimits dynamic-layouts DSL. */
4 | @DslMarker
5 | @Target(AnnotationTarget.TYPE)
6 | public annotation class KtfxLayoutDslMarker
7 |
--------------------------------------------------------------------------------
/testing/coroutines/src/main/kotlin/com/hanggrian/ktfx/test/FakePickResult.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.scene.input.PickResult
4 |
5 | object FakePickResult : PickResult(FakeEventTarget, 0.0, 0.0)
6 |
--------------------------------------------------------------------------------
/testing/commons/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm")
4 | alias(libs.plugins.ktlint)
5 | }
6 |
7 | javafx.modules("javafx.controls")
8 |
9 | dependencies.api(project(":testing:core"))
10 |
--------------------------------------------------------------------------------
/testing/layouts/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm")
4 | alias(libs.plugins.ktlint)
5 | }
6 |
7 | javafx.modules("javafx.controls")
8 |
9 | dependencies.api(project(":testing:core"))
10 |
--------------------------------------------------------------------------------
/testing/coroutines/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm")
4 | alias(libs.plugins.ktlint)
5 | }
6 |
7 | javafx.modules("javafx.controls", "javafx.web")
8 |
9 | dependencies.api(project(":testing:core"))
10 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/Callback.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("NOTHING_TO_INLINE")
2 |
3 | package ktfx
4 |
5 | import javafx.util.Callback
6 |
7 | /** Converts the object provided into its string form. */
8 | public inline operator fun
Callback
.invoke(obj: P): R = call(obj)
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/print/PageRangeTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.print
2 |
3 | import kotlin.test.Test
4 | import kotlin.test.assertEquals
5 |
6 | class PageRangeTest {
7 | @Test
8 | fun untilPage() {
9 | val range = 1 untilPage 3
10 | assertEquals(1, range.startPage)
11 | assertEquals(3, range.endPage)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/print/PageRange.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("NOTHING_TO_INLINE")
2 |
3 | package ktfx.print
4 |
5 | import javafx.print.PageRange
6 |
7 | /**
8 | * Create a [PageRange] ranging from [this] to [endPage].
9 | *
10 | * @see kotlin.ranges.until
11 | */
12 | public inline infix fun Int.untilPage(endPage: Int): PageRange = PageRange(this, endPage)
13 |
--------------------------------------------------------------------------------
/testing/coroutines/src/main/kotlin/com/hanggrian/ktfx/test/FakeEventTarget.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.event.EventDispatchChain
4 | import javafx.event.EventTarget
5 |
6 | object FakeEventTarget : EventTarget {
7 | override fun buildEventDispatchChain(tail: EventDispatchChain) =
8 | throw UnsupportedOperationException()
9 | }
10 |
--------------------------------------------------------------------------------
/testing/core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm")
4 | alias(libs.plugins.ktlint)
5 | }
6 |
7 | javafx.modules("javafx.controls")
8 |
9 | dependencies {
10 | api(kotlin("test-junit", libs.versions.kotlin.get()))
11 | api(libs.kotlinx.coroutines.javafx)
12 | api(libs.truth)
13 | api(libs.bundles.testfx)
14 | }
15 |
--------------------------------------------------------------------------------
/ktfx-all/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | kotlin("jvm") version libs.versions.kotlin
5 | alias(libs.plugins.dokka)
6 | alias(libs.plugins.maven.publish)
7 | }
8 |
9 | dependencies {
10 | api(project(":$releaseArtifact-commons"))
11 | api(project(":$releaseArtifact-layouts"))
12 | api(project(":$releaseArtifact-coroutines"))
13 | }
14 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/CallbackTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx
2 |
3 | import javafx.util.Callback
4 | import javafx.util.Duration
5 | import ktfx.time.m
6 | import kotlin.test.Test
7 | import kotlin.test.assertEquals
8 |
9 | class CallbackTest {
10 | @Test
11 | fun invoke() {
12 | val callback = Callback { it.m }
13 | assertEquals(callback.call(1), callback(1))
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | codecov: codecov/codecov@3
5 |
6 | executors:
7 | linux:
8 | docker:
9 | - image: cimg/openjdk:21.0-browsers
10 |
11 | jobs:
12 | upload-coverage:
13 | executor: linux
14 | steps:
15 | - checkout
16 | - run: ./gradlew check koverXmlReport
17 | - codecov/upload
18 |
19 | workflows:
20 | build:
21 | jobs:
22 | - upload-coverage
23 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/internal/KtfxInternals.kt:
--------------------------------------------------------------------------------
1 | package ktfx.internal
2 |
3 | /** Ktfx internal class, ignore it. */
4 | public object KtfxInternals {
5 | /** No getter error message. */
6 | public const val NO_GETTER: String = "Property does not have a getter."
7 |
8 | /** Some mutable backing fields are only used to set value. */
9 | public fun noGetter(): Nothing = throw UnsupportedOperationException(NO_GETTER)
10 | }
11 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/ClosePathTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.ClosePath
5 |
6 | class ClosePathTest : LayoutsTest() {
7 | override fun manager() = KtfxPath()
8 |
9 | override fun KtfxPath.childCount() = elements.size
10 |
11 | override fun child1() = closePath {}
12 |
13 | override fun KtfxPath.child2() = closePath()
14 | }
15 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-all/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | kotlin("jvm") version libs.versions.kotlin
5 | alias(libs.plugins.dokka)
6 | alias(libs.plugins.maven.publish)
7 | }
8 |
9 | dependencies {
10 | api(project(":thirdparty:$releaseArtifact-jfoenix-commons"))
11 | api(project(":thirdparty:$releaseArtifact-jfoenix-layouts"))
12 | api(project(":thirdparty:$releaseArtifact-jfoenix-coroutines"))
13 | }
14 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-all/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | kotlin("jvm") version libs.versions.kotlin
5 | alias(libs.plugins.dokka)
6 | alias(libs.plugins.maven.publish)
7 | }
8 |
9 | dependencies {
10 | api(project(":thirdparty:$releaseArtifact-controlsfx-commons"))
11 | api(project(":thirdparty:$releaseArtifact-controlsfx-layouts"))
12 | api(project(":thirdparty:$releaseArtifact-controlsfx-coroutines"))
13 | }
14 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/layout/KtfxPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.layout.Pane
8 |
9 | /**
10 | * [Pane] with dynamic-layout dsl support.
11 | * Invoking dsl will add its children.
12 | */
13 | public open class KtfxPane :
14 | Pane(),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { children += it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-commons/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm") version libs.versions.kotlin
4 | alias(libs.plugins.dokka)
5 | alias(libs.plugins.kotlinx.kover)
6 | alias(libs.plugins.ktlint)
7 | alias(libs.plugins.maven.publish)
8 | }
9 |
10 | javafx.modules("javafx.controls", "javafx.swing")
11 |
12 | kotlin.explicitApi()
13 |
14 | dependencies {
15 | ktlintRuleset(libs.rulebook.ktlint)
16 |
17 | testImplementation(project(":testing:commons"))
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxToolBar.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.ToolBar
8 |
9 | /**
10 | * [ToolBar] with dynamic-layout dsl support.
11 | * Invoking dsl will add its children.
12 | */
13 | public open class KtfxToolBar :
14 | ToolBar(),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { items += it }
17 | }
18 |
--------------------------------------------------------------------------------
/sample/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | application
6 | kotlin("jvm")
7 | }
8 |
9 | javafx.modules("javafx.controls")
10 |
11 | application.mainClass.set("com.example.CalculatorApp")
12 |
13 | dependencies {
14 | implementation(project(":$releaseArtifact-all"))
15 | implementation(project(":thirdparty:$releaseArtifact-controlsfx-all"))
16 | implementation(project(":thirdparty:$releaseArtifact-jfoenix-all"))
17 | }
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | developerId=hanggrian
2 | developerName=Hendra Anggrian
3 | developerUrl=https://github.com/hanggrian/
4 | releaseGroup=com.hanggrian.ktfx
5 | releaseArtifact=ktfx
6 | releaseVersion=0.3
7 | releaseDescription=Kotlin extensions for JavaFX app development
8 | releaseUrl=https://github.com/hanggrian/ktfx/
9 |
10 | org.gradle.parallel=true
11 | org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
12 |
13 | kotlin.code.style=official
14 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
15 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/KtfxGroup.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Group
7 | import javafx.scene.Node
8 | import javafx.scene.Scene
9 |
10 | /**
11 | * [Scene] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxGroup :
15 | Group(),
16 | NodeContainer {
17 | final override fun addChild(child: T): T = child.also { children += it }
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxSplitPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.SplitPane
8 |
9 | /**
10 | * [SplitPane] with dynamic-layout dsl support.
11 | * Invoking dsl will add its children.
12 | */
13 | public open class KtfxSplitPane :
14 | SplitPane(),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { items += it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/shape/KtfxPath.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.shape.Path
7 | import javafx.scene.shape.PathElement
8 |
9 | /**
10 | * [Path] with dynamic-layout dsl support.
11 | * Invoking dsl will add its children.
12 | */
13 | public open class KtfxPath :
14 | Path(),
15 | PathElementContainer {
16 | final override fun addChild(child: T): T = child.also { elements += it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/controls/Scene.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("NOTHING_TO_INLINE")
2 |
3 | package ktfx.controls
4 |
5 | import javafx.scene.Node
6 | import javafx.scene.Scene
7 | import javafx.scene.image.WritableImage
8 |
9 | /** Alias of [Scene.lookup] with non-null return and specified type. */
10 | public inline fun Scene.find(selector: String): T = lookup(selector) as T
11 |
12 | /** Take a snapshot of this [Node] returning image it wrote. */
13 | public inline fun Scene.capture(): WritableImage = snapshot(null)
14 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxTab.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.Tab
8 |
9 | /**
10 | * [Tab] with dynamic-layout dsl support.
11 | * Invoking dsl will only set its content.
12 | */
13 | public open class KtfxTab(title: String?, content: Node?) :
14 | Tab(title, content),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { content = it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxScrollPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.ScrollPane
8 |
9 | /**
10 | * [ScrollPane] with dynamic-layout dsl support.
11 | * Invoking dsl will only set its content.
12 | */
13 | public open class KtfxScrollPane(content: Node?) :
14 | ScrollPane(content),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { content = it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/SceneTest.kt:
--------------------------------------------------------------------------------
1 | package javafx.scene
2 |
3 | import com.hanggrian.ktfx.test.initToolkit
4 | import javafx.scene.layout.Region
5 | import ktfx.layouts.region
6 | import ktfx.layouts.scene
7 | import kotlin.test.BeforeTest
8 | import kotlin.test.Test
9 | import kotlin.test.assertIs
10 |
11 | class SceneTest {
12 | @BeforeTest
13 | fun start() = initToolkit()
14 |
15 | @Test
16 | fun add() {
17 | scene {
18 | region()
19 | assertIs(root)
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/layout/PaneTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.layout.Pane
5 |
6 | class PaneTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = pane {}
12 |
13 | override fun KtfxPane.child2() = pane()
14 |
15 | override fun child3() = styledPane()
16 |
17 | override fun KtfxPane.child4() = styledPane()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/LineTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Line
5 |
6 | class LineTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = line {}
12 |
13 | override fun KtfxPane.child2() = line()
14 |
15 | override fun child3() = styledLine()
16 |
17 | override fun KtfxPane.child4() = styledLine()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/PathTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Path
5 |
6 | class PathTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = path {}
12 |
13 | override fun KtfxPane.child2() = path()
14 |
15 | override fun child3() = styledPath()
16 |
17 | override fun KtfxPane.child4() = styledPath()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxTitledPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.TitledPane
8 |
9 | /**
10 | * [TitledPane] with dynamic-layout dsl support.
11 | * Invoking dsl will only set its content.
12 | */
13 | public open class KtfxTitledPane(title: String?) :
14 | TitledPane(title, null),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { content = it }
17 | }
18 |
--------------------------------------------------------------------------------
/ktfx-coroutines/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm") version libs.versions.kotlin
4 | alias(libs.plugins.dokka)
5 | alias(libs.plugins.kotlinx.kover)
6 | alias(libs.plugins.ktlint)
7 | alias(libs.plugins.maven.publish)
8 | }
9 |
10 | javafx.modules("javafx.controls", "javafx.web")
11 |
12 | kotlin.explicitApi()
13 |
14 | dependencies {
15 | ktlintRuleset(libs.rulebook.ktlint)
16 |
17 | implementation(libs.kotlinx.coroutines.javafx)
18 |
19 | testImplementation(project(":testing:coroutines"))
20 | }
21 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/SubSceneTest.kt:
--------------------------------------------------------------------------------
1 | package javafx.scene
2 |
3 | import com.hanggrian.ktfx.test.initToolkit
4 | import javafx.scene.layout.Region
5 | import ktfx.layouts.region
6 | import ktfx.layouts.subScene
7 | import kotlin.test.BeforeTest
8 | import kotlin.test.Test
9 | import kotlin.test.assertIs
10 |
11 | class SubSceneTest {
12 | @BeforeTest
13 | fun start() = initToolkit()
14 |
15 | @Test
16 | fun add() {
17 | subScene {
18 | region()
19 | assertIs(root)
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxDrawer.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXDrawer
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXDrawer] with dynamic-layout dsl support. Invoking dsl will add its children. */
11 | public open class KtfxJfxDrawer :
12 | JFXDrawer(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { content += it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/layout/RegionTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.layout.Region
5 |
6 | class RegionTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = region {}
12 |
13 | override fun KtfxPane.child2() = region()
14 |
15 | override fun child3() = styledRegion()
16 |
17 | override fun KtfxPane.child4() = styledRegion()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/SvgPathTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.SVGPath
5 |
6 | class SvgPathTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = svgPath {}
12 |
13 | override fun KtfxPane.child2() = svgPath()
14 |
15 | override fun child3() = styledSvgPath()
16 |
17 | override fun KtfxPane.child4() = styledSvgPath()
18 | }
19 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxRippler.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXRippler
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXRippler] with dynamic-layout dsl support. Invoking dsl will only set its children. */
11 | public open class KtfxJfxRippler :
12 | JFXRippler(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { control = it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/cells/KtfxCell.kt:
--------------------------------------------------------------------------------
1 | package ktfx.cells
2 |
3 | /** Defines a lifecycle of custom cell/row. */
4 | internal interface KtfxCell {
5 | /** Called when cell is on editing mode. */
6 | fun onEditStart(action: () -> Unit)
7 |
8 | /** Called when cell edit is being committed. */
9 | fun onEditCommit(action: (T?) -> Unit)
10 |
11 | /** Called when cell edit is canceled. */
12 | fun onEditCancel(action: () -> Unit)
13 |
14 | /** Called when cell item is updating. */
15 | fun onUpdate(action: (T?, empty: Boolean) -> Unit)
16 | }
17 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxNodesList.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXNodesList
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXNodesList] with dynamic-layout dsl support. Invoking dsl will add its children. */
11 | public open class KtfxJfxNodesList :
12 | JFXNodesList(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { children += it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/HLineToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.HLineTo
5 | import kotlin.test.assertEquals
6 |
7 | class HLineToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = hlineTo {}
13 |
14 | override fun KtfxPath.child2() = hlineTo()
15 |
16 | override fun HLineTo.testDefaultValues() {
17 | assertEquals(0.0, x)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/VLineToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.VLineTo
5 | import kotlin.test.assertEquals
6 |
7 | class VLineToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = vlineTo {}
13 |
14 | override fun KtfxPath.child2() = vlineTo()
15 |
16 | override fun VLineTo.testDefaultValues() {
17 | assertEquals(0.0, y)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxBadge.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXBadge
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /**
11 | * [JFXBadge] with dynamic-layout dsl support.
12 | * Invoking dsl will only set its control.
13 | */
14 | public open class KtfxJfxBadge :
15 | JFXBadge(),
16 | NodeContainer {
17 | final override fun addChild(child: T): T = child.also { control = it }
18 | }
19 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxClippedPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXClippedPane
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXClippedPane] with dynamic-layout dsl support. Invoking dsl will add its children. */
11 | public open class KtfxJfxClippedPane :
12 | JFXClippedPane(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { children += it }
15 | }
16 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxMasonryPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXMasonryPane
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXMasonryPane] with dynamic-layout dsl support. Invoking dsl will add its children. */
11 | public open class KtfxJfxMasonryPane :
12 | JFXMasonryPane(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { children += it }
15 | }
16 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxScrollPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXScrollPane
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXScrollPane] with dynamic-layout dsl support. Invoking dsl will only set its content. */
11 | public open class KtfxJfxScrollPane :
12 | JFXScrollPane(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { content = it }
15 | }
16 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/main/kotlin/com/jfoenix/controls/KtfxJfxTogglePane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("JfoenixLayoutsKt")
3 |
4 | package ktfx.jfoenix.layouts
5 |
6 | import com.jfoenix.controls.JFXTogglePane
7 | import javafx.scene.Node
8 | import ktfx.layouts.NodeContainer
9 |
10 | /** [JFXTogglePane] with dynamic-layout dsl support. Invoking dsl will only set its content. */
11 | public open class KtfxJfxTogglePane :
12 | JFXTogglePane(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { contentNode = it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ScrollBarTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ScrollBar
5 |
6 | class ScrollBarTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = scrollBar {}
12 |
13 | override fun KtfxPane.child2() = scrollBar()
14 |
15 | override fun child3() = styledScrollBar()
16 |
17 | override fun KtfxPane.child4() = styledScrollBar()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/SeparatorTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Separator
5 |
6 | class SeparatorTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = separator {}
12 |
13 | override fun KtfxPane.child2() = separator()
14 |
15 | override fun child3() = styledSeparator()
16 |
17 | override fun KtfxPane.child4() = styledSeparator()
18 | }
19 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/main/kotlin/org/controlsfx/control/KtfxSnapshotView.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("ControlsfxLayoutsKt")
3 |
4 | package ktfx.controlsfx.layouts
5 |
6 | import javafx.scene.Node
7 | import ktfx.layouts.NodeContainer
8 | import org.controlsfx.control.SnapshotView
9 |
10 | /** [SnapshotView] with dynamic-layout dsl support. Invoking dsl will only set its node. */
11 | public open class KtfxSnapshotView :
12 | SnapshotView(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { this.node = it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-layouts/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.javafx)
3 | kotlin("jvm") version libs.versions.kotlin
4 | alias(libs.plugins.dokka)
5 | alias(libs.plugins.kotlinx.kover)
6 | alias(libs.plugins.ktlint)
7 | alias(libs.plugins.maven.publish)
8 | }
9 |
10 | javafx.modules("javafx.controls", "javafx.web")
11 |
12 | kotlin.explicitApi()
13 |
14 | dependencies {
15 | ktlintRuleset(libs.rulebook.ktlint)
16 |
17 | testImplementation(project(":testing:layouts"))
18 | testImplementation(project(":ktfx-commons"))
19 | testImplementation(libs.commons.lang3)
20 | }
21 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-commons/src/main/kotlin/ktfx/controlsfx/Platform.kt:
--------------------------------------------------------------------------------
1 | @file:JvmName("ControlsfxPlatformKt")
2 |
3 | package ktfx.controlsfx
4 |
5 | import org.controlsfx.tools.Platform
6 |
7 | /** Returns true if this is running on Windows. */
8 | public fun isPlatformWindows(): Boolean = Platform.getCurrent() == Platform.WINDOWS
9 |
10 | /** Returns true if this is running on OSX. */
11 | public fun isPlatformOsx(): Boolean = Platform.getCurrent() == Platform.OSX
12 |
13 | /** Returns true if this is running on Unix. */
14 | public fun isPlatformUnix(): Boolean = Platform.getCurrent() == Platform.UNIX
15 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/LineToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.LineTo
5 | import kotlin.test.assertEquals
6 |
7 | class LineToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = lineTo {}
13 |
14 | override fun KtfxPath.child2() = lineTo()
15 |
16 | override fun LineTo.testDefaultValues() {
17 | assertEquals(0.0, x)
18 | assertEquals(0.0, y)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/MoveToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.MoveTo
5 | import kotlin.test.assertEquals
6 |
7 | class MoveToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = moveTo {}
13 |
14 | override fun KtfxPath.child2() = moveTo()
15 |
16 | override fun MoveTo.testDefaultValues() {
17 | assertEquals(0.0, x)
18 | assertEquals(0.0, y)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/main/kotlin/org/controlsfx/control/KtfxNotificationPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("ControlsfxLayoutsKt")
3 |
4 | package ktfx.controlsfx.layouts
5 |
6 | import javafx.scene.Node
7 | import ktfx.layouts.NodeContainer
8 | import org.controlsfx.control.NotificationPane
9 |
10 | /** [NotificationPane] with dynamic-layout dsl support. Invoking dsl will only set its content. */
11 | public open class KtfxNotificationPane :
12 | NotificationPane(),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { content = it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/SpinnerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Spinner
5 |
6 | class SpinnerTest : LayoutsStyledTest>() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = spinner {}
12 |
13 | override fun KtfxPane.child2() = spinner()
14 |
15 | override fun child3() = styledSpinner()
16 |
17 | override fun KtfxPane.child4() = styledSpinner()
18 | }
19 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/PasswordFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.PasswordField
5 |
6 | class PasswordFieldTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxPane()
8 |
9 | override fun KtfxPane.childCount() = children.size
10 |
11 | override fun child1() = passwordField {}
12 |
13 | override fun KtfxPane.child2() = passwordField()
14 |
15 | override fun child3() = styledPasswordField()
16 |
17 | override fun KtfxPane.child4() = styledPasswordField()
18 | }
19 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/main/kotlin/org/controlsfx/control/KtfxHiddenSidesPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("ControlsfxLayoutsKt")
3 |
4 | package ktfx.controlsfx.layouts
5 |
6 | import javafx.scene.Node
7 | import ktfx.layouts.NodeContainer
8 | import org.controlsfx.control.HiddenSidesPane
9 |
10 | /**
11 | * [HiddenSidesPane] with dynamic-layout dsl support. Invoking dsl will only set its content.
12 | */
13 | public open class KtfxHiddenSidesPane :
14 | HiddenSidesPane(),
15 | NodeContainer {
16 | final override fun addChild(child: T): T = child.also { content = it }
17 | }
18 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/main/kotlin/org/controlsfx/control/KtfxInfoOverlay.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("ControlsfxLayoutsKt")
3 |
4 | package ktfx.controlsfx.layouts
5 |
6 | import javafx.scene.Node
7 | import ktfx.layouts.NodeContainer
8 | import org.controlsfx.control.InfoOverlay
9 |
10 | /** [InfoOverlay] with dynamic-layout dsl support. Invoking dsl will only set its content. */
11 | public open class KtfxInfoOverlay(graphic: Node?, text: String?) :
12 | InfoOverlay(graphic, text),
13 | NodeContainer {
14 | final override fun addChild(child: T): T = child.also { content = it }
15 | }
16 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/controls/Node.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controls
2 |
3 | import javafx.scene.Node
4 | import javafx.scene.SnapshotParameters
5 | import javafx.scene.image.WritableImage
6 |
7 | /** Alias of [Node.lookup] with non-null return and specified type. */
8 | public inline fun Node.find(selector: String): T = lookup(selector) as T
9 |
10 | /** Take a snapshot of this [Node] returning image it wrote. */
11 | public inline fun Node.capture(
12 | image: WritableImage? = null,
13 | configuration: SnapshotParameters.() -> Unit = {},
14 | ): WritableImage = snapshot(SnapshotParameters().apply(configuration), image)
15 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement.repositories {
2 | gradlePluginPortal()
3 | mavenCentral()
4 | }
5 | dependencyResolutionManagement.repositories.mavenCentral()
6 |
7 | rootProject.name = "ktfx"
8 |
9 | include("ktfx-all", "ktfx-commons", "ktfx-coroutines", "ktfx-layouts")
10 | include("codegen")
11 | include("sample")
12 | include("website")
13 |
14 | includeDir("thirdparty")
15 | includeDir("testing")
16 |
17 | fun includeDir(dir: String) =
18 | include(
19 | *file(dir)
20 | .listFiles()!!
21 | .filter { it.isDirectory }
22 | .map { "$dir:${it.name}" }
23 | .toTypedArray(),
24 | )
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-commons/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-commons"))
20 | implementation(libs.jfoenix)
21 |
22 | testImplementation(project(":testing:commons"))
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-layouts"))
20 | implementation(libs.jfoenix)
21 |
22 | testImplementation(project(":testing:layouts"))
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/SeparatorMenuItemTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.SeparatorMenuItem
5 |
6 | class SeparatorMenuItemTest : LayoutsStyledTest() {
7 | override fun manager() = KtfxMenu("", null)
8 |
9 | override fun KtfxMenu.childCount() = items.size
10 |
11 | override fun child1() = separatorMenuItem {}
12 |
13 | override fun KtfxMenu.child2() = separatorMenuItem()
14 |
15 | override fun child3() = styledSeparatorMenuItem()
16 |
17 | override fun KtfxMenu.child4() = styledSeparatorMenuItem()
18 | }
19 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-layouts"))
20 | implementation(libs.controlsfx)
21 |
22 | testImplementation(project(":testing:layouts"))
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/StatusBarTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.StatusBar
6 |
7 | class StatusBarTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = statusBar {}
13 |
14 | override fun KtfxPane.child2() = statusBar()
15 |
16 | override fun child3() = styledStatusBar()
17 |
18 | override fun KtfxPane.child4() = styledStatusBar()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/MaskerPaneTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.MaskerPane
6 |
7 | class MaskerPaneTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = maskerPane {}
13 |
14 | override fun KtfxPane.child2() = maskerPane()
15 |
16 | override fun child3() = styledMaskerPane()
17 |
18 | override fun KtfxPane.child4() = styledMaskerPane()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxHamburgerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXHamburger
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxHamburgerTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxHamburger {}
13 |
14 | override fun KtfxPane.child2() = jfxHamburger()
15 |
16 | override fun child3() = styledJfxHamburger()
17 |
18 | override fun KtfxPane.child4() = styledJfxHamburger()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/KtfxSubScene.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.Parent
8 | import javafx.scene.SubScene
9 | import javafx.scene.layout.Pane
10 |
11 | /**
12 | * [SubScene] with dynamic-layout dsl support.
13 | * Invoking dsl will only set its root.
14 | */
15 | public open class KtfxSubScene(root: Parent, width: Double, height: Double) :
16 | SubScene(root, width, height),
17 | NodeContainer {
18 | final override fun addChild(child: T): T =
19 | child.also {
20 | root = it as? Pane ?: Pane(it)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/WorldMapViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.WorldMapView
6 |
7 | class WorldMapViewTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = worldMapView {}
13 |
14 | override fun KtfxPane.child2() = worldMapView()
15 |
16 | override fun child3() = styledWorldMapView()
17 |
18 | override fun KtfxPane.child4() = styledWorldMapView()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/text/TextTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.text.Text
5 | import kotlin.test.assertEquals
6 |
7 | class TextTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxTextFlow()
9 |
10 | override fun KtfxTextFlow.childCount() = children.size
11 |
12 | override fun child1() = text {}
13 |
14 | override fun KtfxTextFlow.child2() = text()
15 |
16 | override fun child3() = styledText()
17 |
18 | override fun KtfxTextFlow.child4() = styledText()
19 |
20 | override fun Text.testDefaultValues() {
21 | assertEquals("", text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxDrawersStackTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXDrawersStack
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxDrawersStackTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxDrawersStack {}
13 |
14 | override fun KtfxPane.child2() = jfxDrawersStack()
15 |
16 | override fun child3() = styledJfxDrawersStack()
17 |
18 | override fun KtfxPane.child4() = styledJfxDrawersStack()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxToggleButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXToggleButton
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxToggleButtonTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxToggleButton {}
13 |
14 | override fun KtfxPane.child2() = jfxToggleButton()
15 |
16 | override fun child3() = styledJfxToggleButton()
17 |
18 | override fun KtfxPane.child4() = styledJfxToggleButton()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxChipViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXChipView
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxChipViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxChipView {}
13 |
14 | override fun KtfxPane.child2() = jfxChipView()
15 |
16 | override fun child3() = styledJfxChipView()
17 |
18 | override fun KtfxPane.child4() = styledJfxChipView()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxListCellTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXListCell
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxListCellTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxListCell {}
13 |
14 | override fun KtfxPane.child2() = jfxListCell()
15 |
16 | override fun child3() = styledJfxListCell()
17 |
18 | override fun KtfxPane.child4() = styledJfxListCell()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxListViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXListView
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxListViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxListView {}
13 |
14 | override fun KtfxPane.child2() = jfxListView()
15 |
16 | override fun child3() = styledJfxListView()
17 |
18 | override fun KtfxPane.child4() = styledJfxListView()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxPasswordFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXPasswordField
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxPasswordFieldTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxPasswordField {}
13 |
14 | override fun KtfxPane.child2() = jfxPasswordField()
15 |
16 | override fun child3() = styledJfxPasswordField()
17 |
18 | override fun KtfxPane.child4() = styledJfxPasswordField()
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxTreeCellTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXTreeCell
5 | import ktfx.layouts.KtfxPane
6 |
7 | class JfxTreeCellTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = jfxTreeCell {}
13 |
14 | override fun KtfxPane.child2() = jfxTreeCell()
15 |
16 | override fun child3() = styledJfxTreeCell()
17 |
18 | override fun KtfxPane.child4() = styledJfxTreeCell()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/print/PrinterTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.print
2 |
3 | import javafx.print.Printer
4 | import kotlin.test.Test
5 | import kotlin.test.assertEquals
6 |
7 | class PrinterTest {
8 | @Test
9 | fun createJob() {
10 | Printer.getDefaultPrinter()?.run {
11 | val job =
12 | createJob {
13 | copies = 2
14 | setPageRanges(1 untilPage 3)
15 | }
16 | assertEquals(2, job.jobSettings.copies)
17 | job.jobSettings.pageRanges.single().let {
18 | assertEquals(1, it.startPage)
19 | assertEquals(3, it.endPage)
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/MeshViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.MeshView
5 | import kotlin.test.assertNull
6 |
7 | class MeshViewTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = meshView {}
13 |
14 | override fun KtfxPane.child2() = meshView()
15 |
16 | override fun child3() = styledMeshView()
17 |
18 | override fun KtfxPane.child4() = styledMeshView()
19 |
20 | override fun MeshView.testDefaultValues() {
21 | assertNull(mesh)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/web/WebViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.web.WebView
5 | import kotlin.test.Ignore
6 |
7 | /** Error on [child1], [child2] and [child3] because creating [WebView] must be in FX thread. */
8 | @Ignore
9 | class WebViewTest : LayoutsStyledTest() {
10 | override fun manager() = KtfxPane()
11 |
12 | override fun KtfxPane.childCount() = children.size
13 |
14 | override fun child1() = webView {}
15 |
16 | override fun KtfxPane.child2() = webView()
17 |
18 | override fun child3() = styledWebView()
19 |
20 | override fun KtfxPane.child4() = styledWebView()
21 | }
22 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/PlusMinusSliderTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.PlusMinusSlider
6 |
7 | class PlusMinusSliderTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = plusMinusSlider {}
13 |
14 | override fun KtfxPane.child2() = plusMinusSlider()
15 |
16 | override fun child3() = styledPlusMinusSlider()
17 |
18 | override fun KtfxPane.child4() = styledPlusMinusSlider()
19 | }
20 |
--------------------------------------------------------------------------------
/codegen/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseGroup: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | application
6 | kotlin("jvm")
7 | alias(libs.plugins.ktlint)
8 | }
9 |
10 | javafx.modules("javafx.controls", "javafx.web")
11 |
12 | application.mainClass.set("$releaseGroup.codegen.Generator")
13 |
14 | dependencies {
15 | ktlintRuleset(libs.rulebook.ktlint)
16 |
17 | implementation(kotlin("reflect", libs.versions.kotlin.get()))
18 | implementation(libs.kotlinx.coroutines.core)
19 | implementation(libs.kotlinpoet.dsl)
20 | implementation(libs.controlsfx)
21 | implementation(libs.jfoenix)
22 |
23 | testImplementation(kotlin("test-junit", libs.versions.kotlin.get()))
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/LabelTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Label
5 | import kotlin.test.assertNull
6 |
7 | class LabelTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = label {}
13 |
14 | override fun KtfxPane.child2() = label()
15 |
16 | override fun child3() = styledLabel()
17 |
18 | override fun KtfxPane.child4() = styledLabel()
19 |
20 | override fun Label.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/image/ImageViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.image.ImageView
5 | import kotlin.test.assertNull
6 |
7 | class ImageViewTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = imageView {}
13 |
14 | override fun KtfxPane.child2() = imageView()
15 |
16 | override fun child3() = styledImageView()
17 |
18 | override fun KtfxPane.child4() = styledImageView()
19 |
20 | override fun ImageView.testDefaultValues() {
21 | assertNull(image)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/QuadCurveToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.QuadCurveTo
5 | import kotlin.test.assertEquals
6 |
7 | class QuadCurveToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = quadCurveTo {}
13 |
14 | override fun KtfxPath.child2() = quadCurveTo()
15 |
16 | override fun QuadCurveTo.testDefaultValues() {
17 | assertEquals(0.0, controlX)
18 | assertEquals(0.0, controlY)
19 | assertEquals(0.0, x)
20 | assertEquals(0.0, y)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/CustomTextFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.textfield.CustomTextField
6 |
7 | class CustomTextFieldTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = customTextField {}
13 |
14 | override fun KtfxPane.child2() = customTextField()
15 |
16 | override fun child3() = styledCustomTextField()
17 |
18 | override fun KtfxPane.child4() = styledCustomTextField()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/KtfxScene.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.Parent
8 | import javafx.scene.Scene
9 | import javafx.scene.layout.Pane
10 | import javafx.scene.paint.Paint
11 |
12 | /**
13 | * [Scene] with dynamic-layout dsl support.
14 | * Invoking dsl will only set its root.
15 | */
16 | public open class KtfxScene(root: Parent, width: Double, height: Double, fill: Paint) :
17 | Scene(root, width, height, fill),
18 | NodeContainer {
19 | final override fun addChild(child: T): T =
20 | child.also {
21 | root = it as? Pane ?: Pane(it)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TextAreaTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.TextArea
5 | import kotlin.test.assertEquals
6 |
7 | class TextAreaTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = textArea {}
13 |
14 | override fun KtfxPane.child2() = textArea()
15 |
16 | override fun child3() = styledTextArea()
17 |
18 | override fun KtfxPane.child4() = styledTextArea()
19 |
20 | override fun TextArea.testDefaultValues() {
21 | assertEquals("", text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-coroutines/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-coroutines"))
20 | implementation(libs.kotlinx.coroutines.javafx)
21 | implementation(libs.controlsfx)
22 |
23 | testImplementation(project(":testing:coroutines"))
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/media/MediaViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.media.MediaView
5 | import kotlin.test.assertNull
6 |
7 | class MediaViewTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = mediaView {}
13 |
14 | override fun KtfxPane.child2() = mediaView()
15 |
16 | override fun child3() = styledMediaView()
17 |
18 | override fun KtfxPane.child4() = styledMediaView()
19 |
20 | override fun MediaView.testDefaultValues() {
21 | assertNull(mediaPlayer)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-commons/src/main/kotlin/ktfx/jfoenix/dialogs/JfxDialog.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.dialogs
2 |
3 | import com.jfoenix.controls.JFXDialog
4 | import javafx.scene.layout.StackPane
5 | import java.util.WeakHashMap
6 |
7 | private val shownDialogs = WeakHashMap()
8 |
9 | /**
10 | * Track a previously shown dialog within a container to close it before showing a new dialog.
11 | *
12 | * @param container parent layout, or the dialog's default container.
13 | */
14 | public fun JFXDialog.showSingle(container: StackPane = dialogContainer) {
15 | shownDialogs[container]
16 | ?.takeIf { it in container.children }
17 | ?.close()
18 | shownDialogs[container] = apply { show() }
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/CheckBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.CheckBox
5 | import kotlin.test.assertNull
6 |
7 | class CheckBoxTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = checkBox {}
13 |
14 | override fun KtfxPane.child2() = checkBox()
15 |
16 | override fun child3(): CheckBox = styledCheckBox()
17 |
18 | override fun KtfxPane.child4(): CheckBox = styledCheckBox()
19 |
20 | override fun CheckBox.testDefaultValues() {
21 | assertNull(text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/DatePickerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.DatePicker
5 | import kotlin.test.assertNull
6 |
7 | class DatePickerTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = datePicker {}
13 |
14 | override fun KtfxPane.child2() = datePicker()
15 |
16 | override fun child3() = styledDatePicker()
17 |
18 | override fun KtfxPane.child4() = styledDatePicker()
19 |
20 | override fun DatePicker.testDefaultValues() {
21 | assertNull(value)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TextFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.TextField
5 | import kotlin.test.assertEquals
6 |
7 | class TextFieldTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = textField {}
13 |
14 | override fun KtfxPane.child2() = textField()
15 |
16 | override fun child3() = styledTextField()
17 |
18 | override fun KtfxPane.child4() = styledTextField()
19 |
20 | override fun TextField.testDefaultValues() {
21 | assertEquals("", text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/PolygonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.shape.Polygon
6 |
7 | class PolygonTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = polygon {}
13 |
14 | override fun KtfxPane.child2() = polygon()
15 |
16 | override fun child3() = styledPolygon()
17 |
18 | override fun KtfxPane.child4() = styledPolygon()
19 |
20 | override fun Polygon.testDefaultValues() {
21 | assertThat(points).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-coroutines/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls", "javafx.swing")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-coroutines"))
20 | implementation(libs.kotlinx.coroutines.javafx)
21 | implementation(libs.jfoenix)
22 |
23 | testImplementation(project(":testing:coroutines"))
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/text/FontTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.text
2 |
3 | import javafx.scene.text.Font
4 | import kotlin.test.Ignore
5 | import kotlin.test.Test
6 | import kotlin.test.assertEquals
7 |
8 | // fails on CI
9 | @Ignore
10 | class FontTest {
11 | @Test
12 | fun pt() {
13 | assertEquals(Font.font(12.0), 12.pt)
14 | assertEquals(Font.font(18.0), 18.0.pt)
15 | }
16 |
17 | @Test
18 | fun fontOf() {
19 | val font1 = fontOf("Arial", size = 12)
20 | assertEquals("Arial", font1.family)
21 | assertEquals(12.0, font1.size)
22 | val font2 = fontOf("Arial", size = 18.0)
23 | assertEquals("Arial", font2.family)
24 | assertEquals(18.0, font2.size)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/chart/PieChartTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.chart.PieChart
6 |
7 | class PieChartTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = pieChart {}
13 |
14 | override fun KtfxPane.child2() = pieChart()
15 |
16 | override fun child3() = styledPieChart()
17 |
18 | override fun KtfxPane.child4() = styledPieChart()
19 |
20 | override fun PieChart.testDefaultValues() {
21 | assertThat(data).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/PolylineTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.shape.Polyline
6 |
7 | class PolylineTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = polyline {}
13 |
14 | override fun KtfxPane.child2() = polyline()
15 |
16 | override fun child3() = styledPolyline()
17 |
18 | override fun KtfxPane.child4() = styledPolyline()
19 |
20 | override fun Polyline.testDefaultValues() {
21 | assertThat(points).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/canvas/CanvasTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.canvas.Canvas
5 | import kotlin.test.assertEquals
6 |
7 | class CanvasTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = canvas {}
13 |
14 | override fun KtfxPane.child2() = canvas()
15 |
16 | override fun child3() = styledCanvas()
17 |
18 | override fun KtfxPane.child4() = styledCanvas()
19 |
20 | override fun Canvas.testDefaultValues() {
21 | assertEquals(0.0, width)
22 | assertEquals(0.0, height)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/RadioButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.RadioButton
5 | import kotlin.test.assertNull
6 |
7 | class RadioButtonTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = radioButton {}
13 |
14 | override fun KtfxPane.child2() = radioButton()
15 |
16 | override fun child3() = styledRadioButton()
17 |
18 | override fun KtfxPane.child4() = styledRadioButton()
19 |
20 | override fun RadioButton.testDefaultValues() {
21 | assertNull(text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/SphereTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Sphere
5 | import kotlin.test.assertEquals
6 |
7 | class SphereTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = sphere {}
13 |
14 | override fun KtfxPane.child2() = sphere()
15 |
16 | override fun child3() = styledSphere()
17 |
18 | override fun KtfxPane.child4() = styledSphere()
19 |
20 | override fun Sphere.testDefaultValues() {
21 | assertEquals(1.0, radius)
22 | assertEquals(64, divisions)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/CustomPasswordFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.textfield.CustomPasswordField
6 |
7 | class CustomPasswordFieldTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = customPasswordField {}
13 |
14 | override fun KtfxPane.child2() = customPasswordField()
15 |
16 | override fun child3() = styledCustomPasswordField()
17 |
18 | override fun KtfxPane.child4() = styledCustomPasswordField()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/MenuItemTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.MenuItem
5 | import kotlin.test.assertNull
6 |
7 | class MenuItemTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxMenu("", null)
9 |
10 | override fun KtfxMenu.childCount() = items.size
11 |
12 | override fun child1() = menuItem {}
13 |
14 | override fun KtfxMenu.child2() = menuItem()
15 |
16 | override fun child3() = styledMenuItem()
17 |
18 | override fun KtfxMenu.child4() = styledMenuItem()
19 |
20 | override fun MenuItem.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Button
5 | import kotlin.test.assertNull
6 |
7 | class ButtonTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxButtonBar(null)
9 |
10 | override fun KtfxButtonBar.childCount() = buttons.size
11 |
12 | override fun child1() = button {}
13 |
14 | override fun KtfxButtonBar.child2() = button()
15 |
16 | override fun child3() = styledButton()
17 |
18 | override fun KtfxButtonBar.child4() = styledButton()
19 |
20 | override fun Button.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/HyperlinkTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Hyperlink
5 | import kotlin.test.assertNull
6 |
7 | class HyperlinkTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = hyperlink {}
13 |
14 | override fun KtfxPane.child2() = hyperlink()
15 |
16 | override fun child3() = styledHyperlink()
17 |
18 | override fun KtfxPane.child4() = styledHyperlink()
19 |
20 | override fun Hyperlink.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TitledPaneTest2.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.TitledPane
5 | import kotlin.test.assertNull
6 |
7 | class TitledPaneTest2 : LayoutsStyledTest() {
8 | override fun manager() = KtfxAccordion()
9 |
10 | override fun KtfxAccordion.childCount() = panes.size
11 |
12 | override fun child1() = titledPane {}
13 |
14 | override fun KtfxAccordion.child2() = titledPane()
15 |
16 | override fun child3() = styledTitledPane()
17 |
18 | override fun KtfxAccordion.child4() = styledTitledPane()
19 |
20 | override fun TitledPane.testDefaultValues() {
21 | assertNull(text)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TreeViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.TreeView
5 | import kotlin.test.assertNull
6 |
7 | class TreeViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = treeView {}
13 |
14 | override fun KtfxPane.child2() = treeView()
15 |
16 | override fun child3() = styledTreeView()
17 |
18 | override fun KtfxPane.child4() = styledTreeView()
19 |
20 | override fun TreeView.testDefaultValues() {
21 | assertNull(root)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/ListSelectionViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.ListSelectionView
6 |
7 | class ListSelectionViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = listSelectionView {}
13 |
14 | override fun KtfxPane.child2() = listSelectionView()
15 |
16 | override fun child3() = styledListSelectionView()
17 |
18 | override fun KtfxPane.child4() = styledListSelectionView()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/text/KtfxTextFlow.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.text.Text
8 | import javafx.scene.text.TextFlow
9 |
10 | /**
11 | * [TextFlow] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxTextFlow :
15 | TextFlow(),
16 | NodeContainer {
17 | final override fun addChild(child: T): T = child.also { children += it }
18 |
19 | /** Call [NodeContainer.text] by string invocation. */
20 | public inline operator fun String.invoke(
21 | configuration: (@KtfxLayoutDslMarker Text).() -> Unit,
22 | ): Text = text(this, configuration)
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/MenuTest2.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Menu
5 | import kotlin.test.assertEquals
6 | import kotlin.test.assertNull
7 |
8 | class MenuTest2 : LayoutsStyledTest() {
9 | override fun manager() = KtfxMenuBar()
10 |
11 | override fun KtfxMenuBar.childCount() = menus.size
12 |
13 | override fun child1() = menu {}
14 |
15 | override fun KtfxMenuBar.child2() = menu()
16 |
17 | override fun child3() = styledMenu()
18 |
19 | override fun KtfxMenuBar.child4() = styledMenu()
20 |
21 | override fun Menu.testDefaultValues() {
22 | assertEquals("", text)
23 | assertNull(graphic)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/inputs/Clipboard.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("NOTHING_TO_INLINE")
2 |
3 | package ktfx.inputs
4 |
5 | import javafx.scene.input.Clipboard
6 | import javafx.scene.input.DataFormat
7 |
8 | /** Convenient method to put single content to clipboard. */
9 | public operator fun Clipboard.set(dataFormat: DataFormat, content: Any): Boolean =
10 | setContent(mapOf(dataFormat to content))
11 |
12 | /** The content associated with this type, or null if there is none. */
13 | public inline operator fun Clipboard.get(dataFormat: DataFormat): Any? = getContent(dataFormat)
14 |
15 | /** Returns true if there is content on this clipboard for this type. */
16 | public inline operator fun Clipboard.contains(dataFormat: DataFormat): Boolean =
17 | hasContent(dataFormat)
18 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/print/Printer.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalContracts::class)
2 |
3 | package ktfx.print
4 |
5 | import javafx.print.JobSettings
6 | import javafx.print.Printer
7 | import javafx.print.PrinterJob
8 | import kotlin.contracts.ExperimentalContracts
9 | import kotlin.contracts.InvocationKind
10 | import kotlin.contracts.contract
11 |
12 | /** Create a new printer job with specified job settings. */
13 | public inline fun Printer.createJob(
14 | configuration: JobSettings.() -> Unit = {
15 | copies = 1
16 | setPageRanges(1 untilPage 1)
17 | },
18 | ): PrinterJob {
19 | contract { callsInPlace(configuration, InvocationKind.EXACTLY_ONCE) }
20 | return PrinterJob.createPrinterJob(this).also { it.jobSettings.configuration() }
21 | }
22 |
--------------------------------------------------------------------------------
/ktfx-coroutines/src/test/kotlin/javafx/scene/media/MediaViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.coroutines
2 |
3 | import com.hanggrian.ktfx.test.testScene
4 | import javafx.scene.media.MediaView
5 | import javafx.stage.Stage
6 | import org.testfx.framework.junit.ApplicationTest
7 | import kotlin.test.Ignore
8 | import kotlin.test.Test
9 |
10 | @Ignore
11 | class MediaViewTest : ApplicationTest() {
12 | private lateinit var media: MediaView
13 |
14 | override fun start(stage: Stage) {
15 | stage.testScene()
16 | media = MediaView()
17 | }
18 |
19 | // TODO create fake event
20 | @Test
21 | fun onError() {
22 | // media.callOnError { assertFakeMediaErrorEvent(it) }
23 | // media.onError.handle(fakeMediaErrorEventOf())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/SubScene.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 | @file:OptIn(ExperimentalContracts::class)
4 |
5 | package ktfx.layouts
6 |
7 | import javafx.scene.SubScene
8 | import javafx.scene.layout.Pane
9 | import kotlin.contracts.ExperimentalContracts
10 | import kotlin.contracts.InvocationKind
11 | import kotlin.contracts.contract
12 |
13 | /** Create a [SubScene] with configuration block. */
14 | public inline fun subScene(
15 | width: Double = -1.0,
16 | height: Double = -1.0,
17 | configuration: (@KtfxLayoutDslMarker KtfxSubScene).() -> Unit,
18 | ): SubScene {
19 | contract { callsInPlace(configuration, InvocationKind.EXACTLY_ONCE) }
20 | return KtfxSubScene(Pane(), width, height).apply(configuration)
21 | }
22 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/SliderTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Slider
5 | import kotlin.test.assertEquals
6 |
7 | class SliderTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = slider {}
13 |
14 | override fun KtfxPane.child2() = slider()
15 |
16 | override fun child3() = styledSlider()
17 |
18 | override fun KtfxPane.child4() = styledSlider()
19 |
20 | override fun Slider.testDefaultValues() {
21 | assertEquals(0.0, min)
22 | assertEquals(100.0, max)
23 | assertEquals(0.0, value)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ProgressBarTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ProgressBar
5 | import kotlin.test.assertEquals
6 |
7 | class ProgressBarTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = progressBar {}
13 |
14 | override fun KtfxPane.child2() = progressBar()
15 |
16 | override fun child3() = styledProgressBar()
17 |
18 | override fun KtfxPane.child4() = styledProgressBar()
19 |
20 | override fun ProgressBar.testDefaultValues() {
21 | assertEquals(ProgressBar.INDETERMINATE_PROGRESS, progress)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ToggleButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ToggleButton
5 | import kotlin.test.assertNull
6 |
7 | class ToggleButtonTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = toggleButton {}
13 |
14 | override fun KtfxPane.child2() = toggleButton()
15 |
16 | override fun child3() = styledToggleButton()
17 |
18 | override fun KtfxPane.child4() = styledToggleButton()
19 |
20 | override fun ToggleButton.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-commons/build.gradle.kts:
--------------------------------------------------------------------------------
1 | val releaseArtifact: String by project
2 |
3 | plugins {
4 | alias(libs.plugins.javafx)
5 | kotlin("jvm") version libs.versions.kotlin
6 | alias(libs.plugins.dokka)
7 | alias(libs.plugins.kotlinx.kover)
8 | alias(libs.plugins.ktlint)
9 | alias(libs.plugins.maven.publish)
10 | }
11 |
12 | javafx.modules("javafx.controls")
13 |
14 | kotlin.explicitApi()
15 |
16 | dependencies {
17 | ktlintRuleset(libs.rulebook.ktlint)
18 |
19 | implementation(project(":$releaseArtifact-commons"))
20 | implementation(libs.controlsfx)
21 |
22 | testImplementation(project(":testing:commons"))
23 | testImplementation(project(":$releaseArtifact-layouts"))
24 | testImplementation(libs.kotlinx.coroutines.javafx)
25 | }
26 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-commons/src/main/kotlin/ktfx/jfoenix/dialogs/JfxAlert.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalContracts::class)
2 |
3 | package ktfx.jfoenix.dialogs
4 |
5 | import com.jfoenix.controls.JFXAlert
6 | import javafx.stage.Stage
7 | import java.util.Optional
8 | import kotlin.contracts.ExperimentalContracts
9 | import kotlin.contracts.InvocationKind
10 | import kotlin.contracts.contract
11 |
12 | /**
13 | * Show a JFoenix alert.
14 | *
15 | * @param configuration custom dialog action.
16 | * @return dialog result.
17 | */
18 | public fun Stage.jfxAlert(configuration: JFXAlert.() -> Unit): Optional {
19 | contract { callsInPlace(configuration, InvocationKind.EXACTLY_ONCE) }
20 | return JFXAlert(this)
21 | .apply(configuration)
22 | .showAndWait()
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ComboBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.control.ComboBox
6 |
7 | class ComboBoxTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = comboBox {}
13 |
14 | override fun KtfxPane.child2() = comboBox()
15 |
16 | override fun child3() = styledComboBox()
17 |
18 | override fun KtfxPane.child4() = styledComboBox()
19 |
20 | override fun ComboBox.testDefaultValues() {
21 | assertThat(items).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ListViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.control.ListView
6 |
7 | class ListViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = listView {}
13 |
14 | override fun KtfxPane.child2() = listView()
15 |
16 | override fun child3() = styledListView()
17 |
18 | override fun KtfxPane.child4() = styledListView()
19 |
20 | override fun ListView.testDefaultValues() {
21 | assertThat(items).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/BoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Box
5 | import kotlin.test.assertEquals
6 |
7 | class BoxTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = box {}
13 |
14 | override fun KtfxPane.child2() = box()
15 |
16 | override fun child3() = styledBox()
17 |
18 | override fun KtfxPane.child4() = styledBox()
19 |
20 | override fun Box.testDefaultValues() {
21 | assertEquals(Box.DEFAULT_SIZE, width)
22 | assertEquals(Box.DEFAULT_SIZE, height)
23 | assertEquals(Box.DEFAULT_SIZE, depth)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/testing/layouts/src/main/kotlin/com/hanggrian/ktfx/test/LayoutsStyledTest.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.css.Styleable
4 | import kotlin.test.Test
5 | import kotlin.test.assertEquals
6 |
7 | /** Extra tests for a style-able control. */
8 | abstract class LayoutsStyledTest : LayoutsTest() {
9 | abstract fun child3(): C
10 |
11 | abstract fun M.child4(): C
12 |
13 | @Test
14 | fun createStyledChild() {
15 | val child = child3()
16 | child.testDefaultValues()
17 | assertEquals(0, manager.childCount())
18 | }
19 |
20 | @Test
21 | fun addStyledChild() {
22 | val child = manager.child4()
23 | child.testDefaultValues()
24 | assertEquals(1, manager.childCount())
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/SegmentedBarTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.SegmentedBar
6 |
7 | class SegmentedBarTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = segmentedBar {}
13 |
14 | override fun KtfxPane.child2() = segmentedBar()
15 |
16 | override fun child3() = styledSegmentedBar()
17 |
18 | override fun KtfxPane.child4() = styledSegmentedBar()
19 | }
20 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxAccordion.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.control.Accordion
7 | import javafx.scene.control.TitledPane
8 |
9 | /**
10 | * [Accordion] with dynamic-layout dsl support.
11 | * Invoking dsl will add its children.
12 | */
13 | public open class KtfxAccordion :
14 | Accordion(),
15 | TitledPaneContainer {
16 | final override fun addChild(child: T): T = child.also { panes += it }
17 |
18 | /** Call [NodeContainer.titledPane] by string invocation. */
19 | public inline operator fun String.invoke(
20 | configuration: (@KtfxLayoutDslMarker KtfxTitledPane).() -> Unit,
21 | ): TitledPane = titledPane(this, configuration)
22 | }
23 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/CheckMenuItemTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.CheckMenuItem
5 | import kotlin.test.assertNull
6 |
7 | class CheckMenuItemTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxMenu("", null)
9 |
10 | override fun KtfxMenu.childCount() = items.size
11 |
12 | override fun child1() = checkMenuItem {}
13 |
14 | override fun KtfxMenu.child2() = checkMenuItem()
15 |
16 | override fun child3() = styledCheckMenuItem()
17 |
18 | override fun KtfxMenu.child4() = styledCheckMenuItem()
19 |
20 | override fun CheckMenuItem.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ChoiceBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.control.ChoiceBox
6 |
7 | class ChoiceBoxTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = choiceBox {}
13 |
14 | override fun KtfxPane.child2() = choiceBox()
15 |
16 | override fun child3() = styledChoiceBox()
17 |
18 | override fun KtfxPane.child4() = styledChoiceBox()
19 |
20 | override fun ChoiceBox.testDefaultValues() {
21 | assertThat(items).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ColorPickerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ColorPicker
5 | import javafx.scene.paint.Color
6 | import kotlin.test.assertEquals
7 |
8 | class ColorPickerTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = colorPicker {}
14 |
15 | override fun KtfxPane.child2() = colorPicker()
16 |
17 | override fun child3() = styledColorPicker()
18 |
19 | override fun KtfxPane.child4() = styledColorPicker()
20 |
21 | override fun ColorPicker.testDefaultValues() {
22 | assertEquals(Color.WHITE, value)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/RadioMenuItemTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.RadioMenuItem
5 | import kotlin.test.assertNull
6 |
7 | class RadioMenuItemTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxMenu("", null)
9 |
10 | override fun KtfxMenu.childCount() = items.size
11 |
12 | override fun child1() = radioMenuItem {}
13 |
14 | override fun KtfxMenu.child2() = radioMenuItem()
15 |
16 | override fun child3() = styledRadioMenuItem()
17 |
18 | override fun KtfxMenu.child4() = styledRadioMenuItem()
19 |
20 | override fun RadioMenuItem.testDefaultValues() {
21 | assertNull(text)
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TableViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import javafx.scene.control.TableView
6 |
7 | class TableViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = tableView {}
13 |
14 | override fun KtfxPane.child2() = tableView()
15 |
16 | override fun child3() = styledTableView()
17 |
18 | override fun KtfxPane.child4() = styledTableView()
19 |
20 | override fun TableView.testDefaultValues() {
21 | assertThat(items).isEmpty()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/bindings/ArrayBindingsIntegerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.bindings
2 |
3 | import ktfx.collections.observableIntArrayOf
4 | import ktfx.floatPropertyOf
5 | import ktfx.intPropertyOf
6 | import kotlin.test.Test
7 | import kotlin.test.assertEquals
8 |
9 | class ArrayBindingsIntegerTest {
10 | @Test
11 | fun getBinding() {
12 | val numbers = observableIntArrayOf(1)
13 | val binding1 = numbers.getBinding(0)
14 | numbers[0] = 2
15 | assertEquals(2, binding1.value)
16 | val binding2 = numbers.getBinding(floatPropertyOf(0f))
17 | numbers[0] = 3
18 | assertEquals(3, binding2.value)
19 | val binding3 = numbers.getBinding(intPropertyOf(0))
20 | numbers[0] = 4
21 | assertEquals(4, binding3.value)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/CylinderTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Cylinder
5 | import kotlin.test.assertEquals
6 |
7 | class CylinderTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = cylinder {}
13 |
14 | override fun KtfxPane.child2() = cylinder()
15 |
16 | override fun child3() = styledCylinder()
17 |
18 | override fun KtfxPane.child4() = styledCylinder()
19 |
20 | override fun Cylinder.testDefaultValues() {
21 | assertEquals(1.0, radius)
22 | assertEquals(2.0, height)
23 | assertEquals(64, divisions)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxCheckBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXCheckBox
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxCheckBoxTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxCheckBox {}
14 |
15 | override fun KtfxPane.child2() = jfxCheckBox()
16 |
17 | override fun child3() = styledJfxCheckBox()
18 |
19 | override fun KtfxPane.child4() = styledJfxCheckBox()
20 |
21 | override fun JFXCheckBox.testDefaultValues() {
22 | assertNull(text)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/TreeTableViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.TreeTableView
5 | import kotlin.test.assertNull
6 |
7 | class TreeTableViewTest : LayoutsStyledTest>() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = treeTableView {}
13 |
14 | override fun KtfxPane.child2() = treeTableView()
15 |
16 | override fun child3() = styledTreeTableView()
17 |
18 | override fun KtfxPane.child4() = styledTreeTableView()
19 |
20 | override fun TreeTableView.testDefaultValues() {
21 | assertNull(root)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/testing/core/src/main/kotlin/com/hanggrian/ktfx/test/Scene.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.geometry.Insets
4 | import javafx.scene.Scene
5 | import javafx.scene.control.Label
6 | import javafx.scene.layout.VBox
7 | import javafx.scene.text.Font
8 | import javafx.scene.text.FontWeight
9 | import javafx.stage.Stage
10 |
11 | fun Stage.testScene(subject: String): Scene {
12 | scene =
13 | Scene(
14 | VBox(
15 | 10.0,
16 | Label("Currently testing"),
17 | Label(subject).apply { font = Font.font("System", FontWeight.BLACK, 24.0) },
18 | ).apply { padding = Insets(20.0) },
19 | )
20 | show()
21 | return scene
22 | }
23 |
24 | inline fun Stage.testScene() = testScene(T::class.java.simpleName)
25 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/bindings/ArrayBindingsFloatTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.bindings
2 |
3 | import ktfx.collections.observableFloatArrayOf
4 | import ktfx.floatPropertyOf
5 | import ktfx.intPropertyOf
6 | import kotlin.test.Test
7 | import kotlin.test.assertEquals
8 |
9 | class ArrayBindingsFloatTest {
10 | @Test
11 | fun getBinding() {
12 | val numbers = observableFloatArrayOf(1f)
13 | val binding1 = numbers.getBinding(0)
14 | numbers[0] = 2f
15 | assertEquals(2f, binding1.value)
16 | val binding2 = numbers.getBinding(floatPropertyOf(0f))
17 | numbers[0] = 3f
18 | assertEquals(3f, binding2.value)
19 | val binding3 = numbers.getBinding(intPropertyOf(0))
20 | numbers[0] = 4f
21 | assertEquals(4f, binding3.value)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxTabPane.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.Tab
8 | import javafx.scene.control.TabPane
9 |
10 | /**
11 | * [TabPane] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxTabPane :
15 | TabPane(),
16 | TabContainer {
17 | final override fun addChild(child: T): T = child.also { tabs += it }
18 |
19 | /** Call [TabContainer.tab] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker KtfxTab).() -> Unit,
23 | ): Tab = tab(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/PaginationTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.Pagination
5 | import kotlin.test.assertEquals
6 |
7 | class PaginationTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = pagination {}
13 |
14 | override fun KtfxPane.child2() = pagination()
15 |
16 | override fun child3() = styledPagination()
17 |
18 | override fun KtfxPane.child4() = styledPagination()
19 |
20 | override fun Pagination.testDefaultValues() {
21 | assertEquals(Pagination.INDETERMINATE, pageCount)
22 | assertEquals(0, currentPageIndex)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/CubicCurveToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.CubicCurveTo
5 | import kotlin.test.assertEquals
6 |
7 | class CubicCurveToTest : LayoutsTest() {
8 | override fun manager() = KtfxPath()
9 |
10 | override fun KtfxPath.childCount() = elements.size
11 |
12 | override fun child1() = cubicCurveTo {}
13 |
14 | override fun KtfxPath.child2() = cubicCurveTo()
15 |
16 | override fun CubicCurveTo.testDefaultValues() {
17 | assertEquals(0.0, controlX1)
18 | assertEquals(0.0, controlX2)
19 | assertEquals(0.0, controlY1)
20 | assertEquals(0.0, controlY2)
21 | assertEquals(0.0, x)
22 | assertEquals(0.0, y)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/RatingTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.Rating
6 | import kotlin.test.assertEquals
7 |
8 | class RatingTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = rating {}
14 |
15 | override fun KtfxPane.child2() = rating()
16 |
17 | override fun child3() = styledRating()
18 |
19 | override fun KtfxPane.child4() = styledRating()
20 |
21 | override fun Rating.testDefaultValues() {
22 | assertEquals(5, max)
23 | assertEquals(2.0, rating)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxTextAreaTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXTextArea
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertTrue
7 |
8 | class JfxTextAreaTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxTextArea {}
14 |
15 | override fun KtfxPane.child2() = jfxTextArea()
16 |
17 | override fun child3() = styledJfxTextArea()
18 |
19 | override fun KtfxPane.child4() = styledJfxTextArea()
20 |
21 | override fun JFXTextArea.testDefaultValues() {
22 | assertTrue(text.isEmpty())
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxMenuBar.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.Menu
8 | import javafx.scene.control.MenuBar
9 |
10 | /**
11 | * [MenuBar] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxMenuBar :
15 | MenuBar(),
16 | MenuContainer {
17 | final override fun addChild(child: T): T = child.also { menus += it }
18 |
19 | /** Call [MenuContainer.menu] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker KtfxMenu).() -> Unit,
23 | ): Menu = menu(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/PrefixSelectionComboBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.PrefixSelectionComboBox
6 |
7 | class PrefixSelectionComboBoxTest :
8 | LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = prefixSelectionComboBox {}
14 |
15 | override fun KtfxPane.child2() = prefixSelectionComboBox()
16 |
17 | override fun child3() = styledPrefixSelectionComboBox()
18 |
19 | override fun KtfxPane.child4() = styledPrefixSelectionComboBox()
20 | }
21 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/TaskProgressViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.concurrent.Task
5 | import ktfx.layouts.KtfxPane
6 | import org.controlsfx.control.TaskProgressView
7 |
8 | class TaskProgressViewTest : LayoutsStyledTest>>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = taskProgressView> {}
14 |
15 | override fun KtfxPane.child2() = taskProgressView>()
16 |
17 | override fun child3() = styledTaskProgressView>()
18 |
19 | override fun KtfxPane.child4() = styledTaskProgressView>()
20 | }
21 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXButton
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxButtonTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxButton {}
14 |
15 | override fun KtfxPane.child2() = jfxButton()
16 |
17 | override fun child3() = styledJfxButton()
18 |
19 | override fun KtfxPane.child4() = styledJfxButton()
20 |
21 | override fun JFXButton.testDefaultValues() {
22 | assertNull(text)
23 | assertNull(graphic)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/PairTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx
2 |
3 | import javafx.util.Pair
4 | import kotlin.test.Test
5 | import kotlin.test.assertEquals
6 | import kotlin.test.assertNull
7 |
8 | class PairTest {
9 | @Test
10 | fun toKotlinPair() {
11 | val (s, i) = Pair("Hello", 123).toKotlinPair()
12 | assertEquals("Hello", s)
13 | assertEquals(123, i)
14 |
15 | val (n1, n2) = Pair(null, null).toKotlinPair()
16 | assertNull(n1)
17 | assertNull(n2)
18 | }
19 |
20 | @Test
21 | fun toFxPair() {
22 | val (s, i) = kotlin.Pair("Hello", 123).toFxPair()
23 | assertEquals("Hello", s)
24 | assertEquals(123, i)
25 |
26 | val (n1, n2) = kotlin.Pair(null, null).toFxPair()
27 | assertNull(n1)
28 | assertNull(n2)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/ToggleSwitchTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.ToggleSwitch
6 | import kotlin.test.assertNull
7 |
8 | class ToggleSwitchTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = toggleSwitch {}
14 |
15 | override fun KtfxPane.child2() = toggleSwitch()
16 |
17 | override fun child3() = styledToggleSwitch()
18 |
19 | override fun KtfxPane.child4() = styledToggleSwitch()
20 |
21 | override fun ToggleSwitch.testDefaultValues() {
22 | assertNull(text)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxTextFieldTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXTextField
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertTrue
7 |
8 | class JfxTextFieldTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxTextField {}
14 |
15 | override fun KtfxPane.child2() = jfxTextField()
16 |
17 | override fun child3() = styledJfxTextField()
18 |
19 | override fun KtfxPane.child4() = styledJfxTextField()
20 |
21 | override fun JFXTextField.testDefaultValues() {
22 | assertTrue(text.isEmpty())
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxTimePickerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXTimePicker
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxTimePickerTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxTimePicker {}
14 |
15 | override fun KtfxPane.child2() = jfxTimePicker()
16 |
17 | override fun child3() = styledJfxTimePicker()
18 |
19 | override fun KtfxPane.child4() = styledJfxTimePicker()
20 |
21 | override fun JFXTimePicker.testDefaultValues() {
22 | assertNull(value)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxToggleNodeTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXToggleNode
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxToggleNodeTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxToggleNode {}
14 |
15 | override fun KtfxPane.child2() = jfxToggleNode()
16 |
17 | override fun child3() = styledJfxToggleNode()
18 |
19 | override fun KtfxPane.child4() = styledJfxToggleNode()
20 |
21 | override fun JFXToggleNode.testDefaultValues() {
22 | assertNull(graphic)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/PrefixSelectionChoiceBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.PrefixSelectionChoiceBox
6 |
7 | class PrefixSelectionChoiceBoxTest :
8 | LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = prefixSelectionChoiceBox {}
14 |
15 | override fun KtfxPane.child2() = prefixSelectionChoiceBox()
16 |
17 | override fun child3() = styledPrefixSelectionChoiceBox()
18 |
19 | override fun KtfxPane.child4() = styledPrefixSelectionChoiceBox()
20 | }
21 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxRadioButtonTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXRadioButton
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxRadioButtonTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxRadioButton {}
14 |
15 | override fun KtfxPane.child2() = jfxRadioButton()
16 |
17 | override fun child3() = styledJfxRadioButton()
18 |
19 | override fun KtfxPane.child4() = styledJfxRadioButton()
20 |
21 | override fun JFXRadioButton.testDefaultValues() {
22 | assertNull(text)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/EllipseTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Ellipse
5 | import kotlin.test.assertEquals
6 |
7 | class EllipseTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = ellipse {}
13 |
14 | override fun KtfxPane.child2() = ellipse()
15 |
16 | override fun child3() = styledEllipse()
17 |
18 | override fun KtfxPane.child4() = styledEllipse()
19 |
20 | override fun Ellipse.testDefaultValues() {
21 | assertEquals(0.0, centerX)
22 | assertEquals(0.0, centerY)
23 | assertEquals(0.0, radiusX)
24 | assertEquals(0.0, radiusY)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ToolBarTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ToolBar
5 | import javafx.scene.layout.Region
6 | import kotlin.test.Test
7 | import kotlin.test.assertIs
8 |
9 | class ToolBarTest : LayoutsStyledTest() {
10 | override fun manager() = KtfxPane()
11 |
12 | override fun KtfxPane.childCount() = children.size
13 |
14 | override fun child1() = toolBar {}
15 |
16 | override fun KtfxPane.child2() = toolBar()
17 |
18 | override fun child3() = styledToolBar()
19 |
20 | override fun KtfxPane.child4() = styledToolBar()
21 |
22 | @Test
23 | fun add() {
24 | toolBar {
25 | region()
26 | assertIs(items.single())
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/RectangleTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Rectangle
5 | import kotlin.test.assertEquals
6 |
7 | class RectangleTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = rectangle {}
13 |
14 | override fun KtfxPane.child2() = rectangle()
15 |
16 | override fun child3() = styledRectangle()
17 |
18 | override fun KtfxPane.child4() = styledRectangle()
19 |
20 | override fun Rectangle.testDefaultValues() {
21 | assertEquals(0.0, x)
22 | assertEquals(0.0, y)
23 | assertEquals(0.0, width)
24 | assertEquals(0.0, height)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/HyperlinkLabelTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.HyperlinkLabel
6 | import kotlin.test.assertNull
7 |
8 | class HyperlinkLabelTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = hyperlinkLabel {}
14 |
15 | override fun KtfxPane.child2() = hyperlinkLabel()
16 |
17 | override fun child3() = styledHyperlinkLabel()
18 |
19 | override fun KtfxPane.child4() = styledHyperlinkLabel()
20 |
21 | override fun HyperlinkLabel.testDefaultValues() {
22 | assertNull(text)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxSpinnerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXSpinner
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertEquals
7 |
8 | class JfxSpinnerTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxSpinner {}
14 |
15 | override fun KtfxPane.child2() = jfxSpinner()
16 |
17 | override fun child3() = styledJfxSpinner()
18 |
19 | override fun KtfxPane.child4() = styledJfxSpinner()
20 |
21 | override fun JFXSpinner.testDefaultValues() {
22 | assertEquals(JFXSpinner.INDETERMINATE_PROGRESS, progress)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/dialogs/TextInputDialog.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalContracts::class)
2 |
3 | package ktfx.dialogs
4 |
5 | import javafx.scene.control.TextInputDialog
6 | import java.util.Optional
7 | import kotlin.contracts.ExperimentalContracts
8 | import kotlin.contracts.InvocationKind
9 | import kotlin.contracts.contract
10 |
11 | /**
12 | * Show a text input dialog.
13 | *
14 | * @param prefill default text.
15 | * @param configuration custom dialog action.
16 | * @return input text.
17 | */
18 | public inline fun textInputDialog(
19 | prefill: String = "",
20 | configuration: TextInputDialog.() -> Unit,
21 | ): Optional {
22 | contract { callsInPlace(configuration, InvocationKind.EXACTLY_ONCE) }
23 | return TextInputDialog(prefill)
24 | .apply(configuration)
25 | .showAndWait()
26 | }
27 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/Application.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("NOTHING_TO_INLINE")
2 |
3 | package ktfx
4 |
5 | import javafx.application.Application
6 | import javafx.application.HostServices
7 |
8 | /** Launch a JavaFX application with reified type. */
9 | public inline fun launchApplication(vararg args: String): Unit =
10 | Application.launch(T::class.java, *args)
11 |
12 | /**
13 | * Resolves the specified relative URI against the code base URI and returns the resolved URI.
14 | */
15 | public inline fun HostServices.resolveCodeUri(rel: String): String = resolveURI(codeBase, rel)
16 |
17 | /**
18 | * Resolves the specified relative URI against the document base URI and returns the resolved URI.
19 | */
20 | public inline fun HostServices.resolveDocumentUri(rel: String): String =
21 | resolveURI(documentBase, rel)
22 |
--------------------------------------------------------------------------------
/ktfx-commons/src/main/kotlin/ktfx/inputs/MouseEvent.kt:
--------------------------------------------------------------------------------
1 | package ktfx.inputs
2 |
3 | import javafx.scene.input.MouseButton
4 | import javafx.scene.input.MouseEvent
5 |
6 | /** Convenient method to check if mouse event is left click. */
7 | public fun MouseEvent.isLeftClick(): Boolean = button == MouseButton.PRIMARY && clickCount == 1
8 |
9 | /** Convenient method to check if mouse event is right click. */
10 | public fun MouseEvent.isRightClick(): Boolean = button == MouseButton.SECONDARY && clickCount == 1
11 |
12 | /** Convenient method to check if mouse event is middle click. */
13 | public fun MouseEvent.isMiddleClick(): Boolean = button == MouseButton.MIDDLE && clickCount == 1
14 |
15 | /** Convenient method to check if mouse event is double click. */
16 | public fun MouseEvent.isDoubleClick(): Boolean = button == MouseButton.PRIMARY && clickCount == 2
17 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/CustomMenuItemTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.CustomMenuItem
5 | import kotlin.test.assertNull
6 | import kotlin.test.assertTrue
7 |
8 | class CustomMenuItemTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxMenu("", null)
10 |
11 | override fun KtfxMenu.childCount() = items.size
12 |
13 | override fun child1() = customMenuItem {}
14 |
15 | override fun KtfxMenu.child2() = customMenuItem()
16 |
17 | override fun child3() = styledCustomMenuItem()
18 |
19 | override fun KtfxMenu.child4() = styledCustomMenuItem()
20 |
21 | override fun CustomMenuItem.testDefaultValues() {
22 | assertNull(content)
23 | assertTrue(isHideOnClick)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/CircleTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Circle
5 | import kotlin.test.assertEquals
6 | import kotlin.test.assertNull
7 |
8 | class CircleTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = circle {}
14 |
15 | override fun KtfxPane.child2() = circle()
16 |
17 | override fun child3() = styledCircle()
18 |
19 | override fun KtfxPane.child4() = styledCircle()
20 |
21 | override fun Circle.testDefaultValues() {
22 | assertEquals(0.0, centerX)
23 | assertEquals(0.0, centerY)
24 | assertEquals(0.0, radius)
25 | assertNull(fill)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxTreeViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXTreeView
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertNull
7 |
8 | class JfxTreeViewTest : LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxTreeView {}
14 |
15 | override fun KtfxPane.child2() = jfxTreeView()
16 |
17 | override fun child3() = styledJfxTreeView()
18 |
19 | override fun KtfxPane.child4() = styledJfxTreeView()
20 |
21 | override fun JFXTreeView.testDefaultValues() {
22 | assertNull(root)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-commons/src/test/kotlin/ktfx/controlsfx/controls/TextFieldsTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.controls
2 |
3 | import com.hanggrian.ktfx.test.initToolkit
4 | import javafx.scene.control.TextField
5 | import ktfx.text.buildStringConverter
6 | import kotlin.test.BeforeTest
7 | import kotlin.test.Test
8 |
9 | class TextFieldsTest {
10 | private lateinit var field: TextField
11 |
12 | @BeforeTest
13 | fun start() {
14 | initToolkit()
15 | field = TextField()
16 | }
17 |
18 | @Test
19 | fun bindAutoCompletion() {
20 | field.bindAutoCompletion("Hello", "World")
21 | field.bindAutoCompletion(listOf("Hello", "World"))
22 | field.bindAutoCompletion { listOf("Hello", "World") }
23 | field.bindAutoCompletion(buildStringConverter {}) { listOf("Hello", "World") }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/SplitPaneTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.SplitPane
5 | import javafx.scene.layout.Region
6 | import kotlin.test.Test
7 | import kotlin.test.assertIs
8 |
9 | class SplitPaneTest : LayoutsStyledTest() {
10 | override fun manager() = KtfxPane()
11 |
12 | override fun KtfxPane.childCount() = children.size
13 |
14 | override fun child1() = splitPane {}
15 |
16 | override fun KtfxPane.child2() = splitPane()
17 |
18 | override fun child3() = styledSplitPane()
19 |
20 | override fun KtfxPane.child4() = styledSplitPane()
21 |
22 | @Test
23 | fun add() {
24 | splitPane {
25 | region()
26 | assertIs(items.single())
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/PropertySheetTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import ktfx.layouts.KtfxPane
6 | import org.controlsfx.control.PropertySheet
7 |
8 | class PropertySheetTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = propertySheet {}
14 |
15 | override fun KtfxPane.child2() = propertySheet()
16 |
17 | override fun child3() = styledPropertySheet()
18 |
19 | override fun KtfxPane.child4() = styledPropertySheet()
20 |
21 | override fun PropertySheet.testDefaultValues() {
22 | assertThat(items).isEmpty()
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/codegen/src/main/kotlin/com/hanggrian/ktfx/codegen/Generator.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.codegen
2 |
3 | import com.hanggrian.ktfx.codegen.coroutines.ControlsFx
4 | import com.hanggrian.ktfx.codegen.coroutines.CoroutinesFactory
5 | import com.hanggrian.ktfx.codegen.coroutines.CoroutinesWriter
6 | import com.hanggrian.ktfx.codegen.coroutines.JFoenix
7 | import com.hanggrian.ktfx.codegen.coroutines.JavaFx
8 |
9 | object Generator {
10 | @JvmStatic
11 | fun main(args: Array) {
12 | // LayoutsWriter.write(LayoutsFactory.JavaFx)
13 | // LayoutsWriter.write(LayoutsFactory.ControlsFx)
14 | // LayoutsWriter.write(LayoutsFactory.JFoenix)
15 | CoroutinesWriter.write(CoroutinesFactory.JavaFx)
16 | CoroutinesWriter.write(CoroutinesFactory.ControlsFx)
17 | CoroutinesWriter.write(CoroutinesFactory.JFoenix)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/GridViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import ktfx.layouts.KtfxPane
6 | import org.controlsfx.control.GridView
7 |
8 | class GridViewTest : LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = gridView {}
14 |
15 | override fun KtfxPane.child2() = gridView()
16 |
17 | override fun child3() = styledGridView()
18 |
19 | override fun KtfxPane.child4() = styledGridView()
20 |
21 | override fun GridView.testDefaultValues() {
22 | assertThat(items).isEmpty()
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxDatePickerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXDatePicker
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.Ignore
7 | import kotlin.test.assertNull
8 |
9 | @Ignore
10 | class JfxDatePickerTest : LayoutsStyledTest() {
11 | override fun manager() = KtfxPane()
12 |
13 | override fun KtfxPane.childCount() = children.size
14 |
15 | override fun child1() = jfxDatePicker {}
16 |
17 | override fun KtfxPane.child2() = jfxDatePicker()
18 |
19 | override fun child3() = styledJfxDatePicker()
20 |
21 | override fun KtfxPane.child4() = styledJfxDatePicker()
22 |
23 | override fun JFXDatePicker.testDefaultValues() {
24 | assertNull(value)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxContextMenu.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.ContextMenu
8 | import javafx.scene.control.MenuItem
9 |
10 | /**
11 | * [ContextMenu] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxContextMenu :
15 | ContextMenu(),
16 | MenuItemContainer {
17 | final override fun addChild(child: T): T = child.also { items += it }
18 |
19 | /** Call [MenuItemContainer.menuItem] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker MenuItem).() -> Unit,
23 | ): MenuItem = menuItem(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxSliderTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXSlider
5 | import ktfx.layouts.KtfxPane
6 | import kotlin.test.assertEquals
7 |
8 | class JfxSliderTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxSlider {}
14 |
15 | override fun KtfxPane.child2() = jfxSlider()
16 |
17 | override fun child3() = styledJfxSlider()
18 |
19 | override fun KtfxPane.child4() = styledJfxSlider()
20 |
21 | override fun JFXSlider.testDefaultValues() {
22 | assertEquals(0.0, min)
23 | assertEquals(100.0, max)
24 | assertEquals(50.0, value)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ktfx-coroutines/src/test/kotlin/javafx/scene/media/MediaTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.coroutines
2 |
3 | import com.hanggrian.ktfx.test.testScene
4 | import javafx.scene.media.Media
5 | import javafx.stage.Stage
6 | import org.testfx.framework.junit.ApplicationTest
7 | import kotlin.test.Test
8 | import kotlin.test.assertTrue
9 |
10 | class MediaTest : ApplicationTest() {
11 | private lateinit var media: Media
12 |
13 | override fun start(stage: Stage) {
14 | stage.testScene()
15 | media = Media(javaClass.classLoader.getResource("sample.mp3")!!.toString())
16 | }
17 |
18 | @Test
19 | fun onError() {
20 | var assigned = false
21 | interact {
22 | media.onError {
23 | assigned = true
24 | }
25 | media.onError.run()
26 | }
27 | assertTrue(assigned)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxButtonBar.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.Button
8 | import javafx.scene.control.ButtonBar
9 |
10 | /**
11 | * [ButtonBar] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxButtonBar(buttonOrder: String?) :
15 | ButtonBar(buttonOrder),
16 | NodeContainer {
17 | final override fun addChild(child: T): T = child.also { buttons += it }
18 |
19 | /** Call [NodeContainer.button] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker Button).() -> Unit,
23 | ): Button = button(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxMenu.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.Menu
8 | import javafx.scene.control.MenuItem
9 |
10 | /**
11 | * [Menu] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxMenu(text: String, graphic: Node?) :
15 | Menu(text, graphic),
16 | MenuItemContainer {
17 | final override fun addChild(child: T): T = child.also { items += it }
18 |
19 | /** Call [MenuItemContainer.menuItem] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker MenuItem).() -> Unit,
23 | ): MenuItem = menuItem(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/ArcTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.shape.Arc
5 | import kotlin.test.assertEquals
6 |
7 | class ArcTest : LayoutsStyledTest() {
8 | override fun manager() = KtfxPane()
9 |
10 | override fun KtfxPane.childCount() = children.size
11 |
12 | override fun child1() = arc {}
13 |
14 | override fun KtfxPane.child2() = arc()
15 |
16 | override fun child3() = styledArc()
17 |
18 | override fun KtfxPane.child4() = styledArc()
19 |
20 | override fun Arc.testDefaultValues() {
21 | assertEquals(0.0, centerX)
22 | assertEquals(0.0, centerY)
23 | assertEquals(0.0, radiusX)
24 | assertEquals(0.0, radiusY)
25 | assertEquals(0.0, startAngle)
26 | assertEquals(0.0, length)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/shape/ArcToTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsTest
4 | import javafx.scene.shape.ArcTo
5 | import kotlin.test.assertEquals
6 | import kotlin.test.assertFalse
7 |
8 | class ArcToTest : LayoutsTest() {
9 | override fun manager() = KtfxPath()
10 |
11 | override fun KtfxPath.childCount() = elements.size
12 |
13 | override fun child1() = arcTo {}
14 |
15 | override fun KtfxPath.child2() = arcTo()
16 |
17 | override fun ArcTo.testDefaultValues() {
18 | assertEquals(0.0, radiusX)
19 | assertEquals(0.0, radiusY)
20 | assertEquals(0.0, xAxisRotation)
21 | assertEquals(0.0, radiusY)
22 | assertEquals(0.0, x)
23 | assertEquals(0.0, y)
24 | assertFalse(isLargeArcFlag)
25 | assertFalse(isSweepFlag)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-controlsfx-layouts/src/test/kotlin/ktfx/controlsfx/layouts/CheckTreeViewTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.controlsfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import ktfx.layouts.KtfxPane
5 | import org.controlsfx.control.CheckTreeView
6 | import kotlin.test.assertNull
7 |
8 | class CheckTreeViewTest : LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = checkTreeView {}
14 |
15 | override fun KtfxPane.child2() = checkTreeView()
16 |
17 | override fun child3() = styledCheckTreeView()
18 |
19 | override fun KtfxPane.child4() = styledCheckTreeView()
20 |
21 | override fun CheckTreeView.testDefaultValues() {
22 | assertNull(root)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxComboBoxTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.google.common.truth.Truth.assertThat
4 | import com.hanggrian.ktfx.test.LayoutsStyledTest
5 | import com.jfoenix.controls.JFXComboBox
6 | import ktfx.layouts.KtfxPane
7 |
8 | class JfxComboBoxTest : LayoutsStyledTest>() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = jfxComboBox {}
14 |
15 | override fun KtfxPane.child2() = jfxComboBox()
16 |
17 | override fun child3() = styledJfxComboBox()
18 |
19 | override fun KtfxPane.child4() = styledJfxComboBox()
20 |
21 | override fun JFXComboBox.testDefaultValues() {
22 | assertThat(items).isEmpty()
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ktfx-commons/src/test/kotlin/ktfx/inputs/ClipboardTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.inputs
2 |
3 | import com.hanggrian.ktfx.test.JavaFXThreadRule
4 | import javafx.scene.input.Clipboard
5 | import javafx.scene.input.DataFormat
6 | import org.junit.Rule
7 | import kotlin.test.BeforeTest
8 | import kotlin.test.Test
9 | import kotlin.test.assertEquals
10 | import kotlin.test.assertTrue
11 |
12 | class ClipboardTest {
13 | @Rule
14 | @JvmField
15 | var rule = JavaFXThreadRule()
16 | private lateinit var clipboard: Clipboard
17 |
18 | @BeforeTest
19 | fun start() {
20 | clipboard = Clipboard.getSystemClipboard()
21 | }
22 |
23 | @Test
24 | fun test() {
25 | clipboard[DataFormat.PLAIN_TEXT] = "Hello world"
26 | assertTrue(DataFormat.PLAIN_TEXT in clipboard)
27 | assertEquals("Hello world", clipboard[DataFormat.PLAIN_TEXT])
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/test/kotlin/javafx/scene/control/ProgressIndicatorTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import javafx.scene.control.ProgressBar
5 | import javafx.scene.control.ProgressIndicator
6 | import kotlin.test.assertEquals
7 |
8 | class ProgressIndicatorTest : LayoutsStyledTest() {
9 | override fun manager() = KtfxPane()
10 |
11 | override fun KtfxPane.childCount() = children.size
12 |
13 | override fun child1() = progressIndicator {}
14 |
15 | override fun KtfxPane.child2() = progressIndicator()
16 |
17 | override fun child3() = styledProgressIndicator()
18 |
19 | override fun KtfxPane.child4() = styledProgressIndicator()
20 |
21 | override fun ProgressIndicator.testDefaultValues() {
22 | assertEquals(ProgressBar.INDETERMINATE_PROGRESS, progress)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/thirdparty/ktfx-jfoenix-layouts/src/test/kotlin/ktfx/jfoenix/layouts/JfxColorPickerTest.kt:
--------------------------------------------------------------------------------
1 | package ktfx.jfoenix.layouts
2 |
3 | import com.hanggrian.ktfx.test.LayoutsStyledTest
4 | import com.jfoenix.controls.JFXColorPicker
5 | import javafx.scene.paint.Color
6 | import ktfx.layouts.KtfxPane
7 | import kotlin.test.assertEquals
8 |
9 | class JfxColorPickerTest : LayoutsStyledTest() {
10 | override fun manager() = KtfxPane()
11 |
12 | override fun KtfxPane.childCount() = children.size
13 |
14 | override fun child1() = jfxColorPicker {}
15 |
16 | override fun KtfxPane.child2() = jfxColorPicker()
17 |
18 | override fun child3() = styledJfxColorPicker()
19 |
20 | override fun KtfxPane.child4() = styledJfxColorPicker()
21 |
22 | override fun JFXColorPicker.testDefaultValues() {
23 | assertEquals(Color.WHITE, value)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ktfx-layouts/src/main/kotlin/javafx/scene/control/KtfxSplitMenuButton.kt:
--------------------------------------------------------------------------------
1 | @file:JvmMultifileClass
2 | @file:JvmName("KtfxLayoutsKt")
3 |
4 | package ktfx.layouts
5 |
6 | import javafx.scene.Node
7 | import javafx.scene.control.MenuItem
8 | import javafx.scene.control.SplitMenuButton
9 |
10 | /**
11 | * [SplitMenuButton] with dynamic-layout dsl support.
12 | * Invoking dsl will add its children.
13 | */
14 | public open class KtfxSplitMenuButton :
15 | SplitMenuButton(),
16 | MenuItemContainer {
17 | final override fun addChild(child: T): T = child.also { items += it }
18 |
19 | /** Call [MenuItemContainer.menuItem] by string invocation. */
20 | public inline operator fun String.invoke(
21 | graphic: Node? = null,
22 | configuration: (@KtfxLayoutDslMarker MenuItem).() -> Unit,
23 | ): MenuItem = menuItem(this, graphic, configuration)
24 | }
25 |
--------------------------------------------------------------------------------
/testing/commons/src/main/kotlin/com/hanggrian/ktfx/test/DialogShowingTest.kt:
--------------------------------------------------------------------------------
1 | package com.hanggrian.ktfx.test
2 |
3 | import javafx.scene.control.Dialog
4 | import javafx.scene.image.ImageView
5 | import javafx.scene.input.KeyCode
6 | import javafx.stage.Stage
7 | import org.testfx.framework.junit.ApplicationTest
8 |
9 | /**
10 | * Showing dialogs with [Dialog.showAndWait] forces the test to wait for user input.
11 | * Instead, quickly hit enter whenever dialogs are showing.
12 | */
13 | open class DialogShowingTest : ApplicationTest() {
14 | lateinit var stage: Stage
15 | lateinit var sampleGraphic: ImageView
16 |
17 | override fun start(stage: Stage) {
18 | this.stage = stage
19 | stage.testScene