private void setContextMenu() {
Menu menu = new Menu();
MenuItem copy = new MenuItem();
copy.setTitle("Create copy");
copy.setIcon(Imgs.COPY_TAB.get());
copy.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
int tabNumber = ((QueryTabs) getTabSet()).getTabNumber(getTabObject().getID());
TabSettings tabSettings = (TabSettings) view.getSettings().getTabArray().get(tabNumber).clone();
tabSettings.setTabTitle("Copy of " + tabSettings.getTabTitle());
((QueryTabs) getTabSet()).addTab(tabSettings, true);
view.getSettings().addTabSettings(tabSettings);
}
});
MenuItem renameTab = new MenuItem();
renameTab.setTitle("Rename Tab");
renameTab.setIcon(Imgs.EDIT_TEXT.get());
renameTab.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
((QueryTabs) getTabSet()).editTabTitle(getTabObject());
}
});
MenuItem closeTab = new MenuItem();
closeTab.setTitle("Close");
closeTab.setIcon(Imgs.CLOSE_TAB_SINGLE.get());
closeTab.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
((QueryTabs) getTabSet()).removeAndPostProcessTab(getTabObject());
view.getHistory().setHistoryCheckpoint();
}
});
MenuItem closeOtherTabs = new MenuItem();
closeOtherTabs.setTitle("Close others");
closeOtherTabs.setIcon(Imgs.CLOSE_TAB_OTHERS.get());
closeOtherTabs.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
((QueryTabs) getTabSet()).removeAllExcept(getTabObject());
view.getHistory().setHistoryCheckpoint();
}
});
MenuItem closeAll = new MenuItem();
closeAll.setTitle("Close all");
closeAll.setIcon(Imgs.CLOSE_TAB_ALL.get());
closeAll.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
((QueryTabs) getTabSet()).removeAllTabs();
view.getHistory().setHistoryCheckpoint();