Search in sources :

Example 1 with ILoadService

use of org.jkiss.dbeaver.model.runtime.load.ILoadService in project dbeaver by serge-rider.

the class ResultSetViewer method createStatusBar.

private void createStatusBar() {
    Composite statusComposite = UIUtils.createPlaceholder(viewerPanel, 3);
    statusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    statusBar = new Composite(statusComposite, SWT.NONE);
    statusBar.setBackgroundMode(SWT.INHERIT_FORCE);
    statusBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    CSSUtils.setCSSClass(statusBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
    RowLayout toolbarsLayout = new RowLayout(SWT.HORIZONTAL);
    toolbarsLayout.marginTop = 0;
    toolbarsLayout.marginBottom = 0;
    toolbarsLayout.center = true;
    toolbarsLayout.wrap = true;
    toolbarsLayout.pack = true;
    // toolbarsLayout.fill = true;
    statusBar.setLayout(toolbarsLayout);
    {
        ToolBarManager editToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        // handle own commands
        editToolBarManager.add(new Separator());
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_APPLY_CHANGES, "Save", null, null, true));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_REJECT_CHANGES, "Cancel", null, null, true));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_GENERATE_SCRIPT, "Script", null, null, true));
        editToolBarManager.add(new Separator());
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_EDIT));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_ADD));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_COPY));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_DELETE));
        ToolBar editorToolBar = editToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(editorToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(editToolBarManager);
    }
    {
        ToolBarManager navToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        navToolBarManager.add(new ToolbarSeparatorContribution(true));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_FIRST));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_PREVIOUS));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_NEXT));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_LAST));
        navToolBarManager.add(new Separator());
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_PAGE));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_ALL));
        navToolBarManager.add(new Separator(TOOLBAR_GROUP_NAVIGATION));
        ToolBar navToolBar = navToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(navToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(navToolBarManager);
    }
    {
        ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        configToolBarManager.add(new ToolbarSeparatorContribution(true));
        /*
            if (supportsPanels()) {
                CommandContributionItemParameter ciParam = new CommandContributionItemParameter(
                    site,
                    "org.jkiss.dbeaver.core.resultset.panels",
                    ResultSetHandlerMain.CMD_TOGGLE_PANELS,
                    CommandContributionItem.STYLE_PULLDOWN);
                ciParam.label = ResultSetMessages.controls_resultset_config_panels;
                ciParam.mode = CommandContributionItem.MODE_FORCE_TEXT;
                configToolBarManager.add(new CommandContributionItem(ciParam));
            }
            configToolBarManager.add(new ToolbarSeparatorContribution(true));
*/
        ToolBar configToolBar = configToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(configToolBarManager);
    }
    {
        ToolBarManager addToolbBarManagerar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        addToolbBarManagerar.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_EXPORT));
        addToolbBarManagerar.add(new GroupMarker(TOOLBAR_GROUP_PRESENTATIONS));
        addToolbBarManagerar.add(new Separator(TOOLBAR_GROUP_ADDITIONS));
        final IMenuService menuService = getSite().getService(IMenuService.class);
        if (menuService != null) {
            menuService.populateContributionManager(addToolbBarManagerar, TOOLBAR_CONTRIBUTION_ID);
        }
        ToolBar addToolBar = addToolbBarManagerar.createControl(statusBar);
        CSSUtils.setCSSClass(addToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(addToolbBarManagerar);
    }
    {
        // Config toolbar
        ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        configToolBarManager.add(new ToolbarSeparatorContribution(true));
        configToolBarManager.add(new ConfigAction());
        configToolBarManager.update(true);
        ToolBar configToolBar = configToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(configToolBarManager);
    }
    {
        final int fontHeight = UIUtils.getFontHeight(statusBar);
        resultSetSize = new Text(statusBar, SWT.BORDER);
        resultSetSize.setLayoutData(new RowData(5 * fontHeight, SWT.DEFAULT));
        resultSetSize.setBackground(UIStyles.getDefaultTextBackground());
        resultSetSize.setToolTipText(DataEditorsMessages.resultset_segment_size);
        resultSetSize.addFocusListener(new FocusAdapter() {

            @Override
            public void focusLost(FocusEvent e) {
                String realValue = String.valueOf(getSegmentMaxRows());
                if (!realValue.equals(resultSetSize.getText())) {
                    resultSetSize.setText(realValue);
                }
            }
        });
        resultSetSize.addModifyListener(e -> {
            DBSDataContainer dataContainer = getDataContainer();
            int fetchSize = CommonUtils.toInt(resultSetSize.getText());
            if (fetchSize > 0 && fetchSize < ResultSetPreferences.MIN_SEGMENT_SIZE) {
                fetchSize = ResultSetPreferences.MIN_SEGMENT_SIZE;
            }
            if (dataContainer != null && dataContainer.getDataSource() != null) {
                DBPPreferenceStore store = dataContainer.getDataSource().getContainer().getPreferenceStore();
                int oldFetchSize = store.getInt(ModelPreferences.RESULT_SET_MAX_ROWS);
                if (oldFetchSize != fetchSize) {
                    store.setValue(ModelPreferences.RESULT_SET_MAX_ROWS, fetchSize);
                    PrefUtils.savePreferenceStore(store);
                }
            }
        });
        UIUtils.addDefaultEditActionsSupport(site, resultSetSize);
        rowCountLabel = new ActiveStatusMessage(statusBar, DBeaverIcons.getImage(UIIcon.RS_REFRESH), ResultSetMessages.controls_resultset_viewer_calculate_row_count, this) {

            @Override
            protected boolean isActionEnabled() {
                return hasData();
            }

            @Override
            protected ILoadService<String> createLoadService() {
                return new DatabaseLoadService<String>("Load row count", getExecutionContext()) {

                    @Override
                    public String evaluate(DBRProgressMonitor monitor) throws InvocationTargetException {
                        try {
                            long rowCount = readRowCount(monitor);
                            return ROW_COUNT_FORMAT.format(rowCount);
                        } catch (DBException e) {
                            log.error(e);
                            throw new InvocationTargetException(e);
                        }
                    }
                };
            }
        };
        // rowCountLabel.setLayoutData();
        CSSUtils.setCSSClass(rowCountLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        rowCountLabel.setMessage("Row Count");
        rowCountLabel.setToolTipText("Calculates total row count in the current dataset");
        UIUtils.createToolBarSeparator(statusBar, SWT.VERTICAL);
        selectionStatLabel = new Text(statusBar, SWT.READ_ONLY);
        selectionStatLabel.setToolTipText("Selected rows/columns/cells");
        CSSUtils.setCSSClass(selectionStatLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        Label filler = new Label(statusComposite, SWT.NONE);
        filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        statusLabel = new StatusLabel(statusComposite, SWT.NONE, this);
        GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
        gd.widthHint = 30 * fontHeight;
        statusLabel.setLayoutData(gd);
        CSSUtils.setCSSClass(statusLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        statusBar.addListener(SWT.Resize, event -> {
        });
    }
}
Also used : DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) SQLQueryContainer(org.jkiss.dbeaver.model.sql.SQLQueryContainer) org.eclipse.jface.action(org.eclipse.jface.action) CompoundContributionItem(org.eclipse.ui.actions.CompoundContributionItem) org.jkiss.dbeaver.ui(org.jkiss.dbeaver.ui) IMenuService(org.eclipse.ui.menus.IMenuService) org.jkiss.dbeaver.model.virtual(org.jkiss.dbeaver.model.virtual) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) NavigatorCommands(org.jkiss.dbeaver.ui.navigator.NavigatorCommands) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) DBSQLException(org.jkiss.dbeaver.model.sql.DBSQLException) ToolbarSeparatorContribution(org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution) PrefPageResultSetMain(org.jkiss.dbeaver.ui.editors.data.preferences.PrefPageResultSetMain) ModelMessages(org.jkiss.dbeaver.model.messages.ModelMessages) IStatus(org.eclipse.core.runtime.IStatus) org.eclipse.swt.custom(org.eclipse.swt.custom) ITextEditorActionDefinitionIds(org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds) AbstractExecutionSource(org.jkiss.dbeaver.model.impl.AbstractExecutionSource) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) SQLScriptElement(org.jkiss.dbeaver.model.sql.SQLScriptElement) IAdaptable(org.eclipse.core.runtime.IAdaptable) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener) ILoadService(org.jkiss.dbeaver.model.runtime.load.ILoadService) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) org.eclipse.swt.layout(org.eclipse.swt.layout) NLS(org.eclipse.osgi.util.NLS) Status(org.eclipse.core.runtime.Status) IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) IThemeManager(org.eclipse.ui.themes.IThemeManager) org.eclipse.jface.viewers(org.eclipse.jface.viewers) DBStyles(org.jkiss.dbeaver.ui.css.DBStyles) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) StatResultSet(org.jkiss.dbeaver.model.impl.local.StatResultSet) List(java.util.List) EmptyPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.EmptyPresentation) RuntimeUtils(org.jkiss.dbeaver.utils.RuntimeUtils) org.jkiss.dbeaver.ui.controls.resultset.virtual(org.jkiss.dbeaver.ui.controls.resultset.virtual) DBException(org.jkiss.dbeaver.DBException) AutoRefreshControl(org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl) DataEditorsMessages(org.jkiss.dbeaver.ui.editors.data.internal.DataEditorsMessages) SWT(org.eclipse.swt.SWT) ResetRowColorAction(org.jkiss.dbeaver.ui.controls.resultset.colors.ResetRowColorAction) SetRowColorAction(org.jkiss.dbeaver.ui.controls.resultset.colors.SetRowColorAction) SQLUtils(org.jkiss.dbeaver.model.sql.SQLUtils) PrefUtils(org.jkiss.dbeaver.utils.PrefUtils) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) VerticalFolder(org.jkiss.dbeaver.ui.controls.VerticalFolder) TabFolderReorder(org.jkiss.dbeaver.ui.controls.TabFolderReorder) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) CustomizeColorsAction(org.jkiss.dbeaver.ui.controls.resultset.colors.CustomizeColorsAction) java.util(java.util) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) StatisticsPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.StatisticsPresentation) org.jkiss.dbeaver.model.data(org.jkiss.dbeaver.model.data) Rectangle(org.eclipse.swt.graphics.Rectangle) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Nullable(org.jkiss.code.Nullable) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) NotNull(org.jkiss.code.NotNull) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor) DataSourceJob(org.jkiss.dbeaver.runtime.jobs.DataSourceJob) Log(org.jkiss.dbeaver.Log) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) ResultSetMessages(org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages) ErrorPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.ErrorPresentation) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PrefPageDataFormat(org.jkiss.dbeaver.ui.editors.data.preferences.PrefPageDataFormat) ModelPreferences(org.jkiss.dbeaver.ModelPreferences) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) IValueController(org.jkiss.dbeaver.ui.data.IValueController) DBeaverNotifications(org.jkiss.dbeaver.runtime.DBeaverNotifications) org.eclipse.swt.events(org.eclipse.swt.events) org.jkiss.dbeaver.model.struct(org.jkiss.dbeaver.model.struct) FilterValueEditPopup(org.jkiss.dbeaver.ui.controls.resultset.valuefilter.FilterValueEditPopup) org.jkiss.dbeaver.model.exec(org.jkiss.dbeaver.model.exec) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DecimalFormat(java.text.DecimalFormat) VerticalButton(org.jkiss.dbeaver.ui.controls.VerticalButton) ArrayUtils(org.jkiss.utils.ArrayUtils) org.eclipse.ui(org.eclipse.ui) CSSUtils(org.jkiss.dbeaver.ui.css.CSSUtils) org.jkiss.dbeaver.ui.controls.resultset.handler(org.jkiss.dbeaver.ui.controls.resultset.handler) Color(org.eclipse.swt.graphics.Color) ITheme(org.eclipse.ui.themes.ITheme) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) DBRRunnableWithProgress(org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress) ConfirmationDialog(org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog) DBException(org.jkiss.dbeaver.DBException) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) ToolbarSeparatorContribution(org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) InvocationTargetException(java.lang.reflect.InvocationTargetException) IMenuService(org.eclipse.ui.menus.IMenuService) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)

