$(self.element).trigger('resize');
     });
     
-    $('.buttontoolbarview-button', this.element).bind('click.buttontoolbarview', function() {
+    $('.buttontoolbarview-button', this.element).bind('click.buttontoolbarview', function(event) {
       var groupIndex = parseInt($(this).attr('ui:groupindex'), 10);
       var buttonIndex = parseInt($(this).attr('ui:buttonindex'), 10);
       var button = self.get('buttons')[groupIndex].buttons[buttonIndex];
       var scriptletId = button.scriptlet_id;
       var params = eval('(' + button.params + ')'); // To nie powinno być potrzebne
       console.log('Executing', scriptletId, 'with params', params);
-      scriptletCenter[scriptletId](self.parent, params);
+      scriptletCenter.scriptlets[scriptletId](self.parent, params);
     });
     
     $(this.element).trigger('resize');
 
         {% endfor %}
 
         _none: null
-    };
+    };   
             
 }
 
+ScriptletCenter.prototype.XMLEditorSelectedText = function(panel) {
+    return panel.contentView.editor.selection();
+}
+
+ScriptletCenter.prototype.XMLEditorReplaceSelectedText = function(panel, replacement)
+{
+    panel.contentView.editor.replaceSelection(replacement);
+    /* TODO: fire the change event */
+}
+
+ScriptletCenter.prototype.XMLEditorMoveCursorForward = function(panel, n) {
+    var pos = panel.contentView.editor.cursorPosition();
+    panel.contentView.editor.selectLines(pos.line, pos.character + n);
+}
+
 scriptletCenter = new ScriptletCenter();
\ No newline at end of file