Search in sources :

Example 1 with SQLPresentationPanelDescriptor

use of org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor in project dbeaver by serge-rider.

the class SQLEditor method showExtraPresentation.

public void showExtraPresentation(boolean show, boolean maximize) {
    if (extraPresentationDescriptor == null) {
        return;
    }
    resultsSash.setRedraw(false);
    try {
        if (!show) {
            // boolean epHasFocus = UIUtils.hasFocus(getExtraPresentationControl());
            presentationSash.setMaximizedControl(presentationSash.getChildren()[SQL_EDITOR_CONTROL_INDEX]);
            // if (epHasFocus) {
            getEditorControlWrapper().setFocus();
        // }
        } else {
            if (extraPresentation == null) {
                // Lazy activation
                try {
                    extraPresentation = extraPresentationDescriptor.createPresentation();
                    extraPresentation.createPresentation((Composite) getExtraPresentationControl(), this);
                } catch (DBException e) {
                    log.error("Error creating presentation", e);
                }
            }
            if (maximize) {
                presentationSash.setMaximizedControl(getExtraPresentationControl());
                getExtraPresentationControl().setFocus();
            } else {
                presentationSash.setMaximizedControl(null);
            }
        }
        // Show presentation panels
        boolean sideBarChanged = false;
        if (getExtraPresentationState() == SQLEditorPresentation.ActivationType.HIDDEN) {
            // Remove all presentation panel toggles
            for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
                for (Control vb : presentationSwitchFolder.getChildren()) {
                    if (vb.getData() instanceof SQLPresentationPanelDescriptor) {
                        // || vb instanceof Label
                        vb.dispose();
                        sideBarChanged = true;
                    }
                }
            }
            // Close all panels
            for (CTabItem tabItem : resultTabs.getItems()) {
                if (tabItem.getData() instanceof SQLEditorPresentationPanel) {
                    tabItem.dispose();
                }
            }
            extraPresentationCurrentPanel = null;
        } else {
            // Check and add presentation panel toggles
            UIUtils.createEmptyLabel(presentationSwitchFolder, 1, 1).setLayoutData(new GridData(GridData.FILL_VERTICAL));
            for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
                removeToggleLayoutButton();
                sideBarChanged = true;
                PresentationPanelToggleAction toggleAction = new PresentationPanelToggleAction(panelDescriptor);
                VerticalButton panelButton = new VerticalButton(presentationSwitchFolder, SWT.RIGHT);
                panelButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
                panelButton.setAction(toggleAction, true);
                panelButton.setData(panelDescriptor);
                if (panelDescriptor.isAutoActivate()) {
                    // panelButton.setChecked(true);
                    toggleAction.run();
                }
                createToggleLayoutButton();
            }
        }
        boolean isExtra = getExtraPresentationState() == SQLEditorPresentation.ActivationType.MAXIMIZED;
        switchPresentationSQLButton.setChecked(!isExtra);
        switchPresentationExtraButton.setChecked(isExtra);
        presentationSwitchFolder.redraw();
        if (sideBarChanged) {
            sideToolBar.getParent().layout(true, true);
        }
    } finally {
        resultsSash.setRedraw(true);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) GridData(org.eclipse.swt.layout.GridData) SQLPresentationPanelDescriptor(org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 2 with SQLPresentationPanelDescriptor

use of org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor in project dbeaver by dbeaver.

the class SQLEditor method showExtraPresentation.

public void showExtraPresentation(boolean show, boolean maximize) {
    if (extraPresentationDescriptor == null) {
        return;
    }
    resultsSash.setRedraw(false);
    try {
        if (!show) {
            // boolean epHasFocus = UIUtils.hasFocus(getExtraPresentationControl());
            presentationSash.setMaximizedControl(presentationSash.getChildren()[SQL_EDITOR_CONTROL_INDEX]);
            // if (epHasFocus) {
            getEditorControlWrapper().setFocus();
        // }
        } else {
            if (extraPresentation == null) {
                // Lazy activation
                try {
                    extraPresentation = extraPresentationDescriptor.createPresentation();
                    extraPresentation.createPresentation((Composite) getExtraPresentationControl(), this);
                } catch (DBException e) {
                    log.error("Error creating presentation", e);
                }
            }
            if (maximize) {
                presentationSash.setMaximizedControl(getExtraPresentationControl());
                getExtraPresentationControl().setFocus();
            } else {
                presentationSash.setMaximizedControl(null);
            }
        }
        // Show presentation panels
        boolean sideBarChanged = false;
        if (getExtraPresentationState() == SQLEditorPresentation.ActivationType.HIDDEN) {
            // Remove all presentation panel toggles
            for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
                for (Control vb : presentationSwitchFolder.getChildren()) {
                    if (vb.getData() instanceof SQLPresentationPanelDescriptor) {
                        // || vb instanceof Label
                        vb.dispose();
                        sideBarChanged = true;
                    }
                }
            }
            // Close all panels
            for (CTabItem tabItem : resultTabs.getItems()) {
                if (tabItem.getData() instanceof SQLEditorPresentationPanel) {
                    tabItem.dispose();
                }
            }
            extraPresentationCurrentPanel = null;
        } else {
            // Check and add presentation panel toggles
            UIUtils.createEmptyLabel(presentationSwitchFolder, 1, 1).setLayoutData(new GridData(GridData.FILL_VERTICAL));
            for (SQLPresentationPanelDescriptor panelDescriptor : extraPresentationDescriptor.getPanels()) {
                removeToggleLayoutButton();
                sideBarChanged = true;
                PresentationPanelToggleAction toggleAction = new PresentationPanelToggleAction(panelDescriptor);
                VerticalButton panelButton = new VerticalButton(presentationSwitchFolder, SWT.RIGHT);
                panelButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
                panelButton.setAction(toggleAction, true);
                panelButton.setData(panelDescriptor);
                if (panelDescriptor.isAutoActivate()) {
                    // panelButton.setChecked(true);
                    toggleAction.run();
                }
                createToggleLayoutButton();
            }
        }
        boolean isExtra = getExtraPresentationState() == SQLEditorPresentation.ActivationType.MAXIMIZED;
        switchPresentationSQLButton.setChecked(!isExtra);
        switchPresentationExtraButton.setChecked(isExtra);
        presentationSwitchFolder.redraw();
        if (sideBarChanged) {
            sideToolBar.getParent().layout(true, true);
        }
    } finally {
        resultsSash.setRedraw(true);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) GridData(org.eclipse.swt.layout.GridData) SQLPresentationPanelDescriptor(org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor) CTabItem(org.eclipse.swt.custom.CTabItem)

Aggregations

CTabItem (org.eclipse.swt.custom.CTabItem)2 GridData (org.eclipse.swt.layout.GridData)2 DBException (org.jkiss.dbeaver.DBException)2 SQLPresentationPanelDescriptor (org.jkiss.dbeaver.ui.editors.sql.registry.SQLPresentationPanelDescriptor)2