use of net.sourceforge.sqlexplorer.dbproduct.Session in project tdq-studio-se by Talend.
the class FileListEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
// Configure the editor
setSite(site);
setInput(input);
// Create the text editor
editor = new TextEditor();
editor.init(site, input);
// Make sure we get notification that our editor is closing because
// we may need to stop running queries
getSite().getPage().addPartListener(new PartAdapter2() {
/* (non-JavaDoc)
* @see net.sourceforge.sqlexplorer.util.PartAdapter2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
*/
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == FileListEditor.this) {
onCloseEditor();
}
}
});
// If we havn't got a view, then try for the current session in the ConnectionsView
if (getSession() == null) {
ConnectionsView view = SQLExplorerPlugin.getDefault().getConnectionsView();
if (view != null) {
User user = view.getDefaultUser();
if (user != null)
user.queueForNewSession(new SessionEstablishedAdapter() {
@Override
public void sessionEstablished(Session session) {
setSession(session);
}
});
}
}
}
use of net.sourceforge.sqlexplorer.dbproduct.Session 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);
}
use of net.sourceforge.sqlexplorer.dbproduct.Session in project tdq-studio-se by Talend.
the class ConnectionsView method getDefaultAlias.
private Alias getDefaultAlias() {
IStructuredSelection selection = (IStructuredSelection) _treeViewer.getSelection();
if (selection == null) {
return null;
}
Object element = selection.getFirstElement();
if (element instanceof Alias) {
return (Alias) element;
} else if (element instanceof Session) {
ITreeContentProvider provider = (ITreeContentProvider) _treeViewer.getContentProvider();
return (Alias) provider.getParent(element);
}
return null;
}
use of net.sourceforge.sqlexplorer.dbproduct.Session in project tdq-studio-se by Talend.
the class CloseConnectionAction method run.
public void run() {
boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION);
for (SQLConnection connection : getView().getSelectedConnections(false)) {
Session session = connection.getSession();
if (session != null && !session.isConnectionInUse()) {
if (confirm) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getView().getSite().getShell(), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Title"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Message"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Toggle"), false, null, null);
if (dialog.getToggleState() && dialog.getReturnCode() == IDialogConstants.YES_ID)
SQLExplorerPlugin.getDefault().getPluginPreferences().setValue(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION, false);
if (dialog.getReturnCode() != IDialogConstants.YES_ID)
return;
}
session.disposeConnection();
} else if (session == null)
connection.getUser().releaseFromPool(connection);
}
getView().refresh();
}
use of net.sourceforge.sqlexplorer.dbproduct.Session in project tdq-studio-se by Talend.
the class CloseAllConnectionsAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.CONFIRM_BOOL_CLOSE_ALL_CONNECTIONS);
if (confirm) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getView().getSite().getShell(), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Title"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Message"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Toggle"), false, null, null);
if (dialog.getToggleState() && dialog.getReturnCode() == IDialogConstants.YES_ID)
SQLExplorerPlugin.getDefault().getPluginPreferences().setValue(IConstants.CONFIRM_BOOL_CLOSE_ALL_CONNECTIONS, false);
if (dialog.getReturnCode() != IDialogConstants.YES_ID)
return;
}
Set<SQLConnection> connections = getView().getSelectedConnections(true);
for (SQLConnection connection : connections) {
synchronized (connection) {
Session session = connection.getSession();
if (session != null) {
synchronized (session) {
if (!session.isConnectionInUse())
session.disposeConnection();
}
} else
connection.getUser().releaseFromPool(connection);
}
}
setEnabled(false);
getView().refresh();
}
Aggregations