|
18 | 18 | import java.io.File; |
19 | 19 | import java.io.FileReader; |
20 | 20 | import java.io.IOException; |
21 | | -import java.util.ArrayList; |
22 | 21 | import java.util.Iterator; |
23 | | -import java.util.List; |
24 | 22 | import java.util.Map; |
25 | 23 |
|
26 | 24 | import javax.swing.AbstractAction; |
|
54 | 52 | public class RubyScriptNodeDialog extends NodeDialogPane { |
55 | 53 |
|
56 | 54 | private final static String TEMPLATE_FLOW_VAR = "FlowVariableList['%s'] "; |
| 55 | + // rules from knime.rb: |
| 56 | + // name = str.gsub(/[^[[:word:]]]/, '_').gsub(/\_+/, '_').chomp('_') |
| 57 | + // define_method("i#{i}_#{name}") where #{i} - index of the input port |
| 58 | + private final static String TEMPLATE_COLUMN_NAME = "i%d_%s "; |
57 | 59 |
|
58 | 60 | private static NodeLogger logger = NodeLogger |
59 | 61 | .getLogger(RubyScriptNodeDialog.class); |
@@ -324,6 +326,37 @@ private final JPanel addColumnPane(String label, int index) { |
324 | 326 | model.setReadOnly(true); |
325 | 327 | table.setModel(model); |
326 | 328 |
|
| 329 | + // dblclick on a table's row |
| 330 | + table.addMouseListener(new MouseAdapter() { |
| 331 | + private int m_index; |
| 332 | + public void mouseClicked(MouseEvent event) { |
| 333 | + if (event.getClickCount() == 2) { |
| 334 | + JTable table = (JTable) event.getSource(); |
| 335 | + Point p = event.getPoint(); |
| 336 | + int row = table.rowAtPoint(p); |
| 337 | + if (row >= 0) { |
| 338 | + String name = table.getModel().getValueAt(row, 0) |
| 339 | + .toString(); |
| 340 | + if (name.length() > 0) { |
| 341 | + // see knime.rb rules |
| 342 | + name = name.replaceAll("[^\\p{Alnum}]", "_") |
| 343 | + .replaceAll("\\_+", "_"); |
| 344 | + if (name.charAt(name.length() - 1) == '_') |
| 345 | + name = name.substring(0, name.length() - 1); |
| 346 | + |
| 347 | + m_scriptTextArea.insert(String.format( |
| 348 | + TEMPLATE_COLUMN_NAME, m_index, name), |
| 349 | + m_scriptTextArea.getCaretPosition()); |
| 350 | + } |
| 351 | + } |
| 352 | + } |
| 353 | + } |
| 354 | + private MouseAdapter init(int index){ |
| 355 | + m_index = index; |
| 356 | + return this; |
| 357 | + } |
| 358 | + }.init(index)); |
| 359 | + |
327 | 360 | JScrollPane scrollPane = new JScrollPane(table); |
328 | 361 | table.setFillsViewportHeight(true); |
329 | 362 |
|
|
0 commit comments