use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class ConnectionsView method getSelectedConnections.
/**
* Returns a list of selected sessions; if recurse is true, then it includes indirectly selected sessions (eg a
* selected user's sessions)
*
* @param recurse
* @return Set of Sessions, never returns null
*/
public Set<SQLConnection> getSelectedConnections(boolean recurse) {
IStructuredSelection selection = (IStructuredSelection) _treeViewer.getSelection();
if (selection == null) {
return EMPTY_CONNECTIONS;
}
LinkedHashSet<SQLConnection> result = new LinkedHashSet<SQLConnection>();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof SQLConnection) {
result.add((SQLConnection) obj);
} else if (recurse) {
if (obj instanceof Alias) {
Alias alias = (Alias) obj;
for (User user : alias.getUsers()) {
result.addAll(user.getConnections());
}
} else if (obj instanceof User) {
User user = (User) obj;
result.addAll(user.getConnections());
}
}
}
return result;
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class CopyUserAction method run.
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
User user = getView().getSelectedUser(false);
EditUserDlg dlg = new EditUserDlg(Display.getCurrent().getActiveShell(), EditUserDlg.Type.COPY, user.getAlias(), user);
dlg.open();
getView().refresh();
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class EditUserAction method run.
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
User user = getView().getSelectedUser(false);
EditUserDlg dlg = new EditUserDlg(Display.getCurrent().getActiveShell(), EditUserDlg.Type.EDIT, user.getAlias(), user);
dlg.open();
getView().refresh();
}
use of net.sourceforge.sqlexplorer.dbproduct.User 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());
}
}
}
use of net.sourceforge.sqlexplorer.dbproduct.User 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;
}
Aggregations