Skip to content

Commit d7c6e4d

Browse files
committed
refactored attributes names
1 parent 26bf5c0 commit d7c6e4d

1 file changed

Lines changed: 81 additions & 77 deletions

File tree

RubyScript/src/org/knime/ext/jruby/RubyScriptNodeDialog.scala

Lines changed: 81 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@ object RubyScriptNodeDialog {
4848
private var logger: NodeLogger = NodeLogger.getLogger(classOf[RubyScriptNodeDialog])
4949
}
5050

51-
class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extends NodeDialogPane() {
51+
class RubyScriptNodeDialog (private var factory: RubyScriptNodeFactory) extends NodeDialogPane() {
5252

53-
private var m_scriptPanel: JPanel = _
53+
private var scriptPanel: JPanel = _
5454

55-
private var m_scriptTextArea: RSyntaxTextArea = _
55+
private var scriptTextArea: RSyntaxTextArea = _
5656

57-
private var m_errorMessage: JTextArea = _
57+
private var errorMessage: JTextArea = _
5858

59-
private var m_sp_errorMessage: JScrollPane = _
59+
private var spErrorMessage: JScrollPane = _
6060

61-
private var m_table: JTable = _
61+
private var table: JTable = _
6262

63-
private var m_counter: Int = 1
63+
private var columnCounter: Int = 1
6464

65-
private var m_appendColsCB: JCheckBox = _
65+
private var doAppendInputColumns: JCheckBox = _
6666

67-
private var m_columnTables: Array[JTable] = _
67+
private var columnTables: Array[JTable] = _
6868

6969
createColumnSelectionTab()
7070

@@ -76,20 +76,20 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
7676
val outputButtonPanel = new JPanel()
7777
val outputMainPanel = new JPanel(new BorderLayout())
7878
val newtableCBPanel = new JPanel()
79-
m_appendColsCB = new JCheckBox("Append columns to input table spec")
80-
newtableCBPanel.add(m_appendColsCB, BorderLayout.WEST)
79+
doAppendInputColumns = new JCheckBox("Append columns to input table spec")
80+
newtableCBPanel.add(doAppendInputColumns, BorderLayout.WEST)
8181
val addButton = new JButton("Add Output Column")
8282
addButton.addActionListener(new ActionListener() {
8383

8484
def actionPerformed(e: ActionEvent) {
8585
var name: String = null
86-
val model = m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel]
86+
val model = table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel]
8787
val columns = model.getDataTableColumnNames
8888
var found: Boolean = false
8989
do {
9090
found = false
91-
name = "script output " + m_counter
92-
m_counter += 1
91+
name = "script output " + columnCounter
92+
columnCounter += 1
9393
for (s <- columns if name == s) {
9494
found = true
9595
//break
@@ -102,15 +102,15 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
102102
removeButton.addActionListener(new ActionListener() {
103103

104104
def actionPerformed(e: ActionEvent) {
105-
val selectedRows = m_table.getSelectedRows
105+
val selectedRows = table.getSelectedRows
106106
logger.debug("selectedRows = " + selectedRows)
107107
if (selectedRows.length == 0) {
108108
return
109109
}
110110
var i = selectedRows.length - 1
111111
while (i >= 0) {
112112
logger.debug(" removal " + i + ": removing row " + selectedRows(i))
113-
m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].removeRow(selectedRows(i))
113+
table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].removeRow(selectedRows(i))
114114
i -= 1
115115
}
116116
}
@@ -119,46 +119,50 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
119119
upButton.addActionListener(new ActionListener() {
120120

121121
def actionPerformed(e: ActionEvent) {
122-
val selectedRows = m_table.getSelectedRows
122+
val selectedRows = table.getSelectedRows
123123
logger.debug("selectedRows = " + selectedRows)
124124
if (selectedRows.length == 0) {
125125
return
126126
}
127-
m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].moveRowsUp(selectedRows)
127+
table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].moveRowsUp(selectedRows)
128128
}
129129
})
130130
val downButton = new JButton("Down")
131131
downButton.addActionListener(new ActionListener() {
132132

133133
def actionPerformed(e: ActionEvent) {
134-
val selectedRows = m_table.getSelectedRows
134+
val selectedRows = table.getSelectedRows
135135
logger.debug("selectedRows = " + selectedRows)
136136
if (selectedRows.length == 0) {
137137
return
138138
}
139-
m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].moveRowsDown(selectedRows)
139+
table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].moveRowsDown(selectedRows)
140140
}
141141
})
142-
outputButtonPanel.add(addButton)
143-
outputButtonPanel.add(removeButton)
144-
outputButtonPanel.add(Box.createHorizontalStrut(40))
145-
outputButtonPanel.add(upButton)
146-
outputButtonPanel.add(downButton)
147-
m_table = new JTable()
148-
m_table.putClientProperty("terminateEditOnFocusLost", true)
149-
m_table.setAutoscrolls(true)
142+
143+
Array(addButton, removeButton, Box.createHorizontalStrut(40),
144+
upButton, downButton).foreach(outputButtonPanel.add)
145+
146+
// outputButtonPanel.add(addButton)
147+
// outputButtonPanel.add(removeButton)
148+
// outputButtonPanel.add(Box.createHorizontalStrut(40))
149+
// outputButtonPanel.add(upButton)
150+
// outputButtonPanel.add(downButton)
151+
table = new JTable()
152+
table.putClientProperty("terminateEditOnFocusLost", true)
153+
table.setAutoscrolls(true)
150154
val model = new ScriptNodeOutputColumnsTableModel()
151155
model.addColumn("Column name")
152156
model.addColumn("Column type")
153-
model.addRow("script output " + m_counter, "String")
154-
m_counter += 1
155-
m_table.setModel(model)
156-
outputMainPanel.add(m_table.getTableHeader, BorderLayout.PAGE_START)
157-
outputMainPanel.add(m_table, BorderLayout.CENTER)
157+
model.addRow("script output " + columnCounter, "String")
158+
columnCounter += 1
159+
table.setModel(model)
160+
outputMainPanel.add(table.getTableHeader, BorderLayout.PAGE_START)
161+
outputMainPanel.add(table, BorderLayout.CENTER)
158162
outputPanel.add(newtableCBPanel)
159163
outputPanel.add(outputButtonPanel)
160164
outputPanel.add(outputMainPanel)
161-
val typeColumn = m_table.getColumnModel.getColumn(1)
165+
val typeColumn = table.getColumnModel.getColumn(1)
162166
val typeSelector = new JComboBox[String]()
163167
typeSelector.addItem("String")
164168
typeSelector.addItem("Integer")
@@ -169,19 +173,19 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
169173
}
170174

