Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2014-03-11 10:43:43 -0400
committerTom Schindl2014-03-11 10:44:28 -0400
commit17e5e35d2949cb9570b905ccadd4a6d7faa05d2b (patch)
tree62a70a7b360c5e8d375724d6bc8ce09213ea88ec /testcases
parent0c81fab915b8cdcfe11ce3c05176a63a7e214d4f (diff)
downloadorg.eclipse.efxclipse-17e5e35d2949cb9570b905ccadd4a6d7faa05d2b.tar.gz
org.eclipse.efxclipse-17e5e35d2949cb9570b905ccadd4a6d7faa05d2b.tar.xz
org.eclipse.efxclipse-17e5e35d2949cb9570b905ccadd4a6d7faa05d2b.zip
add support for event broker in controller
Diffstat (limited to 'testcases')
-rwxr-xr-xtestcases/org.eclipse.fx.testcases.e4/Application.e4xmi2
-rwxr-xr-xtestcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/ControlPanel.java14
-rw-r--r--testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXML.fxml2
-rw-r--r--testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLBuilder.java17
-rw-r--r--testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLController.java35
5 files changed, 67 insertions, 3 deletions
diff --git a/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi b/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
index f15c2fa38..1b141d4a2 100755
--- a/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
+++ b/testcases/org.eclipse.fx.testcases.e4/Application.e4xmi
@@ -44,7 +44,7 @@
<children xsi:type="basic:Part" xmi:id="_7H_jwBmWEeOe294q4QTZJg" elementId="org.eclipse.fx.testcases.e4.part.15" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.parts.TestPane" label="VBox Pane">
<tags>Container:VBox</tags>
</children>
- <children xsi:type="basic:Part" xmi:id="_UXm2oI3yEeOEhJYRfEsdog" elementId="org.eclipse.fx.testcases.e4.part.17" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.parts.TestFXMLBuilder" label="FXMLLoader"/>
+ <children xsi:type="basic:Part" xmi:id="_UXm2oI3yEeOEhJYRfEsdog" elementId="org.eclipse.fx.testcases.e4.part.17" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.parts.TestFXMLBuilder" label="FXMLLoader" closeable="true"/>
<children xsi:type="basic:Part" xmi:id="_NbT9cI3zEeOEhJYRfEsdog" elementId="org.eclipse.fx.testcases.e4.part.18" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.parts.TestExtendedFXMLBuilder" label="ExtendedFXMLLoader"/>
</children>
<children xsi:type="basic:Part" xmi:id="_txxY4OMsEeGP-5z69KadAQ" elementId="org.eclipse.fx.testcases.e4.part.4" toBeRendered="false" containerData="10" contributionURI="bundleclass://org.eclipse.fx.testcases.e4/org.eclipse.fx.testcases.e4.parts.ContentPanel" label="C4"/>
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/ControlPanel.java b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/ControlPanel.java
index 083b5029b..9543f8e29 100755
--- a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/ControlPanel.java
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/ControlPanel.java
@@ -66,7 +66,7 @@ public class ControlPanel {
@SuppressWarnings("rawtypes")
@Inject
- public ControlPanel(BorderPane p, final MApplication application, final MWindow window, @Optional final MPerspective perspective, final EPartService partService, final EModelService modelService, PopupMenuService<Control> menuService, IEventBroker broker) {
+ public ControlPanel(BorderPane p, final MApplication application, final MWindow window, @Optional final MPerspective perspective, final EPartService partService, final EModelService modelService, PopupMenuService<Control> menuService, final IEventBroker broker) {
broker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new org.osgi.service.event.EventHandler() {
@Override
@@ -548,6 +548,18 @@ public class ControlPanel {
});
box.getChildren().add(button);
}
+
+ {
+ Button button = new Button("Send EventTopic");
+ button.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent event) {
+ System.gc();
+ broker.send("MyTopic", "Hello World");
+ }
+ });
+ box.getChildren().add(button);
+ }
p.setTop(box);
}
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXML.fxml b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXML.fxml
index d87459b52..91ae8f01f 100644
--- a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXML.fxml
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXML.fxml
@@ -3,7 +3,7 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.Button?>
-<HBox xmlns:fx="http://javafx.com/fxml">
+<HBox xmlns:fx="http://javafx.com/fxml" fx:controller="org.eclipse.fx.testcases.e4.parts.TestFXMLController">
<Button text="Hello World"></Button>
</HBox>
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLBuilder.java b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLBuilder.java
index b4f62eb87..7106317b6 100644
--- a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLBuilder.java
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLBuilder.java
@@ -6,10 +6,16 @@ import javafx.scene.Node;
import javafx.scene.layout.BorderPane;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.core.di.extensions.EventTopic;
+import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.fx.ui.di.FXMLBuilder;
import org.eclipse.fx.ui.di.FXMLLoader;
import org.eclipse.fx.ui.di.FXMLLoaderFactory;
+import org.osgi.service.event.Event;
public class TestFXMLBuilder {
@PostConstruct
@@ -22,4 +28,15 @@ public class TestFXMLBuilder {
e.printStackTrace();
}
}
+
+ @Inject
+ public void setContext(IEclipseContext context) {
+ System.err.println("CONTEXT: " + context);
+ }
+
+ @Inject
+ @Optional
+ public void receiveEvent(@EventTopic("MyTopic") Event event) {
+ System.err.println("Receiving Topic: " + event);
+ }
}
diff --git a/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLController.java b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLController.java
new file mode 100644
index 000000000..d07a0f6aa
--- /dev/null
+++ b/testcases/org.eclipse.fx.testcases.e4/src/org/eclipse/fx/testcases/e4/parts/TestFXMLController.java
@@ -0,0 +1,35 @@
+package org.eclipse.fx.testcases.e4.parts;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.core.di.extensions.EventTopic;
+import org.eclipse.e4.ui.di.UIEventTopic;
+import org.osgi.service.event.Event;
+
+public class TestFXMLController {
+
+ @PostConstruct
+ public void init() {
+ System.err.println("Created");
+ }
+
+ @PreDestroy
+ public void cleanup() {
+ System.err.println("Destroyed");
+ }
+
+ @Inject
+ @Optional
+ public void receiveEvent(@EventTopic("MyTopic") Event event) {
+ System.err.println("CONTROLLER Receiving Topic: " + event);
+ }
+
+ @Inject
+ public void setContext(IEclipseContext context) {
+ System.err.println("CONTROLLER CONTEXT: " + context);
+ }
+}

Back to the top