Source:
private void initChangeChunkEngine(String engine) { chunkTypeLabel_.setText(engine); DOM.sinkEvents(chunkTypePanel_.getElement(), Event.ONCLICK); DOM.setEventListener(chunkTypePanel_.getElement(), new EventListener() { @Override public void onBrowserEvent(Event event) { if (DOM.eventGetType(event) == Event.ONCLICK) { Commands commands = RStudioGinjector.INSTANCE.getCommands(); String engineLabel = chunkTypeLabel_.getText(); final ToolbarPopupMenu switchChunksMenu = new ToolbarPopupMenu(); if (engineLabel != "r") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkR(), "r")); switchChunksMenu.addSeparator(); } if (!BrowseCap.isWindows() && engineLabel != "bash") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkBash(), "bash")); } if (engineLabel != "python") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkPython(), "python")); } if (engineLabel != "rcpp") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkRCPP(), "rcpp")); } if (engineLabel != "sql") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkSQL(), "sql")); } if (engineLabel != "stan") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkStan(), "stan")); } switchChunksMenu.setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { switchChunksMenu.setPopupPosition( chunkTypePanel_.getAbsoluteLeft() + chunkTypePanel_.getOffsetWidth() - offsetWidth + 15, chunkTypePanel_.getAbsoluteTop() + chunkTypePanel_.getOffsetHeight()); } }); } } }); }

Target:
private void initChangeChunkEngine(String engine) { chunkTypeLabel_.setText(engine); DOM.sinkEvents(chunkTypePanel_.getElement(), Event.ONCLICK); DOM.setEventListener(chunkTypePanel_.getElement(), new EventListener() { @Override public void onBrowserEvent(Event event) { if (DOM.eventGetType(event) == Event.ONCLICK) { Commands commands = RStudioGinjector.INSTANCE.getCommands(); String engineLabel = chunkTypeLabel_.getText(); final ToolbarPopupMenu switchChunksMenu = new ToolbarPopupMenu(); if (engineLabel != "r") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkR(), "r")); switchChunksMenu.addSeparator(); } if (!BrowseCap.isWindowsDesktop() && engineLabel != "bash") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkBash(), "bash")); } if (engineLabel != "python") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkPython(), "python")); } if (engineLabel != "rcpp") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkRCPP(), "rcpp")); } if (engineLabel != "sql") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkSQL(), "sql")); } if (engineLabel != "stan") { switchChunksMenu.addItem(createMenuItemForType( commands.switchToChunkStan(), "stan")); } switchChunksMenu.setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { switchChunksMenu.setPopupPosition( chunkTypePanel_.getAbsoluteLeft() + chunkTypePanel_.getOffsetWidth() - offsetWidth + 15, chunkTypePanel_.getAbsoluteTop() + chunkTypePanel_.getOffsetHeight()); } }); } } }); }