niedziela, 29 maja 2011

Adding more controls to RichTextItem / RichTextItem (SmartGWT)

Recently I had to extend RichTextItem - add another button on the toolbar. Since I am new to GWT and SmartGWT, I had to waste about 8 hours for those lines (and I hope that someone will find them useful!):

At first, extend RIchTextItem class. Next, create simple clikc handler:


private class MyButtonHandler implements Function
{

@Override
public void execute()
{
//handling code here
}
}


Next, in component's constructor add something like:



String [] myControls = {"myButton"};
JavaScriptObject myButtonProperties = JSOHelper.createObject();
JSOHelper.setAttribute(myButtonProperties, "title", "S");
JSOHelper.setAttribute(myButtonProperties, "prompt", "Prompt text");
MyButtonHandler myButtonHandler = new MyButtonHandler();
JSOHelper.setAttribute(myButtonProperties, "click", myButtonHandler);
this.setAttribute("myButtonProperties", myButtonProperties);
this.setAttribute("myControls", myControls);
this.setControlGroups("fontControls", "formatControls", "styleControls", "colorControls", "myControls");

1 komentarz:

  1. Nice, thanks.

    I am having to do this, and hopefully your post will save me lots of time!

    OdpowiedzUsuń