Search in sources :

Example 21 with DBAServerSession

use of org.jkiss.dbeaver.model.admin.sessions.DBAServerSession in project dbeaver by dbeaver.

the class MySQLSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<MySQLSession>(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {

        private boolean hideSleeping;

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Hide sleeping", Action.AS_CHECK_BOX) {

                {
                    setToolTipText("Show only active connections");
                    setChecked(hideSleeping);
                }

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

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            killSessionAction.setEnabled(session != null);
            terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
        }

        @Override
        public Map<String, Object> getSessionOptions() {
            if (hideSleeping) {
                return Collections.singletonMap(MySQLSessionManager.OPTION_HIDE_SLEEPING, true);
            }
            return super.getSessionOptions();
        }

        @Override
        protected void loadSettings(IDialogSettings settings) {
            hideSleeping = CommonUtils.toBoolean(settings.get("hideSleeping"));
            super.loadSettings(settings);
        }

        @Override
        protected void saveSettings(IDialogSettings settings) {
            super.saveSettings(settings);
            settings.put("hideSleeping", hideSleeping);
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) Action(org.eclipse.jface.action.Action) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) MySQLSessionManager(org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 22 with DBAServerSession

use of org.jkiss.dbeaver.model.admin.sessions.DBAServerSession in project dbeaver by dbeaver.

the class OracleSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<OracleServerSession>(this, parent, new OracleServerSessionManager((OracleDataSource) executionContext.getDataSource())) {

        private boolean showBackground;

        private boolean showInactive;

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(disconnectSessionAction);
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Show background", Action.AS_CHECK_BOX) {

                {
                    setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
                    setToolTipText("Show background tasks");
                    setChecked(showBackground);
                }

                @Override
                public void run() {
                    showBackground = isChecked();
                    refreshPart(OracleSessionEditor.this, true);
                }
            }, true));
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Show inactive", Action.AS_CHECK_BOX) {

                {
                    setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION));
                    setToolTipText("Show inactive sessions");
                    setChecked(showInactive);
                }

                @Override
                public void run() {
                    showInactive = isChecked();
                    refreshPart(OracleSessionEditor.this, true);
                }
            }, true));
        }

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

        @Override
        protected void loadSettings(IDialogSettings settings) {
            showBackground = CommonUtils.toBoolean(settings.get("showBackground"));
            showInactive = CommonUtils.toBoolean(settings.get("showInactive"));
            super.loadSettings(settings);
        }

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

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

Aggregations

IContributionManager (org.eclipse.jface.action.IContributionManager)22 Separator (org.eclipse.jface.action.Separator)22 DBAServerSession (org.jkiss.dbeaver.model.admin.sessions.DBAServerSession)22 DBAServerSessionManager (org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager)22 SessionManagerViewer (org.jkiss.dbeaver.ui.views.session.SessionManagerViewer)22 Action (org.eclipse.jface.action.Action)6 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)6 HashMap (java.util.HashMap)4 DB2DataSource (org.jkiss.dbeaver.ext.db2.model.DB2DataSource)4 ExasolDataSource (org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource)4 MySQLDataSource (org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource)4 MySQLSessionManager (org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager)4 OracleServerSessionManager (org.jkiss.dbeaver.ext.oracle.model.session.OracleServerSessionManager)4 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)4 PostgreSessionManager (org.jkiss.dbeaver.ext.postgresql.model.session.PostgreSessionManager)4 DB2ServerApplicationManager (org.jkiss.dbeaver.ext.db2.model.app.DB2ServerApplicationManager)2 ExasolServerSessionManager (org.jkiss.dbeaver.ext.exasol.model.app.ExasolServerSessionManager)2 SQLServerDataSource (org.jkiss.dbeaver.ext.mssql.model.SQLServerDataSource)2 SQLServerSessionManager (org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager)2 OracleDataSource (org.jkiss.dbeaver.ext.oracle.model.OracleDataSource)2