protected void createStyles() {
int index = this.alignmentBox.getSelectedIndex();
String value = this.alignmentBox.getValue(index);
Widget widget = getWidget();
if (widget instanceof HasHorizontalAlignment) {
HasHorizontalAlignment hw = (HasHorizontalAlignment) widget;
HorizontalAlignmentConstant align = null;
if (i18n.AlignLeft().equals(value)) {
align = HasHorizontalAlignment.ALIGN_LEFT;
} else if (i18n.AlignRight().equals(value)) {
align = HasHorizontalAlignment.ALIGN_RIGHT;
} else if (i18n.AlignCenter().equals(value)) {
align = HasHorizontalAlignment.ALIGN_CENTER;
} else if (i18n.AlignJustify().equals(value)) {
align = HasHorizontalAlignment.ALIGN_JUSTIFY;
}
Map<String, Object> dataSnapshot = new HashMap<String, Object>();
dataSnapshot.put("oldAlignment", hw.getHorizontalAlignment());
dataSnapshot.put("newAlignment", align);
dataSnapshot.put("hwidget", hw);
bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
@Override
public void onEvent(UndoableEvent event) { }
@Override
public void undoAction(UndoableEvent event) {
HorizontalAlignmentConstant oldAlignment = (HorizontalAlignmentConstant) event.getData("oldAlignment");
HasHorizontalAlignment hwidget = (HasHorizontalAlignment) event.getData("hwidget");
hwidget.setHorizontalAlignment(oldAlignment);
}
@Override
public void doAction(UndoableEvent event) {
HorizontalAlignmentConstant newAlignment = (HorizontalAlignmentConstant) event.getData("newAlignment");
HasHorizontalAlignment hwidget = (HasHorizontalAlignment) event.getData("hwidget");
hwidget.setHorizontalAlignment(newAlignment);
}
}));
}
}