99package org .knime .ext .jruby ;
1010
1111import java .awt .BorderLayout ;
12+ import java .awt .Color ;
1213import java .awt .Component ;
13- import java .awt .Font ;
1414import java .awt .event .*;
1515import java .io .BufferedReader ;
1616import java .io .File ;
2525import javax .swing .JFileChooser ;
2626import javax .swing .JLabel ;
2727import javax .swing .JPanel ;
28- import javax .swing .JScrollPane ;
2928import javax .swing .JTable ;
30- import javax .swing .JTextArea ;
3129import javax .swing .table .TableColumn ;
3230import javax .swing .table .TableCellEditor ;
31+ import javax .swing .text .BadLocationException ;
32+
3333import org .knime .core .data .DataTableSpec ;
3434import org .knime .core .node .*;
3535
36+ //import javax.swing.JScrollPane;
37+ //import javax.swing.JTextArea;
38+ //import java.awt.Font;
39+
40+ import org .fife .ui .rtextarea .*;
41+ import org .fife .ui .rsyntaxtextarea .*;
42+
43+
3644public class RubyScriptNodeDialog extends NodeDialogPane {
3745 private static NodeLogger logger = NodeLogger
3846 .getLogger (RubyScriptNodeDialog .class );
39- private JTextArea scriptTextArea = new JTextArea ();
47+ //private JTextArea scriptTextArea = new JTextArea();
48+ private RSyntaxTextArea m_scriptTextArea = new RSyntaxTextArea ();
49+
4050 private JTable table ;
4151 private int counter = 1 ;
4252 private JCheckBox m_appendColsCB ;
@@ -48,9 +58,15 @@ public class RubyScriptNodeDialog extends NodeDialogPane {
4858 protected RubyScriptNodeDialog () {
4959 super ();
5060
51- scriptTextArea .setAutoscrolls (true );
52- Font font = new Font (Font .MONOSPACED , Font .PLAIN , 12 );
53- scriptTextArea .setFont (font );
61+ //scriptTextArea.setAutoscrolls(true);
62+ //Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12);
63+ //scriptTextArea.setFont(font);
64+
65+ m_scriptTextArea .setSyntaxEditingStyle (SyntaxConstants .SYNTAX_STYLE_RUBY );
66+ m_scriptTextArea .setCodeFoldingEnabled (true );
67+ m_scriptTextArea .setAntiAliasingEnabled (true );
68+ RTextScrollPane spScript = new RTextScrollPane (m_scriptTextArea );
69+ spScript .setFoldIndicatorEnabled (true );
5470
5571 // construct the output column selection panel
5672 JPanel outputPanel = new JPanel ();
@@ -163,7 +179,7 @@ public void actionPerformed(final ActionEvent e) {
163179 exc .printStackTrace ();
164180 }
165181
166- scriptTextArea .setText (buffer .toString ());
182+ m_scriptTextArea .setText (buffer .toString ());
167183 }
168184 });
169185 scriptButton .setText ("Load Script from File" );
@@ -172,8 +188,11 @@ public void actionPerformed(final ActionEvent e) {
172188
173189 JPanel scriptMainPanel = new JPanel (new BorderLayout ());
174190 scriptMainPanel .add (new JLabel ("Script: " ), BorderLayout .NORTH );
175- scriptMainPanel .add (new JScrollPane (scriptTextArea ),
176- BorderLayout .CENTER );
191+
192+ //scriptMainPanel.add(new JScrollPane(scriptTextArea),
193+ // BorderLayout.CENTER);
194+
195+ scriptMainPanel .add (spScript , BorderLayout .CENTER );
177196
178197 scriptPanel .add (scriptButtonPanel , BorderLayout .PAGE_START );
179198 scriptPanel .add (scriptMainPanel , BorderLayout .CENTER );
@@ -191,7 +210,7 @@ protected final void loadSettingsFrom(final NodeSettingsRO settings,
191210 if (script == null ) {
192211 script = "" ;
193212 }
194- scriptTextArea .setText (script );
213+ m_scriptTextArea .setText (script );
195214
196215 boolean appendCols = settings .getBoolean (
197216 RubyScriptNodeModel .APPEND_COLS , true );
@@ -231,12 +250,12 @@ protected final void saveSettingsTo(final NodeSettingsWO settings)
231250 }
232251
233252 // save the settings
234- String scriptSetting = scriptTextArea .getText ();
253+ String scriptSetting = m_scriptTextArea .getText ();
235254 if (scriptSetting == null || "" .equals (scriptSetting )) {
236255 throw new InvalidSettingsException (
237256 "Please specify a script to be run." );
238257 }
239- settings .addString (RubyScriptNodeModel .SCRIPT , scriptTextArea .getText ());
258+ settings .addString (RubyScriptNodeModel .SCRIPT , m_scriptTextArea .getText ());
240259
241260 settings .addBoolean (RubyScriptNodeModel .APPEND_COLS ,
242261 m_appendColsCB .isSelected ());
0 commit comments