Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/galite-02GT'
Browse files Browse the repository at this point in the history
	- Fix calendar picker component : Force applying the changes added by the date picker component to the galite field model [APPS-02GT][PR#645]
  • Loading branch information
mgrati committed Nov 13, 2024
2 parents 76b9ea1 + 317f3d9 commit f1fff68
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ class VDateField(val bufferSize: Int) : VField(10, 1) {
* Sets the field value of given record to a date value.
*/
override fun setDate(r: Int, v: LocalDate?) {
if (isChangedUI
|| value[r] == null && v != null
|| value[r] != null && value[r]!! != v) {
if (isChangedUI || value[r] == null && v != null || value[r] != null && value[r]!! != v) {
// trails (backup) the record if necessary
trail(r)
// set value in the defined row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class DGridTextEditorField(

fun valueChanged(event: AbstractField.ComponentValueChangeEvent<GridEditorField<String>, String>) {
if (event.isFromClient) {
if (!getModel().hasFocus()) {
getModel().block!!.gotoField(getModel())
}
checkText(event.value.toString(), true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.kopi.galite.visual.ui.vaadin.form

import com.vaadin.flow.component.contextmenu.ContextMenu

import org.kopi.galite.visual.form.ModelTransformer
import org.kopi.galite.visual.form.UTextField
import org.kopi.galite.visual.form.VConstants
Expand All @@ -27,8 +29,6 @@ import org.kopi.galite.visual.Action
import org.kopi.galite.visual.VException
import org.kopi.galite.visual.VlibProperties

import com.vaadin.flow.component.contextmenu.ContextMenu

/**
* The `DTextField` is the vaadin implementation
* of the [UTextField] specifications.
Expand All @@ -40,11 +40,11 @@ import com.vaadin.flow.component.contextmenu.ContextMenu
* @param detail Does the field belongs to the detail view ?
*/
open class DTextField(
model: VFieldUI,
label: DLabel?,
align: Int,
options: Int,
detail: Boolean,
model: VFieldUI,
label: DLabel?,
align: Int,
options: Int,
detail: Boolean,
) : DField(model, label, align, options, detail), UTextField {

// --------------------------------------------------
Expand All @@ -60,20 +60,19 @@ open class DTextField(
init {
transformer = if (getModel().height == 1
|| !scanner && getModel().getTypeOptions() and VConstants.FDO_DYNAMIC_NL > 0) {
DefaultTransformer(getModel().width,
getModel().height)
DefaultTransformer(getModel().width, getModel().height)
} else if (!scanner) {
NewlineTransformer(
getModel().width,
getModel().height
)
NewlineTransformer(getModel().width, getModel().height)
} else {
ScannerTransformer(this)
}
field = createFieldGUI(options and VConstants.FDO_NOECHO != 0, scanner, align)

field.inputField.addTextValueChangeListener {
if (it.isFromClient) {
if (!getModel().hasFocus()) {
getModel().block!!.gotoField(getModel())
}
valueChanged()
}
}
Expand Down Expand Up @@ -383,55 +382,55 @@ open class DTextField(
* @return The converted string.
*/
private fun convertToSingleLine(source: String?, col: Int, row: Int): String =
buildString {
val length = source!!.length
var start = 0
while (start < length) {
var index = source.indexOf('\n', start)
if (index - start < col && index != -1) {
append(source.substring(start, index))
for (j in index - start until col) {
append(' ')
}
start = index + 1
if (start == length) {
// last line ends with a "new line" -> add an empty line
for (j in 0 until col) {
append(' ')
}
}
} else {
if (start + col >= length) {
append(source.substring(start, length))
for (j in length until start + col) {
append(' ')
}
start = length
} else {
// find white space to break line
var i = start + col - 1
while (i > start) {
if (Character.isWhitespace(source[i])) {
break
}
i--
}
index = if (i == start) {
start + col
} else {
i + 1
}
append(source.substring(start, index))
var j = (index - start) % col
while (j != 0 && j < col) {
append(' ')
j++
}
start = index
}
buildString {
val length = source!!.length
var start = 0
while (start < length) {
var index = source.indexOf('\n', start)
if (index - start < col && index != -1) {
append(source.substring(start, index))
for (j in index - start until col) {
append(' ')
}
start = index + 1
if (start == length) {
// last line ends with a "new line" -> add an empty line
for (j in 0 until col) {
append(' ')
}
}
} else {
if (start + col >= length) {
append(source.substring(start, length))
for (j in length until start + col) {
append(' ')
}
start = length
} else {
// find white space to break line
var i = start + col - 1
while (i > start) {
if (Character.isWhitespace(source[i])) {
break
}
i--
}
index = if (i == start) {
start + col
} else {
i + 1
}
append(source.substring(start, index))
var j = (index - start) % col
while (j != 0 && j < col) {
append(' ')
j++
}
start = index
}
}
}
}

/**
* Converts a given string to a fixed line string.
Expand Down

0 comments on commit f1fff68

Please sign in to comment.