return super.getItems().get(index);
}
@Override
public void add(Widget widget) {
addWidgetToCollection(widget);
final MenuItem menuItem = new MenuItem("Widget", (Command) null){
@Override
public void setSelectionStyle(boolean selected)
{
super.setSelectionStyle(selected);
if(VkMenuBarHorizontal.this.getAutoOpen() && getCommand() != null)
getCommand().execute();
}
};
this.addItem(menuItem);
final PopupPanel popupPanel = new PopupPanel() {
public void hide(boolean autoClosed) {
if(autoClosed) {
new Timer(){
@Override
public void run() {
lateHide();
}}.schedule(100);
} else
super.hide(autoClosed);
}
private void lateHide() {
if(!VkStateHelper.getInstance().getResizeHelper().isResizing())
super.hide(true);
}
};
popupPanel.add(widget);
if(widget instanceof IVkWidget)
((IVkWidget)widget).setVkParent(this);
popupPanel.setAutoHideEnabled(true);
popupPanel.addAutoHidePartner(menuItem.getElement());
menuItem.setCommand(new Command(){
@Override
public void execute() {
if(popupPanel.isShowing())
popupPanel.hide();
else {
popupPanel.showRelativeTo(menuItem);
DOM.setStyleAttribute(popupPanel.getElement(), "top", VkDesignerUtil.getOffsetTop(popupPanel.getElement()) + VkMenuBarHorizontal.this.getOffsetHeight() - menuItem.getOffsetHeight() + "");
popupPanel.show();
}
}});
}