Initial contribution.

Change-Id: Iad2aec816d710f215feb9e904b4220b4fb91ffc9
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/.classpath b/org.eclipse.fmc.blockdiagram.editor.meta/.classpath
new file mode 100644
index 0000000..098194c
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/.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/org.eclipse.fmc.blockdiagram.editor.meta/.gitignore b/org.eclipse.fmc.blockdiagram.editor.meta/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/.project b/org.eclipse.fmc.blockdiagram.editor.meta/.project
new file mode 100644
index 0000000..f92b1fd
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.fmc.blockdiagram.editor.meta</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.fmc.blockdiagram.editor.meta/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fmc.blockdiagram.editor.meta/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/.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/org.eclipse.fmc.blockdiagram.editor.meta/META-INF/MANIFEST.MF b/org.eclipse.fmc.blockdiagram.editor.meta/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..878ce8f
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: FMC Blockdiagram Editor with Ecore Metamodel
+Bundle-SymbolicName: org.eclipse.fmc.blockdiagram.editor.meta;singleton:=true
+Bundle-Version: 0.11.0.qualifier
+Bundle-Activator: org.eclipse.fmc.blockdiagram.editor.meta.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.graphiti,
+ org.eclipse.emf.ecore.edit,
+ org.eclipse.ui.ide,
+ org.eclipse.emf.transaction,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.fmc.blockdiagram.editor,
+ org.eclipse.fmc.mm,
+ org.eclipse.graphiti.ui,
+ org.eclipse.ui.forms,
+ org.eclipse.draw2d
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.fmc.blockdiagram.editor.meta,
+ org.eclipse.fmc.blockdiagram.editor.meta.features,
+ org.eclipse.fmc.blockdiagram.editor.meta.features.add,
+ org.eclipse.fmc.blockdiagram.editor.meta.features.create,
+ org.eclipse.fmc.blockdiagram.editor.meta.features.update
+Import-Package: org.eclipse.ui.views.properties.tabbed
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/about.html b/org.eclipse.fmc.blockdiagram.editor.meta/about.html
new file mode 100644
index 0000000..333235b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>July 26, 2013</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/build.properties b/org.eclipse.fmc.blockdiagram.editor.meta/build.properties
new file mode 100644
index 0000000..f0f6cd3
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/build.properties
@@ -0,0 +1,22 @@
+###############################################################################
+# <copyright>
+#
+# Copyright (c) 2013, 2013 SAP AG.
+# 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:
+#    SAP AG - initial API, implementation and documentation
+#
+# </copyright>
+#
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               about.html
+src.includes = about.html
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/plugin.xml b/org.eclipse.fmc.blockdiagram.editor.meta/plugin.xml
new file mode 100644
index 0000000..03960d0
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/plugin.xml
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--

+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+ -->

+<?eclipse version="3.4"?>

+<plugin>

+   <extension-point id="org.eclipse.fmc.blockdiagram.editor.meta.profile" name="Profile Extension" schema="schema/org.eclipse.fmc.blockdiagram.editor.meta.profile.exsd"/>

+	 <extension

+         point="org.eclipse.ui.newWizards">

+      <wizard

+            canFinishEarly="false"

+            category="org.eclipse.fmc.blockdiagram.category"

+            class="org.eclipse.fmc.blockdiagram.editor.meta.wizard.FMCMetaDiagramFileWizard"

+            finalPerspective="FMC.perspective"

+            icon="icons/fmcfiletype.png"

+            id="org.eclipse.fmc.blockdiagram.wizard.meta"

+            name="FMC Block Diagram + Model">

+         <description>

+            This wizard creates a FMC block diagram for the graphical layouting information and a separate model file with the data model which will be kept in sync.

+         </description>

+      </wizard>

+   </extension>

+   <!-- Add wizard to common navigator context menu -->

+   <extension point="org.eclipse.ui.navigator.navigatorContent">

+      <commonWizard

+            type="new"

+            wizardId="org.eclipse.fmc.blockdiagram.wizard.meta">

+         <enablement>

+         </enablement>

+      </commonWizard>

+   </extension>

+   <extension

+         point="org.eclipse.graphiti.ui.diagramTypes">

+      <diagramType

+            id="org.eclipse.fmc.blockdiagramMeta.diagramtype"

+            name="FMC Meta"

+            type="fmcMeta">

+      </diagramType>

+   </extension>

+   <extension

+         point="org.eclipse.graphiti.ui.diagramTypeProviders">

+      <diagramTypeProvider

+            class="org.eclipse.fmc.blockdiagram.editor.meta.diagram.BlockDiagramMetaDiagramTypeProvider"

+            id="org.eclipse.fmc.blockdiagram.providerMeta"

+            name="org.eclipse.fmc.blockdiagram.typeproviderMeta">

+         <diagramType

+               id="org.eclipse.fmc.blockdiagramMeta.diagramtype">

+         </diagramType>

+         <imageProvider

+               id="org.eclipse.fmc.blockdiagram.imageProvider">

+         </imageProvider>

+      </diagramTypeProvider>

+   </extension>

+   <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertySections">

+      <propertySections

+            contributorId="fmcMeta.PropertyContributor">

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.meta.property.ShapePropertyMetaSection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.FMCNodeFilter"

+               id="fmcMeta.shapeSection"

+               tab="fmcMeta.ShapeTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.meta.property.ConnectionPropertyMetaSection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.FMCConnectionFilter"

+               id="fmcMeta.connectionSection"

+               tab="fmcMeta.ConnectionTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.DiagramPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.DiagramFilter"

+               id="fmcMeta.diagramSection"

+               tab="fmcMeta.DiagramTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.meta.property.MetaPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeAndConnectionFilter"

+               id="fmcMeta.propertySection"

+               tab="fmcMeta.PropertyTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.ColorsAndFontsPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeFilter"

+               id="fmcMeta.styleSection"

+               tab="fmcMeta.StyleTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.AlignmentPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeFilter"

+               id="fmcMeta.alignmentSection"

+               tab="fmcMeta.AlignmentTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.meta.property.ProfileSection"

+               filter="org.eclipse.fmc.blockdiagram.editor.meta.property.ProfileFilter"

+               id="fmcMeta.profileSection"

+               tab="fmcMeta.ProfileTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.meta.property.StereotypeSection"

+               filter="org.eclipse.fmc.blockdiagram.editor.meta.property.StereotypeFilter"

+               id="fmcMeta.stereotypeSection"

+               tab="fmcMeta.StereotypeTab">

+         </propertySection>

+      </propertySections>

+   </extension>

+   <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertyContributor">

+      <propertyContributor

+            contributorId="fmcMeta.PropertyContributor">

+         <propertyCategory

+               category="fmcMeta.diagram">

+         </propertyCategory>

+      </propertyContributor>

+   </extension>

+   <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertyTabs">

+      <propertyTabs

+            contributorId="fmcMeta.PropertyContributor">

+         <propertyTab

+         	   afterTab="fmcMeta.PropertyTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.ShapeTab"

+               label="Shape">

+         </propertyTab>

+         <propertyTab

+               afterTab="fmcMeta.PropertyTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.ConnectionTab"

+               label="Connection">

+         </propertyTab>

+         <propertyTab

+               afterTab="fmcMeta.PropertyTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.DiagramTab"

+               label="Diagram">

+         </propertyTab>

+         <propertyTab

+               category="fmcMeta.diagram"

+               id="fmcMeta.PropertyTab"

+               label="Model">

+         </propertyTab>

+         <propertyTab

+         	   afterTab="fmcMeta.PropertyTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.StyleTab"

+               label="Style">

+         </propertyTab>

+         <propertyTab

+               afterTab="fmcMeta.StyleTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.AlignmentTab"

+               indented="true"

+               label="Text Alignment">

+         </propertyTab>

+         <propertyTab

+         	   afterTab="fmcMeta.DiagramTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.ProfileTab"

+               label="Profile">

+         </propertyTab>

+         <propertyTab

+         	   afterTab="fmcMeta.AlignmentTab"

+               category="fmcMeta.diagram"

+               id="fmcMeta.StereotypeTab"

+               label="Stereotype">

+         </propertyTab>

+      </propertyTabs>

+   </extension>

+   <extension

+         point="org.eclipse.fmc.blockdiagram.editor.typechecking">

+      <typeChecker

+            class="org.eclipse.fmc.blockdiagram.editor.meta.model.MetaFMCTypeHelper">

+      </typeChecker>

+   </extension>

+</plugin>

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/schema/org.eclipse.fmc.blockdiagram.editor.meta.profile.exsd b/org.eclipse.fmc.blockdiagram.editor.meta/schema/org.eclipse.fmc.blockdiagram.editor.meta.profile.exsd
new file mode 100644
index 0000000..3ef0666
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/schema/org.eclipse.fmc.blockdiagram.editor.meta.profile.exsd
@@ -0,0 +1,149 @@
+<?xml version='1.0' encoding='UTF-8'?>

+<!--

+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+ -->

+<!-- Schema file written by PDE -->

+<schema targetNamespace="org.eclipse.fmc.blockdiagram.editor.meta" xmlns="http://www.w3.org/2001/XMLSchema">

+<annotation>

+      <appinfo>

+         <meta.schema plugin="org.eclipse.fmc.blockdiagram.editor.meta" id="org.eclipse.fmc.blockdiagram.editor.meta.profile" name="Profile Extension"/>

+      </appinfo>

+      <documentation>

+         [Enter description of this extension point.]

+      </documentation>

+   </annotation>

+

+   <element name="extension">

+      <annotation>

+         <appinfo>

+            <meta.element />

+         </appinfo>

+      </annotation>

+      <complexType>

+         <choice>

+            <element ref="client"/>

+         </choice>

+         <attribute name="point" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="client">

+      <complexType>

+         <attribute name="diagramSaved" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.meta.profile.IDiagramSaved"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="stereotypeProvider" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="stereotypeSection" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="profileSection" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="since"/>

+      </appinfo>

+      <documentation>

+         [Enter the first release in which this extension point appears.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="examples"/>

+      </appinfo>

+      <documentation>

+         [Enter extension point usage example here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="apiinfo"/>

+      </appinfo>

+      <documentation>

+         [Enter API information here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="implementation"/>

+      </appinfo>

+      <documentation>

+         [Enter information about supplied implementation of this extension point.]

+      </documentation>

+   </annotation>

+

+

+</schema>

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/Activator.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/Activator.java
new file mode 100644
index 0000000..8610806
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/Activator.java
@@ -0,0 +1,63 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta;

+

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+public class Activator extends AbstractUIPlugin {

+

+	/** The plug-in ID */

+	public static final String PLUGIN_ID = "org.eclipse.fmc.blockdiagram.editor.meta"; //$NON-NLS-1$

+

+	/** The shared instance */

+	private static Activator plugin;

+

+	/**

+	 * The constructor

+	 */

+	public Activator() {

+	}

+

+	/**

+	 * Start this plugin.

+	 */

+	public void start(BundleContext context) throws Exception {

+		super.start(context);

+		plugin = this;

+	}

+

+	/**

+	 * Stop this plugin.

+	 */

+	public void stop(BundleContext context) throws Exception {

+		plugin = null;

+		super.stop(context);

+	}

+

+	/**

+	 * Returns the shared instance

+	 * 

+	 * @return the shared instance

+	 */

+	public static Activator getDefault() {

+		return plugin;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/AddFeatureVisitor.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/AddFeatureVisitor.java
new file mode 100644
index 0000000..9ab1fff
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/AddFeatureVisitor.java
@@ -0,0 +1,156 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta;

+

+import org.eclipse.emf.ecore.impl.EObjectImpl;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.AccessAddMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.AgentAddMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.HumanAgentAddMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.StorageAddMetaFeature;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.fmc.blockdiagram.editor.BlockDiagramConstants;

+import org.eclipse.fmc.blockdiagram.editor.features.add.AreaBorderAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.BraceAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.CommonFeatureAreaAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.CommunicationChannelAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.DotsShapeAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.ImageAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.StructureVarianceAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.TextAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.FMCElement;

+import org.eclipse.fmc.mm.IFMCElementVisitor;

+import org.eclipse.fmc.mm.Storage;

+import org.eclipse.fmc.mm.StructureVariance;

+

+/**

+ * Visitor for getting the right AddFeature.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class AddFeatureVisitor extends EObjectImpl implements

+		IFMCElementVisitor {

+

+	/** The FeatureProvider which the AddFeature need. */

+	private BlockDiagramMetaFeatureProvider featureProvider;

+

+	/**

+	 * Create a new visitor for getting the right AddFeature.

+	 * 

+	 * @param featureProvider

+	 *            The FeatureProvider which the AddFeature need.

+	 */

+	public AddFeatureVisitor(BlockDiagramMetaFeatureProvider featureProvider) {

+		this.featureProvider = featureProvider;

+	}

+

+	/**

+	 * Generic visit method which is calling the accept method of the given

+	 * FMCElement object which is calling the special method of this visitor.

+	 */

+	@Override

+	public Object visit(FMCElement element, Object object) {

+		return element.accept(this, object);

+	}

+

+	/**

+	 * Return the right AddFeature for the comment object.

+	 */

+	@Override

+	public Object visitComment(Comment comment, Object object) {

+		switch (comment.getType()) {

+		case BRACE:

+			return new BraceAddFeature(featureProvider);

+		case IMAGE:

+			return new ImageAddFeature(featureProvider, ((IAddContext) object)

+					.getProperty("imageid").toString());

+		case AREABORDER:

+			return new AreaBorderAddFeature(featureProvider);

+		case COMMONFEATUREAREA:

+			return new CommonFeatureAreaAddFeature(featureProvider);

+		case TEXT:

+			return new TextAddFeature(featureProvider);

+		case DOTS:

+			return new DotsShapeAddFeature(featureProvider);

+		default:

+			return null;

+		}

+	}

+

+	/**

+	 * Return a new AccessAddMetaFeature object.

+	 */

+	@Override

+	public Object visitAccess(Access access, Object object) {

+

+		return new AccessAddMetaFeature(

+				featureProvider,

+				(ConnectionStyle) ((IAddContext) object)

+						.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY));

+	}

+

+	/**

+	 * Return a new CommunicationChannelAddFeature object.

+	 */

+	@Override

+	public Object visitChannel(Channel channel, Object object) {

+		return new CommunicationChannelAddFeature(

+				featureProvider,

+				(ConnectionStyle) ((IAddContext) object)

+						.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY));

+	}

+

+	/**

+	 * Return the right AddFeature for the agent object.

+	 */

+	@Override

+	public Object visitAgent(Agent agent, Object object) {

+		if (agent.isHuman()) {

+			ShapeStyle style = (ShapeStyle) ((IAddContext) object)

+					.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY);

+			return new HumanAgentAddMetaFeature(featureProvider, style);

+		}

+		ShapeStyle style = (ShapeStyle) ((IAddContext) object)

+				.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY);

+		return new AgentAddMetaFeature(featureProvider, style);

+	}

+

+	/**

+	 * Return a new StorageAddMetaFeature object.

+	 */

+	@Override

+	public Object visitStorage(Storage storage, Object object) {

+		ShapeStyle style = (ShapeStyle) ((IAddContext) object)

+				.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY);

+		return new StorageAddMetaFeature(featureProvider, style);

+	}

+

+	/**

+	 * Return a new StructureVarianceAddFeature object.

+	 */

+	@Override

+	public Object visitStructureVariance(StructureVariance structureVariance,

+			Object object) {

+		return new StructureVarianceAddFeature(featureProvider);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/BlockDiagramMetaFeatureProvider.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/BlockDiagramMetaFeatureProvider.java
new file mode 100644
index 0000000..b38945d
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/BlockDiagramMetaFeatureProvider.java
@@ -0,0 +1,341 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.draw2d.geometry.Point;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.ReconnectionMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.ShapePasteMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.FMCNodeDeleteFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.TextDirectEditingMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.DotsConnectionAddMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.create.CommunicationChannelCreateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.create.ConnectionCreateMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.create.DotsCreateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.create.HumanAgentCreateMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.create.ShapeCreateMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.AccessUpdateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.AgentUpdateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.CommentUpdateMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.CommunicationChannelUpdateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.StorageUpdateMetaFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.update.FMCNodeUpdateFeature;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.dt.IDiagramTypeProvider;

+import org.eclipse.graphiti.features.IAddFeature;

+import org.eclipse.graphiti.features.ICreateConnectionFeature;

+import org.eclipse.graphiti.features.ICreateFeature;

+import org.eclipse.graphiti.features.IDeleteFeature;

+import org.eclipse.graphiti.features.IDirectEditingFeature;

+import org.eclipse.graphiti.features.IPasteFeature;

+import org.eclipse.graphiti.features.IReconnectionFeature;

+import org.eclipse.graphiti.features.IUpdateFeature;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.features.context.IDeleteContext;

+import org.eclipse.graphiti.features.context.IDirectEditingContext;

+import org.eclipse.graphiti.features.context.IPasteContext;

+import org.eclipse.graphiti.features.context.IReconnectionContext;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.mm.algorithms.MultiText;

+import org.eclipse.graphiti.mm.algorithms.Text;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.ui.editor.DiagramBehavior;

+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;

+import org.eclipse.fmc.blockdiagram.editor.BlockDiagramConstants;

+import org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramImageProvider;

+import org.eclipse.fmc.blockdiagram.editor.features.add.AnchorAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.InvisibleShapeAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.create.ConnectionCreateFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.create.ShapeCreateFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCType;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.AccessType;

+import org.eclipse.fmc.mm.CommentType;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.FMCElement;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.FmcPackage;

+import org.eclipse.fmc.mm.RequestDirection;

+

+/**

+ * Feature provider class.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class BlockDiagramMetaFeatureProvider extends BlockDiagramFeatureProvider {

+

+	/**

+	 * The stereotype provider (is not null only if the Stereotype Extension is

+	 * installed).

+	 */

+	private IStereotypeProvider stereoTypeProvider;

+

+	/**

+	 * Constructor calls the super constructor and try to load the Stereotype

+	 * Extension.

+	 * 

+	 * @param diagramTypeProvider

+	 *            The diagram provider.

+	 */

+	public BlockDiagramMetaFeatureProvider(IDiagramTypeProvider diagramTypeProvider) {

+		super(diagramTypeProvider);

+		setIndependenceSolver(null);

+

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			try {

+				stereoTypeProvider = (IStereotypeProvider) extensions[0]

+						.createExecutableExtension("stereotypeProvider");

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+	}

+

+	/**

+	 * Returns the right UpdateFeature object for the given context.

+	 */

+	@Override

+	public IUpdateFeature getUpdateFeature(IUpdateContext context) {

+		if (context.getPictogramElement() instanceof ContainerShape) {

+			if (typeChecker.isAgent(context.getPictogramElement()))

+				return new AgentUpdateFeature(this, stereoTypeProvider);

+			else if (typeChecker.isStorage(context.getPictogramElement()))

+				return new StorageUpdateMetaFeature(this, stereoTypeProvider);

+			else if (typeChecker.isAreaBorder(context.getPictogramElement()))

+				return new CommentUpdateMetaFeature(this);

+			else

+				return new FMCNodeUpdateFeature(this, stereoTypeProvider);

+		}

+		if (context.getPictogramElement() instanceof Connection) {

+			if (typeChecker.isCommunicationChannel((Connection) context

+					.getPictogramElement())) {

+				return new CommunicationChannelUpdateFeature(this,

+						stereoTypeProvider);

+			} else

+				return new AccessUpdateFeature(this, stereoTypeProvider);

+		} else

+			return super.getUpdateFeature(context);

+

+	}

+

+	/**

+	 * Returns the right DeleteFeature object for the given context.

+	 */

+	@Override

+	public IDeleteFeature getDeleteFeature(IDeleteContext context) {

+		if (context != null

+				&& FMCUtil.getBO(context.getPictogramElement()) instanceof FMCNode)

+			return new FMCNodeDeleteFeature(this);

+		else

+			return new DefaultDeleteFeature(this);

+	}

+

+	/**

+	 * Returns the right CreateFeature object for the given context.

+	 */

+	@Override

+	public ICreateFeature[] getCreateFeatures() {

+		return new ICreateFeature[] {

+				new ShapeCreateMetaFeature(this, "Agent", "Agent",

+						FmcPackage.Literals.AGENT, BlockDiagramImageProvider.ICON_AGENT),

+				new ShapeCreateMetaFeature(this, "Agent L", "Agent L",

+						FmcPackage.Literals.AGENT, ShapeStyle.L,

+						BlockDiagramImageProvider.ICON_AGENT_L),

+				new ShapeCreateMetaFeature(this, "Agent U", "Agent U",

+						FmcPackage.Literals.AGENT, ShapeStyle.U,

+						BlockDiagramImageProvider.ICON_AGENT_U),

+				new ShapeCreateMetaFeature(this, "Storage", "Storage",

+						FmcPackage.Literals.STORAGE,

+						BlockDiagramImageProvider.ICON_STORAGE),

+				new ShapeCreateMetaFeature(this, "Storage_L", "Storage_L",

+						FmcPackage.Literals.STORAGE, ShapeStyle.L,

+						BlockDiagramImageProvider.ICON_STORAGE_L),

+				new ShapeCreateMetaFeature(this, "Storage_U", "Storage_U",

+						FmcPackage.Literals.STORAGE, ShapeStyle.U,

+						BlockDiagramImageProvider.ICON_STORAGE_U),

+				new HumanAgentCreateMetaFeature(this, "HumanAgent",

+						"HumanAgent", FmcPackage.Literals.AGENT,

+						BlockDiagramImageProvider.ICON_HUMAN_AGENT),

+				new ShapeCreateMetaFeature(this, "StructureVariance",

+						"StructureVariance",

+						FmcPackage.Literals.STRUCTURE_VARIANCE,

+						BlockDiagramImageProvider.ICON_STRUCTURE_VARIANCE),

+				new ShapeCreateMetaFeature(this, "Text",

+						CommentType.TEXT.toString(),

+						FmcPackage.Literals.COMMENT, BlockDiagramImageProvider.ICON_TEXT),

+				new ShapeCreateMetaFeature(this, "Common Feature Area",

+						CommentType.COMMONFEATUREAREA.toString(),

+						FmcPackage.Literals.COMMENT,

+						BlockDiagramImageProvider.ICON_COMMON_FEATURE_AREA),

+				new ShapeCreateMetaFeature(this, "Brace",

+						CommentType.BRACE.toString(),

+						FmcPackage.Literals.COMMENT,

+						BlockDiagramImageProvider.ICON_BRACE),

+				new ShapeCreateMetaFeature(this, "AreaBorder",

+						CommentType.AREABORDER.toString(),

+						FmcPackage.Literals.COMMENT,

+						BlockDiagramImageProvider.ICON_AREABORDER),

+				new ShapeCreateMetaFeature(this, "Dots",

+						CommentType.DOTS.toString(),

+						FmcPackage.Literals.COMMENT, BlockDiagramImageProvider.ICON_DOTS),

+				new ShapeCreateFeature(this, "Anchor", "", FMCType.Anchor,

+						BlockDiagramImageProvider.ICON_ANCHOR) };

+	}

+

+	/**

+	 * Returns the right DirectEditingFeature object for the given context.

+	 */

+	@Override

+	public IDirectEditingFeature getDirectEditingFeature(

+			IDirectEditingContext context) {

+		if (context.getGraphicsAlgorithm() instanceof Text

+				|| context.getGraphicsAlgorithm() instanceof MultiText)

+			return new TextDirectEditingMetaFeature(this, stereoTypeProvider);

+		else {

+			return super.getDirectEditingFeature(context);

+		}

+

+	}

+

+	/**

+	 * Returns the right AddFeature object for the given context.

+	 */

+	@Override

+	public IAddFeature getAddFeature(IAddContext context) {

+

+		if (context.getNewObject() == FMCType.Invisible) {

+			return new InvisibleShapeAddFeature(this);

+		} else if (context.getNewObject() == FMCType.Dots) {

+			return new DotsConnectionAddMetaFeature(

+					this,

+					(ConnectionStyle) context

+							.getProperty(BlockDiagramConstants.GRAPHICAL_TYPE_KEY));

+		} else if (context.getNewObject() == FMCType.Anchor) {

+			return new AnchorAddFeature(this);

+		} else {

+			AddFeatureVisitor visitor = new AddFeatureVisitor(this);

+			return (IAddFeature) visitor.visit(

+					(FMCElement) context.getNewObject(), context);

+		}

+	}

+

+	/**

+	 * Returns the right PasteFeature object for the given context.

+	 */

+	@Override

+	public IPasteFeature getPasteFeature(IPasteContext context) {

+		DiagramBehavior diagramBehavior = (DiagramBehavior) this

+				.getDiagramTypeProvider().getDiagramBehavior();

+		Point mouseLoc = diagramBehavior.getMouseLocation();

+		context.putProperty("mouseX", mouseLoc.x());

+		context.putProperty("mouseY", mouseLoc.y());

+		return new ShapePasteMetaFeature(this);

+	}

+

+	/**

+	 * Returns the right CreateConnectionFeature object for the given context.

+	 */

+	@Override

+	public ICreateConnectionFeature[] getCreateConnectionFeatures() {

+		return new ICreateConnectionFeature[] {

+

+				new ConnectionCreateMetaFeature(this, "Modify Access", "",

+						FmcPackage.Literals.ACCESS, ConnectionStyle.COMPOSITE,

+						BlockDiagramImageProvider.ICON_MODIFY_ACCESS, AccessType.RW),

+

+				new ConnectionCreateMetaFeature(this, "Unidirectional Access",

+						"", FmcPackage.Literals.ACCESS,

+						ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_UNIDIRECTIONAL_ACCESS_MH),

+				new ConnectionCreateMetaFeature(this, "Unidirectional Access",

+						"", FmcPackage.Literals.ACCESS, ConnectionStyle.NORMAL,

+						BlockDiagramImageProvider.ICON_UNIDIRECTIONAL_ACCESS),

+

+				new ConnectionCreateMetaFeature(this, "Bidirectional Access",

+						"", FmcPackage.Literals.ACCESS,

+						ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_BIDIRECTIONAL_ACCESS_MH,

+						AccessType.UNSPECIFIED),

+				new ConnectionCreateMetaFeature(this, "Bidirectional Access",

+						"", FmcPackage.Literals.ACCESS, ConnectionStyle.NORMAL,

+						BlockDiagramImageProvider.ICON_BIDIRECTIONAL_ACCESS,

+						AccessType.UNSPECIFIED),

+

+				new CommunicationChannelCreateFeature(this,

+						"Unidirectional Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_UNIDIRECTIONAL_COMM_CHANNEL_MH,

+						DataflowDirection.DEFAULT, RequestDirection.UNSPECIFIED),

+				new CommunicationChannelCreateFeature(this,

+						"Unidirectional Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.NORMAL,

+						BlockDiagramImageProvider.ICON_UNIDIRECTIONAL_COMM_CHANNEL,

+						DataflowDirection.DEFAULT, RequestDirection.UNSPECIFIED),

+

+				new CommunicationChannelCreateFeature(this,

+						"Bidirectional Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_BIDIRECTIONAL_COMM_CHANNEL_MH,

+						DataflowDirection.UNSPECIFIED,

+						RequestDirection.UNSPECIFIED),

+				new CommunicationChannelCreateFeature(this,

+						"Bidirectional Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.NORMAL,

+						BlockDiagramImageProvider.ICON_BIDIRECTIONAL_COMM_CHANNEL,

+						DataflowDirection.UNSPECIFIED,

+						RequestDirection.UNSPECIFIED),

+

+				new CommunicationChannelCreateFeature(this,

+						"Request-Response Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_REQ_RESP_COMM_CHANNEL_MH,

+						DataflowDirection.UNSPECIFIED, RequestDirection.REQUEST),

+				new CommunicationChannelCreateFeature(this,

+						"Request-Response Communication Channel", "",

+						FmcPackage.Literals.CHANNEL, ConnectionStyle.NORMAL,

+						BlockDiagramImageProvider.ICON_REQ_RESP_COMM_CHANNEL,

+						DataflowDirection.DEFAULT, RequestDirection.REQUEST),

+				// new ConnectionCreateMetaFeature(this, "Dots Meta",

+				// "", FmcPackage.Literals.COMMENT, ConnectionStyle.NORMAL,

+				// BlockDiagramImageProvider.ICON_DOTS),

+				new DotsCreateFeature(this, "Dots", "", FMCType.Dots,

+						ConnectionStyle.NORMAL, BlockDiagramImageProvider.ICON_DOTS),

+				new ConnectionCreateFeature(this, "Dots", "", FMCType.Dots,

+						ConnectionStyle.MANHATTAN,

+						BlockDiagramImageProvider.ICON_DOTS_MH) };

+	}

+

+	/**

+	 * Returns the right ReconnectionFeature object for the given context.

+	 */

+	@Override

+	public IReconnectionFeature getReconnectionFeature(

+			IReconnectionContext context) {

+		return new ReconnectionMetaFeature(this);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/BlockDiagramMetaDiagramTypeProvider.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/BlockDiagramMetaDiagramTypeProvider.java
new file mode 100644
index 0000000..9130164
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/BlockDiagramMetaDiagramTypeProvider.java
@@ -0,0 +1,98 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.diagram;

+

+import java.util.Map;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.emf.ecore.xmi.XMLResource;

+import org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramTypeProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.BlockDiagramMetaFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IDiagramSaved;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCModel;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+/**

+ * Diagram provider class.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class BlockDiagramMetaDiagramTypeProvider extends BlockDiagramTypeProvider {

+

+	/**

+	 * The save options map.

+	 */

+	private static Map<String, Object> saveOptions = new java.util.HashMap<String, Object>();

+

+	static {

+		saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true);

+	}

+

+	/**

+	 * Constructor which call the super constructor an set a feature provider.

+	 */

+	public BlockDiagramMetaDiagramTypeProvider() {

+		super();

+		setFeatureProvider(new BlockDiagramMetaFeatureProvider(this));

+		this.setProviderId("org.eclipse.fmc.blockdiagram.providerMeta");

+	}

+

+	/**

+	 * If the Stereotype Extension is installed forward the diagramSaved info.

+	 */

+	@Override

+	public void resourcesSaved(Diagram diagram, Resource[] savedResources) {

+		super.resourcesSaved(diagram, savedResources);

+

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			IDiagramSaved entry;

+			try {

+				entry = (IDiagramSaved) extensions[0]

+						.createExecutableExtension("diagramSaved");

+				entry.diagramSaved(diagram, getFMCModel(), savedResources);

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+	}

+

+	/**

+	 * Get the FMCModel which is represent the diagram.

+	 * 

+	 * @return

+	 */

+	private FMCModel getFMCModel() {

+		for (Shape shape : this.getDiagram().getChildren()) {

+			EObject eObject = FMCUtil.getBO(shape);

+			if ((eObject != null) && (eObject.eContainer() != null)

+					&& (eObject.eContainer() instanceof FMCModel)) {

+				return (FMCModel) eObject.eContainer();

+			}

+		}

+		return null;

+	}

+}
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/package.html
new file mode 100644
index 0000000..d5ca1cd
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/diagram/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package collects all provider classes. For the blockdiagram meta editor only type provider is needed.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/FMCNodeDeleteFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/FMCNodeDeleteFeature.java
new file mode 100644
index 0000000..e41cb52
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/FMCNodeDeleteFeature.java
@@ -0,0 +1,75 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IDeleteContext;

+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCConnection;

+import org.eclipse.fmc.mm.FMCNode;

+

+/**

+ * Feature Class for deleting the graphical representation and the business

+ * model.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class FMCNodeDeleteFeature extends DefaultDeleteFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider object.

+	 */

+	public FMCNodeDeleteFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Deleting all connections before calling the delete method of the super

+	 * class.

+	 */

+	@Override

+	public void delete(IDeleteContext context) {

+		EObject bo = FMCUtil.getBO(context.getPictogramElement());

+		if (bo instanceof FMCNode) {

+			FMCNode node = (FMCNode) FMCUtil.getBO(context

+					.getPictogramElement());

+			deleteConnections(node.getAllConnections());

+		}

+		super.delete(context);

+	}

+

+	/**

+	 * Delete all given connections.

+	 * 

+	 * @param connections

+	 *            List of connections.

+	 */

+	private void deleteConnections(EList<? extends FMCConnection> connections) {

+		EObject[] toDelete = new EObject[connections.size()];

+		int i = 0;

+		for (FMCConnection con : connections) {

+			toDelete[i++] = con;

+		}

+		deleteBusinessObjects(toDelete);

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/MoveShapeMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/MoveShapeMetaFeature.java
new file mode 100644
index 0000000..ae278be
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/MoveShapeMetaFeature.java
@@ -0,0 +1,67 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.FMCMetaUtil;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+

+/**

+ * Feature Class for moving a business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class MoveShapeMetaFeature extends

+	org.eclipse.fmc.blockdiagram.editor.features.ShapeMoveFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider object.

+	 */

+	public MoveShapeMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Reorder and set a new parent of the business model.

+	 */

+	@Override

+	protected void moveDomainObjects(Shape shapeToMove,

+			ContainerShape newContainerShape) {

+		EObject boToMove = FMCUtil.getBO(shapeToMove);

+		EObject boNewContainer = FMCUtil.getBO(newContainerShape);

+		if (boToMove != null && boToMove instanceof FMCNode) {

+			FMCNode nodeToMove = (FMCNode) boToMove;

+			if (boNewContainer != null && boNewContainer instanceof FMCNode) {

+				FMCNode nodeNewContainer = (FMCNode) boNewContainer;

+				nodeToMove.setContainer(nodeNewContainer);

+			} else if (newContainerShape instanceof Diagram) {

+				nodeToMove.setContainer(null);

+				FMCMetaUtil.addModelObject(nodeToMove, getDiagram(),

+						getFeatureProvider());

+			}

+		}

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionMetaFeature.java
new file mode 100644
index 0000000..b0aa96c
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionMetaFeature.java
@@ -0,0 +1,58 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IContext;

+import org.eclipse.graphiti.features.context.IReconnectionContext;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.features.ReconnectionFeature;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCElement;

+

+/**

+ * Feature Class for reconnect a business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ReconnectionMetaFeature extends ReconnectionFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider object.

+	 */

+	public ReconnectionMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Instantiate and call the ReconnectionVisitor.

+	 */

+	@Override

+	public void execute(IContext context) {

+		if (context instanceof IReconnectionContext) {

+			IReconnectionContext reCtx = (IReconnectionContext) context;

+			ReconnectionVisitor visitor = new ReconnectionVisitor();

+			FMCElement bo = (FMCElement) FMCUtil.getBO((PictogramElement) reCtx

+					.getConnection());

+			visitor.visit(bo, reCtx);

+		}

+		super.execute(context);

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionVisitor.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionVisitor.java
new file mode 100644
index 0000000..4590eb2
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ReconnectionVisitor.java
@@ -0,0 +1,116 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.emf.ecore.impl.EObjectImpl;

+import org.eclipse.graphiti.features.context.IReconnectionContext;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessTarget;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.FMCElement;

+import org.eclipse.fmc.mm.IFMCElementVisitor;

+import org.eclipse.fmc.mm.Storage;

+import org.eclipse.fmc.mm.StructureVariance;

+

+/**

+ * Visitor for setting the given text to the right business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ReconnectionVisitor extends EObjectImpl implements

+		IFMCElementVisitor {

+

+	/**

+	 * Generic visit method which is calling the accept method of the given

+	 * FMCElement object which is calling the special method of this visitor.

+	 */

+	@Override

+	public Object visit(FMCElement element, Object object) {

+		return element.accept(this, object);

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitComment(Comment comment, Object object) {

+		return null;

+	}

+

+	/**

+	 * Reconnect a access connection.

+	 */

+	@Override

+	public Object visitAccess(Access access, Object object) {

+		IReconnectionContext context = (IReconnectionContext) object;

+		if (access.getAgent().equals(

+				FMCUtil.getBO(context.getOldAnchor().getParent())))

+			access.setAgent((Agent) FMCUtil.getBO(context.getNewAnchor()

+					.getParent()));

+		else if (access.getTarget().equals(

+				FMCUtil.getBO(context.getOldAnchor().getParent())))

+			access.setTarget((AccessTarget) FMCUtil.getBO(context

+					.getNewAnchor().getParent()));

+		return null;

+	}

+

+	/**

+	 * Reconnect a channel connection.

+	 */

+	@Override

+	public Object visitChannel(Channel channel, Object object) {

+		IReconnectionContext context = (IReconnectionContext) object;

+		if (channel.getSource().equals(

+				FMCUtil.getBO(context.getOldAnchor().getParent())))

+			channel.setSource((Agent) FMCUtil.getBO(context.getNewAnchor()

+					.getParent()));

+		else if (channel.getTarget().equals(

+				FMCUtil.getBO(context.getOldAnchor().getParent())))

+			channel.setTarget((Agent) FMCUtil.getBO(context.getNewAnchor()

+					.getParent()));

+		return null;

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitAgent(Agent agent, Object object) {

+		return null;

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitStorage(Storage storage, Object object) {

+		return null;

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitStructureVariance(StructureVariance structureVariance,

+			Object object) {

+		return null;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ShapePasteMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ShapePasteMetaFeature.java
new file mode 100644
index 0000000..db2bd5e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/ShapePasteMetaFeature.java
@@ -0,0 +1,66 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.FMCMetaUtil;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.CommentType;

+import org.eclipse.fmc.mm.FmcFactory;

+import org.eclipse.graphiti.features.IFeatureProvider;

+

+

+/**

+ * Feature Class for pasting the graphical representation and the business

+ * model.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ShapePasteMetaFeature extends

+	org.eclipse.fmc.blockdiagram.editor.features.ShapePasteFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider object.

+	 */

+	public ShapePasteMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Add copied business object to the meta model.

+	 * 

+	 * @param copy

+	 *            The copied business object.

+	 */

+	protected void addCopyToModel(EObject copy) {

+		FMCMetaUtil.addModelObject(copy, getDiagram(), getFeatureProvider());

+	}

+

+	/**

+	 * Create an comment object not an image.

+	 */

+	@Override

+	protected Object getImageModelObject() {

+		Comment comment = FmcFactory.eINSTANCE.createComment();

+		comment.setType(CommentType.IMAGE);

+		FMCMetaUtil.addModelObject(comment, getDiagram(), getFeatureProvider());

+		return comment;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingMetaFeature.java
new file mode 100644
index 0000000..a19c768
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingMetaFeature.java
@@ -0,0 +1,85 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IDirectEditingContext;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCElement;

+

+/**

+ * Feature Class for editing the text of a business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class TextDirectEditingMetaFeature extends

+	org.eclipse.fmc.blockdiagram.editor.features.TextDirectEditingFeature {

+

+	/**

+	 * The stereotype provider (is not null only if the Stereotype Extension is

+	 * installed).

+	 */

+	private IStereotypeProvider stereotypeProvider;

+

+	/**

+	 * Instantiates a new TextDirectEditingMetaFeature.

+	 * 

+	 * @param fp

+	 *            the FeatureProvider Class.

+	 * @param stereotypeProvider

+	 *            the StereotypeProvider Class.

+	 */

+	public TextDirectEditingMetaFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp);

+		this.stereotypeProvider = stereotypeProvider;

+	}

+

+	/**

+	 * Instantiate and call the TextDirectEditingVisitor.

+	 */

+	@Override

+	public void setValue(String value, IDirectEditingContext context) {

+		FMCElement element = (FMCElement) FMCUtil

+				.getBO((PictogramElement) context.getPictogramElement());

+

+		TextDirectEditingVisitor visitor = new TextDirectEditingVisitor(context);

+		visitor.visit(element, value);

+

+		if (stereotypeProvider != null)

+			value = stereotypeProvider.getStereotypeText(element) + value;

+		super.setValue(value, context);

+	}

+

+	/**

+	 * Get the initial Value when the direct Text editing phase begins.

+	 */

+	@Override

+	public String getInitialValue(IDirectEditingContext context) {

+		AbstractText text = getText(context);

+		if (text != null) {

+			String value = text.getValue();

+			if (stereotypeProvider != null)

+				value = FMCUtil.substringStereotype(value);

+			return value;

+		} else

+			return "";

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingVisitor.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingVisitor.java
new file mode 100644
index 0000000..c5f3e6e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/TextDirectEditingVisitor.java
@@ -0,0 +1,133 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features;

+

+import org.eclipse.emf.ecore.impl.EObjectImpl;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.FMCElement;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.IFMCElementVisitor;

+import org.eclipse.fmc.mm.Storage;

+import org.eclipse.fmc.mm.StructureVariance;

+import org.eclipse.graphiti.features.context.IDirectEditingContext;

+

+/**

+ * Visitor for setting the given text to the right business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class TextDirectEditingVisitor extends EObjectImpl implements

+		IFMCElementVisitor {

+

+	/**

+	 * Context which is needed for some objects types.

+	 */

+	IDirectEditingContext context;

+

+	/**

+	 * Create a new visitor for text direct editing.

+	 * 

+	 * @param context

+	 *            The IDirectEditingContext object.

+	 * 

+	 */

+	public TextDirectEditingVisitor(IDirectEditingContext context) {

+		this.context = context;

+	}

+

+	/**

+	 * Generic visit method which is calling the accept method of the given

+	 * FMCElement object which is calling the special method of this visitor.

+	 */

+	@Override

+	public Object visit(FMCElement element, Object object) {

+		return element.accept(this, object);

+	}

+

+	/**

+	 * Set the text of the Comment object.

+	 */

+	@Override

+	public Object visitComment(Comment comment, Object object) {

+		if (comment != null && context.getPictogramElement().getLink() != null)

+			comment.setContent((String) object);

+		return null;

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitAccess(Access access, Object object) {

+		assert false : "Wrong Type";

+		return null;

+	}

+

+	/**

+	 * Not needed and not implemented.

+	 */

+	@Override

+	public Object visitChannel(Channel channel, Object object) {

+		assert false : "Wrong Type";

+		return null;

+	}

+

+	/**

+	 * Set the text of the Agent object.

+	 */

+	@Override

+	public Object visitAgent(Agent agent, Object object) {

+		setFMCNodeName(agent, (String) object);

+		return null;

+	}

+

+	/**

+	 * Set the text of the Storage object.

+	 */

+	@Override

+	public Object visitStorage(Storage storage, Object object) {

+		setFMCNodeName(storage, (String) object);

+		return null;

+	}

+

+	/**

+	 * Set the text of the StructureVariance object.

+	 */

+	@Override

+	public Object visitStructureVariance(StructureVariance structureVariance,

+			Object object) {

+		setFMCNodeName(structureVariance, (String) object);

+		return null;

+	}

+

+	/**

+	 * Set the Name for all objects from type FMCNode.

+	 * 

+	 * @param fmcNode

+	 *            The FMCNode object.

+	 * @param text

+	 *            The String object.

+	 */

+	public void setFMCNodeName(FMCNode fmcNode, String text) {

+		if (fmcNode != null && context.getPictogramElement().getLink() != null)

+			fmcNode.setName(text);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AccessAddMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AccessAddMetaFeature.java
new file mode 100644
index 0000000..3ed6d29
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AccessAddMetaFeature.java
@@ -0,0 +1,85 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.add;

+

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.mm.algorithms.Polyline;

+import org.eclipse.graphiti.mm.pictograms.CompositeConnection;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.CurvedConnection;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.graphiti.services.IGaService;

+import org.eclipse.graphiti.services.IPeService;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessType;

+

+/**

+ * Feature Class for adding the graphical representation of an existing access

+ * business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class AccessAddMetaFeature extends

+	org.eclipse.fmc.blockdiagram.editor.features.add.AccessAddFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The IFeatureProvider.

+	 * @param style

+	 *            The Shape Style.

+	 */

+	public AccessAddMetaFeature(IFeatureProvider fp, ConnectionStyle style) {

+		super(fp, style);

+	}

+

+	/**

+	 * Decorate the access connection with the right properties (draw a second

+	 * connection if the access object represent a read and write access).

+	 */

+	protected void addDomainModelContent(IAddContext context, Connection con,

+			Polyline line) {

+		if (context.getNewObject() instanceof Access) {

+			Access access = (Access) context.getNewObject();

+

+			if (access.getType() == AccessType.RW) {

+				IGaService ga = Graphiti.getGaService();

+				IPeService pe = Graphiti.getPeService();

+

+				CompositeConnection compCon = (CompositeConnection) con;

+				CurvedConnection curved1 = pe.createCurvedConnection(

+						new double[] { 0.50d, 50d }, getDiagram());

+				CurvedConnection curved2 = pe.createCurvedConnection(

+						new double[] { 0.50d, -50d }, getDiagram());

+				compCon.getChildren().add(curved1);

+				compCon.getChildren().add(curved2);

+				ga.createPolyline(curved1);

+				ga.createPolyline(curved2);

+				createArrowDecorator(getDiagram(), curved1, true);

+				createArrowDecorator(getDiagram(), curved2, false);

+				line.setLineVisible(false);

+			} else if (access.getType() != AccessType.UNSPECIFIED) {

+				createArrowDecorator(getDiagram(), con, true);

+			}

+

+		}

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AgentAddMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AgentAddMetaFeature.java
new file mode 100644
index 0000000..69d63ca
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/AgentAddMetaFeature.java
@@ -0,0 +1,206 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.add;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.BlockDiagramMetaFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.AddConnectionHelper;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.features.context.IContext;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.features.add.AgentAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.MultiplicityType;

+

+/**

+ * Feature Class for adding the graphical representation of an existing agent

+ * business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class AgentAddMetaFeature extends AgentAddFeature {

+

+	/**

+	 * Object for creating all connections which are existing in the meta model.

+	 */

+	AddConnectionHelper connHelper = null;

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 */

+	public AgentAddMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param text

+	 * @param width

+	 * @param height

+	 * @param angle

+	 */

+	public AgentAddMetaFeature(IFeatureProvider fp, String text, int width,

+			int height, int angle) {

+		super(fp, text, width, height, angle);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param style

+	 */

+	public AgentAddMetaFeature(IFeatureProvider fp, ShapeStyle style) {

+		super(fp, style);

+	}

+

+	/**

+	 * Call the AddConnectionHelper for creating all connections which are

+	 * existing in the meta model and draw the right multiplicity.

+	 */

+	@Override

+	public PictogramElement add(IAddContext context) {

+		PictogramElement picEl = super.add(context);

+

+		// When the Model has connections and channels to Elements in the

+		// current Diagram we must add them.

+		connHelper = new AddConnectionHelper();

+		connHelper.addAgentConnections(picEl,

+				(BlockDiagramMetaFeatureProvider) this.getFeatureProvider(),

+				getDiagram());

+

+		checkMultiplicity(context, picEl);

+

+		return picEl;

+	}

+

+	/**

+	 * Create the right graphical multiplicity representation for the given

+	 * PictogramElement object.

+	 * 

+	 * @param context

+	 * @param picEl

+	 */

+	private void checkMultiplicity(IAddContext context, PictogramElement picEl) {

+		ContainerShape container = (ContainerShape) picEl;

+		FMCNode node = (FMCNode) FMCUtil.getBO(container);

+		FMCNodeAlgorithm algorithm = factory.getShape(container);

+		if (algorithm == null)

+			return;

+		boolean isMultiInstance = algorithm.isMultipleInstances(container);

+		if ((node.getMultiplicity() == MultiplicityType.MANY) != isMultiInstance

+				&& !isContainerMultiPart(algorithm, container))

+			algorithm.setMultipleInstances((ContainerShape) picEl,

+					getFeatureProvider(),

+					node.getMultiplicity() == MultiplicityType.MANY);

+	}

+

+	/**

+	 * Checks if the given container is a container multi part.

+	 * 

+	 * @param algorithm

+	 *            the FMCNodeAlgorithm.

+	 * @param container

+	 *            the ContainerShape.

+	 * @return true, if container is a container multi part.

+	 */

+	protected boolean isContainerMultiPart(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		// TODO: Code copy from FMCNodeUpdateFeature;

+		if (container.eContainer() == null

+				|| !(container.eContainer() instanceof ContainerShape))

+			return false;

+		ContainerShape containerParent = (ContainerShape) container

+				.eContainer();

+		return container.getGraphicsAlgorithm().equals(

+				algorithm.getMultiInstanceChild(containerParent, true))

+				|| container.getGraphicsAlgorithm()

+						.equals(algorithm.getMultiInstanceChild(

+								containerParent, false));

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean isAvailable(IContext context) {

+		if (connHelper == null)

+			return super.isAvailable(context);

+		if (!connHelper.isAvailable(context))

+			return false;

+		return super.isAvailable(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean canExecute(IContext context) {

+		if (connHelper == null)

+			return super.canExecute(context);

+		if (!connHelper.canExecute(context))

+			return false;

+		return super.canExecute(context);

+	}

+

+	/**

+	 * Executes the current feature and the builded feature of the connection

+	 * helper with the given context.

+	 */

+	@Override

+	public void execute(IContext context) {

+		super.execute(context);

+		if (connHelper != null)

+			connHelper.execute(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) can be undone - this is

+	 * the undo of the execute operation.

+	 */

+	@Override

+	public boolean canUndo(IContext context) {

+		if (connHelper == null)

+			return super.canUndo(context);

+		if (!connHelper.canUndo(context))

+			return false;

+		return super.canUndo(context);

+	}

+

+	/**

+	 * Check if this feature or the connection helper feature has done changes.

+	 */

+	@Override

+	public boolean hasDoneChanges() {

+		if (connHelper == null)

+			return super.hasDoneChanges();

+		return (connHelper.hasDoneChanges() || super.hasDoneChanges());

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/DotsConnectionAddMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/DotsConnectionAddMetaFeature.java
new file mode 100644
index 0000000..5589b63
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/DotsConnectionAddMetaFeature.java
@@ -0,0 +1,86 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.add;

+

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IUpdateFeature;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.features.context.impl.UpdateContext;

+import org.eclipse.graphiti.mm.pictograms.AnchorContainer;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.features.add.DotsConnectionAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.MultiplicityType;

+

+/**

+ * Feature Class for adding the graphical representation of a multiplicity of an

+ * existing FMCNode business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class DotsConnectionAddMetaFeature extends DotsConnectionAddFeature {

+

+	/**

+	 * Call the constructor of the super class and set the linked property as

+	 * false because this dots connection represent a multipliciy and has only a

+	 * source and no target.

+	 * 

+	 * @param fp

+	 * @param style

+	 */

+	public DotsConnectionAddMetaFeature(IFeatureProvider fp,

+			ConnectionStyle style) {

+		super(fp, style);

+		this.linked = false;

+	}

+

+	/**

+	 * Draw a dots connection without a target to represent a multiplicity.

+	 */

+	@Override

+	public PictogramElement add(IAddContext context) {

+		Connection cShape = (Connection) super.add(context);

+

+		// Change the Target BO to Source BO.

+		FMCNode sourceObj = (FMCNode) FMCUtil.getBO(cShape.getStart()

+				.getParent());

+		AnchorContainer aContainer = cShape.getEnd().getParent();

+		// Delete the overridden BO from the Model.

+		aContainer.getLink().getBusinessObjects().remove(0);

+		this.link(aContainer, sourceObj);

+

+		// Update the Graphic Elements.

+		UpdateContext uContext = new UpdateContext(aContainer);

+		IUpdateFeature updateFeature = this.getFeatureProvider()

+				.getUpdateFeature(uContext);

+		if (updateFeature.canUpdate(uContext))

+			updateFeature.execute(uContext);

+

+		uContext = new UpdateContext(cShape.getStart().getParent());

+		updateFeature = this.getFeatureProvider().getUpdateFeature(uContext);

+		if (updateFeature.canUpdate(uContext))

+			updateFeature.execute(uContext);

+

+		// Set Multiplicity to BO

+		sourceObj.setMultiplicity(MultiplicityType.MANY);

+

+		return cShape;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/HumanAgentAddMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/HumanAgentAddMetaFeature.java
new file mode 100644
index 0000000..ce89eb1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/HumanAgentAddMetaFeature.java
@@ -0,0 +1,148 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.add;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.BlockDiagramMetaFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.AddConnectionHelper;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.features.context.IContext;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+import org.eclipse.fmc.blockdiagram.editor.features.add.HumanAgentAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+

+public class HumanAgentAddMetaFeature extends HumanAgentAddFeature {

+

+	/**

+	 * Object for creating all connections which are existing in the meta model.

+	 */

+	AddConnectionHelper connHelper = null;

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 */

+	public HumanAgentAddMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param text

+	 * @param width

+	 * @param height

+	 * @param angle

+	 */

+	public HumanAgentAddMetaFeature(IFeatureProvider fp, String text,

+			int width, int height, int angle) {

+		super(fp, text, width, height, angle);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param style

+	 */

+	public HumanAgentAddMetaFeature(IFeatureProvider fp, ShapeStyle style) {

+		super(fp, style);

+	}

+

+	/**

+	 * Call the AddConnectionHelper for creating all connections which are

+	 * existing in the meta model and draw the right multiplicity.

+	 */

+	@Override

+	public PictogramElement add(IAddContext context) {

+		PictogramElement picEl = super.add(context);

+

+		// When the Model has connections and channels to Elements in the

+		// current Diagram we must add them.

+		connHelper = new AddConnectionHelper();

+		connHelper.addAgentConnections(picEl,

+				(BlockDiagramMetaFeatureProvider) this.getFeatureProvider(),

+				getDiagram());

+

+		return picEl;

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean isAvailable(IContext context) {

+		if (connHelper == null)

+			return super.isAvailable(context);

+		if (!connHelper.isAvailable(context))

+			return false;

+		return super.isAvailable(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean canExecute(IContext context) {

+		if (connHelper == null)

+			return super.canExecute(context);

+		if (!connHelper.canExecute(context))

+			return false;

+		return super.canExecute(context);

+	}

+

+	/**

+	 * Executes the current feature and the builded feature of the connection

+	 * helper with the given context.

+	 */

+	@Override

+	public void execute(IContext context) {

+		super.execute(context);

+		if (connHelper != null)

+			connHelper.execute(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) can be undone - this is

+	 * the undo of the execute operation.

+	 */

+	@Override

+	public boolean canUndo(IContext context) {

+		if (connHelper == null)

+			return super.canUndo(context);

+		if (!connHelper.canUndo(context))

+			return false;

+		return super.canUndo(context);

+	}

+

+	/**

+	 * Check if this feature or the connection helper feature has done changes.

+	 */

+	@Override

+	public boolean hasDoneChanges() {

+		if (connHelper == null)

+			return super.hasDoneChanges();

+		return (connHelper.hasDoneChanges() || super.hasDoneChanges());

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/StorageAddMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/StorageAddMetaFeature.java
new file mode 100644
index 0000000..9ffcaae
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/StorageAddMetaFeature.java
@@ -0,0 +1,186 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.add;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.BlockDiagramMetaFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.AddConnectionHelper;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.IAddContext;

+import org.eclipse.graphiti.features.context.IContext;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.features.add.StorageAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.MultiplicityType;

+

+/**

+ * Feature Class for adding the graphical representation of an existing storage

+ * business object.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class StorageAddMetaFeature extends StorageAddFeature {

+

+	/**

+	 * Object for creating all connections which are existing in the meta model.

+	 */

+	AddConnectionHelper connHelper = null;

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The IFeatureProvider.

+	 * @param style

+	 *            The Shape Style.

+	 */

+	public StorageAddMetaFeature(IFeatureProvider fp, ShapeStyle style) {

+		super(fp, style);

+	}

+

+	/**

+	 * Call the AddConnectionHelper for creating all connections which are

+	 * existing in the meta model and draw the right multiplicity.

+	 */

+	@Override

+	public PictogramElement add(IAddContext context) {

+		PictogramElement picEl = super.add(context);

+

+		// When the Model has connections and channels to Elements in the

+		// current Diagram we must add them.

+		connHelper = new AddConnectionHelper();

+		connHelper.addStorageConnections(picEl,

+				(BlockDiagramMetaFeatureProvider) this.getFeatureProvider(),

+				getDiagram());

+

+		checkMultiplicity(picEl);

+

+		return picEl;

+

+	}

+

+	/**

+	 * Create the right graphical multiplicity representation for the given

+	 * PictogramElement object.

+	 * 

+	 * @param picEl

+	 *            The PictogramElement object.

+	 */

+	private void checkMultiplicity(PictogramElement picEl) {

+		ContainerShape container = (ContainerShape) picEl;

+		FMCNode node = (FMCNode) FMCUtil.getBO(container);

+		FMCNodeAlgorithm algorithm = factory.getShape(container);

+		if (algorithm == null)

+			return;

+		boolean isMultiInstance = algorithm.isMultipleInstances(container);

+		if ((node.getMultiplicity() == MultiplicityType.MANY) != isMultiInstance

+				&& !isContainerMultiPart(algorithm, container))

+			algorithm.setMultipleInstances((ContainerShape) picEl,

+					getFeatureProvider(),

+					node.getMultiplicity() == MultiplicityType.MANY);

+	}

+

+	/**

+	 * Checks if the given container is a container multi part.

+	 * 

+	 * @param algorithm

+	 *            the FMCNodeAlgorithm.

+	 * @param container

+	 *            the ContainerShape.

+	 * @return true, if container is a container multi part.

+	 */

+	protected boolean isContainerMultiPart(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		if (container.eContainer() == null

+				|| !(container.eContainer() instanceof ContainerShape))

+			return false;

+		ContainerShape containerParent = (ContainerShape) container

+				.eContainer();

+		return container.getGraphicsAlgorithm().equals(

+				algorithm.getMultiInstanceChild(containerParent, true))

+				|| container.getGraphicsAlgorithm()

+						.equals(algorithm.getMultiInstanceChild(

+								containerParent, false));

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean isAvailable(IContext context) {

+		if (connHelper == null)

+			return super.isAvailable(context);

+		if (!connHelper.isAvailable(context))

+			return false;

+		return super.isAvailable(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) is available with the

+	 * given context.

+	 */

+	@Override

+	public boolean canExecute(IContext context) {

+		if (connHelper == null)

+			return super.canExecute(context);

+		if (!connHelper.canExecute(context))

+			return false;

+		return super.canExecute(context);

+	}

+

+	/**

+	 * Executes the current feature and the builded feature of the connection

+	 * helper with the given context.

+	 */

+	@Override

+	public void execute(IContext context) {

+		super.execute(context);

+		if (connHelper != null)

+			connHelper.execute(context);

+	}

+

+	/**

+	 * Decides if the feature of the connection helper or the current feature

+	 * (if the feature of the connection helper is null) can be undone - this is

+	 * the undo of the execute operation.

+	 */

+	@Override

+	public boolean canUndo(IContext context) {

+		if (connHelper == null)

+			return super.canUndo(context);

+		if (!connHelper.canUndo(context))

+			return false;

+		return super.canUndo(context);

+	}

+

+	/**

+	 * Check if this feature or the connection helper feature has done changes.

+	 */

+	@Override

+	public boolean hasDoneChanges() {

+		if (connHelper == null)

+			return super.hasDoneChanges();

+		return (connHelper.hasDoneChanges() || super.hasDoneChanges());

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/package.html
new file mode 100644
index 0000000..f516c4d
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/add/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all modified add features, which has different behaviour as the superclass at the blockdiagram editor.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/CommunicationChannelCreateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/CommunicationChannelCreateFeature.java
new file mode 100644
index 0000000..6cebeb6
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/CommunicationChannelCreateFeature.java
@@ -0,0 +1,91 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.create;

+

+import org.eclipse.emf.ecore.EClass;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.FmcFactory;

+import org.eclipse.fmc.mm.RequestDirection;

+

+/**

+ * Feature Class for creating the graphical representation and the business

+ * object of a CommunicationChannel.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class CommunicationChannelCreateFeature extends

+		ConnectionCreateMetaFeature {

+

+	/**

+	 * The data flow direction of the CommunicationChannel which should be

+	 * create with this feature object.

+	 */

+	protected DataflowDirection dataFlow;

+	/**

+	 * The data request direction of the CommunicationChannel which should be

+	 * create with this feature object.

+	 */

+	protected RequestDirection request;

+

+	/**

+	 * Constructor save the given data flow direction and the given request

+	 * direction as a member and calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param type

+	 * @param style

+	 * @param icon

+	 * @param dataFlow

+	 * @param request

+	 */

+	public CommunicationChannelCreateFeature(IFeatureProvider fp, String name,

+			String description, Object type, ConnectionStyle style,

+			String icon, DataflowDirection dataFlow, RequestDirection request) {

+		super(fp, name, description, type, style, icon);

+		this.dataFlow = dataFlow;

+		this.request = request;

+	}

+

+	/**

+	 * override the createConnectionModel of the superclass (which is setting

+	 * the properties for a access connection) and set the communication channel

+	 * specific properties.

+	 */

+	@Override

+	protected Channel createConnectionModel(Anchor source, Anchor target) {

+		EObject obj = FmcFactory.eINSTANCE.create((EClass) type);

+

+		Channel channel = (Channel) obj;

+		channel.setChannelType(request);

+		channel.setDataflowDirection(dataFlow);

+		EObject sourceObj = FMCUtil.getBO(source.getParent());

+		EObject targetObj = FMCUtil.getBO(target.getParent());

+		channel.setSource((Agent) sourceObj);

+		channel.setTarget((Agent) targetObj);

+		return channel;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ConnectionCreateMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ConnectionCreateMetaFeature.java
new file mode 100644
index 0000000..1a55f5a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ConnectionCreateMetaFeature.java
@@ -0,0 +1,127 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.create;

+

+import org.eclipse.emf.ecore.EClass;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.FMCMetaUtil;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.impl.AddConnectionContext;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessTarget;

+import org.eclipse.fmc.mm.AccessType;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.FmcFactory;

+import org.eclipse.fmc.mm.Storage;

+

+/**

+ * Feature Class for creating the graphical representation and the business

+ * object of a connection.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ConnectionCreateMetaFeature extends

+	org.eclipse.fmc.blockdiagram.editor.features.create.ConnectionCreateFeature {

+

+	/**

+	 * Store the right access type (only relevant when a access object will be

+	 * created).

+	 */

+	protected AccessType accessType;

+

+	/**

+	 * Constructor save the given access type as a member and calls the super

+	 * constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param type

+	 * @param style

+	 * @param icon

+	 * @param accessType

+	 */

+	public ConnectionCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object type, ConnectionStyle style,

+			String icon, AccessType accessType) {

+		super(fp, name, description, type, style, icon);

+		this.accessType = accessType;

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param type

+	 * @param style

+	 * @param icon

+	 */

+	public ConnectionCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object type, ConnectionStyle style, String icon) {

+		super(fp, name, description, type, style, icon);

+	}

+

+	/**

+	 * Create the graphical representation and the business object of the given

+	 * context.

+	 */

+	@Override

+	protected void createConnectionModel(AddConnectionContext context,

+			Anchor source, Anchor target) {

+		EObject obj = createConnectionModel(source, target);

+		FMCMetaUtil.addModelObject(obj, getDiagram(), getFeatureProvider());

+		context.setNewObject(obj);

+	}

+

+	/**

+	 * Set the right properties if the created connection is from type access.

+	 * 

+	 * @param source

+	 *            The source anchor object

+	 * @param target

+	 *            The target anchor object.

+	 * @return The created object.

+	 */

+	protected EObject createConnectionModel(Anchor source, Anchor target) {

+		EObject obj = FmcFactory.eINSTANCE.create((EClass) type);

+		if (obj instanceof Access) {

+			Access access = (Access) obj;

+			EObject sourceObj = FMCUtil.getBO(source.getParent());

+			EObject targetObj = FMCUtil.getBO(target.getParent());

+			if (sourceObj instanceof Storage) {

+				access.setType(AccessType.READ);

+				access.setTarget((Storage) sourceObj);

+				access.setAgent((Agent) targetObj);

+			} else if (sourceObj instanceof Agent) {

+				access.setType(AccessType.WRITE);

+				access.setTarget((AccessTarget) targetObj);

+				access.setAgent((Agent) sourceObj);

+			}

+			if (accessType == AccessType.RW

+					|| accessType == AccessType.UNSPECIFIED)

+				access.setType(accessType);

+		}

+

+		return obj;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/DotsCreateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/DotsCreateFeature.java
new file mode 100644
index 0000000..3a05174
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/DotsCreateFeature.java
@@ -0,0 +1,80 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.create;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.ICreateConnectionContext;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+

+/**

+ * Feature Class for creating the graphical representation of a dots connection.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class DotsCreateFeature extends ConnectionCreateMetaFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param type

+	 * @param style

+	 * @param icon

+	 */

+	public DotsCreateFeature(IFeatureProvider fp, String name,

+			String description, Object type, ConnectionStyle style, String icon) {

+		super(fp, name, description, type, style, icon);

+	}

+

+	/**

+	 * Check if the source and the target able to create a dots connection.

+	 */

+	@Override

+	public boolean canCreate(ICreateConnectionContext context) {

+		boolean returnValue = super.canCreate(context);

+		if (!returnValue) {

+			return returnValue;

+		}

+		EObject source = getModelObject(context.getSourceAnchor());

+		EObject target = getModelObject(context.getTargetAnchor());

+		if (((source != null) && (target == null))

+				|| ((source != null) && (target != null) && (!source.getClass()

+						.equals(target.getClass()))))

+			return false;

+		return true;

+	}

+

+	/**

+	 * Returns the EClass belonging to the anchor, or null if not available.

+	 */

+	private EObject getModelObject(Anchor anchor) {

+		if (anchor != null) {

+			Object object = getBusinessObjectForPictogramElement(anchor

+					.getParent());

+			if (object instanceof EObject) {

+				return (EObject) object;

+			}

+		}

+		return null;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/HumanAgentCreateMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/HumanAgentCreateMetaFeature.java
new file mode 100644
index 0000000..7ae30ce
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/HumanAgentCreateMetaFeature.java
@@ -0,0 +1,74 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.create;

+

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.ICreateContext;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.mm.Agent;

+

+/**

+ * Feature Class for creating the graphical representation and the business

+ * model of a human agent.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class HumanAgentCreateMetaFeature extends ShapeCreateMetaFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param modelType

+	 * @param icon

+	 */

+	public HumanAgentCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object modelType, String icon) {

+		super(fp, name, description, modelType, icon);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param modelType

+	 * @param graphicalType

+	 * @param icon

+	 */

+	public HumanAgentCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object modelType, ShapeStyle graphicalType,

+			String icon) {

+		super(fp, name, description, modelType, graphicalType, icon);

+	}

+

+	/**

+	 * Call the create method of the superclass and set the human property of

+	 * the created business object.

+	 */

+	@Override

+	public Object[] create(ICreateContext context) {

+		Object[] obj = super.create(context);

+		Agent agent = (Agent) obj[0];

+		agent.setHuman(true);

+		return obj;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ShapeCreateMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ShapeCreateMetaFeature.java
new file mode 100644
index 0000000..b714bd4
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/ShapeCreateMetaFeature.java
@@ -0,0 +1,120 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.create;

+

+import org.eclipse.emf.ecore.EClass;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.FMCMetaUtil;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.context.ICreateContext;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.CommentType;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.FmcFactory;

+

+/**

+ * Feature Class for creating the graphical representation and the business

+ * model of a Shape.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ShapeCreateMetaFeature extends

+org.eclipse.fmc.blockdiagram.editor.features.create.ShapeCreateFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param modelType

+	 * @param graphicalType

+	 * @param icon

+	 */

+	public ShapeCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object modelType, ShapeStyle graphicalType,

+			String icon) {

+		super(fp, name, description, modelType, graphicalType, icon);

+	}

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 * @param name

+	 * @param description

+	 * @param modelType

+	 * @param icon

+	 */

+	public ShapeCreateMetaFeature(IFeatureProvider fp, String name,

+			String description, Object modelType, String icon) {

+		super(fp, name, description, modelType, icon);

+	}

+

+	/**

+	 * Create the graphical representation and the business model for the given

+	 * context.

+	 */

+	@Override

+	public Object[] create(ICreateContext context) {

+		if (modelType instanceof EClass) {

+			EObject obj = FmcFactory.eINSTANCE.create((EClass) modelType);

+			EObject targetBO = null;

+			if (obj instanceof Comment)

+				targetBO = FMCUtil.getBO(getDiagram());

+			else

+				targetBO = FMCUtil.getBO(context.getTargetContainer());

+

+			obj = convertComment(obj);

+			FMCMetaUtil.addModelObject(obj, getDiagram(), getFeatureProvider());

+

+			if (targetBO instanceof FMCNode && obj instanceof FMCNode) {

+				FMCNode containerNode = (FMCNode) targetBO;

+				containerNode.getContains().add((FMCNode) obj);

+			}

+			addGraphicalRepresentation(context, obj);

+			return new Object[] { obj };

+		}

+

+		addGraphicalRepresentation(context, modelType);

+		return new Object[] { modelType };

+	}

+

+	/**

+	 * Set the right CommentType to the comment business object if the given

+	 * EObject is a Comment object.

+	 * 

+	 * @param obj

+	 *            The business object.

+	 * @return The converted Comment or the unmodified given object.

+	 */

+	private EObject convertComment(EObject obj) {

+		if (obj instanceof Comment) {

+			Comment comment = (Comment) obj;

+			for (CommentType commentType : CommentType.VALUES) {

+				if (this.getDescription().equals(commentType.toString())) {

+					comment.setType(commentType);

+					return comment;

+				}

+			}

+		}

+		return obj;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/package.html
new file mode 100644
index 0000000..4bd47e5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/create/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all modified create features, which has different behaviour as the superclass at the blockdiagram editor.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/package.html
new file mode 100644
index 0000000..e0c2491
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/package.html
@@ -0,0 +1,4 @@
+<html>

+<body>This package contains the feature classes of the editor. There are subpackages for add, create, custom and resize features.

+</body>

+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AccessUpdateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AccessUpdateFeature.java
new file mode 100644
index 0000000..bd0c3d9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AccessUpdateFeature.java
@@ -0,0 +1,125 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.connection.FMCConnectionAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessType;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.FMCConnection;

+import org.eclipse.fmc.mm.Storage;

+

+/**

+ * Feature Class for updating the graphical representation and the business

+ * model of an Access.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class AccessUpdateFeature extends FMCConnectionUpdateFeature {

+

+	/**

+	 * Constructor only calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider

+	 * @param stereotypeProvider

+	 *            The StereotypeProvider Class.

+	 */

+	public AccessUpdateFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp, stereotypeProvider);

+	}

+

+	/**

+	 * Update the direction of the graphical representation.

+	 */

+	@Override

+	public boolean update(IUpdateContext context) {

+		Connection conShape = (Connection) context.getPictogramElement();

+		FMCConnectionAlgorithm algorithm = factory.getAlgorithm(conShape);

+		Access access = (Access) FMCUtil.getBO(context.getPictogramElement());

+		EObject start = FMCUtil.getBO(conShape.getStart().getParent());

+		if (!equalsAccessType(conShape, access)) {

+			switch (access.getType()) {

+			case UNSPECIFIED:

+				algorithm.setDirection(conShape, DataflowDirection.UNSPECIFIED,

+						getDiagram());

+				break;

+			case READ:

+				algorithm.setDirection(conShape,

+						start instanceof Agent ? DataflowDirection.OTHER

+								: DataflowDirection.DEFAULT, getDiagram());

+				break;

+			case WRITE:

+				algorithm.setDirection(conShape,

+						start instanceof Storage ? DataflowDirection.OTHER

+								: DataflowDirection.DEFAULT, getDiagram());

+				break;

+			case RW:

+				// TODO

+				break;

+			}

+		}

+		return false;

+	}

+

+	/**

+	 * Check if update needed because of when the access type property of the

+	 * graphical representation is not synch with the domain.

+	 */

+	@Override

+	protected IReason updateNeeded(Connection conShape, FMCConnection connection) {

+		Access access = (Access) connection;

+		if (!equalsAccessType(conShape, access))

+			return Reason

+					.createTrueReason("The access type property is not in synch with domain model");

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Equals access type between graphical representation and business object.

+	 * 

+	 * @param conShape

+	 *            The graphical representation.

+	 * @param access

+	 *            The business object.

+	 * @return true if equals otherwiese false

+	 */

+	private boolean equalsAccessType(Connection conShape, Access access) {

+		EObject start = FMCUtil.getBO(conShape.getStart().getParent());

+		FMCConnectionAlgorithm algorithm = factory.getAlgorithm(conShape);

+		DataflowDirection direction = algorithm.getDirection(conShape);

+		boolean write = false;

+		if (direction == DataflowDirection.UNSPECIFIED)

+			return access.getType() == AccessType.UNSPECIFIED;

+		if (direction == DataflowDirection.DEFAULT)

+			write = start instanceof Agent;

+		if (direction == DataflowDirection.OTHER)

+			write = start instanceof Storage;

+		return access.getType() == AccessType.WRITE == write;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AgentUpdateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AgentUpdateFeature.java
new file mode 100644
index 0000000..bd31138
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/AgentUpdateFeature.java
@@ -0,0 +1,107 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.DotsConnectionHelper;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.FMCNode;

+

+/**

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class AgentUpdateFeature extends FMCNodeUpdateFeature {

+

+	/**

+	 * Constructor only calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider

+	 * @param stereotypeProvider

+	 *            The StereotypeProvider Class.

+	 */

+	public AgentUpdateFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp, stereotypeProvider);

+	}

+

+	/**

+	 * Call the updateNeeded of the superclass and make additional a check if

+	 * the human agent property is synch with the domain model.

+	 */

+	@Override

+	protected IReason updateNeeded(ContainerShape container, FMCNode node) {

+		IReason reason = super.updateNeeded(container, node);

+		FMCNodeAlgorithm algorithm = (FMCNodeAlgorithm) factory

+				.getShape(container);

+		if (reason.toBoolean())

+			return reason;

+		else if (!isContainerMultiPart(algorithm, container)

+				&& container.isActive()) {

+			Agent agent = (Agent) node;

+

+			if (agent.isHuman() != (factory.getHumanAgent()

+					.hasHumanFigure(container)))

+				return Reason

+						.createTrueReason("The human agent property is not in synch with domain model");

+		}

+		return reason;

+	}

+

+	/**

+	 * Calls the DotsConnectionHelper to check if the ContainerShape has a

+	 * graphical multiplicity representation.

+	 */

+	@Override

+	protected boolean gaphicalMultiplicity(ContainerShape container,

+			FMCNode node) {

+		return new DotsConnectionHelper().graphicalMultiplicity(container, node);

+	}

+

+	/**

+	 * Call the update method of the superclass and update the human agent

+	 * representation.

+	 */

+	@Override

+	public boolean update(IUpdateContext context) {

+		boolean result = super.update(context);

+		ContainerShape container = (ContainerShape) context

+				.getPictogramElement();

+		Agent agent = (Agent) FMCUtil.getBO(container);

+		FMCNodeAlgorithm algorithm = factory.getShape(container);

+		if ((!isContainerMultiPart(algorithm, container) && agent.isHuman() != (factory

+				.getHumanAgent().hasHumanFigure(container)))) {

+			// TODO adapt vertical orientation of name text

+			if (agent.isHuman()) {

+				factory.getHumanAgent().addHumanFigure(getDiagram(), container,

+						container.getGraphicsAlgorithm().getWidth());

+			} else

+				factory.getHumanAgent().removeHumanFigure(container);

+		}

+

+		return result;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommentUpdateMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommentUpdateMetaFeature.java
new file mode 100644
index 0000000..c7a3a21
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommentUpdateMetaFeature.java
@@ -0,0 +1,158 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+

+/**

+ * @author Patrick Jahnke

+ * 

+ */

+public class CommentUpdateMetaFeature extends AbstractUpdateFeature {

+

+	/**

+	 * Constructor only calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider

+	 */

+	public CommentUpdateMetaFeature(IFeatureProvider fp) {

+		super(fp);

+	}

+

+	/**

+	 * The FMCNode can only updated when the PictogramElement of a given context

+	 * is a ContainerShape.

+	 */

+	@Override

+	public boolean canUpdate(IUpdateContext context) {

+		return context.getPictogramElement() instanceof ContainerShape;

+	}

+

+	/**

+	 * Check if the linked business object of the PictogramElement of a given

+	 * context is a Comment. If the linked business object is a Comment return

+	 * the result of the protected updateNeeded method. Otherwise create a false

+	 * reason.

+	 */

+	@Override

+	public IReason updateNeeded(IUpdateContext context) {

+		EObject bo = FMCUtil.getBO(context.getPictogramElement());

+		if (bo instanceof Comment) {

+			Comment comment = (Comment) bo;

+			ContainerShape container = (ContainerShape) context

+					.getPictogramElement();

+			return updateNeeded(container, comment);

+		}

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Check if update needed because of when the text of the graphical

+	 * representation is not synch with the domain.

+	 * 

+	 * @param container

+	 *            The ContainerShape.

+	 * @param comment

+	 *            The Comment.

+	 * @return the i reason

+	 */

+	protected IReason updateNeeded(ContainerShape container, Comment comment) {

+		AbstractText text = findText(container);

+		if (text == null)

+			return Reason.createFalseReason();

+		// Text not equal

+		if (!equalsText(text, comment))

+			return Reason

+					.createTrueReason("The text is not in synch with domain model");

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Update the Text and the multiplicity if it's needed.

+	 */

+	@Override

+	public boolean update(IUpdateContext context) {

+		ContainerShape container = (ContainerShape) context

+				.getPictogramElement();

+		Comment comment = (Comment) FMCUtil.getBO(container);

+		updateText(context, comment);

+		return true;

+	}

+

+	/**

+	 * Equals text between the graphical representation and the business object.

+	 * 

+	 * @param text

+	 *            The AbstractText

+	 * @param comment

+	 *            The Comment

+	 * @return true, if equals

+	 */

+	protected boolean equalsText(AbstractText text, Comment comment) {

+		return text == null && comment.getContent() == null || text != null

+				&& text.getValue().equals(comment.getContent());

+	}

+

+	/**

+	 * Update text (and if the Stereotype Extension is installed the

+	 * Stereotypetext).

+	 * 

+	 * @param context

+	 *            the UpdateContext.

+	 * @param comment

+	 *            the Comment.

+	 */

+	protected void updateText(IUpdateContext context, Comment comment) {

+		AbstractText text = findText((ContainerShape) context

+				.getPictogramElement());

+		if (text != null) {

+			String commentText = comment.getContent();

+			text.setValue(commentText == null ? "" : commentText);

+		} else {

+			// TODO Add new text

+		}

+	}

+

+	/**

+	 * Find the AbstractText object in a given ContainerShape object.

+	 * 

+	 * @param container

+	 *            the ContainerShape

+	 * @return the AbstractText object or null.

+	 */

+	protected AbstractText findText(ContainerShape container) {

+		GraphicsAlgorithm ga = container.getGraphicsAlgorithm();

+		for (GraphicsAlgorithm gaChild : ga.getGraphicsAlgorithmChildren()) {

+			if (gaChild instanceof AbstractText) {

+				return (AbstractText) gaChild;

+			}

+

+		}

+		return null;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommunicationChannelUpdateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommunicationChannelUpdateFeature.java
new file mode 100644
index 0000000..1a621b8
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/CommunicationChannelUpdateFeature.java
@@ -0,0 +1,177 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.connection.FMCConnectionAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.FMCConnection;

+import org.eclipse.fmc.mm.RequestDirection;

+

+/**

+ * Feature Class for updating the graphical representation and the business

+ * model of a CommunicationChannel.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class CommunicationChannelUpdateFeature extends

+		FMCConnectionUpdateFeature {

+

+	/**

+	 * Constructor only calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider

+	 * @param stereotypeProvider

+	 *            The StereotypeProvider Class.

+	 */

+	public CommunicationChannelUpdateFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp, stereotypeProvider);

+	}

+

+	/**

+	 * Search and return the AbstractText object of the given connection.

+	 * 

+	 * @param con

+	 *            The Connection.

+	 * @return The AbstractText object if exists in the given connection.

+	 */

+	protected AbstractText getText(Connection con) {

+		for (ConnectionDecorator decorator : con.getConnectionDecorators()) {

+			if (decorator.getGraphicsAlgorithm() instanceof AbstractText

+					&& decorator.isActive()

+					&& !"R".equals(((AbstractText) decorator

+							.getGraphicsAlgorithm()).getValue()))

+				return (AbstractText) decorator.getGraphicsAlgorithm();

+		}

+		return null;

+	}

+

+	/**

+	 * Check if update needed because of when the text or the direction of the

+	 * graphical representation is not synch with the domain.

+	 * 

+	 * @param conShape

+	 *            the graphical representation.

+	 * @param connection

+	 *            the business object.

+	 * @return the i reason

+	 */

+	protected IReason updateNeeded(Connection conShape, FMCConnection connection) {

+		Channel channel = (Channel) connection;

+		FMCConnectionAlgorithm algorithm = factory.getAlgorithm(conShape);

+		AbstractText text = getText(conShape);

+		if (!(text == null && channel.getName() == null || text != null

+				&& FMCUtil.substringStereotype(text.getValue())

+						.equals(channel.getName())))

+			return Reason

+					.createTrueReason("The text is not in synch with domain model");

+		else if (channel.getDataflowDirection() != algorithm

+				.getDirection(conShape)) {

+			return Reason

+					.createTrueReason("The data flow direction is not in synch with domain model");

+		} else if (channel.getChannelType() != algorithm

+				.getRequestDirection(conShape)) {

+			return Reason

+					.createTrueReason("The request direction is not in synch with domain model");

+		}

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Update the Text and the direction if it's needed.

+	 */

+	@Override

+	public boolean update(IUpdateContext context) {

+		Connection con = (Connection) context.getPictogramElement();

+		Channel channel = (Channel) FMCUtil.getBO(con);

+		FMCConnectionAlgorithm algorithm = factory.getAlgorithm(con);

+		updateText(context, channel);

+		if (channel.getDataflowDirection() != algorithm.getDirection(con))

+			updateDataflowDirection(context, channel);

+		if ((channel.getChannelType() != algorithm.getRequestDirection(con)))

+			updateRequestDirection(context, channel);

+		return true;

+	}

+

+	/**

+	 * Update the graphical representation of the DataflowDirection.

+	 * 

+	 * @param context

+	 *            The IUpdateContext.

+	 * @param channel

+	 *            The business object.

+	 */

+	private void updateDataflowDirection(IUpdateContext context, Channel channel) {

+		Connection conShape = (Connection) context.getPictogramElement();

+		factory.getAlgorithm(conShape).setDirection(conShape,

+				channel.getDataflowDirection(), getDiagram());

+		if (channel.getDataflowDirection() != DataflowDirection.UNSPECIFIED

+				&& channel.getChannelType() != RequestDirection.UNSPECIFIED)

+			channel.setChannelType(RequestDirection.UNSPECIFIED);

+	}

+

+	/**

+	 * Update the graphical representation of the RequestDirection.

+	 * 

+	 * @param context

+	 *            The IUpdateContext.

+	 * @param channel

+	 *            The business object.

+	 */

+	private void updateRequestDirection(IUpdateContext context, Channel channel) {

+		Connection conShape = (Connection) context.getPictogramElement();

+		factory.getAlgorithm(conShape).setRequestDirection(conShape,

+				channel.getChannelType(), getDiagram());

+		if (channel.getDataflowDirection() != DataflowDirection.UNSPECIFIED

+				&& channel.getChannelType() != RequestDirection.UNSPECIFIED)

+			channel.setDataflowDirection(DataflowDirection.UNSPECIFIED);

+	}

+

+	/**

+	 * Update text (and if the Stereotype Extension is installed the

+	 * Stereotypetext).

+	 * 

+	 * @param context

+	 *            the UpdateContext.

+	 * @param channel

+	 *            the Channel.

+	 */

+	private void updateText(IUpdateContext context, Channel channel) {

+		AbstractText text = getText((Connection) context.getPictogramElement());

+		if (text != null) {

+			String stereotypeText = "";

+			if (stereotypeProvider != null)

+				stereotypeText = stereotypeProvider.getStereotypeText(channel);

+			String nodeText = channel.getName();

+			text.setValue(nodeText == null ? stereotypeText : stereotypeText

+					+ nodeText);

+		} else {

+			// TODO Add new text

+		}

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCConnectionUpdateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCConnectionUpdateFeature.java
new file mode 100644
index 0000000..a5899e8
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCConnectionUpdateFeature.java
@@ -0,0 +1,99 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.connection.FMCConnectionAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCConnection;

+

+/**

+ * Feature Class for updating the graphical representation and the business

+ * model of a FMCConnection.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public abstract class FMCConnectionUpdateFeature extends AbstractUpdateFeature {

+	protected FMCConnectionAlgorithmFactory factory = FMCConnectionAlgorithmFactory

+			.getInstance();

+

+	/**

+	 * The stereotype provider (is not null only if the Stereotype Extension is

+	 * installed).

+	 */

+	protected IStereotypeProvider stereotypeProvider;

+

+	/**

+	 * Instantiates a new FMCConnectionUpdateFeature.

+	 * 

+	 * @param fp

+	 *            the FeatureProvider Class.

+	 * @param stereotypeProvider

+	 *            the StereotypeProvider Class.

+	 */

+	public FMCConnectionUpdateFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp);

+		this.stereotypeProvider = stereotypeProvider;

+	}

+

+	/**

+	 * The FMCNode can only updated when the PictogramElement of a given context

+	 * is a Connection.

+	 */

+	@Override

+	public boolean canUpdate(IUpdateContext context) {

+		return context.getPictogramElement() instanceof Connection;

+	}

+

+	/**

+	 * Check if the linked business object of the PictogramElement of a given

+	 * context is a FMCConnection. If the linked business object is a

+	 * FMCConnection return the result of the abstract updateNeeded method which

+	 * is implemented in the subclasses. Otherwise create a false reason.

+	 */

+	@Override

+	public IReason updateNeeded(IUpdateContext context) {

+		EObject bo = FMCUtil.getBO(context.getPictogramElement());

+		if (bo instanceof FMCConnection) {

+			FMCConnection connection = (FMCConnection) bo;

+			Connection conShape = (Connection) context.getPictogramElement();

+			return updateNeeded(conShape, connection);

+		}

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * The abstract updateNeeded Method which is implemented in the subclasses.

+	 * 

+	 * @param conShape

+	 *            The graphical representation.

+	 * @param connection

+	 *            The business object.

+	 * @return

+	 */

+	protected abstract IReason updateNeeded(Connection conShape,

+			FMCConnection connection);

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCNodeUpdateFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCNodeUpdateFeature.java
new file mode 100644
index 0000000..e321162
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/FMCNodeUpdateFeature.java
@@ -0,0 +1,334 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IReason;

+import org.eclipse.graphiti.features.context.IUpdateContext;

+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;

+import org.eclipse.graphiti.features.impl.Reason;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.MultiplicityType;

+

+/**

+ * Feature Class for updating the graphical representation and the business

+ * model of a FMCNode.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class FMCNodeUpdateFeature extends AbstractUpdateFeature {

+

+	/** The algorithm factory of FMCNodes. */

+	protected FMCNodeAlgorithmFactory factory = FMCNodeAlgorithmFactory

+			.getInstance();

+

+	/**

+	 * The stereotype provider (is not null only if the Stereotype Extension is

+	 * installed).

+	 */

+	private IStereotypeProvider stereotypeProvider;

+

+	/**

+	 * Instantiates a new FMC node update feature.

+	 * 

+	 * @param fp

+	 *            the FeatureProvider Class.

+	 * @param stereotypeProvider

+	 *            the StereotypeProvider Class.

+	 */

+	public FMCNodeUpdateFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp);

+		this.stereotypeProvider = stereotypeProvider;

+	}

+

+	/**

+	 * The FMCNode can only updated when the PictogramElement of a given context

+	 * is a ContainerShape.

+	 */

+	@Override

+	public boolean canUpdate(IUpdateContext context) {

+		return context.getPictogramElement() instanceof ContainerShape;

+	}

+

+	/**

+	 * Check if the linked business object of the PictogramElement of a given

+	 * context is a FMCNode. If the linked business object is a FMCNode return

+	 * the result of the protected updateNeeded method. Otherwise create a false

+	 * reason.

+	 */

+	@Override

+	public IReason updateNeeded(IUpdateContext context) {

+		EObject bo = FMCUtil.getBO(context.getPictogramElement());

+		if (bo instanceof FMCNode) {

+			FMCNode node = (FMCNode) bo;

+			ContainerShape container = (ContainerShape) context

+					.getPictogramElement();

+			return updateNeeded(container, node);

+		}

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Checks if the given container is a container main multi part.

+	 * 

+	 * @param algorithm

+	 *            the algorithm.

+	 * @param container

+	 *            the container.

+	 * @return true, if container is a container main multi part.

+	 */

+	protected boolean isContainerMainMultiPart(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		if (container.eContainer() == null

+				|| !(container.eContainer() instanceof ContainerShape))

+			return false;

+		ContainerShape containerParent = (ContainerShape) container

+				.eContainer();

+		return container.getGraphicsAlgorithm().equals(

+				algorithm.getMultiInstanceChild(containerParent, true));

+	}

+

+	/**

+	 * Checks if the given container is a container multi part.

+	 * 

+	 * @param algorithm

+	 *            the FMCNodeAlgorithm.

+	 * @param container

+	 *            the ContainerShape.

+	 * @return true, if container is a container multi part.

+	 */

+	protected boolean isContainerMultiPart(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		if (container.eContainer() == null

+				|| !(container.eContainer() instanceof ContainerShape))

+			return false;

+		ContainerShape containerParent = (ContainerShape) container

+				.eContainer();

+		return container.getGraphicsAlgorithm().equals(

+				algorithm.getMultiInstanceChild(containerParent, true))

+				|| container.getGraphicsAlgorithm()

+						.equals(algorithm.getMultiInstanceChild(

+								containerParent, false));

+	}

+

+	/**

+	 * Checks if is multi part.

+	 * 

+	 * @param algorithm

+	 *            the algorithm

+	 * @param container

+	 *            the container

+	 * @return true, if is multi part

+	 */

+	protected boolean isMultiPart(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		GraphicsAlgorithm invisibleGa = container.getGraphicsAlgorithm();

+		return invisibleGa.getGraphicsAlgorithmChildren().size() == 2;

+	}

+

+	/**

+	 * Check if the main shape should update.

+	 * 

+	 * @param algorithm

+	 *            the algorithm.

+	 * @param container

+	 *            the container.

+	 * @return true, if main shape should update.

+	 */

+	protected boolean shouldUpdateMainShape(FMCNodeAlgorithm algorithm,

+			ContainerShape container) {

+		boolean isThisContainerAMultiPart = isContainerMultiPart(algorithm,

+				container);

+		boolean isThisContainerMainMultiPart = isContainerMainMultiPart(

+				algorithm, container);

+		boolean isMultiInstance = algorithm.isMultipleInstances(container);

+		return (!isMultiInstance && !isThisContainerAMultiPart || isThisContainerMainMultiPart);

+	}

+

+	/**

+	 * Check if update needed because of when the text or the multiplicity of

+	 * the graphical representation is not synch with the domain.

+	 * 

+	 * @param container

+	 *            the ContainerShape

+	 * @param node

+	 *            the FMCNode

+	 * @return the i reason

+	 */

+	protected IReason updateNeeded(ContainerShape container, FMCNode node) {

+		FMCNodeAlgorithm algorithm = factory.getShape(container);

+		if (algorithm != null) {

+			boolean isThisContainerAMultiPart = isContainerMultiPart(algorithm,

+					container);

+			boolean isMultiInstance = algorithm.isMultipleInstances(container);

+			AbstractText text = findText(container);

+			// Text not equal

+			if (shouldUpdateMainShape(algorithm, container)

+					&& !equalsText(text, node))

+				return Reason

+						.createTrueReason("The text is not in synch with domain model");

+			// Multiplicity not equal

+			boolean graphMulti = gaphicalMultiplicity(container, node);

+			if ((!isThisContainerAMultiPart

+					&& isMultiInstance != (node.getMultiplicity() == MultiplicityType.MANY) && (!graphMulti))

+					|| (graphMulti && (node.getMultiplicity() == MultiplicityType.MANY))) {

+				return Reason

+						.createTrueReason("The multiplicity is not in synch wiht domain model");

+			}

+		}

+		return Reason.createFalseReason();

+	}

+

+	/**

+	 * Placeholder Method - will be overridden.

+	 * 

+	 * @param container

+	 *            the ContainerShape

+	 * @param node

+	 *            the FMCNode

+	 * @return false

+	 */

+	protected boolean gaphicalMultiplicity(ContainerShape container,

+			FMCNode node) {

+		return false;

+	}

+

+	/**

+	 * Find the AbstractText object in a given ContainerShape object.

+	 * 

+	 * @param container

+	 *            the ContainerShape

+	 * @return the AbstractText object or null.

+	 */

+	protected AbstractText findText(ContainerShape container) {

+		for (Shape shape : container.getChildren()) {

+			if (shape.getGraphicsAlgorithm() instanceof AbstractText) {

+				return (AbstractText) shape.getGraphicsAlgorithm();

+			}

+		}

+		AbstractText text = null;

+		for (Shape shape : container.getChildren()) {

+			if (text == null && shape instanceof ContainerShape) {

+				text = findText((ContainerShape) shape);

+			}

+		}

+		return text;

+	}

+

+	/**

+	 * Update the Text and the mutiplicity if it's needed.

+	 */

+	@Override

+	public boolean update(IUpdateContext context) {

+		ContainerShape container = (ContainerShape) context

+				.getPictogramElement();

+		FMCNode node = (FMCNode) FMCUtil.getBO(container);

+		FMCNodeAlgorithm algorithm = factory.getShape(container);

+		if (algorithm == null)

+			return false;

+		boolean isMultiInstance = algorithm.isMultipleInstances(container);

+		if (!isMultiInstance || isContainerMainMultiPart(algorithm, container))

+			updateText(context, node);

+		boolean graphMulti = gaphicalMultiplicity(container, node);

+		if (((node.getMultiplicity() == MultiplicityType.MANY) != isMultiInstance

+				&& !isContainerMultiPart(algorithm, container) && !graphMulti)

+				|| (graphMulti

+						&& (node.getMultiplicity() == MultiplicityType.MANY) && isMultiPart(

+							algorithm, container)))

+			updateMultiplicity(context.getPictogramElement(), algorithm, node,

+					graphMulti);

+		return true;

+	}

+

+	/**

+	 * Update text (and if the Stereotype Extension is installed the

+	 * Stereotypetext).

+	 * 

+	 * @param context

+	 *            the UpdateContext.

+	 * @param node

+	 *            the FMCNode.

+	 */

+	protected void updateText(IUpdateContext context, FMCNode node) {

+		AbstractText text = findText((ContainerShape) context

+				.getPictogramElement());

+		if (text != null) {

+			String stereotypeText = "";

+			if (stereotypeProvider != null)

+				stereotypeText = stereotypeProvider.getStereotypeText(node);

+			String nodeText = node.getName();

+			text.setValue(nodeText == null ? stereotypeText : stereotypeText

+					+ nodeText);

+

+		} else {

+			// TODO Add new text

+		}

+	}

+

+	/**

+	 * Update the multiplicity representation of the given ContainerShape

+	 * object.

+	 * 

+	 * @param picto

+	 *            the PictogramElement.

+	 * @param algorithm

+	 *            the FMCNodeAlgorithm.

+	 * @param node

+	 *            the FMCNode

+	 * @param graphMulti

+	 *            Is the multiplicity set in the graphical representation.

+	 */

+	protected void updateMultiplicity(PictogramElement picto,

+			FMCNodeAlgorithm algorithm, FMCNode node, boolean graphMulti) {

+		algorithm

+				.setMultipleInstances(

+						(ContainerShape) picto,

+						getFeatureProvider(),

+						((node.getMultiplicity() == MultiplicityType.MANY) && (!graphMulti)));

+	}

+

+	/**

+	 * Equals text between the graphical representation and the business object.

+	 * 

+	 * @param text

+	 *            the AbstractText

+	 * @param node

+	 *            the FMCNode

+	 * @return true, if equals

+	 */

+	protected boolean equalsText(AbstractText text, FMCNode node) {

+		if ((text == null) || (node.getName() == null))

+			return true;

+		String substringText = text.getValue();

+		if (stereotypeProvider != null)

+			substringText = FMCUtil

+					.substringStereotype(substringText);

+

+		return substringText.equals(node.getName());

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/StorageUpdateMetaFeature.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/StorageUpdateMetaFeature.java
new file mode 100644
index 0000000..447692e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/StorageUpdateMetaFeature.java
@@ -0,0 +1,56 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.features.update;

+

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.util.DotsConnectionHelper;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+

+/**

+ * Feature Class for updating the graphical representation and the business

+ * model of a Storage.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class StorageUpdateMetaFeature extends FMCNodeUpdateFeature {

+

+	/**

+	 * Constructor just calls the super constructor.

+	 * 

+	 * @param fp

+	 *            The FeatureProvider

+	 * @param stereotypeProvider

+	 *            The StereotypeProvider Class.

+	 */

+	public StorageUpdateMetaFeature(IFeatureProvider fp,

+			IStereotypeProvider stereotypeProvider) {

+		super(fp, stereotypeProvider);

+	}

+

+	/**

+	 * Calls the DotsConnectionHelper to check if the ContainerShape has a

+	 * graphical multiplicity representation.

+	 */

+	@Override

+	protected boolean gaphicalMultiplicity(ContainerShape container,

+			FMCNode node) {

+		return new DotsConnectionHelper().graphicalMultiplicity(container, node);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/package.html
new file mode 100644
index 0000000..d270525
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/features/update/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all modified update features, which has different behaviour as the superclass at the blockdiagram editor.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/MetaFMCTypeHelper.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/MetaFMCTypeHelper.java
new file mode 100644
index 0000000..b1128e7
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/MetaFMCTypeHelper.java
@@ -0,0 +1,261 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.model;

+

+import org.eclipse.emf.ecore.EClass;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessType;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.CommentType;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.FmcPackage;

+import org.eclipse.fmc.mm.RequestDirection;

+

+/**

+ * Class for checking a pictogram Element which FMC type it represent.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class MetaFMCTypeHelper implements FMCTypeChecker {

+

+	/**

+	 * Check if the given pictogram element represent a FMCNode object.

+	 */

+	@Override

+	public boolean isFMCNode(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getFMCNode());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a FMCConnection object.

+	 */

+	@Override

+	public boolean isFMCConnection(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getFMCConnection());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a Agent object.

+	 */

+	@Override

+	public boolean isAgent(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getAgent());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a HumanAgent object.

+	 */

+	@Override

+	public boolean isHumanAgent(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo != null && bo instanceof Agent) {

+			return ((Agent) bo).isHuman();

+		} else

+			return false;

+	}

+

+	/**

+	 * Check if the given pictogram element represent a Storage object.

+	 */

+	@Override

+	public boolean isStorage(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getStorage());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a StructureVariance

+	 * object.

+	 */

+	@Override

+	public boolean isStructureVariance(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getStructureVariance());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a CommunicationChannel

+	 * object.

+	 */

+	@Override

+	public boolean isCommunicationChannel(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getChannel());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a Channel object.

+	 */

+	@Override

+	public boolean isChannelType(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getChannel());

+	}

+

+	/**

+	 * Check if the given pictogram element represent a Access object.

+	 */

+	@Override

+	public boolean isAccessType(PictogramElement element) {

+		return isType(element, FmcPackage.eINSTANCE.getAccess());

+	}

+

+	/**

+	 * Check if the given object represent a Channel object.

+	 */

+	@Override

+	public boolean isChannelType(Object obj) {

+		return (obj.equals(FmcPackage.eINSTANCE.getChannel()) || FmcPackage.eINSTANCE

+				.getChannel().isInstance(obj));

+	}

+

+	/**

+	 * Check if the given object represent a CommunicationChannel object.

+	 */

+	@Override

+	public boolean isReqRespCommunicationChannel(Object obj) {

+		if (obj instanceof Channel) {

+			return ((Channel) obj).getChannelType() != RequestDirection.UNSPECIFIED;

+		} else

+			return false;

+	}

+

+	/**

+	 * Check if the given object represent a UnidirectionalCommunicationChannel

+	 * object.

+	 */

+	@Override

+	public boolean isUnidirectionalCommunicationChannel(Object obj) {

+		if (obj instanceof Channel) {

+			return ((Channel) obj).getDataflowDirection() == DataflowDirection.DEFAULT;

+		} else

+			return false;

+	}

+

+	/**

+	 * Check if the given Connection represent a isReqRespCommunicationChannel

+	 * object.

+	 */

+	@Override

+	public boolean isReqRespCommunicationChannel(Connection con) {

+		EObject bo = FMCUtil.getBO(con);

+		return isReqRespCommunicationChannel(bo);

+	}

+

+	/**

+	 * Check if the given pictogram element has a link to the given EClass.

+	 */

+	private boolean isType(PictogramElement element, EClass clazz) {

+		if (element == null)

+			return false;

+		else if (element.getLink() != null && clazz != null) {

+			for (EObject object : element.getLink().getBusinessObjects()) {

+				if (clazz.isInstance(object))

+					return true;

+			}

+		}

+

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a ModifyAccess object.

+	 */

+	@Override

+	public boolean isModifyAccess(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Access) {

+			return ((Access) bo).getType() != AccessType.RW;

+		} else

+			return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a Brace object.

+	 */

+	@Override

+	public boolean isBrace(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Comment)

+			return ((Comment) bo).getType() == CommentType.BRACE;

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a AreaBorder object.

+	 */

+	@Override

+	public boolean isAreaBorder(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Comment)

+			return ((Comment) bo).getType() == CommentType.AREABORDER;

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a Dots object.

+	 */

+	@Override

+	public boolean isDots(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Comment)

+			return ((Comment) bo).getType() == CommentType.DOTS;

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a text comment object.

+	 */

+	@Override

+	public boolean isTextComment(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Comment)

+			return ((Comment) bo).getType() == CommentType.TEXT;

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a comment object.

+	 */

+	@Override

+	public boolean isComment(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		return bo instanceof Comment;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a image object.

+	 */

+	public boolean isImage(PictogramElement element) {

+		// TODO To be implemented

+		return false;

+	}

+

+	/**

+	 * Check if the given pictoram element represents a CommonFeatureArea

+	 * object.

+	 */

+	public boolean isCommonFeatureArea(PictogramElement element) {

+		EObject bo = FMCUtil.getBO(element);

+		if (bo instanceof Comment)

+			return ((Comment) bo).getType() == CommentType.COMMONFEATUREAREA;

+		return false;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/package.html
new file mode 100644
index 0000000..311ca29
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/model/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains helper classes, which checks the type of a blockdiagram business model.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/package.html
new file mode 100644
index 0000000..b8dee9e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>The basic package for the blockdiagram meta editor. 

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IDiagramSaved.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IDiagramSaved.java
new file mode 100644
index 0000000..820ecd9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IDiagramSaved.java
@@ -0,0 +1,42 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.profile;

+

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.fmc.mm.FMCModel;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+

+/**

+ * The Interface which must be implemented by the Stereotype Extension.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public interface IDiagramSaved {

+

+	/**

+	 * Check the constraints when the diagram is saved.

+	 * 

+	 * @param diagram

+	 *            The diagram which was saved.

+	 * @param model

+	 *            The model behind the diagram.

+	 * @param savedResources

+	 *            Resource[] Object.

+	 */

+	public void diagramSaved(Diagram diagram, FMCModel model,

+			Resource[] savedResources);

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/ISectionProvider.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/ISectionProvider.java
new file mode 100644
index 0000000..636cfa5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/ISectionProvider.java
@@ -0,0 +1,66 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.profile;

+

+import java.util.List;

+

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.swt.widgets.Composite;

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

+

+import org.eclipse.fmc.blockdiagram.editor.property.FMCPropertySection;

+

+/**

+ * The Interface which must be implemented by the Stereotype Extension.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public interface ISectionProvider {

+	/**

+	 * Create Controls for a Property Section.

+	 * 

+	 * @param parent

+	 *            The Composite.

+	 * @param aTabbedPropertySheetPage

+	 *            The TabbedPropertySheetPage.

+	 * @param owner

+	 *            The FMCPropertySection.

+	 */

+	public void createControls(Composite parent,

+			TabbedPropertySheetPage aTabbedPropertySheetPage,

+			FMCPropertySection owner);

+

+	/**

+	 * Check if for the given PictogramElement the section must be shown.

+	 * 

+	 * @param pictogramElement

+	 *            The PictogramElement to check.

+	 * @return true for accepting otherwise false.

+	 */

+	public boolean accept(PictogramElement pictogramElement);

+

+	/**

+	 * Refresh the section.

+	 * 

+	 * @param input

+	 *            for multiple selection.

+	 * @param singleInput

+	 *            for single selection.

+	 */

+	public void refresh(List<PictogramElement> input,

+			PictogramElement singleInput);

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IStereotypeProvider.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IStereotypeProvider.java
new file mode 100644
index 0000000..02f64dd
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/IStereotypeProvider.java
@@ -0,0 +1,45 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.profile;

+

+import org.eclipse.fmc.mm.FMCElement;

+

+/**

+ * The Interface which must be implemented by the Stereotype Extension.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public interface IStereotypeProvider {

+

+	/**

+	 * Get the Stereotype text for a given FMCElement.

+	 * 

+	 * @param node

+	 *            FMCElement which Stereotype text is needed.

+	 * @return The Stereotypes text for node.

+	 */

+	public String getStereotypeText(FMCElement node);

+

+	/**

+	 * Erase the Stereotype text from a given string.

+	 * 

+	 * @param value

+	 *            String which should substring.

+	 * @return String object without the Stereotype text.

+	 */

+	public String substringStereotype(String value);

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/package.html
new file mode 100644
index 0000000..31fb856
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/profile/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all interfaces, which must be implemented by the stereotype extension.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ConnectionPropertyMetaSection.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ConnectionPropertyMetaSection.java
new file mode 100644
index 0000000..d90f66f
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ConnectionPropertyMetaSection.java
@@ -0,0 +1,48 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;

+

+/**

+ * Extended ConnectionPropertySection for Connections.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ConnectionPropertyMetaSection extends

+	org.eclipse.fmc.blockdiagram.editor.property.ConnectionPropertySection {

+

+	/**

+	 * Insert some placeholders.

+	 */

+	@Override

+	protected void createDataFlowDirection(TabbedPropertySheetWidgetFactory fac) {

+		// placeholders - data flow direction property -> model property tab

+		fac.createLabel(comp, "");

+		fac.createLabel(comp, "");

+	}

+

+	/**

+	 * Insert some placeholders.

+	 */

+	@Override

+	protected void createRequestDirection(TabbedPropertySheetWidgetFactory fac) {

+		// placeholders - request direction property -> model property tab

+		fac.createLabel(comp, "");

+		fac.createLabel(comp, "");

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/MetaPropertySection.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/MetaPropertySection.java
new file mode 100644
index 0000000..56222c5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/MetaPropertySection.java
@@ -0,0 +1,117 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import java.util.Map;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.emf.common.notify.Notification;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.EStructuralFeature;

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.emf.transaction.TransactionalEditingDomain;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.IStereotypeProvider;

+import org.eclipse.fmc.blockdiagram.editor.property.DefaultPropertySection;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.ui.editor.DiagramEditor;

+

+/**

+ * Extends the DefaultPropertySection for Stereotype Extension specific

+ * subjects.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class MetaPropertySection extends DefaultPropertySection {

+

+	/**

+	 * Load the Stereotype Extension and call the update Method provided by the

+	 * Extension.

+	 */

+	@Override

+	public void update(final Notification notification) {

+		final EObject eObject = (EObject) notification.getNotifier();

+		if (!isDisposed() && isSelection(eObject) && !isDeleted(eObject)) {

+			getDisplay().asyncExec(new Runnable() {

+

+				public void run() {

+					if (!isDisposed() && isSelection(eObject)

+							&& !isDeleted(eObject))

+						refresh();

+					DiagramEditor editor = (DiagramEditor) FMCUtil

+							.getActiveEditor();

+					TransactionalEditingDomain domain = editor

+							.getEditingDomain();

+					final PictogramElement pe = editor

+							.getSelectedPictogramElements()[0];

+					Map<EStructuralFeature, GraphicsAlgorithm> map = FMCUtil

+							.getLinkedFeaturesMap(pe, eObject);

+					final GraphicsAlgorithm algo;

+					if (map != null) {

+						algo = map.get(notification.getFeature());

+						domain.getCommandStack().execute(

+								new RecordingCommand(domain) {

+

+									@Override

+									protected void doExecute() {

+										if (algo != null

+												&& algo instanceof org.eclipse.graphiti.mm.algorithms.AbstractText) {

+											String stereotypeText = "";

+											if ((eObject != null)

+													&& (eObject instanceof FMCNode)) {

+

+												IExtensionRegistry reg = Platform

+														.getExtensionRegistry();

+												IConfigurationElement[] extensions = reg

+														.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+												if (extensions.length == 1) {

+													IStereotypeProvider entry;

+													try {

+														entry = (IStereotypeProvider) extensions[0]

+																.createExecutableExtension("stereotypeProvider");

+														stereotypeText = entry

+																.getStereotypeText((FMCNode) eObject);

+

+													} catch (CoreException e) {

+														e.printStackTrace();

+													}

+												}

+

+											}

+											String newValue = notification

+													.getNewStringValue() == null ? stereotypeText

+													: stereotypeText

+															+ notification

+																	.getNewStringValue();

+

+											((org.eclipse.graphiti.mm.algorithms.AbstractText) algo)

+													.setValue(newValue);

+										}

+									}

+								});

+						editor.getDiagramBehavior().refresh();

+					}

+				}

+			});

+		}

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileFilter.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileFilter.java
new file mode 100644
index 0000000..2b08a06
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileFilter.java
@@ -0,0 +1,57 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.ui.platform.AbstractPropertySectionFilter;

+

+/**

+ * Extends the AbstractPropertySectionFilter Class for Stereotype Extension

+ * specific subjects.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ProfileFilter extends AbstractPropertySectionFilter {

+

+	/**

+	 * Check if the given PictogramElement has the possibility to add Stereotype

+	 * Values. This will be checked in the Stereotype Extension.

+	 */

+	@Override

+	protected boolean accept(PictogramElement pictogramElement) {

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			ISectionProvider entry;

+			try {

+				entry = (ISectionProvider) extensions[0]

+						.createExecutableExtension("profileSection");

+				return entry.accept(pictogramElement);

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+		return false;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileSection.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileSection.java
new file mode 100644
index 0000000..faca058
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ProfileSection.java
@@ -0,0 +1,73 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider;

+import org.eclipse.swt.widgets.Composite;

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

+import org.eclipse.fmc.blockdiagram.editor.property.FMCPropertySection;

+

+/**

+ * This property section shows actions and properties when the diagram is

+ * selected in the editor.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ProfileSection extends FMCPropertySection {

+

+	/* the loaded Stereotype Extension */

+	ISectionProvider extension;

+

+	/**

+	 * Create Controls for selecting and applying Profiles on a diagram. This

+	 * will be done in the Stereotype Extension.

+	 */

+	@Override

+	public void createControls(Composite parent,

+			TabbedPropertySheetPage aTabbedPropertySheetPage) {

+		super.createControls(parent, aTabbedPropertySheetPage);

+

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			try {

+				extension = (ISectionProvider) extensions[0]

+						.createExecutableExtension("profileSection");

+				extension

+						.createControls(parent, aTabbedPropertySheetPage, this);

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+	}

+

+	/**

+	 * Refresh the profile section. This will be done in the Stereotype

+	 * Extension.

+	 */

+	@Override

+	public void refresh() {

+		super.refresh();

+		if (extension != null)

+			extension.refresh(getInput(), getSingleInput());

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ShapePropertyMetaSection.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ShapePropertyMetaSection.java
new file mode 100644
index 0000000..664bcc9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/ShapePropertyMetaSection.java
@@ -0,0 +1,49 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;

+

+/**

+ * Extended ShapePropertySection for Shapes.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class ShapePropertyMetaSection extends

+	org.eclipse.fmc.blockdiagram.editor.property.ShapePropertySection {

+

+	/**

+	 * Insert some placeholders.

+	 */

+	@Override

+	protected void createMultiInstance(TabbedPropertySheetWidgetFactory fac) {

+		// placeholders - multi instance property -> model property tab

+		fac.createLabel(comp, "");

+		fac.createLabel(comp, "");

+	}

+

+	/**

+	 * Insert some placeholders.

+	 */

+	@Override

+	protected void createHumanAgent(TabbedPropertySheetWidgetFactory fac) {

+		// placeholders - human agent property -> model property tab

+		fac.createLabel(comp, "");

+		fac.createLabel(comp, "");

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeFilter.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeFilter.java
new file mode 100644
index 0000000..f2142e0
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeFilter.java
@@ -0,0 +1,57 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.ui.platform.AbstractPropertySectionFilter;

+

+/**

+ * Extends the AbstractPropertySectionFilter Class for the Stereotype Extension

+ * specific subjects.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class StereotypeFilter extends AbstractPropertySectionFilter {

+

+	/**

+	 * Check if the given PictogramElement has the possibility to add Stereotype

+	 * Values. This will be checked in the Stereotype Extension.

+	 */

+	@Override

+	protected boolean accept(PictogramElement pictogramElement) {

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			ISectionProvider entry;

+			try {

+				entry = (ISectionProvider) extensions[0]

+						.createExecutableExtension("stereotypeSection");

+				return entry.accept(pictogramElement);

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+		return false;

+

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeSection.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeSection.java
new file mode 100644
index 0000000..40fd87b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/StereotypeSection.java
@@ -0,0 +1,73 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.property;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.fmc.blockdiagram.editor.meta.profile.ISectionProvider;

+import org.eclipse.swt.widgets.Composite;

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

+

+import org.eclipse.fmc.blockdiagram.editor.property.FMCPropertySection;

+

+/**

+ * This property section shows actions and properties when the diagram is

+ * selected in the editor.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class StereotypeSection extends FMCPropertySection {

+

+	ISectionProvider extension;

+

+	/**

+	 * Load the Controls for the StereotypeSection from a loaded Extension.

+	 */

+	@Override

+	public void createControls(Composite parent,

+			TabbedPropertySheetPage aTabbedPropertySheetPage) {

+		super.createControls(parent, aTabbedPropertySheetPage);

+

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.meta.profile");

+		if (extensions.length == 1) {

+			try {

+				extension = (ISectionProvider) extensions[0]

+						.createExecutableExtension("stereotypeSection");

+				extension

+						.createControls(parent, aTabbedPropertySheetPage, this);

+			} catch (CoreException e) {

+				e.printStackTrace();

+			}

+		}

+

+	}

+

+	/**

+	 * Send the refresh Command for the StereotypeSection to a loaded Extension.

+	 */

+	@Override

+	public void refresh() {

+		super.refresh();

+		if (extension != null)

+			extension.refresh(getInput(), getSingleInput());

+	}

+

+}
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/package.html
new file mode 100644
index 0000000..7f69057
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/property/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all classes, which implement the property view of the diagram.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/AddConnectionHelper.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/AddConnectionHelper.java
new file mode 100644
index 0000000..1e04192
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/AddConnectionHelper.java
@@ -0,0 +1,394 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.util;

+

+import java.util.ArrayList;

+import java.util.HashMap;

+import java.util.List;

+import java.util.Map;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.fmc.blockdiagram.editor.meta.BlockDiagramMetaFeatureProvider;

+import org.eclipse.fmc.blockdiagram.editor.meta.features.add.AccessAddMetaFeature;

+import org.eclipse.graphiti.features.IFeature;

+import org.eclipse.graphiti.features.context.IContext;

+import org.eclipse.graphiti.features.context.impl.AddConnectionContext;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.graphiti.mm.pictograms.AnchorContainer;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.fmc.blockdiagram.editor.BlockDiagramConstants;

+import org.eclipse.fmc.blockdiagram.editor.features.CompositeFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.CommunicationChannelAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.ConnectionStyle;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.Access;

+import org.eclipse.fmc.mm.AccessType;

+import org.eclipse.fmc.mm.Agent;

+import org.eclipse.fmc.mm.Channel;

+import org.eclipse.fmc.mm.Storage;

+import org.eclipse.fmc.mm.impl.AgentImpl;

+import org.eclipse.fmc.mm.impl.StorageImpl;

+

+/**

+ * The AddConnectionHelper for the Blockdiagram Meta Editor.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class AddConnectionHelper {

+

+	/** The CompositeFeature. */

+	CompositeFeature cf = null;

+

+	/**

+	 * Adds all connections from the meta model to the graphical representation.

+	 * 

+	 * @param picEl

+	 *            the PictogramElement

+	 * @param fmcFP

+	 *            the FMCMetaFeatureProvider

+	 * @param diargam

+	 *            the diargam

+	 */

+	public void addAgentConnections(PictogramElement picEl,

+			BlockDiagramMetaFeatureProvider fmcFP, Diagram diargam) {

+		HashMap<EObject, List<PictogramElement>> diagramEObj = new HashMap<EObject, List<PictogramElement>>();

+		GetAllEObjectOfDiagram(diargam, diagramEObj);

+		AgentImpl agent = (AgentImpl) FMCUtil.getBO(picEl);

+

+		if (agent.getAccessConnections().size() == 0

+				&& agent.getSourceChannels().size() == 0

+				&& agent.getTargetChannels().size() == 0)

+			return;

+

+		// Manage CompositeFeature

+		ArrayList<IFeature> cFList = new ArrayList<IFeature>();

+

+		List<Channel> sourceChanels = getSourceChanels(agent, diagramEObj);

+		for (Channel chl : sourceChanels) {

+			for (PictogramElement pe : diagramEObj.get(chl.getTarget())) {

+				AddConnectionContext context = createContext(picEl, pe, chl,

+						ConnectionStyle.MANHATTAN);

+				CommunicationChannelAddFeature addFeature = (CommunicationChannelAddFeature) fmcFP

+						.getAddFeature(context);

+				addFeature.execute(context);

+				cFList.add(addFeature);

+			}

+		}

+

+		List<Channel> targetChanels = getTargetChanels(agent, diagramEObj);

+		for (Channel chl : targetChanels) {

+			for (PictogramElement pe : diagramEObj.get(chl.getSource())) {

+				AddConnectionContext context = createContext(pe, picEl, chl,

+						ConnectionStyle.MANHATTAN);

+				CommunicationChannelAddFeature addFeature = (CommunicationChannelAddFeature) fmcFP

+						.getAddFeature(context);

+				addFeature.execute(context);

+				cFList.add(addFeature);

+			}

+		}

+

+		List<Access> storageConn = getStorageConnections(agent, diagramEObj);

+		for (Access access : storageConn) {

+			for (PictogramElement pe : diagramEObj.get(access.getTarget())) {

+				AddConnectionContext context = null;

+

+				if (access.getType() == AccessType.READ)

+					context = createContext(pe, picEl, access,

+							ConnectionStyle.MANHATTAN);

+				else if (access.getType() == AccessType.WRITE)

+					context = createContext(picEl, pe, access,

+							ConnectionStyle.MANHATTAN);

+				else

+					context = createContext(picEl, pe, access,

+							ConnectionStyle.COMPOSITE);

+

+				AccessAddMetaFeature addFeature = (AccessAddMetaFeature) fmcFP

+						.getAddFeature(context);

+				addFeature.execute(context);

+				cFList.add(addFeature);

+			}

+		}

+

+		// Manage CompositeFeature

+		IFeature[] featureList = new IFeature[cFList.size()];

+		cf = new CompositeFeature(cFList.toArray(featureList));

+	}

+

+	/**

+	 * Adds all connections from the meta model to the graphical representation.

+	 * 

+	 * @param picEl

+	 *            the PictogramElement

+	 * @param fmcFP

+	 *            the FMCMetaFeatureProvider

+	 * @param diargam

+	 *            the diargam

+	 */

+	public void addStorageConnections(PictogramElement picEl,

+			BlockDiagramMetaFeatureProvider fmcFP, Diagram diargam) {

+		HashMap<EObject, List<PictogramElement>> diagramEObj = new HashMap<EObject, List<PictogramElement>>();

+		GetAllEObjectOfDiagram(diargam, diagramEObj);

+		StorageImpl storage = (StorageImpl) FMCUtil.getBO(picEl);

+

+		if (storage.getConnections().size() == 0)

+			return;

+

+		// Manage CompositeFeature

+		ArrayList<IFeature> cFList = new ArrayList<IFeature>();

+

+		List<Access> storageConn = getStorageConnections(storage, diagramEObj);

+		for (Access access : storageConn) {

+			for (PictogramElement pe : diagramEObj.get(access.getAgent())) {

+				AddConnectionContext context = null;

+

+				if (access.getType() == AccessType.READ)

+					context = createContext(picEl, pe, access,

+							ConnectionStyle.MANHATTAN);

+				else if (access.getType() == AccessType.WRITE)

+					context = createContext(pe, picEl, access,

+							ConnectionStyle.MANHATTAN);

+				else

+					context = createContext(pe, picEl, access,

+							ConnectionStyle.COMPOSITE);

+

+				AccessAddMetaFeature addFeature = (AccessAddMetaFeature) fmcFP

+						.getAddFeature(context);

+				addFeature.execute(context);

+				cFList.add(addFeature);

+			}

+		}

+

+		// Manage CompositeFeature

+		IFeature[] featureList = new IFeature[cFList.size()];

+		cf = new CompositeFeature(cFList.toArray(featureList));

+	}

+

+	/**

+	 * Get all EObject of a diagram.

+	 * 

+	 * @param cShape

+	 *            ContainerShape (diagram)

+	 * @param map

+	 *            the map with the EObject as key and a list of

+	 *            PictogramElements.

+	 */

+	private void GetAllEObjectOfDiagram(ContainerShape cShape,

+			Map<EObject, List<PictogramElement>> map) {

+		for (Shape shape : cShape.getChildren()) {

+			if (shape instanceof ContainerShape)

+				GetAllEObjectOfDiagram((ContainerShape) shape, map);

+			if (!shape.isActive())

+				continue;

+			EObject obj = FMCUtil.getBO(shape);

+			if (map.containsKey(obj))

+				map.get(obj).add(shape);

+			else {

+				ArrayList<PictogramElement> lst = new ArrayList<PictogramElement>();

+				lst.add(shape);

+				map.put(obj, lst);

+			}

+		}

+	}

+

+	/**

+	 * Gets the storage connections.

+	 * 

+	 * @param storage

+	 *            the storage

+	 * @param diagramEObj

+	 *            the diagram e obj

+	 * @return the storage connections

+	 */

+	private List<Access> getStorageConnections(Storage storage,

+			Map<EObject, List<PictogramElement>> diagramEObj) {

+		ArrayList<Access> returnList = new ArrayList<Access>();

+		for (Access access : storage.getConnections()) {

+			if (diagramEObj.containsKey(access.getAgent()))

+				returnList.add(access);

+		}

+

+		return returnList;

+	}

+

+	/**

+	 * Gets the storage connections.

+	 * 

+	 * @param agent

+	 *            the agent

+	 * @param diagramEObj

+	 *            the diagram e obj

+	 * @return the storage connections

+	 */

+	private List<Access> getStorageConnections(Agent agent,

+			Map<EObject, List<PictogramElement>> diagramEObj) {

+		ArrayList<Access> returnList = new ArrayList<Access>();

+		for (Access access : agent.getAccessConnections()) {

+			if (diagramEObj.containsKey(access.getTarget()))

+				returnList.add(access);

+		}

+

+		return returnList;

+	}

+

+	/**

+	 * Gets the source chanels.

+	 * 

+	 * @param agent

+	 *            the agent

+	 * @param diagramEObj

+	 *            the diagram e obj

+	 * @return the source chanels

+	 */

+	private List<Channel> getSourceChanels(Agent agent,

+			Map<EObject, List<PictogramElement>> diagramEObj) {

+		ArrayList<Channel> returnList = new ArrayList<Channel>();

+		for (Channel chl : agent.getSourceChannels()) {

+			if (diagramEObj.containsKey(chl.getTarget()))

+				returnList.add(chl);

+		}

+

+		return returnList;

+	}

+

+	/**

+	 * Gets the target chanels.

+	 * 

+	 * @param agent

+	 *            the agent

+	 * @param diagramEObj

+	 *            the diagram e obj

+	 * @return the target chanels

+	 */

+	private List<Channel> getTargetChanels(Agent agent,

+			Map<EObject, List<PictogramElement>> diagramEObj) {

+		ArrayList<Channel> returnList = new ArrayList<Channel>();

+		for (Channel chl : agent.getTargetChannels()) {

+			if (diagramEObj.containsKey(chl.getSource()))

+				returnList.add(chl);

+		}

+

+		return returnList;

+	}

+

+	/**

+	 * Gets the anchor.

+	 * 

+	 * @param pe

+	 *            the pe

+	 * @return the anchor

+	 */

+	private Anchor getAnchor(PictogramElement pe) {

+		Anchor ret = null;

+		if (pe instanceof Anchor) {

+			ret = (Anchor) pe;

+		} else if (pe instanceof AnchorContainer) {

+			ret = Graphiti.getPeService()

+					.getChopboxAnchor((AnchorContainer) pe);

+		}

+		return ret;

+	}

+

+	/**

+	 * Creates the context.

+	 * 

+	 * @param sourceObject

+	 *            the source object

+	 * @param targetObject

+	 *            the target object

+	 * @param obj

+	 *            the obj

+	 * @param connStyle

+	 *            the conn style

+	 * @return the adds the connection context

+	 */

+	private AddConnectionContext createContext(PictogramElement sourceObject,

+			PictogramElement targetObject, Object obj, ConnectionStyle connStyle) {

+

+		AddConnectionContext connectionContext = new AddConnectionContext(

+				getAnchor(sourceObject), getAnchor(targetObject));

+		connectionContext.setNewObject(obj);

+		connectionContext.putProperty(

+				BlockDiagramConstants.GRAPHICAL_TYPE_KEY, connStyle);

+		return connectionContext;

+	}

+

+	/**

+	 * Checks if is available.

+	 * 

+	 * @param context

+	 *            the context

+	 * @return true, if is available

+	 */

+	public boolean isAvailable(IContext context) {

+		if (cf != null)

+			return cf.isAvailable(context);

+		return true;

+	}

+

+	/**

+	 * Can execute.

+	 * 

+	 * @param context

+	 *            the context

+	 * @return true, if successful

+	 */

+	public boolean canExecute(IContext context) {

+		if (cf != null)

+			return cf.canExecute(context);

+		return true;

+	}

+

+	/**

+	 * Execute.

+	 * 

+	 * @param context

+	 *            the context

+	 */

+	public void execute(IContext context) {

+		if (cf != null)

+			cf.execute(context);

+	}

+

+	/**

+	 * Can undo.

+	 * 

+	 * @param context

+	 *            the context

+	 * @return true, if successful

+	 */

+	public boolean canUndo(IContext context) {

+		if (cf != null)

+			return cf.canUndo(context);

+		return true;

+	}

+

+	/**

+	 * Checks for done changes.

+	 * 

+	 * @return true, if successful

+	 */

+	public boolean hasDoneChanges() {

+		if (cf != null)

+			return cf.hasDoneChanges();

+		return true;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/DotsConnectionHelper.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/DotsConnectionHelper.java
new file mode 100644
index 0000000..cba4c07
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/DotsConnectionHelper.java
@@ -0,0 +1,75 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.util;

+

+import java.util.List;

+

+import org.eclipse.graphiti.mm.pictograms.AnchorContainer;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.fmc.blockdiagram.editor.features.add.DotsConnectionAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.fmc.mm.FMCNode;

+

+/**

+ * The Class DotsConnectionHelper.

+ */

+public class DotsConnectionHelper {

+

+	/**

+	 * Check if a given container for Gaphical multiplicity.

+	 * 

+	 * @param container

+	 *            the container

+	 * @param node

+	 *            the node

+	 * @return true, if successful

+	 */

+	public boolean graphicalMultiplicity(ContainerShape container, FMCNode node) {

+		List<Connection> cons = FMCUtil.getAllConnections(container);

+		for (Connection conn : cons) {

+			if (!DotsConnectionAddFeature.isDots(conn))

+				continue;

+			if (checkDotsConnection(conn.getStart().getParent(), conn.getEnd()

+					.getParent()))

+				return true;

+		}

+

+		return false;

+	}

+

+	/**

+	 * Check if two given container has a dots connection.

+	 * 

+	 * @param aConn1

+	 *            the AnchorContainer 1

+	 * @param aConn2

+	 *            the AnchorContainer 2

+	 * @return true, if successful

+	 */

+	private boolean checkDotsConnection(AnchorContainer aConn1,

+			AnchorContainer aConn2) {

+		if ((aConn1.getLink().getBusinessObjects() != null)

+				&& (aConn1.getLink().getBusinessObjects().size() == 1)

+				&& (aConn2.getLink().getBusinessObjects() != null)

+				&& (aConn2.getLink().getBusinessObjects().size() == 1)) {

+			if (aConn1.getLink().getBusinessObjects().get(0)

+					.equals(aConn2.getLink().getBusinessObjects().get(0)))

+				return true;

+		}

+		return false;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/FMCMetaUtil.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/FMCMetaUtil.java
new file mode 100644
index 0000000..87f7e40
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/FMCMetaUtil.java
@@ -0,0 +1,122 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.util;

+

+import java.util.Collections;

+

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.emf.ecore.resource.ResourceSet;

+import org.eclipse.fmc.blockdiagram.editor.meta.Activator;

+import org.eclipse.fmc.mm.Comment;

+import org.eclipse.fmc.mm.FMCConnection;

+import org.eclipse.fmc.mm.FMCModel;

+import org.eclipse.fmc.mm.FMCNode;

+import org.eclipse.fmc.mm.FmcFactory;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+

+/**

+ * Utility Class for the Meta Editor.

+ * 

+ * @author Patrick Jahnke

+ * 

+ */

+public class FMCMetaUtil {

+

+	private FMCMetaUtil() {

+	}

+

+	/**

+	 * Adds the model object.

+	 * 

+	 * @param obj

+	 *            the object to add

+	 * @param d

+	 *            the diagram

+	 * @param fp

+	 *            the featureprovider

+	 */

+	public static void addModelObject(EObject obj, Diagram d,

+			IFeatureProvider fp) {

+		URI uri = d.eResource().getURI();

+		uri = uri.trimFragment();

+		uri = uri.trimFileExtension();

+		uri = uri.appendFileExtension("block");

+		ResourceSet rSet = d.eResource().getResourceSet();

+		/*

+		 * final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()

+		 * .getRoot(); IResource file =

+		 * workspaceRoot.findMember(uri.toPlatformString(true)); Resource r =

+		 * null;

+		 */

+		FMCModel root = null;

+		Resource file = rSet.getResource(uri, false);

+		if (file == null) {

+			file = rSet.createResource(uri);

+			root = FmcFactory.eINSTANCE.createFMCModel();

+			file.getContents().add(root);

+			try {

+				file.save(Collections.EMPTY_MAP);

+			} catch (Exception e) {

+				Platform.getLog(Platform.getBundle(Activator.PLUGIN_ID)).log(

+						new Status(Status.ERROR, Activator.PLUGIN_ID,

+								"Could not save the model file", e));

+			}

+			fp.link(d, new EObject[] { root });

+		}

+

+		else {

+			file = rSet.getResource(uri, true);

+			root = (FMCModel) file.getContents().get(0);

+		}

+

+		if (obj instanceof FMCNode) {

+			FMCNode node = (FMCNode) obj;

+			// Add only to top level model if not already contained somewhere

+			// else

+			// if (node.getContainer() == null)

+			root.getNodes().add(node);

+		} else if (obj instanceof FMCConnection) {

+			root.getConnections().add((FMCConnection) obj);

+		} else if (obj instanceof Comment) {

+			root.getComments().add((Comment) obj);

+		}

+	}

+

+	/**

+	 * Get the FmcModel object from a given Diagram.

+	 * 

+	 * @param d

+	 *            The diagram

+	 * @return The FMCModel Object.

+	 */

+	public static FMCModel getFMCModel(Diagram d) {

+		URI uri = d.eResource().getURI();

+		uri = uri.trimFragment();

+		uri = uri.trimFileExtension();

+		uri = uri.appendFileExtension("block");

+		ResourceSet rSet = d.eResource().getResourceSet();

+		FMCModel root = null;

+		Resource file = rSet.getResource(uri, false);

+		file = rSet.getResource(uri, true);

+		root = (FMCModel) file.getContents().get(0);

+		return root;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/package.html
new file mode 100644
index 0000000..633d079
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/util/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains all utility classes for the Blockdiagram meta editor.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/FMCMetaDiagramFileWizard.java b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/FMCMetaDiagramFileWizard.java
new file mode 100644
index 0000000..54027e1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/FMCMetaDiagramFileWizard.java
@@ -0,0 +1,45 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.meta.wizard;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.fmc.blockdiagram.editor.util.DiagramFactory;

+import org.eclipse.fmc.blockdiagram.editor.wizards.BlockDiagramFileWizard;

+

+/**

+ * This specialization of the FMCDiagramFileWizard is responsible for creating

+ * FMC files with separated graphical and model files.

+ * 

+ * @author Benjamin Schmeling 

+ * 

+ */

+public class FMCMetaDiagramFileWizard extends BlockDiagramFileWizard {

+

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.wizards.BlockDiagramFileWizard#

+	 * createBlockdiagramFile(org.eclipse.core.resources.IFile)

+	 */

+	@Override

+	protected void createBlockdiagramFile(IFile file) {

+		DiagramFactory.createDefaultBlockdiagramMetaFile(

+				URI.createFileURI(file.getLocation().toFile().getAbsolutePath()),

+				diagramWidth, diagramHeight, gridUnit);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/package.html b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/package.html
new file mode 100644
index 0000000..a508962
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.meta/src/org/eclipse/fmc/blockdiagram/editor/meta/wizard/package.html
@@ -0,0 +1,5 @@
+<html>

+<body>This package contains wizard related code for the blockdiagram meta editor.

+</body>

+</html>

+

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/.classpath b/org.eclipse.fmc.blockdiagram.editor.tests/.classpath
new file mode 100644
index 0000000..098194c
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/.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/org.eclipse.fmc.blockdiagram.editor.tests/.gitignore b/org.eclipse.fmc.blockdiagram.editor.tests/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/.project b/org.eclipse.fmc.blockdiagram.editor.tests/.project
new file mode 100644
index 0000000..f3a826b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.fmc.blockdiagram.editor.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.fmc.blockdiagram.editor.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fmc.blockdiagram.editor.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/.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/org.eclipse.fmc.blockdiagram.editor.tests/META-INF/MANIFEST.MF b/org.eclipse.fmc.blockdiagram.editor.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..699c492
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests
+Bundle-SymbolicName: org.eclipse.fmc.blockdiagram.editor.tests
+Bundle-Version: 0.11.0.qualifier
+Fragment-Host: org.eclipse.fmc.blockdiagram.editor
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.eclipse.graphiti,
+ org.eclipse.emf.ecore.edit,
+ org.eclipse.ui.ide,
+ org.eclipse.emf.transaction,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.fmc.mm
+Import-Package: org.junit,
+ org.junit.runner
+Bundle-Vendor: Eclipse Modeling Project
+ 
diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/about.html b/org.eclipse.fmc.blockdiagram.editor.tests/about.html
new file mode 100644
index 0000000..333235b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>July 26, 2013</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/build.properties b/org.eclipse.fmc.blockdiagram.editor.tests/build.properties
new file mode 100644
index 0000000..a8cc5fe
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/build.properties
@@ -0,0 +1,21 @@
+###############################################################################
+# <copyright>
+#
+# Copyright (c) 2013, 2013 SAP AG.
+# 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:
+#    SAP AG - initial API, implementation and documentation
+#
+# </copyright>
+#
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               about.html
+src.includes = about.html
diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ConnectionTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ConnectionTest.java
new file mode 100644
index 0000000..c9f01ae
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ConnectionTest.java
@@ -0,0 +1,208 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_BI_ACCESS_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_BI_ACCESS_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_BI_COMM_CH_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_BI_COMM_CH_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_DOTS_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_DOTS_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_MODIFY_ACCESS;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_REQRESP_COMM_CH_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_REQRESP_COMM_CH_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_UNI_ACCESS_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_UNI_ACCESS_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_UNI_COMM_CH_FF;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_UNI_COMM_CH_MH;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STRUCTURE_VARIANCE;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertNotNull;

+

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.junit.Test;

+

+public class ConnectionTest extends FMCTestCase {

+

+	@Test

+	public void testUnidirectionalAccessMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape storage = createShape(CREATE_FEATURE_STORAGE, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_UNI_ACCESS_MH,

+				agent, storage);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testUnidirectionalAccessFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape storage = createShape(CREATE_FEATURE_STORAGE, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_UNI_ACCESS_FF,

+				agent, storage);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testBidirectionalAccessMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape storage = createShape(CREATE_FEATURE_STORAGE, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_BI_ACCESS_MH,

+				agent, storage);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testBidirectionalAccessFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape storage = createShape(CREATE_FEATURE_STORAGE, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_BI_ACCESS_FF,

+				agent, storage);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testModifyAccess() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape storage = createShape(CREATE_FEATURE_STORAGE, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_MODIFY_ACCESS,

+				agent, storage);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testBidirectionalComChannelMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_BI_COMM_CH_MH,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testBidirectionalComChannelFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_BI_COMM_CH_FF,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testUnidirectionalComChannelMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_UNI_COMM_CH_MH,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testUnidirectionalComChannelFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_UNI_COMM_CH_FF,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testReqResComChannelMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_REQRESP_COMM_CH_MH,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testReqResComChannelFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_REQRESP_COMM_CH_FF,

+				agent, agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testDotsMH() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_DOTS_MH, agent,

+				agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testDotsMHWithoutTarget() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Connection connection = createConnection(CREATE_CON_DOTS_MH, agent,

+				getDiagram());

+		assertEquals("Source Agent and invisible shape expected", 2,

+				getDiagram().getChildren().size());

+		assertNotNull(connection);

+		remove(connection);

+	}

+

+	@Test

+	public void testDotsFF() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape agent2 = createShape(CREATE_FEATURE_AGENT, 100, 100, 200, 10);

+		Connection connection = createConnection(CREATE_CON_DOTS_FF, agent,

+				agent2);

+		assertNotNull(connection);

+	}

+

+	@Test

+	public void testDotsFFWithoutTarget() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Connection connection = createConnection(CREATE_CON_DOTS_FF, agent,

+				getDiagram());

+		assertEquals("Source Agent and invisible shape expected", 2,

+				getDiagram().getChildren().size());

+		assertNotNull(connection);

+		remove(connection);

+	}

+

+	@Test

+	public void testContainerRemove() {

+		ContainerShape container = (ContainerShape) createShape(

+				CREATE_FEATURE_AGENT, 400, 400, 10, 10);

+		Shape anotherShape = createShape(CREATE_FEATURE_AGENT, 400, 400, 10, 10);

+		ContainerShape container2 = (ContainerShape) createShapeInShape(

+				CREATE_FEATURE_AGENT, 200, 200, 110, 110, container);

+		Shape child = createShapeInShape(CREATE_FEATURE_AGENT, 50, 50, 130,

+				130, container2);

+		Connection connection = createConnection(CREATE_CON_BI_COMM_CH_MH,

+				child, anotherShape);

+		assertNotNull(connection);

+		remove(container);

+	}

+

+	@Test

+	public void testConnectToStructureVariance() {

+		Shape agent = createShape(CREATE_FEATURE_AGENT, 100, 100, 10, 10);

+		Shape strv = createShape(CREATE_FEATURE_STRUCTURE_VARIANCE, 100, 100,

+				200, 10);

+		Connection connection = createConnection(CREATE_CON_UNI_ACCESS_FF,

+				agent, strv);

+		assertNotNull(connection);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCDiagramStateChecker.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCDiagramStateChecker.java
new file mode 100644
index 0000000..973f2e2
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCDiagramStateChecker.java
@@ -0,0 +1,134 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc;

+

+import static org.eclipse.fmc.FMCTestCase.assertSameSize;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertFalse;

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.assertTrue;

+import static org.junit.Assert.fail;

+

+import java.util.HashSet;

+import java.util.Set;

+

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.graphiti.mm.pictograms.CompositeConnection;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+public class FMCDiagramStateChecker {

+

+	private FMCNodeAlgorithmFactory factory = FMCNodeAlgorithmFactory

+			.getInstance();

+

+	public void checkDiagramState(Diagram diagram) {

+		checkNoAnchorsInDiagram(diagram);

+		checkDiagramStateRecursively(diagram);

+		checkConnectionOrphans(diagram);

+	}

+

+	private void checkDiagramStateRecursively(ContainerShape container) {

+		for (Shape shape : container.getChildren()) {

+			if (shape instanceof ContainerShape) {

+				ContainerShape childContainer = (ContainerShape) shape;

+				FMCNodeAlgorithm node = factory.getShape(shape);

+				if (node != null) {

+					if (node.isMultipleInstances(childContainer)) {

+						checkMultiInstanceShapeState(childContainer, node);

+					}

+				}

+				if (!childContainer.getGraphicsAlgorithm().isSetFilled()

+						&& !childContainer.getGraphicsAlgorithm()

+								.isSetLineVisible()) {

+					for (Anchor anchor : childContainer.getAnchors()) {

+						if (anchor.getIncomingConnections().isEmpty()

+								&& anchor.getOutgoingConnections().isEmpty())

+							fail("Invisible shape without connection detected");

+					}

+

+				}

+				checkDiagramStateRecursively(childContainer);

+			} else {

+

+			}

+		}

+	}

+

+	private void checkConnectionOrphans(Diagram diagram) {

+		Set<CompositeConnection> composites = new HashSet<CompositeConnection>();

+		for (Connection con : diagram.getConnections()) {

+			if (con instanceof CompositeConnection) {

+				composites.add((CompositeConnection) con);

+			}

+		}

+

+		for (Connection con : diagram.getConnections()) {

+			if (!isChildOfComposite(composites, con)) {

+				assertNotNull("Orphaned connection with no start anchor",

+						con.getStart());

+				assertNotNull("Orphaned connection with no end anchor",

+						con.getEnd());

+				assertNotNull("Orphaned connection with no start anchor", con

+						.getStart().getParent());

+				assertNotNull("Orphaned connection with no end anchor", con

+						.getEnd().getParent());

+				assertFalse(con.getStart().getParent() == diagram);

+				assertFalse(con.getEnd().getParent() == diagram);

+			}

+		}

+	}

+

+	private boolean isChildOfComposite(Set<CompositeConnection> composites,

+			Connection child) {

+		for (CompositeConnection comp : composites) {

+			for (Connection con : comp.getChildren()) {

+				if (con == child)

+					return true;

+			}

+		}

+		return false;

+	}

+

+	private void checkMultiInstanceShapeState(ContainerShape childContainer,

+			FMCNodeAlgorithm node) {

+		GraphicsAlgorithm multiInstanceChildMain = node.getMultiInstanceChild(

+				childContainer, true);

+		GraphicsAlgorithm multiInstanceChildSecond = node

+				.getMultiInstanceChild(childContainer, false);

+		assertNotNull(multiInstanceChildMain);

+		assertNotNull(multiInstanceChildSecond);

+		assertEquals(multiInstanceChildMain.getClass(),

+				multiInstanceChildSecond.getClass());

+		assertSameSize(multiInstanceChildMain, multiInstanceChildSecond);

+		assertEquals(multiInstanceChildMain.getX(),

+				multiInstanceChildSecond.getX() + 5);

+		assertEquals(multiInstanceChildMain.getY() + 5,

+				multiInstanceChildSecond.getY());

+	}

+

+	private void checkNoAnchorsInDiagram(Diagram diagram) {

+		assertTrue(

+				"State of diagram not valid: There are anchors in the diagram.",

+				diagram.getAnchors().isEmpty());

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCTestCase.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCTestCase.java
new file mode 100644
index 0000000..29a78f6
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/FMCTestCase.java
@@ -0,0 +1,298 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_CON_MODIFY_ACCESS;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertTrue;

+

+import java.io.ByteArrayInputStream;

+import java.io.IOException;

+import java.io.InputStream;

+import java.util.Iterator;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.core.resources.IWorkspaceRoot;

+import org.eclipse.core.resources.ResourcesPlugin;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.draw2d.RoundedRectangle;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.edit.domain.IEditingDomainProvider;

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.emf.transaction.TransactionalEditingDomain;

+import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;

+import org.eclipse.fmc.blockdiagram.editor.BlockDiagramEditor;

+import org.eclipse.fmc.blockdiagram.editor.util.DiagramFactory;

+import org.eclipse.graphiti.features.ICreateConnectionFeature;

+import org.eclipse.graphiti.features.ICreateFeature;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.features.IRemoveFeature;

+import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;

+import org.eclipse.graphiti.features.context.impl.CreateContext;

+import org.eclipse.graphiti.features.context.impl.RemoveContext;

+import org.eclipse.graphiti.internal.datatypes.impl.LocationImpl;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.IWorkbenchPart;

+import org.eclipse.ui.PartInitException;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.ui.ide.IDE;

+import org.eclipse.ui.internal.ViewIntroAdapterPart;

+import org.eclipse.ui.internal.intro.IIntroConstants;

+import org.junit.After;

+import org.junit.Before;

+

+@SuppressWarnings("restriction")

+public abstract class FMCTestCase {

+

+	protected static final String BLOCKDIAG_FILENAME = "newDiag.blockdiag";

+	private BlockDiagramEditor editor = null;

+	private FMCDiagramStateChecker stateChecker = new FMCDiagramStateChecker();

+

+	protected BlockDiagramEditor getEditor() {

+		return this.editor;

+	}

+

+	protected void checkDiagramState() {

+		stateChecker.checkDiagramState(getDiagram());

+	}

+

+	protected TransactionalEditingDomain getEditingDomain() {

+		IWorkbenchPart activePart = PlatformUI.getWorkbench()

+				.getActiveWorkbenchWindow().getActivePage().getActivePart();

+

+		IEditingDomainProvider provider = (IEditingDomainProvider) activePart

+				.getAdapter(IEditingDomainProvider.class);

+		assert provider.getEditingDomain() instanceof TransactionalEditingDomain;

+		TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) provider

+				.getEditingDomain();

+		return editingDomain;

+	}

+

+	protected CreateContext createContext(int width, int height, int x, int y) {

+		CreateContext ctx = new CreateContext();

+		ctx.setLocation(x, y);

+		ctx.setSize(width, height);

+		ctx.setTargetContainer(getDiagram());

+		return ctx;

+	}

+

+	protected IFeatureProvider getFeatureProvider() {

+		return editor.getDiagramTypeProvider().getFeatureProvider();

+	}

+

+	protected Diagram getDiagram() {

+		return editor.getDiagramTypeProvider().getDiagram();

+	}

+

+	public static void assertSameAlgorithm(Shape expected, Shape actual) {

+		GraphicsAlgorithm algorithmA = expected.getGraphicsAlgorithm();

+		GraphicsAlgorithm algorithmB = actual.getGraphicsAlgorithm();

+		assertEquals(algorithmA.getClass(), algorithmB.getClass());

+	}

+

+	public static void assertSameSize(GraphicsAlgorithm expected,

+			GraphicsAlgorithm actual) {

+		assertEquals(expected.getHeight(), actual.getHeight());

+		assertEquals(expected.getWidth(), actual.getWidth());

+		if (expected instanceof RoundedRectangle) {

+			RoundedRectangle rectA = (RoundedRectangle) expected;

+			RoundedRectangle rectB = (RoundedRectangle) expected;

+			assertEquals(rectA.getCornerDimensions().width,

+					rectB.getCornerDimensions().width);

+			assertEquals(rectA.getCornerDimensions().height,

+					rectB.getCornerDimensions().height);

+		} else if (expected instanceof Polygon) {

+			Polygon polyA = (Polygon) expected;

+			Polygon polyB = (Polygon) actual;

+			assertEquals(polyA.getPoints().size(), polyB.getPoints().size());

+			Iterator<Point> iteratorB = polyB.getPoints().iterator();

+			for (Iterator<Point> iteratorA = polyA.getPoints().iterator(); iteratorA

+					.hasNext();) {

+				Point a = iteratorA.next();

+				Point b = iteratorB.next();

+				assertEquals(a.getX(), b.getX());

+				assertEquals(a.getY(), b.getY());

+			}

+		}

+

+	}

+

+	public static void assertSameLocation(Shape expected, Shape actual) {

+		GraphicsAlgorithm algorithmA = expected.getGraphicsAlgorithm();

+		GraphicsAlgorithm algorithmB = actual.getGraphicsAlgorithm();

+		assertEquals(algorithmA.getX(), algorithmB.getX());

+		assertEquals(algorithmA.getY(), algorithmB.getY());

+	}

+

+	public static void assertSize(Shape shape, int width, int height) {

+		GraphicsAlgorithm algorithm = shape.getGraphicsAlgorithm();

+		assertEquals(width, algorithm.getWidth());

+		assertEquals(height, algorithm.getHeight());

+	}

+

+	public void assertPosition(Shape shape, int x, int y) {

+		GraphicsAlgorithm algorithm = shape.getGraphicsAlgorithm();

+		assertEquals(x, algorithm.getX());

+		assertEquals(y, algorithm.getY());

+	}

+

+	protected IProject getProject() {

+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

+		IProject project = root.getProject("TestProject");

+		return project;

+	}

+

+	private IFile getFmcFile(String filename) throws CoreException {

+		IProgressMonitor progressMonitor = new NullProgressMonitor();

+		IProject project = getProject();

+		if (!project.exists())

+			project.create(progressMonitor);

+		project.open(progressMonitor);

+		final IFile file = project.getFile(new Path(filename));

+		/*

+		 * if(file.exists()){ file.delete(true, progressMonitor); }

+		 */

+

+		InputStream stream;

+		try {

+			String contents = "This is the initial file contents for *.blockdiag file that should be word-sorted in the Preview page of the multi-page editor";

+			stream = new ByteArrayInputStream(contents.getBytes());

+			if (!file.exists()) {

+				file.create(stream, true, progressMonitor);

+			}

+			stream.close();

+		} catch (IOException e) {

+		}

+		createFMCFile(file);

+

+		return file;

+	}

+

+	protected void createFMCFile(final IFile file) {

+		DiagramFactory.createDefaultBlockdiagramFile(URI.createPlatformResourceURI(file

+				.getFullPath().toString(), true), 1000, 1000, 10);

+	}

+

+	protected void saveDiagram() {

+		editor.doSave(new NullProgressMonitor());

+	}

+

+	@After

+	public void tearDown() {

+		checkDiagramState();

+		saveDiagram();

+		// TODO close diagram

+		// editor.getSite().getPage().close();

+		// editor = null;

+	}

+

+	@Before

+	public void setUp() throws PartInitException, CoreException {

+		IWorkbenchPage activePage = PlatformUI.getWorkbench()

+				.getActiveWorkbenchWindow().getActivePage();

+		

+		editor = (BlockDiagramEditor) IDE.openEditor(activePage,

+				getFmcFile(BLOCKDIAG_FILENAME));

+		ViewIntroAdapterPart viewIntro = (ViewIntroAdapterPart) activePage

+				.findView(IIntroConstants.INTRO_VIEW_ID);

+		if (viewIntro != null)

+			viewIntro.getViewSite().getPart().dispose();

+	}

+

+	protected Connection createConnection(int createFeature, Shape source,

+			Shape target) {

+		int consBefore = getDiagram().getConnections().size();

+		ICreateConnectionFeature createConnectionFeature = getFeatureProvider()

+				.getCreateConnectionFeatures()[createFeature];

+		CreateConnectionContext ctx = new CreateConnectionContext();

+		ctx.setSourcePictogramElement(source);

+		ctx.setTargetPictogramElement(target);

+		ctx.setTargetLocation(new LocationImpl(source.getGraphicsAlgorithm()

+				.getX() + 50, source.getGraphicsAlgorithm().getY() + 50));

+		if (createConnectionFeature.canExecute(ctx)) {

+			createConnectionFeature.execute(ctx);

+			assertEquals(

+					createFeature == CREATE_CON_MODIFY_ACCESS ? consBefore + 3

+							: consBefore + 1, getDiagram().getConnections()

+							.size());

+			return getDiagram().getConnections().get(consBefore);

+		} else

+			return null;

+	}

+

+	protected void remove(final PictogramElement element) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						RemoveContext ctx = new RemoveContext(element);

+						IRemoveFeature deleteFeature = getFeatureProvider()

+								.getRemoveFeature(ctx);

+						assertTrue(deleteFeature.canRemove(ctx));

+						assertTrue(deleteFeature.canExecute(ctx));

+						deleteFeature.execute(ctx);

+					}

+				});

+	}

+

+	protected Shape createShapeInShape(int createFeature, final int width,

+			final int height, final int x, final int y, ContainerShape container) {

+		int childsBefore = getDiagram().getChildren().size();

+		int childsBeforeContainer = 0;

+		ICreateFeature feature = getFeatureProvider().getCreateFeatures()[createFeature];

+		CreateContext ctx = createContext(width, height, x, y);

+		if (container != null) {

+			ctx.setTargetContainer(container);

+			childsBeforeContainer = container.getChildren().size();

+		}

+		assertTrue(feature.canExecute(ctx));

+		feature.execute(ctx);

+		if (container != null) {

+			assertEquals(childsBeforeContainer + 1, container.getChildren()

+					.size());

+			return container.getChildren().get(childsBeforeContainer);

+		} else {

+			assertEquals(childsBefore + 1, getDiagram().getChildren().size());

+			return getDiagram().getChildren().get(childsBefore);

+		}

+	}

+

+	protected Shape createShape(int createFeature, final int width,

+			final int height, final int x, final int y) {

+		return createShapeInShape(createFeature, width, height, x, y, null);

+	}

+

+	protected boolean isWriteTransaction(TransactionalEditingDomain domain) {

+		if (domain instanceof TransactionalEditingDomainImpl)

+			return !((TransactionalEditingDomainImpl) domain)

+					.getActiveTransaction().isReadOnly();

+		else

+			return true;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTest.java
new file mode 100644
index 0000000..5298de9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTest.java
@@ -0,0 +1,271 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AREA_BORDER;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_BRACE;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_COMMON_FEATURE_AREA;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_DOTS;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_HUMAN_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STRUCTURE_VARIANCE;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertTrue;

+

+import java.awt.Point;

+

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.graphiti.features.IMoveShapeFeature;

+import org.eclipse.graphiti.features.IRemoveFeature;

+import org.eclipse.graphiti.features.IResizeShapeFeature;

+import org.eclipse.graphiti.features.context.impl.MoveShapeContext;

+import org.eclipse.graphiti.features.context.impl.RemoveContext;

+import org.eclipse.graphiti.features.context.impl.ResizeShapeContext;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.algorithms.styles.Orientation;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.junit.Test;

+

+public class ShapeTest extends FMCTestCase {

+

+	private static final int WIDTH = 200;

+	private static final int HEIGHT = 120;

+

+	private Shape testCreate(int createFeature) {

+		return testCreate(createFeature, new Point(0, 0));

+	}

+

+	protected Shape testCreate(int createFeature, final Point offset) {

+		final int width = 200;

+		final int height = 120;

+		final int x = 2;

+		final int y = 5;

+		Shape shape = createShape(createFeature, width, height, x, y);

+		assertSize(shape, width + offset.x, height + offset.y);

+		assertPosition(shape, x, y);

+		return shape;

+	}

+

+	private void testResize(final Shape shape) {

+		testResize(shape, new Point(0, 0), Orientation.ALIGNMENT_BOTTOM);

+	}

+

+	private void testResize(final Shape shape, final Point offset,

+			final Orientation hAlignment) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						int width = 122;

+						int height = 111;

+						AbstractText text = findText((ContainerShape) shape);

+						Orientation horizontalBefore = null;

+						Orientation horizontalAfter = null;

+						if (text != null) {

+							text.setHorizontalAlignment(hAlignment);

+							horizontalBefore = text.getHorizontalAlignment();

+							horizontalAfter = text.getVerticalAlignment();

+						}

+						ResizeShapeContext ctx = new ResizeShapeContext(shape);

+						ctx.setSize(width, height);

+						IResizeShapeFeature resizeShapeFeature = getFeatureProvider()

+								.getResizeShapeFeature(ctx);

+						assertTrue(resizeShapeFeature.canResizeShape(ctx));

+						assertTrue(resizeShapeFeature.canExecute(ctx));

+						resizeShapeFeature.execute(ctx);

+						assertEquals(width + offset.x, shape

+								.getGraphicsAlgorithm().getWidth());

+						assertEquals(height + offset.y, shape

+								.getGraphicsAlgorithm().getHeight());

+						if (text != null) {

+							text = findText((ContainerShape) shape);

+							assertEquals(horizontalBefore,

+									text.getHorizontalAlignment());

+							assertEquals(horizontalAfter,

+									text.getVerticalAlignment());

+						}

+					}

+				});

+	}

+

+	private void testMove(final Shape shape) {

+		testMove(shape, new Point(0, 0));

+	}

+

+	private void testMove(final Shape shape, final Point offset) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						final int width = WIDTH;

+						final int height = HEIGHT;

+						MoveShapeContext ctx = new MoveShapeContext(shape);

+						ctx.setLocation(20, 20);

+						ctx.setSourceContainer(shape.getContainer());

+						ctx.setTargetContainer(shape.getContainer());

+						IMoveShapeFeature moveShapeFeature = getFeatureProvider()

+								.getMoveShapeFeature(ctx);

+						assertTrue(moveShapeFeature.canExecute(ctx));

+						assertTrue(moveShapeFeature.canMoveShape(ctx));

+						assertTrue(moveShapeFeature.isAvailable(ctx));

+						moveShapeFeature.execute(ctx);

+						assertSize(shape, width + offset.x, height + offset.y);

+						assertPosition(shape, 20, 20);

+						// TODO Test moving into another shape

+					}

+				});

+	}

+

+	private void testDelete(final Shape shape) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						RemoveContext ctx = new RemoveContext(shape);

+						IRemoveFeature deleteFeature = getFeatureProvider()

+								.getRemoveFeature(ctx);

+						assertTrue("Remove feature cannot be executed",

+								deleteFeature.canRemove(ctx));

+						assertTrue(deleteFeature.canExecute(ctx));

+						deleteFeature.execute(ctx);

+						assertEquals(0, getDiagram().getChildren().size());

+					}

+				});

+	}

+

+	@Test

+	public void testAgent() {

+		Shape shape = testCreate(CREATE_FEATURE_AGENT);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testAgentL() {

+		Shape shape = testCreate(CREATE_FEATURE_AGENT_L);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testAgentU() {

+		Shape shape = testCreate(CREATE_FEATURE_AGENT_U);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testStorage() {

+		Shape shape = testCreate(CREATE_FEATURE_STORAGE);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testStorageL() {

+		Shape shape = testCreate(CREATE_FEATURE_STORAGE_L);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testStorageU() {

+		Shape shape = testCreate(CREATE_FEATURE_STORAGE_U);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testHumanAgent() {

+		Shape shape = testCreate(CREATE_FEATURE_HUMAN_AGENT);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testStructureVariance() {

+		Shape shape = testCreate(CREATE_FEATURE_STRUCTURE_VARIANCE);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	/*

+	 * public void testChannel(){ Shape shape =

+	 * testCreate(CREATE_FEATURE_CHANNEL); testMove(shape); testResize(shape);

+	 * testDelete(shape); }

+	 */

+	@Test

+	public void testCommonFeatureArea() {

+		Shape shape = testCreate(CREATE_FEATURE_COMMON_FEATURE_AREA);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testBrace() {

+		Shape shape = testCreate(CREATE_FEATURE_BRACE, new Point(0, -75));

+		testMove(shape, new Point(0, -75));

+		testResize(shape, new Point(0, -84), Orientation.ALIGNMENT_RIGHT);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testAreaBorder() {

+		Shape shape = testCreate(CREATE_FEATURE_AREA_BORDER, new Point(0, -92));

+		testMove(shape, new Point(0, -92));

+		testResize(shape, new Point(0, -83), Orientation.ALIGNMENT_RIGHT);

+		testDelete(shape);

+	}

+

+	@Test

+	public void testDots() {

+		Shape shape = testCreate(CREATE_FEATURE_DOTS);

+		testMove(shape);

+		testResize(shape);

+		testDelete(shape);

+	}

+

+	private AbstractText findText(ContainerShape shape) {

+		for (Shape child : shape.getChildren()) {

+			if (child.getGraphicsAlgorithm() instanceof AbstractText) {

+				return (AbstractText) child.getGraphicsAlgorithm();

+			}

+		}

+		AbstractText found = null;

+		for (Shape child : shape.getChildren()) {

+			if (child instanceof ContainerShape)

+				found = findText((ContainerShape) child);

+			if (found != null)

+				return found;

+		}

+		return found;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTransformationsTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTransformationsTest.java
new file mode 100644
index 0000000..861b4ef
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/ShapeTransformationsTest.java
@@ -0,0 +1,423 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_HUMAN_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertFalse;

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.assertTrue;

+

+import java.util.ArrayList;

+

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.AgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.HumanAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.LAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.LStorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.StorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.UAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.UStorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.property.PropertyActions;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.junit.Test;

+

+public class ShapeTransformationsTest extends FMCTestCase {

+

+	private static final int STYLE_RECT = 0;

+	private static final int STYLE_L = 1;

+	private static final int STYLE_U = 2;

+

+	private static final int WIDTH = 200;

+	private static final int HEIGHT = 120;

+	// private FMCTypeChecker helper = FMCTypeHelperFactory.getInstance();

+	private FMCNodeAlgorithmFactory factory = FMCNodeAlgorithmFactory

+			.getInstance();

+	private PropertyActions actions;

+

+	private PropertyActions getPropertyActions() {

+		if (actions == null)

+			actions = new PropertyActions(getDiagram(), getFeatureProvider(),

+					getEditingDomain());

+		return actions;

+	}

+

+	@Test

+	public void testTransformRectStorageToLandUPlusMultiInstances() {

+		ContainerShape storage = (ContainerShape) createShape(

+				CREATE_FEATURE_STORAGE, WIDTH, HEIGHT, 20, 30);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(storage);

+		assertTrue(nodeAlgo instanceof StorageAlgorithm);

+		StorageAlgorithm storageAlgo = (StorageAlgorithm) nodeAlgo;

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		assertSize(storage, WIDTH, HEIGHT);

+		assertPosition(storage, 20, 30);

+		checkDiagramState();

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+		assertFalse(storageAlgo.isMultipleInstances(storage));

+		// Now again but with multiInstance

+		setMultipleInstances(factory.getShape(storage), storage, true);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoL(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoU(storage);

+		assertTrue(storageAlgo.isMultipleInstances(storage));

+		turnStorageIntoRect(storage);

+	}

+

+	@Test

+	public void testTransformRectAgentToLandUPlusMultiInstances() {

+		ContainerShape agent = (ContainerShape) createShape(

+				CREATE_FEATURE_AGENT, WIDTH, HEIGHT, 20, 30);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		AgentAlgorithm agentAlgo = (AgentAlgorithm) nodeAlgo;

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		// Now again but with multiInstance

+		setMultipleInstances(factory.getShape(agent), agent, true);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoL(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoU(agent);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		turnAgentIntoRect(agent);

+	}

+

+	private void turnAgentIntoRect(ContainerShape agent) {

+		getPropertyActions().changeShapeStyle(agent, STYLE_RECT);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	private void turnAgentIntoL(ContainerShape agent) {

+		FMCNodeAlgorithm nodeAlgo;

+		getPropertyActions().changeShapeStyle(agent, STYLE_L);

+		nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		assertTrue(nodeAlgo instanceof LAgentAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	private void turnAgentIntoU(ContainerShape agent) {

+		FMCNodeAlgorithm nodeAlgo;

+		getPropertyActions().changeShapeStyle(agent, STYLE_U);

+		nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		assertTrue(nodeAlgo instanceof UAgentAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	private void turnStorageIntoRect(ContainerShape agent) {

+		getPropertyActions().changeShapeStyle(agent, STYLE_RECT);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof StorageAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	private void turnStorageIntoL(ContainerShape agent) {

+		FMCNodeAlgorithm nodeAlgo;

+		getPropertyActions().changeShapeStyle(agent, STYLE_L);

+		nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof StorageAlgorithm);

+		assertTrue(nodeAlgo instanceof LStorageAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	private void turnStorageIntoU(ContainerShape agent) {

+		FMCNodeAlgorithm nodeAlgo;

+		getPropertyActions().changeShapeStyle(agent, STYLE_U);

+		nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof StorageAlgorithm);

+		assertTrue(nodeAlgo instanceof UStorageAlgorithm);

+		expectHumanAgent(agent, false);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		checkDiagramState();

+	}

+

+	@Test

+	public void testTransformSingleAgentToHumanToMultipleInstances() {

+		ContainerShape agent = (ContainerShape) createShape(

+				CREATE_FEATURE_AGENT, WIDTH, HEIGHT, 20, 30);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		AgentAlgorithm agentAlgo = (AgentAlgorithm) nodeAlgo;

+		expectHumanAgent(agent, false);

+		setMultipleInstances(agentAlgo, agent, true);

+		assertSize(agent, WIDTH, HEIGHT);

+		assertPosition(agent, 20, 30);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		assertNotNull(agentAlgo.getMultiInstanceChild(agent, true));

+		assertNotNull(agentAlgo.getMultiInstanceChild(agent, false));

+		// Now turn into Human Agent

+		turnIntoHumanAgent(agent);

+		expectHumanAgent(agent, true);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into normal Agent

+		turnIntoNormalAgent(agent);

+		expectHumanAgent(agent, false);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into Human Agent

+		turnIntoHumanAgent(agent);

+		expectHumanAgent(agent, true);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into single Human Agent

+		setMultipleInstances(agentAlgo, agent, false);

+		expectHumanAgent(agent, true);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into single normal Agent

+		turnIntoNormalAgent(agent);

+		expectHumanAgent(agent, false);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into single Human Agent

+		turnIntoHumanAgent(agent);

+		expectHumanAgent(agent, true);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into multiple Human Agent

+		setMultipleInstances(agentAlgo, agent, true);

+		expectHumanAgent(agent, true);

+		assertTrue(agentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+		// Turn into single Human Agent

+		setMultipleInstances(agentAlgo, agent, false);

+		expectHumanAgent(agent, true);

+		assertFalse(agentAlgo.isMultipleInstances(agent));

+	}

+

+	private void expectHumanAgent(ContainerShape shape, boolean human) {

+		if (human) {

+			assertTrue(factory.getHumanAgent().hasHumanFigure(shape));

+			assertEquals(1, countHumanFigures(shape));

+		} else {

+			assertFalse(factory.getHumanAgent().hasHumanFigure(shape));

+			assertEquals(0, countHumanFigures(shape));

+		}

+

+	}

+

+	@Test

+	public void testTransformNormalAgentToHumanAgent() {

+		ContainerShape agent = (ContainerShape) createShape(

+				CREATE_FEATURE_HUMAN_AGENT, WIDTH, HEIGHT, 20, 30);

+		FMCNodeAlgorithm nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof HumanAgentAlgorithm);

+		HumanAgentAlgorithm hagentAlgo = (HumanAgentAlgorithm) nodeAlgo;

+

+		turnIntoNormalAgent(agent);

+		expectHumanAgent(agent, false);

+		assertFalse(hagentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+

+		nodeAlgo = factory.getShape(agent);

+		assertTrue(nodeAlgo instanceof AgentAlgorithm);

+		AgentAlgorithm agentAlgo = (HumanAgentAlgorithm) nodeAlgo;

+		checkDiagramState();

+

+		turnIntoHumanAgent(agent);

+		expectHumanAgent(agent, true);

+		assertFalse(hagentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+

+		setMultipleInstances(agentAlgo, agent, true);

+		expectHumanAgent(agent, true);

+		assertTrue(hagentAlgo.isMultipleInstances(agent));

+		checkDiagramState();

+

+		setMultipleInstances(hagentAlgo, agent, false);

+		expectHumanAgent(agent, true);

+		assertFalse(hagentAlgo.isMultipleInstances(agent));

+	}

+

+	public int countHumanFigures(ContainerShape element) {

+		int counter = 0;

+		if (element instanceof ContainerShape) {

+			ContainerShape container = (ContainerShape) element;

+			for (Shape shape : new ArrayList<Shape>(container.getChildren())) {

+				if (shape instanceof ContainerShape

+						&& shape.getGraphicsAlgorithm()

+								.getGraphicsAlgorithmChildren().size() == 5) {

+					counter++;

+				} else if (shape instanceof ContainerShape) {

+					counter += countHumanFigures((ContainerShape) shape);

+				}

+			}

+			;

+		}

+		// ContainerShape multiInstanceChild = (ContainerShape)

+		// factory.getHumanAgent().getMultiInstanceChild(element, false);

+		// if(element != null){

+		// for (Shape shape : new ArrayList<Shape>(element.getChildren())) {

+		// if(shape instanceof ContainerShape &&

+		// ((ContainerShape) shape).getChildren().size() == 5){

+		// counter++;

+		// }

+		// };

+		//

+		// }

+		return counter;

+	}

+

+	private void turnIntoHumanAgent(final ContainerShape shape) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						if (isWriteTransaction(getEditingDomain())) {

+							factory.getHumanAgent().addHumanFigure(

+									getDiagram(), shape,

+									shape.getGraphicsAlgorithm().getWidth());

+						}

+					}

+

+				});

+	}

+

+	private void turnIntoNormalAgent(final ContainerShape shape) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						if (isWriteTransaction(getEditingDomain())) {

+							factory.getHumanAgent().removeHumanFigure(shape);

+						}

+					}

+

+				});

+	}

+

+	private void setMultipleInstances(final FMCNodeAlgorithm algo,

+			final ContainerShape shape, final boolean multi) {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						if (isWriteTransaction(getEditingDomain())) {

+							algo.setMultipleInstances(shape,

+									getFeatureProvider(), multi);

+						}

+					}

+

+				});

+	}

+

+	/*

+	 * private void refreshOldAnchors(Shape shape, GraphicsAlgorithm algorithm,

+	 * Set<BoxRelativeAnchor> stillUsedAnchors){ for (BoxRelativeAnchor anchor :

+	 * stillUsedAnchors) { anchor.setParent(shape);

+	 * shape.getAnchors().add(anchor);

+	 * anchor.setReferencedGraphicsAlgorithm(algorithm); } }

+	 */

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/blockdiagram/editor/property/PropertySheetTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/blockdiagram/editor/property/PropertySheetTest.java
new file mode 100644
index 0000000..4d4a42f
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/blockdiagram/editor/property/PropertySheetTest.java
@@ -0,0 +1,300 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.property;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_HUMAN_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STRUCTURE_VARIANCE;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertFalse;

+import static org.junit.Assert.assertTrue;

+

+import org.eclipse.fmc.blockdiagram.editor.property.DiagramPropertySection;

+import org.eclipse.fmc.blockdiagram.editor.property.ShapePropertySection;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.fmc.FMCTestCase;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.HumanAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.LPolygonAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.MultipleNode;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.RectangleAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.UPolygonAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.swt.SWT;

+import org.eclipse.swt.widgets.Event;

+import org.eclipse.ui.IPageLayout;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.PartInitException;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.ui.views.properties.PropertySheet;

+import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;

+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

+import org.junit.Test;

+

+public class PropertySheetTest extends FMCTestCase {

+

+	private static final String TAB_PREDEFINED_STYLE = "fmc.PredefinedStyleTab";

+	private static final String TAB_DIAGRAM = "fmc.DiagramTab";

+	private static final String TAB_SHAPE = "fmc.ShapeTab";

+	private static final String TAB_STYLE = "fmc.StyleTab";

+	private static final String TAB_ALIGNMENT = "fmc.AlignmentTab";

+

+	private FMCNodeAlgorithmFactory factory = FMCNodeAlgorithmFactory

+			.getInstance();

+

+	@Override

+	public void setUp() throws PartInitException, CoreException {

+		super.setUp();

+	}

+

+	TabbedPropertySheetPage getTabbedPropSheet() throws PartInitException {

+		IWorkbenchPage activePage = PlatformUI.getWorkbench()

+				.getActiveWorkbenchWindow().getActivePage();

+

+		PropertySheet propSheet = (PropertySheet) activePage

+				.findView(IPageLayout.ID_PROP_SHEET);

+		if (propSheet == null)

+			propSheet = (PropertySheet) activePage

+					.showView(IPageLayout.ID_PROP_SHEET);

+		activePage.bringToTop(propSheet);

+		return (TabbedPropertySheetPage) propSheet.getCurrentPage();

+	}

+

+	@Test

+	public void testDiagramPropertySection() throws PartInitException {

+		// Diagram selected

+		TabbedPropertySheetPage page = getTabbedPropSheet();

+		checkTabsForDiagram(page);

+		page.setSelectedTab(TAB_DIAGRAM);

+		DiagramPropertySection section = (DiagramPropertySection) page

+				.getCurrentTab().getSections()[0];

+		assertFalse(section.getAnchorsVisible().getSelection());

+		assertAnchorsVisible(false);

+		section.getAnchorsVisible().setSelection(true);

+		assertAnchorsVisible(false);

+	}

+

+	private void checkTabsForDiagram(TabbedPropertySheetPage page) {

+		ITabDescriptor[] activeTabs = page.getActiveTabs();

+		assertEquals(TAB_DIAGRAM, activeTabs[0].getId());

+		assertEquals(TAB_PREDEFINED_STYLE, activeTabs[1].getId());

+	}

+

+	private void select(PictogramElement element) {

+		getEditor().setPictogramElementForSelection(element);

+		getEditor().getDiagramBehavior().selectBufferedPictogramElements();

+		getEditor().getDiagramBehavior().refresh();

+	}

+

+	@Test

+	public void testShapePropertySectionForAgent() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_AGENT);

+	}

+

+	@Test

+	public void testShapePropertySectionForHumanAgent()

+			throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_HUMAN_AGENT);

+	}

+

+	@Test

+	public void testShapePropertySectionForAgentL() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_AGENT_L);

+	}

+

+	@Test

+	public void testShapePropertySectionForAgentU() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_AGENT_U);

+	}

+

+	@Test

+	public void testShapePropertySectionForStorage() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_STORAGE);

+	}

+

+	@Test

+	public void testShapePropertySectionForStorageL() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_STORAGE_L);

+	}

+

+	@Test

+	public void testShapePropertySectionForStorageU() throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_STORAGE_U);

+	}

+

+	@Test

+	public void testShapePropertySectionForStructureVariance()

+			throws PartInitException {

+		testShapePropertySectionForShape(CREATE_FEATURE_STRUCTURE_VARIANCE);

+	}

+

+	private void testShapePropertySectionForShape(int shapeType)

+			throws PartInitException {

+		final int WIDTH = 150;

+		final int HEIGHT = 200;

+		final int X = 75;

+		final int Y = 50;

+		FMCNodeAlgorithm nodeAlgorithm = null;

+		Shape shape = createShape(shapeType, 100, 100, 5, 5);

+		select(shape);

+		TabbedPropertySheetPage page = getTabbedPropSheet();

+		checkTabsForShape(page);

+		page.setSelectedTab(TAB_SHAPE);

+		ShapePropertySection shapeProp = (ShapePropertySection) page

+				.getCurrentTab().getSections()[0];

+		// Width

+		assertTrue(shapeProp.getWidth().isEnabled());

+		shapeProp.getWidth().setSelection(WIDTH);

+		assertEquals(WIDTH, shape.getGraphicsAlgorithm().getWidth());

+		// Height

+		assertTrue(shapeProp.getHeight().isEnabled());

+		shapeProp.getHeight().setSelection(HEIGHT);

+		assertEquals(HEIGHT, shape.getGraphicsAlgorithm().getHeight());

+		// X

+		assertTrue(shapeProp.getxLocation().isEnabled());

+		shapeProp.getxLocation().setSelection(X);

+		assertEquals(X, shape.getGraphicsAlgorithm().getX());

+		// Y

+		assertTrue(shapeProp.getyLocation().isEnabled());

+		shapeProp.getyLocation().setSelection(Y);

+		assertEquals(Y, shape.getGraphicsAlgorithm().getY());

+		// Human Agent

+		boolean humanAgentAvailable = CREATE_FEATURE_AGENT == shapeType

+				|| CREATE_FEATURE_HUMAN_AGENT == shapeType;

+		assertEquals(humanAgentAvailable, shapeProp.getIsHumanAgent()

+				.isEnabled());

+		if (humanAgentAvailable) {

+			assertEquals(CREATE_FEATURE_HUMAN_AGENT == shapeType, shapeProp

+					.getIsHumanAgent().getSelection());

+			shapeProp.getIsHumanAgent().setSelection(true);

+			shapeProp.getIsHumanAgent().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof HumanAgentAlgorithm);

+			shapeProp.getIsHumanAgent().setSelection(false);

+			shapeProp.getIsHumanAgent().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(!(nodeAlgorithm instanceof HumanAgentAlgorithm));

+		}

+		// Multi Instances

+		shape = createShape(shapeType, 100, 100, 5, 5);

+		select(shape);

+		shapeProp = (ShapePropertySection) page.getCurrentTab().getSections()[0];

+		boolean multiInstanceAvailable = CREATE_FEATURE_AGENT == shapeType

+				|| CREATE_FEATURE_STORAGE == shapeType

+				|| CREATE_FEATURE_HUMAN_AGENT == shapeType

+				|| CREATE_FEATURE_AGENT_L == shapeType

+				|| CREATE_FEATURE_AGENT_U == shapeType

+				|| CREATE_FEATURE_STORAGE_L == shapeType

+				|| CREATE_FEATURE_STORAGE_U == shapeType;

+		assertEquals(multiInstanceAvailable, shapeProp.getIsMultiInstance()

+				.isEnabled());

+		if (multiInstanceAvailable) {

+			assertEquals(false, shapeProp.getIsMultiInstance().getSelection());

+			shapeProp.getIsMultiInstance().setSelection(true);

+			shapeProp.getIsMultiInstance().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof MultipleNode);

+			MultipleNode multiNodeAlgo = (MultipleNode) nodeAlgorithm;

+			assertTrue(multiNodeAlgo

+					.isMultipleInstances((ContainerShape) shape));

+			select(shape);

+			shapeProp = (ShapePropertySection) page.getCurrentTab()

+					.getSections()[0];

+			shapeProp.getIsMultiInstance().setSelection(false);

+			shapeProp.getIsMultiInstance().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof MultipleNode);

+			multiNodeAlgo = (MultipleNode) nodeAlgorithm;

+			assertFalse(multiNodeAlgo

+					.isMultipleInstances((ContainerShape) shape));

+			select(shape);

+			shapeProp = (ShapePropertySection) page.getCurrentTab()

+					.getSections()[0];

+		}

+		// Shape Style

+		shape = createShape(shapeType, 100, 100, 5, 5);

+		select(shape);

+		shapeProp = (ShapePropertySection) page.getCurrentTab().getSections()[0];

+		boolean shapeStyleAvailable = CREATE_FEATURE_AGENT == shapeType

+				|| CREATE_FEATURE_STORAGE == shapeType

+				|| CREATE_FEATURE_AGENT_L == shapeType

+				|| CREATE_FEATURE_AGENT_U == shapeType

+				|| CREATE_FEATURE_STORAGE_L == shapeType

+				|| CREATE_FEATURE_STORAGE_U == shapeType;

+		assertEquals(shapeStyleAvailable, shapeProp.getShapeStyle().isEnabled());

+		if (shapeStyleAvailable) {

+			select(shape);

+			shapeProp = (ShapePropertySection) page.getCurrentTab()

+					.getSections()[0];

+			shapeProp.getShapeStyle().select(0);

+			shapeProp.getShapeStyle().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof RectangleAlgorithm);

+			select(shape);

+			shapeProp = (ShapePropertySection) page.getCurrentTab()

+					.getSections()[0];

+			shapeProp.getShapeStyle().select(1);

+			shapeProp.getShapeStyle().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof LPolygonAlgorithm);

+			select(shape);

+			shapeProp = (ShapePropertySection) page.getCurrentTab()

+					.getSections()[0];

+			shapeProp.getShapeStyle().select(2);

+			shapeProp.getShapeStyle().notifyListeners(SWT.Selection,

+					new Event());

+			nodeAlgorithm = factory.getShape(shape);

+			assertTrue(nodeAlgorithm instanceof UPolygonAlgorithm);

+		}

+

+	}

+

+	private void checkTabsForShape(TabbedPropertySheetPage page) {

+		ITabDescriptor[] activeTabs = page.getActiveTabs();

+		assertEquals(TAB_SHAPE, activeTabs[0].getId());

+		assertEquals(TAB_STYLE, activeTabs[1].getId());

+		assertEquals(TAB_ALIGNMENT, activeTabs[2].getId());

+		assertEquals(TAB_PREDEFINED_STYLE, activeTabs[3].getId());

+	}

+

+	private void assertAnchorsVisible(boolean visible) {

+		for (Shape shape : getDiagram().getChildren()) {

+			for (Anchor anchor : shape.getAnchors()) {

+				if (anchor instanceof BoxRelativeAnchor) {

+					assertEquals(visible, anchor.getGraphicsAlgorithm()

+							.getLineVisible());

+				}

+			}

+		}

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/editor/node/FMCNodeAlgorithmFactoryTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/editor/node/FMCNodeAlgorithmFactoryTest.java
new file mode 100644
index 0000000..79cdc0a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/editor/node/FMCNodeAlgorithmFactoryTest.java
@@ -0,0 +1,97 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.editor.node;

+

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_AGENT_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_HUMAN_AGENT;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_L;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STORAGE_U;

+import static org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramFeatureProvider.CREATE_FEATURE_STRUCTURE_VARIANCE;

+import static org.junit.Assert.assertTrue;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.fmc.FMCTestCase;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.HumanAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.LAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.LStorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.RectangleAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.RectangleStorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.UAgentAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.UStorageAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.ui.PartInitException;

+import org.junit.Test;

+

+public class FMCNodeAlgorithmFactoryTest extends FMCTestCase {

+

+	private FMCNodeAlgorithmFactory factory;

+

+	@Override

+	public void setUp() throws PartInitException, CoreException {

+		super.setUp();

+		factory = FMCNodeAlgorithmFactory.getInstance();

+	}

+

+	@Test

+	public void testGetAgentByShapeStyle() {

+		assertTrue(factory.getAgentByShapestyle(ShapeStyle.RECT) instanceof RectangleAgentAlgorithm);

+		assertTrue(factory.getAgentByShapestyle(ShapeStyle.L) instanceof LAgentAlgorithm);

+		assertTrue(factory.getAgentByShapestyle(ShapeStyle.U) instanceof UAgentAlgorithm);

+	}

+

+	@Test

+	public void testGetStorageByShapeStyle() {

+		assertTrue(factory.getStorageByShapestyle(ShapeStyle.RECT) instanceof RectangleStorageAlgorithm);

+		assertTrue(factory.getStorageByShapestyle(ShapeStyle.L) instanceof LStorageAlgorithm);

+		assertTrue(factory.getStorageByShapestyle(ShapeStyle.U) instanceof UStorageAlgorithm);

+	}

+

+	@Test

+	public void testGetShape() {

+		Shape shape = createShape(CREATE_FEATURE_AGENT, 100, 100, 5, 5);

+		FMCNodeAlgorithm algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof RectangleAgentAlgorithm);

+		shape = createShape(CREATE_FEATURE_HUMAN_AGENT, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof HumanAgentAlgorithm);

+		shape = createShape(CREATE_FEATURE_AGENT_L, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof LAgentAlgorithm);

+		shape = createShape(CREATE_FEATURE_AGENT_U, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof UAgentAlgorithm);

+		shape = createShape(CREATE_FEATURE_STORAGE, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof RectangleStorageAlgorithm);

+		shape = createShape(CREATE_FEATURE_STORAGE_L, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof LStorageAlgorithm);

+		shape = createShape(CREATE_FEATURE_STORAGE_U, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		assertTrue(algorithm instanceof UStorageAlgorithm);

+		shape = createShape(CREATE_FEATURE_STRUCTURE_VARIANCE, 100, 100, 5, 5);

+		algorithm = factory.getShape(shape);

+		// TODO Why?

+		// assertNull(algorithm);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaConnectionTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaConnectionTest.java
new file mode 100644
index 0000000..f420944
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaConnectionTest.java
@@ -0,0 +1,236 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.meta;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.fmc.ConnectionTest;

+import org.eclipse.fmc.blockdiagram.editor.util.DiagramFactory;

+import org.junit.After;

+import org.junit.Test;

+

+public class MetaConnectionTest extends ConnectionTest {

+

+	@Override

+	protected void createFMCFile(IFile file) {

+		DiagramFactory.createDefaultBlockdiagramMetaFile(URI.createPlatformResourceURI(

+				file.getFullPath().toString(), true), 1000, 1000, 10);

+	}

+

+	@Test

+	@Override

+	public void testUnidirectionalAccessMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testUnidirectionalAccessMH();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testUnidirectionalAccessFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testUnidirectionalAccessFF();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testBidirectionalAccessMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testBidirectionalAccessMH();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testBidirectionalAccessFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testBidirectionalAccessFF();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testModifyAccess() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testModifyAccess();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testBidirectionalComChannelMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super

+								.testBidirectionalComChannelMH();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testBidirectionalComChannelFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super

+								.testBidirectionalComChannelFF();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testUnidirectionalComChannelMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super

+								.testUnidirectionalComChannelMH();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testUnidirectionalComChannelFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super

+								.testUnidirectionalComChannelFF();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testReqResComChannelMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testReqResComChannelMH();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testReqResComChannelFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testReqResComChannelFF();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testDotsMH() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testDotsMH();

+					}

+				});

+	}

+

+	@Override

+	public void testDotsMHWithoutTarget() {

+		// Not supported

+	}

+

+	@Test

+	@Override

+	public void testDotsFF() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testDotsFF();

+					}

+				});

+	}

+

+	@Override

+	public void testDotsFFWithoutTarget() {

+		// Not supported

+	}

+

+	@Test

+	@Override

+	public void testContainerRemove() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super.testContainerRemove();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testConnectToStructureVariance() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaConnectionTest.super

+								.testConnectToStructureVariance();

+					}

+				});

+	}

+

+	@Override

+	@After

+	public void tearDown() {

+		MetaTestUtil.assertMetaFileExists(getProject(), BLOCKDIAG_FILENAME);

+		super.tearDown();

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaShapeTest.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaShapeTest.java
new file mode 100644
index 0000000..c4d7caa
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaShapeTest.java
@@ -0,0 +1,191 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.meta;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.transaction.RecordingCommand;

+import org.eclipse.fmc.ShapeTest;

+import org.eclipse.fmc.blockdiagram.editor.util.DiagramFactory;

+import org.junit.After;

+import org.junit.Test;

+

+/**

+ * Testing all shape types for meta editor

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class MetaShapeTest extends ShapeTest {

+

+	@Override

+	protected void createFMCFile(IFile file) {

+		DiagramFactory.createDefaultBlockdiagramMetaFile(URI.createPlatformResourceURI(

+				file.getFullPath().toString(), true), 1000, 1000, 10);

+	}

+

+	@Test

+	@Override

+	public void testAgent() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testAgent();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testAgentL() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testAgentL();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testAgentU() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testAgentU();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testStorage() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testStorage();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testStorageL() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testStorageL();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testStorageU() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testStorageU();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testHumanAgent() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testHumanAgent();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testStructureVariance() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testStructureVariance();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testCommonFeatureArea() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testCommonFeatureArea();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testBrace() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testBrace();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testAreaBorder() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testAreaBorder();

+					}

+				});

+	}

+

+	@Test

+	@Override

+	public void testDots() {

+		getEditingDomain().getCommandStack().execute(

+				new RecordingCommand(getEditingDomain()) {

+					@Override

+					protected void doExecute() {

+						MetaShapeTest.super.testDots();

+					}

+				});

+	}

+

+	@Override

+	@After

+	public void tearDown() {

+		MetaTestUtil.assertMetaFileExists(getProject(), BLOCKDIAG_FILENAME);

+		super.tearDown();

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaTestUtil.java b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaTestUtil.java
new file mode 100644
index 0000000..bcae636
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor.tests/src/org/eclipse/fmc/meta/MetaTestUtil.java
@@ -0,0 +1,37 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.meta;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.core.runtime.AssertionFailedException;

+import org.eclipse.core.runtime.Path;

+

+public class MetaTestUtil {

+

+	private MetaTestUtil() {

+	}

+

+	public static void assertMetaFileExists(IProject project, String blockfile) {

+		final IFile file = project.getFile(new Path(blockfile.replace(

+				".blockdiag", "fmc")));

+		if (!file.exists())

+			throw new AssertionFailedException(

+					"Meta file does not exist! Expected location: "

+							+ file.getLocationURI());

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/.DS_Store b/org.eclipse.fmc.blockdiagram.editor/.DS_Store
new file mode 100644
index 0000000..4f50dec
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/.DS_Store
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/.classpath b/org.eclipse.fmc.blockdiagram.editor/.classpath
new file mode 100644
index 0000000..a14ade4
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/.classpath
@@ -0,0 +1,8 @@
+<?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="src" path="resources"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.fmc.blockdiagram.editor/.gitignore b/org.eclipse.fmc.blockdiagram.editor/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/org.eclipse.fmc.blockdiagram.editor/.project b/org.eclipse.fmc.blockdiagram.editor/.project
new file mode 100644
index 0000000..ecf514e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.fmc.blockdiagram.editor</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.fmc.blockdiagram.editor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.fmc.blockdiagram.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/.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/org.eclipse.fmc.blockdiagram.editor/META-INF/MANIFEST.MF b/org.eclipse.fmc.blockdiagram.editor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..fa159bf
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: FMC Blockdiagram Editor
+Bundle-SymbolicName: org.eclipse.fmc.blockdiagram.editor;singleton:=true
+Bundle-Version: 0.11.0.qualifier
+Bundle-Activator: org.eclipse.fmc.blockdiagram.editor.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: 
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.gef,
+ org.eclipse.graphiti,
+ org.eclipse.graphiti.ui,
+ org.eclipse.emf.ecore.edit,
+ org.eclipse.emf.transaction,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.jface,
+ org.eclipse.fmc.mm
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.fmc.blockdiagram.editor,
+ org.eclipse.fmc.blockdiagram.editor.algorithm.connection,
+ org.eclipse.fmc.blockdiagram.editor.algorithm.node,
+ org.eclipse.fmc.blockdiagram.editor.diagram,
+ org.eclipse.fmc.blockdiagram.editor.features,
+ org.eclipse.fmc.blockdiagram.editor.features.add,
+ org.eclipse.fmc.blockdiagram.editor.features.create,
+ org.eclipse.fmc.blockdiagram.editor.filters,
+ org.eclipse.fmc.blockdiagram.editor.model,
+ org.eclipse.fmc.blockdiagram.editor.property,
+ org.eclipse.fmc.blockdiagram.editor.util,
+ org.eclipse.fmc.blockdiagram.editor.wizards
diff --git a/org.eclipse.fmc.blockdiagram.editor/about.html b/org.eclipse.fmc.blockdiagram.editor/about.html
new file mode 100644
index 0000000..333235b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>July 26, 2013</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor/build.properties b/org.eclipse.fmc.blockdiagram.editor/build.properties
new file mode 100644
index 0000000..ba01172
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/build.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# <copyright>
+#
+# Copyright (c) 2013, 2013 SAP AG.
+# 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:
+#    SAP AG - initial API, implementation and documentation
+#
+# </copyright>
+#
+###############################################################################
+source.. = src/,\
+           resources/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               about.html
+src.includes = about.html
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/.DS_Store b/org.eclipse.fmc.blockdiagram.editor/icons/.DS_Store
new file mode 100644
index 0000000..445ee30
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/.DS_Store
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/.DS_Store b/org.eclipse.fmc.blockdiagram.editor/icons/menu/.DS_Store
new file mode 100644
index 0000000..5098492
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/.DS_Store
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/accessories-text-editor.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/accessories-text-editor.png
new file mode 100644
index 0000000..188e1c1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/accessories-text-editor.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/applications-graphics.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/applications-graphics.png
new file mode 100644
index 0000000..4bb955f
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/applications-graphics.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-copy.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-copy.png
new file mode 100644
index 0000000..8dd48c4
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-copy.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-paste.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-paste.png
new file mode 100644
index 0000000..24588a3
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-paste.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-redo.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-redo.png
new file mode 100644
index 0000000..c3b0df0
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-redo.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-undo.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-undo.png
new file mode 100644
index 0000000..8b0fef9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/edit-undo.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-down.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-down.png
new file mode 100644
index 0000000..3dd7fcc
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-down.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-jump.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-jump.png
new file mode 100644
index 0000000..1d218c3
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-jump.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-up.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-up.png
new file mode 100644
index 0000000..fa9a7d7
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/go-up.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/image-x-generic.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/image-x-generic.png
new file mode 100644
index 0000000..68da502
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/image-x-generic.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/weather-clear.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/weather-clear.png
new file mode 100644
index 0000000..7dc15ea
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/weather-clear.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/menu/x-office-presentation.png b/org.eclipse.fmc.blockdiagram.editor/icons/menu/x-office-presentation.png
new file mode 100644
index 0000000..f7ea302
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/menu/x-office-presentation.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent.png
new file mode 100644
index 0000000..b3e347d
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_16.png
new file mode 100644
index 0000000..ed255ad
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_l.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_l.png
new file mode 100644
index 0000000..230c911
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_l.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_u.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_u.png
new file mode 100644
index 0000000..044571d
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/agent_u.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/anchor.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/anchor.png
new file mode 100644
index 0000000..c9701da
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/anchor.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/areaborder.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/areaborder.png
new file mode 100644
index 0000000..a0e4326
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/areaborder.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess.png
new file mode 100644
index 0000000..2dc6754
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess_mh.png
new file mode 100644
index 0000000..cb5f013
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biAccess_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel.png
new file mode 100644
index 0000000..92a7fa0
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel_mh.png
new file mode 100644
index 0000000..02dca28
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/biCommChannel_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/brace.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/brace.png
new file mode 100644
index 0000000..2062982
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/brace.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/channel.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/channel.png
new file mode 100644
index 0000000..8173ee4
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/channel.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/commonFeatureArea.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/commonFeatureArea.png
new file mode 100644
index 0000000..53bd05b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/commonFeatureArea.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots.png
new file mode 100644
index 0000000..3161611
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots_mh.png
new file mode 100644
index 0000000..b80afcf
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/dots_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/humanAgent.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/humanAgent.png
new file mode 100644
index 0000000..b240832
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/humanAgent.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess.png
new file mode 100644
index 0000000..3a32c3d
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess_16.png
new file mode 100644
index 0000000..4587208
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/modifyAccess_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel.png
new file mode 100644
index 0000000..b4f3940
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_16.png
new file mode 100644
index 0000000..a7b03f1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_mh.png
new file mode 100644
index 0000000..8999c74
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/reqRespCommChannel_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage.png
new file mode 100644
index 0000000..f6027a1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_16.png
new file mode 100644
index 0000000..4a47bf1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_l.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_l.png
new file mode 100644
index 0000000..950dc07
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_l.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_u.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_u.png
new file mode 100644
index 0000000..08a1725
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/storage_u.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/structureVariance.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/structureVariance.png
new file mode 100644
index 0000000..5360739
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/structureVariance.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/text.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/text.png
new file mode 100644
index 0000000..22f772b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/text.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess.png
new file mode 100644
index 0000000..62a618a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_16.png
new file mode 100644
index 0000000..4b3ff2b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_mh.png
new file mode 100644
index 0000000..635cd3f
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirAccess_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel.png
new file mode 100644
index 0000000..cd8d36b
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_16.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_16.png
new file mode 100644
index 0000000..d43253a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_16.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_mh.png b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_mh.png
new file mode 100644
index 0000000..665b217
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/icons/palette/unidirCommChannel_mh.png
Binary files differ
diff --git a/org.eclipse.fmc.blockdiagram.editor/plugin.xml b/org.eclipse.fmc.blockdiagram.editor/plugin.xml
new file mode 100644
index 0000000..d5c607e
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/plugin.xml
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--

+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+ -->

+<?eclipse version="3.4"?>

+<plugin>

+   <extension-point id="org.eclipse.fmc.blockdiagram.editor.palette" name="Palette Extension Point" schema="schema/org.eclipse.fmc.blockdiagram.editor.palette.exsd"/>

+   <extension-point id="org.eclipse.fmc.blockdiagram.editor.featureprovider" name="Feature Provider Extension" schema="schema/org.eclipse.fmc.blockdiagram.editor.featureprovider.exsd"/>

+   <extension-point id="org.eclipse.fmc.blockdiagram.editor.typechecking" name="Type Checker Extension" schema="schema/org.eclipse.fmc.blockdiagram.editor.typechecking.exsd"/>

+	<extension

+         point="org.eclipse.graphiti.ui.diagramTypes">

+      <diagramType

+            id="org.eclipse.fmc.blockdiagram.diagramtype"

+            name="FMC"

+            type="fmc">

+      </diagramType>

+      <diagramType

+            id="org.eclipse.fmc.blockdiagram.diagramtype.tam"

+            name="TAM"

+            type="tam">

+      </diagramType>

+   </extension>

+	<extension

+         point="org.eclipse.ui.editors">

+      <editor

+            class="org.eclipse.fmc.blockdiagram.editor.BlockDiagramEditor"

+            default="true"

+            contributorClass="org.eclipse.graphiti.ui.editor.DiagramEditorActionBarContributor"

+            extensions="blockdiag"

+            icon="icons/blockdiagramfiletype.png"

+            id="org.eclipse.fmc.blockdiagram.FMCBlockdiagramEditor"

+            name="FMC Blockdiagram Editor">

+      </editor>

+   </extension>

+   <extension

+         point="org.eclipse.graphiti.ui.diagramTypeProviders">

+      <diagramTypeProvider

+            class="org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramTypeProvider"

+            id="org.eclipse.fmc.blockdiagram.provider"

+            name="org.eclipse.fmc.blockdiagram.typeprovider">

+         <diagramType

+               id="org.eclipse.fmc.blockdiagram.diagramtype">

+         </diagramType>

+         <imageProvider

+               id="org.eclipse.fmc.blockdiagram.imageProvider">

+         </imageProvider>

+      </diagramTypeProvider>

+      <diagramTypeProvider

+            class="org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramTypeProvider"

+            id="org.eclipse.fmc.blockdiagram.provider"

+            name="org.eclipse.fmc.blockdiagram.typeprovider.tam">

+         <diagramType

+               id="org.eclipse.fmc.blockdiagram.diagramtype.tam">

+         </diagramType>

+         <imageProvider

+               id="org.eclipse.fmc.blockdiagram.imageProvider">

+         </imageProvider>

+      </diagramTypeProvider>

+   </extension>

+   <extension

+         point="org.eclipse.ui.newWizards">

+      <wizard

+            category="org.eclipse.fmc.blockdiagram.category"

+            class="org.eclipse.fmc.blockdiagram.editor.wizards.BlockDiagramFileWizard"

+            icon="icons/blockdiagramfiletype.png"

+            id="org.eclipse.fmc.blockdiagram.wizard.editor"

+            name="FMC Block Diagram">

+         <description>

+            This wizard creates a FMC block diagram.

+         </description>

+      </wizard>

+      <category

+            id="org.eclipse.fmc.blockdiagram.category"

+            name="FMC">

+      </category>

+   </extension>

+   <!-- Add wizard to common navigator context menu -->

+   <extension point="org.eclipse.ui.navigator.navigatorContent">

+      <commonWizard

+            type="new"

+            wizardId="org.eclipse.fmc.blockdiagram.wizard.editor">

+         <enablement>

+         </enablement>

+      </commonWizard>

+      <commonWizard

+            type="new" 

+            wizardId="org.eclipse.ui.wizards.new.project">

+         <enablement>

+         </enablement>

+      </commonWizard>

+   </extension>

+   <extension

+         point="org.eclipse.graphiti.ui.imageProviders">

+      <imageProvider

+            class="org.eclipse.fmc.blockdiagram.editor.diagram.BlockDiagramImageProvider"

+            id="org.eclipse.fmc.blockdiagram.imageProvider">

+      </imageProvider>

+   </extension>

+   <extension

+         point="org.eclipse.ui.perspectives">

+      <perspective

+            class="org.eclipse.fmc.blockdiagram.editor.application.Perspective"

+            id="FMC.perspective"

+            name="FMC Perspective">

+      </perspective>

+   </extension>

+   <extension point="org.eclipse.ui.elementFactories">

+  	<factory class="org.eclipse.fmc.blockdiagram.editor.application.NavigatorRoot" id="org.eclipse.fmc.blockdiagram.application.NavigatorRoot" /> 

+  </extension>

+  <extension point="org.eclipse.ui.navigator.viewer">

+  	<viewer viewerId="org.eclipse.fmc.blockdiagram.application.NavigatorRoot" /> 

+    <viewerContentBinding viewerId="org.eclipse.fmc.blockdiagram.application.NavigatorRoot">

+	 	<includes>

+	  		<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" /> 

+	  	</includes>

+  	</viewerContentBinding>

+ 	<viewerActionBinding viewerId="org.eclipse.fmc.blockdiagram.application.NavigatorRoot">

+	  	<includes>

+	  		<actionExtension pattern="org.eclipse.ui.navigator.resources.*" /> 

+	  		<actionExtension pattern="org.eclipse.ui.navigator.resources.NewActions" /> 

+	  		<actionExtension pattern="org.eclipse.ui.navigator.resources.PropertiesActionProvider" /> 

+	  	</includes>

+	  </viewerActionBinding>

+  </extension>

+  <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertySections">

+      <propertySections

+            contributorId="fmc.PropertyContributor">

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.ShapePropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeFilter"

+               id="fmc.shapeSection"

+               tab="fmc.ShapeTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.ConnectionPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.FMCConnectionFilter"

+               id="fmc.connectionSection"

+               tab="fmc.ConnectionTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.DiagramPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.DiagramFilter"

+               id="fmc.diagramSection"

+               tab="fmc.DiagramTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.FMCColorsAndFontsPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeFilter"

+               id="fmc.styleSection"

+               tab="fmc.StyleTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.AlignmentPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.ShapeFilter"

+               id="fmc.alignmentSection"

+               tab="fmc.AlignmentTab">

+         </propertySection>

+         <propertySection

+               class="org.eclipse.fmc.blockdiagram.editor.property.PredefinedStylesPropertySection"

+               filter="org.eclipse.fmc.blockdiagram.editor.filters.PictogramFilter"

+               id="fmc.predefinedStyleSection"

+               tab="fmc.PredefinedStyleTab">

+         </propertySection>

+      </propertySections>

+   </extension>

+   <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertyContributor">

+      <propertyContributor

+            contributorId="fmc.PropertyContributor">

+         <propertyCategory

+               category="fmc.diagram">

+         </propertyCategory>

+      </propertyContributor>

+   </extension>

+   <extension

+         point="org.eclipse.ui.views.properties.tabbed.propertyTabs">

+      <propertyTabs

+            contributorId="fmc.PropertyContributor">

+         <propertyTab

+               category="fmc.diagram"

+               id="fmc.ShapeTab"

+               label="Shape">

+         </propertyTab>

+         <propertyTab

+               category="fmc.diagram"

+               id="fmc.ConnectionTab"

+               label="Connection">

+         </propertyTab>

+         <propertyTab

+               category="fmc.diagram"

+               id="fmc.DiagramTab"

+               label="Diagram">

+         </propertyTab>

+         <propertyTab

+         	   afterTab="fmc.ShapeTab"	

+               category="fmc.diagram"

+               id="fmc.StyleTab"

+               label="Style">

+         </propertyTab>

+         <propertyTab

+               afterTab="fmc.StyleTab"

+               category="fmc.diagram"

+               id="fmc.AlignmentTab"

+               indented="true"

+               label="Text Alignment">

+         </propertyTab>

+         <propertyTab

+               afterTab="fmc.AlignmentTab"

+               category="fmc.diagram"

+               id="fmc.PredefinedStyleTab"

+               indented="false"

+               label="Predefined Styles">

+         </propertyTab>

+      </propertyTabs>

+   </extension>

+</plugin>

diff --git a/org.eclipse.fmc.blockdiagram.editor/resources/org/eclipse/fmc/blockdiagram/editor/messages.properties b/org.eclipse.fmc.blockdiagram.editor/resources/org/eclipse/fmc/blockdiagram/editor/messages.properties
new file mode 100644
index 0000000..8aab4ca
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/resources/org/eclipse/fmc/blockdiagram/editor/messages.properties
@@ -0,0 +1,17 @@
+###############################################################################

+# <copyright>

+#

+# Copyright (c) 2013, 2013 SAP AG.

+# 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:

+#    SAP AG - initial API, implementation and documentation

+#

+# </copyright>

+#

+###############################################################################

+FMCAddFeature_DefaultShapeTitle=title

+FMCAddFeature_FontType=Arial

diff --git a/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.featureprovider.exsd b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.featureprovider.exsd
new file mode 100644
index 0000000..c525e8a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.featureprovider.exsd
@@ -0,0 +1,132 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2013, 2013 SAP AG.
+ * 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:
+ *    SAP AG - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+ -->
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.fmc.blockdiagram.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.fmc.blockdiagram.editor" id="org.eclipse.fmc.blockdiagram.editor.featureprovider" name="Feature Provider Extension"/>
+      </appinfo>
+      <documentation>
+         This extension point is for providing additional features for the FMC Editors. The Factory interface has to be implemented. This interface is then called by the FMC Blockdiagram Editor in order to instantiate a new feature provider and add the features to the already existing ones.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+         <documentation>
+            This extension is for adding new features to the editor. All kinds of features are supported. A featureProviderFactory must be defined which must implement org.eclipse.fmc.blockdiagram.editor.extension.FeatureProviderExtensionFactory. .
+         </documentation>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="featureProviderFactory"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="featureProviderFactory">
+      <annotation>
+         <documentation>
+            This factory produces new istances of  org.eclipse.fmc.blockdiagram.editor.extension.ExtensionFeatureProvider which is an implementation of AbstractFeatureProvider. All features provided through this extension feature provider will be added to the features of the original editor.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  All features provided through this extension feature provider will be added to the features of the original editor.
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.extension.FeatureProviderExtensionFactory"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         0.3.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         &lt;extension
+    point=&quot;org.eclipse.fmc.blockdiagram.editor.featureprovider&quot;&gt;
+   &lt;featureProviderFactory
+       class=&quot;org.eclipse.fmc.blockdiagram.editor.extension.FeaturesProviderExtensionFactory&quot;&gt;
+   &lt;/featureProviderFactory&gt;
+&lt;/extension&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.palette.exsd b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.palette.exsd
new file mode 100644
index 0000000..e5c7d6c
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.palette.exsd
@@ -0,0 +1,133 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2013, 2013 SAP AG.
+ * 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:
+ *    SAP AG - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+ -->
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.fmc.blockdiagram.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.fmc.blockdiagram.editor" id="org.eclipse.fmc.blockdiagram.editor.palette" name="Palette Extension Point"/>
+      </appinfo>
+      <documentation>
+         This extension point allows to add new tool entries to the palette.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="paletteElement"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="paletteElement">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.gef.palette.PaletteEntry:"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="label" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="shortDescription" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         0.3.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.typechecking.exsd b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.typechecking.exsd
new file mode 100644
index 0000000..179944a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/schema/org.eclipse.fmc.blockdiagram.editor.typechecking.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2013, 2013 SAP AG.
+ * 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:
+ *    SAP AG - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+ -->
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.fmc.blockdiagram.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.fmc.blockdiagram.editor" id="org.eclipse.fmc.blockdiagram.typechecking" name="Type Checker Extension"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="typeChecker"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="typeChecker">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         0.4.1
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/Activator.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/Activator.java
new file mode 100644
index 0000000..f15e988
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/Activator.java
@@ -0,0 +1,74 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor;

+

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * 

+ * The activator class controls the plug-in life cycle.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class Activator extends AbstractUIPlugin {

+

+	/** The plug-in ID. */

+	public static final String PLUGIN_ID = "org.eclipse.fmc.blockdiagram.editor"; //$NON-NLS-1$

+

+	/** The shared instance. */

+	private static Activator plugin;

+

+	/**

+	 * The constructor.

+	 */

+	public Activator() {

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext

+	 * )

+	 */

+	@Override

+	public final void start(final BundleContext context) throws Exception {

+		super.start(context);

+		plugin = this;

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)

+	 */

+	@Override

+	public final void stop(final BundleContext context) throws Exception {

+		plugin = null;

+		super.stop(context);

+	}

+

+	/**

+	 * Returns the shared instance.

+	 * 

+	 * @return the shared instance

+	 */

+	public static Activator getDefault() {

+		return plugin;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramBehavior.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramBehavior.java
new file mode 100644
index 0000000..6132971
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramBehavior.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2013, 2013 SAP AG.
+ * 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:
+ *    SAP AG - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.fmc.blockdiagram.editor;
+
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior;
+import org.eclipse.graphiti.ui.editor.DiagramBehavior;
+import org.eclipse.graphiti.ui.editor.IDiagramContainerUI;
+import org.eclipse.graphiti.ui.internal.action.RemoveAction;
+
+/**
+ * Change delete key behavior from DeleteAction to RemoveAction and enables
+ * direct editing with return key.
+ * 
+ * @author Benjamin Schmeling
+ * 
+ */
+@SuppressWarnings("restriction")
+public class BlockDiagramBehavior extends DiagramBehavior{
+
+	public BlockDiagramBehavior(IDiagramContainerUI diagramContainer) {
+		super(diagramContainer);
+	}
+	
+	@Override
+	protected DefaultPaletteBehavior createPaletteBehaviour() {
+		return new BlockDiagramPaletteBehavior(this);
+	}
+	
+	@Override
+	public KeyHandler getCommonKeyHandler() {
+		KeyHandler handler = super.getCommonKeyHandler();
+		if (getDiagramTypeProvider().getFeatureProvider()
+				.getDeleteFeature(null) == null) {
+			handler.remove(KeyStroke.getPressed((char) 127, 127, 0));
+			handler.put(KeyStroke.getPressed((char) 127, 127, 0),
+					getDiagramContainer().getActionRegistry().getAction(RemoveAction.ACTION_ID));
+		}
+		handler.put(KeyStroke.getPressed((char) 13, 13, 0), getDiagramContainer().getActionRegistry()
+				.getAction(GEFActionConstants.DIRECT_EDIT));
+		return handler;
+	}
+
+}
diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramConstants.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramConstants.java
new file mode 100644
index 0000000..7f93fba
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramConstants.java
@@ -0,0 +1,35 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor;

+

+/**

+ * Provides all public constants for the Blockdiagram Editor.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public interface BlockDiagramConstants {

+

+	/**

+	 * The key for the context property points.

+	 */

+	public static final String POINTS = "points";

+	

+	/**

+	 * Key for storing the information about the style of a shape in a context property.

+	 */

+	public static final String GRAPHICAL_TYPE_KEY = "graphicalType";

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramEditor.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramEditor.java
new file mode 100644
index 0000000..d554f29
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramEditor.java
@@ -0,0 +1,72 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor;

+

+import java.net.MalformedURLException;

+

+import org.eclipse.core.runtime.Status;

+import org.eclipse.fmc.blockdiagram.editor.clipboard.PasteFromClipboard;

+import org.eclipse.gef.MouseWheelHandler;

+import org.eclipse.gef.MouseWheelZoomHandler;

+import org.eclipse.graphiti.ui.editor.DiagramBehavior;

+import org.eclipse.graphiti.ui.editor.DiagramEditor;

+

+import org.eclipse.swt.SWT;

+import org.eclipse.ui.statushandlers.StatusManager;

+

+/**

+ * The diagram editor represents the editor to Eclipse and is a Graphiti editor.

+ * It defines a custom palette behavior to add new tool entries. Registers all

+ * clipboard images to the image provider. Mouse wheel is enabled for zooming.

+ * Registers additional key handlers for deletion and direct editing.

+ * 

+ * 

+ * @author Benjamin Schmeling

+ * @author Rainer Thome

+ */

+public class BlockDiagramEditor extends DiagramEditor {

+

+	/**

+	 * Default Constructor.

+	 */

+	public BlockDiagramEditor() {

+	}

+

+	@Override

+	public void initializeGraphicalViewer() {

+		try {

+			PasteFromClipboard.registerClipImages(this);

+		} catch (MalformedURLException e) {

+			StatusManager

+					.getManager()

+					.handle(new Status(

+							Status.ERROR,

+							Activator.PLUGIN_ID,

+							"Cannot register clip images to the image provider",

+							e));

+		}

+		super.initializeGraphicalViewer();

+		getGraphicalViewer().setProperty(

+				MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),

+				MouseWheelZoomHandler.SINGLETON);

+	}

+

+	@Override

+	protected DiagramBehavior createDiagramBehavior() {

+		return new BlockDiagramBehavior(this);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramMessages.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramMessages.java
new file mode 100644
index 0000000..c5087b5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramMessages.java
@@ -0,0 +1,22 @@
+package org.eclipse.fmc.blockdiagram.editor;

+

+import org.eclipse.osgi.util.NLS;

+

+/**

+ * Internationalized messages used in blockdiagram editor.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class BlockDiagramMessages extends NLS {

+	private static final String BUNDLE_NAME = "org.eclipse.fmc.blockdiagram.editor.messages"; //$NON-NLS-1$

+	public static String FMCAddFeature_DefaultShapeTitle;

+	public static String FMCAddFeature_FontType;

+	static {

+		// initialize resource bundle

+		NLS.initializeMessages(BUNDLE_NAME, BlockDiagramMessages.class);

+	}

+

+	private BlockDiagramMessages() {

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramPaletteBehavior.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramPaletteBehavior.java
new file mode 100644
index 0000000..6f93d46
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/BlockDiagramPaletteBehavior.java
@@ -0,0 +1,87 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.IExtensionRegistry;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.gef.palette.PaletteContainer;

+import org.eclipse.gef.palette.PaletteDrawer;

+import org.eclipse.gef.palette.PaletteEntry;

+import org.eclipse.gef.palette.PaletteRoot;

+import org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior;

+import org.eclipse.graphiti.ui.editor.DiagramBehavior;

+

+/**

+ * This custom palette behavior allows the addition of new palette tool entries

+ * via the dedicated extension point.

+ * 

+ * 

+ * @author Benjamin Schmeling

+ */

+public class BlockDiagramPaletteBehavior extends DefaultPaletteBehavior {

+

+	public BlockDiagramPaletteBehavior(DiagramBehavior diagramBehavior) {

+		super(diagramBehavior);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior#createPaletteRoot()

+	 */

+	protected PaletteRoot createPaletteRoot() {

+		PaletteRoot root = super.createPaletteRoot();

+		// Creates new palette container for extensions

+		PaletteContainer container = new PaletteDrawer("Extensions");

+		try {

+			addFromExtensionPoint(container);

+		} catch (CoreException e) {

+			e.printStackTrace();

+		}

+		if (!container.getChildren().isEmpty())

+			root.add(container);

+

+		return root;

+	}

+

+	/**

+	 * Adds new entries if registered via org.eclipse.fmc.blockdiagram.editor.palette

+	 * extension.

+	 * 

+	 * @param container

+	 *            The palette container.

+	 * @throws CoreException

+	 */

+	private void addFromExtensionPoint(PaletteContainer container)

+			throws CoreException {

+		IExtensionRegistry reg = Platform.getExtensionRegistry();

+		IConfigurationElement[] extensions = reg

+				.getConfigurationElementsFor("org.eclipse.fmc.blockdiagram.editor.palette");

+		for (IConfigurationElement element : extensions) {

+			PaletteEntry entry = (PaletteEntry) element

+					.createExecutableExtension("class");

+			entry.setLabel(element.getAttribute("label"));

+			entry.setDescription(element.getAttribute("shortDescription"));

+			container.add(entry);

+

+		}

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/BraceAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/BraceAlgorithm.java
new file mode 100644
index 0000000..ed0ccc8
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/BraceAlgorithm.java
@@ -0,0 +1,379 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.comment;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.ResizableNode;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.RotatableNode;

+import org.eclipse.fmc.blockdiagram.editor.util.StyleUtil;

+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.Polyline;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.graphiti.services.IGaService;

+

+/**

+ * This abstract class implements all methods common to braces.

+ * 

+ * 1__ 2 \ | 3 \ > 4 5 / | __/ 7 6

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public class BraceAlgorithm implements CommentAlgorithm, RotatableNode,

+		ResizableNode {

+

+	protected IGaService ga = Graphiti.getGaService();

+

+	// ----------------------------------------

+	// ----------- Graphics Node --------------

+

+	public static final int BRACE_MINIMUM_HEIGHT = 60;

+	public static final int BRACE_DEFAULT_HEIGHT = 80;

+	public static final int BRACE_DEFAULT_LINEWIDTH = 2;

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#createGraphics(org.eclipse

+	 * .graphiti.mm.pictograms.Diagram,

+	 * org.eclipse.graphiti.mm.GraphicsAlgorithmContainer, int, int, int, int)

+	 */

+	public GraphicsAlgorithm createGraphics(Diagram diagram,

+			GraphicsAlgorithmContainer container, int x, int y, int width,

+			int height) {

+		GraphicsAlgorithm containerGa = (GraphicsAlgorithm) container;

+

+		int lineXy[];

+		int size;

+		if (width > height) {

+			size = width;

+			lineXy = new int[] {

+			/* 1 */0, 0,

+			/* 2 */0, size / 8,

+			/* 3 */size / 2, size / 8,

+			/* 4 */size / 2, 9 * size / 40,

+			/* 5 */size / 2, size / 8,

+			/* 6 */size, size / 8,

+			/* 7 */size, 0 };

+			ga.setLocationAndSize(containerGa, x, y, size, 9 * size / 40);

+		} else { // width <= height

+			size = height;

+			lineXy = new int[] {

+			/* 1 */0, 0,

+			/* 2 */size / 8, 0,

+			/* 3 */size / 8, size / 2,

+			/* 4 */9 * size / 40, size / 2,

+			/* 5 */size / 8, size / 2,

+			/* 6 */size / 8, size,

+			/* 7 */0, size };

+			ga.setLocationAndSize(containerGa, x, y, 9 * size / 40, size);

+		}

+

+		int cornerSize = size / 10;

+		int lineBeforeAfter[] = new int[] {

+		/* 1 */0, 0,

+		/* 2 */cornerSize, cornerSize,

+		/* 3 */cornerSize, cornerSize,

+		/* 4 */0, 0,

+		/* 5 */cornerSize, cornerSize,

+		/* 6 */cornerSize, cornerSize,

+		/* 7 */0, 0 };

+

+		Polyline polyline = ga.createPolyline(container, lineXy,

+				lineBeforeAfter);

+		polyline.setStyle(StyleUtil.getStyle(diagram, StyleUtil.SHAPE));

+		// polyline.setForeground(ga.manageColor(diagram, 0, 0, 0));

+		polyline.setLineWidth(BRACE_DEFAULT_LINEWIDTH);

+		return polyline;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getDefaultLineWidth()

+	 */

+	public int getDefaultLineWidth() {

+		return BRACE_DEFAULT_LINEWIDTH;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getMinimumHeight()

+	 */

+	public int getMinimumHeight() {

+		return BRACE_MINIMUM_HEIGHT;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getMinimumWidth()

+	 */

+	public int getMinimumWidth() {

+		return 9 * BRACE_MINIMUM_HEIGHT / 40;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getDefaultHeight()

+	 */

+	public int getDefaultHeight() {

+		return BRACE_DEFAULT_HEIGHT;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getDefaultWidth()

+	 */

+	public int getDefaultWidth() {

+		return 9 * BRACE_DEFAULT_HEIGHT / 40;

+	}

+

+	// ----------------------------------------

+	// ----------- Rotatable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#getAngle(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public int getAngle(GraphicsAlgorithm graphicsAlgorithm) {

+		Polyline polyline = (Polyline) graphicsAlgorithm;

+		EList<Point> points = polyline.getPoints();

+		Point point1 = points.get(1);

+		Point point2 = points.get(2);

+		Point point7 = points.get(7);

+		if (point2.getY() == point1.getY()) {

+			return (point7.getY() > point1.getY()) ? 0 : 180;

+		} else {

+			return (point7.getX() < point1.getX()) ? 90 : 270;

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#isFlipped(org.eclipse.

+	 * graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public boolean isFlipped(GraphicsAlgorithm graphicsAlgorithm) {

+		Polyline polyline = (Polyline) graphicsAlgorithm;

+		EList<Point> points = polyline.getPoints();

+		Point point1 = points.get(1);

+		Point point2 = points.get(2);

+		switch (getAngle(polyline)) {

+		case 90:

+			return (point1.getY() < point2.getY()) ? false : true;

+		case 180:

+			return (point1.getX() > point2.getX()) ? false : true;

+		case 270:

+			return (point1.getY() > point2.getY()) ? false : true;

+		default:

+			return (point1.getX() < point2.getX()) ? false : true;

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#rotate90Right(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void rotate90Right(GraphicsAlgorithm graphicsAlgorithm) {

+		Polyline polyline = (Polyline) graphicsAlgorithm

+				.getGraphicsAlgorithmChildren().get(0);

+		graphicsAlgorithm

+				.setX(graphicsAlgorithm.getX()

+						+ (graphicsAlgorithm.getWidth() - graphicsAlgorithm

+								.getHeight()) / 2);

+		graphicsAlgorithm

+				.setY(graphicsAlgorithm.getY()

+						- (graphicsAlgorithm.getWidth() - graphicsAlgorithm

+								.getHeight()) / 2);

+		// Rotate graphicsAlgorithm

+		int oldWidth = graphicsAlgorithm.getWidth();

+		int oldHeight = graphicsAlgorithm.getHeight();

+		int oldX, oldY;

+		for (Point point : polyline.getPoints()) {

+			oldX = point.getX();

+			oldY = point.getY();

+			point.setX(oldHeight - oldY);

+			point.setY(oldX);

+		}

+

+		// Adapt the size of graphicsAlgorithm

+		graphicsAlgorithm.setHeight(oldWidth);

+		graphicsAlgorithm.setWidth(oldHeight);

+		polyline.setHeight(oldWidth);

+		polyline.setWidth(oldHeight);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipHorizontally(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipHorizontally(GraphicsAlgorithm graphicsAlgorithm) {

+		Polyline polyline = (Polyline) graphicsAlgorithm

+				.getGraphicsAlgorithmChildren().get(0);

+

+		// Flip graphicsAlgorithm

+		int width = graphicsAlgorithm.getWidth();

+		for (Point point : polyline.getPoints()) {

+			point.setX(width - point.getX());

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipVertically(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipVertically(GraphicsAlgorithm graphicsAlgorithm) {

+		Polyline polyline = (Polyline) graphicsAlgorithm

+				.getGraphicsAlgorithmChildren().get(0);

+

+		// Flip graphicsAlgorithm

+		int height = graphicsAlgorithm.getHeight();

+		for (Point point : polyline.getPoints()) {

+			point.setY(height - point.getY());

+		}

+

+	}

+

+	// ----------------------------------------

+	// ----------- Resizable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ResizableNode#resize(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm, int, int, int, int)

+	 */

+	public void resize(GraphicsAlgorithm algorithm, int x, int y, int width,

+			int height) {

+		// Resize polyline

+		Polyline polyline = (Polyline) algorithm.getGraphicsAlgorithmChildren()

+				.get(0);

+		int newWidth = width;

+		int newHeight = height;

+		int oldWidth = algorithm.getWidth();

+		int oldHeight = algorithm.getHeight();

+

+		int lineXy[];

+		int newSize, oldSize;

+

+		// resize if aspect-ratio change is detected

+		if ((newWidth > newHeight && oldWidth > oldHeight)

+				|| (newWidth < newHeight && oldWidth < oldHeight)) {

+			if (newWidth > newHeight) {

+				newSize = newWidth;

+				oldSize = oldWidth;

+				ga.setLocationAndSize(algorithm, x, y, newSize,

+						9 * newSize / 40);

+			} else {

+				newSize = newHeight;

+				oldSize = oldHeight;

+				ga.setLocationAndSize(algorithm, x, y, 9 * newSize / 40,

+						newSize);

+			}

+

+			double factor = ((double) newSize) / oldSize;

+			for (Point p : polyline.getPoints()) {

+				p.setX((int) (p.getX() * factor));

+				p.setBefore((int) (p.getBefore() * factor));

+				p.setY((int) (p.getY() * factor));

+				p.setAfter((int) (p.getAfter() * factor));

+			}

+			// redraw if aspect-ratio has changed

+		} else {

+			if (newWidth > newHeight) {

+				newSize = newWidth;

+				lineXy = new int[] {

+				/* 1 */0, 0,

+				/* 2 */0, newSize / 8,

+				/* 3 */newSize / 2, newSize / 8,

+				/* 4 */newSize / 2, 9 * newSize / 40,

+				/* 5 */newSize / 2, newSize / 8,

+				/* 6 */newSize, newSize / 8,

+				/* 7 */newSize, 0 };

+				ga.setLocationAndSize(algorithm, x, y, newSize,

+						9 * newSize / 40);

+			} else { // w <= h

+				newSize = newHeight;

+				lineXy = new int[] {

+				/* 1 */0, 0,

+				/* 2 */newSize / 8, 0,

+				/* 3 */newSize / 8, newSize / 2,

+				/* 4 */9 * newSize / 40, newSize / 2,

+				/* 5 */newSize / 8, newSize / 2,

+				/* 6 */newSize / 8, newSize,

+				/* 7 */0, newSize };

+				ga.setLocationAndSize(algorithm, x, y, 9 * newSize / 40,

+						newSize);

+			}

+

+			int cornerSize = newSize / 10;

+			int lineBeforeAfter[] = new int[] {

+			/* 1 */0, 0,

+			/* 2 */cornerSize, cornerSize,

+			/* 3 */cornerSize, cornerSize,

+			/* 4 */0, 0,

+			/* 5 */cornerSize, cornerSize,

+			/* 6 */cornerSize, cornerSize,

+			/* 7 */0, 0 };

+

+			int i = 0;

+			for (Point p : polyline.getPoints()) {

+				p.setX(lineXy[i]);

+				p.setBefore(lineBeforeAfter[i++]);

+				p.setY(lineXy[i]);

+				p.setAfter(lineBeforeAfter[i++]);

+			}

+

+		}

+

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithm.java
new file mode 100644
index 0000000..b050cc2
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithm.java
@@ -0,0 +1,29 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.comment;

+

+import org.eclipse.fmc.blockdiagram.editor.algorithm.element.FMCElementAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.GraphicsNode;

+

+/**

+ * This is the interface for all comment algorithms.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public interface CommentAlgorithm extends FMCElementAlgorithm, GraphicsNode {

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithmFactory.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithmFactory.java
new file mode 100644
index 0000000..4f6a9f1
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/CommentAlgorithmFactory.java
@@ -0,0 +1,78 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.comment;

+

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeCheckerFactory;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+/**

+ * This factory produces Comment algorithms depending on an already existing

+ * comment instance. The factory is responsible for creating the appropriate

+ * algorithm. This class is singleton.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public class CommentAlgorithmFactory {

+

+	private static CommentAlgorithmFactory instance;

+	private FMCTypeChecker helper = FMCTypeCheckerFactory.getInstance();

+

+	private BraceAlgorithm brace = null;

+

+	private CommentAlgorithmFactory() {

+	}

+

+	/**

+	 * Lazy initialization method of this factory.

+	 * 

+	 * @return The singleton instance of this factory.

+	 */

+	public static synchronized CommentAlgorithmFactory getInstance() {

+		if (instance == null) {

+			instance = new CommentAlgorithmFactory();

+		}

+		return instance;

+	}

+

+	/**

+	 * Returns the brace algorithm singleton instance.

+	 * @return BraceAlgorithm object.

+	 */

+	public BraceAlgorithm getBrace() {

+		if (brace == null) {

+			brace = new BraceAlgorithm();

+		}

+		return brace;

+	}

+

+	/**

+	 * Returns the appropriate algorithm for the already existing pictogram

+	 * element.

+	 * 

+	 * @param picto

+	 *            The pictogram element to find the algorithm for.

+	 * @return The appropriate FMCNodeAlgorithm instance.

+	 * 

+	 */

+	public CommentAlgorithm getShape(PictogramElement picto) {

+		if (helper.isBrace(picto)) {

+			return getBrace();

+		}

+		return null;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/package.html b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/package.html
new file mode 100644
index 0000000..0ea0354
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/comment/package.html
@@ -0,0 +1,4 @@
+<html>

+<body>This package contains classes responsible for algorithms to create/modify/process comment elements such as braces. 

+</body>

+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithm.java
new file mode 100644
index 0000000..0e97347
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithm.java
@@ -0,0 +1,401 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.connection;

+

+import java.util.HashSet;

+import java.util.Set;

+

+import org.eclipse.fmc.blockdiagram.editor.algorithm.element.FMCElementAlgorithm;

+import org.eclipse.fmc.blockdiagram.editor.features.add.CommunicationChannelAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.features.add.ConnectionAddFeature;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeCheckerFactory;

+import org.eclipse.fmc.mm.DataflowDirection;

+import org.eclipse.fmc.mm.RequestDirection;

+import org.eclipse.graphiti.mm.algorithms.AbstractText;

+import org.eclipse.graphiti.mm.algorithms.Ellipse;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.Text;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.CompositeConnection;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;

+import org.eclipse.graphiti.mm.pictograms.CurvedConnection;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.graphiti.services.IGaService;

+import org.eclipse.graphiti.services.IPeService;

+

+/**

+ * This class encapsulates the graphical connection algorithms for editing

+ * different types of connections such as communication channels or access

+ * connections.

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class FMCConnectionAlgorithm implements FMCElementAlgorithm {

+	private static final String R_DECO = "R";

+	private static final float decoPosX = 0.4f;

+	private static final int[] POINTS_REQUEST_ARROW = new int[] { 0, 24, -15,

+			18, 0, 12, -3, 18 };

+	private static final int[] POINTS_RESPONSE_ARROW = new int[] { 10, 24, 25,

+			18, 10, 12, 13, 18 };

+	private FMCTypeChecker helper = FMCTypeCheckerFactory.getInstance();

+

+	/**

+	 * The minimum supported size of a channel line decoration (diameter).

+	 */

+	public static final int CHANNEL_MIN_SIZE = 16;

+

+	/**

+	 * Returns all connection decorators representing connection arrows (access

+	 * connection)

+	 * 

+	 * @param con

+	 *            The connection containing the decorators.

+	 * @return Set of connection decorators.

+	 */

+	private Set<ConnectionDecorator> getArrowDecorators(Connection con) {

+		Set<ConnectionDecorator> allArrows = new HashSet<ConnectionDecorator>();

+		for (ConnectionDecorator deco : con.getConnectionDecorators()) {

+			if (deco.getGraphicsAlgorithm() instanceof Polygon) {

+				allArrows.add(deco);

+			}

+		}

+		return allArrows;

+	}

+	

+	/**

+	 * Returns the connection decorator representing the channel from the

+	 * connection con.

+	 * 

+	 * @param con

+	 *            The connection containing the channel decorator.

+	 * @return The channel decorator, null if no such decorator exists.

+	 * 

+	 */

+	private ConnectionDecorator getChannelDecorator(Connection con) {

+		for (ConnectionDecorator deco : con.getConnectionDecorators()) {

+			if (deco.getGraphicsAlgorithm() instanceof Ellipse) {

+				return deco;

+			}

+		}

+		return null;

+	}

+

+	/**

+	 * Returns the connection decorator representing the R for Request.

+	 * 

+	 * @param con

+	 *            The connection containing the R decorator.

+	 * @return The R decorator, null if no such decorator exists.

+	 * 

+	 */

+	private ConnectionDecorator getRequestRDecorator(Connection con) {

+		for (ConnectionDecorator deco : con.getConnectionDecorators()) {

+			if (deco.getGraphicsAlgorithm() instanceof AbstractText

+					&& R_DECO.equals(((AbstractText) deco

+							.getGraphicsAlgorithm()).getValue())) {

+				return deco;

+			}

+		}

+		return null;

+	}

+

+	/**

+	 * Compares the polygon with the given points and returns true if both are

+	 * equal.

+	 * 

+	 * @param polyPoints

+	 *            The polygon points to compare.

+	 * @param poly

+	 *            The polygon object to compare.

+	 * @return True if both polygons are equal.

+	 */

+	private boolean equalsPolygon(int[] polyPoints, Polygon poly) {

+		int i = 0;

+		for (Point p : poly.getPoints()) {

+			if (p.getX() != polyPoints[i] || p.getY() != polyPoints[i + 1]) {

+				return false;

+			}

+			i += 2;

+		}

+		return true;

+	}

+

+	/**

+	 * Sets the location of the channel decorator.

+	 * 

+	 * @param con

+	 *            The connection containing the channel decorator.

+	 * @param location

+	 *            The relative position of the decorator.

+	 * @param diagram

+	 *            The diagram object.

+	 */

+	public void setChannelLocation(Connection con, Diagram diagram,

+			double location) {

+		ConnectionDecorator channelDecorator = getChannelDecorator(con);

+		if (channelDecorator != null) {

+			Set<ConnectionDecorator> arrowDecorators = getArrowDecorators(con);

+			for (ConnectionDecorator arrowDecorator : arrowDecorators) {

+				if (arrowDecorator.getLocation() != 1.0

+						&& arrowDecorator.getLocation() != 0.0) {

+					arrowDecorator.setLocation(location);

+				}

+			}

+			con.getConnectionDecorators().remove(channelDecorator);

+			ConnectionDecorator newChannelDecorator = createChannelSymbol(con,

+					diagram);

+			newChannelDecorator.setLocation(location);

+			ConnectionDecorator requestRDecorator = getRequestRDecorator(con);

+			if (requestRDecorator != null)

+				requestRDecorator.setLocation(location);

+		}

+	}

+

+	/**

+	 * Returns the relative location of the channel decorator.

+	 * 

+	 * @param con The connection containing the decorator.

+	 * @return The relative channel location.

+	 */

+	public double getChannelLocation(Connection con) {

+		ConnectionDecorator channelDecorator = getChannelDecorator(con);

+		if (channelDecorator != null) {

+			return channelDecorator.getLocation();

+		} else

+			return 0;

+	}

+

+	/**

+	 * 

+	 * @param con

+	 * @param direction

+	 * @param diagram

+	 */

+	public void setRequestDirection(Connection con, RequestDirection direction,

+			Diagram diagram) {

+		Set<ConnectionDecorator> arrows = getArrowDecorators(con);

+		DataflowDirection dfDirection = getDirection(con);

+		con.getConnectionDecorators().removeAll(arrows);

+		con.getConnectionDecorators().remove(getRequestRDecorator(con));

+		createRequestArrow(con, direction, diagram);

+		createDirectionArrow(con, dfDirection, diagram);

+	}

+

+	/**

+	 * Return the request direction of the communication channel, either

+	 * Request, Response or Request/Response.

+	 * 

+	 * @param con

+	 *            The connection representing a communication channel.

+	 * @return The request direction of the communication channel.

+	 */

+	public RequestDirection getRequestDirection(Connection con) {

+		boolean request = false;

+		boolean response = false;

+		for (ConnectionDecorator deco : con.getConnectionDecorators()) {

+			if (deco.getGraphicsAlgorithm() instanceof Polygon) {

+				if (equalsPolygon(POINTS_REQUEST_ARROW,

+						(Polygon) deco.getGraphicsAlgorithm())) {

+					request = true;

+				}

+				if (equalsPolygon(POINTS_RESPONSE_ARROW,

+						(Polygon) deco.getGraphicsAlgorithm())) {

+					response = true;

+				}

+				if (request && response)

+					return RequestDirection.REQUESTRESPONSE;

+			}

+		}

+		if (request) {

+			return RequestDirection.REQUEST;

+		} else if (response) {

+			return RequestDirection.RESPONSE;

+		}

+		return RequestDirection.UNSPECIFIED;

+	}

+

+	/**

+	 * Creates a new request arrow with the specified request direction.

+	 * 

+	 * @param con

+	 *            Then connection for which the decorator will be created.

+	 * @param direction

+	 *            The request arrow direction

+	 * @param diagram

+	 *            The diagram containing the connection.

+	 */

+	private void createRequestArrow(Connection con, RequestDirection direction,

+			Diagram diagram) {

+		IGaService ga = Graphiti.getGaService();

+		IPeService pe = Graphiti.getPeService();

+		ConnectionDecorator arrow = pe.createConnectionDecorator(con, false,

+				decoPosX, true);

+		Polygon arrowPoly = null;

+		switch (direction) {

+		case REQUEST:

+			arrowPoly = ga.createPolygon(arrow, POINTS_REQUEST_ARROW);

+			arrowPoly.setBackground(ga.manageColor(diagram, 0, 0, 0));

+			break;

+		case RESPONSE:

+			arrowPoly = ga.createPolygon(arrow, POINTS_RESPONSE_ARROW);

+			arrowPoly.setBackground(ga.manageColor(diagram, 0, 0, 0));

+			break;

+		case REQUESTRESPONSE:

+			arrowPoly = ga.createPolygon(arrow, POINTS_REQUEST_ARROW);

+			arrowPoly.setBackground(ga.manageColor(diagram, 0, 0, 0));

+			ConnectionDecorator arrow2 = pe.createConnectionDecorator(con,

+					false, decoPosX, true);

+			Polygon arrowPoly2 = ga

+					.createPolygon(arrow2, POINTS_RESPONSE_ARROW);

+			arrowPoly2.setBackground(ga.manageColor(diagram, 0, 0, 0));

+			break;

+		default:

+			break;

+		}

+		if (direction != RequestDirection.UNSPECIFIED) {

+			ConnectionDecorator letter = pe.createConnectionDecorator(con,

+					false, decoPosX, true);

+			letter.setActive(true);

+			Text txt = ga.createText(letter, R_DECO);

+			txt.setForeground(ga.manageColor(diagram, 0, 0, 0));

+			txt.setWidth(10);

+			txt.setHeight(10);

+			ga.setLocation(txt, -8, -22);

+		}

+	}

+

+	/**

+	 * Sets the data flow direction of a connection by creating a connection

+	 * decorator. If the connection is a composite connection, the direction

+	 * is also switched for the children.

+	 * 

+	 * @param con

+	 *            The connection to set the data flow direction for.

+	 * @param direction

+	 *            The data flow direction to be set.

+	 * @param diagram

+	 *            The diagram containing the connection.

+	 */

+	public void setDirection(Connection con, DataflowDirection direction,

+			Diagram diagram) {

+		if (con instanceof CompositeConnection) {

+			CompositeConnection composite = (CompositeConnection) con;

+			int i = 0;

+			for (CurvedConnection child : composite.getChildren()) {

+				changeDirection(child, i == 0 ? direction

+						: DataflowDirection.getOpposite(direction), diagram);

+				i++;

+			}

+		} else

+			changeDirection(con, direction, diagram);

+	}

+

+	/**

+	 * Sets the data flow direction of a connection by creating a connection

+	 * decorator.

+	 * 

+	 * @param con

+	 *            The connection to set the data flow direction for.

+	 * @param direction

+	 *            The data flow direction to be set.

+	 * @param diagram

+	 *            The diagram containing the connection.

+	 */

+	private void changeDirection(Connection con, DataflowDirection direction,

+			Diagram diagram) {

+		Set<ConnectionDecorator> arrows = getArrowDecorators(con);

+		RequestDirection requestDirection = getRequestDirection(con);

+		con.getConnectionDecorators().removeAll(arrows);

+		con.getConnectionDecorators().remove(getRequestRDecorator(con));

+		createDirectionArrow(con, direction, diagram);

+		createRequestArrow(con, requestDirection, diagram);

+	}

+

+	/**

+	 * Returns the data flow direction of the connection.

+	 * 

+	 * @param con

+	 *            The connection for which the data flow is to be determined.

+	 * @return The data flow direction of the connection.

+	 */

+	public DataflowDirection getDirection(Connection con) {

+		Set<ConnectionDecorator> arrows = getArrowDecorators(con);

+		if (arrows.isEmpty())

+			return DataflowDirection.UNSPECIFIED;

+		else {

+			for (ConnectionDecorator connectionDecorator : arrows) {

+				if (connectionDecorator.getLocation() == 0) {

+					return DataflowDirection.OTHER;

+				} else if (connectionDecorator.getLocation() == 1) {

+					return DataflowDirection.DEFAULT;

+				}

+			}

+			return DataflowDirection.UNSPECIFIED;

+		}

+	}

+

+	/**

+	 * Creates a data flow direction arrow for the connection.

+	 * 

+	 * @param con

+	 *            The connection to create the connection for.

+	 * @param direction

+	 *            The direction of the connection to be created.

+	 * @param diagram

+	 *            The diagram containing the connection.

+	 */

+	private void createDirectionArrow(Connection con,

+			DataflowDirection direction, Diagram diagram) {

+		boolean defaultDirection = direction == DataflowDirection.DEFAULT;

+		if (direction != DataflowDirection.UNSPECIFIED) {

+			ConnectionAddFeature.createArrowDecorator(diagram, con,

+					defaultDirection);

+		}

+		if (direction != DataflowDirection.UNSPECIFIED

+				&& helper.isCommunicationChannel(con)) {

+			CommunicationChannelAddFeature.createCenterArrow(diagram, con,

+					defaultDirection);

+		}

+	}

+

+	/**

+	 * Creates a channel connection decorator for the connection.

+	 * 

+	 * @param con

+	 *            The connection to create a channel for.

+	 * @param diagram

+	 *            The diagram containing the connection.

+	 * @return The connection decorator for the channel.

+	 */

+	public ConnectionDecorator createChannelSymbol(Connection con,

+			Diagram diagram) {

+		ConnectionDecorator cDecorator = Graphiti.getPeService()

+				.createConnectionDecorator(con, false, decoPosX, true);

+		Ellipse e = Graphiti.getGaService().createEllipse(cDecorator);

+		e.setBackground(Graphiti.getGaService().manageColor(diagram, 255, 255,

+				255));

+		e.setForeground(Graphiti.getGaService().manageColor(diagram, 0, 0, 0));

+		e.setLineWidth(2);

+		Graphiti.getGaService().setLocationAndSize(e, -8, 0, CHANNEL_MIN_SIZE,

+				CHANNEL_MIN_SIZE);

+		return cDecorator;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithmFactory.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithmFactory.java
new file mode 100644
index 0000000..109dbec
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/FMCConnectionAlgorithmFactory.java
@@ -0,0 +1,65 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.connection;

+

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+/**

+ * This factory produces connection algorithms.

+ * 

+ * @author Benjamin Schmeling

+ *

+ */

+public class FMCConnectionAlgorithmFactory {

+

+	private static FMCConnectionAlgorithmFactory instance = null;

+

+	/**

+	 * This class cannot be instantiated it is a singleton.

+	 */

+	private FMCConnectionAlgorithmFactory() {

+	}

+

+	/**

+	 * Return the singleton instance of this factory class.

+	 * 

+	 * @return The factory instance.

+	 */

+	public static synchronized FMCConnectionAlgorithmFactory getInstance() {

+		if (instance == null) {

+			instance = new FMCConnectionAlgorithmFactory();

+		}

+		return instance;

+	}

+	

+	/**

+	 * Returns the connection algorithm for the pictogram element. If the

+	 * pictogram element is not a connection, this method will return null.

+	 * 

+	 * @param picto

+	 *            The pictogram element for determination of the connection

+	 *            algorithm.

+	 * 

+	 * @return The connection algorithm matching the pictogram input. Currently,

+	 *         there is only one type of connection algorithm

+	 */

+	public FMCConnectionAlgorithm getAlgorithm(PictogramElement picto) {

+		if (picto instanceof Connection)

+			return new FMCConnectionAlgorithm();

+		return null;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/package.html b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/package.html
new file mode 100644
index 0000000..c7ce532
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/connection/package.html
@@ -0,0 +1,4 @@
+<html>

+<body>This package contains classes responsible for algorithms to create/modify/process connections such as communication channels or access connections. 

+</body>

+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithm.java
new file mode 100644
index 0000000..6f062f9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithm.java
@@ -0,0 +1,26 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.element;

+

+/**

+ * This is the interface for all FMC element algorithms.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public interface FMCElementAlgorithm {

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithmFactory.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithmFactory.java
new file mode 100644
index 0000000..92ffc70
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/FMCElementAlgorithmFactory.java
@@ -0,0 +1,84 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.element;

+

+import org.eclipse.fmc.blockdiagram.editor.algorithm.comment.CommentAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.connection.FMCConnectionAlgorithmFactory;

+import org.eclipse.fmc.blockdiagram.editor.algorithm.node.FMCNodeAlgorithmFactory;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+/**

+ * This factory produces all kinds of algorithms depending on an already existing

+ * pictogram element instance. The factory is responsible for creating the appropriate

+ * algorithm. This class is singleton.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public class FMCElementAlgorithmFactory {

+

+	private static FMCElementAlgorithmFactory instance;

+	private FMCNodeAlgorithmFactory fmcNodeAlgorithmFactory = FMCNodeAlgorithmFactory

+			.getInstance();

+	private FMCConnectionAlgorithmFactory connectionAlgorithmFactory = FMCConnectionAlgorithmFactory

+			.getInstance();

+	private CommentAlgorithmFactory commentAlgorithmFactory = CommentAlgorithmFactory

+			.getInstance();

+

+	/** 

+	 * Private constructor. Singleton.

+	 */

+	private FMCElementAlgorithmFactory() {

+	}

+

+	/**

+	 * Lazy initialization method of this factory.

+	 * 

+	 * @return The singleton instance of this factory.

+	 */

+	public static synchronized FMCElementAlgorithmFactory getInstance() {

+		if (instance == null) {

+			instance = new FMCElementAlgorithmFactory();

+		}

+		return instance;

+	}

+

+	/**

+	 * Returns the appropriate algorithm for the already existing pictogram

+	 * element, either a FMCNodeAlgorithm, a ConnectionAlgorithm or a

+	 * CommentAlgorithm.

+	 * 

+	 * @param picto

+	 *            The pictogram element to find the algorithm for.

+	 * @return The appropriate FMCElementAlgorithm instance.

+	 * 

+	 */

+	public FMCElementAlgorithm getShape(PictogramElement picto) {

+		// Is it a Node?

+		FMCElementAlgorithm result = fmcNodeAlgorithmFactory.getShape(picto);

+		if (result != null) {

+			return result;

+		}

+		// Is it a Connection?

+		result = connectionAlgorithmFactory.getAlgorithm(picto);

+		if (result != null) {

+			return result;

+		}

+		// Is it a Comment?

+		result = commentAlgorithmFactory.getShape(picto);

+		return result;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/package.html b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/package.html
new file mode 100644
index 0000000..04a0600
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/element/package.html
@@ -0,0 +1,4 @@
+<html>

+<body>This package contains classes responsible for algorithms to create/modify/process all kinds of pictogram elements: nodes, connections and comments. 

+</body>

+</html>
\ No newline at end of file
diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractLPolygonAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractLPolygonAlgorithm.java
new file mode 100644
index 0000000..34ba3d5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractLPolygonAlgorithm.java
@@ -0,0 +1,822 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import java.util.ArrayList;

+import java.util.List;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.MultiText;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+/**

+ * This abstract class implements all methods common to L-shaped polygons.

+ * 

+ * 43 xx 0xx5x 1xxx2

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public abstract class AbstractLPolygonAlgorithm extends

+		AbstractPolygonAlgorithm implements LPolygonAlgorithm {

+

+	// ----------------------------------------

+	// ----------- (L)Polygon Impl ------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.PolygonAlgorithm#getInitialPoints(int,

+	 * int, int, int)

+	 */

+	public List<Point> getInitialPoints(int x, int y, int width, int height) {

+		int outerCornerSize = hasRoundedCorners() ? L_PART_DEFAULT_SIZE / 2 : 0;

+		int innerCornerSize = hasRoundedCorners() ? outerCornerSize * 2 / 3 : 0;

+		List<Point> points = new ArrayList<Point>();

+

+		/* 0 */points.add(ga.createPoint(x, y + height - L_PART_DEFAULT_SIZE,

+				outerCornerSize, outerCornerSize));

+		/* 1 */points.add(ga.createPoint(x, y + height, outerCornerSize,

+				outerCornerSize));

+		/* 2 */points.add(ga.createPoint(x + width, y + height,

+				outerCornerSize, outerCornerSize));

+		/* 3 */points.add(ga.createPoint(x + width, y, outerCornerSize,

+				outerCornerSize));

+		/* 4 */points.add(ga.createPoint(x + width - L_PART_DEFAULT_SIZE, y,

+				outerCornerSize, outerCornerSize));

+		/* 5 */points.add(ga.createPoint(x + width - L_PART_DEFAULT_SIZE, y

+				+ height - L_PART_DEFAULT_SIZE, innerCornerSize,

+				innerCornerSize));

+

+		return points;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.LPolygonAlgorithm#

+	 * getBottomPartSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getBottomPartSize(Polygon polygon) {

+		EList<Point> points = polygon.getPoints();

+		if (isFlattened(polygon))

+			return Math.abs(points.get(1).getX() - points.get(5).getX());

+		else

+			return Math.abs(points.get(1).getY() - points.get(5).getY());

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.LPolygonAlgorithm#

+	 * getRightPartSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getRightPartSize(Polygon polygon) {

+		EList<Point> points = polygon.getPoints();

+		if (isFlattened(polygon))

+			return Math.abs(points.get(3).getY() - points.get(4).getY());

+		else

+			return Math.abs(points.get(3).getX() - points.get(4).getX());

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.LPolygonAlgorithm#

+	 * resizeBottomPart(org.eclipse.graphiti.mm.algorithms.Polygon, int)

+	 */

+	public void resizeBottomPart(Polygon polygon, int size) {

+		if (size < LPolygonAlgorithm.L_PART_MINIMUM_SIZE) {

+			size = LPolygonAlgorithm.L_PART_MINIMUM_SIZE;

+		}

+		int oldSize = getBottomPartSize(polygon);

+		int sizeDif = isFlipped(polygon) ? oldSize - size : size - oldSize;

+		EList<Point> points = polygon.getPoints();

+		if (sizeDif != 0) {

+			switch (getAngle(polygon)) {

+			case 90:

+				points.get(0).setX(points.get(0).getX() + sizeDif);

+				points.get(5).setX(points.get(5).getX() + sizeDif);

+				break;

+			case 180:

+				points.get(0).setY(points.get(0).getY() + sizeDif);

+				points.get(5).setY(points.get(5).getY() + sizeDif);

+				break;

+			case 270:

+				points.get(0).setX(points.get(0).getX() - sizeDif);

+				points.get(5).setX(points.get(5).getX() - sizeDif);

+				break;

+			default:

+				points.get(0).setY(points.get(0).getY() - sizeDif);

+				points.get(5).setY(points.get(5).getY() - sizeDif);

+			}

+

+			// adapt corner roundings if storage

+			if (hasRoundedCorners()) {

+				int cornerSize = getBottomPartLeftCornerSize(polygon);

+				int innerCornerSize = getBottomPartRightCornerSize(polygon);

+

+				points.get(0).setBefore(cornerSize);

+				points.get(0).setAfter(cornerSize);

+				points.get(1).setBefore(cornerSize);

+				points.get(1).setAfter(cornerSize);

+				points.get(2).setBefore(innerCornerSize);

+				points.get(5).setAfter(innerCornerSize);

+			}

+		}

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = polygon

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Resize bottom part of polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.resizeBottomPart(

+						(Polygon) graphicsAlgorithmChildren.get(i), size);

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(polygon));

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.LPolygonAlgorithm#

+	 * resizeRightPart(org.eclipse.graphiti.mm.algorithms.Polygon, int)

+	 */

+	public void resizeRightPart(Polygon polygon, int size) {

+		if (size < LPolygonAlgorithm.L_PART_MINIMUM_SIZE) {

+			size = LPolygonAlgorithm.L_PART_MINIMUM_SIZE;

+		}

+		int oldSize = getRightPartSize(polygon);

+		int sizeDif = size - oldSize;

+		EList<Point> points = polygon.getPoints();

+		if (sizeDif != 0) {

+			switch (getAngle(polygon)) {

+			case 90:

+				points.get(4).setY(points.get(4).getY() - sizeDif);

+				points.get(5).setY(points.get(5).getY() - sizeDif);

+				break;

+			case 180:

+				points.get(4).setX(points.get(4).getX() + sizeDif);

+				points.get(5).setX(points.get(5).getX() + sizeDif);

+				break;

+			case 270:

+				points.get(4).setY(points.get(4).getY() + sizeDif);

+				points.get(5).setY(points.get(5).getY() + sizeDif);

+				break;

+			default:

+				points.get(4).setX(points.get(4).getX() - sizeDif);

+				points.get(5).setX(points.get(5).getX() - sizeDif);

+			}

+

+			// adapt corner roundings if polygon has rounded corners

+			if (hasRoundedCorners()) {

+				int cornerSize = getRightPartTopCornerSize(polygon);

+				int innerCornerSize = getRightPartBottomCornerSize(polygon);

+

+				points.get(3).setBefore(cornerSize);

+				points.get(3).setAfter(cornerSize);

+				points.get(4).setBefore(cornerSize);

+				points.get(4).setAfter(cornerSize);

+				points.get(5).setBefore(innerCornerSize);

+				points.get(2).setAfter(innerCornerSize);

+			}

+		}

+

+		relocateText(polygon);

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = polygon

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Resize right part of polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.resizeRightPart(

+						(Polygon) graphicsAlgorithmChildren.get(i), size);

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(polygon));

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.LPolygonAlgorithm#getRightPartTopCornerSize

+	 * (org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getRightPartTopCornerSize(Polygon polygon) {

+		return getRightPartSize(polygon) / 2;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.LPolygonAlgorithm#

+	 * getBottomPartLeftCornerSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getBottomPartLeftCornerSize(Polygon polygon) {

+		return getBottomPartSize(polygon) / 2;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.LPolygonAlgorithm#

+	 * getRightPartBottomCornerSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getRightPartBottomCornerSize(Polygon polygon) {

+		return getRightPartTopCornerSize(polygon);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.LPolygonAlgorithm#

+	 * getBottomPartRightCornerSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getBottomPartRightCornerSize(Polygon polygon) {

+		return getBottomPartLeftCornerSize(polygon);

+	}

+

+	// ----------------------------------------

+	// ----------- Rotatable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#getAngle(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public int getAngle(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+		EList<Point> points = polygon.getPoints();

+		Point point1 = points.get(1);

+		Point point2 = points.get(2);

+		if (point2.getY() == point1.getY()) {

+			return (point2.getX() > point1.getX()) ? 0 : 180;

+		} else {

+			return (point2.getY() > point1.getY()) ? 90 : 270;

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#isFlipped(org.eclipse.

+	 * graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public boolean isFlipped(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+		EList<Point> points = polygon.getPoints();

+		Point point2 = points.get(2);

+		Point point3 = points.get(3);

+		switch (getAngle(polygon)) {

+		case 90:

+			return (point2.getX() < point3.getX()) ? false : true;

+		case 180:

+			return (point2.getY() < point3.getY()) ? false : true;

+		case 270:

+			return (point2.getX() > point3.getX()) ? false : true;

+		default:

+			return (point2.getY() > point3.getY()) ? false : true;

+		}

+	}

+

+	/**

+	 * Is the angle of the L polygon 90 or 270?

+	 * 

+	 * @param polygon

+	 * @return True, if angle is 90 or 270

+	 */

+	protected boolean isFlattened(Polygon polygon) {

+		double oldAngle = getAngle(polygon);

+		return (oldAngle % 180) == 90;

+	}

+

+	// ----------------------------------------

+	// ----------- Resizable Node -------------

+

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.polygon.AbstractPolygonAlgorithm#resize(org

+	 * .eclipse.graphiti.mm.algorithms.GraphicsAlgorithm, int, int, int, int)

+	 */

+	public void resize(GraphicsAlgorithm algorithm, int x, int y, int width,

+			int height) {

+		Polygon polygon = (Polygon) algorithm;

+		int angle = getAngle(polygon);

+		int[] resizeX;

+		int[] resizeY;

+		if (isFlipped(polygon)) {

+			switch (angle) {

+			case 90:

+				resizeX = new int[4];

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeX[2] = 2;

+				resizeX[3] = 5;

+				resizeY = new int[4];

+				resizeY[0] = 2;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 5;

+				break;

+			case 180:

+				resizeX = new int[2];

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeY = new int[4];

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				resizeY[2] = 2;

+				resizeY[3] = 5;

+				break;

+			case 270:

+				resizeX = new int[2];

+				resizeX[0] = 3;

+				resizeX[1] = 4;

+				resizeY = new int[2];

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				break;

+			default:

+				resizeX = new int[4];

+				resizeX[0] = 2;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 5;

+				resizeY = new int[2];

+				resizeY[0] = 3;

+				resizeY[1] = 4;

+			}

+		} else {

+			switch (angle) {

+			case 90:

+				resizeX = new int[2];

+				resizeX[0] = 3;

+				resizeX[1] = 4;

+				resizeY = new int[4];

+				resizeY[0] = 2;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 5;

+				break;

+			case 180:

+				resizeX = new int[2];

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeY = new int[2];

+				resizeY[0] = 3;

+				resizeY[1] = 4;

+				break;

+			case 270:

+				resizeX = new int[4];

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeX[2] = 2;

+				resizeX[3] = 5;

+				resizeY = new int[2];

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				break;

+			default:

+				resizeX = new int[4];

+				resizeX[0] = 2;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 5;

+				resizeY = new int[4];

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				resizeY[2] = 2;

+				resizeY[3] = 5;

+			}

+		}

+

+		int oldHeight = polygon.getHeight();

+		int oldWidth = polygon.getWidth();

+		int heightDif = height - oldHeight;

+		int widthDif = width - oldWidth;

+

+		EList<Point> points = polygon.getPoints();

+		for (int i = 0; i < resizeX.length; i++) {

+			points.get(resizeX[i]).setX(

+					points.get(resizeX[i]).getX() + widthDif);

+		}

+		for (int i = 0; i < resizeY.length; i++) {

+			points.get(resizeY[i]).setY(

+					points.get(resizeY[i]).getY() + heightDif);

+		}

+

+		// adapt corner roundings if polygon has rounded corners

+		if (hasRoundedCorners()) {

+			int rightCornerSize = getRightPartTopCornerSize(polygon);

+			int rightInnerBottomCornerSize = getRightPartBottomCornerSize(polygon);

+			int bottomCornerSize = getBottomPartLeftCornerSize(polygon);

+			int bottomInnerRightCornerSize = getBottomPartRightCornerSize(polygon);

+

+			points.get(0).setBefore(bottomCornerSize);

+			points.get(0).setAfter(bottomCornerSize);

+			points.get(1).setBefore(bottomCornerSize);

+			points.get(1).setAfter(bottomCornerSize);

+			points.get(2).setBefore(bottomInnerRightCornerSize);

+			points.get(2).setAfter(rightInnerBottomCornerSize);

+			points.get(3).setBefore(rightCornerSize);

+			points.get(3).setAfter(rightCornerSize);

+			points.get(4).setBefore(rightCornerSize);

+			points.get(4).setAfter(rightCornerSize);

+			points.get(5).setBefore(rightInnerBottomCornerSize);

+			points.get(5).setAfter(bottomInnerRightCornerSize);

+		}

+

+		ga.setLocationAndSize(polygon, x, y, width, height);

+

+		relocateText(polygon);

+

+		// adapt first level container (relative anchors + invisible shape)

+		ContainerShape container = this.getContainerShape(polygon);

+		createBoxAnchorSet(container);

+		synchronizeFirstLevelShape(container);

+	}

+

+	// ----------------------------------------

+	// ----------- Named Node -----------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.NamedNode#relocateText(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void relocateText(GraphicsAlgorithm graphicsAlgorithm) {

+		MultiText text = this.getText(graphicsAlgorithm);

+		if (text != null) {

+			int multipleOffset = 0;

+			if (this.isMultipleInstances(this

+					.getContainerShape(graphicsAlgorithm))) {

+				multipleOffset = MULTI_INSTANCE_GAP;

+			}

+			int angle = getAngle(graphicsAlgorithm);

+			int textContainingPartSize;

+			boolean isOnTop;

+			textContainingPartSize = (angle == 0 || angle == 180) ? getBottomPartSize((Polygon) graphicsAlgorithm)

+					: getRightPartSize((Polygon) graphicsAlgorithm);

+			if (isFlipped(graphicsAlgorithm)) {

+				isOnTop = (angle == 0 || angle == 270) ? true : false;

+			} else {

+				isOnTop = (angle == 180 || angle == 270) ? true : false;

+			}

+

+			int x = super.textMargin;

+			int width = graphicsAlgorithm.getWidth() - 2 * super.textMargin

+					- multipleOffset;

+			int y = (isOnTop ? super.textMargin : graphicsAlgorithm.getHeight()

+					- textContainingPartSize + super.textMargin)

+					+ multipleOffset;

+			int height = textContainingPartSize - 2 * super.textMargin

+					- multipleOffset;

+

+			ga.setLocationAndSize(text, x, y, width, height);

+		}

+	}

+

+	// ----------------------------------------

+	// ----------- Anchored Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractNode#addBoxAnchorSet(org.eclipse

+	 * .graphiti.mm.pictograms.ContainerShape)

+	 */

+	protected void addBoxAnchorSet(Shape shape) {

+

+		GraphicsAlgorithm firstLevelPolygon = shape.getGraphicsAlgorithm();

+		Polygon secondLevelPolygon = (Polygon) firstLevelPolygon

+				.getGraphicsAlgorithmChildren().get(0);

+

+		// Sides of the polygon:

+		// 3

+		// ---

+		// | |

+		// 4 | |

+		// 5 | | 2

+		// ------- |

+		// 0 | |

+		// -----------

+		// 1

+		int numSides = 6;

+		int lineWidth = getDefaultLineWidth();

+		Point[] point = new Point[numSides];

+		for (int i = 0; i < point.length; i++) {

+			point[i] = secondLevelPolygon.getPoints().get(i);

+		}

+

+		// Offset in case of a multi instance shape (adapt anchors when drawing

+		// background part)

+		double offsetMultiInstance = 0.0d;

+		if (firstLevelPolygon.getWidth() != secondLevelPolygon.getWidth()) {

+			// Remove anchors created when drawing the main part

+			FMCUtil.removeObsoleteAnchors(shape);

+			offsetMultiInstance = MULTI_INSTANCE_GAP;

+		}

+

+		// Length of the sides (not taking into account rounded corners)

+		int[] length = new int[numSides];

+		length[0] = getBottomPartSize(secondLevelPolygon) + lineWidth;

+		length[1] = Math.abs(isFlattened(secondLevelPolygon) ? point[1].getY()

+				- point[2].getY() : point[1].getX() - point[2].getX());

+		length[2] = Math.abs(isFlattened(secondLevelPolygon) ? point[2].getX()

+				- point[3].getX() : point[2].getY() - point[3].getY());

+		length[3] = getRightPartSize(secondLevelPolygon) + lineWidth;

+		length[4] = length[2] - length[0];

+		length[5] = length[1] - length[3];

+

+		// Length of the sides that should contain anchors

+		int[] anchoredLength = new int[numSides];

+		for (int i = 0; i < numSides; i++)

+			anchoredLength[i] = Math.max(length[i] - point[i].getAfter()

+					- point[(i + 1) % numSides].getBefore(),

+					DEFAULT_ANCHOR_DIAMETER);

+

+		// Number of anchors of the sides

+		int[] numAnchors = new int[numSides];

+

+		// Gaps between the anchor starting points of the sides (in x and y

+		// direction)

+		double[][] gaps = new double[numSides][2];

+		for (int i = 0; i < gaps.length; i++)

+			for (int j = 0; j < gaps[i].length; j++)

+				gaps[i][j] = 0.0d;

+

+		// Offsets of the starting points of the sides (in x and y direction)

+		double[][] offset = new double[numSides][2];

+		switch (getAngle(secondLevelPolygon)) {

+		case 90:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = length[4] + offsetMultiInstance;

+				offset[1][1] = 0.0d;

+				offset[1][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[5] + offsetMultiInstance;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[5];

+				offset[4][0] = offsetMultiInstance;

+				offset[5][1] = offsetMultiInstance;

+				offset[5][0] = length[4];

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				length[4] = length[4] - (int) offsetMultiInstance;

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = offsetMultiInstance;

+				offset[1][1] = offsetMultiInstance;

+				offset[1][0] = 0.0d;

+				offset[2][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[5];

+				offset[3][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][1] = length[5];

+				offset[4][0] = length[0] + offsetMultiInstance;

+				offset[5][1] = 0.0d;

+				offset[5][0] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+			}

+			break;

+		case 180:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[4];

+				offset[0][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][0] = 0.0d;

+				offset[2][1] = offsetMultiInstance;

+				offset[2][0] = 0.0d;

+				offset[3][1] = 0.0d;

+				offset[3][0] = offsetMultiInstance;

+				offset[4][1] = 0.0d;

+				offset[4][0] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][1] = length[4];

+				offset[5][0] = length[3] + offsetMultiInstance;

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][1] = 0.0d;

+				offset[1][0] = offsetMultiInstance;

+				offset[2][1] = offsetMultiInstance;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[0] + offsetMultiInstance;

+				offset[4][0] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][1] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][0] = length[3] + offsetMultiInstance;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[4].getAfter())

+					anchoredLength[4] = anchoredLength[4]

+							- (int) (offsetMultiInstance - point[5].getBefore());

+			}

+			break;

+		case 270:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[0][0] = 0.0d;

+				offset[1][1] = offsetMultiInstance;

+				offset[1][0] = 0.0d;

+				offset[2][1] = 0.0d;

+				offset[2][0] = offsetMultiInstance;

+				offset[3][1] = 0.0d;

+				offset[3][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][1] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][0] = length[0] + offsetMultiInstance;

+				offset[5][1] = length[3] + offsetMultiInstance;

+				offset[5][0] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[4].getAfter())

+					anchoredLength[4] = anchoredLength[4]

+							- (int) (offsetMultiInstance - point[5].getBefore());

+				if (offsetMultiInstance > point[5].getAfter())

+					anchoredLength[5] = anchoredLength[5]

+							- (int) (offsetMultiInstance - point[5].getAfter());

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[0][0] = length[4];

+				offset[1][1] = 0.0d;

+				offset[1][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][1] = 0.0d;

+				offset[2][0] = offsetMultiInstance;

+				offset[3][1] = offsetMultiInstance;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][0] = 0.0d;

+				offset[5][1] = length[3] + offsetMultiInstance;

+				offset[5][0] = length[4];

+			}

+			break;

+		default: // rotation = 0

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = offsetMultiInstance;

+				offset[0][0] = 0.0d;

+				offset[1][1] = 0.0d;

+				offset[1][0] = offsetMultiInstance;

+				offset[2][1] = 0.0d;

+				offset[2][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][0] = length[5];

+				offset[4][1] = length[0] + offsetMultiInstance;

+				offset[4][0] = length[5];

+				offset[5][1] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][0] = 0.0d;

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[4] + offsetMultiInstance;

+				offset[0][0] = 0.0d;

+				offset[1][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][0] = 0.0d;

+				offset[2][1] = 0.0d;

+				offset[2][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][1] = 0.0d;

+				offset[3][0] = length[5] + offsetMultiInstance;

+				offset[4][1] = offsetMultiInstance;

+				offset[4][0] = length[5];

+				offset[5][1] = length[4];

+				offset[5][0] = offsetMultiInstance;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[5].getAfter())

+					anchoredLength[5] = anchoredLength[5]

+							- (int) (offsetMultiInstance - point[5].getAfter());

+			}

+		}

+

+		// adjust offsets according to rounded corners

+		for (int i = 0; i < numSides; i++) {

+			if (point[i].getX() == point[(i + 1) % numSides].getX()) { // vertical

+				// side

+				offset[i][1] = offset[i][1]

+						+ (point[i].getY() < point[(i + 1) % numSides].getY() ? (point[i]

+								.getAfter() > 0 ? point[i].getAfter()

+								- ((double) DEFAULT_ANCHOR_DIAMETER) / 2 : 0.0d)

+								: (point[(i + 1) % numSides].getBefore() > 0 ? point[(i + 1)

+										% numSides].getBefore()

+										- ((double) DEFAULT_ANCHOR_DIAMETER)

+										/ 2

+										: 0.0d));

+			} else { // horizontal side

+				offset[i][0] = offset[i][0]

+						+ (point[i].getX() < point[(i + 1) % numSides].getX() ? (point[i]

+								.getAfter() > 0 ? point[i].getAfter()

+								- ((double) DEFAULT_ANCHOR_DIAMETER) / 2 : 0.0d)

+								: (point[(i + 1) % numSides].getBefore() > 0 ? point[(i + 1)

+										% numSides].getBefore()

+										- ((double) DEFAULT_ANCHOR_DIAMETER)

+										/ 2

+										: 0.0d));

+			}

+		}

+

+		// Calculate number of anchors per side

+		for (int i = 0; i < numSides; i++)

+			numAnchors[i] = anchoredLength[i] / DEFAULT_ANCHOR_GAP;

+

+		// Calculate gaps between the starting points of the anchors for each

+		// side

+		int direction = 0;

+		for (int i = 0; i < numSides; i++) {

+			direction = isFlattened(secondLevelPolygon) ? (i % 2)

+					: ((i + 1) % 2);

+			gaps[i][direction] = ((double) anchoredLength[i]) / numAnchors[i];

+		}

+

+		// Create relative box anchors

+		for (int i = 0; i < numSides; i++)

+			for (int j = 0; j < numAnchors[i]; j++)

+				createBoxAnchor(shape, (offset[i][0] + j * gaps[i][0])

+						/ firstLevelPolygon.getWidth(), (offset[i][1] + j

+						* gaps[i][1])

+						/ firstLevelPolygon.getHeight(),

+						AnchoredNode.DEFAULT_ANCHOR_GAP,

+						AnchoredNode.DEFAULT_ANCHOR_DIAMETER);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractNode.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractNode.java
new file mode 100644
index 0000000..27055b5
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractNode.java
@@ -0,0 +1,541 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import java.util.ArrayList;

+import java.util.HashSet;

+import java.util.List;

+

+import org.eclipse.emf.common.util.BasicEList;

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.graphiti.features.IFeatureProvider;

+import org.eclipse.graphiti.mm.algorithms.Ellipse;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.MultiText;

+import org.eclipse.graphiti.mm.pictograms.Anchor;

+import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;

+import org.eclipse.graphiti.mm.pictograms.CompositeConnection;

+import org.eclipse.graphiti.mm.pictograms.Connection;

+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.CurvedConnection;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.graphiti.services.IGaService;

+import org.eclipse.graphiti.services.IPeService;

+

+/**

+ * This abstract class implements methods for nodes with anchors and

+ * multiplicity property. The node can be named and may contain nested nodes.

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public abstract class AbstractNode implements AnchoredNode, MultipleNode,

+		NamedNode, ResizableNode, ContainerNode {

+

+	protected IGaService ga = Graphiti.getGaService();

+	protected IPeService pe = Graphiti.getPeService();

+	protected int textMargin = DEFAULT_MARGIN;

+

+	// ----------------------------------------

+	// ----------- Anchored Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#setBoxAnchorsVisible(org

+	 * .eclipse.graphiti.mm.pictograms.Shape, boolean)

+	 */

+	public void setBoxAnchorsVisible(Shape shape, boolean visible) {

+		for (Anchor anchor : shape.getAnchors()) {

+			if (anchor instanceof BoxRelativeAnchor) {

+				anchor.getGraphicsAlgorithm().setFilled(visible);

+				anchor.getGraphicsAlgorithm().setLineVisible(visible);

+			}

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#isBoxAnchorsVisible(org

+	 * .eclipse.graphiti.mm.pictograms.Shape)

+	 */

+	public boolean isBoxAnchorsVisible(Shape shape) {

+		for (Anchor anchor : shape.getAnchors()) {

+			if (anchor instanceof BoxRelativeAnchor) {

+				return anchor.getGraphicsAlgorithm().getLineVisible();

+			}

+		}

+		return false;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#resizeBoxAnchorSet(org.

+	 * eclipse.graphiti.mm.pictograms.ContainerShape, int, int, int, int)

+	 */

+	public void resizeBoxAnchorSet(ContainerShape container, int x, int y,

+			int width, int height) {

+		createBoxAnchorSet(container);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#createBoxAnchorSet(org.

+	 * eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public void createBoxAnchorSet(Shape shape) {

+		boolean isAnchorsVisible = isBoxAnchorsVisible(shape);

+		FMCUtil.removeObsoleteAnchors(shape);

+		addBoxAnchorSet(shape);

+		this.setBoxAnchorsVisible(shape, isAnchorsVisible);

+		// removeInnerUnusedAnchors(container);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#removeUnusedBoxAnchors(

+	 * org.eclipse.graphiti.mm.pictograms.Shape)

+	 */

+	public void removeUnusedBoxAnchors(Shape shape) {

+		FMCUtil.removeObsoleteAnchors(shape);

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AnchoredNode#hasUnusedAnchors(org.eclipse

+	 * .graphiti.mm.pictograms.Shape)

+	 */

+	public boolean hasUnusedAnchors(Shape shape) {

+		for (Anchor anchor : new HashSet<Anchor>(shape.getAnchors())) {

+			if (anchor instanceof BoxRelativeAnchor) {

+				if (anchor.getIncomingConnections().isEmpty()

+						&& anchor.getOutgoingConnections().isEmpty()) {

+					return true;

+				}

+			}

+		}

+		return false;

+	}

+

+	protected abstract void addBoxAnchorSet(Shape container);

+

+	public BoxRelativeAnchor createBoxAnchor(Shape shape, double rw, double rh,

+			int w, int h) {

+		BoxRelativeAnchor boxRelativeAnchor = pe.createBoxRelativeAnchor(shape);

+		// boxRelativeAnchor.setActive(true);

+		boxRelativeAnchor.setRelativeWidth(rw);

+		boxRelativeAnchor.setRelativeHeight(rh);

+		boxRelativeAnchor.setReferencedGraphicsAlgorithm(shape

+				.getGraphicsAlgorithm());

+		final Ellipse ellipse = ga.createEllipse(boxRelativeAnchor);

+		ellipse.setBackground(ga.manageColor(

+				pe.getDiagramForPictogramElement(shape), 195, 195, 240));

+		ellipse.setTransparency(0.3);

+		ellipse.setLineVisible(false);

+		ellipse.setFilled(false);

+		ga.setLocationAndSize(ellipse, 0, 0, w, h);

+		return boxRelativeAnchor;

+	}

+

+	// ----------------------------------------

+	// ----------- Multiple Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.MultipleBox#

+	 * setMultipleInstances(org.eclipse.graphiti.mm.pictograms.ContainerShape,

+	 * org.eclipse.graphiti.features.IFeatureProvider, boolean)

+	 */

+	public void setMultipleInstances(ContainerShape container,

+			IFeatureProvider provider, boolean multipleInstances) {

+		if (multipleInstances) {

+			GraphicsAlgorithm mainShapeGa = container.getGraphicsAlgorithm()

+					.getGraphicsAlgorithmChildren().get(0);

+

+			// Resize main shape

+			this.resize(mainShapeGa, mainShapeGa.getX() + MULTI_INSTANCE_GAP,

+					mainShapeGa.getY(), mainShapeGa.getWidth()

+							- MULTI_INSTANCE_GAP, mainShapeGa.getHeight()

+							- MULTI_INSTANCE_GAP);

+

+			// Create background shape

+			Diagram diagram = Graphiti.getPeService()

+					.getDiagramForPictogramElement(container);

+			GraphicsAlgorithm bgShapeGa = createGraphics(diagram,

+					container.getGraphicsAlgorithm(), 0, MULTI_INSTANCE_GAP,

+					mainShapeGa.getWidth(), mainShapeGa.getHeight());

+			bgShapeGa.setBackground(mainShapeGa.getBackground());

+			bgShapeGa.setForeground(mainShapeGa.getForeground());

+			bgShapeGa.setTransparency(mainShapeGa.getTransparency());

+			bgShapeGa.setStyle(mainShapeGa.getStyle());

+

+			// Synchronize polygons (e.g. rotation, flip)

+			synchronizeMultiInstanceChildren(container);

+

+			// Adapt first level container (relative anchors + invisible shape)

+			createBoxAnchorSet(container);

+			synchronizeFirstLevelShape(container);

+

+			// Adapt position of text field

+			relocateText(mainShapeGa);

+		} else {

+			GraphicsAlgorithm backgroundGa = getMultiInstanceChild(container,

+					false);

+			GraphicsAlgorithm foregroundGa = getMultiInstanceChild(container,

+					true);

+

+			// Remove background shape

+			container.getGraphicsAlgorithm().getGraphicsAlgorithmChildren()

+					.remove(backgroundGa);

+

+			// Resize main shape

+			this.resize(foregroundGa, foregroundGa.getX() - MULTI_INSTANCE_GAP,

+					foregroundGa.getY(), foregroundGa.getWidth()

+							+ MULTI_INSTANCE_GAP, foregroundGa.getHeight()

+							+ MULTI_INSTANCE_GAP);

+

+			// Adapt position of text field

+			relocateText(foregroundGa);

+

+			// Adapt first level container (relative anchors + invisible shape)

+			createBoxAnchorSet(container);

+			synchronizeFirstLevelShape(container);

+		}

+	}

+

+	/**

+	 * Synchronize invisible shape of the first level container (do nothing by

+	 * default).

+	 * 

+	 * @param firstLevelContainer

+	 *            the ContainerShape of the node.

+	 */

+	protected void synchronizeFirstLevelShape(ContainerShape firstLevelContainer) {

+		// synchronize invisible shape of the first level container (do nothing

+		// by default)

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.MultipleNode#

+	 * synchronizeMultiInstanceChildren

+	 * (org.eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public void synchronizeMultiInstanceChildren(

+			ContainerShape firstLevelContainer) {

+		// synchronize foreground and background ga (do nothing by default)

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.MultipleNode#getMultiInstanceChild(org

+	 * .eclipse.graphiti.mm.pictograms.ContainerShape, boolean)

+	 */

+	public GraphicsAlgorithm getMultiInstanceChild(ContainerShape container,

+			boolean main) {

+		GraphicsAlgorithm invisibleGa = container.getGraphicsAlgorithm();

+		if (invisibleGa.getGraphicsAlgorithmChildren().size() > 1) {

+			return invisibleGa.getGraphicsAlgorithmChildren().get(main ? 0 : 1);

+		}

+		return null;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.MultipleBox#

+	 * isMultipleInstances(org.eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public boolean isMultipleInstances(ContainerShape container) {

+		return getMultiInstanceChild(container, false) != null;

+	}

+

+	// ----------------------------------------

+	// ----------- Container Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#getContainerShape(org.

+	 * eclipse.graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public ContainerShape getContainerShape(GraphicsAlgorithm ga) {

+		if (ga.getPictogramElement() != null)

+			return (ContainerShape) ga.getPictogramElement();

+		return this.getContainerShape(ga.getParentGraphicsAlgorithm());

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#isEmpty(org.eclipse.graphiti

+	 * .mm.pictograms.ContainerShape)

+	 */

+	public boolean isEmpty(ContainerShape cs) {

+		return this.getContainedShapes(cs).isEmpty();

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#isHiding(org.eclipse.graphiti

+	 * .mm.pictograms.ContainerShape)

+	 */

+	public boolean isHiding(ContainerShape cs) {

+		for (Shape child : this.getContainedShapes(cs)) {

+			if (child.isVisible())

+				return false;

+		}

+		return true;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#getContainedShapes(org

+	 * .eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public EList<Shape> getContainedShapes(ContainerShape cs) {

+		EList<Shape> results = new BasicEList<Shape>();

+		for (Shape shape : cs.getChildren()) {

+			if (!(shape.getGraphicsAlgorithm() instanceof MultiText))

+				results.add(shape);

+		}

+		return results;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#hideContainedShapes(org

+	 * .eclipse.graphiti.mm.pictograms.ContainerShape, boolean)

+	 */

+	public void hideContainedShapes(ContainerShape cs, boolean hideChildren) {

+		for (Shape child : this.getContainedShapes(cs)) {

+			child.setVisible(!hideChildren);

+			this.hideContainedConnections(child, hideChildren);

+		}

+

+		// Resize node

+		// final ContainerShape container = cs;

+		// final GraphicsAlgorithm containerGa =

+		// container.getGraphicsAlgorithm();

+		// final int adaptedWidth = this.getContainedWidth(cs);

+		// final int adaptedHeight = this.getContainedHeight(cs);

+		// final IFeatureProvider fp =

+		// Util.getActiveEditor().getDiagramTypeProvider().getFeatureProvider();

+		// final TransactionalEditingDomain editingDomain =

+		// this.getEditingDomain();

+		//

+		// editingDomain.getCommandStack().execute(

+		// new RecordingCommand(editingDomain) {

+		// @Override

+		// protected void doExecute() {

+		// if(isWriteTransaction(editingDomain)){

+		// ResizeShapeContext ctx = new ResizeShapeContext(container);

+		// ctx.setX(containerGa.getX());

+		// ctx.setY(containerGa.getY());

+		// ctx.setWidth(adaptedWidth);

+		// ctx.setHeight(adaptedHeight);

+		// IResizeShapeFeature resizeShapeFeature =

+		// fp.getResizeShapeFeature(ctx);

+		// if(resizeShapeFeature.canExecute(ctx))

+		// resizeShapeFeature.execute(ctx);

+		// }

+		// }

+		// }

+		// );

+	}

+

+	private void hideContainedConnections(Shape s, boolean hideChildren) {

+		for (Anchor anchor : s.getAnchors()) {

+			List<Connection> connections = new ArrayList<Connection>();

+			connections.addAll(anchor.getIncomingConnections());

+			connections.addAll(anchor.getOutgoingConnections());

+

+			for (Connection con : connections) {

+				// unhide connection only if both start and end shape is visible

+				if (hideChildren

+						|| (con.getStart().getParent().isVisible() && con

+								.getEnd().getParent().isVisible())) {

+					con.setVisible(!hideChildren);

+					for (ConnectionDecorator conDecorator : con

+							.getConnectionDecorators()) {

+						conDecorator.setVisible(!hideChildren);

+					}

+					if (con instanceof CompositeConnection) {

+						CompositeConnection cc = (CompositeConnection) con;

+						con.setVisible(!hideChildren);

+						for (CurvedConnection conChild : cc.getChildren()) {

+							// TODO setVisible has no effect for composite

+							// connections - why? (workaround via transparency)

+							conChild.setVisible(!hideChildren);

+							conChild.getGraphicsAlgorithm().setTransparency(

+									hideChildren ? 1.0 : 0.0);

+							for (ConnectionDecorator conChildDecorator : conChild

+									.getConnectionDecorators()) {

+								conChildDecorator.setVisible(!hideChildren);

+								conChildDecorator.getGraphicsAlgorithm()

+										.setTransparency(

+												hideChildren ? 1.0 : 0.0);

+							}

+						}

+					}

+				}

+			}

+		}

+

+		// Hide connections of children, unhide connections only if the child

+		// element is visible

+		if (s instanceof ContainerShape) {

+			for (Shape childShape : ((ContainerShape) s).getChildren()) {

+				if (hideChildren || childShape.isVisible())

+					this.hideContainedConnections(childShape, hideChildren);

+			}

+		}

+

+	}

+

+	// private boolean isWriteTransaction(TransactionalEditingDomain domain){

+	// if(domain instanceof TransactionalEditingDomainImpl)

+	// return !((TransactionalEditingDomainImpl)

+	// domain).getActiveTransaction().isReadOnly();

+	// else

+	// return true;

+	// }

+	//

+	// private TransactionalEditingDomain getEditingDomain(){

+	// IWorkbenchPart activePart = PlatformUI.getWorkbench()

+	// .getActiveWorkbenchWindow().getActivePage().getActivePart();

+	//

+	// IEditingDomainProvider provider = (IEditingDomainProvider) activePart

+	// .getAdapter(IEditingDomainProvider.class);

+	// assert provider.getEditingDomain() instanceof TransactionalEditingDomain;

+	// return (TransactionalEditingDomain) provider.getEditingDomain();

+	// }

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#getContainedWidth(org.

+	 * eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public int getContainedWidth(ContainerShape cs) {

+		int result = 0;

+		for (Shape child : this.getContainedShapes(cs)) {

+			if (child.isVisible())

+				result = Math.max(result, child.getGraphicsAlgorithm().getX()

+						+ child.getGraphicsAlgorithm().getWidth());

+		}

+		if (result == 0)

+			return this.getDefaultWidth();

+		return result + CONTAINER_MARGIN;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ContainerNode#getContainedHeight(org

+	 * .eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public int getContainedHeight(ContainerShape cs) {

+		int result = 0;

+		for (Shape child : this.getContainedShapes(cs)) {

+			if (child.isVisible())

+				result = Math.max(result, child.getGraphicsAlgorithm().getY()

+						+ child.getGraphicsAlgorithm().getHeight());

+		}

+		if (result == 0)

+			return this.getDefaultHeight();

+		return result + CONTAINER_MARGIN;

+	}

+

+	// ----------------------------------------

+	// ----------- Named Node -----------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.NamedNode#getText(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public MultiText getText(GraphicsAlgorithm graphicsAlgorithm) {

+		ContainerShape container = this.getContainerShape(graphicsAlgorithm);

+		for (Shape child : container.getChildren()) {

+			if (child.getGraphicsAlgorithm() instanceof MultiText) {

+				return (MultiText) child.getGraphicsAlgorithm();

+			}

+		}

+		return null;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.NamedNode#setTextMargin(int)

+	 */

+	public void setTextMargin(int margin) {

+		this.textMargin = margin;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractPolygonAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractPolygonAlgorithm.java
new file mode 100644
index 0000000..7fbd15c
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractPolygonAlgorithm.java
@@ -0,0 +1,303 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.util.StyleUtil;

+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+

+/**

+ * This abstract class is the super class for all polygon algorithms and

+ * provides common methods for them. For example, there is a general rotate

+ * method and a standard resize method.

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public abstract class AbstractPolygonAlgorithm extends AbstractNode implements

+		PolygonAlgorithm {

+

+	// ----------------------------------------

+	// ----------- Graphics Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#createGraphics(org.eclipse

+	 * .graphiti.mm.pictograms.Diagram,

+	 * org.eclipse.graphiti.mm.GraphicsAlgorithmContainer, int, int, int, int)

+	 */

+	public Polygon createGraphics(Diagram diagram,

+			GraphicsAlgorithmContainer container, int x, int y, int width,

+			int height) {

+

+		// Create polygon

+		Polygon polygon = ga.createPolygon(container,

+				this.getInitialPoints(0, 0, width, height));

+		ga.setLocationAndSize(polygon, x, y, width, height);

+		polygon.setLineWidth(3);

+		polygon.setTransparency(null);

+		polygon.setStyle(StyleUtil.getStyle(diagram, StyleUtil.SHAPE));

+

+		// Create anchors

+		if (container instanceof GraphicsAlgorithm) {

+			ContainerShape containerShape = this.getContainerShape(polygon);

+			pe.createChopboxAnchor(containerShape);

+			createBoxAnchorSet(containerShape);

+		}

+		return polygon;

+	}

+

+	// ----------------------------------------

+	// ----------- Polygon Impl ---------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.PolygonAlgorithm#hasRoundedCorners()

+	 */

+	public boolean hasRoundedCorners() {

+		return false;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractNode#synchronizeFirstLevelShape

+	 * (org.eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public void synchronizeFirstLevelShape(ContainerShape firstLevelContainer) {

+		Polygon firstLevelPolygon = (Polygon) firstLevelContainer

+				.getGraphicsAlgorithm();

+		Polygon secondLevelPolygon;

+		if (isMultipleInstances(firstLevelContainer))

+			secondLevelPolygon = (Polygon) getMultiInstanceChild(

+					firstLevelContainer, true);

+		else

+			secondLevelPolygon = (Polygon) firstLevelPolygon

+					.getGraphicsAlgorithmChildren().get(0);

+		int w = firstLevelPolygon.getWidth();

+		int h = firstLevelPolygon.getHeight();

+

+		int i = 0;

+		Point firstLevelPoint;

+		for (Point secondLevelPoint : secondLevelPolygon.getPoints()) {

+			firstLevelPoint = firstLevelPolygon.getPoints().get(i++);

+

+			// ensure that invisible first level shape has maximum width

+			if (secondLevelPoint.getX() != (w - MultipleNode.MULTI_INSTANCE_GAP))

+				firstLevelPoint.setX(secondLevelPoint.getX());

+			else

+				firstLevelPoint.setX(w);

+

+			// ensure that invisible first level shape has maximum height

+			if (secondLevelPoint.getY() != (h - MultipleNode.MULTI_INSTANCE_GAP))

+				firstLevelPoint.setY(secondLevelPoint.getY());

+			else

+				firstLevelPoint.setY(h);

+

+			firstLevelPoint.setAfter(secondLevelPoint.getAfter());

+			firstLevelPoint.setBefore(secondLevelPoint.getBefore());

+		}

+	}

+

+	// ----------------------------------------

+	// ----------- Rotatable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#rotate90Right(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void rotate90Right(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+		polygon.setX(polygon.getX()

+				+ (polygon.getWidth() - polygon.getHeight()) / 2);

+		polygon.setY(polygon.getY()

+				- (polygon.getWidth() - polygon.getHeight()) / 2);

+		doRotate(polygon);

+	}

+

+	private void doRotate(Polygon polygon) {

+		// Rotate graphicsAlgorithm

+		int oldWidth = polygon.getWidth();

+		int oldHeight = polygon.getHeight();

+		int oldX, oldY;

+		for (Point point : polygon.getPoints()) {

+			oldX = point.getX();

+			oldY = point.getY();

+			point.setX(oldHeight - oldY);

+			point.setY(oldX);

+		}

+

+		// Adapt the size of graphicsAlgorithm

+		polygon.setHeight(oldWidth);

+		polygon.setWidth(oldHeight);

+

+		// Relocate the text shape of the polygon

+		relocateText(polygon);

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = polygon

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Flip polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.doRotate((Polygon) graphicsAlgorithmChildren.get(i));

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(polygon));

+		}

+

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipHorizontally(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipHorizontally(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+

+		// Flip graphicsAlgorithm

+		int width = polygon.getWidth();

+		for (Point point : polygon.getPoints()) {

+			point.setX(width - point.getX());

+		}

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = graphicsAlgorithm

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Flip polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.flipHorizontally(graphicsAlgorithmChildren.get(i));

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(graphicsAlgorithm));

+		}

+

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipVertically(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipVertically(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+

+		// Flip graphicsAlgorithm

+		int height = polygon.getHeight();

+		for (Point point : polygon.getPoints()) {

+			point.setY(height - point.getY());

+		}

+

+		// Relocate the text shape of the polygon

+		relocateText(polygon);

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = graphicsAlgorithm

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Flip polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.flipVertically(graphicsAlgorithmChildren.get(i));

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(graphicsAlgorithm));

+		}

+	}

+

+	// ----------------------------------------

+	// ----------- Resizable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.ResizableNode#resize(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm, int, int, int, int)

+	 */

+	public void resize(GraphicsAlgorithm algorithm, int x, int y, int width,

+			int height) {

+

+		ga.setLocationAndSize(algorithm, x, y, width, height);

+		ContainerShape container = this.getContainerShape(algorithm);

+		resizeBoxAnchorSet(container, x, y, width, height);

+	}

+

+	// ----------------------------------------

+	// ----------- Multiple Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.AbstractNode#

+	 * synchronizeMultiInstanceChildren

+	 * (org.eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public void synchronizeMultiInstanceChildren(

+			ContainerShape firstLevelContainer) {

+		if (isMultipleInstances(firstLevelContainer)) {

+			GraphicsAlgorithm foregroundGa = getMultiInstanceChild(

+					firstLevelContainer, true);

+			GraphicsAlgorithm backgroundGa = getMultiInstanceChild(

+					firstLevelContainer, false);

+

+			if (foregroundGa != null && backgroundGa != null) {

+				if (foregroundGa instanceof Polygon) {

+					Polygon foregroundPolygon = (Polygon) foregroundGa;

+					Polygon backgroundPolygon = (Polygon) backgroundGa;

+					int i = 0;

+					Point backgroundPoint;

+					for (Point mainPoint : foregroundPolygon.getPoints()) {

+						backgroundPoint = backgroundPolygon.getPoints()

+								.get(i++);

+						backgroundPoint.setX(mainPoint.getX());

+						backgroundPoint.setY(mainPoint.getY());

+						backgroundPoint.setAfter(mainPoint.getAfter());

+						backgroundPoint.setBefore(mainPoint.getBefore());

+					}

+				}

+			}

+		}

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractRectangleAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractRectangleAlgorithm.java
new file mode 100644
index 0000000..cd0dcac
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractRectangleAlgorithm.java
@@ -0,0 +1,157 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.MultiText;

+

+/**

+ * This abstract class is the super class for all rectangle algorithms and

+ * provides common methods for them. For example, there is a general rotate

+ * method.

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public abstract class AbstractRectangleAlgorithm extends AbstractNode implements

+		RectangleAlgorithm, RotatableNode {

+

+	// ----------------------------------------

+	// ----------- Named Node -----------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.NamedNode#relocateText(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void relocateText(GraphicsAlgorithm graphicsAlgorithm) {

+		MultiText text = this.getText(graphicsAlgorithm);

+		if (text != null) {

+			int multipleOffset = 0;

+			if (this.isMultipleInstances(this

+					.getContainerShape(graphicsAlgorithm))) {

+				multipleOffset = MULTI_INSTANCE_GAP;

+			}

+			int x = super.textMargin;

+			int width = graphicsAlgorithm.getWidth() - 2 * super.textMargin

+					- multipleOffset;

+			int y = super.textMargin + multipleOffset;

+			int height = graphicsAlgorithm.getHeight() - 2 * super.textMargin

+					- multipleOffset;

+

+			ga.setLocationAndSize(text, x, y, width, height);

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#getAngle(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public int getAngle(GraphicsAlgorithm graphicsAlgorithm) {

+		return 0;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#isFlipped(org.eclipse.

+	 * graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public boolean isFlipped(GraphicsAlgorithm graphicsAlgorithm) {

+		return false;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#rotate90Right(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void rotate90Right(GraphicsAlgorithm graphicsAlgorithm) {

+		translateForRotation(graphicsAlgorithm);

+		doRotate(graphicsAlgorithm);

+		relocateText(graphicsAlgorithm);

+		for (GraphicsAlgorithm algorithm : graphicsAlgorithm

+				.getGraphicsAlgorithmChildren()) {

+			doRotate(algorithm);

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipHorizontally(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipHorizontally(GraphicsAlgorithm graphicsAlgorithm) {

+

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RotatableNode#flipVertically(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void flipVertically(GraphicsAlgorithm graphicsAlgorithm) {

+	}

+

+	/**

+	 * Moves algorithm to the point to simulate rotation around center.

+	 * 

+	 * @param graphicsAlgorithm

+	 *            Algorithm to translate.

+	 */

+	protected void translateForRotation(GraphicsAlgorithm graphicsAlgorithm) {

+		graphicsAlgorithm

+				.setX(graphicsAlgorithm.getX()

+						+ (graphicsAlgorithm.getWidth() - graphicsAlgorithm

+								.getHeight()) / 2);

+		graphicsAlgorithm

+				.setY(graphicsAlgorithm.getY()

+						- (graphicsAlgorithm.getWidth() - graphicsAlgorithm

+								.getHeight()) / 2);

+	}

+

+	/**

+	 * Rotates algorithm by simply switching width and height.

+	 * 

+	 * @param graphicsAlgorithm

+	 *            Algorithm to rotate.

+	 */

+	protected void doRotate(GraphicsAlgorithm graphicsAlgorithm) {

+		int width = graphicsAlgorithm.getWidth();

+		graphicsAlgorithm.setWidth(graphicsAlgorithm.getHeight());

+		graphicsAlgorithm.setHeight(width);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractUPolygonAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractUPolygonAlgorithm.java
new file mode 100644
index 0000000..72ff48a
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AbstractUPolygonAlgorithm.java
@@ -0,0 +1,810 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import java.util.ArrayList;

+import java.util.List;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.MultiText;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+/**

+ * This abstract class collects all methods common to U-shaped polygons.

+ * 

+ * 07 43 xx xx x6xx5x 1xxxx2

+ * 

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public abstract class AbstractUPolygonAlgorithm extends

+		AbstractLPolygonAlgorithm implements UPolygonAlgorithm {

+

+	// ----------------------------------------

+	// ----------- (U)Polygon Impl ------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractLPolygonAlgorithm#getInitialPoints

+	 * (int, int, int, int)

+	 */

+	public List<Point> getInitialPoints(int x, int y, int width, int height) {

+		int outerCornerSize = hasRoundedCorners() ? L_PART_DEFAULT_SIZE / 2 : 0;

+		int innerCornerSize = hasRoundedCorners() ? outerCornerSize * 2 / 3 : 0;

+		List<Point> points = new ArrayList<Point>();

+

+		/* 0 */points.add(ga

+				.createPoint(x, y, outerCornerSize, outerCornerSize));

+		/* 1 */points.add(ga.createPoint(x, y + height, outerCornerSize,

+				outerCornerSize));

+		/* 2 */points.add(ga.createPoint(x + width, y + height,

+				outerCornerSize, outerCornerSize));

+		/* 3 */points.add(ga.createPoint(x + width, y, outerCornerSize,

+				outerCornerSize));

+		/* 4 */points.add(ga.createPoint(x + width - L_PART_DEFAULT_SIZE, y,

+				outerCornerSize, outerCornerSize));

+		/* 5 */points.add(ga.createPoint(x + width - L_PART_DEFAULT_SIZE, y

+				+ height - L_PART_DEFAULT_SIZE, innerCornerSize,

+				innerCornerSize));

+		/* 6 */points.add(ga.createPoint(x + L_PART_DEFAULT_SIZE, y + height

+				- L_PART_DEFAULT_SIZE, innerCornerSize, innerCornerSize));

+		/* 7 */points.add(ga.createPoint(x + L_PART_DEFAULT_SIZE, y,

+				outerCornerSize, outerCornerSize));

+

+		return points;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.polygon.UPolygonAlgorithm#resizeLeftPart(

+	 * org.eclipse.graphiti.mm.algorithms.Polygon, int)

+	 */

+	public void resizeLeftPart(Polygon polygon, int size) {

+		int oldSize = getLeftPartSize(polygon);

+		int sizeDif = size - oldSize;

+		EList<Point> points = polygon.getPoints();

+		if (sizeDif != 0) {

+			switch (getAngle(polygon)) {

+			case 90:

+				points.get(6).setY(points.get(6).getY() + sizeDif);

+				points.get(7).setY(points.get(7).getY() + sizeDif);

+				break;

+			case 180:

+				points.get(6).setX(points.get(6).getX() - sizeDif);

+				points.get(7).setX(points.get(7).getX() - sizeDif);

+				break;

+			case 270:

+				points.get(6).setY(points.get(6).getY() - sizeDif);

+				points.get(7).setY(points.get(7).getY() - sizeDif);

+				break;

+			default:

+				points.get(6).setX(points.get(6).getX() + sizeDif);

+				points.get(7).setX(points.get(7).getX() + sizeDif);

+			}

+		}

+

+		// adapt corner roundings if polygon has rounded corners

+		if (hasRoundedCorners()) {

+			int leftTopCornerSize = getLeftPartTopCornerSize(polygon);

+			int leftBottomCornerSize = getLeftPartBottomCornerSize(polygon);

+

+			points.get(0).setBefore(leftTopCornerSize);

+			points.get(0).setAfter(leftTopCornerSize);

+			points.get(1).setBefore(leftBottomCornerSize);

+			points.get(6).setAfter(leftBottomCornerSize);

+			points.get(7).setBefore(leftTopCornerSize);

+			points.get(7).setAfter(leftTopCornerSize);

+		}

+

+		relocateText(polygon);

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = polygon

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Resize left part of polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.resizeLeftPart((Polygon) graphicsAlgorithmChildren.get(i),

+						size);

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(polygon));

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.polygon.UPolygonAlgorithm#getLeftPartSize

+	 * (org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getLeftPartSize(Polygon polygon) {

+		EList<Point> points = polygon.getPoints();

+		if (isFlattened(polygon))

+			return Math.abs(points.get(7).getY() - points.get(0).getY());

+		else

+			return Math.abs(points.get(7).getX() - points.get(0).getX());

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.graphicsalgorithms.LPolygonAlgorithm#

+	 * resizeBottomPart(org.eclipse.graphiti.mm.algorithms.Polygon, int)

+	 */

+	public void resizeBottomPart(Polygon polygon, int size) {

+		int oldSize = getBottomPartSize(polygon);

+		int sizeDif = isFlipped(polygon) ? oldSize - size : size - oldSize;

+		EList<Point> points = polygon.getPoints();

+		if (sizeDif != 0) {

+			switch (getAngle(polygon)) {

+			case 90:

+				points.get(6).setX(points.get(6).getX() + sizeDif);

+				points.get(5).setX(points.get(5).getX() + sizeDif);

+				break;

+			case 180:

+				points.get(6).setY(points.get(6).getY() + sizeDif);

+				points.get(5).setY(points.get(5).getY() + sizeDif);

+				break;

+			case 270:

+				points.get(6).setX(points.get(6).getX() - sizeDif);

+				points.get(5).setX(points.get(5).getX() - sizeDif);

+				break;

+			default:

+				points.get(6).setY(points.get(6).getY() - sizeDif);

+				points.get(5).setY(points.get(5).getY() - sizeDif);

+			}

+		}

+

+		// adapt corner roundings if polygon has rounded corners

+		if (hasRoundedCorners()) {

+			int bottomLeftCornerSize = getBottomPartLeftCornerSize(polygon);

+			int bottomRightCornerSize = getBottomPartRightCornerSize(polygon);

+

+			points.get(1).setAfter(bottomLeftCornerSize);

+			points.get(2).setBefore(bottomRightCornerSize);

+			points.get(5).setAfter(bottomRightCornerSize);

+			points.get(6).setBefore(bottomLeftCornerSize);

+		}

+

+		relocateText(polygon);

+

+		EList<GraphicsAlgorithm> graphicsAlgorithmChildren = polygon

+				.getGraphicsAlgorithmChildren();

+		for (int i = 0; i < graphicsAlgorithmChildren.size(); i++) {

+			// Resize bottom part of polygon children

+			if (graphicsAlgorithmChildren.get(i) instanceof Polygon)

+				this.resizeBottomPart(

+						(Polygon) graphicsAlgorithmChildren.get(i), size);

+

+			// Update relative anchors when the ga modification is done

+			if (i == graphicsAlgorithmChildren.size() - 1)

+				createBoxAnchorSet(this.getContainerShape(polygon));

+		}

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.UPolygonAlgorithm#getLeftPartTopCornerSize

+	 * (org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getLeftPartTopCornerSize(Polygon polygon) {

+		return getLeftPartSize(polygon) / 2;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.UPolygonAlgorithm#

+	 * getLeftPartBottomCornerSize(org.eclipse.graphiti.mm.algorithms.Polygon)

+	 */

+	public int getLeftPartBottomCornerSize(Polygon polygon) {

+		return getLeftPartTopCornerSize(polygon);

+	}

+

+	// ----------------------------------------

+	// ----------- Resizable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractLPolygonAlgorithm#resize(org

+	 * .eclipse.graphiti.mm.algorithms.GraphicsAlgorithm, int, int, int, int)

+	 */

+	public void resize(GraphicsAlgorithm algorithm, int x, int y, int width,

+			int height) {

+		Polygon polygon = (Polygon) algorithm;

+		int angle = getAngle(polygon);

+		int[] resizeX = new int[4];

+		int[] resizeY = new int[4];

+		if (isFlipped(polygon)) {

+			switch (angle) {

+			case 90:

+				resizeX[0] = 1;

+				resizeX[1] = 2;

+				resizeX[2] = 5;

+				resizeX[3] = 6;

+				resizeY[0] = 2;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 5;

+				break;

+			case 180:

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeX[2] = 6;

+				resizeX[3] = 7;

+				resizeY[0] = 1;

+				resizeY[1] = 2;

+				resizeY[2] = 5;

+				resizeY[3] = 6;

+				break;

+			case 270:

+				resizeX[0] = 0;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 7;

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				resizeY[2] = 6;

+				resizeY[3] = 7;

+				break;

+			default:

+				resizeX[0] = 2;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 5;

+				resizeY[0] = 0;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 7;

+			}

+		} else {

+			switch (angle) {

+			case 90:

+				resizeX[0] = 0;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 7;

+				resizeY[0] = 2;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 5;

+				break;

+			case 180:

+				resizeX[0] = 0;

+				resizeX[1] = 1;

+				resizeX[2] = 6;

+				resizeX[3] = 7;

+				resizeY[0] = 0;

+				resizeY[1] = 3;

+				resizeY[2] = 4;

+				resizeY[3] = 7;

+				break;

+			case 270:

+				resizeX[0] = 1;

+				resizeX[1] = 2;

+				resizeX[2] = 5;

+				resizeX[3] = 6;

+				resizeY[0] = 0;

+				resizeY[1] = 1;

+				resizeY[2] = 6;

+				resizeY[3] = 7;

+				break;

+			default:

+				resizeX[0] = 2;

+				resizeX[1] = 3;

+				resizeX[2] = 4;

+				resizeX[3] = 5;

+				resizeY[0] = 1;

+				resizeY[1] = 2;

+				resizeY[2] = 5;

+				resizeY[3] = 6;

+			}

+		}

+

+		int oldHeight = polygon.getHeight();

+		int oldWidth = polygon.getWidth();

+		int heightDif = height - oldHeight;

+		int widthDif = width - oldWidth;

+

+		EList<Point> points = polygon.getPoints();

+		for (int i = 0; i < resizeX.length; i++) {

+			points.get(resizeX[i]).setX(

+					points.get(resizeX[i]).getX() + widthDif);

+		}

+		for (int i = 0; i < resizeY.length; i++) {

+			points.get(resizeY[i]).setY(

+					points.get(resizeY[i]).getY() + heightDif);

+		}

+

+		// adapt corner roundings if polygon has rounded corners

+		if (hasRoundedCorners()) {

+			int leftTopCornerSize = getLeftPartTopCornerSize(polygon);

+			int leftBottomCornerSize = getLeftPartBottomCornerSize(polygon);

+			int rightTopCornerSize = getRightPartTopCornerSize(polygon);

+			int rightBottomCornerSize = getRightPartBottomCornerSize(polygon);

+			int bottomLeftCornerSize = getBottomPartLeftCornerSize(polygon);

+			int bottomRightCornerSize = getBottomPartRightCornerSize(polygon);

+

+			points.get(0).setBefore(leftTopCornerSize);

+			points.get(0).setAfter(leftTopCornerSize);

+			points.get(1).setBefore(leftBottomCornerSize);

+			points.get(1).setAfter(bottomLeftCornerSize);

+			points.get(2).setBefore(bottomRightCornerSize);

+			points.get(2).setAfter(rightBottomCornerSize);

+			points.get(3).setBefore(rightTopCornerSize);

+			points.get(3).setAfter(rightTopCornerSize);

+			points.get(4).setBefore(rightTopCornerSize);

+			points.get(4).setAfter(rightTopCornerSize);

+			points.get(5).setBefore(rightBottomCornerSize);

+			points.get(5).setAfter(bottomRightCornerSize);

+			points.get(6).setBefore(bottomLeftCornerSize);

+			points.get(6).setAfter(leftBottomCornerSize);

+			points.get(7).setBefore(leftTopCornerSize);

+			points.get(7).setAfter(leftTopCornerSize);

+		}

+

+		ga.setLocationAndSize(polygon, x, y, width, height);

+

+		relocateText(polygon);

+

+		// adapt first level container (relative anchors + invisible shape)

+		ContainerShape container = this.getContainerShape(polygon);

+		createBoxAnchorSet(container);

+		synchronizeFirstLevelShape(container);

+	}

+

+	// ----------------------------------------

+	// ----------- Named Node -----------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.NamedNode#relocateText(org.eclipse.graphiti

+	 * .mm.algorithms.GraphicsAlgorithm)

+	 */

+	public void relocateText(GraphicsAlgorithm graphicsAlgorithm) {

+		Polygon polygon = (Polygon) graphicsAlgorithm;

+		MultiText text = this.getText(graphicsAlgorithm);

+		if (text != null) {

+			int multipleOffset = 0;

+			if (this.isMultipleInstances(this

+					.getContainerShape(graphicsAlgorithm))) {

+				multipleOffset = MULTI_INSTANCE_GAP;

+			}

+			int angle = getAngle(graphicsAlgorithm);

+			int textContainingPartSize;

+			boolean isOnTop = false;

+			switch (angle) {

+			case 90:

+				textContainingPartSize = getRightPartSize(polygon);

+				break;

+			case 270:

+				textContainingPartSize = getLeftPartSize(polygon);

+				break;

+			default:

+				textContainingPartSize = getBottomPartSize(polygon);

+			}

+			if ((isFlipped(graphicsAlgorithm) && angle == 0)

+					|| (!isFlipped(graphicsAlgorithm) && angle == 180)) {

+				isOnTop = true;

+			}

+

+			int x = super.textMargin;

+			int width = graphicsAlgorithm.getWidth() - 2 * super.textMargin

+					- multipleOffset;

+			int y = (isOnTop ? super.textMargin : graphicsAlgorithm.getHeight()

+					- textContainingPartSize + super.textMargin)

+					+ multipleOffset;

+			int height = textContainingPartSize - 2 * super.textMargin

+					- multipleOffset;

+

+			ga.setLocationAndSize(text, x, y, width, height);

+		}

+	}

+

+	// ----------------------------------------

+	// ----------- Anchored Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractLPolygonAlgorithm#addBoxAnchorSet

+	 * (org.eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	protected void addBoxAnchorSet(Shape shape) {

+

+		GraphicsAlgorithm firstLevelPolygon = shape.getGraphicsAlgorithm();

+		Polygon secondLevelPolygon = (Polygon) firstLevelPolygon

+				.getGraphicsAlgorithmChildren().get(0);

+

+		// Sides of the polygon:

+		// 7 3

+		// --- ---

+		// | | | |

+		// | | 6 4 | |

+		// 0 | | 5 | | 2

+		// | ------- |

+		// | |

+		// ---------------

+		// 1

+		int numSides = 8;

+		int lineWidth = getDefaultLineWidth();

+		Point[] point = new Point[numSides];

+		for (int i = 0; i < point.length; i++) {

+			point[i] = secondLevelPolygon.getPoints().get(i);

+		}

+

+		// Offset in case of a multi instance shape (adapt anchors when drawing

+		// background part)

+		double offsetMultiInstance = 0.0d;

+		if (firstLevelPolygon.getWidth() != secondLevelPolygon.getWidth()) {

+			// Remove anchors created when drawing the main part

+			FMCUtil.removeObsoleteAnchors(shape);

+			offsetMultiInstance = MULTI_INSTANCE_GAP;

+		}

+

+		// Length of the sides (not taking into account rounded corners)

+		int[] length = new int[numSides];

+		length[0] = Math.abs(isFlattened(secondLevelPolygon) ? point[2].getX()

+				- point[3].getX() : point[2].getY() - point[3].getY());

+		length[1] = Math.abs(isFlattened(secondLevelPolygon) ? point[1].getY()

+				- point[2].getY() : point[1].getX() - point[2].getX());

+		length[2] = length[0];

+		length[3] = getRightPartSize(secondLevelPolygon) + lineWidth;

+		length[4] = length[2] - getBottomPartSize(secondLevelPolygon);

+		length[6] = length[4];

+		length[7] = getLeftPartSize(secondLevelPolygon) + lineWidth;

+		length[5] = length[1] - length[7] - length[3];

+

+		// Length of the sides that should contain anchors

+		int[] anchoredLength = new int[numSides];

+		for (int i = 0; i < numSides; i++)

+			anchoredLength[i] = Math.max(length[i] - point[i].getAfter()

+					- point[(i + 1) % numSides].getBefore(),

+					DEFAULT_ANCHOR_DIAMETER);

+

+		// Number of anchors of the sides

+		int[] numAnchors = new int[numSides];

+

+		// Gaps between the anchor starting points of the sides (in x and y

+		// direction)

+		double[][] gaps = new double[numSides][2];

+		for (int i = 0; i < gaps.length; i++)

+			for (int j = 0; j < gaps[i].length; j++)

+				gaps[i][j] = 0.0d;

+

+		// Offsets of the starting points of the sides (in x and y direction)

+		double[][] offset = new double[numSides][2];

+		switch (getAngle(secondLevelPolygon)) {

+		case 90:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = offsetMultiInstance;

+				offset[1][1] = 0.0d;

+				offset[1][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[7] + length[5] + offsetMultiInstance;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[7] + length[5];

+				offset[4][0] = offsetMultiInstance;

+				offset[5][1] = length[7] + offsetMultiInstance;

+				offset[5][0] = length[4] - lineWidth;

+				offset[6][1] = length[7] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[6][0] = 0.0d;

+				offset[7][1] = offsetMultiInstance;

+				offset[7][0] = 0.0d;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[4].getAfter())

+					anchoredLength[4] = anchoredLength[4]

+							- (int) Math.abs((offsetMultiInstance - point[4]

+									.getAfter()));

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = offsetMultiInstance;

+				offset[1][1] = offsetMultiInstance;

+				offset[1][0] = 0.0d;

+				offset[2][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[7] + length[5];

+				offset[3][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][1] = length[7] + length[5];

+				offset[4][0] = length[0] - length[4] + offsetMultiInstance;

+				offset[5][1] = length[7];

+				offset[5][0] = length[0] - length[4] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER + lineWidth;

+				offset[6][1] = length[7] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[6][0] = length[0] - length[4] + offsetMultiInstance; // overlapping

+				offset[7][1] = 0.0d;

+				offset[7][0] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[6].getAfter())

+					anchoredLength[6] = anchoredLength[6]

+							- (int) Math.abs((offsetMultiInstance - point[6]

+									.getAfter()));

+			}

+			break;

+		case 180:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][0] = 0.0d;

+				offset[2][1] = offsetMultiInstance;

+				offset[2][0] = 0.0d;

+				offset[3][1] = 0.0d;

+				offset[3][0] = offsetMultiInstance;

+				offset[4][1] = 0.0d;

+				offset[4][0] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][1] = length[4] - lineWidth;

+				offset[5][0] = length[3] + offsetMultiInstance;

+				offset[6][1] = offsetMultiInstance;

+				offset[6][0] = length[3] + length[5];

+				offset[7][1] = 0.0d;

+				offset[7][0] = length[3] + length[5] + offsetMultiInstance;

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = 0.0d;

+				offset[0][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][1] = 0.0d;

+				offset[1][0] = offsetMultiInstance;

+				offset[2][1] = offsetMultiInstance;

+				offset[2][0] = 0.0d;

+				offset[3][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[0] - length[4] + offsetMultiInstance;

+				offset[4][0] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[5][1] = length[0] - length[4] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER + lineWidth;

+				offset[5][0] = length[3] + offsetMultiInstance;

+				offset[6][1] = length[0] - length[4] + offsetMultiInstance;

+				offset[6][0] = length[3] + length[5];

+				offset[7][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[7][0] = length[3] + length[5];

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[4].getAfter())

+					anchoredLength[4] = anchoredLength[4]

+							- (int) Math.abs((offsetMultiInstance - point[4]

+									.getAfter()));

+			}

+			break;

+		case 270:

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[0][0] = 0.0d;

+				offset[1][1] = offsetMultiInstance;

+				offset[1][0] = 0.0d;

+				offset[2][1] = 0.0d;

+				offset[2][0] = offsetMultiInstance;

+				offset[3][1] = 0.0d;

+				offset[3][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][1] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][0] = length[0] - length[4] + offsetMultiInstance;

+				offset[5][1] = length[3] + offsetMultiInstance;

+				offset[5][0] = length[0] - length[4] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER + lineWidth;

+				offset[6][1] = length[3] + length[5];

+				offset[6][0] = length[0] - length[4] + offsetMultiInstance;

+				offset[7][1] = length[3] + length[5];

+				offset[7][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[4].getAfter())

+					anchoredLength[4] = anchoredLength[4]

+							- (int) Math.abs((offsetMultiInstance - point[4]

+									.getAfter()));

+				if (offsetMultiInstance > point[5].getAfter())

+					anchoredLength[5] = anchoredLength[5]

+							- (int) Math.abs((offsetMultiInstance - point[5]

+									.getAfter()));

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[0][0] = 0.0d;

+				offset[1][1] = 0.0d;

+				offset[1][0] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[2][1] = 0.0d;

+				offset[2][0] = offsetMultiInstance;

+				offset[3][1] = offsetMultiInstance;

+				offset[3][0] = 0.0d;

+				offset[4][1] = length[3] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[4][0] = 0.0d;

+				offset[5][1] = length[3] + offsetMultiInstance;

+				offset[5][0] = length[4] - lineWidth;

+				offset[6][1] = length[3] + length[5];

+				offset[6][0] = offsetMultiInstance;

+				offset[7][1] = length[3] + length[5] + offsetMultiInstance;

+				offset[7][0] = 0.0d;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[6].getAfter())

+					anchoredLength[6] = anchoredLength[6]

+							- (int) Math.abs((offsetMultiInstance - point[6]

+									.getAfter()));

+			}

+			break;

+		default: // rotation = 0

+			if (isFlipped(secondLevelPolygon)) {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = offsetMultiInstance;

+				offset[0][0] = 0.0d;

+				offset[1][1] = 0.0d;

+				offset[1][0] = offsetMultiInstance;

+				offset[2][1] = 0.0d;

+				offset[2][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][0] = length[7] + length[5];

+				offset[4][1] = length[0] - length[4] + offsetMultiInstance;

+				offset[4][0] = length[7] + length[5];

+				offset[5][1] = length[0] - length[4] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER + lineWidth;

+				offset[5][0] = length[7];

+				offset[6][1] = length[0] - length[4] + offsetMultiInstance;

+				offset[6][0] = length[7] - DEFAULT_ANCHOR_DIAMETER

+						+ offsetMultiInstance; // overlapping

+				offset[7][1] = length[0] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[7][0] = 0.0d;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[6].getAfter())

+					anchoredLength[6] = anchoredLength[6]

+							- (int) (offsetMultiInstance - point[6].getAfter());

+			} else {

+				// specify relative starting points of polygon line segments

+				offset[0][1] = offsetMultiInstance;

+				offset[0][0] = 0.0d;

+				offset[1][1] = length[2] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[1][0] = 0.0d;

+				offset[2][1] = 0.0d;

+				offset[2][0] = length[1] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[3][1] = 0.0d;

+				offset[3][0] = length[7] + length[5] + offsetMultiInstance;

+				offset[4][1] = offsetMultiInstance;

+				offset[4][0] = length[7] + length[5];

+				offset[5][1] = length[4] - lineWidth;

+				offset[5][0] = length[7] + offsetMultiInstance;

+				offset[6][1] = 0.0d;

+				offset[6][0] = length[7] + offsetMultiInstance

+						- DEFAULT_ANCHOR_DIAMETER;

+				offset[7][1] = 0.0d;

+				offset[7][0] = offsetMultiInstance;

+

+				// adjust length of segments due to overlapping of multi

+				// instances

+				if (offsetMultiInstance > point[5].getAfter())

+					anchoredLength[5] = anchoredLength[5]

+							- (int) (offsetMultiInstance - point[5].getAfter());

+			}

+		}

+

+		// adjust offsets according to rounded corners

+		for (int i = 0; i < numSides; i++) {

+			if (point[i].getX() == point[(i + 1) % numSides].getX()) { // vertical

+				// side

+				offset[i][1] = offset[i][1]

+						+ (point[i].getY() < point[(i + 1) % numSides].getY() ? (point[i]

+								.getAfter() > 0 ? point[i].getAfter()

+								- ((double) DEFAULT_ANCHOR_DIAMETER) / 2 : 0.0d)

+								: (point[(i + 1) % numSides].getBefore() > 0 ? point[(i + 1)

+										% numSides].getBefore()

+										- ((double) DEFAULT_ANCHOR_DIAMETER)

+										/ 2

+										: 0.0d));

+			} else { // horizontal side

+				offset[i][0] = offset[i][0]

+						+ (point[i].getX() < point[(i + 1) % numSides].getX() ? (point[i]

+								.getAfter() > 0 ? point[i].getAfter()

+								- ((double) DEFAULT_ANCHOR_DIAMETER) / 2 : 0.0d)

+								: (point[(i + 1) % numSides].getBefore() > 0 ? point[(i + 1)

+										% numSides].getBefore()

+										- ((double) DEFAULT_ANCHOR_DIAMETER)

+										/ 2

+										: 0.0d));

+			}

+		}

+

+		// Calculate number of anchors per side

+		for (int i = 0; i < numSides; i++)

+			numAnchors[i] = anchoredLength[i] / DEFAULT_ANCHOR_GAP;

+

+		// Calculate gaps between the starting points of the anchors for each

+		// side

+		int direction = 0;

+		for (int i = 0; i < numSides; i++) {

+			direction = isFlattened(secondLevelPolygon) ? (i % 2)

+					: ((i + 1) % 2);

+			gaps[i][direction] = ((double) anchoredLength[i]) / numAnchors[i];

+		}

+

+		// Create relative box anchors

+		for (int i = 0; i < numSides; i++)

+			for (int j = 0; j < numAnchors[i]; j++)

+				createBoxAnchor(shape, (offset[i][0] + j * gaps[i][0])

+						/ firstLevelPolygon.getWidth(), (offset[i][1] + j

+						* gaps[i][1])

+						/ firstLevelPolygon.getHeight(),

+						AnchoredNode.DEFAULT_ANCHOR_GAP,

+						AnchoredNode.DEFAULT_ANCHOR_DIAMETER);

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AgentAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AgentAlgorithm.java
new file mode 100644
index 0000000..f6a1500
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AgentAlgorithm.java
@@ -0,0 +1,27 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+/**

+ * This is the interface for all agent algorithms.

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public interface AgentAlgorithm extends FMCNodeAlgorithm {

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AnchoredNode.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AnchoredNode.java
new file mode 100644
index 0000000..1a23306
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/AnchoredNode.java
@@ -0,0 +1,80 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+/**

+ * This is the interface for all nodes with anchors.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public interface AnchoredNode extends GraphicsNode {

+

+	public static final int DEFAULT_ANCHOR_GAP = 8; // 20;

+	public static final int DEFAULT_ANCHOR_DIAMETER = 8;

+

+	/**

+	 * 

+	 * @param container

+	 * @param visible

+	 */

+	public void setBoxAnchorsVisible(Shape shape, boolean visible);

+

+	/**

+	 * 

+	 * @param shape

+	 * @return

+	 */

+	public boolean isBoxAnchorsVisible(Shape shape);

+

+	/**

+	 * 

+	 * @param shape

+	 * @return

+	 */

+	public boolean hasUnusedAnchors(Shape shape);

+

+	/**

+	 * Resizes the anchor set of the container according to the given

+	 * parameters.

+	 * 

+	 * @param container

+	 * @param x

+	 * @param y

+	 * @param width

+	 * @param height

+	 */

+	public void resizeBoxAnchorSet(ContainerShape container, int x, int y,

+			int width, int height);

+

+	/**

+	 * Creates an anchor set for the shape.

+	 * 

+	 * @param shape

+	 */

+	public void createBoxAnchorSet(Shape shape);

+

+	/**

+	 * Removes the anchor set for the shape. Only removes anchors which have no

+	 * connection lines.

+	 * 

+	 * @param shape

+	 */

+	public void removeUnusedBoxAnchors(Shape shape);

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/ContainerNode.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/ContainerNode.java
new file mode 100644
index 0000000..1616d46
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/ContainerNode.java
@@ -0,0 +1,111 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+

+/**

+ * This is the interface for all nodes potentially containing other nodes. The

+ * graphical representation of the node is constructed as an invisible graphics

+ * algorithm with potentially multiple visible graphics algorithm children.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public interface ContainerNode extends GraphicsNode {

+

+	/**

+	 * Defines the size of the gap between the container and the contained

+	 * element.

+	 */

+	public static final int CONTAINER_MARGIN = 5;

+

+	/**

+	 * Retrieves the shape the provided graphics algorithm is contained in. The

+	 * graphics algorithm can be either the invisible main graphics algorithm of

+	 * the ContainerShape or a nested graphics algorithm.

+	 * 

+	 * @param ga

+	 *            Any graphics algorithm of a ContainerNode.

+	 * @return The ContainerShape of the ContainerNode.

+	 */

+	public ContainerShape getContainerShape(GraphicsAlgorithm ga);

+

+	/**

+	 * Checks whether there are elements contained in the container node.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @return True if the container node does have contained elements.

+	 */

+	public boolean isEmpty(ContainerShape cs);

+

+	/**

+	 * Checks whether the contained elements are hidden.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @return True if the contained elements are hidden.

+	 */

+	public boolean isHiding(ContainerShape cs);

+

+	/**

+	 * Retrieves the list of shapes contained in the container node. Shapes that

+	 * are part of the container node itself (e.g. name, human agent figure) are

+	 * ignored.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @return A list of shapes contained in the container node.

+	 */

+	public EList<Shape> getContainedShapes(ContainerShape cs);

+

+	/**

+	 * Hides or unhides the shapes contained in the container node according to

+	 * the hideChildren parameter.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @param hideChildren

+	 *            Whether the contained shapes should be hidden or not.

+	 */

+	public void hideContainedShapes(ContainerShape cs, boolean hideChildren);

+

+	/**

+	 * Calculates the minimum width the container node should have to show all

+	 * contained elements.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @return The minimum width of the container node when showing all

+	 *         contained elements.

+	 */

+	public int getContainedWidth(ContainerShape cs);

+

+	/**

+	 * Calculates the minimum height the container node should have to show all

+	 * contained elements.

+	 * 

+	 * @param cs

+	 *            The container shape of the container node.

+	 * @return The minimum height of the container node when showing all

+	 *         contained elements.

+	 */

+	public int getContainedHeight(ContainerShape cs);

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithm.java
new file mode 100644
index 0000000..6c18997
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithm.java
@@ -0,0 +1,29 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.fmc.blockdiagram.editor.algorithm.element.FMCElementAlgorithm;

+

+/**

+ * This is the interface for all FMC nodes.

+ * 

+ * @author Heiko Witteborg 

+ * 

+ */

+public interface FMCNodeAlgorithm extends FMCElementAlgorithm, MultipleNode,

+		AnchoredNode, NamedNode, ResizableNode, ContainerNode {

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithmFactory.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithmFactory.java
new file mode 100644
index 0000000..8702a32
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/FMCNodeAlgorithmFactory.java
@@ -0,0 +1,222 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.model.ShapeStyle;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker;

+import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeCheckerFactory;

+import org.eclipse.graphiti.mm.algorithms.Polygon;

+import org.eclipse.graphiti.mm.algorithms.styles.Point;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+/**

+ * This factory produces FMC node algorithms depending on the shape style or an

+ * already existing FMC node instance. The factory is responsible for creating

+ * the appropriate algorithm. This class is singleton.

+ * 

+ * @author Benjamin Schmeling 

+ * @author Heiko Witteborg 

+ * 

+ */

+public class FMCNodeAlgorithmFactory {

+

+	private static FMCNodeAlgorithmFactory instance;

+	private FMCTypeChecker helper = FMCTypeCheckerFactory.getInstance();

+

+	private RectangleStorageAlgorithm storage = null;

+	private HumanAgentAlgorithm humanAgent = null;

+	private RectangleAgentAlgorithm agent = null;

+	private LAgentAlgorithm lAgent = null;

+	private UAgentAlgorithm uAgent = null;

+	private LStorageAlgorithm lStorage = null;

+	private UStorageAlgorithm uStorage = null;

+

+	private FMCNodeAlgorithmFactory() {

+	}

+

+	/**

+	 * Lazy initialization method of this factory.

+	 * 

+	 * @return The singleton instance of this factory.

+	 */

+	public static synchronized FMCNodeAlgorithmFactory getInstance() {

+		if (instance == null) {

+			instance = new FMCNodeAlgorithmFactory();

+		}

+		return instance;

+	}

+

+	private RectangleAgentAlgorithm getAgent() {

+		if (agent == null) {

+			agent = new RectangleAgentAlgorithm();

+		}

+		return agent;

+	}

+

+	public HumanAgentAlgorithm getHumanAgent() {

+		if (humanAgent == null) {

+			humanAgent = new HumanAgentAlgorithm();

+		}

+		return humanAgent;

+	}

+

+	private RectangleStorageAlgorithm getStorage() {

+		if (storage == null) {

+			storage = new RectangleStorageAlgorithm();

+		}

+		return storage;

+	}

+

+	private RectangleStorageAlgorithm getStructureVariance() {

+		if (storage == null) {

+			// TODO own algorithm for structure variances?

+			storage = new RectangleStorageAlgorithm();

+		}

+		return storage;

+	}

+

+	private LAgentAlgorithm getLAgent() {

+		if (lAgent == null) {

+			lAgent = new LAgentAlgorithm();

+		}

+		return lAgent;

+	}

+

+	private UAgentAlgorithm getUAgent() {

+		if (uAgent == null) {

+			uAgent = new UAgentAlgorithm();

+		}

+		return uAgent;

+	}

+

+	private LStorageAlgorithm getLStorage() {

+		if (lStorage == null) {

+			lStorage = new LStorageAlgorithm();

+		}

+		return lStorage;

+	}

+

+	private UStorageAlgorithm getUStorage() {

+		if (uStorage == null) {

+			uStorage = new UStorageAlgorithm();

+		}

+		return uStorage;

+	}

+

+	/**

+	 * Returns the singleton instance of the appropriate agent algorithm.

+	 * 

+	 * @param style

+	 *            The shape style

+	 * 

+	 * @return The AgentAlgorithm appropriate for the given shape style.

+	 */

+	public AgentAlgorithm getAgentByShapestyle(ShapeStyle style) {

+		switch (style) {

+		case L:

+			return getLAgent();

+		case U:

+			return getUAgent();

+		case RECT:

+		default:

+			return getAgent();

+		}

+	}

+

+	/**

+	 * Returns the singleton instance of the appropriate storage algorithm.

+	 * 

+	 * @param style

+	 *            The shape style

+	 * 

+	 * @return The StorageAlgorithm appropriate for the given shape style.

+	 */

+	public StorageAlgorithm getStorageByShapestyle(ShapeStyle style) {

+		switch (style) {

+		case L:

+			return getLStorage();

+		case U:

+			return getUStorage();

+		case RECT:

+		default:

+			return getStorage();

+		}

+	}

+

+	/**

+	 * Returns the appropriate algorithm for the already existing pictogram

+	 * element.

+	 * 

+	 * @param picto

+	 *            The pictogram element to find the algorithm for.

+	 * @return The appropriate FMCNodeAlgorithm instance.

+	 * 

+	 */

+	public FMCNodeAlgorithm getShape(PictogramElement picto) {

+		if (isAgentWithStyle(picto, ShapeStyle.L)) {

+			return getLAgent();

+		} else if (isAgentWithStyle(picto, ShapeStyle.U)) {

+			return getUAgent();

+		} else if (helper.isHumanAgent(picto))

+			return getHumanAgent();

+		else if (helper.isAgent(picto))

+			return getAgent();

+		else if (isStorageWithStyle(picto, ShapeStyle.L)) {

+			return getLStorage();

+		} else if (isStorageWithStyle(picto, ShapeStyle.U)) {

+			return getUStorage();

+		} else if (helper.isStorage(picto))

+			return getStorage();

+		else if (helper.isStructureVariance(picto))

+			return getStructureVariance();

+		return null;

+	}

+

+	private boolean isAgentWithStyle(PictogramElement picto, ShapeStyle style) {

+		if (!helper.isAgent(picto))

+			return false;

+		if (style != ShapeStyle.RECT

+				&& picto.getGraphicsAlgorithm() instanceof Polygon) {

+			Polygon polygon = (Polygon) picto.getGraphicsAlgorithm();

+			EList<Point> points = polygon.getPoints();

+			if (style == ShapeStyle.L && points.size() == 6)

+				return true;

+			else if (style == ShapeStyle.U && points.size() == 8)

+				return true;

+		} else if (style == ShapeStyle.RECT) {

+			return (helper.isAgent(picto));

+		}

+		return false;

+	}

+

+	private boolean isStorageWithStyle(PictogramElement picto, ShapeStyle style) {

+		if (!helper.isStorage(picto))

+			return false;

+		if (style != ShapeStyle.RECT

+				&& picto.getGraphicsAlgorithm() instanceof Polygon) {

+			Polygon polygon = (Polygon) picto.getGraphicsAlgorithm();

+			EList<Point> points = polygon.getPoints();

+			if (style == ShapeStyle.L && points.size() == 6)

+				return true;

+			else if (style == ShapeStyle.U && points.size() == 8)

+				return true;

+		} else if (style == ShapeStyle.RECT) {

+			return helper.isStorage(picto);

+		}

+		return false;

+	}

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/GraphicsNode.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/GraphicsNode.java
new file mode 100644
index 0000000..3fe65f9
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/GraphicsNode.java
@@ -0,0 +1,88 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+

+/**

+ * This is the interface for all graphical nodes.

+ * 

+ * @author Heiko Witteborg

+ * 

+ */

+public interface GraphicsNode {

+

+	/**

+	 * Creates a GraphicsAlgorithm in the given container with the given

+	 * location and size. The graphics will be created depending on the type of

+	 * node.

+	 * 

+	 * @param diagram

+	 *            The diagram the graphics algorithm is added to.

+	 * @param container

+	 *            The container of the newly created graphics algorithm

+	 *            (container shape or parent graphics algorithm).

+	 * @param x

+	 *            The horizontal offset of the newly created graphics algorithm.

+	 * @param y

+	 *            The vertical offset of the newly created graphics algorithm.

+	 * @param width

+	 *            The width of the newly created graphics algorithm.

+	 * @param height

+	 *            The width of the newly created graphics algorithm.

+	 * @return The newly created graphics algorithm.

+	 */

+	public GraphicsAlgorithm createGraphics(Diagram diagram,

+			GraphicsAlgorithmContainer container, int x, int y, int width,

+			int height);

+

+	/**

+	 * Retrieves The default line width of the graphical node.

+	 * 

+	 * @return The default line width of the graphical node.

+	 */

+	public int getDefaultLineWidth();

+

+	/**

+	 * Retrieves the minimum height of the graphical node.

+	 * 

+	 * @return The minimum height of the graphical node.

+	 */

+	public int getMinimumHeight();

+

+	/**

+	 * Retrieves the minimum width of the graphical node.

+	 * 

+	 * @return The minimum width of the graphical node.

+	 */

+	public int getMinimumWidth();

+

+	/**

+	 * Retrieves the default height of the graphical node.

+	 * 

+	 * @return The default height of the graphical node.

+	 */

+	public int getDefaultHeight();

+

+	/**

+	 * Retrieves the default width of the graphical node.

+	 * 

+	 * @return The default width of the graphical node.

+	 */

+	public int getDefaultWidth();

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/HumanAgentAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/HumanAgentAlgorithm.java
new file mode 100644
index 0000000..6f9dda4
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/HumanAgentAlgorithm.java
@@ -0,0 +1,268 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+import java.util.ArrayList;

+

+import org.eclipse.emf.common.util.BasicEList;

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil;

+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;

+import org.eclipse.graphiti.mm.algorithms.Ellipse;

+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;

+import org.eclipse.graphiti.mm.algorithms.Polyline;

+import org.eclipse.graphiti.mm.algorithms.Rectangle;

+import org.eclipse.graphiti.mm.algorithms.styles.Color;

+import org.eclipse.graphiti.mm.pictograms.ContainerShape;

+import org.eclipse.graphiti.mm.pictograms.Diagram;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.mm.pictograms.Shape;

+import org.eclipse.graphiti.services.Graphiti;

+import org.eclipse.graphiti.services.IPeCreateService;

+

+/**

+ * 

+ * @author Benjamin Schmeling

+ * 

+ */

+public class HumanAgentAlgorithm extends RectangleAgentAlgorithm {

+

+	/**

+	 * Changes the type of the agent from human agent to (rectangle) agent,

+	 * removes the next human figure that is found. If there is more than one

+	 * human figure only one is removed.

+	 * 

+	 * @param element

+	 *            The shape containing the human figure.

+	 */

+	public void removeHumanFigure(PictogramElement element) {

+		if (element instanceof ContainerShape) {

+			ContainerShape container = (ContainerShape) element;

+			for (Shape shape : new ArrayList<Shape>(container.getChildren())) {

+				if (shape instanceof ContainerShape

+						&& shape.getGraphicsAlgorithm()

+								.getGraphicsAlgorithmChildren().size() == 5) {

+					container.getChildren().remove(shape);

+					break;

+				}

+			}

+			;

+		}

+	}

+

+	/**

+	 * Checks if the agent is a human agent / has a human figure.

+	 * 

+	 * @param element

+	 *            The shape of the agent.

+	 * @return True if the agent shape contains a human figure.

+	 */

+	public boolean hasHumanFigure(PictogramElement element) {

+		if (element instanceof ContainerShape) {

+			ContainerShape container = (ContainerShape) element;

+			for (Shape shape : new ArrayList<Shape>(container.getChildren())) {

+				if (shape instanceof ContainerShape

+						&& shape.getGraphicsAlgorithm()

+								.getGraphicsAlgorithmChildren().size() == 5) {

+					return true;

+				}

+			}

+			;

+		}

+		return false;

+	}

+

+	/**

+	 * Retrieves the human agent's container shape with the human figure, if

+	 * existing.

+	 * 

+	 * @param element

+	 *            The shape of the agent.

+	 * @return The container shape with the human figure, else null.

+	 */

+	public ContainerShape getHumanFigure(PictogramElement element) {

+		if (element instanceof ContainerShape) {

+			ContainerShape container = (ContainerShape) element;

+			for (Shape shape : new ArrayList<Shape>(container.getChildren())) {

+				if (shape instanceof ContainerShape

+						&& shape.getGraphicsAlgorithm()

+								.getGraphicsAlgorithmChildren().size() == 5) {

+					return (ContainerShape) shape;

+				}

+			}

+			;

+		}

+		return null;

+	}

+

+	/**

+	 * Changes the type of the agent to human agent, adds a human figure.

+	 * 

+	 * @param diag

+	 *            The current Blockdiagram.

+	 * @param container

+	 *            The shape containing the graphics algorithms of the agent.

+	 * @param width

+	 *            The width of the agent.

+	 */

+	public void addHumanFigure(Diagram diag, ContainerShape container, int width) {

+		int startPointX = width / 2 - 12;

+		IPeCreateService pe = Graphiti.getPeCreateService();

+		Color black = ga.manageColor(diag, 0, 0, 0);

+		ContainerShape figure = pe.createContainerShape(container, true);

+

+		int headX = 6;

+		int headSize = 10;

+		int bodyX = headSize;

+		int bodyY = headSize - 1;

+		int bodySize = 18;

+		int lArmX = bodyX + 1;

+		int rArmX = bodyX - 1;

+		int armsY = 18;

+		int armEndX = 13;

+		int armEndY = 9;

+		int legY = headSize * 2 + bodySize - 2;

+		int rLegX = headSize * 2 + 1;

+		int centerOfLegsX = headSize;

+		int centerOfLegsY = -headSize - 1;

+

+		// link(figure, FMCType.HumanAgentIcon);

+		Rectangle invRec = ga.createInvisibleRectangle(figure);

+		ga.setLocationAndSize(invRec, startPointX, 10, 25, bodySize + 2

+				* headSize);

+

+		Ellipse head = ga.createEllipse(invRec);

+		head.setFilled(false);

+		head.setForeground(black);

+		head.setParentGraphicsAlgorithm(invRec);

+		ga.setLocationAndSize(head, headX, 0, headSize, headSize);

+		Polyline leftArm = ga.createPolyline(invRec, new int[] { 0, 0,

+				-armEndX, -armEndY });

+		leftArm.setForeground(black);

+		leftArm.setParentGraphicsAlgorithm(invRec);

+		ga.setLocation(leftArm, lArmX, armsY);

+		Polyline rightArm = ga.createPolyline(invRec, new int[] { 0, 0,

+				armEndX, -armEndY });

+		rightArm.setForeground(black);

+		rightArm.setParentGraphicsAlgorithm(invRec);

+		ga.setLocation(rightArm, rArmX, armsY);

+		Polyline body = ga.createPolyline(invRec,

+				new int[] { 0, 0, 0, bodySize });

+		body.setForeground(black);

+		body.setParentGraphicsAlgorithm(invRec);

+		ga.setLocation(body, bodyX, bodyY);

+		Polyline legs = ga.createPolyline(invRec, new int[] { 0, 0,

+				centerOfLegsX, centerOfLegsY, rLegX, 0 });

+		legs.setForeground(black);

+		legs.setParentGraphicsAlgorithm(invRec);

+		ga.setLocation(legs, 0, legY);

+

+		// Shape headShape = pe.createShape(figure, false);

+		// Ellipse head = ga.createEllipse(headShape);

+		// head.setFilled(false);

+		// head.setForeground(black);

+		// ga.setLocationAndSize(head, headX, 0, headSize, headSize);

+		// Shape leftArmShape = pe.createShape(figure, false);

+		// Polyline leftArm = ga.createPolyline(leftArmShape, new int[] { 0, 0,

+		// -armEndX, -armEndY });

+		// leftArm.setForeground(black);

+		// ga.setLocation(leftArm, lArmX, armsY);

+		// Shape rightArmShape = pe.createShape(figure, false);

+		// Polyline rightArm = ga.createPolyline(rightArmShape, new int[] { 0,

+		// 0,

+		// armEndX, -armEndY });

+		// rightArm.setForeground(black);

+		// ga.setLocation(rightArm, rArmX, armsY);

+		// Shape bodyShape = pe.createShape(figure, false);

+		// Polyline body = ga.createPolyline(bodyShape, new int[] { 0, 0, 0,

+		// bodySize});

+		// body.setForeground(black);

+		// ga.setLocation(body, bodyX, bodyY);

+		// Shape legsShape = pe.createShape(figure, false);

+		// Polyline legs = ga.createPolyline(legsShape, new int[] { 0, 0,

+		// centerOfLegsX, centerOfLegsY,

+		// rLegX, 0 });

+		// legs.setForeground(black);

+		// ga.setLocation(legs, 0, legY);

+	}

+

+	// ----------------------------------------

+	// ----------- Graphics Node --------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RectangleAgentAlgorithm#createGraphics

+	 * (org.eclipse.graphiti.mm.pictograms.Diagram,

+	 * org.eclipse.graphiti.mm.GraphicsAlgorithmContainer, int, int, int, int)

+	 */

+	public GraphicsAlgorithm createGraphics(Diagram diag,

+			GraphicsAlgorithmContainer container, int x, int y, int width,

+			int height) {

+		GraphicsAlgorithm rectangle = super.createGraphics(diag, container, x,

+				y, width, height);

+		if (container instanceof ContainerShape)

+			addHumanFigure(diag, (ContainerShape) container, width);

+		return rectangle;

+	}

+

+	// ----------------------------------------

+	// ----------- Resizable Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.RectangleAgentAlgorithm#resize(org.eclipse

+	 * .graphiti.mm.algorithms.GraphicsAlgorithm, int, int, int, int)

+	 */

+	public void resize(GraphicsAlgorithm algorithm, int x, int y, int width,

+			int height) {

+

+		super.resize(algorithm, x, y, width, height);

+		ContainerShape container = this.getContainerShape(algorithm);

+		removeHumanFigure(container);

+		addHumanFigure(FMCUtil.getActiveEditor().getDiagramTypeProvider()

+				.getDiagram(), container, width);

+	}

+

+	// ----------------------------------------

+	// ----------- Container Node -------------

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see

+	 * org.eclipse.fmc.blockdiagram.editor.node.AbstractNode#getContainedShapes(org.

+	 * eclipse.graphiti.mm.pictograms.ContainerShape)

+	 */

+	public EList<Shape> getContainedShapes(ContainerShape cs) {

+		EList<Shape> results = new BasicEList<Shape>();

+		Shape humanFigureShape = this.getHumanFigure(cs);

+		if (humanFigureShape != null) {

+			for (Shape shape : super.getContainedShapes(cs)) {

+				if (!(shape.equals(humanFigureShape)))

+					results.add(shape);

+			}

+		}

+		return results;

+	}

+

+}

diff --git a/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/LAgentAlgorithm.java b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/LAgentAlgorithm.java
new file mode 100644
index 0000000..8bf70f8
--- /dev/null
+++ b/org.eclipse.fmc.blockdiagram.editor/src/org/eclipse/fmc/blockdiagram/editor/algorithm/node/LAgentAlgorithm.java
@@ -0,0 +1,87 @@
+/*******************************************************************************

+ * <copyright>

+ *

+ * Copyright (c) 2013, 2013 SAP AG.

+ * 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:

+ *    SAP AG - initial API, implementation and documentation

+ *

+ * </copyright>

+ *

+ *******************************************************************************/

+package org.eclipse.fmc.blockdiagram.editor.algorithm.node;

+

+/**

+ * This class encapsulates all operations on a LShape Agent.

+ * 

+ * @author Benjamin Schmeling

+ * @author Heiko Witteborg 

+ * 

+ */

+public class LAgentAlgorithm extends AbstractLPolygonAlgorithm implements

+		AgentAlgorithm {

+

+	// ----------------------------------------

+	// ----------- Graphics Node --------------

+

+	public static final int LAGENT_MINIMUM_WIDTH = 30;

+	public static final int LAGENT_MINIMUM_HEIGHT = 30;

+	public static final int LAGENT_DEFAULT_WIDTH = 60;

+	public static final int LAGENT_DEFAULT_HEIGHT = 70;

+	public static final int LAGENT_DEFAULT_LINEWIDTH = 3;

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getMinimumHeight()

+	 */

+	public int getMinimumHeight() {

+		return LAGENT_MINIMUM_HEIGHT;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getMinimumWidth()

+	 */

+	public int getMinimumWidth() {

+		return LAGENT_MINIMUM_WIDTH;

+	}

+

+	@Override

+	/*

+	 * (non-Javadoc)

+	 * 

+	 * @see org.eclipse.fmc.blockdiagram.editor.node.GraphicsNode#getDefaultHeight()

+	 */

+	public int getDefaultHeight() {