setStyleName(closeButtonElement, "tab-close-button-hover", false);
}
});
}
final MenuBuilder menuBuilder = tabSpec.getMenuBuilder();
if (menuBuilder != null || showDefaultContextMenu) {
ContextMenuHandler handler = new ContextMenuHandler() {
public void onContextMenu(final com.google.gwt.dom.client.Element element, final int x, final int y) {
final MenuPopup menu = new MenuPopup(true);
if (showDefaultContextMenu) {
if (!isSelected()) {
menu.addItem("Select", new Command() {
public void execute() {
select();
}
}).setEnabled(enabled);
}
if (closeButtonElement != null) {
menu.addItem("Close", new Command() {
public void execute() {
handleOnClose();
}
}).setEnabled(enabled);
}
menu.addItem("Close Others", new Command() {
public void execute() {
handleCloseOthers();
}
}).setEnabled(enabled);
}
if (menuBuilder != null) {
if (showDefaultContextMenu) {
menu.addSeparator();
}
menuBuilder.build(menu.getMenu());
}
menu.setPopupPositionAndShow(new Popup.PositionCallback() {
public void setPosition(int offsetWidth, int offsetHeight) {
menu.setPopupPosition(element.getAbsoluteLeft() + x, element.getAbsoluteTop() + y);
}