Example 2 with ILoadService

use of org.jkiss.dbeaver.model.runtime.load.ILoadService in project dbeaver by dbeaver.

the class ResultSetViewer method createStatusBar.

private void createStatusBar() {
    Composite statusComposite = UIUtils.createPlaceholder(viewerPanel, 3);
    statusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    statusBar = new Composite(statusComposite, SWT.NONE);
    statusBar.setBackgroundMode(SWT.INHERIT_FORCE);
    statusBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    CSSUtils.setCSSClass(statusBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
    RowLayout toolbarsLayout = new RowLayout(SWT.HORIZONTAL);
    toolbarsLayout.marginTop = 0;
    toolbarsLayout.marginBottom = 0;
    toolbarsLayout.center = true;
    toolbarsLayout.wrap = true;
    toolbarsLayout.pack = true;
    // toolbarsLayout.fill = true;
    statusBar.setLayout(toolbarsLayout);
    {
        ToolBarManager editToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        // handle own commands
        editToolBarManager.add(new Separator());
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_APPLY_CHANGES, "Save", null, null, true));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_REJECT_CHANGES, "Cancel", null, null, true));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_GENERATE_SCRIPT, "Script", null, null, true));
        editToolBarManager.add(new Separator());
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_EDIT));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_ADD));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_COPY));
        editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_DELETE));
        ToolBar editorToolBar = editToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(editorToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(editToolBarManager);
    }
    {
        ToolBarManager navToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        navToolBarManager.add(new ToolbarSeparatorContribution(true));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_FIRST));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_PREVIOUS));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_NEXT));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_LAST));
        navToolBarManager.add(new Separator());
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_PAGE));
        navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_ALL));
        navToolBarManager.add(new Separator(TOOLBAR_GROUP_NAVIGATION));
        ToolBar navToolBar = navToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(navToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(navToolBarManager);
    }
    {
        ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        configToolBarManager.add(new ToolbarSeparatorContribution(true));
        /*
            if (supportsPanels()) {
                CommandContributionItemParameter ciParam = new CommandContributionItemParameter(
                    site,
                    "org.jkiss.dbeaver.core.resultset.panels",
                    ResultSetHandlerMain.CMD_TOGGLE_PANELS,
                    CommandContributionItem.STYLE_PULLDOWN);
                ciParam.label = ResultSetMessages.controls_resultset_config_panels;
                ciParam.mode = CommandContributionItem.MODE_FORCE_TEXT;
                configToolBarManager.add(new CommandContributionItem(ciParam));
            }
            configToolBarManager.add(new ToolbarSeparatorContribution(true));
*/
        ToolBar configToolBar = configToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(configToolBarManager);
    }
    {
        ToolBarManager addToolbBarManagerar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        addToolbBarManagerar.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_EXPORT));
        addToolbBarManagerar.add(new GroupMarker(TOOLBAR_GROUP_PRESENTATIONS));
        addToolbBarManagerar.add(new Separator(TOOLBAR_GROUP_ADDITIONS));
        final IMenuService menuService = getSite().getService(IMenuService.class);
        if (menuService != null) {
            menuService.populateContributionManager(addToolbBarManagerar, TOOLBAR_CONTRIBUTION_ID);
        }
        ToolBar addToolBar = addToolbBarManagerar.createControl(statusBar);
        CSSUtils.setCSSClass(addToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(addToolbBarManagerar);
    }
    {
        // Config toolbar
        ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
        configToolBarManager.add(new ToolbarSeparatorContribution(true));
        configToolBarManager.add(new ConfigAction());
        configToolBarManager.update(true);
        ToolBar configToolBar = configToolBarManager.createControl(statusBar);
        CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
        toolbarList.add(configToolBarManager);
    }
    {
        final int fontHeight = UIUtils.getFontHeight(statusBar);
        resultSetSize = new Text(statusBar, SWT.BORDER);
        resultSetSize.setLayoutData(new RowData(5 * fontHeight, SWT.DEFAULT));
        resultSetSize.setBackground(UIStyles.getDefaultTextBackground());
        resultSetSize.setToolTipText(DataEditorsMessages.resultset_segment_size);
        resultSetSize.addFocusListener(new FocusAdapter() {

            @Override
            public void focusLost(FocusEvent e) {
                String realValue = String.valueOf(getSegmentMaxRows());
                if (!realValue.equals(resultSetSize.getText())) {
                    resultSetSize.setText(realValue);
                }
            }
        });
        resultSetSize.addModifyListener(e -> {
            DBSDataContainer dataContainer = getDataContainer();
            int fetchSize = CommonUtils.toInt(resultSetSize.getText());
            if (fetchSize > 0 && fetchSize < ResultSetPreferences.MIN_SEGMENT_SIZE) {
                fetchSize = ResultSetPreferences.MIN_SEGMENT_SIZE;
            }
            if (dataContainer != null && dataContainer.getDataSource() != null) {
                DBPPreferenceStore store = dataContainer.getDataSource().getContainer().getPreferenceStore();
                int oldFetchSize = store.getInt(ModelPreferences.RESULT_SET_MAX_ROWS);
                if (oldFetchSize != fetchSize) {
                    store.setValue(ModelPreferences.RESULT_SET_MAX_ROWS, fetchSize);
                    PrefUtils.savePreferenceStore(store);
                }
            }
        });
        UIUtils.addDefaultEditActionsSupport(site, resultSetSize);
        rowCountLabel = new ActiveStatusMessage(statusBar, DBeaverIcons.getImage(UIIcon.RS_REFRESH), ResultSetMessages.controls_resultset_viewer_calculate_row_count, this) {

            @Override
            protected boolean isActionEnabled() {
                return hasData();
            }

            @Override
            protected ILoadService<String> createLoadService() {
                return new DatabaseLoadService<String>("Load row count", getExecutionContext()) {

                    @Override
                    public String evaluate(DBRProgressMonitor monitor) throws InvocationTargetException {
                        try {
                            long rowCount = readRowCount(monitor);
                            return ROW_COUNT_FORMAT.format(rowCount);
                        } catch (DBException e) {
                            log.error(e);
                            throw new InvocationTargetException(e);
                        }
                    }
                };
            }
        };
        // rowCountLabel.setLayoutData();
        CSSUtils.setCSSClass(rowCountLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        rowCountLabel.setMessage("Row Count");
        rowCountLabel.setToolTipText("Calculates total row count in the current dataset");
        UIUtils.createToolBarSeparator(statusBar, SWT.VERTICAL);
        selectionStatLabel = new Text(statusBar, SWT.READ_ONLY);
        selectionStatLabel.setToolTipText("Selected rows/columns/cells");
        CSSUtils.setCSSClass(selectionStatLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        Label filler = new Label(statusComposite, SWT.NONE);
        filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        statusLabel = new StatusLabel(statusComposite, SWT.NONE, this);
        GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
        gd.widthHint = 30 * fontHeight;
        statusLabel.setLayoutData(gd);
        CSSUtils.setCSSClass(statusLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
        statusBar.addListener(SWT.Resize, event -> {
        });
    }
}
Also used : DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) SQLQueryContainer(org.jkiss.dbeaver.model.sql.SQLQueryContainer) org.eclipse.jface.action(org.eclipse.jface.action) CompoundContributionItem(org.eclipse.ui.actions.CompoundContributionItem) org.jkiss.dbeaver.ui(org.jkiss.dbeaver.ui) IMenuService(org.eclipse.ui.menus.IMenuService) org.jkiss.dbeaver.model.virtual(org.jkiss.dbeaver.model.virtual) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) NavigatorCommands(org.jkiss.dbeaver.ui.navigator.NavigatorCommands) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) DBSQLException(org.jkiss.dbeaver.model.sql.DBSQLException) ToolbarSeparatorContribution(org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution) PrefPageResultSetMain(org.jkiss.dbeaver.ui.editors.data.preferences.PrefPageResultSetMain) ModelMessages(org.jkiss.dbeaver.model.messages.ModelMessages) IStatus(org.eclipse.core.runtime.IStatus) org.eclipse.swt.custom(org.eclipse.swt.custom) ITextEditorActionDefinitionIds(org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds) AbstractExecutionSource(org.jkiss.dbeaver.model.impl.AbstractExecutionSource) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) SQLScriptElement(org.jkiss.dbeaver.model.sql.SQLScriptElement) IAdaptable(org.eclipse.core.runtime.IAdaptable) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener) ILoadService(org.jkiss.dbeaver.model.runtime.load.ILoadService) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) org.eclipse.swt.layout(org.eclipse.swt.layout) NLS(org.eclipse.osgi.util.NLS) Status(org.eclipse.core.runtime.Status) IFindReplaceTarget(org.eclipse.jface.text.IFindReplaceTarget) IThemeManager(org.eclipse.ui.themes.IThemeManager) org.eclipse.jface.viewers(org.eclipse.jface.viewers) DBStyles(org.jkiss.dbeaver.ui.css.DBStyles) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) StatResultSet(org.jkiss.dbeaver.model.impl.local.StatResultSet) List(java.util.List) EmptyPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.EmptyPresentation) RuntimeUtils(org.jkiss.dbeaver.utils.RuntimeUtils) org.jkiss.dbeaver.ui.controls.resultset.virtual(org.jkiss.dbeaver.ui.controls.resultset.virtual) DBException(org.jkiss.dbeaver.DBException) AutoRefreshControl(org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl) DataEditorsMessages(org.jkiss.dbeaver.ui.editors.data.internal.DataEditorsMessages) SWT(org.eclipse.swt.SWT) ResetRowColorAction(org.jkiss.dbeaver.ui.controls.resultset.colors.ResetRowColorAction) SetRowColorAction(org.jkiss.dbeaver.ui.controls.resultset.colors.SetRowColorAction) SQLUtils(org.jkiss.dbeaver.model.sql.SQLUtils) PrefUtils(org.jkiss.dbeaver.utils.PrefUtils) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) VerticalFolder(org.jkiss.dbeaver.ui.controls.VerticalFolder) TabFolderReorder(org.jkiss.dbeaver.ui.controls.TabFolderReorder) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) CustomizeColorsAction(org.jkiss.dbeaver.ui.controls.resultset.colors.CustomizeColorsAction) java.util(java.util) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) StatisticsPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.StatisticsPresentation) org.jkiss.dbeaver.model.data(org.jkiss.dbeaver.model.data) Rectangle(org.eclipse.swt.graphics.Rectangle) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Nullable(org.jkiss.code.Nullable) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) NotNull(org.jkiss.code.NotNull) ResultSetPanelDescriptor(org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor) DataSourceJob(org.jkiss.dbeaver.runtime.jobs.DataSourceJob) Log(org.jkiss.dbeaver.Log) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) ResultSetMessages(org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages) ErrorPresentation(org.jkiss.dbeaver.ui.controls.resultset.view.ErrorPresentation) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PrefPageDataFormat(org.jkiss.dbeaver.ui.editors.data.preferences.PrefPageDataFormat) ModelPreferences(org.jkiss.dbeaver.ModelPreferences) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) IValueController(org.jkiss.dbeaver.ui.data.IValueController) DBeaverNotifications(org.jkiss.dbeaver.runtime.DBeaverNotifications) org.eclipse.swt.events(org.eclipse.swt.events) org.jkiss.dbeaver.model.struct(org.jkiss.dbeaver.model.struct) FilterValueEditPopup(org.jkiss.dbeaver.ui.controls.resultset.valuefilter.FilterValueEditPopup) org.jkiss.dbeaver.model.exec(org.jkiss.dbeaver.model.exec) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DecimalFormat(java.text.DecimalFormat) VerticalButton(org.jkiss.dbeaver.ui.controls.VerticalButton) ArrayUtils(org.jkiss.utils.ArrayUtils) org.eclipse.ui(org.eclipse.ui) CSSUtils(org.jkiss.dbeaver.ui.css.CSSUtils) org.jkiss.dbeaver.ui.controls.resultset.handler(org.jkiss.dbeaver.ui.controls.resultset.handler) Color(org.eclipse.swt.graphics.Color) ITheme(org.eclipse.ui.themes.ITheme) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) DBRRunnableWithProgress(org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress) ConfirmationDialog(org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog) DBException(org.jkiss.dbeaver.DBException) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) ToolbarSeparatorContribution(org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) InvocationTargetException(java.lang.reflect.InvocationTargetException) IMenuService(org.eclipse.ui.menus.IMenuService) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DecimalFormat (java.text.DecimalFormat)2 java.util (java.util)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 org.eclipse.jface.action (org.eclipse.jface.action)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)2 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)2 org.eclipse.jface.viewers (org.eclipse.jface.viewers)2 NLS (org.eclipse.osgi.util.NLS)2 SWT (org.eclipse.swt.SWT)2 org.eclipse.swt.custom (org.eclipse.swt.custom)2 org.eclipse.swt.events (org.eclipse.swt.events)2 Color (org.eclipse.swt.graphics.Color)2