From e4b5290e4898858612da882d9186b2aba548a9d9 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 27 Feb 2020 15:28:16 +0100 Subject: Remove deprecated methods. Style fixes. --- src/main/kotlin/pl/treksoft/kvision/core/Css.kt | 180 +-------------------- src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 24 +-- .../pl/treksoft/kvision/form/check/CheckBox.kt | 9 -- .../kotlin/pl/treksoft/kvision/form/check/Radio.kt | 9 -- .../kotlin/pl/treksoft/kvision/form/range/Range.kt | 9 -- .../treksoft/kvision/form/select/SimpleSelect.kt | 6 - .../pl/treksoft/kvision/form/text/AbstractText.kt | 6 - src/main/kotlin/pl/treksoft/kvision/types/Date.kt | 3 - 8 files changed, 3 insertions(+), 243 deletions(-) (limited to 'src/main/kotlin/pl') diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt index 66a0db36..e2108136 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt @@ -566,31 +566,6 @@ class Border( private val width: CssSize? = null, private val style: BorderStyle? = null, private val color: Color? = null ) { - /** - * Creates CSS Border with given width, style and color given in hex format. - * @param width width of the border - * @param style style of the border - * @param color color in hex format - */ - @Deprecated( - "Use primary constructor Border(CssSize?, BorderStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(width: CssSize? = null, style: BorderStyle? = null, color: Int) : this( - width, style, Color.hex(color) - ) - - /** - * Creates CSS Border with given width, style and color given with named constant. - * @param width width of the border - * @param style style of the border - * @param color color named constant - */ - @Deprecated( - "Use primary constructor Border(CssSize?, BorderStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(width: CssSize? = null, style: BorderStyle? = null, color: Col) : this(width, style, Color.name(color)) internal fun asString(): String { val w = width?.asString() @@ -602,21 +577,9 @@ class Border( /** * Type-safe definition of CSS color. + * @param color CSS color string */ -class Color private constructor(internal val color: String? = null) { - /** - * Creates CSS Color with color given in hex format. - * @param color color in hex format - */ - @Deprecated("Use Color.hex() function instead.", level = DeprecationLevel.WARNING) - constructor(color: Int) : this("#" + color.toHexString()) - - /** - * Creates CSS Color with color given with named constant. - * @param color color named constant - */ - @Deprecated("Use Color.name() function instead.", level = DeprecationLevel.WARNING) - constructor(color: Col) : this(color.color) +class Color(val color: String? = null) { fun asString(): String { return color.orEmpty() @@ -665,89 +628,6 @@ class Background( private val origin: BgOrigin? = null, private val clip: BgClip? = null, private val attachment: BgAttach? = null ) { - /** - * Creates CSS Background with given parameters. - * @param image background image - * @param positionX horizontal position of the background image - * @param positionY vertical position of the background image - * @param sizeX horizontal size of the background image - * @param sizeY vertical size of the background image - * @param size resize of the background image - * @param repeat repeat option of the background image - * @param origin origin option of the background image - * @param clip clipping option of the background image - * @param attachment attachment option of the background image - */ - @Deprecated( - "Use primary constructor Background(Color?, ResString?, ...) instead.", - level = DeprecationLevel.WARNING - ) - constructor( - image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BgSize? = null, - repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, - attachment: BgAttach? = null - ) : this( - null, - image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment - ) - - /** - * Creates CSS Background with given parameters. - * @param color color of the background in hex format - * @param image background image - * @param positionX horizontal position of the background image - * @param positionY vertical position of the background image - * @param sizeX horizontal size of the background image - * @param sizeY vertical size of the background image - * @param size resize of the background image - * @param repeat repeat option of the background image - * @param origin origin option of the background image - * @param clip clipping option of the background image - * @param attachment attachment option of the background image - */ - @Deprecated( - "Use primary constructor Background(Color?, ResString?, ...) instead.", - level = DeprecationLevel.WARNING - ) - constructor( - color: Int, image: ResString? = null, positionX: CssSize? = null, - positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BgSize? = null, - repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, - attachment: BgAttach? = null - ) : this( - Color.hex(color), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, - attachment - ) - - /** - * Creates CSS Background with given parameters. - * @param color color of the background with named constant - * @param image background image - * @param positionX horizontal position of the background image - * @param positionY vertical position of the background image - * @param sizeX horizontal size of the background image - * @param sizeY vertical size of the background image - * @param size resize of the background image - * @param repeat repeat option of the background image - * @param origin origin option of the background image - * @param clip clipping option of the background image - * @param attachment attachment option of the background image - */ - @Deprecated( - "Use primary constructor Background(Color?, ResString?, ...) instead.", - level = DeprecationLevel.WARNING - ) - constructor( - color: Col, image: ResString? = null, positionX: CssSize? = null, - positionY: CssSize? = null, sizeX: CssSize? = null, sizeY: CssSize? = null, - size: BgSize? = null, repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, - attachment: BgAttach? = null - ) : this( - Color.name(color), image, - positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment - ) internal fun asString(): String { val img = image?.let { @@ -780,33 +660,6 @@ class TextDecoration( private val line: TextDecorationLine? = null, private val style: TextDecorationStyle? = null, private val color: Color? = null ) { - /** - * Creates CSS text decoration with given line, style and color given in hex format. - * @param line text decoration line - * @param style text decoration style - * @param color color in hex format - */ - @Deprecated( - "Use primary constructor TextDecoration(TextDecorationLine?, TextDecorationStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(line: TextDecorationLine? = null, style: TextDecorationStyle? = null, color: Int) : this( - line, style, Color.hex(color) - ) - - /** - * Creates CSS text decoration with given line, style and color given with named constant. - * @param line text decoration line - * @param style text decoration style - * @param color color named constant - */ - @Deprecated( - "Use primary constructor TextDecoration(TextDecorationLine?, TextDecorationStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(line: TextDecorationLine? = null, style: TextDecorationStyle? = null, color: Col) : this( - line, style, Color.name(color) - ) internal fun asString(): String { return (line?.textDecorationLine).orEmpty() + " " + @@ -828,35 +681,6 @@ class TextShadow private constructor( private val hShadow: CssSize? = null, private val vShadow: CssSize? = null, private val blurRadius: CssSize? = null, private val color: Color? = null ) { - /** - * Creates CSS text shadow with given position and radius and color given in hex format. - * @param hShadow the position of horizontal shadow - * @param vShadow the position of vertical shadow - * @param blurRadius the blur radius - * @param color color in hex format - */ - @Deprecated( - "Use primary constructor TextDecoration(TextDecorationLine?, TextDecorationStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(hShadow: CssSize? = null, vShadow: CssSize? = null, blurRadius: CssSize? = null, color: Int) : this( - hShadow, vShadow, blurRadius, Color.hex(color) - ) - - /** - * Creates CSS text shadow with given position and radius and color given with named constant. - * @param hShadow the position of horizontal shadow - * @param vShadow the position of vertical shadow - * @param blurRadius the blur radius - * @param color color named constant - */ - @Deprecated( - "Use primary constructor TextDecoration(TextDecorationLine?, TextDecorationStyle?, Color?) instead.", - level = DeprecationLevel.WARNING - ) - constructor(hShadow: CssSize? = null, vShadow: CssSize? = null, blurRadius: CssSize? = null, color: Col) : this( - hShadow, vShadow, blurRadius, Color.name(color) - ) internal fun asString(): String { return (hShadow?.asString()).orEmpty() + " " + diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index 4dcb62e3..b74352d3 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -317,7 +317,7 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component * @suppress * Internal function */ - @Suppress("UNCHECKED_CAST") + @Suppress("UNCHECKED_CAST", "UnsafeCastFromDynamic") protected fun setInternalEventListener(block: SnOn.() -> Unit): Int { val handlerCounter = listenerCounter++ val blockAsWidget = block as SnOn.() -> Unit @@ -372,28 +372,6 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component return handlerCounter } - /** - * Sets an event listener for current widget. - * @param block event handler - * @return id of the handler - * - * Example: - * - * button.setEventListener { - * dblclick = { - * Alert.show("Button double clicked!") - * // self is of type Widget here - * } - * } - */ - @Deprecated( - "Use onEvent extension function instead.", - ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent") - ) - open fun setEventListener(block: SnOn.() -> Unit): Int { - return setEventListener(block) - } - /** * Removes event listener from current widget. * @param id the id of the handler returned by onEvent diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt index 7dae0f86..60147114 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -127,15 +127,6 @@ open class CheckBox( return input.setEventListener(block) } - @Deprecated( - "Use onEvent extension function instead.", - ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent") - ) - override fun setEventListener(block: SnOn.() -> Unit): Int { - @Suppress("DEPRECATION") - return input.setEventListener(block) - } - override fun removeEventListener(id: Int): Widget { input.removeEventListener(id) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt index 4d8a1607..b8757da2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -137,15 +137,6 @@ open class Radio( return input.setEventListener(block) } - @Deprecated( - "Use onEvent extension function instead.", - ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent") - ) - override fun setEventListener(block: SnOn.() -> Unit): Int { - @Suppress("DEPRECATION") - return input.setEventListener(block) - } - override fun removeEventListener(id: Int): Widget { input.removeEventListener(id) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/form/range/Range.kt b/src/main/kotlin/pl/treksoft/kvision/form/range/Range.kt index a03ce2c8..a54ccddb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/range/Range.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/range/Range.kt @@ -165,15 +165,6 @@ open class Range( return input.setEventListener(block) } - @Deprecated( - "Use onEvent extension function instead.", - ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent") - ) - override fun setEventListener(block: SnOn.() -> Unit): Int { - @Suppress("DEPRECATION") - return input.setEventListener(block) - } - override fun removeEventListener(id: Int): Widget { input.removeEventListener(id) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt index 97e61de3..4d47a239 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt @@ -141,12 +141,6 @@ open class SimpleSelect( return input.setEventListener(block) } - @Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent")) - override fun setEventListener(block: SnOn.() -> Unit): Int { - @Suppress("DEPRECATION") - return input.setEventListener(block) - } - override fun removeEventListener(id: Int): Widget { input.removeEventListener(id) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt index c7528cb1..d887e814 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt @@ -138,12 +138,6 @@ abstract class AbstractText(label: String? = null, rich: Boolean = false) : return input.setEventListener(block) } - @Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent")) - override fun setEventListener(block: SnOn.() -> Unit): Int { - @Suppress("DEPRECATION") - return input.setEventListener(block) - } - override fun removeEventListener(id: Int): Widget { input.removeEventListener(id) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index 9f601c25..889d26fc 100644 --- a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -31,9 +31,6 @@ import kotlin.js.Date const val KV_DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss" -@Deprecated("Not supported in KVision 2+. Use LocalDateTime or OffsetDateTime instead.", level = DeprecationLevel.ERROR) -actual typealias Date = Date - actual typealias LocalDateTime = Date actual typealias LocalDate = Date -- cgit