Search in sources :

Example 46 with IContributionManager

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

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(OracleLockManager.sidHold, pLock.getHold_sid());
                        put(OracleLockManager.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 47 with IContributionManager

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

the class ObjectListDialog method createObjectSelector.

@NotNull
protected static <T extends DBPObject> DatabaseObjectListControl<T> createObjectSelector(Composite group, boolean singleSelection, String listId, List<T> selectedObjects, DBRRunnableWithResult<List<T>> objectReader) {
    return new DatabaseObjectListControl<T>(group, (singleSelection ? SWT.SINGLE : SWT.MULTI), null, new ListContentProvider()) {

        private Font boldFont;

        private ISearchExecutor searcher = new SearcherFilter();

        @NotNull
        @Override
        protected String getListConfigId(List<Class<?>> classList) {
            return listId;
        }

        @Override
        protected LoadingJob<Collection<T>> createLoadService() {
            return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {

                @Override
                public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    objectReader.run(monitor);
                    return objectReader.getResult();
                }

                @Override
                public Object getFamily() {
                    return ObjectListDialog.class;
                }
            }, new ObjectsLoadVisualizer() {

                @Override
                public void completeLoading(Collection<T> items) {
                    super.completeLoading(items);
                    performSearch(SearchType.NONE);
                    getItemsViewer().getControl().setFocus();
                }
            });
        }

        protected CellLabelProvider getColumnLabelProvider(ObjectColumn objectColumn) {
            return new ObjectLabelProvider(objectColumn);
        }

        @Override
        protected Object getObjectValue(T item) {
            if (item instanceof DBSWrapper) {
                return ((DBSWrapper) item).getObject();
            }
            return super.getObjectValue(item);
        }

        @Override
        protected DBPImage getObjectImage(T item) {
            if (item instanceof DBNDatabaseNode) {
                return ((DBNDatabaseNode) item).getNodeIcon();
            }
            return null;
        }

        @Override
        protected void setListData(Collection<T> items, boolean append) {
            super.setListData(items, append);
            if (selectedObjects != null) {
                getItemsViewer().setSelection(new StructuredSelection(selectedObjects), true);
            }
        }

        @Override
        public void fillCustomActions(IContributionManager contributionManager) {
            super.fillCustomActions(contributionManager);
            addColumnConfigAction(contributionManager);
        }

        protected void addSearchAction(IContributionManager contributionManager) {
            contributionManager.add(new Action("Filter objects", DBeaverIcons.getImageDescriptor(UIIcon.SEARCH)) {

                @Override
                public void run() {
                    performSearch(SearchType.NONE);
                }
            });
        }

        @Override
        protected ISearchExecutor getSearchRunner() {
            return searcher;
        }

        class ObjectLabelProvider extends ObjectColumnLabelProvider implements IFontProvider {

            ObjectLabelProvider(ObjectColumn objectColumn) {
                super(objectColumn);
            }

            @Override
            public Font getFont(Object element) {
                if (selectedObjects.contains(element)) {
                    if (boldFont == null) {
                        boldFont = UIUtils.makeBoldFont(group.getFont());
                        group.addDisposeListener(e -> boldFont.dispose());
                    }
                    return boldFont;
                }
                return null;
            }
        }
    };
}
Also used : ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) org.jkiss.dbeaver.ui(org.jkiss.dbeaver.ui) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DBPImage(org.jkiss.dbeaver.model.DBPImage) NotNull(org.jkiss.code.NotNull) ArrayList(java.util.ArrayList) Composite(org.eclipse.swt.widgets.Composite) DatabaseObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.DatabaseObjectListControl) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) AbstractLoadService(org.jkiss.dbeaver.model.runtime.load.AbstractLoadService) CommonUtils(org.jkiss.utils.CommonUtils) Shell(org.eclipse.swt.widgets.Shell) DBRRunnableWithResult(org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult) Collection(java.util.Collection) IContributionManager(org.eclipse.jface.action.IContributionManager) Action(org.eclipse.jface.action.Action) IFontProvider(org.eclipse.jface.viewers.IFontProvider) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) SWT(org.eclipse.swt.SWT) DBPObject(org.jkiss.dbeaver.model.DBPObject) AbstractPopupPanel(org.jkiss.dbeaver.ui.dialogs.AbstractPopupPanel) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Control(org.eclipse.swt.widgets.Control) Action(org.eclipse.jface.action.Action) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DatabaseObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.DatabaseObjectListControl) Font(org.eclipse.swt.graphics.Font) InvocationTargetException(java.lang.reflect.InvocationTargetException) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) SWT(org.eclipse.swt.SWT) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) DBPObject(org.jkiss.dbeaver.model.DBPObject) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IContributionManager(org.eclipse.jface.action.IContributionManager) NotNull(org.jkiss.code.NotNull)

Example 48 with IContributionManager

use of org.eclipse.jface.action.IContributionManager 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)

Example 49 with IContributionManager

use of org.eclipse.jface.action.IContributionManager 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 50 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(OracleLockManager.sidHold, pLock.getHold_sid());
                        put(OracleLockManager.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)

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