简体   繁体   English

Eclipse RCP:最小化视图时不要刷新

[英]Eclipse RCP: don't refresh View when it is minimized

We have View that shows file from Internet 我们有显示来自Internet的文件的视图

public class GfmView extends ViewPart implements GfmListener {

How to know when View is minimized, so maybe there is no need to refresh View. 如何知道何时将View最小化,因此也许不需要刷新View。

#8 [optimization] Don't update View when it is minimized #8 [优化]最小化视图时不要更新

Documentation doesn't say about it. 文档没有说明

You can add an org.eclipse.ui.IPartListener2 - Implementation to track the state of your view. 您可以添加org.eclipse.ui.IPartListener2实现来跟踪视图状态。 This listener is called if your view will be minimized (or closed or hidden or ...) 如果将视图最小化(或关闭或隐藏或...),则调用此侦听器

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(<myPartListener>)

@Tom: I'm afraid it is not always that simple... @Tom:恐怕并不总是那么简单...

In Eclipse Juno (4.2), the IPartListener2 notifies about visible-hidden and also about activated-deactivated. 在Eclipse Juno(4.2)中,IPartListener2通知有关可见隐藏的消息以及有关已激活的消息的消息。

But this does not allow me to reliably determine when a ViewPart is minimized. 但这不能让我可靠地确定何时最小化ViewPart。

  • visible-hidden is not triggered when minimizing or un-minimizing. 最小化或取消最小化时不会触发可见隐藏。 It is only used for covering / uncovering windows. 它仅用于覆盖/发现窗户。

  • activated-deactivated is triggered when a window is minimized / un-minimized. 当窗口最小化/未最小化时,激活-停用状态被触发。 But it is also triggered when the focus is changed to / from the window while the window is visible. 但是,当在窗口可见时将焦点从窗口更改为/时,也会触发该事件。 (So actually this seems to be a focusGained-focusLost notification.) (因此,实际上这似乎是一个focusGained-focusLost通知。)

Especially when a minimized window is restored (by pressing the icon with the stacked windows), there is no notification at all because the view does not gain the focus. 尤其是在还原最小化的窗口时(通过按下带有堆叠窗口的图标),因为视图无法获得焦点,所以根本没有任何通知。

Bottom line: For IPartListener2, minimized windows are visible. 底线:对于IPartListener2,最小化的窗口是可见的。

The question remains: How can I know when a view is minimized? 问题仍然存在:如何知道何时将视图最小化?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM