Search in sources :

Example 16 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project dbeaver by serge-rider.

the class PostgreLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new PostgreLockManager((PostgreDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final PostgreLock pLock = (PostgreLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(PostgreLockManager.pidHold, pLock.getHold_pid());
                        put(PostgreLockManager.pidWait, pLock.getWait_pid());
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreLockManager(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) PostgreLock(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 17 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project dbeaver by serge-rider.

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 18 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.

the class ObjectPropertiesEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // Add lazy props listener
    // PropertiesContributor.getInstance().addLazyListener(this);
    pageControl = new ObjectEditorPageControl(parent, SWT.SHEET, this) {

        @Override
        public void fillCustomActions(IContributionManager contributionManager) {
            createPropertyRefreshAction(contributionManager);
            super.fillCustomActions(contributionManager);
            if (propertiesPanel != null && folderComposite == null) {
                // We have object editor and no folders - contribute default actions
                DatabaseEditorUtils.contributeStandardEditorActions(getSite(), contributionManager);
            }
        }
    };
    CSSUtils.setCSSClass(pageControl, DBStyles.COLORED_BY_CONNECTION_TYPE);
    pageControl.setShowDivider(true);
    mainComposite = new Composite(pageControl, SWT.NONE);
    GridLayout gl = new GridLayout(1, false);
    gl.verticalSpacing = 5;
    gl.horizontalSpacing = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    mainComposite.setLayout(gl);
    mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    pageControl.createProgressPanel();
    curFolderId = getEditorInput().getDefaultFolderId();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ObjectEditorPageControl(org.jkiss.dbeaver.ui.controls.ObjectEditorPageControl) GridData(org.eclipse.swt.layout.GridData) IContributionManager(org.eclipse.jface.action.IContributionManager)

Example 19 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.

the class PostgreLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new PostgreLockManager((PostgreDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final PostgreLock pLock = (PostgreLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(PostgreLockManager.pidHold, pLock.getHold_pid());
                        put(PostgreLockManager.pidWait, pLock.getWait_pid());
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreLockManager(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) PostgreLock(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 20 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.

the class ExasolLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    @SuppressWarnings("rawtypes") DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new ExasolLockManager((ExasolDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @SuppressWarnings("serial")
        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final ExasolLock pLock = (ExasolLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(sidHold, BigInteger.valueOf(pLock.getHold_sid()));
                        put(sidWait, BigInteger.valueOf(pLock.getWait_sid().longValue()));
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) ExasolLockManager(org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLockManager) ExasolLock(org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) ExasolDataSource(org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

IContributionManager (org.eclipse.jface.action.IContributionManager)52 Separator (org.eclipse.jface.action.Separator)31 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)9 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)8 ExasolDataSource (org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource)7 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)7 LockManagerViewer (org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer)7 DBAServerLock (org.jkiss.dbeaver.model.admin.locks.DBAServerLock)7 DBAServerLockItem (org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem)7 DBAServerLockManager (org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager)7 Composite (org.eclipse.swt.widgets.Composite)6 GridData (org.eclipse.swt.layout.GridData)5 OracleDataSource (org.jkiss.dbeaver.ext.oracle.model.OracleDataSource)5 HashMap (java.util.HashMap)4 DB2DataSource (org.jkiss.dbeaver.ext.db2.model.DB2DataSource)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3