Search in sources :

Example 1 with IContributionManager

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

the class UIUtils method registerContributionManager.

/**
 * Register the given ContributionManager with the given id. The
 * contribution manager gets unregistered on control disposal.
 *
 * @param id
 *            the id
 * @param contributionManager
 *            the contribution manager
 * @param control
 *            the control
 *
 * @see ContributionManager
 * @see IMenuService
 * @see DisposeListener
 */
public static void registerContributionManager(final String id, final IContributionManager contributionManager, final Control control) {
    Assert.isNotNull(id);
    Assert.isNotNull(contributionManager);
    Assert.isTrue(control != null && !control.isDisposed());
    final IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class);
    menuService.populateContributionManager((ContributionManager) contributionManager, id);
    contributionManager.update(true);
    control.addDisposeListener(e -> menuService.releaseContributions((ContributionManager) contributionManager));
}
Also used : IMenuService(org.eclipse.ui.menus.IMenuService) IContributionManager(org.eclipse.jface.action.IContributionManager) ContributionManager(org.eclipse.jface.action.ContributionManager)

Example 2 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)

Example 3 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(pidHold, pLock.getHold_pid());
                        put(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 4 with IContributionManager

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

the class OracleLockEditor method createLockViewer.

@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new OracleLockManager((OracleDataSource) 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 OracleLock pLock = (OracleLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(sidHold, pLock.getHold_sid());
                        put(sidWait, pLock.getWait_sid());
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) OracleDataSource(org.jkiss.dbeaver.ext.oracle.model.OracleDataSource) OracleLock(org.jkiss.dbeaver.ext.oracle.model.lock.OracleLock) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) OracleLockManager(org.jkiss.dbeaver.ext.oracle.model.lock.OracleLockManager) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 5 with IContributionManager

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

the class DB2ServerApplicationEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<DB2ServerApplication>(this, parent, new DB2ServerApplicationManager((DB2DataSource) executionContext.getDataSource())) {

        @Override
        @SuppressWarnings("rawtypes")
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(forceApplicationAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            forceApplicationAction.setEnabled(session != null);
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) DB2DataSource(org.jkiss.dbeaver.ext.db2.model.DB2DataSource) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) 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