Initial contribution (sources of APP4MC)
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/.classpath b/plugins/org.eclipse.app4mc.amalthea.emf.util/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/.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.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/.gitignore b/plugins/org.eclipse.app4mc.amalthea.emf.util/.gitignore
new file mode 100644
index 0000000..bb5e943
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/target
\ No newline at end of file
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/.project b/plugins/org.eclipse.app4mc.amalthea.emf.util/.project
new file mode 100644
index 0000000..9e995f0
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.app4mc.amalthea.emf.util</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/plugins/org.eclipse.app4mc.amalthea.emf.util/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.app4mc.amalthea.emf.util/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/.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.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.app4mc.amalthea.emf.util/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..adba3cd
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: APP4MC Amalthea EMF Util
+Bundle-SymbolicName: org.eclipse.app4mc.amalthea.emf.util
+Bundle-Version: 0.7.0.qualifier
+Bundle-Activator: org.eclipse.app4mc.amalthea.emf.util.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.edit
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8,
+ JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: Eclipse.org
+Export-Package: org.eclipse.app4mc.amalthea.emf.util.edit
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/build.properties b/plugins/org.eclipse.app4mc.amalthea.emf.util/build.properties
new file mode 100644
index 0000000..29f8823
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
+src.includes = pom.xml
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/pom.xml b/plugins/org.eclipse.app4mc.amalthea.emf.util/pom.xml
new file mode 100644
index 0000000..7ce54af
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+ <parent>
+ <relativePath>../../build/org.eclipse.app4mc.build/pom.xml</relativePath>
+ <groupId>org.eclipse.app4mc.build</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.app4mc.amalthea.emf.util</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/Activator.java b/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/Activator.java
new file mode 100644
index 0000000..bd4865f
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/Activator.java
@@ -0,0 +1,43 @@
+/**
+ * *******************************************************************************
+ * Copyright (c) 2013 Robert Bosch GmbH 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:
+ * Robert Bosch GmbH - initial API and implementation
+ *
+ * *******************************************************************************
+ */
+package org.eclipse.app4mc.amalthea.emf.util;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/edit/ProviderUtil.java b/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/edit/ProviderUtil.java
new file mode 100644
index 0000000..8db65e4
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.amalthea.emf.util/src/org/eclipse/app4mc/amalthea/emf/util/edit/ProviderUtil.java
@@ -0,0 +1,71 @@
+/**
+ * *******************************************************************************
+ * Copyright (c) 2013 Robert Bosch GmbH 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:
+ * Robert Bosch GmbH - initial API and implementation
+ *
+ * *******************************************************************************
+ */
+package org.eclipse.app4mc.amalthea.emf.util.edit;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.ItemProvider;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+
+public class ProviderUtil {
+
+ /**
+ * @param source
+ * The {@link EObject} which should get updated
+ * @param target
+ * The target {@link EObject} to listen for changes
+ * @param targetItemProviderClass
+ * The {@link ItemProvider} class of the target {@link EObject}
+ * @param sourceItemProviderAdapter
+ * {@link ItemProviderAdapter} of the source {@link EObject}
+ */
+ public void registerForElementUpdates(final EObject source, final EObject target,
+ final Class<?> targetItemProviderClass, final ItemProviderAdapter sourceItemProviderAdapter) {
+ final IChangeNotifier changeNotifier = (IChangeNotifier) sourceItemProviderAdapter.getAdapterFactory().adapt(
+ target, targetItemProviderClass);
+ changeNotifier.addListener(new INotifyChangedListener() {
+
+ @Override
+ public void notifyChanged(final Notification notification) {
+ if (notification.getNotifier() == target) {
+ sourceItemProviderAdapter.fireNotifyChanged(new ViewerNotification(notification, source, false,
+ true));
+ }
+
+ }
+ });
+ }
+
+ /**
+ *
+ * @param element
+ * {@link EObject} to get text for
+ * @param adapterFactory
+ * @return {@link String} created by found {@link IItemLabelProvider}, empty {@link String} otherwise
+ */
+ public String getTextForElementByLabelProvider(final EObject element, final AdapterFactory adapterFactory) {
+ final Object plainAdapter = adapterFactory.adapt(element, IItemLabelProvider.class);
+ if (plainAdapter instanceof IItemLabelProvider) {
+ return ((IItemLabelProvider) plainAdapter).getText(element);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+}