Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Scholz2014-10-07 17:02:21 +0000
committerSimon Scholz2014-10-07 17:02:21 +0000
commit61595b80f8deecfdb1d88e5ff25589ef1543ddc8 (patch)
tree20a6a710dc78969bbb4eef9202dee9c28832bee0
parentaa3add8a1949d893153117c4913d655ee0252544 (diff)
downloadorg.eclipse.e4.tools-61595b80f8deecfdb1d88e5ff25589ef1543ddc8.tar.gz
org.eclipse.e4.tools-61595b80f8deecfdb1d88e5ff25589ef1543ddc8.tar.xz
org.eclipse.e4.tools-61595b80f8deecfdb1d88e5ff25589ef1543ddc8.zip
Bug 446194 - The AddonTemplate should use the new @EventTopic APII20141007-2200
Change-Id: I7b0822f491d3ffe58211b912d972c88c346d852a Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/AddonTemplate.java8
-rw-r--r--bundles/org.eclipse.e4.tools/templates/addon.txtjet25
2 files changed, 17 insertions, 16 deletions
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/AddonTemplate.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/AddonTemplate.java
index 75bbfcd9..0f1e1f64 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/AddonTemplate.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/AddonTemplate.java
@@ -1,7 +1,7 @@
package org.eclipse.e4.internal.tools.wizards.classes.templates;
import org.eclipse.e4.internal.tools.wizards.classes.AbstractNewClassPage.JavaClass;
-@SuppressWarnings("nls")
+
public class AddonTemplate
{
protected static String nl;
@@ -17,8 +17,9 @@ public class AddonTemplate
protected final String TEXT_1 = " ";
protected final String TEXT_2 = NL + "package ";
protected final String TEXT_3 = ";";
- protected final String TEXT_4 = NL + NL + "import javax.inject.Inject;" + NL + "import javax.annotation.PostConstruct;" + NL + "import javax.annotation.PreDestroy;" + NL + "" + NL + "import org.eclipse.e4.core.services.events.IEventBroker;" + NL + "" + NL + "public class ";
- protected final String TEXT_5 = " {" + NL + "\t@Inject" + NL + "\tIEventBroker eventBroker;" + NL + "\t" + NL + "\t@PostConstruct" + NL + "\tvoid hookListeners() {" + NL + "\t\t// Hook event listeners" + NL + "\t}" + NL + "\t" + NL + "\t@PreDestroy" + NL + "\tvoid unhookListeners() {" + NL + "\t\t// Unhook event listeners" + NL + "\t}" + NL + "}";
+ protected final String TEXT_4 = NL + NL + "import javax.inject.Inject;" + NL + "" + NL + "import org.eclipse.e4.core.di.annotations.Optional;" + NL + "import org.eclipse.e4.core.di.extensions.EventTopic;" + NL + "import org.eclipse.e4.ui.workbench.UIEvents;" + NL + "import org.osgi.service.event.Event;" + NL + "" + NL + "import org.eclipse.e4.core.services.events.IEventBroker;" + NL + "" + NL + "public class ";
+ protected final String TEXT_5 = " {" + NL + "" + NL + "\t@Inject" + NL + "\t@Optional" + NL + "\tpublic void applicationStarted(" + NL + "\t\t\t@EventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event) {" + NL + "\t\t// TODO Modify the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE EventTopic to a certain event you want to listen to." + NL + "\t}" + NL + "" + NL + "}";
+ protected final String TEXT_6 = NL;
public String generate(Object argument)
{
@@ -33,6 +34,7 @@ public class AddonTemplate
stringBuffer.append(TEXT_4);
stringBuffer.append( domainClass.getName() );
stringBuffer.append(TEXT_5);
+ stringBuffer.append(TEXT_6);
return stringBuffer.toString();
}
}
diff --git a/bundles/org.eclipse.e4.tools/templates/addon.txtjet b/bundles/org.eclipse.e4.tools/templates/addon.txtjet
index b9806093..7404b0a0 100644
--- a/bundles/org.eclipse.e4.tools/templates/addon.txtjet
+++ b/bundles/org.eclipse.e4.tools/templates/addon.txtjet
@@ -5,22 +5,21 @@ package <%= domainClass.getPackageFragment().getElementName() %>;
<% } %>
import javax.inject.Inject;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
+
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.core.di.extensions.EventTopic;
+import org.eclipse.e4.ui.workbench.UIEvents;
+import org.osgi.service.event.Event;
import org.eclipse.e4.core.services.events.IEventBroker;
public class <%= domainClass.getName() %> {
+
@Inject
- IEventBroker eventBroker;
-
- @PostConstruct
- void hookListeners() {
- // Hook event listeners
+ @Optional
+ public void applicationStarted(
+ @EventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event) {
+ // TODO Modify the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE EventTopic to a certain event you want to listen to.
}
-
- @PreDestroy
- void unhookListeners() {
- // Unhook event listeners
- }
-} \ No newline at end of file
+
+}

Back to the top