use of net.sourceforge.sqlexplorer.dbproduct.User 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();
}
use of net.sourceforge.sqlexplorer.dbproduct.User 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;
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class SQLEditorCatalogSwitcher method createControl.
protected Control createControl(Composite parent) {
_catalogCombo = new Combo(parent, SWT.READ_ONLY);
_catalogCombo.setToolTipText(Messages.getString("SQLEditor.Actions.ChooseCatalog.ToolTip"));
_catalogCombo.setSize(200, _catalogCombo.getSize().y);
_catalogCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
int selIndex = _catalogCombo.getSelectionIndex();
String newCat = _catalogCombo.getItem(selIndex);
if (_editor.getSession() != null) {
try {
_editor.getSession().setCatalog(newCat);
} catch (Exception e1) {
SQLExplorerPlugin.error("Error changing catalog", e1);
}
}
}
});
_catalogCombo.add("");
if (_editor.getSession() != null) {
try {
String[] catalogs = getMetaDataSession().getCatalogs();
User user = _editor.getSession().getUser();
// Get the connection directly from the user because the session may be busy with its one one
SQLConnection connection = user.getConnection();
try {
String currentCatalog = connection.getCatalog();
for (int i = 0; i < catalogs.length; i++) {
_catalogCombo.add(catalogs[i]);
if (currentCatalog.equals(catalogs[i])) {
_catalogCombo.select(_catalogCombo.getItemCount() - 1);
}
}
} finally {
if (connection != null)
user.releaseConnection(connection);
}
} catch (SQLException e) {
SQLExplorerPlugin.error(e);
}
}
return _catalogCombo;
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class SQLEditorSessionSwitcher method setSessionOptions.
private void setSessionOptions() {
if (_sessionCombo.isDisposed()) {
return;
}
_sessionCombo.removeAll();
_sessionCombo.add("");
int index = 0;
User currentUser = null;
if (_editor.getSession() != null) {
currentUser = _editor.getSession().getUser();
}
for (Alias alias : SQLExplorerPlugin.getDefault().getAliasManager().getAliases()) {
for (User user : alias.getUsers()) {
_sessionCombo.add(user.getDescription());
sessionIndexes.put(new Integer(index++), user);
// MOD msjian TDQ-5927 2013-5-24: set the item identify by the username, url and connection name
if (currentUser != null) {
boolean isMatched = currentUser.getUserName().equals(user.getUserName()) && currentUser.getAlias().getUrl().equals(alias.getUrl());
if (currentUser.getDatabaseConnection() != null) {
isMatched = isMatched && currentUser.getDatabaseConnection().getName().equals(alias.getName());
}
if (isMatched) {
_sessionCombo.select(_sessionCombo.getItemCount() - 1);
}
}
}
}
}
use of net.sourceforge.sqlexplorer.dbproduct.User 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;
}
Aggregations