title: How to know when a perspective is selected rcp
body: <p>In my class, I'm implementing IPerspectiveListener, IPartListener, in order to perform certain actions if certain perspective is activated in the method perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) and do something in the partActivated(IWorkbenchPart part). But the problem is, partActivated(IWorkbenchPart part) is getting called before perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective). Doesn't seem like above method is getting called on perspective switch manually. Is there any way to implement what I mentioned.</p>
  
  <pre><code>public class MyClass implements IPerspectiveListener, IPartListener {
  
   private boolean buttonClicked = false;
  
          @Override
          public void partActivated(IWorkbenchPart part) {
              try {
                  if(buttonClicked){
  
                       //do something
  
                 }
              } catch (WorkbenchException e) {
                  e.printStackTrace();
              }
  
          }
  
          @Override
          public void partBroughtToTop(IWorkbenchPart part) {
          }
  
          @Override
          public void partClosed(IWorkbenchPart part) {}
  
          @Override
          public void partDeactivated(IWorkbenchPart part) {}
  
          @Override
          public void partOpened(IWorkbenchPart part) {}
  
          @Override
          public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
          buttonClicked = true;
          }
  
  
          @Override
          public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
  
          }
  
  
  
      }
  </code></pre>