diff options
author | Tom Schindl | 2013-11-20 23:08:36 +0000 |
---|---|---|
committer | Tom Schindl | 2013-11-20 23:08:36 +0000 |
commit | d9bac3147f61ef7300bb3eee5c525ef632e0c3f5 (patch) | |
tree | 47feb63416b6b450bccdceb70b750f1d76580e77 | |
parent | a5124f3e8c5ed8cef221c8be602fc047477a65bd (diff) | |
download | org.eclipse.efxclipse-d9bac3147f61ef7300bb3eee5c525ef632e0c3f5.tar.gz org.eclipse.efxclipse-d9bac3147f61ef7300bb3eee5c525ef632e0c3f5.tar.xz org.eclipse.efxclipse-d9bac3147f61ef7300bb3eee5c525ef632e0c3f5.zip |
Bug 422198 - Provide more lightweight access to IEclipseContext values
32 files changed, 38 insertions, 952 deletions
diff --git a/org.eclipse.fx.core.di.context.tests/.classpath b/org.eclipse.fx.core.di.context.tests/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.fx.core.di.context.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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/org.eclipse.fx.core.di.context.tests/.gitignore b/org.eclipse.fx.core.di.context.tests/.gitignore deleted file mode 100644 index 5e56e040e..000000000 --- a/org.eclipse.fx.core.di.context.tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin diff --git a/org.eclipse.fx.core.di.context.tests/.project b/org.eclipse.fx.core.di.context.tests/.project deleted file mode 100644 index b0dad9d36..000000000 --- a/org.eclipse.fx.core.di.context.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.fx.core.di.context.tests</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> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/org.eclipse.fx.core.di.context.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fx.core.di.context.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.fx.core.di.context.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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/org.eclipse.fx.core.di.context.tests/META-INF/MANIFEST.MF b/org.eclipse.fx.core.di.context.tests/META-INF/MANIFEST.MF deleted file mode 100644 index 23b58b6be..000000000 --- a/org.eclipse.fx.core.di.context.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,19 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Tests -Bundle-SymbolicName: org.eclipse.fx.core.di.context.tests -Bundle-Version: 1.0.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.junit;bundle-version="4.11.0", - org.eclipse.fx.core.di;bundle-version="0.9.0", - org.eclipse.e4.core.contexts;bundle-version="1.3.0", - org.eclipse.osgi;bundle-version="3.9.1", - org.eclipse.e4.core.di;bundle-version="1.3.0", - org.eclipse.equinox.ds;bundle-version="1.4.101", - org.eclipse.core.databinding.observable;bundle-version="1.4.1", - org.eclipse.core.databinding;bundle-version="1.4.1", - org.eclipse.core.databinding.property;bundle-version="1.4.200", - org.eclipse.fx.core;bundle-version="0.9.0" -Import-Package: javax.annotation;version="1.1.0", - javax.inject;version="1.0.0" -Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.fx.core.di.context.tests/build.properties b/org.eclipse.fx.core.di.context.tests/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.fx.core.di.context.tests/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.fx.core.di.context.tests/src/org/eclipse/fx/core/di/context/tests/ContextBoundValueTestCase.java b/org.eclipse.fx.core.di.context.tests/src/org/eclipse/fx/core/di/context/tests/ContextBoundValueTestCase.java deleted file mode 100644 index 4a222ed41..000000000 --- a/org.eclipse.fx.core.di.context.tests/src/org/eclipse/fx/core/di/context/tests/ContextBoundValueTestCase.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - *******************************************************************************/ -package org.eclipse.fx.core.di.context.tests; - -import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.observable.value.IValueChangeListener; -import org.eclipse.core.databinding.observable.value.ValueChangeEvent; -import org.eclipse.e4.core.contexts.ContextInjectionFactory; -import org.eclipse.e4.core.contexts.EclipseContextFactory; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.di.annotations.Optional; -import org.eclipse.fx.core.di.ContextBoundValue; -import org.eclipse.fx.core.di.ContextValue; -import org.junit.Assert; -import org.junit.Test; -import org.osgi.framework.FrameworkUtil; - -public class ContextBoundValueTestCase { - public static class SimpleInject { - @Inject - @ContextValue(contextKey="simpleValue") - public ContextBoundValue<String> value; - } - - public static class ObservableInject { - @Inject - @ContextValue(contextKey="simpleValue") - public ContextBoundValue<String> value; - - public IObservableValue observableValue; - - @Inject - @Named("simpleValue") - @Optional - public String injectedValue; - - @PostConstruct - void makeObservable() { - observableValue = value.adaptTo(IObservableValue.class); - } - } - - public static class DirectObservableInject { - @Inject - @ContextValue(contextKey="simpleValue") - public IObservableValue value; - } - - public static class Target { - @Inject - @Named("simpleValue") - @Optional - public String injectedValue; - - } - - @Test - public void testSimpleInjection() { - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()); - SimpleInject simpleInject = ContextInjectionFactory.make(SimpleInject.class, serviceContext); - Assert.assertNotNull(simpleInject.value); - } - - @Test - public void testSimpleObservable() { - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()); - ObservableInject obsInject = ContextInjectionFactory.make(ObservableInject.class, serviceContext); - Assert.assertNotNull(obsInject.observableValue); - } - - @Test - public void observableSupportModify() { - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()); - serviceContext.declareModifiable("simpleValue"); - ObservableInject obsInject = ContextInjectionFactory.make(ObservableInject.class, serviceContext); - Assert.assertNull(obsInject.injectedValue); - - { - String uuid = UUID.randomUUID().toString(); - obsInject.observableValue.setValue(uuid); - - Assert.assertEquals(uuid,obsInject.injectedValue); - Assert.assertEquals(uuid, obsInject.value.getValue()); - } - - final AtomicBoolean bool = new AtomicBoolean(); - final String uuid = UUID.randomUUID().toString(); - obsInject.observableValue.addValueChangeListener(new IValueChangeListener() { - - @Override - public void handleValueChange(ValueChangeEvent event) { - bool.set(uuid.equals(event.diff.getNewValue())); - } - }); - serviceContext.modify("simpleValue", uuid); - Assert.assertTrue(bool.get()); - } - - @Test - public void testContextModify() { - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()); - serviceContext.declareModifiable("simpleValue"); - - Target t = ContextInjectionFactory.make(Target.class, serviceContext); - - IEclipseContext c = serviceContext.createChild(); - SimpleInject i = ContextInjectionFactory.make(SimpleInject.class, c); - String uuid = UUID.randomUUID().toString(); - i.value.publish(uuid); - - Assert.assertEquals(uuid, t.injectedValue); - } - - @Test - public void testDirectObservable() { - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()); - serviceContext.declareModifiable("simpleValue"); - Realm r = new Realm() { - - @Override - public boolean isCurrent() { - return true; - } - - }; - serviceContext.set(Realm.class, r); - DirectObservableInject directObservableInject = ContextInjectionFactory.make(DirectObservableInject.class, serviceContext); - Assert.assertNotNull(directObservableInject.value); - Assert.assertEquals(r, directObservableInject.value.getRealm()); - } -} diff --git a/org.eclipse.fx.core.di.context/.classpath b/org.eclipse.fx.core.di.context/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.fx.core.di.context/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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/org.eclipse.fx.core.di.context/.gitignore b/org.eclipse.fx.core.di.context/.gitignore deleted file mode 100644 index 5e56e040e..000000000 --- a/org.eclipse.fx.core.di.context/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin diff --git a/org.eclipse.fx.core.di.context/.project b/org.eclipse.fx.core.di.context/.project deleted file mode 100644 index 03b2f16e8..000000000 --- a/org.eclipse.fx.core.di.context/.project +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.fx.core.di.context</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/org.eclipse.fx.core.di.context/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fx.core.di.context/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.fx.core.di.context/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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/org.eclipse.fx.core.di.context/META-INF/MANIFEST.MF b/org.eclipse.fx.core.di.context/META-INF/MANIFEST.MF deleted file mode 100644 index 77f9ebf3c..000000000 --- a/org.eclipse.fx.core.di.context/META-INF/MANIFEST.MF +++ /dev/null @@ -1,48 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Context -Bundle-SymbolicName: org.eclipse.fx.core.di.context -Bundle-Version: 0.9.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.fx.core.di;bundle-version="0.9.0", - org.eclipse.fx.core;bundle-version="0.9.0", - org.eclipse.e4.core.contexts;bundle-version="1.3.0", - org.eclipse.core.databinding.observable;bundle-version="1.4.1";resolution:=optional, - org.eclipse.e4.core.di -Import-Package: javafx.animation;version="2.2.0", - javafx.application;version="2.2.0", - javafx.beans;version="2.2.0", - javafx.beans.binding;version="2.2.0", - javafx.beans.property;version="2.2.0", - javafx.beans.property.adapter;version="2.2.0", - javafx.beans.value;version="2.2.0", - javafx.collections;version="2.2.0", - javafx.concurrent;version="2.2.0", - javafx.embed.swing;version="2.2.0", - javafx.embed.swt;version="2.2.0", - javafx.event;version="2.2.0", - javafx.fxml;version="2.2.0", - javafx.geometry;version="2.2.0", - javafx.scene;version="2.2.0", - javafx.scene.canvas;version="2.2.0", - javafx.scene.chart;version="2.2.0", - javafx.scene.control;version="2.2.0", - javafx.scene.control.cell;version="2.2.0", - javafx.scene.effect;version="2.2.0", - javafx.scene.image;version="2.2.0", - javafx.scene.input;version="2.2.0", - javafx.scene.layout;version="2.2.0", - javafx.scene.media;version="2.2.0", - javafx.scene.paint;version="2.2.0", - javafx.scene.shape;version="2.2.0", - javafx.scene.text;version="2.2.0", - javafx.scene.transform;version="2.2.0", - javafx.scene.web;version="2.2.0", - javafx.stage;version="2.2.0", - javafx.util;version="2.2.0", - javafx.util.converter;version="2.2.0", - javax.annotation;version="1.1.0", - javax.inject;version="1.0.0" -Service-Component: OSGI-INF/services/obervableadapter.xml,OSGI-INF/services/fxpropertyadapter.xml, - OSGI-INF/services/valuesupplier.xml diff --git a/org.eclipse.fx.core.di.context/OSGI-INF/services/fxpropertyadapter.xml b/org.eclipse.fx.core.di.context/OSGI-INF/services/fxpropertyadapter.xml deleted file mode 100644 index 8f7ba3c8e..000000000 --- a/org.eclipse.fx.core.di.context/OSGI-INF/services/fxpropertyadapter.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.core.di.context.fxpropertyadapter"> - <implementation class="org.eclipse.fx.core.di.context.internal.PropertyAdapterProvider"/> - <service> - <provide interface="org.eclipse.fx.core.adapter.AdapterProvider"/> - </service> -</scr:component> diff --git a/org.eclipse.fx.core.di.context/OSGI-INF/services/obervableadapter.xml b/org.eclipse.fx.core.di.context/OSGI-INF/services/obervableadapter.xml deleted file mode 100644 index 338da133c..000000000 --- a/org.eclipse.fx.core.di.context/OSGI-INF/services/obervableadapter.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.core.di.context.observableadapter"> - <implementation class="org.eclipse.fx.core.di.context.internal.ObservableAdapterProvider"/> - <service> - <provide interface="org.eclipse.fx.core.adapter.AdapterProvider"/> - </service> -</scr:component> diff --git a/org.eclipse.fx.core.di.context/OSGI-INF/services/valuesupplier.xml b/org.eclipse.fx.core.di.context/OSGI-INF/services/valuesupplier.xml deleted file mode 100644 index 1d58914a4..000000000 --- a/org.eclipse.fx.core.di.context/OSGI-INF/services/valuesupplier.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.core.di.context.valuesupplier"> - <implementation class="org.eclipse.fx.core.di.context.internal.ContextBoundValueSupplier"/> - <service> - <provide interface="org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier"/> - </service> - <property name="dependency.injection.annotation" type="String" value="org.eclipse.fx.core.di.ContextValue"/> -</scr:component> diff --git a/org.eclipse.fx.core.di.context/build.properties b/org.eclipse.fx.core.di.context/build.properties deleted file mode 100644 index 3ec3b851f..000000000 --- a/org.eclipse.fx.core.di.context/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/,\ - OSGI-INF/services/valuesupplier.xml -source.. = src/ diff --git a/org.eclipse.fx.core.di.context/pom.xml b/org.eclipse.fx.core.di.context/pom.xml deleted file mode 100755 index 8cf2d73fa..000000000 --- a/org.eclipse.fx.core.di.context/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ -<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 - Core DI Context</name> - <groupId>org.eclipse.fx</groupId> - <artifactId>org.eclipse.fx.core.di.context</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.9.0-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/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java b/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java deleted file mode 100644 index 60f4ce88e..000000000 --- a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - *******************************************************************************/ -package org.eclipse.fx.core.di.context.internal; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; - -import javax.inject.Inject; - -import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; -import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; -import org.eclipse.e4.core.di.suppliers.IRequestor; -import org.eclipse.e4.core.internal.di.Requestor; -import org.eclipse.fx.core.adapter.AdapterService; -import org.eclipse.fx.core.di.ContextBoundValue; -import org.eclipse.fx.core.di.ContextValue; - -/** - * - */ -@SuppressWarnings("restriction") -public class ContextBoundValueSupplier extends ExtendedObjectSupplier { - @Inject - AdapterService adapterService; - - @Override - public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { - ContextValue qualifier = descriptor.getQualifier(ContextValue.class); - Requestor r = (Requestor) requestor; - EclipseContextBoundValue<?> c = r.getInjector().make(EclipseContextBoundValue.class, r.getPrimarySupplier()); - c.setContextKey(qualifier.contextKey()); - - Class<?> desiredClass = getDesiredClass(descriptor.getDesiredType()); - - if( desiredClass == ContextBoundValue.class) { - return c; - } else { - return c.adaptTo(desiredClass); - } - } - - private Class<?> getDesiredClass(Type desiredType) { - if (desiredType instanceof Class<?>) - return (Class<?>) desiredType; - if (desiredType instanceof ParameterizedType) { - Type rawType = ((ParameterizedType) desiredType).getRawType(); - if (rawType instanceof Class<?>) - return (Class<?>) rawType; - } - return null; - } -} diff --git a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java b/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java deleted file mode 100644 index b5bee6b4c..000000000 --- a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - *******************************************************************************/ -package org.eclipse.fx.core.di.context.internal; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.PreDestroy; -import javax.inject.Inject; - -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.contexts.RunAndTrack; -import org.eclipse.fx.core.Callback; -import org.eclipse.fx.core.Subscription; -import org.eclipse.fx.core.adapter.AdapterService; -import org.eclipse.fx.core.adapter.AdapterService.ValueAccess; -import org.eclipse.fx.core.di.ContextBoundValue; - -/** - * Implementation of a ContextBoundValue - */ -public class EclipseContextBoundValue<T> implements ContextBoundValue<T> { - private IEclipseContext context; - private String contextKey; - private List<Callback<T>> callbacks; - private List<Callback<Void>> disposalCallbacks; - private AdapterService adapterService; - private T value; - - @Inject - public EclipseContextBoundValue(IEclipseContext context, AdapterService adapterService) { - this.context = context; - this.adapterService = adapterService; - } - - public void setContextKey(final String contextKey) { - this.contextKey = contextKey; - this.context.runAndTrack(new RunAndTrack() { - - @SuppressWarnings("unchecked") - @Override - public boolean changed(IEclipseContext context) { - setCurrentValue((T) context.get(contextKey)); - return true; - } - }); - } - - @SuppressWarnings("unchecked") - private void setCurrentValue(T o) { - this.value = o; - if( callbacks != null ) { - for( Callback<?> c : callbacks.toArray(new Callback<?>[0]) ) { - ((Callback<T>)c).call(o); - } - } - } - - @Override - public T getValue() { - return value; - } - - @Override - public void publish(T value) { - context.modify(contextKey, value); - } - - @Override - public Subscription subscribeOnValueChange(final Callback<T> callback) { - if( callbacks == null ) { - callbacks = new ArrayList<Callback<T>>(); - } - callbacks.add(callback); - return new Subscription() { - - @Override - public void dispose() { - callbacks.remove(callback); - } - }; - } - - @Override - public Subscription subscribeOnDispose(final Callback<Void> callback) { - if( disposalCallbacks == null ) { - disposalCallbacks = new ArrayList<Callback<Void>>(); - } - disposalCallbacks.add(callback); - return new Subscription() { - - @Override - public void dispose() { - disposalCallbacks.remove(callback); - } - }; - } - - @Override - public <A> A adaptTo(Class<A> adapt) { - return adapterService.adapt(this, adapt, new ValueAccessImpl(context)); - } - - @Override - public boolean canAdaptTo(Class<?> adapt) { - return adapterService.canAdapt(this, adapt); - } - - @PreDestroy - void dispose() { - if( disposalCallbacks != null ) { - for(Callback<?> callback : disposalCallbacks.toArray(new Callback<?>[0])) { - callback.call(null); - } - disposalCallbacks.clear(); - } - if( callbacks != null ) { - callbacks.clear(); - } - value = null; - } - - static class ValueAccessImpl implements ValueAccess { - private final IEclipseContext context; - - public ValueAccessImpl(IEclipseContext context) { - this.context = context; - } - - @SuppressWarnings("unchecked") - @Override - public <O> O getValue(String key) { - return (O) context.get(key); - } - - @Override - public <O> O getValue(Class<O> key) { - return context.get(key); - } - - } -}
\ No newline at end of file diff --git a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java b/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java deleted file mode 100644 index eacb11ab3..000000000 --- a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - *******************************************************************************/ -package org.eclipse.fx.core.di.context.internal; - -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.observable.value.IValueChangeListener; -import org.eclipse.core.databinding.observable.value.ValueChangeEvent; -import org.eclipse.core.databinding.observable.value.WritableValue; -import org.eclipse.fx.core.Callback; -import org.eclipse.fx.core.adapter.AdapterProvider; -import org.eclipse.fx.core.adapter.AdapterService.ValueAccess; -import org.eclipse.fx.core.di.ContextBoundValue; - -/** - * Eclipse Databinding Observable Adapter - */ -@SuppressWarnings("rawtypes") -public class ObservableAdapterProvider implements AdapterProvider<ContextBoundValue, IObservableValue> { - - @Override - public Class<ContextBoundValue> getSourceType() { - return ContextBoundValue.class; - } - - @Override - public Class<IObservableValue> getTargetType() { - return IObservableValue.class; - } - - @Override - public boolean canAdapt(ContextBoundValue sourceObject, Class<IObservableValue> targetType) { - return true; - } - - @SuppressWarnings("unchecked") - @Override - public IObservableValue adapt(final ContextBoundValue sourceObject, Class<IObservableValue> targetType, ValueAccess... valueAccess) { - Realm r = null; - - for( ValueAccess a : valueAccess ) { - r = a.getValue(Realm.class); - if( r != null ) { - break; - } - } - - if( r == null ) { - r = Realm.getDefault(); - } - - if( r == null ) { - r = new Realm() { - private Thread t = Thread.currentThread(); - - @Override - public boolean isCurrent() { - return t == Thread.currentThread(); - } - }; - } - - final WritableValue w = new WritableValue(r); - w.setValue(sourceObject.getValue()); - w.addValueChangeListener(new IValueChangeListener() { - - @Override - public void handleValueChange(ValueChangeEvent event) { - sourceObject.publish(event.diff.getNewValue()); - } - }); - sourceObject.subscribeOnValueChange(new Callback() { - - @Override - public void call(Object value) { - w.setValue(value); - } - }); - sourceObject.subscribeOnDispose(new Callback<Void>() { - - @Override - public void call(Void value) { - w.dispose(); - } - }); - return w; - } -}
\ No newline at end of file diff --git a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java b/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java deleted file mode 100644 index eff4f2201..000000000 --- a/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - *******************************************************************************/ -package org.eclipse.fx.core.di.context.internal; - -import javafx.beans.InvalidationListener; -import javafx.beans.Observable; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleObjectProperty; - -import org.eclipse.fx.core.Callback; -import org.eclipse.fx.core.adapter.AdapterProvider; -import org.eclipse.fx.core.adapter.AdapterService.ValueAccess; -import org.eclipse.fx.core.di.ContextBoundValue; - -/** - * JavaFX Property adapter provider - */ -@SuppressWarnings("rawtypes") -public class PropertyAdapterProvider implements AdapterProvider<ContextBoundValue, Property> { - - @Override - public Class<ContextBoundValue> getSourceType() { - return ContextBoundValue.class; - } - - @Override - public Class<Property> getTargetType() { - return Property.class; - } - - @Override - public boolean canAdapt(ContextBoundValue sourceObject, Class<Property> targetType) { - return true; - } - - @SuppressWarnings("unchecked") - @Override - public Property adapt(final ContextBoundValue sourceObject, Class<Property> targetType, ValueAccess... valueAccess) { - final SimpleObjectProperty<Object> rv = new SimpleObjectProperty<>(sourceObject.getValue()); - final InvalidationListener l = new InvalidationListener() { - - @Override - public void invalidated(Observable observable) { - sourceObject.publish(rv.get()); - } - }; - rv.addListener(l); - sourceObject.subscribeOnValueChange(new Callback() { - - @Override - public void call(Object value) { - rv.set(value); - } - }); - sourceObject.subscribeOnDispose(new Callback() { - - @Override - public void call(Object value) { - rv.removeListener(l); - } - }); - return rv; - } - -} diff --git a/org.eclipse.fx.core.di/.classpath b/org.eclipse.fx.core.di/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.fx.core.di/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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/org.eclipse.fx.core.di/.gitignore b/org.eclipse.fx.core.di/.gitignore deleted file mode 100644 index 5e56e040e..000000000 --- a/org.eclipse.fx.core.di/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin diff --git a/org.eclipse.fx.core.di/.project b/org.eclipse.fx.core.di/.project deleted file mode 100644 index ea5940133..000000000 --- a/org.eclipse.fx.core.di/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.fx.core.di</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> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/org.eclipse.fx.core.di/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fx.core.di/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.fx.core.di/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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/org.eclipse.fx.core.di/META-INF/MANIFEST.MF b/org.eclipse.fx.core.di/META-INF/MANIFEST.MF deleted file mode 100644 index 84b426b99..000000000 --- a/org.eclipse.fx.core.di/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Di -Bundle-SymbolicName: org.eclipse.fx.core.di -Bundle-Version: 0.9.0.qualifier -Import-Package: javax.inject;version="1.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.eclipse.fx.core;bundle-version="0.9.0" -Export-Package: org.eclipse.fx.core.di diff --git a/org.eclipse.fx.core.di/build.properties b/org.eclipse.fx.core.di/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.fx.core.di/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.fx.core.di/pom.xml b/org.eclipse.fx.core.di/pom.xml deleted file mode 100755 index 3a263926f..000000000 --- a/org.eclipse.fx.core.di/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ -<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 - Core DI</name> - <groupId>org.eclipse.fx</groupId> - <artifactId>org.eclipse.fx.core.di</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.9.0-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/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextBoundValue.java b/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextBoundValue.java deleted file mode 100644 index 4519975da..000000000 --- a/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextBoundValue.java +++ /dev/null @@ -1,85 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2013 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.fx.core.di;
-
-import org.eclipse.fx.core.Callback;
-import org.eclipse.fx.core.Subscription;
-import org.eclipse.fx.core.adapter.Adaptable;
-
-/**
- * A value bound to the IEclipseContext
- *
- * @param <T>
- * the type
- */
-public interface ContextBoundValue<T> extends Adaptable {
- /**
- * @return the current value
- */
- public T getValue();
-
- /**
- * Publish the value back to the context
- *
- * @param value
- * the value to publish
- */
- public void publish(T value);
-
- /**
- * Subscribe for value change events
- *
- * @param callback
- * the callback to be invoked
- * @return the subscription to revoke it
- */
- public Subscription subscribeOnValueChange(Callback<T> callback);
-
- /**
- * Get informed about disposal
- *
- * @param callback
- * the callback
- * @return the subscription to revoke it
- */
- public Subscription subscribeOnDispose(Callback<Void> callback);
-
- /**
- * Allows to adapt the type to the given type.
- *
- * By default the following adapters are available:
- * <ul>
- * <li>Eclipse Databinding - {@link org.eclipse.core.databinding.observable.value.IObservableValue}</li>
- * <li>JavaFX property - {@link javafx.beans.property.Property}</li>
- * </ul>
- *
- * @param adapt
- * the type to adapt to
- * @return the adapted type
- * @see Adaptable#adaptTo(Class)
- */
- @Override
- public <A> A adaptTo(Class<A> adapt);
-
- /**
- * Test if the instance can be adapted to the target
- *
- * By default the following adapters are available:
- * <ul>
- * <li>Eclipse Databinding - {@link org.eclipse.core.databinding.observable.value.IObservableValue}</li>
- * <li>JavaFX property - {@link javafx.beans.property.Property}</li>
- * </ul>
- *
- * @see Adaptable#canAdaptTo(Class)
- */
- @Override
- public boolean canAdaptTo(Class<?> adapt);
-}
\ No newline at end of file diff --git a/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextValue.java b/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextValue.java deleted file mode 100644 index 1439d04f3..000000000 --- a/org.eclipse.fx.core.di/src/org/eclipse/fx/core/di/ContextValue.java +++ /dev/null @@ -1,27 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2013 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.fx.core.di;
-
-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;
-
-import javax.inject.Qualifier;
-
-@Qualifier
-@Documented
-@Target({ElementType.FIELD, ElementType.PARAMETER})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ContextValue {
- String contextKey();
-}
diff --git a/releng/org.eclipse.fx.releng/pom.xml b/releng/org.eclipse.fx.releng/pom.xml index 9517d1bd0..0bbede0a9 100755 --- a/releng/org.eclipse.fx.releng/pom.xml +++ b/releng/org.eclipse.fx.releng/pom.xml @@ -36,6 +36,9 @@ <module>../../bundles/runtime/org.eclipse.fx.core.p2</module> <module>../../bundles/runtime/org.eclipse.fx.core.log4j</module> <module>../../bundles/runtime/org.eclipse.fx.core.guice</module> + <module>../../bundles/runtime/org.eclipse.fx.core.di</module> + <module>../../bundles/runtime/org.eclipse.fx.core.di.context</module> + <!-- UI Modules --> <module>../../bundles/runtime/org.eclipse.fx.ui.databinding</module> <module>../../bundles/runtime/org.eclipse.fx.ui.di</module> diff --git a/releng/runtime/org.eclipse.fx.target.feature/feature.xml b/releng/runtime/org.eclipse.fx.target.feature/feature.xml index 2a147aa07..ef80be438 100644 --- a/releng/runtime/org.eclipse.fx.target.feature/feature.xml +++ b/releng/runtime/org.eclipse.fx.target.feature/feature.xml @@ -2159,4 +2159,39 @@ This Agreement is governed by the laws of the State of New York and the intellec version="0.0.0" unpack="false"/> + <plugin + id="org.eclipse.fx.ui.mobile.source" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.fx.core.di" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.fx.core.di.source" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.fx.core.di.context" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.fx.core.di.context.source" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature> |