Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » IStatusLineManger
IStatusLineManger [message #1042407] Tue, 16 April 2013 11:46 Go to next message
Dennis Murray is currently offline Dennis MurrayFriend
Messages: 4
Registered: April 2013
Junior Member
Hi,

I try to use the IStatusLineManaer in an eclipse 4 plugin.
I found following snippet:

@Inject
IStatusLineManager statusLine;
...
statusLine.setMessage(msg);


/*******************************************************************************
 * Copyright (c) 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package de.testplugin.test.handlers;

import javax.inject.Inject;
import javax.inject.Named;

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;

public class AboutHandler {
	@Inject
	IStatusLineManager statusLine;
	
	@Execute
	public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
		statusLine.setMessage("text");
		MessageDialog.openInformation(shell, "About", "e4 Application example.");
	}
}


After I start the plugin I get the following error message:
org.eclipse.e4.core.di.InjectionException: Unable to process "AboutHandler.statusLine": no actual value was found for the argument "IStatusLineManager"


Thanks for your help
Re: IStatusLineManger [message #1042473 is a reply to message #1042407] Tue, 16 April 2013 13:26 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5462
Registered: July 2009
Senior Member
Do not use @Inject in handlers but put it into the execute-method as an
argument.

Tom

On 16.04.13 15:08, Dennis Murray wrote:
> Hi,
>
> I try to use the IStatusLineManaer in an eclipse 4 plugin.
> I found following snippet:
>
> @Inject
> IStatusLineManager statusLine;
> ..
> statusLine.setMessage(msg);
>
> /*******************************************************************************
>
> * Copyright (c) 2010 IBM Corporation and others.
> * All rights reserved. This program and the accompanying materials
> * are made available under the terms of the Eclipse Public License v1.0
> * which accompanies this distribution, and is available at
> * http://www.eclipse.org/legal/epl-v10.html
> *
> * Contributors:
> * IBM Corporation - initial API and implementation
> *******************************************************************************/
>
> package de.testplugin.test.handlers;
>
> import javax.inject.Inject;
> import javax.inject.Named;
>
> import org.eclipse.e4.core.di.annotations.Execute;
> import org.eclipse.e4.ui.services.IServiceConstants;
> import org.eclipse.jface.action.IStatusLineManager;
> import org.eclipse.jface.dialogs.MessageDialog;
> import org.eclipse.swt.widgets.Shell;
>
> public class AboutHandler {
> @Inject
> IStatusLineManager statusLine;
>
> @Execute
> public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell
> shell) {
> statusLine.setMessage("text");
> MessageDialog.openInformation(shell, "About", "e4 Application
> example.");
> }
> }
>
> After I start the plugin I get the following error message:
> org.eclipse.e4.core.di.InjectionException: Unable to process
> "AboutHandler.statusLine": no actual value was found for the argument
> "IStatusLineManager"
>
>
> Thanks for your help
>
Re: IStatusLineManger [message #1043019 is a reply to message #1042473] Wed, 17 April 2013 06:57 Go to previous messageGo to next message
Dennis Murray is currently offline Dennis MurrayFriend
Messages: 4
Registered: April 2013
Junior Member
Thanks Tom. But now I have another Problem. I want to add a Statusbar in my e4 App. So i created a ToolControl, set it to the bottom of the window and linked it with the following class:

public class StatusLine {

	public StatusLine() {
	}

	/**
	 * Create contents of the StatusLine
	 */
	
	@PostConstruct
	public void createControls(Composite parent, IStatusLineManager statusManager) {
		
		
		StatusLineContributionItem field = new StatusLineContributionItem("HelloWorld");
		field.setText("Hello World");
		statusManager.add(field);

	}

	@PreDestroy
	public void dispose() {
	}

	@Focus
	public void setFocus() {
		// TODO	Set the focus to control
	}
}

And i get the same Error as before:
org.eclipse.e4.core.di.InjectionException: Unable to process "StatusLine#createControls()": no actual value was found for the argument "IStatusLineManager".

[Updated on: Wed, 17 April 2013 06:59]

Report message to a moderator

Re: IStatusLineManger [message #1043129 is a reply to message #1043019] Wed, 17 April 2013 10:12 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi,

I need this as well, looking at the IStatusLineManager a bit, I don't
think this concept is supported in e4 "out of the box". Note I am
talking pure e4 here, no dependencies on org.eclipse.ui.* plugins.

The IStatusLineManager in 3.x is produced by IActionBars
implementations, and guess what IActionBars is in the org.eclipse.ui
package/plugin.

Now, that's fine, because the whole concept of IActionBars is not
applicable in case of pure e4 (Wow, that's quiet a statement, please
shoot if this is wrong! ).

If you look a 3.x implementation of IActionBars (As seen in the attached
screenshot), you will see in SubActionBars for example this:

public IStatusLineManager getStatusLineManager() {
if (statusLineMgr == null) {
statusLineMgr = new SubStatusLineManager(parent
.getStatusLineManager());
statusLineMgr.setVisible(active);
}
return statusLineMgr;
}

So, what needs to be done for pure e4 is to add the creation of a
IStatusLineManager by Dependency injection. This is done with a
ContextInjectionFactory.make(...) method. You could do this perhaps in
the MPart related to the status line.

Hope this helps.
Cheers Christophe



On 17-04-13 08:57, Dennis Murray wrote:
> Thanks Tom. But now I have a another Problem. I want to add a Statusbar
> in my e4 App. So i created a ToolControl, set it to the bottom of the
> window and linked it with the following class:
> public class StatusLine {
>
> public StatusLine() {
> }
>
> /**
> * Create contents of the StatusLine
> */
>
> @PostConstruct
> public void createControls(Composite parent, IStatusLineManager
> statusManager) {
>
>
> StatusLineContributionItem field = new
> StatusLineContributionItem("HelloWorld");
> field.setText("Hello World");
> statusManager.add(field);
>
> }
>
> @PreDestroy
> public void dispose() {
> }
>
> @Focus
> public void setFocus() {
> // TODO Set the focus to control
> }
> }
> And i get the same Error as before:
> org.eclipse.e4.core.di.InjectionException: Unable to process
> "AboutHandler.statusLine": no actual value was found for the argument
> "IStatusLineManager"
>
>
Re: IStatusLineManger [message #1043883 is a reply to message #1043129] Thu, 18 April 2013 08:18 Go to previous message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

On a quick look I see that there is no one which puts a status line manager in the context hierarchy which means you can not inject it, no matter where you put your @Inject. If you want a status manager it's pretty trivial to provide an addon and put in a context of your choice (on a MWindow's context level for example) at start up and have it injected anywhere you need it.
Previous Topic:Edit entities with context menu via parameterized commands
Next Topic:ActionHandler behavior change in Eclipse 4?
Goto Forum:
  


Current Time: Sat Nov 22 00:31:13 GMT 2014

Powered by FUDForum. Page generated in 0.01808 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software