在我的课程中,我正在实现IPerspectiveListener,IPartListener,以便在方法perspectiveActivated(IWorkbenchPage页面,IPerspectiveDescriptor透视图)中激活某些透视图时执行某些操作,并在partActivated(IWorkbenchPart部分)中执行某些操作。但问题是,partActivated(IWorkbenchPart部分)在perspectiveActivated(IWorkbenchPage页面,IPerspectiveDescriptor透视图)之前被调用。看起来上面的方法似乎没有手动调用透视切换。有没有办法实现我提到的。
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) {
}
}