171175
private def createScriptTab() {
172-
m_errorMessage = new JTextArea()
173-
m_sp_errorMessage = new JScrollPane(m_errorMessage)
174-
m_scriptTextArea = new RSyntaxTextArea()
175-
m_scriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_RUBY)
176-
m_scriptTextArea.setCodeFoldingEnabled(true)
177-
m_scriptTextArea.setAntiAliasingEnabled(true)
178-
val spScript = new RTextScrollPane(m_scriptTextArea)
176+
errorMessage = new JTextArea()
177+
spErrorMessage = new JScrollPane(errorMessage)
178+
scriptTextArea = new RSyntaxTextArea()
179+
scriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_RUBY)
180+
scriptTextArea.setCodeFoldingEnabled(true)
181+
scriptTextArea.setAntiAliasingEnabled(true)
182+
val spScript = new RTextScrollPane(scriptTextArea)
179183
spScript.setFoldIndicatorEnabled(true)
180184
val font = new Font(Font.MONOSPACED, Font.PLAIN, 12)
181-
m_errorMessage.setFont(font)
182-
m_errorMessage.setForeground(Color.RED)
183-
m_errorMessage.setEditable(false)
184-
m_scriptPanel = new JPanel(new BorderLayout())
185+
errorMessage.setFont(font)
186+
errorMessage.setForeground(Color.RED)
187+
errorMessage.setEditable(false)
188+
scriptPanel = new JPanel(new BorderLayout())
185189
val scriptButtonPanel = new JPanel()
186190
val scriptButton = new JButton("Load Script from File")
187191
scriptButton.addActionListener(new ActionListener() {
@@ -209,17 +213,17 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
209213
} catch {
210214
case exc: IOException => exc.printStackTrace()
211215
}
212-
m_scriptTextArea.setText(buffer.toString)
216+
scriptTextArea.setText(buffer.toString)
213217
clearErrorHighlight()
214218
}
215219
})
216220
scriptButtonPanel.add(scriptButton)
217221
val scriptMainPanel = new JPanel(new BorderLayout())
218222
scriptMainPanel.add(new JLabel("Script: "), BorderLayout.NORTH)
219-
var splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, spScript, m_sp_errorMessage)
223+
var splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, spScript, spErrorMessage)
220224
scriptMainPanel.add(splitPane, BorderLayout.CENTER)
221-
val num = m_factory.getModel.getInputPortRoles.length
222-
m_columnTables = Array.ofDim[JTable](num)
225+
val num = factory.getModel.getInputPortRoles.length
226+
columnTables = Array.ofDim[JTable](num)
223227
val inputColumnsPanel = new JPanel()
224228
inputColumnsPanel.setLayout(new BoxLayout(inputColumnsPanel, BoxLayout.PAGE_AXIS))
225229
if (num > 0) inputColumnsPanel.setMinimumSize(new Dimension(20, 150))
@@ -229,9 +233,9 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
229233
val flowVariablesPanel = addFlowVariablesPane("Flow variables: ")
230234
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputColumnsPanel, flowVariablesPanel)
231235
splitPane.setDividerLocation(splitPane.getSize().height - splitPane.getInsets().bottom - splitPane.getDividerSize - 50)
232-
m_scriptPanel.add(scriptButtonPanel, BorderLayout.PAGE_START)
233-
m_scriptPanel.add(scriptMainPanel, BorderLayout.CENTER)
234-
val config_and_sript = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane, m_scriptPanel)
236+
scriptPanel.add(scriptButtonPanel, BorderLayout.PAGE_START)
237+
scriptPanel.add(scriptMainPanel, BorderLayout.CENTER)
238+
val config_and_sript = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane, scriptPanel)
235239
config_and_sript.setDividerLocation(200)
236240
addTab("Script", config_and_sript, false)
237241
}
@@ -260,7 +264,7 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
260264
if (name.length > 0) {
261265
name = name.replaceAll("[^\\p{Alnum}]", "_").replaceAll("\\_+", "_")
262266
if (name.charAt(name.length - 1) == '_') name = name.substring(0, name.length - 1)
263-
m_scriptTextArea.insert(TEMPLATE_COLUMN_NAME.format(m_index, name), m_scriptTextArea.getCaretPosition)
267+
scriptTextArea.insert(TEMPLATE_COLUMN_NAME.format(m_index, name), scriptTextArea.getCaretPosition)
264268
}
265269
}
266270
}
@@ -275,7 +279,7 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
275279
table.setFillsViewportHeight(true)
276280
panel.add(new JLabel(label), BorderLayout.NORTH)
277281
panel.add(scrollPane, BorderLayout.CENTER)
278-
m_columnTables(index) = table
282+
columnTables(index) = table
279283
panel
280284
}
281285

