I have a GWT bootstrap 3 button as a ButtonCell created with IconType and ButtonType:
public abstract class ButtonColumn<T> extends Column<T, String> {
public ButtonColumn(IconType iconType, ButtonType buttonType) {
this(new ButtonCell(buttonType, iconType));
}
}
So when I create the button, I do
new ButtonColumn<Object>(IconType.PLAY, ButtonType.SUCCESS) {
@Override
public void onClick(Object obj) {
doStuff(obj);
}
};
I want to change my button IconType onClick. Is it possible to achieve it? And can I create a custom IconType extending the GWT IconType Enum? I wanted to put an animated icon (like a loading icon).
Well, you can not change the button's icon in a row, especially when you create the whole column with an icon already specified. But you can
redraw()a row and this could be a way to achieve what you want.I use AbstractCell to render a button and onBrowserEvent:
ClickEventinconsumedEventsparameterrender()method render a button based on the clicked stateonBrowserEvent()method change the clicked state and re-render the rowThe clicked state is best to be kept in the table's underlying data type so it is available for each row.
Here is a complete working example code:
And example table's data type keeping the clicked state:
As for extending the
IconTypeenum - no, you can not extend an enum in Java. See this question for example: Can enums be subclassed to add new elements?.You could try to add your own
CSSclass but this should be asked as another question to get precise answers.