Search in sources :

Example 21 with IContributionManager

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

the class PostgreSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<PostgreSession>(this, parent, new PostgreSessionManager((PostgreDataSource) executionContext.getDataSource())) {

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            terminateQueryAction.setEnabled(session != null);
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) PostgreSessionManager(org.jkiss.dbeaver.ext.postgresql.model.session.PostgreSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 22 with IContributionManager

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

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

the class StatusLineContributionItemEx method updateUI.

private void updateUI() {
    setVisible(true);
    IContributionManager contributionManager = getParent();
    if (contributionManager != null) {
        contributionManager.update(true);
    }
}
Also used : IContributionManager(org.eclipse.jface.action.IContributionManager)

Example 24 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project translationstudio8 by heartsome.

the class XLIFFEditorStatusLineItem method setText.

public void setText(String text, Image image) {
    Assert.isNotNull(image);
    Assert.isNotNull(text);
    this.text = LegacyActionTools.escapeMnemonics(text);
    this.image = image;
    if (label != null && !label.isDisposed()) {
        label.setText(this.text);
        label.setImage(this.image);
    }
    if (this.text.length() == 0) {
        if (isVisible()) {
            setVisible(false);
            IContributionManager contributionManager = getParent();
            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    } else {
        if (!isVisible()) {
            setVisible(true);
            IContributionManager contributionManager = getParent();
            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    }
}
Also used : IContributionManager(org.eclipse.jface.action.IContributionManager)

Example 25 with IContributionManager

use of org.eclipse.jface.action.IContributionManager in project translationstudio8 by heartsome.

the class XLIFFEditorStatusLineItem method setText.

public void setText(String text) {
    Assert.isNotNull(text);
    this.text = LegacyActionTools.escapeMnemonics(text);
    if (label != null && !label.isDisposed()) {
        label.setText(this.text);
    }
    if (this.text.length() == 0) {
        if (isVisible()) {
            setVisible(false);
            IContributionManager contributionManager = getParent();
            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    } else {
        if (!isVisible()) {
            setVisible(true);
            IContributionManager contributionManager = getParent();
            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    }
}
Also used : IContributionManager(org.eclipse.jface.action.IContributionManager)

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