Search in sources :

Example 6 with Alias

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

the class ConnectionTreeLabelProvider method getText.

/**
 * Return the text to display
 *
 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
 */
public String getText(Object element) {
    if (element instanceof Alias) {
        Alias alias = (Alias) element;
        String label = alias.getName();
        int numSessions = 0;
        for (User user : alias.getUsers()) numSessions += user.getConnections().size();
        if (numSessions == 1)
            return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.single.Postfix") + // $NON-NLS-1$
            ")";
        if (numSessions > 1)
            return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.multiple.Postfix") + // $NON-NLS-1$
            ")";
        return label;
    } else if (element instanceof User) {
        User user = (User) element;
        return user.getUserName();
    } else if (element instanceof SQLConnection) {
        SQLConnection connection = (SQLConnection) element;
        String label;
        if (connection.getDescription() == null) {
            // $NON-NLS-1$
            SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss");
            // $NON-NLS-2$
            label = Messages.getString("ConnectionsView.ConnectedAlias.ConnectedSince") + ' ' + fmt.format(new Date(connection.getCreatedTime()));
        } else
            // $NON-NLS-2$
            label = Messages.getString("ConnectionsView.ConnectedAlias.Connection") + ' ' + connection.getDescription();
        if (connection.isPooled())
            // $NON-NLS-1$
            label += ' ' + Messages.getString("ConnectionsView.ConnectedAlias.Pooled");
        return label;
    }
    return null;
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 7 with Alias

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

the class DeleteAction method run.

public void run() {
    boolean okToDelete = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.getString("ConnectionsView.ConfirmDelete.WindowTitle"), Messages.getString("ConnectionsView.ConfirmDelete.Message"));
    if (!okToDelete)
        return;
    for (User user : getView().getSelectedUsers(false)) user.getAlias().removeUser(user);
    for (Alias alias : getView().getSelectedAliases(false)) alias.remove();
    getView().refresh();
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias)

Example 8 with Alias

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

the class DeleteAction method isAvailable.

/**
 * Only show action when there is at least 1 alias selected
 *
 * @see net.sourceforge.sqlexplorer.connections.actions.AbstractConnectionTreeAction#isAvailable()
 */
public boolean isAvailable() {
    if (getView() == null)
        return false;
    Set<Alias> aliases = getView().getSelectedAliases(false);
    Set<User> users = getView().getSelectedUsers(false);
    if (aliases.isEmpty() && users.isEmpty())
        return false;
    for (User user : users) if (user.getAlias().hasNoUserName())
        return false;
    return true;
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias)

Example 9 with Alias

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

the class NewAliasAction method run.

public void run() {
    CreateAliasDlg dlg = new CreateAliasDlg(Display.getCurrent().getActiveShell(), CreateAliasDlg.Type.CREATE, new Alias());
    dlg.open();
    getView().refresh();
}
Also used : Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) CreateAliasDlg(net.sourceforge.sqlexplorer.dialogs.CreateAliasDlg)

Example 10 with Alias

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

Aggregations

Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)27 User (net.sourceforge.sqlexplorer.dbproduct.User)14 SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)6 AliasManager (net.sourceforge.sqlexplorer.dbproduct.AliasManager)5 DatabaseStructureView (net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 SQLExplorerPlugin (net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin)4 PartInitException (org.eclipse.ui.PartInitException)4 Iterator (java.util.Iterator)3 LinkedHashSet (java.util.LinkedHashSet)3 CreateAliasDlg (net.sourceforge.sqlexplorer.dialogs.CreateAliasDlg)3 MalformedURLException (java.net.MalformedURLException)2 SQLCannotConnectException (net.sourceforge.sqlexplorer.SQLCannotConnectException)2 Session (net.sourceforge.sqlexplorer.dbproduct.Session)2 OpenPasswordConnectDialogAction (net.sourceforge.sqlexplorer.plugin.actions.OpenPasswordConnectDialogAction)2 SQLEditor (net.sourceforge.sqlexplorer.plugin.editors.SQLEditor)2 SQLEditorInput (net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput)2 Menu (org.eclipse.swt.widgets.Menu)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1