KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > resources > SootWorkbenchListener


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.resources;
21
22 import org.eclipse.ui.IEditorPart;
23 import org.eclipse.ui.IWindowListener;
24 import org.eclipse.ui.IWorkbenchWindow;
25
26 import ca.mcgill.sable.soot.SootPlugin;
27
28 public class SootWorkbenchListener implements IWindowListener {
29
30     private boolean initialized = false;
31     /* (non-Javadoc)
32      * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
33      */

34     public void windowActivated(IWorkbenchWindow window) {
35         if (!initialized){
36             window.getActivePage().addPartListener(new EditorActivationListener());
37             IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
38             SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
39             initialized = true;
40         }
41
42         
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
47      */

48     public void windowDeactivated(IWorkbenchWindow window) {
49         
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
54      */

55     public void windowClosed(IWorkbenchWindow window) {
56         
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
61      */

62     public void windowOpened(IWorkbenchWindow window) {
63         window.getActivePage().addPartListener(new EditorActivationListener());
64         IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
65         SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
66     }
67
68 }
69
Popular Tags