Search in sources :

Example 1 with DatabaseStructureView

use of net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView in project tdq-studio-se by Talend.

the class OpenPasswordConnectDialogAction method run.

public void run() {
    SessionEstablishedListener listener = null;
    if (!user.hasAuthenticated())
        listener = new SessionEstablishedAdapter() {

            @Override
            public void sessionEstablished(Session session) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        DatabaseStructureView dsView = SQLExplorerPlugin.getDefault().getDatabaseStructureView();
                        if (dsView != null)
                            try {
                                dsView.addUser(user);
                            } catch (SQLCannotConnectException e) {
                                MessageDialog.openError(Display.getDefault().getActiveShell(), "Cannot connect", e.getMessage());
                            }
                    }
                });
            }
        };
    ConnectionJob.createSession(alias, user, listener, alwaysPrompt);
}
Also used : SessionEstablishedListener(net.sourceforge.sqlexplorer.connections.SessionEstablishedListener) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SessionEstablishedAdapter(net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter) Session(net.sourceforge.sqlexplorer.dbproduct.Session) SQLCannotConnectException(net.sourceforge.sqlexplorer.SQLCannotConnectException)

Example 2 with DatabaseStructureView

use of net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView in project tdq-studio-se by Talend.

the class ConnectionsView method openNewEditor.

public void openNewEditor(User user) {
    try {
        // First time we connect, get the database structure view up too
        if (!user.hasAuthenticated()) {
            DatabaseStructureView dsView = SQLExplorerPlugin.getDefault().getDatabaseStructureView();
            dsView.addUser(user);
        }
        SQLEditorInput input = new SQLEditorInput("SQL Editor (" + SQLExplorerPlugin.getDefault().getEditorSerialNo() + // $NON-NLS-1$ $NON-NLS-2$
        ").sql");
        input.setUser(user);
        IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
        page.openEditor(input, SQLEditor.class.getName());
    } catch (SQLCannotConnectException e) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("ConnectionsView.cannotConnect"), e.getMessage());
    } catch (Throwable e) {
        SQLExplorerPlugin.error(Messages.getString("ConnectionsView.errCreateSql"), e);
    }
}
Also used : SQLEditorInput(net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput) SQLEditor(net.sourceforge.sqlexplorer.plugin.editors.SQLEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SQLCannotConnectException(net.sourceforge.sqlexplorer.SQLCannotConnectException)

Example 3 with DatabaseStructureView

use of net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView in project tdq-studio-se by Talend.

the class NewDatabaseStructureViewAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    DatabaseStructureView view = SQLExplorerPlugin.getDefault().getDatabaseStructureView();
    if (view == null) {
        return;
    }
    Collection<User> users = getView().getSelectedUsers(true);
    for (User user : users) {
        try {
            // ADD msjian TDQ-8535 2014-4-25: we need to do this to make sure the hive connection can be created
            // successfully
            setMetadataToUserAndUpdateDriver(user);
            // TDQ-8535~
            view.addUser(user);
        } catch (SQLCannotConnectException e) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Cannot connect", e.getMessage());
        }
    }
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SQLCannotConnectException(net.sourceforge.sqlexplorer.SQLCannotConnectException)

Example 4 with DatabaseStructureView

use of net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView in project tdq-studio-se by Talend.

the class SqlexplorerService method removeAliasInSQLExplorer.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.service.ISqlexplorerService#removeAliasInSQLExplorer(orgomg.cwm.foundation.softwaredeployment
     * .DataProvider[])
     */
@Override
public void removeAliasInSQLExplorer(DataProvider... dataproviders) {
    SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
    AliasManager aliasManager = sqlPlugin.getAliasManager();
    DatabaseStructureView dsView = sqlPlugin.findDatabaseStructureView();
    // alias from propertyFile map at the same time.
    try {
        Collection<Alias> aliases = aliasManager.getAliases();
        if (aliases.isEmpty()) {
            return;
        }
        for (DataProvider dataProvider : dataproviders) {
            String aliasName = dataProvider.getName();
            if (null == aliasName) {
                continue;
            }
            Alias alias = aliasManager.getAlias(aliasName);
            if (alias != null) {
                sqlPlugin.getPropertyFile().remove(alias);
                aliasManager.removeAlias(aliasName);
            }
            // if the ctabItem is open,close it.
            if (dsView != null) {
                dsView.closeCurrentCabItem(aliasName);
            }
        }
    } catch (Exception e) {
        log.error(e, e);
    }
    aliasManager.modelChanged();
}
Also used : DataProvider(orgomg.cwm.foundation.softwaredeployment.DataProvider) AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SQLExplorerPlugin(net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException)

Example 5 with DatabaseStructureView

use of net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView in project tdq-studio-se by Talend.

the class SqlexplorerService method updateConnetionAliasByName.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.service.ISqlexplorerService#updateConnetionAliasByName(org.talend.core.model.metadata.
     * builder.connection.Connection, java.lang.String)
     */
@Override
public void updateConnetionAliasByName(Connection connection, String aliasName) {
    if (connection == null || aliasName == null) {
        return;
    }
    SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
    // if the ctabItem is open,close it.
    DatabaseStructureView view = sqlPlugin.findDatabaseStructureView();
    if (view != null) {
        view.closeCurrentCabItem(aliasName);
    }
    AliasManager aliasManager = sqlPlugin.getAliasManager();
    Alias alias = aliasManager.getAlias(aliasName);
    if (alias != null) {
        try {
            aliasManager.removeAlias(aliasName);
            addConnetionAliasToSQLPlugin(connection);
        } catch (Exception e) {
            log.error(e, e);
        }
    }
}
Also used : AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SQLExplorerPlugin(net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException)

Aggregations

DatabaseStructureView (net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView)9 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)5 SQLCannotConnectException (net.sourceforge.sqlexplorer.SQLCannotConnectException)4 PartInitException (org.eclipse.ui.PartInitException)3 MalformedURLException (java.net.MalformedURLException)2 AliasManager (net.sourceforge.sqlexplorer.dbproduct.AliasManager)2 Session (net.sourceforge.sqlexplorer.dbproduct.Session)2 User (net.sourceforge.sqlexplorer.dbproduct.User)2 DatabaseNode (net.sourceforge.sqlexplorer.dbstructure.nodes.DatabaseNode)2 SQLExplorerPlugin (net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin)2 SQLEditor (net.sourceforge.sqlexplorer.plugin.editors.SQLEditor)2 SQLEditorInput (net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 SessionEstablishedAdapter (net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter)1 SessionEstablishedListener (net.sourceforge.sqlexplorer.connections.SessionEstablishedListener)1 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)1 SchemaNode (net.sourceforge.sqlexplorer.dbstructure.nodes.SchemaNode)1 TableFolderNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableFolderNode)1