Search in sources :

Example 1 with NewEditorAction

use of net.sourceforge.sqlexplorer.connections.actions.NewEditorAction in project tdq-studio-se by Talend.

the class ConnectionTreeActionGroup method fillContextMenu.

/**
 * Fill the node context menu with all the correct actions.
 *
 * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
 */
public void fillContextMenu(IMenuManager menu) {
    ConnectionsView view = SQLExplorerPlugin.getDefault().getConnectionsView();
    Object[] selection = (view == null) ? null : view.getSelected();
    // If nothing is selected, then show the default ones
    if (selection == null || selection.length != 1) {
        // addAction(menu, new CloseAllConnectionsAction());
        return;
    }
    if (selection[0] instanceof Alias) {
        Alias alias = (Alias) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        addAction(menu, new ConnectAliasAction());
        menu.add(new Separator());
        for (User user : alias.getUsers()) if (!user.isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
            break;
        }
    // addAction(menu, new NewUserAction());
    // addAction(menu, new ChangeAliasAction());
    // addAction(menu, new CopyAliasAction());
    // addAction(menu, new DeleteAction());
    } else if (selection[0] instanceof User) {
        User user = (User) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        addAction(menu, new ConnectAliasAction());
        menu.add(new Separator());
        if (!user.isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
        }
    // addAction(menu, new NewUserAction());
    // addAction(menu, new EditUserAction());
    // addAction(menu, new CopyUserAction());
    // addAction(menu, new DeleteAction());
    } else if (selection[0] instanceof SQLConnection) {
        SQLConnection connection = (SQLConnection) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        menu.add(new Separator());
        if (!connection.getUser().isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
        }
    // addAction(menu, new CloseConnectionAction());
    }
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) NewDatabaseStructureViewAction(net.sourceforge.sqlexplorer.connections.actions.NewDatabaseStructureViewAction) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) NewEditorAction(net.sourceforge.sqlexplorer.connections.actions.NewEditorAction) ConnectAliasAction(net.sourceforge.sqlexplorer.connections.actions.ConnectAliasAction) RollbackAction(net.sourceforge.sqlexplorer.connections.actions.RollbackAction) Separator(org.eclipse.jface.action.Separator) CommitAction(net.sourceforge.sqlexplorer.connections.actions.CommitAction)

Aggregations

CommitAction (net.sourceforge.sqlexplorer.connections.actions.CommitAction)1 ConnectAliasAction (net.sourceforge.sqlexplorer.connections.actions.ConnectAliasAction)1 NewDatabaseStructureViewAction (net.sourceforge.sqlexplorer.connections.actions.NewDatabaseStructureViewAction)1 NewEditorAction (net.sourceforge.sqlexplorer.connections.actions.NewEditorAction)1 RollbackAction (net.sourceforge.sqlexplorer.connections.actions.RollbackAction)1 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)1 SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)1 User (net.sourceforge.sqlexplorer.dbproduct.User)1 Separator (org.eclipse.jface.action.Separator)1