Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Riena/Detached Views"

(Riena Detached Views How-To)
(Riena Detached Views)
Line 1: Line 1:
=== Riena Detached Views ===
+
== Riena Detached Views ==
  
 
This document explains how to easily open 'auxilary' views when a certain navigation node is selected in the main window.
 
This document explains how to easily open 'auxilary' views when a certain navigation node is selected in the main window.
Line 5: Line 5:
 
[[Image:riena_detached_views.png]]
 
[[Image:riena_detached_views.png]]
  
==== How-To ====
+
Riena has a mechanism that allows developers to show a <tt>ViewPart</tt> in a separate 'detached' shell/window. This can be used to show one or more views in separate shells. These shells are draggable, moveable, but not closeable.
  
Riena has a mechanism that allows developers to show any ViewPart in a separate 'detached' shell/window. This can be used to show one or more views in separate shells. These shells are draggable, moveable, but not closeable.
+
Only one view can be shown in each 'detached' shell. This view can be a regular <tt>ViewPart</tt> or an implementation of Riena's <tt>SubModuleView</tt>.
  
Only one view can be shown in each 'detached' shell. This view can be a regular ViewPart or an implementation of Riena's SubModuleView.
+
To show / hide / dispose the 'detached' shells, we want to react to events in the navigation tree on the left of the main window. Typically when a node is selected, the corresponding <tt>SubModuleView</tt> is shown in the workarea (i.e. main area on the right). When this happens we would like to show additional 'detached' views. When the navigation node becomes unselected, we would like to hide these views.
  
Using this mechanism is done in three steps:
+
To accomplish that we need to attach a custom listener to the view's navigation node. This is typically done in the <tt>#basicCreatePartControl(...)</tt> method of your sub module:
* deciding when to show / hide /dispose these detached shells.  
+
* deciding where to show these shells.
+
* using a DetachedViewMAnager to do the actual work.
+
  
TBD.
+
<source lang="java">
 +
protected void basicCreatePartControl(Composite parent) {
 +
  // ...
 +
  getNavigationNode().addSimpleListener(new NodeListener());
 +
}
 +
</source>
 +
 
 +
The class <tt>NodeListener</tt> extends <tt>SimpleNavigationNodeAdapter</tt>. This adapter has several methods, that are invoked at different points during the lifecycle of a navigation node. When the node becomes selected (=activated) the method <tt>#activated((INavigationNode source)</tt> is invoked -- in that case we show the detached view. When the node becomes de-selected (=deactivated) the method <tt>#deactivated(INavigationNode source)</tt> is invoked -- in that case we hide the detached view. When the node is destroyed (=disposed) the method <tt>#disposed(INavigationNode source)</tt> is invoked -- in that case perform any necessary clean-up.
 +
 
 +
<source lang="java">
 +
private final class NodeListener extends SimpleNavigationNodeAdapter {
 +
  public void activated(INavigationNode<?> source) {
 +
    // show detached views
 +
  }
 +
  public void deactivated(INavigationNode<?> source) {
 +
    // hide detached views
 +
  }
 +
  public void disposed(INavigationNode<?> source) {
 +
    // clean-up
 +
}
 +
</source>
 +
 
 +
 
 +
==== References ====
 +
 
 +
See:
 +
* class <tt>DetachedSubModuleView</tt> in the <tt>org.eclipse.riena.example.client</tt> bundle
 +
* class <tt>DetachedViewsManager</tt> in the <tt>org.eclipse.riena.ui.swt</tt> bundle
  
 
[[Category:Riena]]
 
[[Category:Riena]]

Revision as of 21:22, 13 May 2009

Riena Detached Views

This document explains how to easily open 'auxilary' views when a certain navigation node is selected in the main window.

Riena detached views.png

Riena has a mechanism that allows developers to show a ViewPart in a separate 'detached' shell/window. This can be used to show one or more views in separate shells. These shells are draggable, moveable, but not closeable.

Only one view can be shown in each 'detached' shell. This view can be a regular ViewPart or an implementation of Riena's SubModuleView.

To show / hide / dispose the 'detached' shells, we want to react to events in the navigation tree on the left of the main window. Typically when a node is selected, the corresponding SubModuleView is shown in the workarea (i.e. main area on the right). When this happens we would like to show additional 'detached' views. When the navigation node becomes unselected, we would like to hide these views.

To accomplish that we need to attach a custom listener to the view's navigation node. This is typically done in the #basicCreatePartControl(...) method of your sub module:

protected void basicCreatePartControl(Composite parent) {
  // ...
  getNavigationNode().addSimpleListener(new NodeListener());
}

The class NodeListener extends SimpleNavigationNodeAdapter. This adapter has several methods, that are invoked at different points during the lifecycle of a navigation node. When the node becomes selected (=activated) the method #activated((INavigationNode source) is invoked -- in that case we show the detached view. When the node becomes de-selected (=deactivated) the method #deactivated(INavigationNode source) is invoked -- in that case we hide the detached view. When the node is destroyed (=disposed) the method #disposed(INavigationNode source) is invoked -- in that case perform any necessary clean-up.

private final class NodeListener extends SimpleNavigationNodeAdapter {
  public void activated(INavigationNode<?> source) {
    // show detached views
  }
  public void deactivated(INavigationNode<?> source) {
    // hide detached views
  } 		
  public void disposed(INavigationNode<?> source) {
    // clean-up
}


References

See:

  • class DetachedSubModuleView in the org.eclipse.riena.example.client bundle
  • class DetachedViewsManager in the org.eclipse.riena.ui.swt bundle

Back to the top