Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/runtime/org.eclipse.fx.ui.lifecycle')
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore1
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.project33
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF18
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties5
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml34
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java14
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java78
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java16
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java47
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java14
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java14
15 files changed, 300 insertions, 0 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath
new file mode 100644
index 000000000..098194ca4
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore
new file mode 100644
index 000000000..5e56e040e
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.project b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.project
new file mode 100644
index 000000000..7b38d57b1
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.fx.ui.lifecycle</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..f42de363a
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..e8ff8be0b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..795322649
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Lifecycle
+Bundle-SymbolicName: org.eclipse.fx.ui.lifecycle
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.eclipse.e4.ui.model.workbench,
+ org.eclipse.e4.core.di,
+ org.eclipse.e4.core.contexts,
+ org.eclipse.e4.core.services,
+ org.eclipse.e4.ui.workbench,
+ org.eclipse.emf.ecore;bundle-version="2.9.0"
+Export-Package: org.eclipse.fx.ui.lifecycle,
+ org.eclipse.fx.ui.lifecycle.annotations
+Import-Package: javax.annotation;version="1.1.0",
+ javax.inject;version="1.0.0"
+Service-Component: OSGI-INF/component.xml
+Bundle-ActivationPolicy: lazy
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml b/bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml
new file mode 100644
index 000000000..86219f015
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ui.lifecycle">
+ <implementation class="org.eclipse.fx.ui.internal.lifecycle.LifecycleContextFunction"/>
+ <service>
+ <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
+ </service>
+ <property name="service.context.key" type="String" value="org.eclipse.fx.ui.lifecycle.ELifecycleService"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties b/bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties
new file mode 100644
index 000000000..c58ea2178
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml b/bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml
new file mode 100644
index 000000000..a807df10d
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <name>e(fx)clipse - Runtime - e4 - Lifecycle Service API</name>
+ <groupId>org.eclipse.fx</groupId>
+ <artifactId>org.eclipse.fx.ui.lifecycle</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <parent>
+ <groupId>org.eclipse.fx</groupId>
+ <artifactId>releng</artifactId>
+ <relativePath>../../../releng/org.eclipse.fx.releng/pom.xml</relativePath>
+ <version>0.8.1-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <resources>
+ <!-- to ensure that the feature lookup of the ui test works -->
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>META-INF/</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java
new file mode 100644
index 000000000..a646b7da6
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java
@@ -0,0 +1,14 @@
+package org.eclipse.fx.ui.internal.lifecycle;
+
+import org.eclipse.e4.core.contexts.ContextFunction;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+
+public class LifecycleContextFunction extends ContextFunction {
+
+ @Override
+ public Object compute(IEclipseContext context, String contextKey) {
+ return ContextInjectionFactory.make(LifecycleServiceImpl.class, context);
+ }
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java
new file mode 100644
index 000000000..54316919d
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java
@@ -0,0 +1,78 @@
+package org.eclipse.fx.ui.internal.lifecycle;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.services.contributions.IContributionFactory;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.MContext;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.fx.ui.lifecycle.ELifecycleService;
+import org.eclipse.fx.ui.lifecycle.LifecycleAddon;
+
+public class LifecycleServiceImpl implements ELifecycleService{
+
+ @Inject
+ private EModelService modelService;
+
+ @Inject
+ private MApplication app;
+
+ @Inject
+ private IContributionFactory factory;
+
+ public void registerLifecycleURI(MUIElement element, String lifecycleURI) {
+ Set<Object> contributions = (Set<Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (contributions == null) {
+ contributions = new HashSet<Object>();
+ element.getTransientData().put(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY, contributions);
+ }
+
+ Object object = factory.create(lifecycleURI, app.getContext());
+ contributions.add(object);
+
+ }
+
+ public boolean validateAnnotation(Class annotationClass, MUIElement element, IEclipseContext context) {
+ return validateLifecycleAnnotation(annotationClass, getContextForParent(element), context, element);
+ }
+
+ private boolean validateLifecycleAnnotation(Class clazz, IEclipseContext parentContext,
+ IEclipseContext partContext, MUIElement part) {
+ Set<Object> set = (Set<Object>) part.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (set!=null){
+ for (Object object : set) {
+ Object invokeResult = ContextInjectionFactory.invoke(object, clazz, parentContext, partContext,true);
+ if (invokeResult!=null){//supports void methods
+ return (boolean)invokeResult;
+ }
+ else return true;
+ }
+ }
+ return true;
+ }
+ private IEclipseContext getContextForParent(MUIElement element) {
+ return modelService.getContainingContext(element);
+ }
+
+ private IEclipseContext getModelContext(MUIElement part) {
+ if (part instanceof MContext) {
+ return ((MContext) part).getContext();
+ }
+ return getContextForParent(part);
+ }
+
+ @Override
+ public void unregisterLifecycleContribution(MUIElement element,
+ Object contribution) {
+ Set<Object> objects = (Set<Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (objects!=null) objects.remove(contribution);
+ }
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java
new file mode 100644
index 000000000..fd1afe872
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java
@@ -0,0 +1,16 @@
+package org.eclipse.fx.ui.lifecycle;
+
+import java.lang.annotation.Annotation;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+
+public interface ELifecycleService {
+
+ public void registerLifecycleURI(MUIElement element, String lifecycleURI);
+
+ public void unregisterLifecycleContribution(MUIElement element, Object contribution);
+
+ public boolean validateAnnotation(Class<? extends Annotation> annotationClass, MUIElement element, IEclipseContext context);
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java
new file mode 100644
index 000000000..fc07466aa
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java
@@ -0,0 +1,47 @@
+package org.eclipse.fx.ui.lifecycle;
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+
+//when we are ready to ditch the tag-based stuff we simply swap the addon
+public class LifecycleAddon {
+
+ @Inject
+ MApplication app;
+
+// @Inject
+// EModelService modelService;
+
+ @Inject
+ ELifecycleService lifecycleService;
+
+ public static final String LIFECYCLE_TRANSIENT_KEY="EFX_LIFECYCLE";
+
+ public static final String LIFECYCLE_TAG_PREFIX = "EFX_LC:";
+
+ @PostConstruct
+ public void postConstruct(){
+ TreeIterator<EObject> it = EcoreUtil.getAllContents((EObject)app, true);
+ while( it.hasNext() ) {
+ EObject e = it.next();
+ if( e instanceof MUIElement ) {
+ MUIElement element = (MUIElement) e;
+ List<String> tags = element.getTags();
+ for (String tag: tags) {
+ if (tag.startsWith(LIFECYCLE_TAG_PREFIX)) {
+ lifecycleService.registerLifecycleURI(element,tag.substring(LIFECYCLE_TAG_PREFIX.length()));
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java
new file mode 100644
index 000000000..5e4960ac8
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java
@@ -0,0 +1,14 @@
+package org.eclipse.fx.ui.lifecycle.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Target({ ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PreClose {
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java
new file mode 100644
index 000000000..4fbb42a46
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java
@@ -0,0 +1,14 @@
+package org.eclipse.fx.ui.lifecycle.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Target({ ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PreShow {
+
+} \ No newline at end of file

Back to the top