Search in sources :

Example 1 with AliasManager

use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.

the class SQLExplorerPlugin method start.

/**
 * Initialises the Plugin
 */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    this.bundleContext = context;
    try {
        getLog().addLogListener(new ILogListener() {

            @Override
            public void logging(IStatus status, String plugin) {
                Throwable t = status.getException();
                if (t != null) {
                    System.err.println(t.getMessage());
                    t.printStackTrace(System.err);
                }
            }
        });
        driverManager = new DriverManager();
        // MOD qiongli TDQ-8893.we will don't use the xml file to maintain the ManagedDrivers later.so no need to
        // laod or save the xml files.
        // driverManager.loadDrivers();
        aliasManager = new AliasManager();
        try {
            // $NON-NLS-1$
            resourceBundle = ResourceBundle.getBundle("net.sourceforge.sqlexplorer.test");
        } catch (MissingResourceException x) {
            resourceBundle = null;
        }
        // load SQL History from previous sessions
        _history = new SQLHistory();
    } catch (Exception e) {
        error("Exception during start", e);
        throw e;
    }
}
Also used : AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) IStatus(org.eclipse.core.runtime.IStatus) MissingResourceException(java.util.MissingResourceException) ILogListener(org.eclipse.core.runtime.ILogListener) DriverManager(net.sourceforge.sqlexplorer.dbproduct.DriverManager) SQLHistory(net.sourceforge.sqlexplorer.history.SQLHistory) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) SQLCannotConnectException(net.sourceforge.sqlexplorer.SQLCannotConnectException)

Example 2 with AliasManager

use of net.sourceforge.sqlexplorer.dbproduct.AliasManager 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 3 with AliasManager

use of net.sourceforge.sqlexplorer.dbproduct.AliasManager 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)

Example 4 with AliasManager

use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.

the class ConnectionTreeContentProvider method getChildren.

/**
 * Return all the children
 *
 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
 */
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof AliasManager) {
        AliasManager aliases = (AliasManager) parentElement;
        Object[] children = aliases.getAliases().toArray();
        return children;
    } else if (parentElement instanceof Alias) {
        Alias alias = (Alias) parentElement;
        Object[] children = alias.getUsers().toArray();
        return children;
    } else if (parentElement instanceof User) {
        User user = (User) parentElement;
        return user.getConnections().toArray();
    }
    return null;
}
Also used : AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias)

Example 5 with AliasManager

use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.

the class SqlexplorerService method aliasExist.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ISqlexplorerService#aliasExist(java.lang.String)
     */
@Override
public boolean aliasExist(String connectionName) {
    SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
    AliasManager aliasManager = sqlPlugin.getAliasManager();
    Alias alias = aliasManager.getAlias(connectionName);
    return alias != null;
}
Also used : AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLExplorerPlugin(net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin)

Aggregations

AliasManager (net.sourceforge.sqlexplorer.dbproduct.AliasManager)6 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)5 SQLExplorerPlugin (net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin)4 PartInitException (org.eclipse.ui.PartInitException)3 MalformedURLException (java.net.MalformedURLException)2 DriverManager (net.sourceforge.sqlexplorer.dbproduct.DriverManager)2 User (net.sourceforge.sqlexplorer.dbproduct.User)2 DatabaseStructureView (net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView)2 MissingResourceException (java.util.MissingResourceException)1 SQLCannotConnectException (net.sourceforge.sqlexplorer.SQLCannotConnectException)1 ManagedDriver (net.sourceforge.sqlexplorer.dbproduct.ManagedDriver)1 SQLHistory (net.sourceforge.sqlexplorer.history.SQLHistory)1 AliasAndManaDriverHelper (net.sourceforge.sqlexplorer.util.AliasAndManaDriverHelper)1 ILogListener (org.eclipse.core.runtime.ILogListener)1 IStatus (org.eclipse.core.runtime.IStatus)1 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 DataProvider (orgomg.cwm.foundation.softwaredeployment.DataProvider)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1