@@ -311,12 +315,12 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
311315
val p = event.getPoint
312316
val row = table.rowAtPoint(p)
313317
if (row >= 0) {
314-
m_scriptTextArea.insert(String.format(TEMPLATE_FLOW_VAR, table.getModel.getValueAt(row, 0).toString), m_scriptTextArea.getCaretPosition)
318+
scriptTextArea.insert(String.format(TEMPLATE_FLOW_VAR, table.getModel.getValueAt(row, 0).toString), scriptTextArea.getCaretPosition)
315319
}
316320
}
317321
}
318322
})
319-
val flow_variables = m_factory.getModel.getAvailableFlowVariables
323+
val flow_variables = factory.getModel.getAvailableFlowVariables
320324
var i = flow_variables.values.iterator()
321325
while (i.hasNext) {
322326
val `var` = i.next()
@@ -334,62 +338,62 @@ class RubyScriptNodeDialog (private var m_factory: RubyScriptNodeFactory) extend
334338
if (script == null) {
335339
script = ""
336340
}
337-
m_scriptTextArea.setText(script)
341+
scriptTextArea.setText(script)
338342
clearErrorHighlight()
339-
val error = m_factory.getModel.getErrorData
343+
val error = factory.getModel.getErrorData
340344
if (error.lineNum != -1) {
341345
try {
342-
m_scriptTextArea.addLineHighlight(error.lineNum - 1, Color.red)
346+
scriptTextArea.addLineHighlight(error.lineNum - 1, Color.red)
343347
} catch {
344348
case e1: BadLocationException =>
345349
}
346350
val outstr = new StringBuilder()
347351
outstr.append(error.text)
348352
outstr.append("\nline:\t class ( method )\t file\n")
349353
outstr.append(error.trace)
350-
m_errorMessage.setText(outstr.toString)
351-
m_sp_errorMessage.setVisible(true)
354+
errorMessage.setText(outstr.toString)
355+
spErrorMessage.setVisible(true)
352356
setSelected("Script")
353357
}
354358
val appendCols = settings.getBoolean(RubyScriptNodeModel.APPEND_COLS, true)
355-
m_appendColsCB.setSelected(appendCols)
359+
doAppendInputColumns.setSelected(appendCols)
356360
val dataTableColumnNames = settings.getStringArray(RubyScriptNodeModel.COLUMN_NAMES, Array.ofDim[String](0):_*)
357361
val dataTableColumnTypes = settings.getStringArray(RubyScriptNodeModel.COLUMN_TYPES, Array.ofDim[String](0):_*)
358-
m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].clearRows()
362+
table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].clearRows()
359363
if (dataTableColumnNames == null) {
360364
return
361365
}
362366
for (i <- 0 until dataTableColumnNames.length) {
363-
m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].addRow(dataTableColumnNames(i), dataTableColumnTypes(i))
367+
table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].addRow(dataTableColumnNames(i), dataTableColumnTypes(i))
364368
}
365369
updateColumnTable(specs)
366370
}
367371

