see also bugzilla enhancement
bug: Bug 268103
I noticed that in
org.eclipse.riena.navigation.ui.swt.views.NavigationViewFactory the current
implementation always returns a
static instance for the specific view
(moduleGroup, module). I need to
specify a specific user related type of view,
which is responsible for a
doubleClick on a subModule.
So I've implemented a more
generic way to specify the real class for a specific
factory type. there is a new
extension point
org.eclipse.riena.navigation.ui.swt.defaultFactoryClass
which can be used to
overload the defaults.
In the attached zip you can find
the extension-point scheme, the modified
plugin.xml exporting the scheme,
the modified NavigationViewFactory class using
the new extension point and the
new annotated ExtensionInterface class
IDefaultFactoryClassDesc.
Maybe it's a good idea to adopt
all kinds of factories with a behavior like
this. In this case we must move
the extension point into a bundle closer to the
...riena.core classes to make it
available for other factories.
Unfortunately I am unable to
provide a real cvs patch file, because i've to
work completely offline without
cvs access from the reimported target platform
bundle. changes are based on the
release build 1.0.
Usage Example below…
The usage of the new extension
point:
<!--
**********************************************************************
The next entry registers a specific ModuleView SubClass for the
NavigationFactory
wich allows to handle doubleclick action on a subModule.
*********************************************************************** -->
<extension
point="org.eclipse.riena.navigation.ui.swt.defaultFactoryClass">
<defaultFactoryClass
type="ModuleView" factoryClass="de.stf.client.riena.base.navigation.MyModuleView"
/>
</extension>
An example ModuleView subclass registering a
doubleClick event listener:
/*
* This class is an example how to overload the default
behavior of the ModuleView.
* In this implementation we add a doubleclick handler.
* */
package de.stf.client.riena.base.navigation;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.swt.views.ModuleView;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TreeItem;
/** */
public class MyModuleView extends ModuleView {
/**
* Konstruktor für eine HMModuleView.
*
* @param parent das parent {@link Composite} für diese
{@link ModuleView}
*/
public HMModuleView(Composite parent) {
super(parent);
}
/**
* {@inheritDoc}
*
* @see
org.eclipse.riena.navigation.ui.swt.views.ModuleView#createBodyContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createBodyContent(Composite parent) {
super.createBodyContent(parent);
addMyListeners();
}
/**
* Registriert einen double-click MouseListener für
alle @link ISubModuleView}. Für alle
* Instanzen welche über einen assoziierten {@link
INavigationnodeController} verfügen, welcher
* das {@link IDoubleClickHandler} Interface
implementiert wird bei doubleClick die Methode
* <code>doubleClicked()</code> aufgerufen.
*/
private void addMyListeners() {
MouseAdapter mouseAdapter = new
MouseAdapter() {
@Override
public void
mouseDoubleClick(MouseEvent event) {
TreeItem[] selection = getTree().getSelection();
if (selection[0].getData() instanceof ISubModuleNode) {
ISubModuleNode node = (ISubModuleNode) selection[0].getData();
if (node.getNavigationNodeController() instanceof IDoubleClickHandler) {
IDoubleClickHandler activeSubModuleController = (IDoubleClickHandler)
node.getNavigationNodeController();
activeSubModuleController.doubleClicked();
System.out.println(".mouseDoubleClick() handler=" +
activeSubModuleController.getClass());
}
}
}
};
getTree().addMouseListener(mouseAdapter);
}
}
The Interface which an associated
SubModuleController has to implement, when he want’s a doubleClick
notification.
package
de.hansemerkur.client.riena.base.navigation;
/** */
public interface IDoubleClickHandler {
/**
* This method is called when the associated UI widget
is doubleclicked.
*/
void doubleClicked();
}
Regards, Stefan