private void createResultTabs() {
        resultTabs = new CTabFolder(resultsSash, SWT.TOP | SWT.FLAT) {
            // prevent eclipse from overriding this CTabFolder's css class
            @Override
            public void setBackground(Color color) {
                DBPDataSourceContainer dsContainer = getDataSourceContainer();
                Color bgColor = dsContainer != null ? UIUtils.getConnectionColor(dsContainer.getConnectionConfiguration()) : null;
                if (bgColor != null && !bgColor.equals(color)) {
                    UIUtils.asyncExec(() -> CSSUtils.setCSSClass(resultTabs, DBStyles.COLORED_BY_CONNECTION_TYPE));
                } else {
                    super.setBackground(color);
                }
            }
        };
        CSSUtils.setCSSClass(resultTabs, DBStyles.COLORED_BY_CONNECTION_TYPE);
        resultTabsReorder = new TabFolderReorder(resultTabs);
        resultTabs.setLayoutData(new GridData(GridData.FILL_BOTH));
        resultTabs.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (extraPresentationManager.activePresentationPanel != null) {
                    extraPresentationManager.activePresentationPanel.deactivatePanel();
                    extraPresentationManager.activePresentationPanel = null;
                }
                Object data = e.item.getData();
                if (data instanceof QueryResultsContainer qrc) {
                    setActiveResultsContainer(qrc);
                } else if (data instanceof SingleTabQueryProcessor stqp) {
                    setActiveResultsContainer(stqp.getFirstResults());
                } else if (data instanceof SQLEditorPresentationPanel pp) {
                    extraPresentationManager.activePresentationPanel = pp;
                    extraPresentationManager.activePresentationPanel.activatePanel();
                } else if (data instanceof ExplainPlanViewer epv) {
                    SQLQuery planQuery = epv.getQuery();
                    if (planQuery != null) {
                        getSelectionProvider().setSelection(new TextSelection(planQuery.getOffset(), 0));
                    }
                }
            }
        });
        this.addSashRatioSaveListener(resultsSash, SQLPreferenceConstants.RESULTS_PANEL_RATIO);
        this.resultTabs.addListener(TabFolderReorder.ITEM_MOVE_EVENT, event -> {
            CTabItem item = (CTabItem) event.item;
            if (item.getData() instanceof MultiTabsQueryResultsContainer qrc) {
                qrc.resultsTab = item;
            }
            if (item.getData() instanceof SingleTabQueryProcessor stqp) {
                stqp.resultsTab = item;
            }
        });
        restoreSashRatio(resultsSash, SQLPreferenceConstants.RESULTS_PANEL_RATIO);

        TextViewer textViewer = getTextViewer();
        if (textViewer != null) {
            textViewer.getTextWidget().addTraverseListener(e -> {
                if (e.detail == SWT.TRAVERSE_TAB_NEXT && e.stateMask == SWT.MOD1) {
                    ResultSetViewer viewer = getActiveResultSetViewer();
                    if (viewer != null && viewer.getActivePresentation().getControl().isVisible()) {
                        viewer.getActivePresentation().getControl().setFocus();
                        e.detail = SWT.TRAVERSE_NONE;
                    }
                }
            });
        }
        resultTabs.setSimple(true);
        resultTabs.setFont(JFaceResources.getFont(UIFonts.DBEAVER_FONTS_MAIN_FONT));

        resultTabs.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseUp(MouseEvent e) {
                if (e.button == 2) {
                    CTabItem item = resultTabs.getItem(new Point(e.x, e.y));
                    if (item != null && item.getShowClose()) {
                        item.dispose();
                    }
                }
            }
        });
        resultTabs.addListener(SWT.MouseDoubleClick, event -> {
            if (event.button != 1) {
                return;
            }
            CTabItem selectedItem = resultTabs.getItem(new Point(event.getBounds().x, event.getBounds().y));
            if (selectedItem != null && selectedItem  == resultTabs.getSelection()) {
                toggleEditorMaximize();
            }
        });

        // Extra views
        createExtraViewControls();

        // Create results tab
        createQueryProcessor(true, true, true);
        if (isHideQueryText()) {
            resultsSash.setMaximizedControl(resultTabs);
        } else {
            resultsSash.setMaximizedControl(sqlEditorPanel);
        }

        {
            resultTabs.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
                    activeResultsTab = resultTabs.getItem(new Point(e.x, e.y));
                }
            });
            MenuManager menuMgr = new MenuManager();
            Menu menu = menuMgr.createContextMenu(resultTabs);
            menuMgr.addMenuListener(manager -> {
                final CTabItem activeTab = getActiveResultsTab();
                boolean activeTabHasSingleResult = activeTab != null && activeTab.getData() instanceof QueryResultsContainer;
                boolean activeTabHasMultipleResults = activeTab != null && activeTab.getData() instanceof SingleTabQueryProcessor;
                if (activeTabHasSingleResult || activeTabHasMultipleResults) {
                    int pinnedTabsCount = 0;
                    int resultTabsCount = 0;

                    for (CTabItem item : resultTabs.getItems()) {
                        if (item.getData() instanceof QueryProcessingComponent) {
                            resultTabsCount++;
                            if (item.getData() instanceof QueryResultsContainer && ((QueryResultsContainer) item.getData()).isPinned()) {
                                pinnedTabsCount++;
                            }
                        }
                    }

                    if (activeTab.getShowClose()) {
                        manager.add(ActionUtils.makeCommandContribution(getSite(), SQLEditorCommands.CMD_SQL_EDITOR_CLOSE_TAB));

                        if (resultTabsCount - pinnedTabsCount > 1) {
                            manager.add(new Action(SQLEditorMessages.action_result_tabs_close_all_tabs) {
                                @Override
                                public void run() {
                                    closeExtraResultTabs(null, false, false);
                                }
                            });

                            if (activeTabHasSingleResult) {
                                manager.add(new Action(SQLEditorMessages.action_result_tabs_close_query_tabs) {
                                    @Override
                                    public void run() {
                                        final QueryProcessor processor = ((QueryResultsContainer) activeTab.getData()).queryProcessor;
                                        final List<CTabItem> tabs = new ArrayList<>();
                                        for (QueryResultsContainer container : processor.getResultContainers()) {
                                            if (!container.isPinned() && container.queryProcessor == processor) {
                                                tabs.add(container.getResultsTab());
                                            }
                                        }
                                        for (CTabItem tab : tabs) {
                                            tab.dispose();
                                        }
                                    }
                                });
                            }

                            manager.add(new Action(SQLEditorMessages.action_result_tabs_close_other_tabs) {
                                @Override
                                public void run() {
                                    final List<CTabItem> tabs = new ArrayList<>();
                                    for (CTabItem tab : resultTabs.getItems()) {
                                        if (tab.getShowClose() && tab != activeTab && !isPinned(tab)) {
                                            tabs.add(tab);
                                        }
                                    }
                                    for (CTabItem tab : tabs) {
                                        tab.dispose();
                                    }
                                    if (activeTabHasSingleResult) {
                                        setActiveResultsContainer((QueryResultsContainer) activeTab.getData());
                                    }
                                    if (activeTabHasMultipleResults) {
                                        setActiveResultsContainer(((SingleTabQueryProcessor) activeTab.getData()).getFirstResults());
                                    }
                                }
                            });

                            if (resultTabs.indexOf(activeTab) - pinnedTabsCount > 0) {
                                manager.add(new Action(SQLEditorMessages.action_result_tabs_close_tabs_to_the_left) {
                                    @Override
                                    public void run() {
                                        final List<CTabItem> tabs = new ArrayList<>();
                                        for (int i = 0, last = resultTabs.indexOf(activeTab); i < last; i++) {
                                            CTabItem tab = resultTabs.getItem(i);
                                            if (!isPinned(tab)) {
                                                tabs.add(tab);
                                            }
                                        }
                                        for (CTabItem tab : tabs) {
                                            tab.dispose();
                                        }
                                    }
                                });
                            }

                            if (resultTabs.indexOf(activeTab) < resultTabsCount - pinnedTabsCount - 1) {
                                manager.add(new Action(SQLEditorMessages.action_result_tabs_close_tabs_to_the_right) {
                                    @Override
                                    public void run() {
                                        final List<CTabItem> tabs = new ArrayList<>();
                                        for (int i = resultTabs.indexOf(activeTab) + 1; i < resultTabs.getItemCount(); i++) {
                                            CTabItem tab = resultTabs.getItem(i);
                                            if (!isPinned(tab)) {
                                                tabs.add(tab);
                                            }
                                        }
                                        for (CTabItem tab : tabs) {
                                            tab.dispose();
                                        }
                                    }
                                });
                            }
                        }
                    }

                    final QueryResultsContainer container = activeTabHasSingleResult ? (QueryResultsContainer) activeTab.getData() : null;
                    if (container != null && container.hasData()) {
                        final boolean isPinned = container.isPinned();

                        manager.add(new Separator());
                        manager.add(ActionUtils.makeCommandContribution(getSite(), SQLEditorCommands.CMD_SQL_EDITOR_TOGGLE_TAB_PINNED));

                        if (isPinned && pinnedTabsCount > 1) {
                            manager.add(new Action(SQLEditorMessages.action_result_tabs_unpin_all_tabs) {
                                @Override
                                public void run() {
                                    for (CTabItem item : resultTabs.getItems()) {
                                        if (item.getData() instanceof QueryResultsContainer) {
                                            if (((QueryResultsContainer) item.getData()).isPinned()) {
                                                ((QueryResultsContainer) item.getData()).setPinned(false);
                                            }
                                        }
                                    }
                                }
                            });
                        }

                        manager.add(new Action(SQLEditorMessages.action_result_tabs_set_name) {
                            @Override
                            public void run() {
                                EnterNameDialog dialog = new EnterNameDialog(resultTabs.getShell(), SQLEditorMessages.action_result_tabs_set_name_title, activeTab.getText());
                                if (dialog.open() == IDialogConstants.OK_ID) {
                                    container.setTabName(dialog.getResult());
                                }
                            }
                        });

                        if (!container.isStatistics()) {
                            manager.add(new Action(SQLEditorMessages.action_result_tabs_detach_tab) {
                                @Override
                                public void run() {
                                    container.detach();
                                }
                            });
                        }

                        if (container.getQuery() != null) {
                            manager.add(new Separator());
                            AssignVariableAction action = new AssignVariableAction(SQLEditor.this, container.getQuery().getText());
                            action.setEditable(false);
                            manager.add(action);
                        }
                    }
                }
                manager.add(new Separator());
                manager.add(ActionUtils.makeCommandContribution(getSite(), SQLEditorCommands.CMD_SQL_EDITOR_MAXIMIZE_PANEL));
            });
            menuMgr.setRemoveAllWhenShown(true);
            resultTabs.setMenu(menu);
        }
    }
Changes mode of showing result for script execution - multiple results per tab or one tab per result.
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java