Skip to content

Commit

Permalink
IJMP-1609 Added check if the text field value matches the previous fi…
Browse files Browse the repository at this point in the history
…le name when renaming
  • Loading branch information
Katsiaryna Tsytsenia committed Apr 18, 2024
1 parent 6162706 commit 3587a87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import eu.ibagroup.formainframe.common.ui.StatefulComponent
import eu.ibagroup.formainframe.dataops.attributes.RemoteDatasetAttributes
import eu.ibagroup.formainframe.explorer.actions.DuplicateMemberAction
import eu.ibagroup.formainframe.explorer.actions.RenameAction
import eu.ibagroup.formainframe.utils.validateDatasetNameOnInput
import eu.ibagroup.formainframe.utils.validateForBlank
import eu.ibagroup.formainframe.utils.validateMemberName
import eu.ibagroup.formainframe.utils.validateUssFileName
import eu.ibagroup.formainframe.utils.validateUssFileNameAlreadyExists
import eu.ibagroup.formainframe.utils.*
import javax.swing.JComponent
import javax.swing.JTextField

Expand Down Expand Up @@ -83,6 +79,9 @@ class RenameDialog(
*/
private fun validateOnInput(component: JTextField): ValidationInfo? {
val attributes = selectedNodeData.attributes

validateForTheSameValue(attributes?.name, component)?.let { return it }

when (node) {
is LibraryNode, is FileLikeDatasetNode -> {
return if (attributes is RemoteDatasetAttributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ private val volserRegex = Regex("[A-Za-z0-9]{1,6}")
private val firstLetterRegex = Regex("[A-Z@\$#a-z]")
private val memberRegex = Regex("[A-Z@$#a-z][A-Z@#\$a-z0-9]{0,7}")

/**
* Validate text field for a match with the previous value
* @param prev of the current node
* @param component the component containing the invalid data
*/
fun validateForTheSameValue(prev: String?, component: JTextField): ValidationInfo? {
return if (component.text == prev) ValidationInfo("Field value matches the previous one", component) else null
}

/**
* Validate text field for blank value
Expand Down

0 comments on commit 3587a87

Please sign in to comment.