Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
Row("From", List(fromPathText)),
Row("To", List(fileTextField, fileButton))
)
addToTableDialog(parentFrame, "Add path substitution...", rows, tblPathSubstitutions.addRow)
addToTableDialog(parentFrame, "Add Path Substitution...", rows, tblPathSubstitutions.addRow)
}

private val tblPathSubstitutions = new Table(0, 2) {
Expand All @@ -543,24 +543,20 @@ object CsvValidatorUi extends SimpleSwingApplication {
model.asInstanceOf[DefaultTableModel].addRow(rowData.asInstanceOf[Array[AnyRef]])
}

def removeSelectedRow() : Unit = {
model.asInstanceOf[DefaultTableModel].removeRow(peer.getSelectedRow)
def removeSelectedRows() : Unit = peer.getSelectedRows.zipWithIndex.foreach { case (row, index) =>
model.asInstanceOf[DefaultTableModel]removeRow(row - index) // when you delete a row, the index of next row to delete shifts down by 1
}

def pathSubstitutions : List[(String, String)] = {
for(rowIdx <- (0 to model.getRowCount - 1)) yield (model.getValueAt(rowIdx, 0).asInstanceOf[String], model.getValueAt(rowIdx, 1).asInstanceOf[String])
}.toList
}

private val popupMenu = new PopupMenu
private val miRemove = new MenuItem("Remove Path Substitution")
miRemove.reactions += onClick(tblPathSubstitutions.removeSelectedRow())
popupMenu.contents += miRemove
tblPathSubstitutions.popupMenu(popupMenu)

private val spTblPathSubstitutions = new ScrollPane(tblPathSubstitutions)
private val btnRemovePathSubstitution = new Button("Remove Path Substitution...")
Copy link
Contributor

@sparkhi sparkhi Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the ... from the text. The ellipsis in UI is a cue to user that there will be more input needed before the action is performed. In case of Removal, the action is performed as soon as the button is clicked so it should not have the ellipsis

I know, this rule is violated elsewhere in the UI (e.g. "save" button, which technically works like "save as...") but I think for new button addition we should do it correctly

private val btnAddPathSubstitution = new Button("Add Path Substitution...")

btnRemovePathSubstitution.reactions += onClick(tblPathSubstitutions.removeSelectedRows())
btnAddPathSubstitution.reactions += onClick(tablePathDialog())

private val settingsGroupLayout = new GridBagPanel {
Expand Down Expand Up @@ -605,6 +601,11 @@ object CsvValidatorUi extends SimpleSwingApplication {
c.gridwidth = 2
layout(spTblPathSubstitutions) = c

c.gridx = 0
c.gridy = 7
c.anchor = Anchor.LineStart
layout(btnRemovePathSubstitution) = c

c.gridx = 1
c.gridy = 7
c.anchor = Anchor.LastLineEnd
Expand Down
Loading