menu.add(new SeparatorMenuItem());
} else if (w instanceof ToggleButton) {
final ToggleButton b = (ToggleButton) w;
final CheckMenuItem item = new CheckMenuItem(b.getText());
item.setItemId(b.getItemId());
item.setChecked(b.getValue());
if (b.getData("gxt-menutext") != null) {
item.setText(b.getData("gxt-menutext").toString());
}
item.setEnabled(b.isEnabled());
item.addCheckChangeHandler(new CheckChangeHandler<CheckMenuItem>() {
@Override
public void onCheckChange(CheckChangeEvent<CheckMenuItem> event) {
// must pass true to cause value change event to fire
b.setValue(event.getItem().isChecked(), true);