Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Using EventBroker in composites
Using EventBroker in composites [message #1744512] Tue, 27 September 2016 15:15
Dimg Cim is currently offline Dimg CimFriend
Messages: 59
Registered: December 2015
Member
Hi together,

I have a Problem to use IEventBroker injection in not ViewParts. Are there anyway to use this in Composites.

E.g. I Have two Views with 1 nested Composites, when I click in the first View I want to Change data in the second view nested composite.

I tried this

View 1
import javax.inject.Inject;

import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class View1 {

    @Inject
    IEventBroker broker;

    @Inject
    public View1(Composite parent) {
        Button button = new Button(parent, SWT.PUSH);
        button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
        button.setText("Ahhh");
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                broker.post("SEND", "TEST WORLD");
            }
        });

    }
}


View2
public class View2 {

    @Inject
    IEventBroker broker;

    @Inject
    public View2(Composite parent) {
        new TestComposite(parent);
    }

}


Nested Composite TestComposite.java
public class TestComposite extends Composite {

    public TestComposite(Composite parent) {
        super(parent, 0);
        Button button = new Button(parent, SWT.PUSH);
        button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
        button.setText("Beeeh");
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {

            }
        });
    }

    @Inject
    public void get(@UIEventTopic("SEND") String value) {
        System.out.println(value);
    }

}


The subribe method in the TestComposite won't be used.
How can I do this?

Many thanks
Dim
Previous Topic:P2 checks repository once
Next Topic:error in eclipse install new software
Goto Forum:
  


Current Time: Fri Apr 26 00:12:41 GMT 2024

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

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

Back to the top