Frage

We have View that shows file from Internet

public class GfmView extends ViewPart implements GfmListener {

How to know when View is minimized, so maybe there is no need to refresh View.

#8 [optimization] Don't update View when it is minimized

Documentation doesn't say about it.

War es hilfreich?

Lösung

You can add an org.eclipse.ui.IPartListener2 - Implementation to track the state of your view. This listener is called if your view will be minimized (or closed or hidden or ...)

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

Andere Tipps

@Tom: I'm afraid it is not always that simple...

In Eclipse Juno (4.2), the IPartListener2 notifies about visible-hidden and also about activated-deactivated.

But this does not allow me to reliably determine when a ViewPart is minimized.

  • 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.)

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.

The question remains: How can I know when a view is minimized?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top