IStatusLineManger [message #1042407] |
Tue, 16 April 2013 07:46  |
Eclipse User |
|
|
|
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 #1043129 is a reply to message #1043019] |
Wed, 17 April 2013 06:12   |
Eclipse User |
|
|
|
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 #1829311 is a reply to message #1043883] |
Wed, 01 July 2020 06:47  |
Eclipse User |
|
|
|
The one that I tried an worked in an eclipse E4 based application as a replacement for IStatusLineManager. And it worked for me.
1. Created a Window Trim - Side Bottom
2. Added a Tool Control with a Handler Class
3. In that Handler class
Created a variable.
private CLabel status = null;
@PostConstruct
public void createComposite(Composite parent) {
int leftRightMargin = 5;
int topBottomMargin = 7;
String message = "Application Status";
status = new CLabel(parent, SWT.NONE, message, leftRightMargin, leftRightMargin,
topBottomMargin, topBottomMargin);
}
@Inject
@Optional
public void subscribeStatusErrorEvent(@UIEventTopic("CHANGE_STATUS") String status,
MApplication application) {
this.status .setImage(image); // Needed if you need to set any Images
this.status .setText(status);
this.ctiState.requestLayout();
}
4. When ever need to change the Status. Send a event using the IEventBroker
|
|
|
Powered by
FUDForum. Page generated in 0.04481 seconds