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