Search in sources :

Example 1 with PartAdapter2

use of net.sourceforge.sqlexplorer.util.PartAdapter2 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);
                    }
                });
        }
    }
}
Also used : PartAdapter2(net.sourceforge.sqlexplorer.util.PartAdapter2) TextEditor(org.eclipse.ui.editors.text.TextEditor) User(net.sourceforge.sqlexplorer.dbproduct.User) ConnectionsView(net.sourceforge.sqlexplorer.connections.ConnectionsView) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) SessionEstablishedAdapter(net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter) Session(net.sourceforge.sqlexplorer.dbproduct.Session)

Example 2 with PartAdapter2

use of net.sourceforge.sqlexplorer.util.PartAdapter2 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);
                    }
                });
            }
        }
    }
}
Also used : PartAdapter2(net.sourceforge.sqlexplorer.util.PartAdapter2) User(net.sourceforge.sqlexplorer.dbproduct.User) CoreException(org.eclipse.core.runtime.CoreException) ConnectionsView(net.sourceforge.sqlexplorer.connections.ConnectionsView) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) SessionEstablishedAdapter(net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter) Session(net.sourceforge.sqlexplorer.dbproduct.Session)

Aggregations

ConnectionsView (net.sourceforge.sqlexplorer.connections.ConnectionsView)2 SessionEstablishedAdapter (net.sourceforge.sqlexplorer.connections.SessionEstablishedAdapter)2 Session (net.sourceforge.sqlexplorer.dbproduct.Session)2 User (net.sourceforge.sqlexplorer.dbproduct.User)2 PartAdapter2 (net.sourceforge.sqlexplorer.util.PartAdapter2)2 IWorkbenchPartReference (org.eclipse.ui.IWorkbenchPartReference)2 CoreException (org.eclipse.core.runtime.CoreException)1 TextEditor (org.eclipse.ui.editors.text.TextEditor)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1