在我的Eclipse中打开编辑器时,我可能希望根据编辑器的内容再次关闭它。
关闭刚刚打开的编辑器的最佳地点是哪里?是否有某种扩展点可用于此,或者是否有一种方法可以避免打开编辑器?
编辑器本身是通过扩展点org.eclipse.ui.editors添加的。
我试着用编辑器的连接方法来连接自己,但我没有设法避免编辑器的打开。
解决方案:感谢格雷格为我指明了正确的方向!
我的编辑器现在实现了IPartListener,实现的工作方式如下:
@Override
public void partOpened(IWorkbenchPart part) {
if (part instanceof MyEditor) {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(this, false);
}
}这将在打开编辑器后关闭它。
发布于 2014-06-03 09:25:35
您可以使用IPartListener侦听所有打开、关闭和正在激活的部件。
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
window.getPartService().addPartListener(partListener);https://stackoverflow.com/questions/24011365
复制相似问题