Search in sources :

Example 1 with SQLServerSessionManager

use of org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager in project dbeaver by dbeaver.

the class SQLServerSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<SQLServerSession>(this, parent, new SQLServerSessionManager((SQLServerDataSource) executionContext.getDataSource())) {

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Only connections", Action.AS_CHECK_BOX) {

                {
                    setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
                    setToolTipText("Show only physical connections");
                    setChecked(showOnlyConnections);
                }

                @Override
                public void run() {
                    showOnlyConnections = isChecked();
                    refreshPart(SQLServerSessionEditor.this, true);
                }
            }, true));
            contributionManager.add(new Separator());
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            terminateQueryAction.setEnabled(session != null);
        }

        @Override
        protected void loadSettings(IDialogSettings settings) {
            showOnlyConnections = CommonUtils.getBoolean(settings.get("showOnlyConnections"), true);
            super.loadSettings(settings);
        }

        @Override
        protected void saveSettings(IDialogSettings settings) {
            super.saveSettings(settings);
            settings.put("showOnlyConnections", showOnlyConnections);
        }

        @Override
        public Map<String, Object> getSessionOptions() {
            Map<String, Object> options = new HashMap<>();
            if (showOnlyConnections) {
                options.put(SQLServerSessionManager.OPTION_SHOW_ONLY_CONNECTIONS, true);
            }
            return options;
        }
    };
}
Also used : Action(org.eclipse.jface.action.Action) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) HashMap(java.util.HashMap) SQLServerDataSource(org.jkiss.dbeaver.ext.mssql.model.SQLServerDataSource) SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) SQLServerSessionManager(org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 2 with SQLServerSessionManager

use of org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager in project dbeaver by serge-rider.

the class SQLServerSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<SQLServerSession>(this, parent, new SQLServerSessionManager((SQLServerDataSource) executionContext.getDataSource())) {

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Only connections", Action.AS_CHECK_BOX) {

                {
                    setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
                    setToolTipText("Show only physical connections");
                    setChecked(showOnlyConnections);
                }

                @Override
                public void run() {
                    showOnlyConnections = isChecked();
                    refreshPart(SQLServerSessionEditor.this, true);
                }
            }, true));
            contributionManager.add(new Separator());
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            terminateQueryAction.setEnabled(session != null);
        }

        @Override
        protected void loadSettings(IDialogSettings settings) {
            showOnlyConnections = CommonUtils.getBoolean(settings.get("showOnlyConnections"), true);
            super.loadSettings(settings);
        }

        @Override
        protected void saveSettings(IDialogSettings settings) {
            super.saveSettings(settings);
            settings.put("showOnlyConnections", showOnlyConnections);
        }

        @Override
        public Map<String, Object> getSessionOptions() {
            Map<String, Object> options = new HashMap<>();
            if (showOnlyConnections) {
                options.put(SQLServerSessionManager.OPTION_SHOW_ONLY_CONNECTIONS, true);
            }
            return options;
        }
    };
}
Also used : Action(org.eclipse.jface.action.Action) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) HashMap(java.util.HashMap) SQLServerDataSource(org.jkiss.dbeaver.ext.mssql.model.SQLServerDataSource) SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) SQLServerSessionManager(org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

HashMap (java.util.HashMap)2 Action (org.eclipse.jface.action.Action)2 IContributionManager (org.eclipse.jface.action.IContributionManager)2 Separator (org.eclipse.jface.action.Separator)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 SQLServerDataSource (org.jkiss.dbeaver.ext.mssql.model.SQLServerDataSource)2 SQLServerSessionManager (org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager)2 DBAServerSession (org.jkiss.dbeaver.model.admin.sessions.DBAServerSession)2 DBAServerSessionManager (org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager)2 SessionManagerViewer (org.jkiss.dbeaver.ui.views.session.SessionManagerViewer)2