use of org.eclipse.jface.action.Separator in project dbeaver by serge-rider.
the class ItemListControl method fillCustomActions.
@Override
protected void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
final DBNNode rootNode = getRootNode();
if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
contributionManager.add(new Action("Filter", DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
@Override
public void run() {
NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
}
});
}
IWorkbenchSite workbenchSite = getWorkbenchSite();
if (workbenchSite != null) {
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
}
if (rootNode instanceof DBNDatabaseNode) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_OPEN));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_CREATE));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_DELETE));
}
if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
boolean hasReorder = false;
List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
for (Class<?> chilType : childrenTypes) {
if (EntityEditorsRegistry.getInstance().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
hasReorder = true;
break;
}
}
if (hasReorder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_UP));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_DOWN));
}
}
if (workbenchSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
if (editor instanceof EntityEditor) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_SAVE, null, UIIcon.SAVE, null, true));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REVERT, null, UIIcon.RESET, null, true));
}
}
}
use of org.eclipse.jface.action.Separator in project dbeaver by serge-rider.
the class DataSourceTransactionModeContributor method fillContributionItems.
@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
IWorkbenchWindow window = DBeaverUI.getActiveWorkbenchWindow();
if (window == null) {
return;
}
IEditorPart activePart = window.getActivePage().getActiveEditor();
DBPDataSourceContainer container = AbstractDataSourceHandler.getDataSourceContainer(activePart);
DBPDataSource dataSource = null;
if (container != null) {
dataSource = container.getDataSource();
}
if (dataSource == null) {
return;
}
final DBPDataSourceInfo dsInfo = dataSource.getInfo();
DBCTransactionManager txnManager = DBUtils.getTransactionManager(dataSource.getDefaultContext(false));
if (txnManager != null) {
menuItems.add(ActionUtils.makeCommandContribution(window, CoreCommands.CMD_TOGGLE_AUTOCOMMIT, CommandContributionItem.STYLE_CHECK));
menuItems.add(new Separator());
// Transactions
DBPTransactionIsolation txnLevelCurrent = null;
try {
txnLevelCurrent = txnManager.getTransactionIsolation();
} catch (DBCException ex) {
log.warn("Can't determine current transaction isolation level", ex);
}
for (DBPTransactionIsolation txi : CommonUtils.safeCollection(dsInfo.getSupportedTransactionsIsolation())) {
if (!txi.isEnabled()) {
continue;
}
menuItems.add(ActionUtils.makeActionContribution(new TransactionIsolationAction(dataSource, txi, txi.equals(txnLevelCurrent)), true));
}
}
}
use of org.eclipse.jface.action.Separator in project dbeaver by serge-rider.
the class ToolsContextMenuHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
final Shell activeShell = HandlerUtil.getActiveShell(event);
if (part == null || activeShell == null) {
return null;
}
final Control focusControl = activeShell.getDisplay().getFocusControl();
if (focusControl == null) {
return null;
}
Point location = getLocationFromControl(activeShell, focusControl);
if (menuManager != null) {
menuManager.dispose();
}
menuManager = new MenuManager();
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_CONNECT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_DISCONNECT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_INVALIDATE));
if (part instanceof IEditorPart) {
menuManager.add(new Separator());
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_COMMIT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_ROLLBACK));
{
final MenuManager txnMenu = new MenuManager(DBeaverActivator.getPluginResourceBundle().getString("command.org.jkiss.dbeaver.core.transaction_mode.name"));
txnMenu.add(new DataSourceTransactionModeContributor());
menuManager.add(txnMenu);
}
}
menuManager.add(new Separator());
{
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_SQL_EDITOR_OPEN));
/*
final MenuManager toolsMenu = new MenuManager(
DBeaverActivator.getPluginResourceBundle().getString("menu.database.tools"));
toolsMenu.add(new DataSourceToolsContributor());
menuManager.add(toolsMenu);
*/
}
if (part instanceof IEditorPart) {
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_LINK_EDITOR, "Find in navigator", null));
}
final Menu contextMenu = menuManager.createContextMenu(focusControl);
if (location != null) {
contextMenu.setLocation(location);
}
contextMenu.setVisible(true);
contextMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
int keyIndex = 1;
for (MenuItem item : contextMenu.getItems()) {
if (/*item.getMenu() == null && */
!CommonUtils.isEmpty(item.getText())) {
item.setText(String.valueOf(keyIndex) + ". " + item.getText());
keyIndex++;
if (keyIndex >= 10) {
break;
}
}
}
}
});
return null;
}
use of org.eclipse.jface.action.Separator in project dbeaver by serge-rider.
the class MySQLSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {
@Override
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(terminateQueryAction);
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()));
}
};
}
use of org.eclipse.jface.action.Separator in project dbeaver by serge-rider.
the class ExasolServerSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer(this, parent, new ExasolServerSessionManager((ExasolDataSource) executionContext.getDataSource())) {
@Override
@SuppressWarnings("rawtypes")
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(terminateQueryAction);
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()));
}
};
}
Aggregations