use of net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter 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.connections.SessionEstablishedAdapter 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.connections.SessionEstablishedAdapter in project tdq-studio-se by Talend.
the class SQLEditor method setInput.
/*
* (non-JavaDoc)
*
* @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
*/
@Override
protected void setInput(IEditorInput input) {
super.setInput(input);
if (textEditor != null) {
textEditor.setInput(input);
}
// Handle our own form of input
if (input instanceof SQLEditorInput) {
SQLEditorInput sqlInput = (SQLEditorInput) input;
if (input != null) {
User user = sqlInput.getUser();
if (user != null) {
user.queueForNewSession(new SessionEstablishedAdapter() {
@Override
public void sessionEstablished(Session session) {
setSession(session);
}
});
}
isDirty = true;
isUntitled = true;
}
}
// set part name as displayName + " " + version
String partName = input.getName();
if (input instanceof FileEditorInput) {
FileEditorInput fileEditorInput = (FileEditorInput) input;
// $NON-NLS-1$
IPath fileName = fileEditorInput.getPath().removeFileExtension().addFileExtension("properties");
Property property = null;
URI propURI = URI.createFileURI(fileName.toOSString());
Resource resource = new ResourceSetImpl().getResource(propURI, true);
if (resource.getContents() != null) {
Object object = EcoreUtil.getObjectByType(resource.getContents(), PropertiesPackage.eINSTANCE.getProperty());
if (object != null) {
property = (Property) object;
}
}
if (property != null) {
// $NON-NLS-1$
partName = property.getDisplayName() + " " + property.getVersion();
}
}
setPartName(partName);
}
use of net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter in project tdq-studio-se by Talend.
the class SQLEditor method init.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
// Configure the editor
setSite(site);
// PTODO qzhang fixed bug 3904: syschronize the resource.
if (input instanceof FileEditorInput) {
try {
((FileEditorInput) input).getFile().getParent().refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
setInput(input);
// Create the text editor
textEditor = new SQLTextEditor(this);
textEditor.init(site, input);
// setPartName(getSite().getPage().getLabel());
// 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)
*/
@Override
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == SQLEditor.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);
}
});
}
}
}
}
Aggregations