Handler does not execute [message #957978] |
Thu, 25 October 2012 16:52 |
Christian Eugster Messages: 203 Registered: July 2009 Location: St. Gallen Switzerland |
Senior Member |
|
|
Hi,
In a eclipse4 app I have:
In the model:
a command add.level.command,
a command edit.level.command,
a part with toolbar with a Direct Toolbar Item that references a class AddLevelHandler and a handler edit.level.handler that references edit.level.command.
An implementation of:
the mentioned AddLevelHandler
a EditLevelHandler that is references by edit.level.handler.
Running the app, both toolbar items are shown but clicking on them does nothing. The objects AddLevelHandler and EditLevelHandler are instantiated on startup. The execution method is annotated with @Execute. There are no exceptions thrown.
As an example the code for AddLevelHandler. EditLevelHandler just has some minor differences.
package ch.eugster.herakles.tectonics.handlers;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Shell;
import ch.eugster.herakles.persistence.model.Level;
import ch.eugster.herakles.persistence.service.LevelService;
import ch.eugster.herakles.tectonics.dialogs.LevelInputDialog;
import ch.eugster.image.service.ImageConverter;
public class AddLevelHandler
{
@Inject
private Shell shell;
@Inject
private LevelService levelService;
@Inject
private ImageConverter imageConverter;
public AddLevelHandler()
{
System.out.println();
}
@Execute
public void execute()
{
Level level = Level.newInstance();
LevelInputDialog dialog = new LevelInputDialog(shell, level, imageConverter);
if (dialog.open() == IDialogConstants.OK_ID)
{
levelService.persist(level);
}
}
}
Can anyone tell me what I am missing? I did not find any hints googling. Thank you!
[Updated on: Thu, 25 October 2012 17:00] Report message to a moderator
|
|
|
|
Re: Handler does not execute [message #958982 is a reply to message #958940] |
Fri, 26 October 2012 11:06 |
Christian Eugster Messages: 203 Registered: July 2009 Location: St. Gallen Switzerland |
Senior Member |
|
|
I added the trace. There is nothing logged except some statements from aries concerning a service (LevelService) that is injected in the handler (so it seems to inject properly):
org.apache.aries.blueprint[org.apache.aries.blueprint.container.ServiceRecipe] : Retrieving service for bundle org.eclipse.e4.ui.workbench_0.10.3.v20120822-140642 [30] and service registration {ch.eugster.herakles.persistence.service.LevelService}={osgi.service.blueprint.compname=levelBean, service.id=112}
org.apache.aries.transaction.blueprint[org.apache.aries.transaction.TxComponentMetaDataHelperImpl] : Getting the txAttribute for the component {0} and method {1}
org.apache.aries.transaction.blueprint[org.apache.aries.transaction.TxComponentMetaDataHelperImpl] : Return the txAttribute {0} for the component and method
org.apache.aries.transaction.blueprint[org.apache.aries.transaction.TxInterceptorImpl] : Method: public java.lang.String java.lang.Object.toString(), has transaction strategy: REQUIRED
org.apache.aries.blueprint[org.apache.aries.blueprint.container.ServiceRecipe] : Method entry: getService, args ch.eugster.herakles.persistence.jpa.service.LevelServiceComponent@2ff7ac92
When I add @Inject to the execute method, the execute method is called. But as said by Tom Schindl in an other thread (http://www.eclipse.org/forums/index.php/mv/msg/385788/924928/#msg_924928), the @Inject annotation must not be added. Have you another suggestion?
[Updated on: Fri, 26 October 2012 11:11] Report message to a moderator
|
|
|
|
|
|
Re: Handler does not execute (SOLVED) [message #959122 is a reply to message #959083] |
Fri, 26 October 2012 13:21 |
Christian Eugster Messages: 203 Registered: July 2009 Location: St. Gallen Switzerland |
Senior Member |
|
|
As I understand, this is not necessary for DirectToolItem's. But: yes I had declared it for all handlers and removed some putting them to the classURI of DirectToolItems. The handlers for HandledToolItem's are declared in the model.
I got it: Header Import-Package was missing the package org.eclipse.e4.core.di.annotations.
This raises another question: Why does eclipse not complain the missing package? Even forcing "add dependencies" in the automated management of dependecies section of the manifest editor did resolve it (there the bundle org.eclipse.e4.core.di is included).
[Updated on: Fri, 26 October 2012 13:33] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03550 seconds