Skip to content
Merged
Changes from all 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")
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