1717import java .io .File ;
1818import java .io .FileReader ;
1919import java .io .IOException ;
20+ import java .util .ArrayList ;
2021import java .util .Iterator ;
2122import java .util .List ;
2223import java .util .Map ;
@@ -68,6 +69,8 @@ public class RubyScriptNodeDialog extends NodeDialogPane {
6869 private JCheckBox m_appendColsCB ;
6970 private RubyScriptNodeFactory m_factory ;
7071
72+ private JTable m_columnTable ;
73+
7174 /**
7275 * New pane for configuring ScriptedNode node dialog.
7376 *
@@ -262,8 +265,7 @@ public void actionPerformed(final ActionEvent e) {
262265 scriptMainPanel .add (splitPane , BorderLayout .CENTER );
263266
264267 // add output column list
265- List <DataColumnSpec > list = m_factory .getModel ().getInputColumnList ();
266- JPanel inputColumnsPanel = addColumnPane ("Input[0] columns: " , list );
268+ JPanel inputColumnsPanel = addColumnPane ("Input[0] columns: " );
267269
268270 // add flow variables
269271 JPanel flowVariablesPanel = addFlowVariablesPane ("Flow variables: " );
@@ -296,7 +298,7 @@ public void actionPerformed(final ActionEvent e) {
296298 * @param list of columns
297299 * @return JPanel
298300 */
299- private final JPanel addColumnPane (String label , List < DataColumnSpec > list ) {
301+ private final JPanel addColumnPane (String label ) {
300302 JPanel panel = new JPanel (new BorderLayout ());
301303 JTable table = new JTable ();
302304 table .putClientProperty ("terminateEditOnFocusLost" , Boolean .TRUE );
@@ -311,23 +313,30 @@ private final JPanel addColumnPane(String label, List<DataColumnSpec> list) {
311313 model .setReadOnly (true );
312314 table .setModel (model );
313315
314- if (list != null ) {
315- for (Iterator <DataColumnSpec > i = list .iterator (); i .hasNext ();) {
316- DataColumnSpec spec = i .next ();
317- ((ScriptNodeOutputColumnsTableModel ) (table .getModel ()))
318- .addRow (spec .getName (), spec .getType ().toString ());
319- }
320- }
321316 JScrollPane scrollPane = new JScrollPane (table );
322317 table .setFillsViewportHeight (true );
323318
324319 panel .add (new JLabel (label ), BorderLayout .NORTH );
325320 // inputColumnsPanel.add(m_inpputColumnsTable.getTableHeader(),
326321 // BorderLayout.PAGE_START);
327322 panel .add (scrollPane , BorderLayout .CENTER );
323+ m_columnTable = table ;
328324 return panel ;
329325 }
330326
327+ private final void updateColumnTable (final DataTableSpec [] specs ) {
328+ if (specs != null && specs .length > 0 ) {
329+ ScriptNodeOutputColumnsTableModel model =
330+ (ScriptNodeOutputColumnsTableModel ) (m_columnTable .getModel ());
331+ model .clearRows ();
332+ for (Iterator <DataColumnSpec > item = specs [0 ].iterator (); item
333+ .hasNext ();) {
334+ DataColumnSpec spec = item .next ();
335+ model .addRow (spec .getName (), spec .getType ().toString ());
336+ }
337+ }
338+ }
339+
331340 /**
332341 * Creates a panel with flow variable list
333342 * @param label
@@ -430,6 +439,8 @@ protected final void loadSettingsFrom(final NodeSettingsRO settings,
430439 ((ScriptNodeOutputColumnsTableModel ) m_table .getModel ()).addRow (
431440 dataTableColumnNames [i ], dataTableColumnTypes [i ]);
432441 }
442+
443+ updateColumnTable (specs );
433444 }
434445
435446 /**
0 commit comments