368372
protected def saveSettingsTo(settings: NodeSettingsWO) {
369-
val editingRow = m_table.getEditingRow
370-
val editingColumn = m_table.getEditingColumn
373+
val editingRow = table.getEditingRow
374+
val editingColumn = table.getEditingColumn
371375
if (editingRow != -1 && editingColumn != -1) {
372-
val editor = m_table.getCellEditor(editingRow, editingColumn)
376+
val editor = table.getCellEditor(editingRow, editingColumn)
373377
editor.stopCellEditing()
374378
}
375-
val scriptSetting = m_scriptTextArea.getText
379+
val scriptSetting = scriptTextArea.getText
376380
if (scriptSetting == null || "" == scriptSetting) {
377381
throw new InvalidSettingsException("Please specify a script to be run.")
378382
}
379-
settings.addString(RubyScriptNodeModel.SCRIPT, m_scriptTextArea.getText)
380-
settings.addBoolean(RubyScriptNodeModel.APPEND_COLS, m_appendColsCB.isSelected)
381-
val columnNames = m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].getDataTableColumnNames
383+
settings.addString(RubyScriptNodeModel.SCRIPT, scriptTextArea.getText)
384+
settings.addBoolean(RubyScriptNodeModel.APPEND_COLS, doAppendInputColumns.isSelected)
385+
val columnNames = table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].getDataTableColumnNames
382386
settings.addStringArray(RubyScriptNodeModel.COLUMN_NAMES, columnNames:_*)
383-
val columnTypes = m_table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].getDataTableColumnTypes
387+
val columnTypes = table.getModel.asInstanceOf[ScriptNodeOutputColumnsTableModel].getDataTableColumnTypes
384388
settings.addStringArray(RubyScriptNodeModel.COLUMN_TYPES, columnTypes:_*)
385389
}
386390

387391
protected def clearErrorHighlight() {
388-
m_scriptTextArea.removeAllLineHighlights()
389-
m_sp_errorMessage.setVisible(false)
390-
m_errorMessage.setText("")
391-
m_scriptPanel.revalidate()
392-
m_scriptPanel.repaint()
392+
scriptTextArea.removeAllLineHighlights()
393+
spErrorMessage.setVisible(false)
394+
errorMessage.setText("")
395+
scriptPanel.revalidate()
396+
scriptPanel.repaint()
393397
}
394398

395399
/*

0 commit comments

Comments
 (0)