AbstractTimeView.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.ui;
00002 
00003 import org.eclipse.ui.IPartListener2;
00004 import org.eclipse.ui.IViewSite;
00005 import org.eclipse.ui.IWorkbenchPage;
00006 import org.eclipse.ui.IWorkbenchPartReference;
00007 import org.eclipse.ui.part.ViewPart;
00008 
00009 public abstract class AbstractTimeView 
00010     extends ViewPart 
00011     implements IActiveNotification 
00012 {
00013 
00014     /*****
00015      * Setup the default listener
00016      * The derived class is recommended to call this function after the view is instantiated
00017      * such as during createPartControl
00018      */
00019     protected void addListener()
00020     {
00021         final IViewSite  viewSite = getViewSite();
00022         if (viewSite == null)
00023             return;
00024         
00025         final String id           = viewSite.getId();
00026         final IWorkbenchPage page = viewSite.getPage();
00027         
00028         page.addPartListener( new IPartListener2() {
00029             
00030             @Override
00031             /*
00032              * (non-Javadoc)
00033              * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
00034              */
00035             public void partVisible(IWorkbenchPartReference partRef) {
00036                 if (id.equals(partRef.getId())) {
00037                     active(true);
00038                 }
00039             }
00040             
00041             @Override
00042             /*
00043              * (non-Javadoc)
00044              * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
00045              */
00046             public void partHidden(IWorkbenchPartReference partRef) {
00047                 if (id.equals(partRef.getId())) {
00048                     active(false);
00049                 }
00050             }
00051             
00052             @Override
00053             /*
00054              * (non-Javadoc)
00055              * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
00056              */
00057             public void partClosed(IWorkbenchPartReference partRef) {
00058                 page.removePartListener(this);              
00059             }
00060             
00061             @Override
00062             public void partOpened(IWorkbenchPartReference partRef) {}
00063             
00064             @Override
00065             public void partInputChanged(IWorkbenchPartReference partRef) {}
00066             
00067             
00068             @Override
00069             public void partDeactivated(IWorkbenchPartReference partRef) {}
00070             
00071             @Override
00072             public void partBroughtToTop(IWorkbenchPartReference partRef) {}
00073             
00074             @Override
00075             public void partActivated(IWorkbenchPartReference partRef) {}
00076         });
00077     }
00078 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1