Search in sources :

Example 6 with ResultSetPanelDescriptor

use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by dbeaver.

the class ResultSetPresentationRegistry method getSupportedPanels.

public List<ResultSetPanelDescriptor> getSupportedPanels(IResultSetContext context, DBPDataSource dataSource, String presentationId, IResultSetPresentation.PresentationType presentationType) {
    List<ResultSetPanelDescriptor> result = new ArrayList<>();
    for (ResultSetPanelDescriptor panel : panels) {
        if (panel.supportedBy(context, dataSource, presentationId, presentationType)) {
            result.add(panel);
        }
    }
    result.sort(Comparator.comparing(ResultSetPanelDescriptor::getLabel));
    return result;
}
Also used : ArrayList(java.util.ArrayList) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)

Example 7 with ResultSetPanelDescriptor

use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.

the class ResultSetViewer method fillPanelsMenu.

private List<IContributionItem> fillPanelsMenu() {
    List<IContributionItem> items = new ArrayList<>();
    for (final ResultSetPanelDescriptor panel : availablePanels) {
        CommandContributionItemParameter params = new CommandContributionItemParameter(site, panel.getId(), ResultSetHandlerTogglePanel.CMD_TOGGLE_PANEL, CommandContributionItem.STYLE_CHECK);
        Map<String, String> parameters = new HashMap<>();
        parameters.put(ResultSetHandlerTogglePanel.PARAM_PANEL_ID, panel.getId());
        params.parameters = parameters;
        items.add(new CommandContributionItem(params));
    }
    items.add(new Separator());
    // if (viewerSash.getMaximizedControl() == null) {
    // items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_LAYOUT));
    // }
    items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_MAXIMIZE));
    // items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_PANELS));
    items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ACTIVATE_PANELS));
    return items;
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)

Example 8 with ResultSetPanelDescriptor

use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.

the class ResultSetViewer method updatePanelsButtons.

private void updatePanelsButtons() {
    boolean panelsVisible = isPanelsVisible();
    for (Control child : panelSwitchFolder.getChildren()) {
        if (child instanceof VerticalButton && child.getData() instanceof ResultSetPanelDescriptor) {
            boolean newChecked = panelsVisible && isPanelVisible(((ResultSetPanelDescriptor) child.getData()).getId());
            if (((VerticalButton) child).isChecked() != newChecked) {
                ((VerticalButton) child).setChecked(newChecked);
                child.redraw();
            }
        }
    }
}
Also used : AutoRefreshControl(org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl) VerticalButton(org.jkiss.dbeaver.ui.controls.VerticalButton) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)

Example 9 with ResultSetPanelDescriptor

use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.

the class ResultSetViewer method activatePanel.

@Override
public boolean activatePanel(String id, boolean setActive, boolean showPanels) {
    if (!supportsPanels()) {
        return false;
    }
    if (showPanels && !isPanelsVisible()) {
        showPanels(true, false, false);
    }
    PresentationSettings presentationSettings = getPresentationSettings();
    IResultSetPanel panel = activePanels.get(id);
    if (panel != null) {
        CTabItem panelTab = getPanelTab(id);
        if (panelTab != null) {
            if (setActive) {
                panelFolder.setSelection(panelTab);
                presentationSettings.activePanelId = id;
                if (showPanels) {
                    panel.setFocus();
                }
            // panelTab.getControl().setFocus();
            }
            return true;
        } else {
            log.debug("Panel '" + id + "' tab not found");
        }
    }
    // Create panel
    ResultSetPanelDescriptor panelDescriptor = getPanelDescriptor(id);
    if (panelDescriptor == null) {
        log.debug("Panel '" + id + "' not found");
        return false;
    }
    try {
        panel = panelDescriptor.createInstance();
    } catch (DBException e) {
        DBWorkbench.getPlatformUI().showError("Can't show panel", "Can't create panel '" + id + "'", e);
        return false;
    }
    activePanels.put(id, panel);
    // Create control and tab item
    panelFolder.setRedraw(false);
    try {
        Control panelControl = panel.createContents(activePresentation, panelFolder);
        boolean firstPanel = panelFolder.getItemCount() == 0;
        CTabItem panelTab = new CTabItem(panelFolder, SWT.CLOSE);
        panelTab.setData(id);
        panelTab.setText(panelDescriptor.getLabel());
        panelTab.setImage(DBeaverIcons.getImage(panelDescriptor.getIcon()));
        panelTab.setToolTipText(panelDescriptor.getDescription());
        panelTab.setControl(panelControl);
        UIUtils.disposeControlOnItemDispose(panelTab);
        if (setActive || firstPanel) {
            panelFolder.setSelection(panelTab);
        }
        if (showPanels) {
            panel.setFocus();
        }
    } finally {
        panelFolder.setRedraw(true);
    }
    presentationSettings.enabledPanelIds.add(id);
    if (setActive) {
        setActivePanel(id);
    }
    updatePanelsButtons();
    return true;
}
Also used : DBException(org.jkiss.dbeaver.DBException) AutoRefreshControl(org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)

Example 10 with ResultSetPanelDescriptor

use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by dbeaver.

the class ResultSetViewer method updatePanelsButtons.

private void updatePanelsButtons() {
    boolean panelsVisible = isPanelsVisible();
    for (Control child : panelSwitchFolder.getChildren()) {
        if (child instanceof VerticalButton && child.getData() instanceof ResultSetPanelDescriptor) {
            boolean newChecked = panelsVisible && isPanelVisible(((ResultSetPanelDescriptor) child.getData()).getId());
            if (((VerticalButton) child).isChecked() != newChecked) {
                ((VerticalButton) child).setChecked(newChecked);
                child.redraw();
            }
        }
    }
}
Also used : AutoRefreshControl(org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl) VerticalButton(org.jkiss.dbeaver.ui.controls.VerticalButton) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)

Aggregations

ResultSetPanelDescriptor (org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)12 AutoRefreshControl (org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl)6 VerticalButton (org.jkiss.dbeaver.ui.controls.VerticalButton)4 ArrayList (java.util.ArrayList)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)2 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)2 DBException (org.jkiss.dbeaver.DBException)2 IResultSetController (org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)2 StatisticsPresentation (org.jkiss.dbeaver.ui.controls.resultset.view.StatisticsPresentation)2