Skip to content

Commit 929d1f2

Browse files
author
Uladzislau Kalesnikau
committed
Merge branch 'bugfix/IJMP-1685' into 'release/v1.2.3-221'
IJMP-1685 Changed validation for LRECL field See merge request ijmp/for-mainframe!575
2 parents 5e0e324 + 4961068 commit 929d1f2

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/main/kotlin/eu/ibagroup/formainframe/explorer/ui/AllocationDialog.kt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ class AllocationDialog(project: Project?, config: ConnectionConfig, override var
5454
private lateinit var advancedParametersField: JTextField
5555
private lateinit var presetsBox: JComboBox<Presets>
5656
private val HLQ = getUsername(config)
57+
private val nonNegativeIntRange = IntRange(0, Int.MAX_VALUE - 1)
58+
private val positiveIntRange = IntRange(1, Int.MAX_VALUE - 1)
5759

5860
private val mainPanel by lazy {
5961
val sameWidthLabelsGroup = "ALLOCATION_DIALOG_LABELS_WIDTH_GROUP"
6062
val sameWidthComboBoxGroup = "ALLOCATION_DIALOG_COMBO_BOX_WIDTH_GROUP"
61-
val nonNegativeIntRange = IntRange(0, Int.MAX_VALUE - 1)
62-
val positiveIntRange = IntRange(1, Int.MAX_VALUE - 1)
6363

6464
panel {
6565
row {
@@ -199,7 +199,7 @@ class AllocationDialog(project: Project?, config: ConnectionConfig, override var
199199
row {
200200
label("Record Length: ")
201201
.widthGroup(sameWidthLabelsGroup)
202-
intTextField(positiveIntRange)
202+
intTextField(nonNegativeIntRange)
203203
.bindText(
204204
{ state.allocationParameters.recordLength?.toString() ?: "0" },
205205
{ state.allocationParameters.recordLength = it.toIntOrNull() }
@@ -334,6 +334,7 @@ class AllocationDialog(project: Project?, config: ConnectionConfig, override var
334334
return validateDatasetNameOnInput(datasetNameField)
335335
?: validateForBlank(memberNameField)
336336
?: validateMemberName(memberNameField)
337+
?: validateLrecl(recordFormatBox, recordLengthField)
337338
?: defaultValidationInfos.firstOrNull()
338339
?: validateVolser(advancedParametersField)
339340
}
@@ -342,6 +343,26 @@ class AllocationDialog(project: Project?, config: ConnectionConfig, override var
342343
return mainPanel.preferredFocusedComponent ?: super.getPreferredFocusedComponent()
343344
}
344345

346+
/**
347+
* Function for validating LRECL value
348+
* @param recordFormatBox RecordFormat combo box
349+
* @param recordLengthField record length text field
350+
* @return ValidationInfo in case of error or null otherwise
351+
*/
352+
private fun validateLrecl(recordFormatBox: JComboBox<RecordFormat>, recordLengthField: JTextField): ValidationInfo? {
353+
val range = if (recordFormatBox.selectedItem == RecordFormat.U)
354+
nonNegativeIntRange
355+
else
356+
positiveIntRange
357+
return if (recordLengthField.text.toIntOrNull() !in range)
358+
ValidationInfo(
359+
"Please enter a number from ${range.first} to ${range.last}",
360+
recordLengthField
361+
)
362+
else
363+
null
364+
}
365+
345366
init {
346367
title = "Allocate Dataset"
347368
init()

0 commit comments

Comments
 (0)