super( new BorderLayout() );
this.model = model;
model.addPropertyChangeListener( this );
Settings settings = model.getSettings();
Font editorFont = UISupport.getEditorFont( settings );
editArea = new RSyntaxTextArea();
editArea.restoreDefaultSyntaxScheme();
String defaultScriptLanguage = ( ( WsdlProject )ModelSupport.getModelItemProject( model.getModelItem() ) )
.getDefaultScriptLanguage();
if( defaultScriptLanguage.equals( GroovyScriptEngineFactory.ID ) )
editArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_GROOVY );
else if( defaultScriptLanguage.equals( JsScriptEngineFactory.ID ) )
editArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT );
editArea.setBorder( BorderFactory.createMatteBorder( 0, 2, 0, 0, Color.WHITE ) );
editArea.setText( model.getScript() );
editArea.setCaretPosition( 0 );
editArea.setHighlightCurrentLine( false );
Action runAction = model.getRunAction();
if( runAction != null )
{
editArea.getInputMap().put( KeyStroke.getKeyStroke( "alt ENTER" ), "run-action" );
editArea.getActionMap().put( "run-action", runAction );
}
editArea.getInputMap().put( KeyStroke.getKeyStroke( "F3" ), "find-action" );
editArea.getInputMap().put( KeyStroke.getKeyStroke( "ctrl F" ), "find-action" );
RSyntaxTextAreaFindAndReplaceable findAndReplaceable = new RSyntaxTextAreaFindAndReplaceable();
editArea.getActionMap().put( "find-action", new FindAndReplaceDialog( findAndReplaceable ) );
groovyDocumentListener = new GroovyDocumentListener();
editArea.getDocument().addDocumentListener( groovyDocumentListener );
settingsListener = new InternalSettingsListener();
settings.addSettingsListener( settingsListener );
// scrollPane = new RTextScrollPane( 500, 300, editArea, true );
scrollPane = new RTextScrollPane( editArea, true );
scrollPane.setPreferredSize( new Dimension( 500, 300 ) );
add( scrollPane );
UISupport.addPreviewCorner( scrollPane, true );
addFocusListener( new FocusAdapter()
{
public void focusGained( FocusEvent e )
{
editArea.requestFocusInWindow();
}
} );
RSyntaxAreaPopupMenu popup = RSyntaxAreaPopupMenu.add( editArea );
popup.add( new FindAndReplaceDialog( findAndReplaceable ) );
popup.addSeparator();
popup.add( new GoToLineAction() );
toggleLineNumbersMenuItem = new JCheckBoxMenuItem( "Show Line Numbers", scrollPane.getLineNumbersEnabled() );
toggleLineNumbersMenuItem.setAccelerator( UISupport.getKeyStroke( "alt L" ) );
toggleLineNumbersMenuItem.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
enableLineNumbers( toggleLineNumbersMenuItem.isSelected() );
}
} );
editArea.getInputMap().put( KeyStroke.getKeyStroke( "alt L" ), new AbstractAction()
{
public void actionPerformed( ActionEvent e )
{
enableLineNumbers( !scrollPane.getLineNumbersEnabled() );
}
} );
popup.add( toggleLineNumbersMenuItem );
editArea.setPopupMenu( popup );
enableLineNumbers( settings.getBoolean( UISettings.SHOW_GROOVY_LINE_NUMBERS ) );
}