Initial Code Contribution
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..98f5e58
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+target/
+src-gen/
+xtend-gen/
+bin/
+.antlr*
+.metadata/
+*/plugin.xml_gen
+.DS_Store
+
+
+/.project
+*.checkstyle
diff --git a/CONTRIBUTING b/CONTRIBUTING
new file mode 100644
index 0000000..dd15cb6
--- /dev/null
+++ b/CONTRIBUTING
@@ -0,0 +1,39 @@
+Contributing to Eclipse Vorto
+=================================
+
+Thanks for your interest in this project.
+
+Project description:
+--------------------
+
+The Eclipse Vorto project is a toolset which allows you to define the structure and semantics of IoT devices using a simple DSL for which you can plug in custom code generators to generate executable device specific code.
+
+- http://www.eclipse.org/vorto/
+
+Developer resources:
+--------------------
+
+Information regarding source code management, builds, coding standards, and more.
+
+- http://www.eclipse.org/vorto/community.html#HowToContribute
+
+Contributor License Agreement:
+------------------------------
+
+Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).
+
+- http://www.eclipse.org/legal/CLA.php
+
+Search for bugs:
+----------------
+
+This project uses Bugzilla to track ongoing development and issues.
+
+- https://bugs.eclipse.org/bugs/buglist.cgi?product=Vorto
+
+Create a new bug:
+-----------------
+
+Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
+
+- https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Vorto
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..99d475f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,198 @@
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation
+ distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+ i) changes to the Program, and
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are
+ distributed by that particular Contributor. A Contribution 'originates' from
+ a Contributor if it was added to the Program by such Contributor itself or
+ anyone acting on such Contributor's behalf. Contributions do not include
+ additions to the Program which: (i) are separate modules of software
+ distributed in conjunction with the Program under their own license
+ agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
+ reproduce, prepare derivative works of, publicly display, publicly perform,
+ distribute and sublicense the Contribution of such Contributor, if any, and
+ such derivative works, in source code and object code form.
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
+ Recipient a non-exclusive, worldwide, royalty-free patent license under
+ Licensed Patents to make, use, sell, offer to sell, import and otherwise
+ transfer the Contribution of such Contributor, if any, in source code and
+ object code form. This patent license shall apply to the combination of the
+ Contribution and the Program if, at the time the Contribution is added by
+ the Contributor, such addition of the Contribution causes such combination
+ to be covered by the Licensed Patents. The patent license shall not apply
+ to any other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+ c) Recipient understands that although each Contributor grants the licenses to
+ its Contributions set forth herein, no assurances are provided by any
+ Contributor that the Program does not infringe the patent or other
+ intellectual property rights of any other entity. Each Contributor
+ disclaims any liability to Recipient for claims brought by any other entity
+ based on infringement of intellectual property rights or otherwise. As a
+ condition to exercising the rights and licenses granted hereunder, each
+ Recipient hereby assumes sole responsibility to secure any other
+ intellectual property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the Program, it
+ is Recipient's responsibility to acquire that license before distributing
+ the Program.
+ d) Each Contributor represents that to its knowledge it has sufficient
+ copyright rights in its Contribution, if any, to grant the copyright
+ license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+ b) its license agreement:
+ i) effectively disclaims on behalf of all Contributors all warranties and
+ conditions, express and implied, including warranties or conditions of
+ title and non-infringement, and implied warranties or conditions of
+ merchantability and fitness for a particular purpose;
+ ii) effectively excludes on behalf of all Contributors all liability for
+ damages, including direct, indirect, special, incidental and
+ consequential damages, such as lost profits;
+ iii) states that any provisions which differ from this Agreement are offered
+ by that Contributor alone and not by any other party; and
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+ b) a copy of this Agreement must be included with each copy of the Program.
+ Contributors may not remove or alter any copyright notices contained within
+ the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement , including but not limited to the risks and costs
+of program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+(excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
+may assign the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions) may always
+be distributed subject to the version of the Agreement under which it was
+received. In addition, after a new version of the Agreement is published,
+Contributor may elect to distribute the Program (including its Contributions)
+under the new version. Except as expressly stated in Sections 2(a) and 2(b)
+above, Recipient receives no rights or licenses to the intellectual property of
+any Contributor under this Agreement, whether expressly, by implication,
+estoppel or otherwise. All rights in the Program not expressly granted under
+this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.codegen/.classpath b/bundles/org.eclipse.vorto.codegen/.classpath
new file mode 100644
index 0000000..dec9bf2
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <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="icons"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.vorto.codegen/.gitignore b/bundles/org.eclipse.vorto.codegen/.gitignore
new file mode 100644
index 0000000..85e109c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/.gitignore
@@ -0,0 +1,3 @@
+/.settings
+/bin
+/xtend-gen
diff --git a/bundles/org.eclipse.vorto.codegen/.project b/bundles/org.eclipse.vorto.codegen/.project
new file mode 100644
index 0000000..dfb1c63
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.codegen</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <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>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.codegen/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.codegen/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3c0e5cd
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Code-Generation Infrastructure
+Bundle-SymbolicName: org.eclipse.vorto.codegen;singleton:=true
+Bundle-Version: 0.1.0
+Bundle-Activator: org.eclipse.vorto.codegen.Activator
+Bundle-Vendor: Bosch-SI
+Require-Bundle: org.eclipse.vorto.common,
+ org.eclipse.vorto.metamodel,
+ org.apache.log4j;bundle-version="1.2.0",
+ org.eclipse.core.runtime;bundle-version="3.9.0",
+ org.eclipse.jdt.core;bundle-version="3.9.0",
+ org.eclipse.jdt.launching;bundle-version="3.7.0",
+ org.eclipse.ui.workbench;bundle-version="3.105.0",
+ org.eclipse.jface;bundle-version="3.9.0",
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.xtend.lib;bundle-version="[2.7.0,3.0.0)",
+ org.apache.commons.lang3;bundle-version="3.1.0",
+ org.apache.commons.io;bundle-version="2.0.1"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.vorto.codegen,
+ org.eclipse.vorto.codegen.api,
+ org.eclipse.vorto.codegen.api.tasks,
+ org.eclipse.vorto.codegen.api.tasks.eclipse
+Bundle-ClassPath: icons/,
+ .
diff --git a/bundles/org.eclipse.vorto.codegen/about.html b/bundles/org.eclipse.vorto.codegen/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.codegen/build.properties b/bundles/org.eclipse.vorto.codegen/build.properties
new file mode 100644
index 0000000..d1bab99
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/build.properties
@@ -0,0 +1,10 @@
+source.. = src/,\
+ xtend-gen/,\
+ icons/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ schema/,\
+ about.html
diff --git a/bundles/org.eclipse.vorto.codegen/icons/generate.gif b/bundles/org.eclipse.vorto.codegen/icons/generate.gif
new file mode 100644
index 0000000..0a44550
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/icons/generate.gif
Binary files differ
diff --git a/bundles/org.eclipse.vorto.codegen/icons/start.gif b/bundles/org.eclipse.vorto.codegen/icons/start.gif
new file mode 100644
index 0000000..57f4102
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/icons/start.gif
Binary files differ
diff --git a/bundles/org.eclipse.vorto.codegen/plugin.xml b/bundles/org.eclipse.vorto.codegen/plugin.xml
new file mode 100644
index 0000000..b136759
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/plugin.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org_eclipse_vorto_codegen_Generators" name="Generator" schema="schema/org_eclipse_vorto_codegen_Generators.exsd"/>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:generate.code.submenu">
+ <dynamic
+ class="org.eclipse.vorto.codegen.internal.extensioninterface.PopulateGeneratorsMenu"
+ id="org.eclipse.vorto.codegen.dynamic.menu.contribution.item.id">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ id="org.eclipse.vorto.codegen.generator.category"
+ name="Generators Category">
+ </category>
+ <command
+ categoryId="org.eclipse.vorto.codegen.generator.category"
+ id="org.eclipse.vorto.codegen.generator.command.id"
+ name="Populate All Generators">
+ <commandParameter
+ id="org.eclipse.vorto.codegen.generator.commandParameter"
+ name="Generartor Class name"
+ optional="true">
+ </commandParameter>
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.vorto.codegen.internal.handler.EvaluateContributionsHandler"
+ commandId="org.eclipse.vorto.codegen.generator.command.id">
+ </handler>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.vorto.project.menu">
+ <menu
+ icon="icons/start.gif"
+ id="generate.code.submenu"
+ label="Generate Code">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.vorto.codegen.generatemenu.id">
+ </reference>
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.vorto.perspectives.vortotreeview">
+ <menu
+ icon="icons/start.gif"
+ id="generate.code.submenu"
+ label="Generate Code">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.vorto.m2mtreeview.codegen.generatemenu.id">
+ </reference>
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.eclipse.vorto.codegen.generatemenu.id">
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.vorto.iotnature">
+ </test>
+ </adapt>
+ </iterate>
+ </with>
+ </definition>
+ <definition
+ id="org.eclipse.vorto.m2mtreeview.codegen.generatemenu.id">
+ <with
+ variable="activeMenuSelection">
+ <count
+ value="1">
+ </count>
+ </with>
+ </definition>
+ </extension>
+
+</plugin>
diff --git a/bundles/org.eclipse.vorto.codegen/pom.xml b/bundles/org.eclipse.vorto.codegen/pom.xml
new file mode 100644
index 0000000..7e5e76a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/pom.xml
@@ -0,0 +1,125 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.codegen</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Vorto Code Generator</name>
+
+ <profiles>
+ <profile>
+ <id>copy-plugins</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-kepler</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.codegen</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${kepler.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-luna</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.codegen</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${luna.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-visualrules</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.codegen</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${visualrules.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.4.1</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>xtend-gen</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/bundles/org.eclipse.vorto.codegen/schema/org_eclipse_vorto_codegen_Generators.exsd b/bundles/org.eclipse.vorto.codegen/schema/org_eclipse_vorto_codegen_Generators.exsd
new file mode 100644
index 0000000..e2a0f12
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/schema/org_eclipse_vorto_codegen_Generators.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.vorto.codegen" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.vorto.codegen" id="org_eclipse_vorto_codegen_Generators" name="Generator"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <choice>
+ <element ref="client" minOccurs="1" maxOccurs="unbounded"/>
+ </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="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.vorto.codegen.CodeGenerator"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="menuLabel" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="resource"/>
+ </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/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/Activator.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/Activator.java
new file mode 100644
index 0000000..e87320f
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/Activator.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen;
+
+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.vorto.codegen"; //$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)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ initialize();
+ }
+
+ public static void initialize() {
+ plugin = new Activator();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ deinitialize();
+ super.stop(context);
+ }
+
+ public static void deinitialize() {
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/FileWritingStrategyFactory.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/FileWritingStrategyFactory.java
new file mode 100644
index 0000000..4ff1753
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/FileWritingStrategyFactory.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api;
+
+import org.eclipse.vorto.codegen.internal.OverWritingStrategy;
+import org.eclipse.vorto.codegen.internal.WriteGenOverWriteStrategy;
+
+/**
+ * Factory for getting a file writer strategy for a code generator
+ *
+ *
+ *
+ */
+public final class FileWritingStrategyFactory {
+
+ private static FileWritingStrategyFactory instance = null;
+
+ private FileWritingStrategyFactory() {
+
+ }
+
+ public static FileWritingStrategyFactory getInstance() {
+ if (instance == null) {
+ instance = new FileWritingStrategyFactory();
+ }
+ return instance;
+ }
+
+ /**
+ * @return strategy which overwrites a previously generated file.
+ */
+ public IFileWritingStrategy getOverwriteStrategy() {
+ return new OverWritingStrategy();
+ }
+
+ /**
+ * @return strategy which creates a *.gen file which the latest content. The
+ * user must then do a manual merge.
+ */
+ public IFileWritingStrategy getGenFileStrategy() {
+ return new WriteGenOverWriteStrategy();
+ }
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/ICodeGenerator.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/ICodeGenerator.java
new file mode 100644
index 0000000..a92928e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/ICodeGenerator.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+/**
+ * This Code Generator generates platform specific code for the function block
+ * model which can be executed in a target environment.
+ *
+ *
+ *
+ */
+public interface ICodeGenerator {
+
+ static final String GENERATOR_ID = "org.eclipse.vorto.codegen.org_eclipse_vorto_codegen_Generators";
+
+ /**
+ * Generates environment specific code for a given function block model
+ *
+ * @param model
+ * Function block model instance which contains the semantics of
+ * parts of an abstract device
+ * @param monitor
+ * callback to monitor steps during the generation process
+ */
+ void generate(FunctionblockModel model, IProgressMonitor monitor);
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IFileWritingStrategy.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IFileWritingStrategy.java
new file mode 100644
index 0000000..bb44486
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IFileWritingStrategy.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+
+/**
+ * Writes the {@link Generated} produced by the {@link ICodeGenerator} in a
+ * custom way
+ *
+ * Available strategies:
+ * <ul>
+ * <li>{@link FileWritingStrategyFactory#getGenFileStrategy()}</li>
+ * <li>{@link FileWritingStrategyFactory#getOverwriteStrategy()}</li>
+ * </ul>
+ *
+ *
+ *
+ */
+public interface IFileWritingStrategy {
+
+ /**
+ * Decides over how to write the specified generated content.
+ *
+ * @param generated
+ * generated content
+ * @param existingFile
+ * generated file and content from a previous generation
+ * @throws CoreException
+ * @throws IOException
+ */
+ void writeFile(Generated generated, IFile existingFile)
+ throws CoreException, IOException;
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IProjectGenerator.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IProjectGenerator.java
new file mode 100644
index 0000000..34fb735
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/IProjectGenerator.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api;
+
+import org.eclipse.core.resources.IProject;
+
+/**
+ * This generator generates an Eclipse {@link IProject}
+ *
+ *
+ *
+ */
+public interface IProjectGenerator extends ICodeGenerator {
+
+ /**
+ * All eclipse project generator should implement this method to get the end
+ * result project
+ *
+ * @return eclipse project that has been generated
+ */
+ IProject getProject();
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/AbstractTemplateGeneratorTask.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/AbstractTemplateGeneratorTask.java
new file mode 100644
index 0000000..769b991
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/AbstractTemplateGeneratorTask.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks;
+
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+import org.eclipse.vorto.codegen.api.tasks.IOutputter;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public abstract class AbstractTemplateGeneratorTask implements
+ ICodeGeneratorTask {
+
+ public void generate(final FunctionblockModel model,
+ final IOutputter outputter) {
+
+ Generated generated = new Generated(getFileName(model), getPath(model),
+ getTemplate().getContent(model));
+ outputter.output(generated);
+ }
+
+ abstract public String getFileName(final FunctionblockModel model);
+
+ abstract public String getPath(final FunctionblockModel model);
+
+ /**
+ * @return Tempalte to be used for Generation
+ */
+ abstract public ITemplate getTemplate();
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/Generated.xtend b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/Generated.xtend
new file mode 100644
index 0000000..f4aa7f9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/Generated.xtend
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.codegen.api.tasks;
+
+class Generated {
+ public static final String ROOT_FOLDER_PATH = null;
+
+ String fileName;
+ String folderPath;
+ String content;
+
+ new(String fileName, String folderPath, String content) {
+ this.fileName = fileName;
+ this.folderPath = folderPath;
+ this.content = content;
+ }
+
+ def String getFileName() {
+ return fileName;
+ }
+
+ def String getFolderPath() {
+ return folderPath;
+ }
+
+ def String getContent() {
+ return content;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/GeneratorConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/GeneratorConfiguration.java
new file mode 100644
index 0000000..3fbe7d1
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/GeneratorConfiguration.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks;
+
+import org.eclipse.vorto.codegen.api.IProjectGenerator;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.ClasspathConfiguration;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.ConfigurationContainer;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.IEclipseProjectConfiguration;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.EclipseProjectGenerator;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.FolderModule;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.LocationWrapper;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.MavenNatureConfiguration;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.NatureConfiguration;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+
+/**
+ * Creates a configuration for a Code Generator
+ *
+ *
+ *
+ */
+public class GeneratorConfiguration {
+
+ /**
+ * Creates a Generator Task for the Generation of an Eclipse Project.
+ * Returned generator can be executed with
+ * {@link IProjectGenerator#generate(org.eclipse.vorto.functionblock.FunctionblockModel, org.eclipse.core.runtime.IProgressMonitor)}
+ *
+ * Example: eclipseProject('myproject',configuration(mavenNature(new
+ * MyPomTemplate())),new MyCustomGeneratorTask(),
+ * MyOtherCustomGeneratorTask())
+ *
+ * @param projectName
+ * target eclipse project name
+ * @param configuration
+ * configurations for the project
+ * @param tasks
+ * custom code generation tasks
+ *
+ * @return fully configured eclipse project generator.
+ */
+ public static IProjectGenerator eclipseProject(String projectName,
+ ConfigurationContainer configuration, ICodeGeneratorTask... tasks) {
+ return new EclipseProjectGenerator(projectName, configuration, tasks);
+ }
+
+ /**
+ * Creates a Generator Task for the Generation of an Eclipse Project.
+ * Returned generator can be executed with
+ * {@link IProjectGenerator#generate(org.eclipse.vorto.functionblock.FunctionblockModel, org.eclipse.core.runtime.IProgressMonitor)}
+ *
+ * Example: eclipseProject('myproject',configuration(mavenNature(new
+ * MyPomTemplate())),new MyCustomGeneratorTask(),
+ * MyOtherCustomGeneratorTask())
+ *
+ * @param location
+ * custom location specific setting for the target project
+ * @param configuration
+ * configurations for the project
+ * @param tasks
+ * custom code generation tasks
+ *
+ * @return fully configured eclipse project generator.
+ */
+ public static IProjectGenerator eclipseProject(LocationWrapper location,
+ ConfigurationContainer configuration,
+ ICodeGeneratorTask... generators) {
+ return new EclipseProjectGenerator(location, configuration, generators);
+ }
+
+ /**
+ * Eclipse configurations for the project, like nature(s) or classpath
+ * variables etc.
+ *
+ * @param configurations
+ * a list of configurations
+ * @return
+ */
+ public static ConfigurationContainer configuration(
+ IEclipseProjectConfiguration... configurations) {
+ return new ConfigurationContainer(configurations);
+ }
+
+ /**
+ * @return an empty configuration for a project.
+ */
+ public static ConfigurationContainer empty() {
+ return new ConfigurationContainer();
+ }
+
+ /**
+ * Makes the eclipse project a java project
+ *
+ * @param configurations
+ * additional configurations for the java project
+ * @return
+ */
+ public static IEclipseProjectConfiguration javaNature(
+ IEclipseProjectConfiguration... configurations) {
+ return new NatureConfiguration("org.eclipse.jdt.core.javanature",
+ configurations);
+ }
+
+ /**
+ * Makes the project a xText project
+ *
+ * @param configurations
+ * additional configurations for the xText project
+ * @return
+ */
+ public static IEclipseProjectConfiguration xtextNature(
+ IEclipseProjectConfiguration... configurations) {
+ return new NatureConfiguration(
+ "org.eclipse.xtext.ui.shared.xtextNature", configurations);
+ }
+
+ /**
+ * Makes the project a Maven project
+ *
+ * @param pom
+ * maven build file template
+ * @param configurations
+ * additional configurations for the maven project
+ * @return
+ */
+ public static IEclipseProjectConfiguration mavenNature(ITemplate pom,
+ IEclipseProjectConfiguration... configurations) {
+ return new MavenNatureConfiguration(pom, javaNature());
+ }
+
+ /**
+ * Creates the specified folder(s) for the eclipse project
+ *
+ * @param folders
+ * a list of folder names, like model or src-gen/model
+ * @return
+ */
+ public static ICodeGeneratorTask folders(String... folders) {
+ return new FolderModule(folders);
+ }
+
+ /**
+ * Makes the specified folder(s) source folders for the project
+ *
+ * @param sourceFolders
+ * a list of folder names, like model or target/generated-sources
+ * @return
+ */
+ public static IEclipseProjectConfiguration sourceFolders(
+ String... sourceFolders) {
+ return new ClasspathConfiguration(sourceFolders);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ICodeGeneratorTask.xtend b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ICodeGeneratorTask.xtend
new file mode 100644
index 0000000..ad24d66
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ICodeGeneratorTask.xtend
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.codegen.api.tasks;
+
+import org.eclipse.vorto.functionblock.FunctionblockModel
+
+
+interface ICodeGeneratorTask {
+
+ /**
+ * Generates code from the specified function block model and sends it to the specified outputter
+ */
+ def void generate(FunctionblockModel model, IOutputter outputter);
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/IOutputter.xtend b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/IOutputter.xtend
new file mode 100644
index 0000000..664675a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/IOutputter.xtend
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+ package org.eclipse.vorto.codegen.api.tasks;
+
+import org.eclipse.vorto.codegen.api.IFileWritingStrategy
+
+/**
+ * Outputter for generated content produced by the {@link CodeGenerator}
+ *
+ *
+ *
+ */
+interface IOutputter {
+
+ /**
+ * Outputs the specified generated artifact
+ */
+ def void output(Generated generated);
+
+ /**
+ * Sets the strategy for file writing for generated artifact
+ */
+ def void setFileWritingStrategy(IFileWritingStrategy fileWritingHandler);
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ITemplate.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ITemplate.java
new file mode 100644
index 0000000..6b801ef
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/ITemplate.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks;
+
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public interface ITemplate {
+
+ /**
+ * gets the template content as a string
+ *
+ * @param context
+ * @return
+ */
+ String getContent(FunctionblockModel context);
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/AbstractConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/AbstractConfiguration.java
new file mode 100644
index 0000000..0a78b92
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/AbstractConfiguration.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+
+
+public abstract class AbstractConfiguration implements
+ IEclipseProjectConfiguration {
+
+ @Override
+ public List<ICodeGeneratorTask> getGeneratorTasks() {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ClasspathConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ClasspathConfiguration.java
new file mode 100644
index 0000000..627ac21
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ClasspathConfiguration.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+
+/**
+ * Configures the classpath and source folders for a Java Project
+ *
+ *
+ *
+ */
+public class ClasspathConfiguration extends AbstractConfiguration {
+
+ private String[] sourceFolders = new String[0];
+
+ public ClasspathConfiguration(String... sourceFolders) {
+ this.sourceFolders = sourceFolders;
+ }
+
+ @Override
+ public IEclipseProjectConfiguration configure(IProject project) {
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ javaProject.setRawClasspath(getClasspathEntries(project),
+ new NullProgressMonitor());
+ javaProject.setOutputLocation(project.getFolder("target")
+ .getFullPath(), new NullProgressMonitor());
+ } catch (JavaModelException e1) {
+ }
+
+ return this;
+ }
+
+ private IClasspathEntry[] getClasspathEntries(IProject project) {
+
+ IClasspathEntry[] newEntries = new IClasspathEntry[sourceFolders.length + 1];
+
+ for (int i = 0; i < sourceFolders.length; i++) {
+ newEntries[i] = JavaCore.newSourceEntry(project.getFolder(
+ sourceFolders[i]).getFullPath());
+ }
+
+ newEntries[sourceFolders.length] = getVmClasspathEntry();
+
+ return newEntries;
+ }
+
+ private IClasspathEntry getVmClasspathEntry() {
+ IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
+ IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
+ IPath vmPath = containerPath.append(
+ vmInstall.getVMInstallType().getId()).append(
+ vmInstall.getName());
+ return JavaCore.newContainerEntry(vmPath);
+
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ConfigurationContainer.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ConfigurationContainer.java
new file mode 100644
index 0000000..200441a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ConfigurationContainer.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+
+/**
+ * Container for different eclipse project configurations
+ *
+ *
+ *
+ */
+public class ConfigurationContainer implements IEclipseProjectConfiguration {
+
+ private IEclipseProjectConfiguration[] configurations = new IEclipseProjectConfiguration[0];
+
+ public ConfigurationContainer(IEclipseProjectConfiguration... configurations) {
+ if (configurations != null) {
+ this.configurations = configurations;
+ }
+ }
+
+ @Override
+ public IEclipseProjectConfiguration configure(IProject project) {
+ for (IEclipseProjectConfiguration configuration : configurations) {
+ configuration.configure(project);
+ }
+ return this;
+ }
+
+ @Override
+ public List<ICodeGeneratorTask> getGeneratorTasks() {
+ List<ICodeGeneratorTask> modules = new ArrayList<ICodeGeneratorTask>();
+ for (IEclipseProjectConfiguration configuration : configurations) {
+ modules.addAll(configuration.getGeneratorTasks());
+ }
+ return modules;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/EclipseProjectGenerator.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/EclipseProjectGenerator.java
new file mode 100644
index 0000000..0f2cc6b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/EclipseProjectGenerator.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+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.SubProgressMonitor;
+import org.eclipse.vorto.codegen.api.IProjectGenerator;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+import org.eclipse.vorto.codegen.api.tasks.eclipse.ProjectFileOutputter;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+/**
+ * Code Generator which generates an Eclipse project
+ *
+ *
+ *
+ */
+public class EclipseProjectGenerator implements IProjectGenerator {
+
+ private ConfigurationContainer configuration;
+
+ private List<ICodeGeneratorTask> tasks = new ArrayList<ICodeGeneratorTask>();
+
+ private IProject project;
+
+ private LocationWrapper locationW;
+
+ public EclipseProjectGenerator(LocationWrapper location,
+ ConfigurationContainer configuration, ICodeGeneratorTask... tasks) {
+ this.locationW = location;
+ this.configuration = configuration;
+ this.tasks.addAll(Arrays.asList(tasks));
+ }
+
+ public EclipseProjectGenerator(String projectName,
+ ConfigurationContainer configuration, ICodeGeneratorTask[] tasks) {
+ String rootWorkspace = ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation().toString();
+ this.locationW = new LocationWrapper(rootWorkspace, projectName);
+ this.configuration = configuration;
+ this.tasks.addAll(Arrays.asList(tasks));
+ }
+
+ public void generate(FunctionblockModel model, IProgressMonitor monitor) {
+ project = getWorkspace().getProject(locationW.getProjectName());
+
+ if (!project.exists()) {
+ try {
+ project = createProjectInWorkspace(monitor);
+ project.open(monitor);
+ configuration.configure(project);
+ this.tasks.addAll(configuration.getGeneratorTasks());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (!project.isOpen()) {
+ try {
+ project.open(monitor);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ for (ICodeGeneratorTask task : tasks) {
+ task.generate(model, new ProjectFileOutputter(project));
+ }
+
+ }
+
+ private IProject createProjectInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProjectDescription desc = workspace.newProjectDescription(locationW
+ .getProjectName());
+
+ desc.setLocation(locationW.getValidPath());
+
+ if (!isDefaultWorkLocation(workspace)) {
+ project.create(desc, new SubProgressMonitor(monitor, 1));
+ } else {
+ project.create(new SubProgressMonitor(monitor, 1));
+ }
+ return project;
+ }
+
+ private boolean isDefaultWorkLocation(IWorkspace workspace) {
+ String defaultWorkspace = workspace.getRoot().getLocation().toString();
+ return StringUtils.equals(defaultWorkspace, locationW.getPath());
+ }
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ private IWorkspaceRoot getWorkspace() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/FolderModule.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/FolderModule.java
new file mode 100644
index 0000000..ee6d937
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/FolderModule.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import org.eclipse.vorto.codegen.internal.OverWritingStrategy;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+import org.eclipse.vorto.codegen.api.tasks.IOutputter;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+/**
+ * Code Generator which creates specific folder (structure)
+ *
+ *
+ *
+ */
+public class FolderModule implements ICodeGeneratorTask {
+
+ private String[] folders;
+
+ public FolderModule(String... folders) {
+ this.folders = folders;
+ }
+
+ @Override
+ public void generate(FunctionblockModel model, IOutputter outputter) {
+ outputter.setFileWritingStrategy(new OverWritingStrategy());
+ if (folders != null) {
+ for (String customFolder : folders) {
+ outputter.output(new Generated(null, customFolder, null));
+ }
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/IEclipseProjectConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/IEclipseProjectConfiguration.java
new file mode 100644
index 0000000..cadbe00
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/IEclipseProjectConfiguration.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+
+/**
+ * Configures an Eclipse project like nature, classpath etc.
+ *
+ *
+ *
+ */
+public interface IEclipseProjectConfiguration {
+
+ /**
+ * Configures an Eclipse project like nature, classpath etc.
+ *
+ * @param project
+ * the eclipse project to configure
+ * @return
+ */
+ IEclipseProjectConfiguration configure(IProject project);
+
+ /**
+ * @return generator tasks that are needed to invoke for this configuration
+ */
+ List<ICodeGeneratorTask> getGeneratorTasks();
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/LocationWrapper.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/LocationWrapper.java
new file mode 100644
index 0000000..913556e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/LocationWrapper.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.URIUtil;
+
+/**
+ * Workspace aware location for a project
+ *
+ *
+ *
+ */
+public class LocationWrapper {
+
+ private String path;
+ private String projectName;
+ private URI uri;
+
+ public LocationWrapper(String path, String projectName) {
+
+ this.path = path;
+ this.projectName = projectName;
+
+ try {
+ uri = URIUtil.fromString(path + "/" + projectName);
+
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(
+ "Invalid workspace location provided", e);
+ }
+ }
+
+ public Path getValidPath() {
+ return new Path(uri.toString());
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/MavenNatureConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/MavenNatureConfiguration.java
new file mode 100644
index 0000000..380c4dc
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/MavenNatureConfiguration.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.vorto.codegen.api.tasks.ITemplate;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+
+/**
+ * Maven Configuration of an Eclipse Project
+ *
+ *
+ *
+ */
+public class MavenNatureConfiguration extends NatureConfiguration {
+
+ private static FolderModule mavenDefaultFolders = new FolderModule(
+ "src/main/java", "src/main/test", "src/test/java",
+ "src/test/resources", "target/classes", "target/test-classes");
+
+ private final PomFileModule pomFileGenerator;
+
+ public MavenNatureConfiguration(ITemplate pomFile,
+ IEclipseProjectConfiguration... configurations) {
+ super("org.eclipse.m2e.core.maven2Nature", configurations);
+ pomFileGenerator = new PomFileModule(pomFile);
+ }
+
+ @Override
+ public IEclipseProjectConfiguration configure(IProject project) {
+ super.configure(project);
+ return this;
+ }
+
+ @Override
+ public List<ICodeGeneratorTask> getGeneratorTasks() {
+ List<ICodeGeneratorTask> modules = new ArrayList<ICodeGeneratorTask>();
+ modules.add(mavenDefaultFolders);
+ modules.add(pomFileGenerator);
+ return modules;
+ }
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/NatureConfiguration.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/NatureConfiguration.java
new file mode 100644
index 0000000..213f265
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/NatureConfiguration.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+/**
+ * Configures the nature of a project
+ *
+ *
+ *
+ */
+public class NatureConfiguration extends AbstractConfiguration {
+
+ private String nature;
+
+ private IEclipseProjectConfiguration[] natureConfigurations;
+
+ public NatureConfiguration(String nature,
+ IEclipseProjectConfiguration... natureConfigurations) {
+ this.nature = nature;
+ this.natureConfigurations = natureConfigurations;
+ }
+
+ @Override
+ public IEclipseProjectConfiguration configure(IProject project) {
+ try {
+ IProjectDescription description = project.getDescription();
+ List<String> natures = new ArrayList<String>(
+ Arrays.asList(description.getNatureIds()));
+ natures.add(nature);
+ description
+ .setNatureIds(natures.toArray(new String[natures.size()]));
+ project.setDescription(description, new NullProgressMonitor());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ for (IEclipseProjectConfiguration configuration : natureConfigurations) {
+ configuration.configure(project);
+ }
+
+ return this;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/PomFileModule.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/PomFileModule.java
new file mode 100644
index 0000000..f03548a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/PomFileModule.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import org.eclipse.vorto.codegen.api.tasks.ITemplate;
+import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+import org.eclipse.vorto.codegen.api.tasks.IOutputter;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+/**
+ * Generates a pom.xml for a maven project
+ *
+ *
+ *
+ */
+public class PomFileModule implements ICodeGeneratorTask {
+
+ private ITemplate template = null;
+
+ public PomFileModule(ITemplate template) {
+ this.template = template;
+ }
+
+ public void generate(FunctionblockModel model, IOutputter outputter) {
+ Generated generatedPom = new Generated("pom.xml", null,
+ template.getContent(model));
+ outputter.output(generatedPom);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ProjectFileOutputter.xtend b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ProjectFileOutputter.xtend
new file mode 100644
index 0000000..d020536
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/api/tasks/eclipse/ProjectFileOutputter.xtend
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+ package org.eclipse.vorto.codegen.api.tasks.eclipse;
+
+import org.apache.log4j.Logger
+import org.eclipse.core.resources.IFile
+import org.eclipse.core.resources.IFolder
+import org.eclipse.core.resources.IProject
+import org.eclipse.vorto.codegen.internal.WriteGenOverWriteStrategy
+import org.eclipse.vorto.codegen.api.tasks.Generated
+import org.eclipse.vorto.codegen.api.tasks.IOutputter
+import org.eclipse.vorto.codegen.api.IFileWritingStrategy
+
+/**
+ * Eclipse Project Outtputter strategy, which writes {@link Generated} content as part of an Eclipse Project
+ *
+ *
+ *
+ */
+class ProjectFileOutputter implements IOutputter {
+
+ private static final Logger logger = Logger.getLogger(ProjectFileOutputter.canonicalName)
+
+ IProject project = null;
+ IFileWritingStrategy strategy;
+
+ new(IProject project) {
+ this.project = project;
+ }
+
+ override void output(Generated generated) {
+
+ try {
+ var IFolder folder = null;
+ if (generated.getFolderPath() != null) { // make sure that folders are created before file
+ folder = createProjectFolders(generated.folderPath);
+ }
+
+ if (generated.fileName != null) {
+
+ var IFile generatedFile = null;
+ if (folder != null) {
+ generatedFile = folder.getFile(generated.fileName);
+ } else {
+ generatedFile = project.getFile(generated.getFileName());
+ }
+
+ getFileWritingStrategy.writeFile(generated,generatedFile);
+
+ }
+ } catch (Exception ioEx) {
+ ioEx.printStackTrace;
+ throw new RuntimeException("Generated resource " + generated + " could not be written", ioEx);
+ }
+ }
+
+ private def IFolder createProjectFolders(String folderPath) {
+ var folder = project.getFolder(folderPath);
+ if (!folder.exists()) {
+ val foldersCreated = folder.getLocation().toFile().mkdirs()
+ if(!foldersCreated) {
+ logger.info("Folders not created at " + folder.getLocation().toFile().path)
+ //throw exception here?
+ //throw new RuntimeException("Folders not created at " + folder.getLocation().toFile().path);
+ }
+ folder.refreshLocal(1, null);
+ folder = project.getFolder(folderPath);
+ }
+ return folder;
+ }
+
+ override def void setFileWritingStrategy(IFileWritingStrategy strategy){
+ this.strategy = strategy;
+ }
+
+ public def IFileWritingStrategy getFileWritingStrategy(){
+ if(this.strategy == null){
+ this.strategy = new WriteGenOverWriteStrategy();
+ }
+ this.strategy
+ }
+
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/OverWritingStrategy.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/OverWritingStrategy.java
new file mode 100644
index 0000000..35e5e5d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/OverWritingStrategy.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.vorto.codegen.api.IFileWritingStrategy;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+
+
+public class OverWritingStrategy implements IFileWritingStrategy {
+
+ @Override
+ public void writeFile(Generated generated, IFile existingFile)
+ throws CoreException, IOException {
+ if (existingFile.exists())
+ existingFile.delete(true, null);
+
+ InputStream content = IOUtils.toInputStream(generated.getContent());
+
+ existingFile.create(content, false, null);
+ content.close();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/WriteGenOverWriteStrategy.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/WriteGenOverWriteStrategy.java
new file mode 100644
index 0000000..513427c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/WriteGenOverWriteStrategy.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileState;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.vorto.codegen.api.IFileWritingStrategy;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+
+
+public class WriteGenOverWriteStrategy implements IFileWritingStrategy {
+
+ private static final String FILENAME_SUFFIX = "_gen";
+
+ @Override
+ public void writeFile(Generated generated, IFile existingFile)
+ throws CoreException, IOException {
+
+ String fileName = generated.getFileName();
+ IProject project = existingFile.getProject();
+
+ if (!existingFile.exists()) {
+ write(generated.getContent(), existingFile);
+
+ /*
+ * Clearing the file history of the newly created file is because
+ * file history is not deleted when the file is being deleted. So if
+ * the file is not found whether deleted by the system or user , it
+ * will clear the history after creating the file to avoid false
+ * detection of modification.
+ */
+ existingFile.clearHistory(null);
+ } else {
+ if (isModified(existingFile)) {
+ IFile replacefile = getFile(fileName + FILENAME_SUFFIX,
+ generated.getFolderPath(), project);
+
+ if (replacefile.exists())
+ replacefile.delete(true, null);
+
+ write(generated.getContent(), replacefile);
+ } else {
+ existingFile.delete(true, null);
+ write(generated.getContent(), existingFile);
+ }
+
+ }
+
+ }
+
+ private boolean isModified(IFile existingFile) {
+ IFileState[] history = null;
+ try {
+ history = existingFile.getHistory(null);
+ } catch (CoreException e) {
+ return true;
+ }
+ return history.length != 0;
+ }
+
+ private IFile getFile(String fileName, String folderPath, IProject project) {
+ IFile file = null;
+
+ if (StringUtils
+ .equalsIgnoreCase(folderPath, Generated.ROOT_FOLDER_PATH)) {
+ file = project.getFile(fileName);
+ } else {
+ file = project.getFolder(folderPath).getFile(fileName);
+ }
+
+ return file;
+ }
+
+ private void write(String contentStr, IFile existingFile)
+ throws CoreException, IOException {
+ InputStream content = IOUtils.toInputStream(contentStr);
+ existingFile.create(content, false, null);
+ content.close();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/ExtensionMetaData.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/ExtensionMetaData.java
new file mode 100644
index 0000000..5e3e69a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/ExtensionMetaData.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal.extensioninterface;
+
+
+public class ExtensionMetaData {
+
+ private String generatorPluginId;
+ private String className;
+ private String extensionIdentifier;
+ private String menuLabel;
+ private String iconPath;
+
+ public String getGeneratorPluginId() {
+ return generatorPluginId;
+ }
+
+ public void setGeneratorPluginId(String generatorPluginId) {
+ this.generatorPluginId = generatorPluginId;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getExtensionIdentifier() {
+ return extensionIdentifier;
+ }
+
+ public void setExtensionIdentifier(String extensionIdentifier) {
+ this.extensionIdentifier = extensionIdentifier;
+ }
+
+ public String getMenuLabel() {
+ return menuLabel;
+ }
+
+ public void setMenuLabel(String menuLabel) {
+ this.menuLabel = menuLabel;
+ }
+
+ public String getIconPath() {
+ return iconPath;
+ }
+
+ public void setIconPath(String iconPath) {
+ this.iconPath = iconPath;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/PopulateGeneratorsMenu.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/PopulateGeneratorsMenu.java
new file mode 100644
index 0000000..e9e8e37
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/extensioninterface/PopulateGeneratorsMenu.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal.extensioninterface;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.vorto.codegen.Activator;
+import org.eclipse.vorto.codegen.api.ICodeGenerator;
+import org.osgi.framework.Bundle;
+
+
+public class PopulateGeneratorsMenu extends CompoundContributionItem {
+
+ private static final String GENERATEALL_CLASS = "org.eclipse.vorto.codegen.extensioninterface.EvaluateContributionsHandler";
+ private static final String CLASS = "class";
+ private static final String MENU_LABEL = "menuLabel";
+ public static final String GENERATE_ALL = "Generate All";
+
+ public PopulateGeneratorsMenu() {
+ }
+
+ public PopulateGeneratorsMenu(String id) {
+ super(id);
+ }
+
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ List<CommandContributionItem> contributionItems = new ArrayList<CommandContributionItem>();
+ IConfigurationElement[] registeredGenerators = getAllRegisteredGeneratorNames();
+ for (IConfigurationElement aGenerator : registeredGenerators) {
+ CommandContributionItem commandForGenerator = constructCommandForGenerator(aGenerator);
+ if (commandForGenerator != null) {
+ contributionItems.add(commandForGenerator);
+ }
+ }
+ CommandContributionItem generateAllContributionItem = constructCommandForGenerator(
+ GENERATEALL_CLASS, GENERATE_ALL, GENERATE_ALL,
+ "org.eclipse.vorto.codegen");
+ contributionItems.add(generateAllContributionItem);
+ return contributionItems
+ .toArray(new IContributionItem[contributionItems.size()]);
+ }
+
+ private CommandContributionItem constructCommandForGenerator(
+ IConfigurationElement aGenerator) {
+ return constructCommandForGenerator(populateExtensionMetaData(aGenerator));
+ }
+
+ @SuppressWarnings("unchecked")
+ private CommandContributionItem constructCommandForGenerator(
+ ExtensionMetaData extensionMetaData) {
+ String extensionIdentifier = extensionMetaData.getExtensionIdentifier();
+ if (StringUtils.isNotEmpty(extensionIdentifier)) {
+ CommandContributionItemParameter generatorCommand = new CommandContributionItemParameter(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
+ "org.eclipse.vorto.codegen.dynamic.menu.contribution.item.id",
+ "org.eclipse.vorto.codegen.generator.command.id", SWT.NONE);
+ CommandContributionItem generatorContributionItem;
+ generatorCommand.label = extensionMetaData.getMenuLabel();
+ String iconPath = extensionMetaData.getIconPath();
+ Bundle bundle = Platform.getBundle(extensionMetaData
+ .getGeneratorPluginId());
+ if (iconPath == null) {
+ // Load the defaults
+ iconPath = "icons/generate.gif";
+ bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ }
+ IPath path = new Path(iconPath);
+ generatorCommand.icon = ImageDescriptor.createFromURL(FileLocator
+ .find(bundle, path, null));
+ generatorCommand.parameters = new HashMap<String, String>();
+ generatorCommand.parameters.put(
+ "org.eclipse.vorto.codegen.generator.commandParameter",
+ extensionIdentifier);
+ generatorContributionItem = new CommandContributionItem(
+ generatorCommand);
+ return generatorContributionItem;
+ }
+ return null;
+ }
+
+ private ExtensionMetaData populateExtensionMetaData(
+ IConfigurationElement confiurationElement) {
+ ExtensionMetaData extensionMetaData = new ExtensionMetaData();
+ extensionMetaData.setGeneratorPluginId(confiurationElement
+ .getContributor().getName());
+ extensionMetaData.setClassName(confiurationElement.getAttribute(CLASS));
+ extensionMetaData.setExtensionIdentifier(confiurationElement
+ .getDeclaringExtension().getUniqueIdentifier());
+ extensionMetaData.setMenuLabel(confiurationElement
+ .getAttribute(MENU_LABEL));
+ extensionMetaData.setIconPath(confiurationElement.getAttribute("icon"));
+ return extensionMetaData;
+ }
+
+ @SuppressWarnings("unchecked")
+ private CommandContributionItem constructCommandForGenerator(
+ String className, String extensionIdentifier, String menuLabel,
+ String generatorPluginId) {
+ CommandContributionItemParameter generatorCommand = new CommandContributionItemParameter(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
+ "org.eclipse.vorto.codegen.dynamic.menu.contribution.item.id",
+ "org.eclipse.vorto.codegen.generator.command.id", SWT.NONE);
+ generatorCommand.label = menuLabel;
+ Bundle bundle = Platform.getBundle("org.eclipse.vorto.codegen");
+ IPath path = new Path("icons/generate.gif");
+ generatorCommand.icon = ImageDescriptor.createFromURL(FileLocator.find(
+ bundle, path, null));
+ generatorCommand.parameters = new HashMap<String, String>();
+ generatorCommand.parameters.put(
+ "org.eclipse.vorto.codegen.generator.commandParameter",
+ extensionIdentifier);
+ CommandContributionItem generatorContributionItem = new CommandContributionItem(
+ generatorCommand);
+ return generatorContributionItem;
+ }
+
+ private IConfigurationElement[] getAllRegisteredGeneratorNames() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ final IConfigurationElement[] generators = extensionRegistry
+ .getConfigurationElementsFor(ICodeGenerator.GENERATOR_ID);
+ return generators;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/EvaluateContributionsHandler.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/EvaluateContributionsHandler.java
new file mode 100644
index 0000000..fc4a162
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/EvaluateContributionsHandler.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal.handler;
+
+import static org.eclipse.vorto.codegen.internal.extensioninterface.PopulateGeneratorsMenu.GENERATE_ALL;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.vorto.api.common.project.FunctionBlockProjectFactory;
+import org.eclipse.vorto.api.common.project.IProjectSelectionFactory;
+import org.eclipse.vorto.api.common.project.IoTModelProject;
+import org.eclipse.vorto.codegen.api.ICodeGenerator;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public class EvaluateContributionsHandler extends AbstractHandler {
+
+ private static final String GENERATOR_ID = ICodeGenerator.GENERATOR_ID;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ final String generatorIdentifier = event
+ .getParameter("org.eclipse.vorto.codegen.generator.commandParameter");
+ evaluate(extensionRegistry, generatorIdentifier);
+ return null;
+ }
+
+ private void evaluate(IExtensionRegistry registry, String generatorName) {
+
+ final IConfigurationElement[] configElements = getUserSelectedGenerators(
+ registry, generatorName);
+ final FunctionblockModel model = getSelectedFbDesignProject()
+ .getFunctionBlockModel();
+
+ GenerateService.runGenerateCodeInBackground(configElements, model);
+ }
+
+ private IConfigurationElement[] getUserSelectedGenerators(
+ IExtensionRegistry registry, String generatorIdentifier) {
+ IConfigurationElement[] configurationElements;
+ if (GENERATE_ALL.equals(generatorIdentifier)) {
+ configurationElements = registry
+ .getConfigurationElementsFor(GENERATOR_ID);
+ } else {
+ IExtension extension = registry.getExtension(
+ ICodeGenerator.GENERATOR_ID, generatorIdentifier);
+ configurationElements = extension.getConfigurationElements();
+ }
+ return configurationElements;
+ }
+
+ private IoTModelProject getSelectedFbDesignProject() {
+ try {
+ FunctionBlockProjectFactory factory = FunctionBlockProjectFactory
+ .getInstance();
+
+ IProject projectFromSelection = IProjectSelectionFactory
+ .getInstance().getProjectFromSelection();
+ if (projectFromSelection != null)
+ return factory.getProject(projectFromSelection,
+ IoTModelProject.class);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/GenerateService.java b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/GenerateService.java
new file mode 100644
index 0000000..8792f88
--- /dev/null
+++ b/bundles/org.eclipse.vorto.codegen/src/org/eclipse/vorto/codegen/internal/handler/GenerateService.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.internal.handler;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.vorto.api.console.ConsoleDisplayMgr;
+import org.eclipse.vorto.codegen.api.ICodeGenerator;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public class GenerateService {
+
+ public static final String CODE_GEN_JOBFAMILY = "IoTGenerator";
+
+ public static void runGenerateCodeInBackground(
+ final IConfigurationElement[] configElements,
+ final FunctionblockModel functionBlockModel) {
+ try {
+ ConsoleDisplayMgr.getDefault().printInfo("GenerateService invoked");
+ for (IConfigurationElement e : configElements) {
+ final Object o = e.createExecutableExtension("class");
+ if (o instanceof ICodeGenerator) {
+ final String generatorName = e.getAttribute("menuLabel");
+
+ Job job = new Job("Generating Code using " + generatorName) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ monitor.beginTask("Invoking generator ["
+ + generatorName + "]",
+ configElements.length);
+ try {
+ ((ICodeGenerator) o).generate(
+ functionBlockModel, monitor);
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
+ monitor.done();
+ return Status.CANCEL_STATUS;
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Status.CANCEL_STATUS;
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == CODE_GEN_JOBFAMILY;
+ }
+
+ };
+
+ job.setUser(true);
+ job.schedule();
+ // job.join(); // execute synchronously
+ }
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.vorto.common/.classpath b/bundles/org.eclipse.vorto.common/.classpath
new file mode 100644
index 0000000..098194c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.vorto.common/.gitignore b/bundles/org.eclipse.vorto.common/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/bundles/org.eclipse.vorto.common/.project b/bundles/org.eclipse.vorto.common/.project
new file mode 100644
index 0000000..76d41ec
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/.project
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtend.shared.ui.xtendBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtend.shared.ui.xtendXPandNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.common/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8ba0e55
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Commons
+Bundle-SymbolicName: org.eclipse.vorto.common;singleton:=true
+Bundle-Version: 0.1.0
+Bundle-Activator: org.eclipse.vorto.api.common.Activator
+Bundle-Vendor: Bosch-SI
+Require-Bundle: org.eclipse.vorto.metamodel,
+ org.eclipse.ui;bundle-version="3.105.0",
+ org.eclipse.core.runtime;bundle-version="3.9.0",
+ org.eclipse.jdt.core;bundle-version="3.9.0",
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.emf.ecore;bundle-version="2.10.0",
+ org.eclipse.jface.text;bundle-version="3.8.0",
+ org.eclipse.ui.console;bundle-version="3.5.0",
+ org.eclipse.xtend.lib;bundle-version="[2.7.0,3.0.0)",
+ org.apache.commons.lang3;bundle-version="3.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.vorto.api.common,
+ org.eclipse.vorto.api.common.generation,
+ org.eclipse.vorto.api.common.project;uses:="org.eclipse.core.runtime,org.eclipse.core.resources",
+ org.eclipse.vorto.api.common.project.nature,
+ org.eclipse.vorto.api.console,
+ org.eclipse.vorto.api.ui.changeevent,
+ org.eclipse.vorto.api.ui.progresstask,
+ org.eclipse.vorto.api.ui.progresstask.service
diff --git a/bundles/org.eclipse.vorto.common/about.html b/bundles/org.eclipse.vorto.common/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.common/build.properties b/bundles/org.eclipse.vorto.common/build.properties
new file mode 100644
index 0000000..786b1df
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html
diff --git a/bundles/org.eclipse.vorto.common/plugin.xml b/bundles/org.eclipse.vorto.common/plugin.xml
new file mode 100644
index 0000000..4252a46
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="org.eclipse.vorto.iotnature"
+ name="IoTNature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.vorto.api.common.project.nature.IoTProjectNature">
+ </run>
+ </runtime>
+ </extension>
+
+</plugin>
diff --git a/bundles/org.eclipse.vorto.common/pom.xml b/bundles/org.eclipse.vorto.common/pom.xml
new file mode 100644
index 0000000..d86d6dc
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/pom.xml
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.common</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Vorto Commons</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/Activator.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/Activator.java
new file mode 100644
index 0000000..35f37a5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/Activator.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common;
+
+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.vorto.common"; //$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)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ initialize();
+ }
+
+ public static void initialize() {
+ plugin = new Activator();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ deinitialize();
+ super.stop(context);
+ }
+
+ public static void deinitialize() {
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/ApplicationConstants.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/ApplicationConstants.java
new file mode 100644
index 0000000..da9091e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/ApplicationConstants.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common;
+
+
+public class ApplicationConstants {
+ public static final String VORTO_TREE_VIEW_ID = "org.eclipse.vorto.perspectives.vortotreeview";
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/generation/FunctionBlockMetaData.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/generation/FunctionBlockMetaData.java
new file mode 100644
index 0000000..27d34dd
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/generation/FunctionBlockMetaData.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.generation;
+
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+import com.google.common.base.Strings;
+
+
+public class FunctionBlockMetaData {
+ public static final String FB_DEFAULT_VERSION = "1.0.0";
+ public static final String DEFAULT_ARCHITECT_PRFIX = "com.bosch.functionblock.";
+
+ private String name;
+ private String displayName;
+ private String version;
+ private String category;
+ private String vendor;
+ private String description;
+ private String groupName;
+ private FunctionblockModel fbm;
+
+ public FunctionBlockMetaData(String name) {
+ this.name = name;
+ this.displayName = name;
+ this.version = FB_DEFAULT_VERSION;
+ this.category = "demo";
+ this.vendor = "www.bosch.com";
+ this.description = "Function block model for " + name;
+ this.groupName = "";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDefaultGroupId() {
+ return DEFAULT_ARCHITECT_PRFIX + this.category;
+ }
+
+ public void validate() {
+
+ }
+
+ public String toString() {
+ return "FbName=" + this.name;
+ }
+
+ public String getGroupName() {
+ if (Strings.isNullOrEmpty(groupName))
+ return getDefaultGroupId();
+ return groupName;
+ }
+
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+
+ public FunctionblockModel getFbm() {
+ return fbm;
+ }
+
+ public void setFbm(FunctionblockModel fbm) {
+ this.fbm = fbm;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionBlockProjectFactory.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionBlockProjectFactory.java
new file mode 100644
index 0000000..cbd158b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionBlockProjectFactory.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IProject;
+
+
+public class FunctionBlockProjectFactory implements IProjectFactory {
+
+ private static FunctionBlockProjectFactory instance = null;
+
+ private FunctionBlockProjectFactory() {
+
+ }
+
+ public static FunctionBlockProjectFactory getInstance() {
+ if (instance == null) {
+ instance = new FunctionBlockProjectFactory();
+ }
+ return instance;
+ }
+
+ public <T extends InfoModelProject, InfoModelProject> T getProject(
+ IProject project, Class<T> projectClass) {
+ try {
+ return projectClass.getConstructor(IProject.class).newInstance(
+ project);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(
+ "Problem instantiating information model project", e);
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionModelModelFileFinder.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionModelModelFileFinder.java
new file mode 100644
index 0000000..04dea7a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/FunctionModelModelFileFinder.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.eclipse.core.resources.IProject;
+
+
+public class FunctionModelModelFileFinder {
+ public static File getFunctionModelFile(IProject project) {
+ File srcModelDirectory = new File(project.getLocation().toFile()
+ .getAbsolutePath()
+ + "/src/models/");
+
+ if (!srcModelDirectory.exists()) {
+ return null;
+ }
+
+ File[] files = srcModelDirectory.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".fbmodel");
+ }
+ });
+
+ if (files.length == 0) {
+ return null;
+ }
+ return files[0];
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IEclipseProjectSelectionFactory.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IEclipseProjectSelectionFactory.java
new file mode 100644
index 0000000..2e74c46
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IEclipseProjectSelectionFactory.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+
+public interface IEclipseProjectSelectionFactory {
+
+ /**
+ * returns IProject from the currently selected project in the workspace.
+ *
+ * @param <T>
+ * @param projectClass
+ * @return
+ */
+ <T> T getProjectFromSelection();
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IFunctionBlockProject.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IFunctionBlockProject.java
new file mode 100644
index 0000000..e96b31c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IFunctionBlockProject.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public interface IFunctionBlockProject {
+ /**
+ * The name of the m2m project
+ *
+ * @return
+ */
+ String getName();
+
+ /**
+ * gets any file of the current project by its relative path
+ *
+ * @param name
+ * @return
+ */
+ IFile getFile(String path);
+
+ /**
+ * refreshes the project and its content
+ *
+ * @param monitor
+ * callback to give feedback to the user while it is refreshing
+ * @throws CoreException
+ */
+ void refresh(IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * retrieve the domain model of the project
+ *
+ * @return FunctionBlockModel fbm
+ */
+ FunctionblockModel getFunctionBlockModel();
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectFactory.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectFactory.java
new file mode 100644
index 0000000..aced3a3
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import org.eclipse.core.resources.IProject;
+
+
+public interface IProjectFactory {
+ /**
+ * creates a M2M Project from an Eclipse project model
+ *
+ * @param <S>
+ * @param project
+ * @param projectClass
+ * @return
+ */
+
+ <T extends S, S> T getProject(IProject project, Class<T> projectClass);
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectSelectionFactory.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectSelectionFactory.java
new file mode 100644
index 0000000..480eaba
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IProjectSelectionFactory.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.vorto.api.common.ApplicationConstants;
+
+
+public class IProjectSelectionFactory implements IEclipseProjectSelectionFactory {
+
+ private static IProjectSelectionFactory instance = null;
+
+ private IProjectSelectionFactory() {
+
+ }
+
+ public static IProjectSelectionFactory getInstance() {
+ if (instance == null) {
+ instance = new IProjectSelectionFactory();
+ }
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <IProject> IProject getProjectFromSelection() {
+ if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow activeWorkbenchWindow = workbench
+ .getActiveWorkbenchWindow();
+ ISelectionService selectionService = activeWorkbenchWindow
+ .getSelectionService();
+ ISelection selection2 = selectionService.getSelection();
+ IViewPart activePart = null;
+ IStructuredSelection selection = null;
+
+ if (selection2 instanceof ITextSelection) {
+ IViewReference[] viewReferences = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .getViewReferences();
+ for (IViewReference view : viewReferences) {
+ if (ApplicationConstants.VORTO_TREE_VIEW_ID.equals(view
+ .getId())) {
+ activePart = view.getView(true);
+ break;
+ }
+ }
+ selection = (IStructuredSelection) activePart.getSite()
+ .getSelectionProvider().getSelection();
+ } else {
+ selection = (IStructuredSelection) selection2;
+ }
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IJavaProject) {
+ return (IProject) ((IJavaProject) firstElement).getProject();
+ } else if (firstElement instanceof IAdaptable) {
+ IProject project = (IProject) ((IAdaptable) firstElement);
+ return project;
+ } else if (firstElement instanceof IoTModelProject) {
+ IProject project = (IProject) ((IoTModelProject) firstElement)
+ .getProject();
+ return project;
+ } else
+ return (IProject) firstElement;
+ }
+
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IoTModelProject.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IoTModelProject.java
new file mode 100644
index 0000000..8bd25c7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/IoTModelProject.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public class IoTModelProject implements IFunctionBlockProject {
+
+ private FunctionblockModel model;
+ private IProject project;
+
+ public IoTModelProject(IProject project) {
+ this.project = project;
+ model = parseFbModel();
+ }
+
+ public File getFbModelFile() {
+ File projectDir = project.getLocation().toFile();
+ String filePath = projectDir.getAbsolutePath() + "/src/models";
+ File fbModelDir = new File(filePath);
+
+ if (fbModelDir.exists() && fbModelDir.isDirectory()) {
+ for (File file : fbModelDir.listFiles()) {
+ if (file.getName().endsWith(".fbmodel")) {
+ return file;
+ }
+ }
+ }
+ return null;
+
+ }
+
+ @Override
+ public FunctionblockModel getFunctionBlockModel() {
+ return model;
+ }
+
+ private FunctionblockModel parseFbModel() {
+ File fbModelFile = getFunctionModelFile();
+ String modelFileUrl = project.getLocationURI() + "/src/models/"
+ + fbModelFile.getName();
+ ResourceSet rs = new ResourceSetImpl();
+ Resource resource = rs.getResource(URI.createURI(modelFileUrl), true);
+ return (FunctionblockModel) resource.getContents().get(0);
+ }
+
+ public File getFunctionModelFile() {
+ return FunctionModelModelFileFinder.getFunctionModelFile(project);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public String getName() {
+ return project.getName();
+ }
+
+ @Override
+ public IFile getFile(String path) {
+ return project.getFile(path);
+ }
+
+ @Override
+ public void refresh(IProgressMonitor monitor) throws CoreException {
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/UnsupportedProject.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/UnsupportedProject.java
new file mode 100644
index 0000000..e8b6cd7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/UnsupportedProject.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+/**
+ *
+ *
+ * NOOP Project, which is used instead of returning Null
+ *
+ */
+public class UnsupportedProject implements IFunctionBlockProject {
+
+ @Override
+ public String getName() {
+ return "Unknown project";
+ }
+
+ @Override
+ public IFile getFile(String name) {
+ return null;
+ }
+
+ @Override
+ public void refresh(IProgressMonitor monitor) {
+ }
+
+ @Override
+ public FunctionblockModel getFunctionBlockModel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/WizardUtil.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/WizardUtil.java
new file mode 100644
index 0000000..371d960
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/WizardUtil.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+
+public class WizardUtil {
+ public static IConfigurationElement getWizardConfigurationElement(
+ String wizardId) {
+
+ IExtensionRegistry er = Platform.getExtensionRegistry();
+ IConfigurationElement[] elems = er
+ .getConfigurationElementsFor("org.eclipse.ui.newWizards");
+
+ for (IConfigurationElement configurationElement : elems) {
+ IConfigurationElement config = getConfigFor(configurationElement,
+ wizardId);
+ if (config != null) {
+ return config;
+ }
+ }
+ return null;
+ }
+
+ private static IConfigurationElement getConfigFor(
+ IConfigurationElement elem, String wizardId) {
+
+ for (String attribute : elem.getAttributeNames()) {
+ String value = elem.getAttribute(attribute);
+ if ("id".equals(attribute) && wizardId.equals(value)) {
+ return elem;
+ }
+
+ }
+
+ IConfigurationElement[] elemsc = elem.getChildren();
+ for (IConfigurationElement childElem : elemsc) {
+ IConfigurationElement configurationElement = getConfigFor(
+ childElem, wizardId);
+ if (configurationElement != null) {
+ return configurationElement;
+ }
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/nature/IoTProjectNature.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/nature/IoTProjectNature.java
new file mode 100644
index 0000000..f93877c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/common/project/nature/IoTProjectNature.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.common.project.nature;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+
+public class IoTProjectNature implements IProjectNature {
+ public static final String NATURE_ID = "org.eclipse.vorto.iotnature";
+
+ private IProject project;
+
+ @Override
+ public void configure() throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/console/ConsoleDisplayMgr.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/console/ConsoleDisplayMgr.java
new file mode 100644
index 0000000..14f32aa
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/console/ConsoleDisplayMgr.java
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.console;
+
+import java.io.IOException;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IOConsoleOutputStream;
+import org.eclipse.ui.console.MessageConsole;
+
+/**
+ *
+ *
+ * Used to write to console. Usage: create instance,
+ * ConsoleDisplayMgr.getDefault().println("message",
+ * ConsoleDisplayMgr.MSG_ERROR)
+ *
+ */
+public class ConsoleDisplayMgr {
+ private static ConsoleDisplayMgr fDefault = null;
+ private String fTitle = null;
+ private static MessageConsole fMessageConsole = null;
+ private static Color warningColor;
+ private static Color infoColor;
+ private static Color errorColor;
+ private static Color successColor;
+ private static final String SEPERATOR = "------------------------------------------------------------------------";
+
+ public static enum MSG_KIND {
+ ERROR, WARNING, INFO, SUCCESS
+ }
+
+ private ConsoleDisplayMgr(String messageTitle) {
+ //fDefault = this;
+ fTitle = messageTitle;
+
+ Display display = Display.getDefault();
+
+ infoColor = display.getSystemColor(SWT.COLOR_BLACK);
+ errorColor = display.getSystemColor(SWT.COLOR_RED);
+ successColor = display.getSystemColor(SWT.COLOR_DARK_GREEN);
+ warningColor = display.getSystemColor(SWT.COLOR_BLUE);
+ }
+
+ public static ConsoleDisplayMgr getDefault() {
+ if (fDefault == null) {
+ fDefault = new ConsoleDisplayMgr(" M2M ");
+ }
+
+ ConsolePlugin.getDefault().getConsoleManager()
+ .showConsoleView(fMessageConsole);
+ return fDefault;
+ }
+
+ /**
+ * prints a message to the current console.
+ *
+ * @param msg
+ * message to be printed
+ * @param msgKind
+ * Defines the kind of message: MSG_INFORMATION(black) or
+ * MSG_ERROR(red)
+ *
+ */
+ public void println(final String msg, final MSG_KIND msgKind) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (msg == null)
+ return;
+ if (!displayConsoleView()) {
+ MessageDialog.openError(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), "Error",
+ msg);
+ return;
+ }
+ final String msgWithMarker;
+
+ switch (msgKind) {
+ case INFO:
+ msgWithMarker = "[INFO] " + msg;
+ break;
+ case ERROR:
+ msgWithMarker = "[ERROR] " + msg;
+ break;
+ case SUCCESS:
+ msgWithMarker = "[SUCCESS] " + msg;
+ break;
+ case WARNING:
+ msgWithMarker = "[WARNING] " + msg;
+ break;
+ default:
+ msgWithMarker = msg;
+ }
+
+ try {
+ getNewMessageConsoleStream(msgKind).write(msgWithMarker);
+ getNewMessageConsoleStream(msgKind).write('\n');
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ });
+
+ }
+
+ public void printError(final String msg) {
+ this.println(msg, MSG_KIND.ERROR);
+ }
+
+ public void printSuccess(final String msg) {
+ this.println(msg, MSG_KIND.SUCCESS);
+ }
+
+ public void printWarning(final String msg) {
+ this.println(msg, MSG_KIND.WARNING);
+ }
+
+ public void printInfo(final String msg) {
+ this.println(msg, MSG_KIND.INFO);
+ }
+
+ public void clear() {
+ IDocument document = getMessageConsole().getDocument();
+ if (document != null) {
+ document.set("");
+ }
+ }
+
+ public void printSeperator() {
+ println(SEPERATOR, MSG_KIND.INFO);
+ }
+
+ private boolean displayConsoleView() {
+ try {
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ IWorkbenchPage activePage = activeWorkbenchWindow
+ .getActivePage();
+ if (activePage != null)
+ activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW,
+ null, IWorkbenchPage.VIEW_VISIBLE);
+ }
+
+ } catch (PartInitException partEx) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public IOConsoleOutputStream getNewMessageConsoleStream(MSG_KIND msgKind) {
+ Color color = null;
+
+ switch (msgKind) {
+ case INFO:
+ color = infoColor;
+ break;
+ case ERROR:
+ color = errorColor;
+ break;
+ case SUCCESS:
+ color = successColor;
+ break;
+ case WARNING:
+ color = warningColor;
+ break;
+ default:
+ color = infoColor;
+ }
+
+ IOConsoleOutputStream msgConsoleStream = getMessageConsole()
+ .newOutputStream();
+ msgConsoleStream.setColor(color);
+ return msgConsoleStream;
+ }
+
+ private MessageConsole getMessageConsole() {
+ if (fMessageConsole == null)
+ createMessageConsoleStream(fTitle);
+
+ return fMessageConsole;
+ }
+
+ private void createMessageConsoleStream(String title) {
+ initalize(title);
+
+ ConsolePlugin.getDefault().getConsoleManager()
+ .addConsoles(new IConsole[] { fMessageConsole });
+ }
+
+ private static void initalize(String title) {
+ fMessageConsole = new MessageConsole(title, null);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/IProjectChangeListener.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/IProjectChangeListener.java
new file mode 100644
index 0000000..3563ae5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/IProjectChangeListener.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.changeevent;
+
+
+public interface IProjectChangeListener {
+ public void projectChanged(ProjectChangeEvent event);
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectChangeEvent.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectChangeEvent.java
new file mode 100644
index 0000000..5ca735a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectChangeEvent.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.changeevent;
+
+
+public class ProjectChangeEvent {
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectEventListenerRegistry.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectEventListenerRegistry.java
new file mode 100644
index 0000000..70c6adc
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/changeevent/ProjectEventListenerRegistry.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.changeevent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ProjectEventListenerRegistry {
+ private List<IProjectChangeListener> eventReceivers = new ArrayList<IProjectChangeListener>();
+ private static ProjectEventListenerRegistry instance = new ProjectEventListenerRegistry();
+
+ private ProjectEventListenerRegistry() {
+
+ }
+
+ public static ProjectEventListenerRegistry getInstance() {
+ if (instance == null) {
+ instance = new ProjectEventListenerRegistry();
+ }
+ return instance;
+ }
+
+ public void add(IProjectChangeListener listener) {
+ this.eventReceivers.add(listener);
+ }
+
+ public void remove(IProjectChangeListener listener) {
+ this.eventReceivers.remove(listener);
+ }
+
+ public void fire(ProjectChangeEvent projectChangeEvent) {
+ for (IProjectChangeListener listener : eventReceivers) {
+ listener.projectChanged(projectChangeEvent);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/IProgressTask.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/IProgressTask.java
new file mode 100644
index 0000000..74b86c9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/IProgressTask.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.progresstask;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+
+public interface IProgressTask extends IRunnableWithProgress {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException;
+
+ public String getErrorMessage();
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/TaskParameter.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/TaskParameter.java
new file mode 100644
index 0000000..fb379dc
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/TaskParameter.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.progresstask;
+
+import java.util.HashMap;
+
+
+public class TaskParameter {
+
+ HashMap<String, Object> map = new HashMap<>();
+
+ public void add(String string, Object param) {
+ map.put(string, param);
+ }
+
+ public Object get(String string) {
+ return map.get(string);
+ }
+
+ public boolean contains(String string) {
+ return map.containsKey(string);
+ }
+
+ public boolean isEmpty() {
+ return map.isEmpty();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/service/ProgressTaskExecutionService.java b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/service/ProgressTaskExecutionService.java
new file mode 100644
index 0000000..8ef4a56
--- /dev/null
+++ b/bundles/org.eclipse.vorto.common/src/org/eclipse/vorto/api/ui/progresstask/service/ProgressTaskExecutionService.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.api.ui.progresstask.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.vorto.api.ui.progresstask.IProgressTask;
+
+
+public class ProgressTaskExecutionService {
+
+ private static ProgressTaskExecutionService service;
+
+ public static ProgressTaskExecutionService getProgressTaskExecutionService() {
+ if (service == null) {
+ service = new ProgressTaskExecutionService();
+ }
+ return service;
+ }
+
+ public void syncRun(final IProgressTask task) {
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+
+ ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(
+ shell);
+
+ try {
+ progressDialog.run(false, true, task);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ MessageDialog.openError(shell, task.getErrorMessage(),
+ getExceptionMsg(ex, "Error creating project"));
+ }
+
+ }
+ });
+
+ }
+
+ private String getExceptionMsg(Exception e, String defaultMsg) {
+ String errorMsg = "";
+ if (!StringUtils.isEmpty(e.getMessage())) {
+ errorMsg = e.getMessage();
+ } else if (e.getCause() != null
+ && !StringUtils.isEmpty(e.getCause().getMessage())) {
+ errorMsg = e.getCause().getMessage();
+ }
+ return errorMsg;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/.classpath b/bundles/org.eclipse.vorto.fbeditor.tests/.classpath
new file mode 100644
index 0000000..9938e7c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <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="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/.gitignore b/bundles/org.eclipse.vorto.fbeditor.tests/.gitignore
new file mode 100644
index 0000000..750c1e1
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/.gitignore
@@ -0,0 +1,4 @@
+/target
+/bin
+/src-gen
+/xtend-gen
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/.project b/bundles/org.eclipse.vorto.fbeditor.tests/.project
new file mode 100644
index 0000000..57f403a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.fbeditor.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>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.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/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.xtend.core.Xtend.prefs b/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.xtend.core.Xtend.prefs
new file mode 100644
index 0000000..c71588e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/.settings/org.eclipse.xtend.core.Xtend.prefs
@@ -0,0 +1,19 @@
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.directory=xtend-gen
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.ignore=false
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/generated-sources/xtend
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.ignore=false
+autobuilding=true
+eclipse.preferences.version=1
+is_project_specific=true
+outlet.DEFAULT_OUTPUT.cleanDirectory=false
+outlet.DEFAULT_OUTPUT.cleanupDerived=true
+outlet.DEFAULT_OUTPUT.createDirectory=true
+outlet.DEFAULT_OUTPUT.derived=true
+outlet.DEFAULT_OUTPUT.description=Output folder for generated Java files
+outlet.DEFAULT_OUTPUT.directory=xtend-gen
+outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
+outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
+outlet.DEFAULT_OUTPUT.keepLocalHistory=false
+outlet.DEFAULT_OUTPUT.name=DEFAULT_OUTPUT
+outlet.DEFAULT_OUTPUT.override=true
+outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.fbeditor.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ecdb0ce
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Toolchain Tests
+Bundle-Vendor: Bosch-SI
+Bundle-Version: 0.1.0
+Bundle-SymbolicName: org.eclipse.vorto.fbeditor.tests;singleton:=true
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Require-Bundle: org.eclipse.vorto.codegen,
+ org.eclipse.vorto.fbeditor.ui,
+ org.eclipse.vorto.metamodel,
+ org.eclipse.vorto.codegen.examples,
+ org.eclipse.xtext;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.junit4;bundle-version="[2.7.0,3.0.0)",
+ org.junit;bundle-version="4.5.0",
+ org.apache.commons.lang3;bundle-version="3.1.0",
+ org.mockito;bundle-version="1.9.5",
+ org.eclipse.ui,
+ org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Export-Package: org.eclipse.vorto.fbeditor
+
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/about.html b/bundles/org.eclipse.vorto.fbeditor.tests/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.fbeditor.tests/build.properties b/bundles/org.eclipse.vorto.fbeditor.tests/build.properties
new file mode 100644
index 0000000..df0f457
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .,\
+ about.html
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/org.eclipse.vorto.tests.launch b/bundles/org.eclipse.vorto.fbeditor.tests/org.eclipse.vorto.tests.launch
new file mode 100644
index 0000000..0ad243f
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/org.eclipse.vorto.tests.launch
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.vorto.fbeditor.tests"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.vorto.fbeditor.tests"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.vorto.fbeditor.tests"/>
+</launchConfiguration>
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/pom.xml b/bundles/org.eclipse.vorto.fbeditor.tests/pom.xml
new file mode 100644
index 0000000..386bf03
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/pom.xml
@@ -0,0 +1,108 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.fbeditor.tests</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Vorto Functionblock Editor Tests</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <useUIHarness>false</useUIHarness>
+ <useUIThread>false</useUIThread>
+ </configuration>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>test</phase>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/All*Tests.java</exclude>
+ </excludes>
+ </configuration>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>analysis</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.6.3.201306030806</version>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <!-- implmentation is needed only for Maven 2 -->
+ <rule implementation="org.jacoco.maven.RuleConfiguration">
+ <element>BUNDLE</element>
+ <limits>
+ <!-- implmentation is needed only for Maven 2 -->
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>COMPLEXITY</counter>
+ <value>COVEREDRATIO</value>
+ <minimum>0.60</minimum>
+ </limit>
+ </limits>
+ </rule>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/AllTests.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/AllTests.java
new file mode 100644
index 0000000..9401490
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/AllTests.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.AllWebDeviceGeneratorTaskTests;
+import org.eclipse.vorto.fbeditor.AllEditorTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+ AllWebDeviceGeneratorTaskTests.class,
+ AllEditorTests.class
+})
+public class AllTests {
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/AllWebDeviceGeneratorTaskTests.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/AllWebDeviceGeneratorTaskTests.java
new file mode 100644
index 0000000..d20d71b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/AllWebDeviceGeneratorTaskTests.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.ConfigurationClassTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.FaultClassTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.FunctionBlockClassTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.IndexHtmlFileTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.PomFileTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.ServiceClassTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.StatusClassTemplateTest;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.templates.WebXmlTemplateTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+ WordSeperatorTest.class,
+ ModuleUtilTest.class,
+ ConfigurationClassTemplateTest.class,
+ FaultClassTemplateTest.class,
+ FunctionBlockClassTemplateTest.class,
+ IndexHtmlFileTemplateTest.class,
+ PomFileTemplateTest.class,
+ ServiceClassTemplateTest.class,
+ StatusClassTemplateTest.class,
+ WebXmlTemplateTest.class,
+ ConfigurationClassGeneratorTaskTest.class,
+ FaultClassGeneratorTaskTest.class,
+ FunctionBlockClassGeneratorTaskTest.class,
+ IndexHtmlFileGeneratorTaskTest.class,
+ ServiceClassGeneratorTaskTest.class,
+ StatusClassGeneratorTaskTest.class,
+ WebXmlGeneratorTaskTest.class
+})
+public class AllWebDeviceGeneratorTaskTests {
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ConfigurationClassGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ConfigurationClassGeneratorTaskTest.java
new file mode 100644
index 0000000..08a7f8e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ConfigurationClassGeneratorTaskTest.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ConfigurationClassGeneratorTask;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.ConfigurationClassTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConfigurationClassGeneratorTaskTest {
+ ConfigurationClassGeneratorTask configurationClassGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ configurationClassGenerator = new ConfigurationClassGeneratorTask();
+ }
+
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = model.getName() + "Configuration.java";
+ assertEquals(expectedFileName,
+ configurationClassGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = ModuleUtil.getModelPath(model);
+ assertEquals(expectedPath, configurationClassGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(configurationClassGenerator.getTemplate() instanceof ConfigurationClassTemplate);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FaultClassGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FaultClassGeneratorTaskTest.java
new file mode 100644
index 0000000..71bb94a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FaultClassGeneratorTaskTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.FaultClassGeneratorTask;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.FaultClassTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FaultClassGeneratorTaskTest {
+ FaultClassGeneratorTask faultClassGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ faultClassGenerator = new FaultClassGeneratorTask();
+ }
+
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = model.getName() + "Fault.java";
+ assertEquals(expectedFileName, faultClassGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = ModuleUtil.getModelPath(model);
+ assertEquals(expectedPath, faultClassGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(faultClassGenerator.getTemplate() instanceof FaultClassTemplate);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FunctionBlockClassGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FunctionBlockClassGeneratorTaskTest.java
new file mode 100644
index 0000000..b634724
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/FunctionBlockClassGeneratorTaskTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.FunctionBlockClassGeneratorTask;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.FunctionBlockClassTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FunctionBlockClassGeneratorTaskTest {
+ FunctionBlockClassGeneratorTask functionBlockClassGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ functionBlockClassGenerator = new FunctionBlockClassGeneratorTask();
+ }
+
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = model.getName() + ".java";
+ assertEquals(expectedFileName, functionBlockClassGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = ModuleUtil.getModelPath(model);
+ assertEquals(expectedPath, functionBlockClassGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(functionBlockClassGenerator.getTemplate() instanceof FunctionBlockClassTemplate);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/GeneratedClassMatcher.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/GeneratedClassMatcher.java
new file mode 100644
index 0000000..7e93cb0
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/GeneratedClassMatcher.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.vorto.codegen.api.tasks.Generated;
+import org.mockito.ArgumentMatcher;
+
+public class GeneratedClassMatcher extends ArgumentMatcher<Generated> {
+
+ private Generated generated;
+
+ public GeneratedClassMatcher(Generated generated) {
+ this.generated = generated;
+ }
+
+ @Override
+ public boolean matches(final Object argument) {
+ if (argument == null || !(argument instanceof Generated)) {
+ return false;
+ }
+ Generated arguGenerated = (Generated) argument;
+
+ return StringUtils.equals(generated.getContent(),
+ arguGenerated.getContent())
+ && StringUtils.equals(generated.getFileName(),
+ arguGenerated.getFileName())
+ && StringUtils.equals(generated.getFolderPath(),
+ arguGenerated.getFolderPath());
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/IndexHtmlFileGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/IndexHtmlFileGeneratorTaskTest.java
new file mode 100644
index 0000000..1338572
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/IndexHtmlFileGeneratorTaskTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.IndexHtmlFileGeneratorTask;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.IndexHtmlFileTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IndexHtmlFileGeneratorTaskTest {
+ IndexHtmlFileGeneratorTask indexHtmlFileGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ indexHtmlFileGenerator = new IndexHtmlFileGeneratorTask();
+ }
+
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = "index.html";
+ assertEquals(expectedFileName,
+ indexHtmlFileGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = "src/main/webapp";
+ assertEquals(expectedPath, indexHtmlFileGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(indexHtmlFileGenerator.getTemplate() instanceof IndexHtmlFileTemplate);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ModuleUtilTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ModuleUtilTest.java
new file mode 100644
index 0000000..df6ad0d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ModuleUtilTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.junit.Test;
+
+public class ModuleUtilTest {
+
+ FunctionblockModel model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ @Test
+ public void getModelPackage(){
+ String packageName = ModuleUtil.getModelPackage(model);
+ assertEquals("com.bosch.iot.fridge.model", packageName);
+ }
+
+ @Test
+ public void getServicePackage(){
+ String packageName = ModuleUtil.getServicePackage(model);
+ assertEquals("com.bosch.iot.fridge.service", packageName);
+ }
+
+ @Test
+ public void getModelPath(){
+ String packageName = ModuleUtil.getModelPath(model);
+ assertEquals("/src/main/java/com/bosch/iot/fridge/model", packageName);
+ }
+
+ @Test
+ public void getServicePath(){
+ String packageName = ModuleUtil.getServicePath(model);
+ assertEquals("/src/main/java/com/bosch/iot/fridge/service", packageName);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ServiceClassGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ServiceClassGeneratorTaskTest.java
new file mode 100644
index 0000000..45aa283
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/ServiceClassGeneratorTaskTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ServiceClassGeneratorTask;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.ServiceClassTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ServiceClassGeneratorTaskTest {
+ ServiceClassGeneratorTask serviceClassGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ serviceClassGenerator = new ServiceClassGeneratorTask();
+ }
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = model.getName() + "Service.java";
+ assertEquals(expectedFileName, serviceClassGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = ModuleUtil.getServicePath(model);
+ assertEquals(expectedPath, serviceClassGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(serviceClassGenerator.getTemplate() instanceof ServiceClassTemplate);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/StatusClassGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/StatusClassGeneratorTaskTest.java
new file mode 100644
index 0000000..c70224d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/StatusClassGeneratorTaskTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.ModuleUtil;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.StatusClassGeneratorTask;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.StatusClassTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StatusClassGeneratorTaskTest {
+ StatusClassGeneratorTask statusGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ statusGenerator = new StatusClassGeneratorTask();
+ }
+
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = model.getName() + "Status.java";
+ assertEquals(expectedFileName, statusGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = ModuleUtil.getModelPath(model);
+ assertEquals(expectedPath, statusGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(statusGenerator.getTemplate() instanceof StatusClassTemplate);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/TestFunctionblockModelFactory.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/TestFunctionblockModelFactory.xtend
new file mode 100644
index 0000000..b389e87
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/TestFunctionblockModelFactory.xtend
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks
+
+import org.eclipse.vorto.functionblock.FBFeature
+import org.eclipse.vorto.functionblock.FunctionblockFactory
+import org.eclipse.vorto.functionblock.FunctionblockModel
+import org.eclipse.vorto.functionblock.Operation
+import org.eclipse.vorto.functionblock.PrimitiveProperty
+import org.eclipse.vorto.functionblock.PrimitiveType
+
+class TestFunctionblockModelFactory {
+
+ public static def FunctionblockModel populateFBmodelWithProperties() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+
+ fbmodel.setName("Fridge");
+ fb.setDescription("Refrigerator");
+ fb.setCategory("demo");
+ fb.setDescription("comment");
+ fb.setVendor("www.bosch.com");
+ fb.setVersion("1.2.3");
+ fb.getFeatures().add(createOnOperation());
+ fb.getFeatures().add(createOffOperation());
+ fb.getFeatures().add(createToggleOperation());
+ fb.setConfiguration(createConfiguration);
+ fb.setStatus(createStatus);
+ fb.setFault(createFault);
+ fbmodel.setFunctionblock(fb);
+
+ return fbmodel;
+ }
+
+ public static def FunctionblockModel populateFBmodel() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+
+ fbmodel.setName("Fridge");
+ fb.setDescription("Refrigerator");
+ fb.setCategory("demo");
+ fb.setDescription("comment");
+ fb.setVendor("www.bosch.com");
+ fb.setVersion("1.2.3");
+ fb.getFeatures().add(createOnOperation());
+ fb.getFeatures().add(createOffOperation());
+ fb.getFeatures().add(createToggleOperation());
+
+ fbmodel.setFunctionblock(fb);
+
+ return fbmodel;
+ }
+
+ private static def Operation createOnOperation() {
+ var operation = FunctionblockFactory.eINSTANCE.createOperation();
+ operation.setMethodName("on");
+ operation.setDescription("Turn device on");
+ return operation;
+ }
+
+ private static def Operation createOffOperation() {
+ var operation = FunctionblockFactory.eINSTANCE.createOperation();
+ operation.setMethodName("Off");
+ operation.setDescription("Turn device off");
+ return operation;
+ }
+
+ private static def Operation createToggleOperation() {
+ var operation = FunctionblockFactory.eINSTANCE.createOperation();
+ operation.setMethodName("Toggle");
+ operation.setDescription("Toggle device");
+ return operation;
+ }
+
+ private static def FBFeature createConfiguration() {
+ var configuration = FunctionblockFactory.eINSTANCE.createFBFeature();
+ configuration.properties.add(createPrimitiveProperty("testString", PrimitiveType.STRING));
+ configuration.properties.add(createPrimitiveProperty("testShort", PrimitiveType.SHORT));
+ configuration.properties.add(createPrimitiveProperty("testInt", PrimitiveType.INT));
+
+ return configuration;
+ }
+
+ private static def FBFeature createStatus() {
+ var status = FunctionblockFactory.eINSTANCE.createFBFeature();
+ status.properties.add(createPrimitiveProperty("testString", PrimitiveType.STRING));
+ status.properties.add(createPrimitiveProperty("testShort", PrimitiveType.SHORT));
+ status.properties.add(createPrimitiveProperty("testInt", PrimitiveType.INT));
+ status.properties.add(createPrimitiveProperty("testLong", PrimitiveType.LONG));
+ status.properties.add(createPrimitiveProperty("testFloat", PrimitiveType.FLOAT));
+ status.properties.add(createPrimitiveProperty("testDouble", PrimitiveType.DOUBLE));
+ status.properties.add(createPrimitiveProperty("testDatetime", PrimitiveType.DATETIME));
+ status.properties.add(createPrimitiveProperty("testByte", PrimitiveType.BYTE));
+ status.properties.add(createPrimitiveProperty("testBase64", PrimitiveType.BASE64_BINARY));
+ status.properties.add(createPrimitiveProperty("testBoolean", PrimitiveType.BOOLEAN));
+ return status;
+ }
+
+ private static def FBFeature createFault() {
+ var fault = FunctionblockFactory.eINSTANCE.createFBFeature();
+ fault.properties.add(createPrimitiveProperty("isFault", PrimitiveType.BOOLEAN));
+ return fault;
+ }
+
+ private static def PrimitiveProperty createPrimitiveProperty(String propName, PrimitiveType type) {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setPropName(propName);
+ prop.setType(type);
+ return prop;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WebXmlGeneratorTaskTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WebXmlGeneratorTaskTest.java
new file mode 100644
index 0000000..8f98a54
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WebXmlGeneratorTaskTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.WebXmlGeneratorTask;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory;
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.WebXmlTemplate;
+import org.junit.Before;
+import org.junit.Test;
+
+public class WebXmlGeneratorTaskTest {
+ WebXmlGeneratorTask webXmlGenerator;
+
+ FunctionblockModel model = TestFunctionblockModelFactory
+ .populateFBmodelWithProperties();
+
+ @Before
+ public void init() {
+ webXmlGenerator = new WebXmlGeneratorTask();
+ }
+ @Test
+ public void testGetFileName() {
+ String expectedFileName = "web.xml";
+ assertEquals(expectedFileName, webXmlGenerator.getFileName(model));
+ }
+
+ @Test
+ public void testGetPath() {
+ String expectedPath = "src/main/webapp/WEB-INF";
+ assertEquals(expectedPath, webXmlGenerator.getPath(model));
+ }
+
+ @Test
+ public void testGetTemplate() {
+ assertTrue(webXmlGenerator.getTemplate() instanceof WebXmlTemplate);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WordSeperatorTest.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WordSeperatorTest.java
new file mode 100644
index 0000000..75ec272
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/tasks/WordSeperatorTest.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.codegen.examples.webdevice.tests.tasks;
+
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.WordSeperator;
+import org.junit.Test;
+
+public class WordSeperatorTest {
+
+ @Test
+ public void testSeperateNull(){
+ String words = WordSeperator.splitIntoWords(null);
+ assertTrue(words==null);
+ }
+
+ @Test
+ public void testSeperateUpper(){
+ String words = WordSeperator.splitIntoWords("isOn");
+ assertTrue(words.equals("Is On"));
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ConfigurationClassTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ConfigurationClassTemplateTest.xtend
new file mode 100644
index 0000000..dc5647c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ConfigurationClassTemplateTest.xtend
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.ConfigurationClassTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class ConfigurationClassTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new ConfigurationClassTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''package com.bosch.iot.fridge.model;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize
+public class FridgeConfiguration {
+
+ private String testString = "";
+
+ public String getTestString() {
+ return testString;
+ }
+
+ public void setTestString(String testString) {
+ this.testString = testString;
+ }
+
+ private short testShort = 0;
+
+ public short getTestShort() {
+ return testShort;
+ }
+
+ public void setTestShort(short testShort) {
+ this.testShort = testShort;
+ }
+
+ private int testInt = 0;
+
+ public int getTestInt() {
+ return testInt;
+ }
+
+ public void setTestInt(int testInt) {
+ this.testInt = testInt;
+ }
+}'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FaultClassTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FaultClassTemplateTest.xtend
new file mode 100644
index 0000000..7063670
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FaultClassTemplateTest.xtend
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.FaultClassTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class FaultClassTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new FaultClassTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''package com.bosch.iot.fridge.model;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize
+public class FridgeFault {
+
+ private boolean isFault = false;
+
+ public boolean getIsFault() {
+ return isFault;
+ }
+
+ public void setIsFault(boolean isFault) {
+ this.isFault = isFault;
+ }
+}'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FunctionBlockClassTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FunctionBlockClassTemplateTest.xtend
new file mode 100644
index 0000000..857ffbb
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/FunctionBlockClassTemplateTest.xtend
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.FunctionBlockClassTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class FunctionBlockClassTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new FunctionBlockClassTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ return '''package com.bosch.iot.fridge.model;
+
+public class Fridge {
+
+ private String displayName = "";
+ private String description = "comment";
+ private String vendor = "www.bosch.com";
+ private String category = "demo";
+ private String version = "1.2.3";
+
+ private FridgeConfiguration configuration = new FridgeConfiguration();
+
+ private FridgeStatus status = new FridgeStatus();
+
+ private FridgeFault fault = new FridgeFault();
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public FridgeConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public FridgeStatus getStatus() {
+ return status;
+ }
+
+ public FridgeFault getFault() {
+ return fault;
+ }
+}'''
+ }
+}
+
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/IndexHtmlFileTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/IndexHtmlFileTemplateTest.xtend
new file mode 100644
index 0000000..964c281
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/IndexHtmlFileTemplateTest.xtend
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.IndexHtmlFileTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class IndexHtmlFileTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new IndexHtmlFileTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''<html>
+ <head>
+ <style>
+ #idPropertiesContainerTable {
+ background-color: rgba(255,255,255,0.65);
+ border-radius: 20px;
+ padding:20px;
+ -webkit-box-shadow: 0px 3px 2px 0px rgba(30, 103, 157, 0.5);
+ -moz-box-shadow: 0px 3px 2px 0px rgba(30, 103, 157, 0.5);
+ box-shadow: 0px 3px 2px 0px rgba(30, 103, 157, 0.5);
+ }
+
+ body {
+ font-family: Arial;
+ background-color: #dfebfa !important;
+ background-image: -webkit-linear-gradient(top, #f2f7fe 0%, #b7c9d9 50%, #dfebfa 100%) !important;
+ background: -moz-linear-gradient(top, #f2f7fe 0%, #b7c9d9 50%, #dfebfa 100%) !important;
+ }
+
+ button {
+ border-radius: 2px;
+ border: 0px none;
+ padding: 6px 12px;
+ color: #FFF;
+ background: linear-gradient(to bottom, #0081C7 0%, #004986 100%) repeat scroll 0% 0% transparent;
+ }
+
+ th {
+ color: #0D3155;
+ }
+
+ label {
+ display: block;
+ margin: 5px;
+ color: #333;
+ }
+
+ fieldset {
+ border: 1px solid #0066AD;
+ margin-bottom: 8px;
+ }
+
+ legend {
+ color: #0066AD;
+ font-size: 14px;
+ }
+
+ .column{
+ float:left;
+ }
+
+ input[type=text]{
+ margin: 3px;
+ }
+
+ label.display{
+ font-weight: bold;
+ }
+ </style>
+
+ <script language="javascript">
+ function displayProperty(propertyName, propertyObject){
+ var keys = Object.keys(propertyObject);
+ for(var i=0; i<keys.length; i++){
+ var key = keys[i];
+ var labelId = propertyName + "_id_" + key;
+ if(document.getElementById(labelId)){
+ document.getElementById(labelId).innerHTML = propertyObject[key];
+ }
+ }
+ }
+
+ function displayProperties(){
+ var instanceJsonValue = httpGet("/fridge-webapp/service/Fridge/instance");
+ var instanceObject = JSON.parse(instanceJsonValue);
+ var configurationObject = instanceObject.configuration;
+ var statusObject = instanceObject.status;
+ var faultObject = instanceObject.fault;
+ displayProperty("configuration", configurationObject);
+ displayProperty("status", statusObject);
+ displayProperty("fault", faultObject);
+
+ }
+
+ function invokeOperation(operation){
+ httpPut("/fridge-webapp/service/Fridge/" + operation);
+ displayProperties();
+ }
+
+ function httpGet(restUrl)
+ {
+ var xmlHttp = new XMLHttpRequest();
+ xmlHttp.open( "GET", restUrl, false );
+ xmlHttp.send( null );
+ return xmlHttp.responseText;
+ }
+
+ function httpPut(restUrl)
+ {
+ var xmlHttp = new XMLHttpRequest();
+ xmlHttp.open("PUT", restUrl, false);
+ xmlHttp.setRequestHeader("Content-Type", "text/plain");
+ xmlHttp.send(null);
+ }
+ </script>
+</head>
+<body onload="displayProperties();" >
+ <table border="0" align="center" width="75%">
+ <tr>
+ <th>Fridge</th>
+ </tr>
+ <tr>
+ <td>
+ <fieldset id="configurationFs">
+ <legend>Configuration:</legend>
+ <table border="0" align="center" width="100%">
+ <tr>
+ <td width="20%"><label>Test String:</label></td>
+ <td width="30%"><label id="configuration_id_testString" class="display"></label></td>
+ <td width="20%"><label>Test Short:</label></td>
+ <td width="30%"><label id="configuration_id_testShort" class="display"></label></td>
+ </tr>
+ <tr>
+ <td width="20%"><label>Test Int:</label></td>
+ <td width="30%"><label id="configuration_id_testInt" class="display"></label></td>
+ <td width="20%"><label></td>
+ <td width="30%"><label></td>
+ </tr>
+ </table>
+ </fieldset>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <fieldset id="statusFs">
+ <legend>Status:</legend>
+ <table border="0" align="center" width="100%">
+ <tr>
+ <td width="20%"><label>Test String:</label></td>
+ <td width="30%"><label id="status_id_testString" class="display"></label></td>
+ <td width="20%"><label>Test Short:</label></td>
+ <td width="30%"><label id="status_id_testShort" class="display"></label></td>
+ </tr>
+ <tr>
+ <td width="20%"><label>Test Int:</label></td>
+ <td width="30%"><label id="status_id_testInt" class="display"></label></td>
+ <td width="20%"><label>Test Long:</label></td>
+ <td width="30%"><label id="status_id_testLong" class="display"></label></td>
+ </tr>
+ <tr>
+ <td width="20%"><label>Test Float:</label></td>
+ <td width="30%"><label id="status_id_testFloat" class="display"></label></td>
+ <td width="20%"><label>Test Double:</label></td>
+ <td width="30%"><label id="status_id_testDouble" class="display"></label></td>
+ </tr>
+ <tr>
+ <td width="20%"><label>Test Datetime:</label></td>
+ <td width="30%"><label id="status_id_testDatetime" class="display"></label></td>
+ <td width="20%"><label>Test Byte:</label></td>
+ <td width="30%"><label id="status_id_testByte" class="display"></label></td>
+ </tr>
+ <tr>
+ <td width="20%"><label>Test Base64:</label></td>
+ <td width="30%"><label id="status_id_testBase64" class="display"></label></td>
+ <td width="20%"><label>Test Boolean:</label></td>
+ <td width="30%"><label id="status_id_testBoolean" class="display"></label></td>
+ </tr>
+ </table>
+ </fieldset>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <fieldset id="faultFs">
+ <legend>Fault:</legend>
+ <table border="0" align="center" width="100%">
+ <tr>
+ <td width="20%"><label>Is Fault:</label></td>
+ <td width="30%"><label id="fault_id_isFault" class="display"></label></td>
+ <td width="20%"><label></td>
+ <td width="30%"><label></td>
+ </tr>
+ </table>
+ </fieldset>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <button type="button" value="on" title="Turn device on" onClick="javascript:invokeOperation('on')">On</button>
+ <button type="button" value="Off" title="Turn device off" onClick="javascript:invokeOperation('Off')">Off</button>
+ <button type="button" value="Toggle" title="Toggle device" onClick="javascript:invokeOperation('Toggle')">Toggle</button>
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
+ '''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/PomFileTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/PomFileTemplateTest.xtend
new file mode 100644
index 0000000..7d773eb
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/PomFileTemplateTest.xtend
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates;
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.PomFileTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+public class PomFileTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new PomFileTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse.vorto.examples</groupId>
+ <artifactId>fridge-webapp</artifactId>
+ <version>1.2.3</version>
+ <name>Sample project generated from Fridge</name>
+ <packaging>war</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>1.18.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ <version>1.18.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ <version>1.18.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>fridge-webapp</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>9.2.3.v20140905</version>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <webApp>
+ <contextPath>/fridge-webapp</contextPath>
+ </webApp>
+ <stopPort>9966</stopPort>
+ <stopKey>jettystop</stopKey>
+ <stopWait>10</stopWait>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </project>'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ServiceTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ServiceTemplateTest.xtend
new file mode 100644
index 0000000..f9ba3ad
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/ServiceTemplateTest.xtend
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.ServiceClassTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class ServiceClassTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new ServiceClassTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''package com.bosch.iot.fridge.service;
+
+import java.util.logging.Logger;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import com.bosch.iot.fridge.model.Fridge;
+
+@Path("/Fridge")
+public class FridgeService {
+ private static Logger logger = Logger.getLogger("Fridge");
+ private static Fridge fridgeinstance = new Fridge();
+
+ @GET
+ @Path("/instance")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Fridge getInstance(){
+ return fridgeinstance ;
+ }
+
+ /**
+ * Turn device on
+ */
+ @PUT
+ @Path("/on")
+ public void on() {
+ //Please handle your operation here
+ logger.info("on invoked");
+ }
+
+ /**
+ * Turn device off
+ */
+ @PUT
+ @Path("/Off")
+ public void Off() {
+ //Please handle your operation here
+ logger.info("Off invoked");
+ }
+
+ /**
+ * Toggle device
+ */
+ @PUT
+ @Path("/Toggle")
+ public void Toggle() {
+ //Please handle your operation here
+ logger.info("Toggle invoked");
+ }
+
+}'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/StatusClassTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/StatusClassTemplateTest.xtend
new file mode 100644
index 0000000..0361b22
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/StatusClassTemplateTest.xtend
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.StatusClassTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class StatusClassTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new StatusClassTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''package com.bosch.iot.fridge.model;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize
+public class FridgeStatus {
+
+ private String testString = "";
+
+ public String getTestString() {
+ return testString;
+ }
+
+ public void setTestString(String testString) {
+ this.testString = testString;
+ }
+
+ private short testShort = 0;
+
+ public short getTestShort() {
+ return testShort;
+ }
+
+ public void setTestShort(short testShort) {
+ this.testShort = testShort;
+ }
+
+ private int testInt = 0;
+
+ public int getTestInt() {
+ return testInt;
+ }
+
+ public void setTestInt(int testInt) {
+ this.testInt = testInt;
+ }
+
+ private long testLong = 0;
+
+ public long getTestLong() {
+ return testLong;
+ }
+
+ public void setTestLong(long testLong) {
+ this.testLong = testLong;
+ }
+
+ private float testFloat = 0;
+
+ public float getTestFloat() {
+ return testFloat;
+ }
+
+ public void setTestFloat(float testFloat) {
+ this.testFloat = testFloat;
+ }
+
+ private double testDouble = 0;
+
+ public double getTestDouble() {
+ return testDouble;
+ }
+
+ public void setTestDouble(double testDouble) {
+ this.testDouble = testDouble;
+ }
+
+ private java.util.Date testDatetime = java.util.Calendar.getInstance().getTime();
+
+ public java.util.Date getTestDatetime() {
+ return testDatetime;
+ }
+
+ public void setTestDatetime(java.util.Date testDatetime) {
+ this.testDatetime = testDatetime;
+ }
+
+ private byte testByte = 0;
+
+ public byte getTestByte() {
+ return testByte;
+ }
+
+ public void setTestByte(byte testByte) {
+ this.testByte = testByte;
+ }
+
+ private byte[] testBase64 = new byte[]{};
+
+ public byte[] getTestBase64() {
+ return testBase64;
+ }
+
+ public void setTestBase64(byte[] testBase64) {
+ this.testBase64 = testBase64;
+ }
+
+ private boolean testBoolean = false;
+
+ public boolean getTestBoolean() {
+ return testBoolean;
+ }
+
+ public void setTestBoolean(boolean testBoolean) {
+ this.testBoolean = testBoolean;
+ }
+}'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/WebXmlTemplateTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/WebXmlTemplateTest.xtend
new file mode 100644
index 0000000..897a19b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/codegen/examples/webdevice/tests/templates/WebXmlTemplateTest.xtend
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.codegen.examples.webdevice.tests.templates
+
+import org.eclipse.vorto.codegen.examples.webdevice.tasks.templates.WebXmlTemplate
+import org.eclipse.vorto.codegen.examples.webdevice.tests.tasks.TestFunctionblockModelFactory
+import org.junit.Test
+
+import static org.junit.Assert.assertEquals
+
+class WebXmlTemplateTest {
+
+ @Test
+ def testGeneration() {
+ var model = TestFunctionblockModelFactory.populateFBmodelWithProperties();
+
+ var result = new WebXmlTemplate().getContent(model);
+ assertEquals(fetchExpected, result);
+ }
+
+ private def String fetchExpected() {
+ '''<web-app id="Fridge" version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Sample Rest Service Generated from Sample REST Generator</display-name>
+
+ <servlet>
+ <servlet-name>jersey-serlvet</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>jersey-serlvet</servlet-name>
+ <url-pattern>/service/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>'''
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/AllEditorTests.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/AllEditorTests.java
new file mode 100644
index 0000000..35a50c7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/AllEditorTests.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor;
+
+import org.eclipse.vorto.fbeditor.tests.formatter.FbDslFormatterTest;
+import org.eclipse.vorto.fbeditor.tests.validator.FbConstraintValidationTest;
+import org.eclipse.vorto.fbeditor.tests.validator.FbValidatorTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+ FbDslFormatterTest.class,
+ FbConstraintValidationTest.class,
+ FbValidatorTest.class,
+})
+public class AllEditorTests {
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockInjectorProvider.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockInjectorProvider.java
new file mode 100644
index 0000000..2e5d7b4
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockInjectorProvider.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *******************************************************************************/
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor;
+
+import org.eclipse.xtext.junit4.GlobalRegistries;
+import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
+import org.eclipse.xtext.junit4.IInjectorProvider;
+import org.eclipse.xtext.junit4.IRegistryConfigurator;
+
+import com.google.inject.Injector;
+
+public class FunctionblockInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
+
+ protected GlobalStateMemento stateBeforeInjectorCreation;
+ protected GlobalStateMemento stateAfterInjectorCreation;
+ protected Injector injector;
+
+ static {
+ GlobalRegistries.initializeDefaults();
+ }
+
+ public Injector getInjector()
+ {
+ if (injector == null) {
+ stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
+ this.injector = internalCreateInjector();
+ stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
+ }
+ return injector;
+ }
+
+ protected Injector internalCreateInjector() {
+ return new FunctionblockStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+
+ public void restoreRegistry() {
+ stateBeforeInjectorCreation.restoreGlobalState();
+ }
+
+ public void setupRegistry() {
+ getInjector();
+ stateAfterInjectorCreation.restoreGlobalState();
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockUiInjectorProvider.java b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockUiInjectorProvider.java
new file mode 100644
index 0000000..428bfe2
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/FunctionblockUiInjectorProvider.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *******************************************************************************/
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor;
+
+import org.eclipse.xtext.junit4.IInjectorProvider;
+
+import com.google.inject.Injector;
+
+public class FunctionblockUiInjectorProvider implements IInjectorProvider {
+
+ public Injector getInjector() {
+ return org.eclipse.vorto.fbeditor.ui.internal.FunctionblockActivator.getInstance().getInjector("org.eclipse.vorto.fbeditor.Functionblock");
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/formatter/FbDslFormatterTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/formatter/FbDslFormatterTest.xtend
new file mode 100644
index 0000000..f75dcc7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/formatter/FbDslFormatterTest.xtend
@@ -0,0 +1,715 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.fbeditor.tests.formatter
+
+import com.google.inject.Inject
+import org.eclipse.vorto.fbeditor.FunctionblockInjectorProvider
+import org.eclipse.vorto.functionblock.FunctionblockModel
+import org.eclipse.vorto.functionblock.impl.FunctionblockPackageImpl
+import org.eclipse.xtext.formatting.INodeModelFormatter
+import org.eclipse.xtext.junit4.AbstractXtextTests
+import org.eclipse.xtext.junit4.InjectWith
+import org.eclipse.xtext.junit4.XtextRunner
+import org.eclipse.xtext.junit4.util.ParseHelper
+import org.eclipse.xtext.resource.XtextResource
+import org.junit.BeforeClass
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(typeof(XtextRunner))
+@InjectWith(typeof(FunctionblockInjectorProvider))
+class FbDslFormatterTest extends AbstractXtextTests {
+
+ @Inject extension ParseHelper<FunctionblockModel> parserHelper;
+ @Inject extension INodeModelFormatter formatter;
+
+ @BeforeClass
+ def static void initializeModel() {
+ FunctionblockPackageImpl.init();
+ }
+
+ @Test
+ def void testFormattingForBasicBlock() {
+ val expectedText = '''
+ functionblock BasicFunctionBlock {
+ displayname "BasicFunctionBlock"
+ description "A Basic desription."
+ vendor www.bosch.com
+ category demo
+ version 2.1.1
+
+ configuration {
+ mandatory strproperty as string "Demo property"
+ optional intproperty as string "Demo property"
+ }
+
+ status {
+ mandatory currentStatus as string "Demo Status"
+ }
+
+ fault {
+ mandatory faultProperty as string
+ }
+
+ operations {
+ start(param as string)
+ }
+
+ }'''
+ val rawText = '''functionblock BasicFunctionBlock { displayname "BasicFunctionBlock" description "A Basic desription." vendor
+ www.bosch.com category demo version 2.1.1 configuration { mandatory strproperty as string "Demo property" optional intproperty as
+ string "Demo property" } status {
+ mandatory currentStatus as string "Demo Status" } fault { mandatory faultProperty as string } operations { start(param as string) }}'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testFormattingWithManyElements() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ mandatory str as string "description"
+ mandatory intprop as int "description"
+ }
+
+ status {
+ optional stat as COLOR "Demo"
+ mandatory somethingelse as int "int property"
+ }
+
+ fault {
+ mandatory opt as Simple "Demo"
+ mandatory withconstraint as int <MIN 1,MAX 100>
+ }
+
+ operations {
+ start(param as string,onemore as int) "starting"
+ stopping(param as string)
+ }
+
+ }
+
+ entity Simple {
+ mandatory randomProperty as string
+ }
+
+ enum COLOR {
+ RED,
+ GREEN,
+ BLUE
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock
+ {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration
+ {
+ mandatory str as string "description"
+ mandatory intprop as int "description"
+ }
+
+ status
+ {
+ optional stat as COLOR "Demo"
+ mandatory somethingelse as int "int property"
+ }
+
+ fault
+ {
+ mandatory opt as Simple "Demo"
+ mandatory withconstraint as int <MIN 1 , MAX 100>
+ }
+
+ operations
+ {
+ start(param as string , onemore as int) "starting"
+ stopping(param as string)
+ }
+
+ }
+
+ entity Simple
+ {
+ mandatory randomProperty as string
+ }
+
+ enum COLOR {
+ RED , GREEN , BLUE
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testSingleTabIndendation() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ }
+
+ status {
+ }
+
+ fault {
+ }
+
+ operations {
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ }
+
+ status {
+ }
+
+ fault {
+ }
+
+ operations {
+ }
+
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testNoDoubleIndendation() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ }'''
+ expectedText.assertNotFormattedAs(rawText)
+ }
+
+ @Test
+ def void testSameLineBraces() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ }
+
+ status {
+ }
+
+ fault {
+ }
+
+ operations {
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock
+ {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration
+
+ {
+ }
+
+ status
+ {
+ }
+
+ fault
+ {
+ }
+
+ operations
+ {}}'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testEnumWithLineBreaks() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ }
+
+ enum COLOR {
+ RED,
+ GREEN,
+ BLUE
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock
+ {
+ }
+ enum COLOR {RED , GREEN , BLUE}'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testNoSpaceBetweenParameters() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ }
+
+ status {
+ }
+
+ fault {
+ }
+
+ operations {
+ start(param as string,onemore as int) "starting"
+ stopping(param as string,morespaceparam as int)
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+ configuration {
+ }
+ status {
+ }
+ fault {
+ }
+ operations {
+ start(param as string , onemore as int) "starting"
+ stopping ( param as string , morespaceparam as int )
+ }
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testNoSpaceBetweenConstraints() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ }
+
+ status {
+ }
+
+ fault {
+ mandatory withconstraint as int <MIN 1,MAX 100>
+ mandatory propB as string <REGEX "[a-z]",STRLEN 4>
+ mandatory propC as float <MAX 199.1,MIN 120.2>
+ }
+
+ operations {
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock
+ {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+ configuration {}
+ status{}
+
+ fault
+ {
+ mandatory withconstraint as int <MIN 1 , MAX 100>
+ mandatory propB as string <REGEX "[a-z]" , STRLEN 4>
+ mandatory propC as float <MAX 199.1 , MIN 120.2>
+ }
+ operations {}
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testOneLineBreakBetweenSections() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ mandatory str as string "description"
+ mandatory intprop as int "description"
+ }
+
+ status {
+ optional stat as COLOR "Demo"
+ mandatory somethingelse as int "int property"
+ }
+
+ fault {
+ mandatory opt as Simple "Demo"
+ mandatory withconstraint as int <MIN 1,MAX 100>
+ }
+
+ operations {
+ start(param as string,onemore as int) "starting"
+ stopping(param as string)
+ }
+
+ }
+
+ entity Simple {
+ mandatory randomProperty as string
+ }
+
+ enum COLOR {
+ RED,
+ GREEN,
+ BLUE
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+ configuration {
+ mandatory str as string "description"
+ mandatory intprop as int "description"
+ }
+ status {
+ mandatory stat as string "Demo"
+ }
+ fault {
+ mandatory opt as Simple "Demo"
+ mandatory withconstraint as int <MIN 1,MAX 100>
+ }
+ operations {
+ start(param as string,onemore as int) "starting"
+ stopping(param as string)
+ }
+ }
+ entity Simple {
+ mandatory randomProperty as string
+ }
+ enum COLOR {
+ RED,
+ GREEN,
+ BLUE
+ }'''
+ expectedText.assertNotFormattedAs(rawText)
+ }
+
+ @Test
+ def void testFormattingWithOnlyFbMetadata() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testFormattingWithOptionalConfigurationProperty() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ optional str as string "description"
+ optional intprop as int "description"
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ optional str as string "description"
+ optional intprop as int "description"
+ }
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testFormattingWithOptionalMandatoryConfigurationAndStatusProperty() {
+ val expectedText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ optional str as string "description"
+ optional intprop as int "description"
+ }
+
+ status {
+ optional str as string "description"
+ mandatory intprop as int "description"
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock ComplexFunctionBlock {
+ displayname "ComplexFunctionBlock"
+ description "Complex Function block description"
+ vendor www.bosch.com
+ category complexcategory
+ version 1.1.1
+
+ configuration {
+ optional str as string "description"
+ optional intprop as int "description"
+ }
+
+ status {
+ optional str as string "description"
+ mandatory intprop as int "description"
+ }
+ }'''
+ rawText.assertFormattedAs(expectedText)
+ }
+
+ @Test
+ def void testFormattingWithEvents() {
+ val expectedText = '''
+ functionblock Sample {
+ displayname "Sample"
+ description "Function block model for Sample"
+ vendor www.bosch.com
+ category demo
+ version 1.0.0
+
+ configuration {
+ mandatory testconfig as string
+ }
+
+ status {
+ mandatory teststatus as string
+ }
+
+ fault {
+ optional testfault as string
+ }
+
+ events {
+ testEvent {
+ mandatory test as string
+ }
+
+ refreshevent {
+ mandatory refresh as string
+ }
+
+ }
+
+ operations {
+ simpleOperation()
+ complexOperation(arg1 as string,arg2 as int)
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock Sample { displayname "Sample" description "Function block model for Sample" vendor www.bosch.com category demo version 1.0.0
+
+ configuration { mandatory testconfig as string }
+
+ status { mandatory teststatus as string }
+
+ fault { optional testfault as string }
+
+ events { testEvent { mandatory test as string }
+
+ refreshevent { mandatory refresh as string }
+
+ }
+
+ operations { simpleOperation() complexOperation(arg1 as string,arg2 as int) }
+ }'''
+
+ rawText.assertFormattedAs(expectedText)
+
+ }
+
+ @Test
+ def void testFormattingWithEmptyEvents() {
+ val expectedText = '''
+ functionblock Sample {
+ displayname "Sample"
+ description "Function block model for Sample"
+ vendor www.bosch.com
+ category demo
+ version 1.0.0
+
+ configuration {
+ mandatory testconfig as string
+ }
+
+ status {
+ mandatory teststatus as string
+ }
+
+ fault {
+ optional testfault as string
+ }
+
+ events {
+ testEvent {
+ }
+
+ refreshevent {
+ }
+
+ }
+
+ operations {
+ simpleOperation()
+ complexOperation(arg1 as string,arg2 as int)
+ }
+
+ }'''
+
+ val rawText = '''
+ functionblock Sample { displayname "Sample" description "Function block model for Sample" vendor www.bosch.com category demo version 1.0.0
+
+ configuration { mandatory testconfig as string }
+
+ status { mandatory teststatus as string }
+
+ fault { optional testfault as string }
+
+ events { testEvent {}
+
+ refreshevent {}
+
+ }
+
+ operations { simpleOperation() complexOperation(arg1 as string,arg2 as int) }
+ }'''
+
+ rawText.assertFormattedAs(expectedText)
+
+ }
+
+
+ def void assertFormattedAs(CharSequence input, CharSequence expected) {
+ val expectedText = expected.toString
+ val formattedText = (input.parse.eResource as XtextResource).parseResult.rootNode.format(0, input.length).formattedText
+ assertEquals(expectedText, formattedText)
+ }
+
+ def void assertNotFormattedAs(CharSequence input, CharSequence unexpected) {
+ val unExpectedText = unexpected.toString
+ val formattedText = (input.parse.eResource as XtextResource).parseResult.rootNode.format(0, input.length).formattedText
+ assertNotEquals(unExpectedText, formattedText)
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbConstraintValidationTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbConstraintValidationTest.xtend
new file mode 100644
index 0000000..67a39c9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbConstraintValidationTest.xtend
@@ -0,0 +1,606 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.fbeditor.tests.validator
+
+import org.eclipse.vorto.fbeditor.FunctionblockStandaloneSetup
+import org.eclipse.vorto.fbeditor.internal.validation.ConstraintValidatorFactory
+import org.eclipse.vorto.fbeditor.validation.FunctionblockValidator
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.fbeditor.internal.validation.validator.PropertyConstraintMappingValidation
+import org.eclipse.vorto.functionblock.ConstraintIntervalType
+import org.eclipse.vorto.functionblock.FunctionblockFactory
+import org.eclipse.vorto.functionblock.PrimitiveType
+import org.eclipse.xtext.junit4.AbstractXtextTests
+import org.eclipse.xtext.junit4.validation.ValidatorTester
+import org.junit.Test
+
+class FbConstraintValidationTest extends AbstractXtextTests {
+
+ private ValidatorTester<FunctionblockValidator> tester;
+
+ def override void setUp() throws Exception {
+ super.setUp();
+ with(FunctionblockStandaloneSetup);
+ var validator = get(FunctionblockValidator);
+ tester = new ValidatorTester<FunctionblockValidator>(validator, getInjector());
+ }
+
+ @Test
+ def test_Constraint_INT_IntValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.INT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('22')
+
+ prop.constraints.add(constraint1)
+
+ var constraint2 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint2.setType(ConstraintIntervalType.MIN)
+ constraint2.setConstraintValues('1')
+
+ prop.constraints.add(constraint2)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator.evaluateValueType(PrimitiveType.INT,constraint1))
+ assertEquals("",validator.getErrorMessage())
+
+ var validator2 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator2.evaluateValueType(PrimitiveType.INT,constraint2))
+ assertEquals("",validator2.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_Float_FloatValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.FLOAT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('2.2')
+
+ prop.constraints.add(constraint1)
+
+ var constraint2 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint2.setType(ConstraintIntervalType.MIN)
+ constraint2.setConstraintValues('1')
+
+ prop.constraints.add(constraint2)
+
+ var validator1 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator1.evaluateValueType(PrimitiveType.FLOAT,constraint1))
+ assertEquals("",validator1.getErrorMessage())
+
+ var validator2 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator2.evaluateValueType(PrimitiveType.FLOAT,constraint2))
+ assertEquals("",validator2.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_String_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.STRING);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.REGEX)
+ constraint1.setConstraintValues('[A..B]')
+
+ prop.constraints.add(constraint1)
+
+ var constraint2 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint2.setType(ConstraintIntervalType.STRLEN)
+ constraint2.setConstraintValues('11')
+
+ prop.constraints.add(constraint2)
+
+ var validator1 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator1.evaluateValueType(PrimitiveType.STRING,constraint1))
+ assertEquals("",validator1.getErrorMessage())
+
+ var validator2 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator2.evaluateValueType(PrimitiveType.STRING,constraint2))
+ assertEquals("",validator2.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_Datetime_DtValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.DATETIME);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('2002-05-30T09:30:10+06:00')
+
+ prop.constraints.add(constraint1)
+
+ var constraint2 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint2.setType(ConstraintIntervalType.MIN)
+ constraint2.setConstraintValues('2002-04-30T01:30:10+06:00')
+
+ prop.constraints.add(constraint2)
+
+ var validator1 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator1.evaluateValueType(prop.type,constraint1))
+ assertEquals("",validator1.getErrorMessage())
+
+ var validator2 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator2.evaluateValueType(prop.type,constraint2))
+ assertEquals("",validator2.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_Datetime_Wrong_DtValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.DATETIME);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('2002-05-30T09:30:10')
+
+ prop.constraints.add(constraint1)
+
+ var validator1 = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator1.evaluateValueType(prop.type,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_DATETIME,validator1.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_DATETIME)
+ }
+
+ @Test
+ def test_Constraint_Boolean_NoConstraint(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BOOLEAN);
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+
+ @Test
+ def test_Constraint_INT_MAX_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.INT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('abc')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.INT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_INT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_INT);
+ }
+
+ @Test
+ def test_Constraint_Float_MAX_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.FLOAT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('abc')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.FLOAT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_FLOAT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_FLOAT);
+ }
+
+ @Test
+ def test_Constraint_DateTime_MIN_IntValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.DATETIME);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MIN)
+ constraint1.setConstraintValues('211')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.DATETIME,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_DATETIME,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_DATETIME);
+ }
+
+ @Test
+ def test_Constraint_Str_StrLen_FloatValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.STRING);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.STRLEN)
+ constraint1.setConstraintValues('21.1')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.STRING,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_INT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_INT);
+
+ }
+
+ @Test
+ def test_Constraint_Boolean_Max_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BOOLEAN);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('sadfasfa')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator.evaluateValueType(PrimitiveType.STRING,constraint1))
+
+ var validat = new PropertyConstraintMappingValidation();
+ assertFalse(validat.checkPropertyConstraints(PrimitiveType.BOOLEAN,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validat.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+
+ }
+
+ @Test
+ def test_Constraint_StringProperty_MIN() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.STRING);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.MIN)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(PrimitiveType.STRING,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_IntProperty_RegeX() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.INT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.REGEX)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(PrimitiveType.INT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_IntProperty_Max_NegValue() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.INT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.constraintValues = '-1111'
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertTrue(validator.checkPropertyConstraints(PrimitiveType.INT,constraint1))
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_BoolProperty_Min() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BOOLEAN);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.MIN)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(PrimitiveType.BOOLEAN,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_ShortProperty_MAX_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.SHORT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('abc')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.SHORT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT);
+ }
+
+ @Test
+ def test_Constraint_ShortProperty_MIN_OutOfRange(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.SHORT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MIN)
+ constraint1.setConstraintValues('32800')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.SHORT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT);
+ }
+
+ @Test
+ def test_Constraint_ShortProperty_MAX_OutOfRange_Negative(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.SHORT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('-32800')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.SHORT,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT);
+ }
+
+ @Test
+ def test_Constraint_ShortProperty_MIN_NegValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.SHORT);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MIN)
+ constraint1.setConstraintValues('-111')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator.evaluateValueType(PrimitiveType.SHORT,constraint1))
+ assertEquals("",validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_LongProperty_RegeX() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.LONG);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.REGEX)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(PrimitiveType.LONG,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_Base64BinaryProperty_NoConstraint() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BASE64_BINARY);
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Constraint_Base64BinaryProperty_Min() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BASE64_BINARY);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.MIN)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(prop.type,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_DoubleProperty_Strlen() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.DOUBLE);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.STRLEN)
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertFalse(validator.checkPropertyConstraints(PrimitiveType.DOUBLE,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID);
+ }
+
+ @Test
+ def test_Constraint_DoubleProperty_Max_NegValue() {
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.DOUBLE);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.constraintValues = '-11.11'
+ prop.constraints.add(constraint1)
+
+ var validator = new PropertyConstraintMappingValidation();
+ assertTrue(validator.checkPropertyConstraints(PrimitiveType.DOUBLE,constraint1))
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK
+ }
+
+
+ @Test
+ def test_Constraint_ByteProperty_MAX_StrValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BYTE);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MAX)
+ constraint1.setConstraintValues('abc')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.BYTE,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_BYTE,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_BYTE);
+ }
+
+ @Test
+ def test_Constraint_ByteProperty_MIN_OutOfRange(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BYTE);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MIN)
+ constraint1.setConstraintValues('128')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertFalse(validator.evaluateValueType(PrimitiveType.BYTE,constraint1))
+ assertEquals(SystemMessage.ERROR_CONSTRAINT_VALUE_BYTE,validator.getErrorMessage())
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_CONSTRAINT_VALUE_BYTE);
+ }
+
+ @Test
+ def test_Constraint_ByteProperty_MIN_NegValue(){
+ var prop = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+ prop.setType(PrimitiveType.BYTE);
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+
+ constraint1.setType(ConstraintIntervalType.MIN)
+ constraint1.setConstraintValues('-128')
+
+ prop.constraints.add(constraint1)
+
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint1.type);
+
+ assertTrue(validator.evaluateValueType(PrimitiveType.BYTE,constraint1));
+
+ tester.validator().checkConstraint(prop);
+ tester.diagnose().assertOK();
+ }
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbValidatorTest.xtend b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbValidatorTest.xtend
new file mode 100644
index 0000000..69c90e7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.tests/src/org/eclipse/vorto/fbeditor/tests/validator/FbValidatorTest.xtend
@@ -0,0 +1,416 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.fbeditor.tests.validator
+
+import org.eclipse.vorto.fbeditor.FunctionblockStandaloneSetup
+import org.eclipse.vorto.fbeditor.validation.FunctionblockValidator
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.functionblock.ConstraintIntervalType
+import org.eclipse.vorto.functionblock.FunctionblockFactory
+import org.eclipse.vorto.functionblock.PrimitiveType
+import org.eclipse.xtext.junit4.AbstractXtextTests
+import org.eclipse.xtext.junit4.validation.ValidatorTester
+import org.junit.Test
+
+class FbValidatorTest extends AbstractXtextTests {
+
+ private ValidatorTester<FunctionblockValidator> tester;
+
+ def override void setUp() throws Exception {
+ super.setUp();
+ with(FunctionblockStandaloneSetup);
+ var validator = get(FunctionblockValidator);
+ tester = new ValidatorTester<FunctionblockValidator>(validator, getInjector());
+ }
+
+ @Test
+ def test_Duplicated_Entity() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+
+ var entity1 = FunctionblockFactory.eINSTANCE.createEntity();
+ entity1.setName("abc");
+
+ var entity2 = FunctionblockFactory.eINSTANCE.createEntity();
+ entity2.setName("abc");
+
+ fbmodel.getElements().add(entity1);
+ fbmodel.getElements().add(entity2);
+
+ tester.validator().checkDuplicateEntityName(entity1);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_ENTITY_NAME);
+ }
+
+ @Test
+ def test_Duplicated_OperationName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+
+ var op1=FunctionblockFactory.eINSTANCE.createOperation();
+ op1.setMethodName("on");
+
+ var op2=FunctionblockFactory.eINSTANCE.createOperation();
+ op2.setMethodName("on");
+
+ fbmodel.getFeatures().add(op1);
+ fbmodel.getFeatures().add(op2);
+
+ tester.validator().checkDuplicateOperation(op1);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_METHOD_NAME);
+ }
+
+ @Test
+ def test_Duplicated_ParameterName() {
+
+ var operation = FunctionblockFactory.eINSTANCE.createOperation();
+
+ var param1= FunctionblockFactory.eINSTANCE.createPrimitiveParam()
+ param1.setParamName("ABB");
+
+ var param2= FunctionblockFactory.eINSTANCE.createPrimitiveParam();
+ param2.setParamName("ABB");
+
+ operation.getParams().add(param1);
+ operation.getParams().add(param2);
+
+ tester.validator().checkDuplicateParameter(operation);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_PARAMETER_NAME);
+ }
+
+
+ @Test
+ def test_Duplicated_Feature() {
+ var fbFeature = FunctionblockFactory.eINSTANCE.createFBFeature();
+
+ var feature = FunctionblockFactory.eINSTANCE.createProperty();
+ feature.setPropName("Test");
+
+ var feature2 = FunctionblockFactory.eINSTANCE.createProperty();
+ feature2.setPropName("Test");
+
+ fbFeature.properties.add(feature);
+ fbFeature.properties.add(feature2);
+
+ tester.validator().checkProperty(feature);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_PROPERTY_NAME);
+ }
+
+ @Test
+ def test_EntityName_CamelCase() {
+ var entity = FunctionblockFactory.eINSTANCE.createEntity();
+ entity.setName("abc");
+
+ tester.validator().checkEntityName(entity);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENTITYNAME_INVALID_CAMELCASE);
+ }
+
+ @Test
+ def test_EntityName_SuffixReply() {
+ var entity = FunctionblockFactory.eINSTANCE.createEntity();
+ entity.setName("AbcReply");
+
+ tester.validator().checkEntityName(entity);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENTITYNAME_SUFFIX_REPLY);
+ }
+
+ @Test
+ def test_EntityName_SuffixReply_JustReply() {
+ var entity = FunctionblockFactory.eINSTANCE.createEntity();
+ entity.setName("Reply");
+
+ tester.validator().checkEntityName(entity);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENTITYNAME_SUFFIX_REPLY);
+ }
+
+ @Test
+ def test_FBName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+
+ fbmodel.setName("fame")
+
+ tester.validator().checkFunctionBlockName(fbmodel);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_FBNAME_INVALID);
+ }
+
+ @Test
+ def test_Property_Name_SuffixTS(){
+ var property = FunctionblockFactory.eINSTANCE.createProperty();
+ property.setPropName("sodaTS")
+
+ tester.validator().checkPropertyName(property)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_PROPNAME_SUFFIX_TS);
+ }
+
+ @Test
+ def test_Property_Name_Suffixts(){
+ var feature = FunctionblockFactory.eINSTANCE.createProperty();
+ feature.setPropName("products")
+
+ tester.validator().checkPropertyName(feature)
+ tester.diagnose().assertOK()
+ }
+
+ @Test
+ def test_OperationName_Same_EntityName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ var op1=FunctionblockFactory.eINSTANCE.createOperation();
+ var ent = FunctionblockFactory.eINSTANCE.createEntity()
+
+ op1.setMethodName("transAction");
+ ent.setName("TransAction")
+
+ fb.features.add(op1)
+ fbmodel.elements.add(ent)
+ fbmodel.setFunctionblock(fb);
+
+ tester.validator().checkOpNameAgainstEntityName(op1)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_OPERATION_SAME_ENTITYNAME);
+ }
+
+ @Test
+ def test_OperationName_Same_EnumName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ var op1=FunctionblockFactory.eINSTANCE.createOperation();
+ var ent = FunctionblockFactory.eINSTANCE.createEnum()
+
+ op1.setMethodName("transAction");
+ ent.setName("TransAction")
+
+ fb.features.add(op1)
+ fbmodel.enums.add(ent)
+ fbmodel.setFunctionblock(fb);
+
+ tester.validator().checkOpNameAgainstEntityName(op1)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_OPERATION_SAME_ENUMNAME);
+ }
+
+ @Test
+ def test_OperationName_Diff_EnumName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ var op1=FunctionblockFactory.eINSTANCE.createOperation();
+ var ent = FunctionblockFactory.eINSTANCE.createEnum()
+
+ op1.setMethodName("transActionz");
+ ent.setName("TransAction")
+
+ fb.features.add(op1)
+ fbmodel.enums.add(ent)
+ fbmodel.setFunctionblock(fb);
+
+ tester.validator().checkOpNameAgainstEntityName(op1)
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_OperationName_Same_EntityName_Multiple_Op() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ var op1=FunctionblockFactory.eINSTANCE.createOperation();
+ var op2=FunctionblockFactory.eINSTANCE.createOperation();
+ var ent = FunctionblockFactory.eINSTANCE.createEntity()
+ var ent1 = FunctionblockFactory.eINSTANCE.createEntity()
+
+ op1.setMethodName("transAction");
+ op2.setMethodName("action");
+ ent.setName("TransAction")
+ ent1.setName("Trans");
+
+ fb.features.add(op1)
+ fb.features.add(op2)
+ fbmodel.elements.add(ent)
+ fbmodel.elements.add(ent1)
+ fbmodel.setFunctionblock(fb);
+
+ tester.validator().checkOpNameAgainstEntityName(op1)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_OPERATION_SAME_ENTITYNAME);
+ }
+
+ @Test
+ def test_Duplicated_Constraint() {
+ var feature = FunctionblockFactory.eINSTANCE.createPrimitiveProperty();
+
+ feature.type = PrimitiveType.STRING
+
+ var constraint1 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint1.type = ConstraintIntervalType.STRLEN
+ feature.constraints.add(constraint1)
+
+ var constraint2 = FunctionblockFactory.eINSTANCE.createConstraint();
+ constraint2.type = ConstraintIntervalType.STRLEN
+ feature.constraints.add(constraint2)
+
+ tester.validator().checkDuplicatedConstraint(feature);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_CONSTRAINT);
+ }
+
+ @Test
+ def test_FuncBlock_Version_Valid(){
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb.version = "1.1.1-RC"
+
+ tester.validator().checkVersionPattern(fb)
+ tester.diagnose().assertOK
+
+ var fb1 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb1.version = "1.1.1"
+
+ tester.validator().checkVersionPattern(fb1)
+ tester.diagnose().assertOK
+
+ var fb2 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb2.version = "11.11.11"
+
+ tester.validator().checkVersionPattern(fb2)
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_FuncBlock_Version_Invalid(){
+ var fb = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb.version = "1.1"
+
+ tester.validator().checkVersionPattern(fb)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_VERSION_PATTERN);
+
+ var fb1 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb1.version = "1."
+
+ tester.validator().checkVersionPattern(fb1)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_VERSION_PATTERN);
+
+ var fb2 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb2.version = "1"
+
+ tester.validator().checkVersionPattern(fb2)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_VERSION_PATTERN);
+
+ var fb3 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb3.version = "1.1-RC"
+
+ tester.validator().checkVersionPattern(fb3)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_VERSION_PATTERN);
+
+ var fb4 = FunctionblockFactory.eINSTANCE.createFunctionBlock();
+ fb4.version = "1-RC"
+
+ tester.validator().checkVersionPattern(fb4)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_VERSION_PATTERN);
+ }
+
+ @Test
+ def test_Duplicated_Enum() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+
+ var enum1 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum1.setName("Abc");
+
+ var enum2 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum2.setName("Abc");
+
+ fbmodel.getEnums().add(enum1);
+ fbmodel.getEnums().add(enum2);
+
+ tester.validator().checkDuplicateEnumName(enum1);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_ENUM_NAME);
+ }
+
+ @Test
+ def test_Enum_Name() {
+
+ var enum1 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum1.setName("abc");
+
+ tester.validator().checkEnumName(enum1);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENUMNAME_INVALID_CAMELCASE);
+
+ var enum2 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum2.setName("Abc");
+
+ tester.validator().checkEnumName(enum2);
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Duplicated_Literal() {
+ var enum1 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum1.setName("Abc");
+
+ var literal1 = FunctionblockFactory.eINSTANCE.createEnumLiteral
+ var literal2 = FunctionblockFactory.eINSTANCE.createEnumLiteral
+
+ literal1.literal = "green"
+ literal2.literal = "green"
+
+ enum1.enums.add(literal1)
+ enum1.enums.add(literal2)
+
+ tester.validator().checkDuplicatedLiteral(enum1)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_DUPLICATED_ENUM_LITERAL);
+ }
+
+ @Test
+ def test_EntityName_Same_EnumName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var enm = FunctionblockFactory.eINSTANCE.createEnum()
+ var ent = FunctionblockFactory.eINSTANCE.createEntity()
+
+ ent.setName("TransAction")
+ enm.setName("TransAction")
+
+ fbmodel.elements.add(ent)
+ fbmodel.enums.add(enm)
+
+ tester.validator().checkEnumNameAgainstEntityName(enm)
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENTITY_SAME_ENUMNAME);
+ }
+
+ @Test
+ def test_EntityName_Diff_EnumName() {
+ var fbmodel = FunctionblockFactory.eINSTANCE.createFunctionblockModel();
+ var enm = FunctionblockFactory.eINSTANCE.createEnum()
+ var ent = FunctionblockFactory.eINSTANCE.createEntity()
+
+ ent.setName("TransAction")
+ enm.setName("TransActionZ")
+
+ fbmodel.elements.add(ent)
+ fbmodel.enums.add(enm)
+
+ tester.validator().checkEnumNameAgainstEntityName(enm)
+ tester.diagnose().assertOK
+ }
+
+ @Test
+ def test_Enum_Empty_Literal() {
+
+ var enum1 = FunctionblockFactory.eINSTANCE.createEnum();
+ enum1.setName("Abc");
+
+ tester.validator().checkEnum(enum1);
+ tester.diagnose().assertErrorContains(SystemMessage.ERROR_ENUM_CANNOT_BE_EMPTY);
+
+ var lit = FunctionblockFactory.eINSTANCE.createEnumLiteral;
+ lit.setLiteral("test")
+
+ enum1.enums.add(lit)
+
+ tester.validator().checkEnumName(enum1);
+ tester.diagnose().assertOK
+
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.classpath b/bundles/org.eclipse.vorto.fbeditor.ui/.classpath
new file mode 100644
index 0000000..91d2917
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.classpath
@@ -0,0 +1,8 @@
+<classpath>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.gitignore b/bundles/org.eclipse.vorto.fbeditor.ui/.gitignore
new file mode 100644
index 0000000..184cc00
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.gitignore
@@ -0,0 +1,7 @@
+/target
+/bin
+/src-gen
+/xtend-gen
+.DS_Store
+/model/generated
+plugin.xml_gen
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.project b/bundles/org.eclipse.vorto.fbeditor.ui/.project
new file mode 100644
index 0000000..c42b2cf
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.fbeditor.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.m2e.core.prefs b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.xtend.core.Xtend.prefs b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.xtend.core.Xtend.prefs
new file mode 100644
index 0000000..c71588e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/.settings/org.eclipse.xtend.core.Xtend.prefs
@@ -0,0 +1,19 @@
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.directory=xtend-gen
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.ignore=false
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/generated-sources/xtend
+//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.ignore=false
+autobuilding=true
+eclipse.preferences.version=1
+is_project_specific=true
+outlet.DEFAULT_OUTPUT.cleanDirectory=false
+outlet.DEFAULT_OUTPUT.cleanupDerived=true
+outlet.DEFAULT_OUTPUT.createDirectory=true
+outlet.DEFAULT_OUTPUT.derived=true
+outlet.DEFAULT_OUTPUT.description=Output folder for generated Java files
+outlet.DEFAULT_OUTPUT.directory=xtend-gen
+outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
+outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
+outlet.DEFAULT_OUTPUT.keepLocalHistory=false
+outlet.DEFAULT_OUTPUT.name=DEFAULT_OUTPUT
+outlet.DEFAULT_OUTPUT.override=true
+outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.fbeditor.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..cb49af9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Functionblock Editor UI
+Bundle-Vendor: Bosch-SI
+Bundle-Version: 0.1.0
+Bundle-SymbolicName: org.eclipse.vorto.fbeditor.ui; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.vorto.fbeditor;visibility:=reexport,
+ org.eclipse.vorto.metamodel,
+ org.eclipse.vorto.common,
+ org.eclipse.ui.ide;bundle-version="3.9.0",
+ org.eclipse.compare;bundle-version="3.5.0",
+ org.eclipse.xtext.ui;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.builder;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.xbase.ui;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.common.types.ui;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.ui.codetemplates.ui;bundle-version="[2.7.0,3.0.0)",
+ org.eclipse.xtext.ui.shared;bundle-version="[2.7.0,3.0.0)",
+ org.apache.log4j;bundle-version="1.2.0",
+ org.eclipse.core.filesystem;bundle-version="1.4.0",
+ org.apache.commons.lang3;bundle-version="3.1.0",
+ org.apache.commons.io;bundle-version="2.0.1",
+ org.eclipse.ui.editors,
+ org.eclipse.ui,
+ org.eclipse.xtext.xbase.lib,
+ org.antlr.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Export-Package: org.eclipse.vorto.fbeditor.ui.api.project,
+ org.eclipse.vorto.fbeditor.ui.api.perspectives,
+ org.eclipse.vorto.fbeditor.ui.api.serializer,
+ org.eclipse.vorto.fbeditor.ui.contentassist,
+ org.eclipse.vorto.fbeditor.ui.contentassist.antlr,
+ org.eclipse.vorto.fbeditor.ui.internal,
+ org.eclipse.vorto.fbeditor.ui.quickfix
+Bundle-Activator: org.eclipse.vorto.fbeditor.ui.internal.FunctionblockActivator
+Bundle-ClassPath: templates/,.,icons/
+Import-Package: org.apache.log4j
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/about.html b/bundles/org.eclipse.vorto.fbeditor.ui/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.fbeditor.ui/build.properties b/bundles/org.eclipse.vorto.fbeditor.ui/build.properties
new file mode 100644
index 0000000..0c039c5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/build.properties
@@ -0,0 +1,12 @@
+source.. = src/,\
+ src-gen/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ templates/,\
+ icons/,\
+ about.html
+src.includes = templates/,\
+ icons/
+
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/icons/add.gif b/bundles/org.eclipse.vorto.fbeditor.ui/icons/add.gif
new file mode 100644
index 0000000..7380d7a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/icons/add.gif
Binary files differ
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb.png b/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb.png
new file mode 100644
index 0000000..f84bad1
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb.png
Binary files differ
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb_large.png b/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb_large.png
new file mode 100644
index 0000000..de76d09
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/icons/fb_large.png
Binary files differ
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/icons/start.gif b/bundles/org.eclipse.vorto.fbeditor.ui/icons/start.gif
new file mode 100644
index 0000000..57f4102
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/icons/start.gif
Binary files differ
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/plugin.xml b/bundles/org.eclipse.vorto.fbeditor.ui/plugin.xml
new file mode 100644
index 0000000..7998722
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/plugin.xml
@@ -0,0 +1,483 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ class="org.eclipse.vorto.fbeditor.ui.internal.VortoTreeViewPart"
+ id="org.eclipse.vorto.perspectives.vortotreeview"
+ name="Function Block Models"
+ icon="icons/fb_large.png"
+ restorable="true">
+ </view>
+ </extension>
+ <extension point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID="org.eclipse.vorto.perspectives.api.VortoPerspective">
+ <view
+ id="org.eclipse.ui.console.ConsoleView"
+ relationship="bottom"
+ ratio="0.8"
+ relative="org.eclipse.ui.editorss"/>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
+ contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
+ default="true"
+ extensions="fbmodel"
+ id="org.eclipse.vorto.fbeditor.Functionblock"
+ name="Functionblock Editor">
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
+ commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
+ commandId="org.eclipse.vorto.fbeditor.Functionblock.validate">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </activeWhen>
+ </handler>
+ <!-- copy qualified name -->
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
+ commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
+ <activeWhen>
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened" />
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
+ commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
+ <activeWhen>
+ <and>
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.XtextEditor.opened" />
+ <iterate>
+ <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+ </iterate>
+ </and>
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension point="org.eclipse.core.expressions.definitions">
+ <definition id="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ <and>
+ <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
+ <with variable="activeEditor">
+ <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
+ value="org.eclipse.vorto.fbeditor.Functionblock"
+ forcePluginActivation="true"/>
+ </with>
+ </and>
+ </definition>
+ <definition id="org.eclipse.vorto.fbeditor.Functionblock.XtextEditor.opened">
+ <and>
+ <reference definitionId="isXtextEditorActive"/>
+ <with variable="activeEditor">
+ <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
+ value="org.eclipse.vorto.fbeditor.Functionblock"
+ forcePluginActivation="true"/>
+ </with>
+ </and>
+ </definition>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock"
+ name="Functionblock">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ </page>
+ <page
+ category="org.eclipse.vorto.fbeditor.Functionblock"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock.coloring"
+ name="Syntax Coloring">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ </page>
+ <page
+ category="org.eclipse.vorto.fbeditor.Functionblock"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock.templates"
+ name="Templates">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock"
+ name="Functionblock">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject"/>
+ </enabledWhen>
+ <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.keywords">
+ <keyword
+ id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"
+ label="Functionblock"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="Trigger expensive validation"
+ id="org.eclipse.vorto.fbeditor.Functionblock.validate"
+ name="Validate">
+ </command>
+ <!-- copy qualified name -->
+ <command
+ id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+ categoryId="org.eclipse.ui.category.edit"
+ description="Copy the qualified name for the selected element"
+ name="Copy Qualified Name">
+ </command>
+ <command
+ id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
+ categoryId="org.eclipse.ui.category.edit"
+ description="Copy the qualified name for the selected element"
+ name="Copy Qualified Name">
+ </command>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:#TextEditorContext?after=group.edit">
+ <command
+ commandId="org.eclipse.vorto.fbeditor.Functionblock.validate"
+ style="push"
+ tooltip="Trigger expensive validation">
+ <visibleWhen checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- copy qualified name -->
+ <menuContribution locationURI="popup:#TextEditorContext?after=copy">
+ <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+ style="push" tooltip="Copy Qualified Name">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened" />
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution locationURI="menu:edit?after=copy">
+ <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+ style="push" tooltip="Copy Qualified Name">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened" />
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
+ <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
+ style="push" tooltip="Copy Qualified Name">
+ <visibleWhen checkEnabled="false">
+ <and>
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.XtextEditor.opened" />
+ <iterate>
+ <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+ </iterate>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
+ <command commandId="org.eclipse.xtext.ui.editor.FindReferences">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
+ commandId="org.eclipse.xtext.ui.editor.FindReferences">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </activeWhen>
+ </handler>
+ </extension>
+
+<!-- adding resource factories -->
+
+ <extension
+ point="org.eclipse.emf.ecore.extension_parser">
+ <parser
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
+ type="fbmodel">
+ </parser>
+ </extension>
+ <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
+ <resourceServiceProvider
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
+ uriExtension="fbmodel">
+ </resourceServiceProvider>
+ </extension>
+
+
+ <!-- marker definitions for org.eclipse.vorto.fbeditor.Functionblock -->
+ <extension
+ id="functionblock.check.fast"
+ name="Functionblock Problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.xtext.ui.check.fast"/>
+ <persistent value="true"/>
+ </extension>
+ <extension
+ id="functionblock.check.normal"
+ name="Functionblock Problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.xtext.ui.check.normal"/>
+ <persistent value="true"/>
+ </extension>
+ <extension
+ id="functionblock.check.expensive"
+ name="Functionblock Problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.xtext.ui.check.expensive"/>
+ <persistent value="true"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.xtext.builder.participant">
+ <participant
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
+ fileExtensions="fbmodel"
+ >
+ </participant>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.vorto.fbeditor.Functionblock"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock.compiler.preferencePage"
+ name="Compiler">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ category="org.eclipse.vorto.fbeditor.Functionblock"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock.compiler.propertyPage"
+ name="Compiler">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject"/>
+ </enabledWhen>
+ <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
+ </page>
+ </extension>
+
+ <!-- Quick Outline -->
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
+ commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="Open the quick outline."
+ id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+ name="Quick Outline">
+ </command>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:#TextEditorContext?after=group.open">
+ <command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+ style="push"
+ tooltip="Open Quick Outline">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened"/>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <!-- quickfix marker resolution generator for org.eclipse.vorto.fbeditor.Functionblock -->
+ <extension
+ point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+ markerType="org.eclipse.vorto.fbeditor.ui.functionblock.check.fast">
+ <attribute
+ name="FIXABLE_KEY"
+ value="true">
+ </attribute>
+ </markerResolutionGenerator>
+ <markerResolutionGenerator
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+ markerType="org.eclipse.vorto.fbeditor.ui.functionblock.check.normal">
+ <attribute
+ name="FIXABLE_KEY"
+ value="true">
+ </attribute>
+ </markerResolutionGenerator>
+ <markerResolutionGenerator
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+ markerType="org.eclipse.vorto.fbeditor.ui.functionblock.check.expensive">
+ <attribute
+ name="FIXABLE_KEY"
+ value="true">
+ </attribute>
+ </markerResolutionGenerator>
+ </extension>
+ <!-- Rename Refactoring -->
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
+ commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:#TextEditorContext?after=group.edit">
+ <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.vorto.fbeditor.Functionblock.Editor.opened">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.vorto.fbeditor.Functionblock"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
+ id="org.eclipse.vorto.fbeditor.Functionblock.refactoring"
+ name="Refactoring">
+ <keywordReference id="org.eclipse.vorto.fbeditor.ui.keyword_Functionblock"/>
+ </page>
+ </extension>
+
+ <extension point="org.eclipse.compare.contentViewers">
+ <viewer id="org.eclipse.vorto.fbeditor.Functionblock.compare.contentViewers"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
+ extensions="fbmodel">
+ </viewer>
+ </extension>
+ <extension point="org.eclipse.compare.contentMergeViewers">
+ <viewer id="org.eclipse.vorto.fbeditor.Functionblock.compare.contentMergeViewers"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
+ extensions="fbmodel" label="Functionblock Compare">
+ </viewer>
+ </extension>
+ <extension point="org.eclipse.ui.editors.documentProviders">
+ <provider id="org.eclipse.vorto.fbeditor.Functionblock.editors.documentProviders"
+ class="org.eclipse.vorto.fbeditor.ui.FunctionblockExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
+ extensions="fbmodel">
+ </provider>
+ </extension>
+
+ <!-- Wizards -->
+
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ name="Vorto"
+ id="org.eclipse.vorto.functionblock.ui.wizards">
+ </category>
+ <wizard
+ category="org.eclipse.vorto.functionblock.ui.wizards"
+ class="org.eclipse.vorto.fbeditor.ui.internal.wizards.IoTWizard"
+ finalPerspective="org.eclipse.vorto.perspectives.api.VortoPerspective"
+ icon="icons/fb.png"
+ id="org.eclipse.vorto.fbeditor.ui.wizards.IoTWizard"
+ name="Function Block Model"
+ project="true">
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
+ <menu
+ id="org.eclipse.vorto.project.menu"
+ label="Vorto">
+ </menu>
+ </menuContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.vorto.perspectives.vortotreeview">
+ <command
+ commandId="org.eclipse.vorto.fbeditor.ui.command1.newfbproject"
+ id="id.package.menu.newfb"
+ icon="icons/add.gif"
+ label="Create new Function Block">
+ </command>
+ <separator name="additions1" visible="true"/>
+ </menuContribution>
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.vorto.project.menu">
+ <command
+ commandId="org.eclipse.vorto.fbeditor.ui.command1.newfbproject"
+ icon="icons/add.gif"
+ label="Create new Function Block Model">
+ </command>
+ <separator name="additions1" visible="true"/>
+ </menuContribution>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command defaultHandler="org.eclipse.vorto.fbeditor.ui.internal.command.NewFunctionBlockProjectCommand"
+ id="org.eclipse.vorto.fbeditor.ui.command1.newfbproject" name="NewFunctionBlockProjectCommand">
+ </command>
+ </extension>
+</plugin>
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/pom.xml b/bundles/org.eclipse.vorto.fbeditor.ui/pom.xml
new file mode 100644
index 0000000..78a8530
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/pom.xml
@@ -0,0 +1,105 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.fbeditor.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Function Block Designer UI</name>
+
+ <profiles>
+ <profile>
+ <id>copy-plugins</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-kepler</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor.ui</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${kepler.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-luna</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor.ui</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${luna.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-visualrules</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor.ui</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${visualrules.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/FunctionblockUiModule.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/FunctionblockUiModule.java
new file mode 100644
index 0000000..aef5a6c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/FunctionblockUiModule.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ *
+ *
+ * Use this class to register components to be used within the IDE.
+ */
+public class FunctionblockUiModule extends
+ org.eclipse.vorto.fbeditor.ui.AbstractFunctionblockUiModule {
+ public FunctionblockUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/perspectives/VortoPerspective.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/perspectives/VortoPerspective.java
new file mode 100644
index 0000000..637f5c0
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/perspectives/VortoPerspective.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.api.perspectives;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.vorto.api.common.ApplicationConstants;
+
+
+public class VortoPerspective implements IPerspectiveFactory {
+
+ @Override
+ public void createInitialLayout(IPageLayout layout) {
+
+ layout.createFolder("left", IPageLayout.LEFT, 0.2f,
+ IPageLayout.ID_EDITOR_AREA);
+ layout.createFolder("right", IPageLayout.RIGHT, 0.6f,
+ IPageLayout.ID_EDITOR_AREA);
+ layout.createFolder("bottom", IPageLayout.BOTTOM, 0.8f,
+ IPageLayout.ID_EDITOR_AREA);
+ layout.createFolder("top", IPageLayout.TOP, 0.6f,
+ IPageLayout.ID_EDITOR_AREA);
+ layout.addView(ApplicationConstants.VORTO_TREE_VIEW_ID, IPageLayout.LEFT,
+ 0.25f, layout.getEditorArea());
+
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/project/ProjectCreationTask.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/project/ProjectCreationTask.java
new file mode 100644
index 0000000..376ac16
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/project/ProjectCreationTask.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.api.project;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.vorto.api.common.generation.FunctionBlockMetaData;
+import org.eclipse.vorto.api.common.project.IoTModelProject;
+import org.eclipse.vorto.api.common.project.nature.IoTProjectNature;
+import org.eclipse.vorto.api.ui.progresstask.IProgressTask;
+import org.eclipse.vorto.api.ui.progresstask.TaskParameter;
+import org.eclipse.vorto.fbeditor.ui.internal.template.FbmodelTemplateFileContent;
+
+
+public class ProjectCreationTask implements IProgressTask {
+
+ public static final String SRC_MODELS = "src/models/";
+ public static final String FUNCTION_BLOCK_META_DATA = "FunctionBlockMetaData";
+ public static final String WORK_SPACE = "WorkSpace";
+ public static final String PROJECT_NAME = "ProjectName";
+
+ private String errorMessage = "";
+
+ private String projectName;
+ private String workspaceLocation;
+ private FunctionBlockMetaData userInput;
+ private IWorkspace workspace;
+
+ public static final String XTEXT_NATURE = "org.eclipse.xtext.ui.shared.xtextNature";
+ public static final String JAVA_NATURE = "org.eclipse.jdt.core.javanature";
+ public static final String TARGET_JAVA_CLASS_FOLDER = "target/classes";
+ public static final String ADDITIONAL_SOURCES_FOLDER = "target/generated-sources";
+
+ private IoTModelProject iotproject;
+
+ private static final Logger logger = Logger.getLogger(ProjectCreationTask.class);
+
+ protected ProjectCreationTask() {
+ }
+
+ public ProjectCreationTask(TaskParameter param) {
+ projectName = (String) param.get(PROJECT_NAME);
+ workspaceLocation = (String) param.get(WORK_SPACE);
+ userInput = (FunctionBlockMetaData) param.get(FUNCTION_BLOCK_META_DATA);
+
+ workspace = ResourcesPlugin.getWorkspace();
+ }
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ try {
+ IProject project = createProjectInWorkspace(monitor);
+ project.open(new SubProgressMonitor(monitor, 1));
+ setProjectNatures(project, monitor);
+
+ monitor.beginTask("Generating project-specific resources", 2);
+
+ generateFolders(project);
+
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+
+ createTemplateFbmodel(project);
+
+ monitor.worked(1);
+
+ monitor.beginTask("Refreshing Project to reflect changes", 1);
+ monitor.worked(1);
+
+ setIotproject(new IoTModelProject(project));
+
+ getIotproject().refresh(monitor);
+
+ } catch (CoreException e) {
+ this.errorMessage = e.getMessage();
+ throw new RuntimeException("Problem when creating project, error: "
+ + e.getMessage(), e);
+ } finally {
+ monitor.done();
+ }
+
+ }
+
+ private void createTemplateFbmodel(IProject project) {
+ String fbfilename = userInput.getName() + ".fbmodel";
+
+ FbmodelTemplateFileContent gen = new FbmodelTemplateFileContent(
+ userInput);
+ InputStream ctInputStream = IOUtils.toInputStream(gen
+ .getFbModelContent());
+ IFolder folder = project.getFolder(SRC_MODELS);
+ IFile file = folder.getFile(fbfilename);
+
+ try {
+ file.create(ctInputStream, false, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ this.errorMessage = "fbmodel file creation error";
+ }
+ }
+
+ private void generateFolders(IProject project) throws CoreException {
+ String[] folders = { "src", SRC_MODELS };
+
+ for (String f : folders) {
+ createProjectFolders(f, project);
+ }
+ }
+
+ protected IFolder createProjectFolders(String folderPath, IProject project)
+ throws CoreException {
+ IFolder folder = project.getFolder(folderPath);
+ if (!folder.exists()) {
+ boolean created = folder.getLocation().toFile().mkdirs();
+ if(!created) {
+ logger.info("Folder not created at " + folder.getLocation().toFile().getPath());
+ //throw exception here?
+ //this.errorMessage = "Folder not created at " + folder.getLocation().toFile().getPath();
+ //throw new RuntimeException(errorMessage);
+ }
+ folder.refreshLocal(1, null);
+ folder = project.getFolder(folderPath);
+ }
+ return folder;
+ }
+
+ private void setProjectNatures(IProject project, IProgressMonitor monitor)
+ throws CoreException {
+ monitor.beginTask("Setting Project Nature", 1);
+ IProjectDescription description = project.getDescription();
+ description.setNatureIds(resolveProjectNatures());
+ project.setDescription(description, monitor);
+ }
+
+ private String[] resolveProjectNatures() {
+ return new String[] { XTEXT_NATURE, IoTProjectNature.NATURE_ID };
+ }
+
+ private IProject createProjectInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ IWorkspaceRoot root = workspace.getRoot();
+ IProject project = root.getProject(projectName);
+ IProjectDescription desc = workspace.newProjectDescription(projectName);
+
+ desc.setLocation(getValidPath());
+
+ if (!isDefaultWorkLocation()) {
+ project.create(desc, new SubProgressMonitor(monitor, 1));
+ } else {
+ project.create(new SubProgressMonitor(monitor, 1));
+ }
+ return project;
+ }
+
+ private IPath getValidPath() {
+ URI uri = null;
+ try {
+ uri = URIUtil.fromString(workspaceLocation + "/" + projectName);
+
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(
+ "Invalid workspace location provided", e);
+ }
+
+ return new Path(uri.toString());
+ }
+
+ private boolean isDefaultWorkLocation() {
+ String defaultWorkspace = workspace.getRoot().getLocation().toString();
+ return StringUtils.equals(defaultWorkspace, workspaceLocation);
+ }
+
+ @Override
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public IoTModelProject getIotproject() {
+ return iotproject;
+ }
+
+ public void setIotproject(IoTModelProject iotproject) {
+ this.iotproject = iotproject;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public String getWorkspaceLocation() {
+ return workspaceLocation;
+ }
+
+ public void setWorkspaceLocation(String workspaceLocation) {
+ this.workspaceLocation = workspaceLocation;
+ }
+
+ public FunctionBlockMetaData getUserInput() {
+ return userInput;
+ }
+
+ public void setUserInput(FunctionBlockMetaData userInput) {
+ this.userInput = userInput;
+ }
+
+ public IWorkspace getWorkspace() {
+ return workspace;
+ }
+
+ public void setWorkspace(IWorkspace workspace) {
+ this.workspace = workspace;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/FunctionBlockSerializerFactory.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/FunctionBlockSerializerFactory.java
new file mode 100644
index 0000000..99641cf
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/FunctionBlockSerializerFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.api.serializer;
+
+import org.eclipse.vorto.fbeditor.ui.internal.serializer.FunctionBlockSerializer;
+
+
+public final class FunctionBlockSerializerFactory {
+
+ private static FunctionBlockSerializerFactory inst = null;
+
+ private FunctionBlockSerializerFactory(){
+
+ }
+
+ public static FunctionBlockSerializerFactory getInstance() {
+ if (inst == null) {
+ inst = new FunctionBlockSerializerFactory();
+ }
+ return inst;
+ }
+
+ public IFunctionBlockSerializer getDefaultSerializer(){
+ return new FunctionBlockSerializer();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/IFunctionBlockSerializer.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/IFunctionBlockSerializer.java
new file mode 100644
index 0000000..31c807d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/api/serializer/IFunctionBlockSerializer.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.api.serializer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+
+
+public interface IFunctionBlockSerializer {
+
+ /**
+ * Save the domain model into the DSL file.
+ *
+ * @param fbm
+ * @return
+ * @throws CoreException
+ */
+ String serialize(FunctionblockModel fbm) throws CoreException;
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/contentassist/FunctionblockProposalProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/contentassist/FunctionblockProposalProvider.xtend
new file mode 100644
index 0000000..532b27a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/contentassist/FunctionblockProposalProvider.xtend
@@ -0,0 +1,12 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.ui.contentassist
+
+import org.eclipse.vorto.fbeditor.ui.contentassist.AbstractFunctionblockProposalProvider
+
+/**
+ * see http://www.eclipse.org/Xtext/documentation.html#contentAssist on how to customize content assistant
+ */
+class FunctionblockProposalProvider extends AbstractFunctionblockProposalProvider {
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/highlight/FunctionBlockHighlightConfiguration.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/highlight/FunctionBlockHighlightConfiguration.xtend
new file mode 100644
index 0000000..d3e3d31
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/highlight/FunctionBlockHighlightConfiguration.xtend
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+ package org.eclipse.vorto.fbeditor.ui.highlight;
+
+import org.eclipse.swt.graphics.RGB
+import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor
+import org.eclipse.xtext.ui.editor.utils.TextStyle
+
+public class FunctionBlockHighlightConfiguration extends
+ DefaultHighlightingConfiguration {
+
+ public static final String ENTITY_ID = "Entity ID";
+
+ override void configure(IHighlightingConfigurationAcceptor acceptor) {
+ acceptor.acceptDefaultHighlighting(ENTITY_ID, "ENTITYID", entityTextStyle());
+ super.configure(acceptor);
+ }
+
+ def TextStyle entityTextStyle() {
+ var textStyle = defaultTextStyle();
+ textStyle.setBackgroundColor(new RGB(42, 0, 255));
+ textStyle
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/VortoTreeViewPart.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/VortoTreeViewPart.java
new file mode 100644
index 0000000..e340a7a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/VortoTreeViewPart.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.vorto.api.common.project.IoTModelProject;
+import org.eclipse.vorto.api.ui.changeevent.ProjectChangeEvent;
+import org.eclipse.vorto.api.ui.changeevent.ProjectEventListenerRegistry;
+import org.eclipse.vorto.fbeditor.ui.internal.treeview.FBContentProvider;
+import org.eclipse.vorto.fbeditor.ui.internal.treeview.FBLabelProvider;
+
+
+public class VortoTreeViewPart extends ViewPart {
+
+ protected TreeViewer treeViewer;
+ protected FBContentProvider fbContentProvider;
+ protected FBLabelProvider labelProvider;
+
+ public VortoTreeViewPart() {
+
+ }
+
+ public void createPartControl(Composite parent) {
+
+ // Create the tree viewer as a child of the composite parent
+ treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ this.fbContentProvider = new FBContentProvider();
+ ProjectEventListenerRegistry.getInstance().add(fbContentProvider);
+ treeViewer.setContentProvider(fbContentProvider);
+ labelProvider = new FBLabelProvider();
+ treeViewer.setLabelProvider(labelProvider);
+
+ treeViewer.setUseHashlookup(true);
+
+ hookListeners();
+
+ treeViewer.setInput("Root");
+ ColumnViewerToolTipSupport.enableFor(treeViewer);
+
+ getSite().setSelectionProvider(treeViewer);
+ initContextMenu();
+ }
+
+ private void initContextMenu() {
+ // initalize the context menu
+ MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ Menu menu = menuMgr.createContextMenu(this.treeViewer.getTree());
+ this.treeViewer.getTree().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, this.treeViewer);
+ }
+
+ protected void hookListeners() {
+ addSelectionChangedEventListener();
+ addWorkspaceChangeEventListenr();
+ }
+
+ public ImageDescriptor getImage(String imageFileName) {
+
+ URL url;
+ try {
+ url = new URL(
+ "platform:/plugin/org.eclipse.vorto.fbeditor.ui/icons/"
+ + imageFileName);
+ return ImageDescriptor.createFromURL(url);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ protected void addWorkspaceChangeEventListenr() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ /**
+ * @@TODo Here it seems to fire event for every resource changed, thus
+ * creation of one project fire the event multiple times we
+ * should filter it to improve performance
+ */
+ IResourceChangeListener rcl = new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event) {
+
+ try {
+ if (event.getDelta() == null
+ || event.getDelta().getResource() == null) {
+ return;
+ }
+
+ ProjectEventListenerRegistry.getInstance().fire(
+ new ProjectChangeEvent());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ workspace.addResourceChangeListener(rcl);
+ }
+
+ protected void addSelectionChangedEventListener() {
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ // if the selection is empty clear the label
+ if (event.getSelection().isEmpty()) {
+ // text.setText("");
+ return;
+ }
+ if (event.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) event
+ .getSelection();
+ if (selection.size() > 0) {
+ if (!(selection.getFirstElement() instanceof IoTModelProject)) {
+ return;
+ }
+ IoTModelProject fbDesignProject = (IoTModelProject) selection
+ .getFirstElement();
+ openFileInEditor(fbDesignProject);
+ }
+ }
+ }
+ });
+ }
+
+ private void openFileInEditor(IoTModelProject project) {
+ File fileToOpen = project.getFbModelFile();
+
+ if (fileToOpen.exists() && fileToOpen.isFile()) {
+ org.eclipse.core.filesystem.IFileStore fileStore = EFS
+ .getLocalFileSystem().getStore(fileToOpen.toURI());
+ org.eclipse.ui.IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+
+ try {
+ IDE.openEditorOnFileStore(page, fileStore);
+ } catch (org.eclipse.ui.PartInitException e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("File not found for: "
+ + project.getFbModelFile());
+ }
+ }
+
+ @Override
+ public void setFocus() {
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/command/NewFunctionBlockProjectCommand.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/command/NewFunctionBlockProjectCommand.java
new file mode 100644
index 0000000..550d26d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/command/NewFunctionBlockProjectCommand.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.command;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.vorto.fbeditor.ui.internal.wizards.IoTWizard;
+
+
+public class NewFunctionBlockProjectCommand extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IoTWizard wizard = new IoTWizard();
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.create();
+ dialog.open();
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/serializer/FunctionBlockSerializer.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/serializer/FunctionBlockSerializer.java
new file mode 100644
index 0000000..dda43c2
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/serializer/FunctionBlockSerializer.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.serializer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.vorto.fbeditor.FunctionblockRuntimeModule;
+import org.eclipse.vorto.fbeditor.ui.api.serializer.IFunctionBlockSerializer;
+import org.eclipse.vorto.functionblock.FunctionblockModel;
+import org.eclipse.xtext.resource.IResourceFactory;
+
+import com.google.inject.Guice;
+
+
+public class FunctionBlockSerializer implements IFunctionBlockSerializer {
+
+ public String serialize(FunctionblockModel model) {
+ IResourceFactory resourceFactory = Guice.createInjector(
+ new FunctionblockRuntimeModule()).getInstance(
+ IResourceFactory.class);
+ Resource resource = resourceFactory.createResource(URI
+ .createURI("fakeDsl.fbmodel"));
+ resource.getContents().add(model);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ resource.save(baos, new HashMap<String, String>());
+ return new String(baos.toByteArray(), "utf-8");
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Something went wrong during serialization", e);
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/template/FbmodelTemplateFileContent.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/template/FbmodelTemplateFileContent.xtend
new file mode 100644
index 0000000..12b6776
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/template/FbmodelTemplateFileContent.xtend
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+ package org.eclipse.vorto.fbeditor.ui.internal.template
+
+import org.eclipse.vorto.api.common.generation.FunctionBlockMetaData
+
+class FbmodelTemplateFileContent {
+
+ FunctionBlockMetaData context;
+
+ new (FunctionBlockMetaData context) {
+ this.context = context;
+ }
+
+ public def String getFbModelContent() {
+ return '''
+functionblock «context.name» {
+ displayname "«context.displayName»"
+ description "«context.description»"
+ vendor www.bosch.com
+ category demo
+ version «context.version»
+
+ configuration{
+ //Please enter functionblock configuration details.
+ }
+
+ status{
+ //Please enter functionblock status details.
+ }
+
+ fault{
+ //Please enter functionblock fault configuration.
+ }
+
+ operations{
+ //Please enter functionblock operations.
+ }
+}
+ '''
+ }
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBContentProvider.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBContentProvider.java
new file mode 100644
index 0000000..f28eddd
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBContentProvider.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.treeview;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.vorto.api.ui.changeevent.ProjectChangeEvent;
+import org.eclipse.vorto.api.ui.changeevent.IProjectChangeListener;
+
+
+public class FBContentProvider implements ITreeContentProvider,
+ IProjectChangeListener {
+ TreeViewer treeViewer = null;
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.treeViewer = (TreeViewer) viewer;
+ }
+
+ /*
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /*
+ * @see ITreeContentProvider#getChildren(Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ return new FunctionBlockScanner().readAllFunctionBlocksFromWorkspace()
+ .toArray();
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ @Override
+ public void projectChanged(ProjectChangeEvent event) {
+
+ final Object[] projects = new FunctionBlockScanner()
+ .readAllFunctionBlocksFromWorkspace().toArray();
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ try {
+ treeViewer.setInput(projects);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBLabelProvider.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBLabelProvider.java
new file mode 100644
index 0000000..f296d00
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FBLabelProvider.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.treeview;
+
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.vorto.api.common.project.IoTModelProject;
+
+
+public class FBLabelProvider extends ColumnLabelProvider implements
+ ILabelProvider {
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public Image getImage(Object element) {
+
+ URL url;
+ try {
+ url = new URL(
+ "platform:/plugin/org.eclipse.vorto.fbeditor.ui/icons/fb.png");
+ return ImageDescriptor.createFromURL(url).createImage();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ IoTModelProject project = (IoTModelProject) element;
+ return project.getFunctionBlockModel().getFunctionblock()
+ .getDisplayname();
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ IoTModelProject project = (IoTModelProject) element;
+ return project.getFunctionBlockModel().getFunctionblock()
+ .getDescription();
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FunctionBlockScanner.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FunctionBlockScanner.java
new file mode 100644
index 0000000..fcbae2d
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/treeview/FunctionBlockScanner.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.treeview;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.vorto.api.common.project.FunctionModelModelFileFinder;
+import org.eclipse.vorto.api.common.project.IoTModelProject;
+
+
+public class FunctionBlockScanner {
+
+ public List<IoTModelProject> readAllFunctionBlocksFromWorkspace() {
+ List<IoTModelProject> fbDesignProjects = new ArrayList<IoTModelProject>();
+
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ for (IProject iProject : projects) {
+ try {
+
+ if (iProject.isOpen() && isFunctionBlockProject(iProject)) {
+ fbDesignProjects.add(new IoTModelProject(iProject));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return fbDesignProjects;
+ }
+
+ private boolean isFunctionBlockProject(IProject iProject) {
+ File fbModelFile = FunctionModelModelFileFinder
+ .getFunctionModelFile(iProject);
+ return fbModelFile != null;
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizard.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizard.java
new file mode 100644
index 0000000..8904647
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizard.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.wizards;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.vorto.api.common.generation.FunctionBlockMetaData;
+import org.eclipse.vorto.api.common.project.WizardUtil;
+import org.eclipse.vorto.api.ui.changeevent.ProjectChangeEvent;
+import org.eclipse.vorto.api.ui.changeevent.ProjectEventListenerRegistry;
+import org.eclipse.vorto.api.ui.progresstask.TaskParameter;
+import org.eclipse.vorto.api.ui.progresstask.service.ProgressTaskExecutionService;
+import org.eclipse.vorto.fbeditor.ui.api.project.ProjectCreationTask;
+
+
+public class IoTWizard extends Wizard implements INewWizard,
+ IExecutableExtension {
+
+ private IoTWizardPage iotWizardPage;
+ private IConfigurationElement configurationElement;
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ @Override
+ public void addPages() {
+ iotWizardPage = new IoTWizardPage("wizardPage");
+ iotWizardPage.setTitle("Create Function Block Model");
+ iotWizardPage
+ .setDescription("Please enter the details for creating function block model project.");
+ addPage(iotWizardPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ TaskParameter param = getTaskParameter();
+
+ ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService
+ .getProgressTaskExecutionService();
+ progressTaskExecutionService.syncRun(new ProjectCreationTask(param));
+
+ openFBModelWithDefaultEditor();
+
+ fireRefreshEvent();
+
+ BasicNewProjectResourceWizard
+ .updatePerspective(getConfigurationElement());
+
+ return true;
+ }
+
+ private TaskParameter getTaskParameter() {
+ String projectName = iotWizardPage.getProjectName();
+ String workspaceLocation = iotWizardPage.getWorkspaceLocation();
+ FunctionBlockMetaData userInput = collectFbUserInput();
+
+ TaskParameter param = new TaskParameter();
+ param.add(ProjectCreationTask.PROJECT_NAME, projectName);
+ param.add(ProjectCreationTask.WORK_SPACE, workspaceLocation);
+ param.add(ProjectCreationTask.FUNCTION_BLOCK_META_DATA, userInput);
+ return param;
+ }
+
+ private FunctionBlockMetaData collectFbUserInput() {
+ FunctionBlockMetaData fbUserInput = new FunctionBlockMetaData(
+ iotWizardPage.getFunctionBlockName());
+ fbUserInput.setVersion(iotWizardPage.getFunctionBlockVersion());
+ String description = iotWizardPage.getFunctionBlockDescription();
+ fbUserInput.setDescription(description);
+ return fbUserInput;
+ }
+
+ private void openFBModelWithDefaultEditor() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ String fbName = iotWizardPage.getFunctionBlockName();
+ IProject project = workspace.getRoot().getProject(
+ iotWizardPage.getProjectName());
+ final IFile fbfile = project.getFile("/src/models/" + fbName
+ + ".fbmodel");
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchWindow activeWindow = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ if (activeWindow != null) {
+ IWorkbenchPage page = activeWindow.getActivePage();
+ if (page != null) {
+ try {
+ IDE.openEditor(page, fbfile);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+ public void fireRefreshEvent() {
+ ProjectEventListenerRegistry.getInstance().fire(
+ new ProjectChangeEvent());
+ }
+
+ @Override
+ public void setInitializationData(IConfigurationElement config,
+ String propertyName, Object data) throws CoreException {
+
+ this.configurationElement = config;
+
+ }
+
+ public IConfigurationElement getConfigurationElement() {
+ if (this.configurationElement != null) {
+ return this.configurationElement;
+ } else {
+ return WizardUtil.getWizardConfigurationElement(this.getClass()
+ .getName());
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizardPage.java b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizardPage.java
new file mode 100644
index 0000000..f9dfb77
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/internal/wizards/IoTWizardPage.java
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.ui.internal.wizards;
+
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.vorto.api.common.generation.FunctionBlockMetaData;
+
+import com.google.common.base.Strings;
+
+
+public class IoTWizardPage extends WizardPage {
+
+ public static final String PROJECTNAME_REGEX = "[^a-zA-Z0-9 \\._]";
+
+ public static final String FUNCTIONBLOCK_REGEX = "^[A-Z][a-zA-Z]*$";
+ public static final String VERSION_REGEX = "^\\d+\\.\\d+\\.\\d+(-\\w+)*$";
+ public static final String DEFAULT_DESCRIPTION = "Function block model for ";
+ public static final String DEFAULT_FUNCTIONBLOCK_NAME = "NewFunctionBlock";
+ private Text txtFunctionBlockName;
+ private Text txtVersion;
+ private Text txtProjectName;
+ private Text txtWorkspaceLocation;
+ private Text txtDescription;
+ private String workspaceLocation;
+
+ public IoTWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * Create contents of the wizard.
+ *
+ * @param parent
+ */
+ public void createControl(Composite parent) {
+ Composite topContainer = new Composite(parent, SWT.NULL);
+
+ setControl(topContainer);
+ topContainer.setLayout(new GridLayout(1, false));
+
+ Group grpFunctionBlock = new Group(topContainer, SWT.NONE);
+ grpFunctionBlock.setText("Function Block Details");
+ grpFunctionBlock.setLayout(new GridLayout(2, false));
+ GridData gridGroupFunctionBlock = new GridData(SWT.LEFT, SWT.CENTER,
+ false, false, 1, 1);
+ gridGroupFunctionBlock.heightHint = 134;
+ gridGroupFunctionBlock.widthHint = 570;
+ grpFunctionBlock.setLayoutData(gridGroupFunctionBlock);
+
+ Label lblFunctionBlockName = new Label(grpFunctionBlock, SWT.NONE);
+ lblFunctionBlockName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
+ false, false, 1, 1));
+ lblFunctionBlockName.setText("Function Block Name:");
+
+ txtFunctionBlockName = new Text(grpFunctionBlock, SWT.BORDER);
+ GridData gridTxtFunctionBlockName = new GridData(SWT.FILL, SWT.CENTER,
+ false, false, 1, 1);
+ gridTxtFunctionBlockName.widthHint = 400;
+ txtFunctionBlockName.setLayoutData(gridTxtFunctionBlockName);
+ txtFunctionBlockName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ fbNameChanged();
+ dialogChanged();
+
+ }
+ });
+
+ Label lblVersion = new Label(grpFunctionBlock, SWT.NONE);
+ lblVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
+ false, 1, 1));
+ lblVersion.setText("Version:");
+
+ txtVersion = new Text(grpFunctionBlock, SWT.BORDER);
+ GridData gridTxtVersion = new GridData(SWT.FILL, SWT.CENTER, false,
+ false, 1, 1);
+ gridTxtVersion.widthHint = 411;
+ txtVersion.setLayoutData(gridTxtVersion);
+ txtVersion.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ fbNameChanged();
+ dialogChanged();
+ }
+ });
+
+ Label lblDescription = new Label(grpFunctionBlock, SWT.NONE);
+ lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
+ false, 1, 1));
+ lblDescription.setText("Description:");
+
+ txtDescription = new Text(grpFunctionBlock, SWT.BORDER | SWT.V_SCROLL
+ | SWT.MULTI);
+ GridData gridTxtDescription = new GridData(SWT.FILL, SWT.TOP, true,
+ false, 1, 1);
+ gridTxtDescription.heightHint = 53;
+ txtDescription.setLayoutData(gridTxtDescription);
+
+ Group grpProjectDetails = new Group(topContainer, SWT.NONE);
+ grpProjectDetails.setLayout(new GridLayout(3, false));
+ GridData gridGrpProjectDetails = new GridData(SWT.CENTER, SWT.CENTER,
+ false, false, 1, 1);
+ gridGrpProjectDetails.heightHint = 97;
+ gridGrpProjectDetails.widthHint = 575;
+ grpProjectDetails.setLayoutData(gridGrpProjectDetails);
+ grpProjectDetails.setText("Project Details");
+
+ Label lblProjectName = new Label(grpProjectDetails, SWT.NONE);
+ GridData gridLblProjectName = new GridData(SWT.RIGHT, SWT.CENTER,
+ false, false, 1, 1);
+ gridLblProjectName.widthHint = 78;
+ lblProjectName.setLayoutData(gridLblProjectName);
+ lblProjectName.setText("Project Name:");
+
+ txtProjectName = new Text(grpProjectDetails, SWT.BORDER);
+ GridData gridTxtProjectName = new GridData(SWT.FILL, SWT.CENTER, false,
+ false, 1, 1);
+ gridTxtProjectName.widthHint = 370;
+ txtProjectName.setLayoutData(gridTxtProjectName);
+ txtProjectName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ projectNameChanged();
+ dialogChanged();
+ }
+ });
+ new Label(grpProjectDetails, SWT.NONE);
+
+ Label lblLocation = new Label(grpProjectDetails, SWT.NONE);
+ GridData gridLblLocation = new GridData(SWT.RIGHT, SWT.CENTER, false,
+ false, 1, 1);
+ gridLblLocation.widthHint = 48;
+ lblLocation.setLayoutData(gridLblLocation);
+ lblLocation.setText("Location:");
+
+ txtWorkspaceLocation = new Text(grpProjectDetails, SWT.BORDER);
+ txtWorkspaceLocation.setEditable(false);
+ GridData gridTxtLocation = new GridData(SWT.LEFT, SWT.CENTER, false,
+ false, 1, 1);
+ gridTxtLocation.widthHint = 385;
+ txtWorkspaceLocation.setLayoutData(gridTxtLocation);
+
+ Button btnBrowse = new Button(grpProjectDetails, SWT.NONE);
+ btnBrowse.setText("Browse...");
+ btnBrowse.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse(e);
+ }
+
+ });
+ initialize();
+ dialogChanged();
+ setControl(topContainer);
+ }
+
+ private void initialize() {
+ txtFunctionBlockName.setText(DEFAULT_FUNCTIONBLOCK_NAME);
+ txtVersion.setText(FunctionBlockMetaData.FB_DEFAULT_VERSION);
+ txtProjectName.setText(DEFAULT_FUNCTIONBLOCK_NAME);
+ txtWorkspaceLocation.setText(getWorkspaceLocation() + "/"
+ + DEFAULT_FUNCTIONBLOCK_NAME);
+ txtDescription
+ .setText(DEFAULT_DESCRIPTION + DEFAULT_FUNCTIONBLOCK_NAME);
+
+ }
+
+ private void handleBrowse(SelectionEvent e) {
+ DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
+ directoryDialog.setFilterPath(workspaceLocation);
+ directoryDialog.setText("Workspace folder selection");
+ directoryDialog.setMessage("Select a directory for this project");
+
+ String selectedDirectory = directoryDialog.open();
+ selectedDirectory = StringUtils.replace(selectedDirectory, "\\", "/");
+
+ if (selectedDirectory != null) {
+ workspaceLocation = selectedDirectory;
+ updateWorkspaceLocationField(workspaceLocation);
+ dialogChanged();
+ }
+ }
+
+ private void projectNameChanged() {
+ txtWorkspaceLocation.setText(getWorkspaceLocation() + "/"
+ + getProjectName());
+ }
+
+ public void dialogChanged() {
+ if (this.validateProject()) {
+ this.setErrorMessage(null);
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+
+ }
+
+ private boolean validateProject() {
+ boolean result = true;
+ String projectName = getProjectName();
+ String functionBlockName = getFunctionBlockName();
+ String fbVersion = getFunctionBlockVersion();
+
+ result &= validateStrExist(projectName,
+ "Project name must be specified");
+ result &= validateStrExist(functionBlockName,
+ "Functionblock name must be specified");
+ result &= validateExistingSameProjectName();
+
+ // if(validateNoSpaceForLocation(projectLocation)){
+ // setErrorMessage("Project location should not contain space(s).");
+ // result = false;
+ // }
+ if (checkForRegexPattern(projectName, true, PROJECTNAME_REGEX)) {
+ setErrorMessage("Project name should not contain special characters.");
+ result = false;
+ }
+
+ if (checkForRegexPattern(functionBlockName, false, FUNCTIONBLOCK_REGEX)) {
+ setErrorMessage("Functionblock name should start with a capital letter and must not contain any special characters.");
+ result = false;
+ }
+
+ if (checkForRegexPattern(fbVersion, false, VERSION_REGEX)) {
+ setErrorMessage("Version should follow pattern <MAJOR>.<MINOR>.<PATCH>");
+ result = false;
+ }
+
+ return result;
+ }
+
+ private boolean checkForRegexPattern(String input, boolean expectedBool,
+ String regexPattern) {
+ return Pattern.compile(regexPattern).matcher(input).find() == expectedBool;
+ }
+
+ private boolean validateStrExist(String string, String errorMsgToBeShown) {
+ if (Strings.isNullOrEmpty(string)) {
+ this.setErrorMessage(errorMsgToBeShown);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean validateExistingSameProjectName() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ String projectName = getProjectName();
+
+ if (workspace.getRoot().getProject(getProjectName()).exists()) {
+ setErrorMessage("Project " + getProjectName() + " already exists.");
+ return false;
+ }
+
+ IPath projectLocation = ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation().append(projectName);
+ if (projectLocation.toFile().exists()) {
+ try {
+ String canonicalPath = projectLocation.toFile()
+ .getCanonicalPath();
+ projectLocation = new Path(canonicalPath);
+
+ String existingName = projectLocation.lastSegment();
+ if (!existingName.equals(projectName)) {
+ setErrorMessage("Project " + getProjectName()
+ + " already exists.");
+ return false;
+ }
+ } catch (IOException e) {
+ }
+
+ }
+
+ return true;
+ }
+
+ public void updateWorkspaceLocationField(String directory) {
+ txtWorkspaceLocation.setText(directory + "/" + getProjectName());
+ }
+
+ private void fbNameChanged() {
+ String fbName = getFunctionBlockName();
+ txtProjectName.setText(fbName);
+ txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" + fbName);
+ txtDescription.setText(DEFAULT_DESCRIPTION + fbName);
+ }
+
+ public String getWorkspaceLocation() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspaceLocation == null) {
+ workspaceLocation = workspace.getRoot().getLocation().toString();
+ }
+ return workspaceLocation;
+ }
+
+ public String getProjectName() {
+ return txtProjectName.getText();
+ }
+
+ public String getFunctionBlockVersion() {
+ return txtVersion.getText();
+ }
+
+ public String getFunctionBlockName() {
+ return txtFunctionBlockName.getText();
+ }
+
+ public String getFunctionBlockDescription() {
+ return txtDescription.getText();
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockDescriptionLabelProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockDescriptionLabelProvider.xtend
new file mode 100644
index 0000000..a2a87f1
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockDescriptionLabelProvider.xtend
@@ -0,0 +1,24 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor.ui.labeling
+
+//import org.eclipse.xtext.resource.IEObjectDescription
+
+/**
+ * Provides labels for a IEObjectDescriptions and IResourceDescriptions.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
+ */
+class FunctionblockDescriptionLabelProvider extends org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider {
+
+ // Labels and icons can be computed like this:
+
+// override text(IEObjectDescription ele) {
+// ele.name.toString
+// }
+//
+// override image(IEObjectDescription ele) {
+// ele.EClass.name + '.gif'
+// }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockLabelProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockLabelProvider.xtend
new file mode 100644
index 0000000..990d188
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/labeling/FunctionblockLabelProvider.xtend
@@ -0,0 +1,29 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor.ui.labeling
+
+import com.google.inject.Inject
+
+/**
+ * Provides labels for a EObjects.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
+ */
+class FunctionblockLabelProvider extends org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider {
+
+ @Inject
+ new(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+ // Labels and icons can be computed like this:
+
+// def text(Greeting ele) {
+// 'A greeting to ' + ele.name
+// }
+//
+// def image(Greeting ele) {
+// 'Greeting.gif'
+// }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/FunctionblockOutlineTreeProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/FunctionblockOutlineTreeProvider.xtend
new file mode 100644
index 0000000..f4f9bf9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/FunctionblockOutlineTreeProvider.xtend
@@ -0,0 +1,13 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor.ui.outline
+
+/**
+ * Customization of the default outline structure.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#outline
+ */
+class FunctionblockOutlineTreeProvider extends org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider {
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/InfomodelOutlineTreeProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/InfomodelOutlineTreeProvider.xtend
new file mode 100644
index 0000000..8be8894
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/outline/InfomodelOutlineTreeProvider.xtend
@@ -0,0 +1,13 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor.ui.outline
+
+/**
+ * Customization of the default outline structure.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#outline
+ */
+class InfomodelOutlineTreeProvider extends org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider {
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/quickfix/FunctionblockQuickfixProvider.xtend b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/quickfix/FunctionblockQuickfixProvider.xtend
new file mode 100644
index 0000000..cf53d3c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/src/org/eclipse/vorto/fbeditor/ui/quickfix/FunctionblockQuickfixProvider.xtend
@@ -0,0 +1,26 @@
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor.ui.quickfix
+
+//import org.eclipse.xtext.ui.editor.quickfix.Fix
+//import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor
+//import org.eclipse.xtext.validation.Issue
+
+/**
+ * Custom quickfixes.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#quickfixes
+ */
+class FunctionblockQuickfixProvider extends org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider {
+
+// @Fix(MyDslValidator::INVALID_NAME)
+// def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
+// acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
+// context |
+// val xtextDocument = context.xtextDocument
+// val firstLetter = xtextDocument.get(issue.offset, 1)
+// xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
+// ]
+// }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor.ui/templates/templates.xml b/bundles/org.eclipse.vorto.fbeditor.ui/templates/templates.xml
new file mode 100644
index 0000000..453606b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor.ui/templates/templates.xml
@@ -0,0 +1,8 @@
+<template
+name="Constraint"
+description="Constraint Example"
+id="Constraint"
+context="http://www.boschsi.com/m2m/tool/fbdesigner/FbDsl/Constraint"
+enabled="true">
+${type:CrossReference(’ConstraintIntervalType’)} ${constraintValue}
+</template>
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/.classpath b/bundles/org.eclipse.vorto.fbeditor/.classpath
new file mode 100644
index 0000000..42eb522
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <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="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.vorto.fbeditor/.gitignore b/bundles/org.eclipse.vorto.fbeditor/.gitignore
new file mode 100644
index 0000000..11f5b29
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/.gitignore
@@ -0,0 +1,9 @@
+/target
+/bin
+/src-gen
+/xtend-gen
+.DS_Store
+/model/generated
+plugin.xml_gen
+/model
+/.settings
diff --git a/bundles/org.eclipse.vorto.fbeditor/.project b/bundles/org.eclipse.vorto.fbeditor/.project
new file mode 100644
index 0000000..8a7d985
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.fbeditor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.fbeditor/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.fbeditor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3b5b592
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/META-INF/MANIFEST.MF
@@ -0,0 +1,35 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Functionblock Editor
+Bundle-Vendor: Bosch-SI
+Bundle-Version: 0.1.0
+Bundle-SymbolicName: org.eclipse.vorto.fbeditor; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.vorto.metamodel,
+ org.apache.log4j;bundle-version="1.2.0",
+ org.eclipse.emf.mwe2.launch;bundle-version="2.7.0";resolution:=optional,
+ org.eclipse.core.runtime;bundle-version="3.9.0",
+ org.eclipse.xtext.xbase;bundle-version="[2.7.0,3.0.0)";resolution:=optional;visibility:=reexport,
+ org.eclipse.xtext.generator;bundle-version="[2.7.0,3.0.0)";resolution:=optional,
+ org.eclipse.xtext,
+ org.eclipse.xtext.util,
+ org.eclipse.xtext.xbase.lib,
+ org.antlr.runtime,
+ org.eclipse.xtext.common.types,
+ org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Export-Package: org.eclipse.vorto.fbeditor,
+ org.eclipse.vorto.fbeditor.formatting,
+ org.eclipse.vorto.fbeditor.generator,
+ org.eclipse.vorto.fbeditor.internal.validation;x-friends:="org.eclipse.vorto.fbeditor.tests",
+ org.eclipse.vorto.fbeditor.internal.validation.validator;x-friends:="org.eclipse.vorto.fbeditor.tests",
+ org.eclipse.vorto.fbeditor.internal.validation.validator.impl;x-friends:="org.eclipse.vorto.fbeditor.tests",
+ org.eclipse.vorto.fbeditor.jvmmodel,
+ org.eclipse.vorto.fbeditor.parser.antlr,
+ org.eclipse.vorto.fbeditor.parser.antlr.internal,
+ org.eclipse.vorto.fbeditor.scoping,
+ org.eclipse.vorto.fbeditor.serializer,
+ org.eclipse.vorto.fbeditor.services,
+ org.eclipse.vorto.fbeditor.validation
+Bundle-ClassPath: .
+Import-Package: org.apache.log4j
diff --git a/bundles/org.eclipse.vorto.fbeditor/about.html b/bundles/org.eclipse.vorto.fbeditor/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.fbeditor/build.properties b/bundles/org.eclipse.vorto.fbeditor/build.properties
new file mode 100644
index 0000000..cf0693c
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/build.properties
@@ -0,0 +1,8 @@
+source.. = src/,\
+ src-gen/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .,\
+ about.html
+
+
diff --git a/bundles/org.eclipse.vorto.fbeditor/pom.xml b/bundles/org.eclipse.vorto.fbeditor/pom.xml
new file mode 100644
index 0000000..b422ec5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/pom.xml
@@ -0,0 +1,152 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.fbeditor</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>Function Block Editor Plugin</name>
+ <description>The designer plugin lets users create a function block
+ definition.</description>
+
+ <properties>
+ <test.project>org.eclipse.vorto.fbeditor.tests</test.project>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>copy-plugins</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-kepler</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${kepler.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-luna</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${luna.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-visualrules</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.fbeditor</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${visualrules.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includeProjectDependencies>false</includeProjectDependencies>
+ <includePluginDependencies>true</includePluginDependencies>
+ <mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
+ <arguments>
+ <argument>file://${project.basedir}/src/org/eclipse/vorto/fbeditor/GenerateFunctionblock.mwe2</argument>
+ <argument>
+ -p
+ </argument>
+ <argument>
+ runtimeProject=/${project.basedir}
+ </argument>
+ </arguments>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.xtext</groupId>
+ <artifactId>org.eclipse.xtext.xtext</artifactId>
+ <version>${xtext.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.xtext</groupId>
+ <artifactId>org.eclipse.xtext.xbase</artifactId>
+ <version>${xtext.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.metamodel</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/Functionblock.xtext b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/Functionblock.xtext
new file mode 100644
index 0000000..351678b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/Functionblock.xtext
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+grammar org.eclipse.vorto.fbeditor.Functionblock with org.eclipse.xtext.common.Terminals
+
+import "http://www.eclipse.org/vorto/metamodel/Functionblock"
+
+FunctionblockModel:
+ 'functionblock' name= ID '{'
+ functionblock = FunctionBlock
+ '}'
+ (elements += Entity)*
+ (enums+=Enum)* ;
+
+FunctionBlock:
+ 'displayname' displayname=STRING
+ ('description' description=STRING)?
+ 'vendor' vendor=VENDOR
+ 'category' category=CATEGORY
+ 'version' version=VERSION
+ ('configuration' '{'
+ configuration = FBFeature
+ '}')?
+ ('status' '{'
+ status = FBFeature
+ '}')?
+ ('fault' '{'
+ fault = FBFeature
+ '}')?
+
+ ('events' '{'
+ (events+=Event)*
+ '}')?
+
+ ('operations' '{'
+ (features += Operation)*
+ '}')?
+
+;
+
+Event :
+ name = ID '{'
+ feature = FBFeature
+ '}'
+;
+
+terminal VERSION : ('0'..'9')* '.' ('0'..'9')* '.' ('0'..'9')*('-'ID)?;
+
+terminal VENDOR : ('a'..'z')+ "." ('a'..'z')+ ("." ('a'..'z')+)?;
+
+CATEGORY : ID ('/' ID)*;
+
+FBFeature:
+ (properties += Property)*
+;
+
+enum PrimitiveType: string = 'string' | int = 'int' | float = 'float' | boolean = 'boolean' | datetime = 'dateTime' | double = 'double' | long = 'long' | short = 'short' | base64Binary ='base64Binary' | byte = 'byte';
+
+ObjectType:
+ Entity | Enum
+;
+
+Property:
+ PrimitiveProperty | ObjectProperty
+;
+
+
+Entity:
+ 'entity' name = ID ('extends' superType = [Entity])? '{'
+ properties = FBFeature
+ '}'
+;
+
+Presence:
+ mandatory = 'mandatory' | optional = 'optional'
+;
+
+PrimitiveProperty:
+ presence = Presence (multiplicity = 'multiple')? propName = ID 'as' type = PrimitiveType
+ ('<' Constraints += Constraint ("," Constraints += Constraint)* '>')?
+ (description=STRING)?
+;
+
+ObjectProperty:
+ presence = Presence (multiplicity = 'multiple')? propName = ID 'as' type = [ObjectType]
+ (description=STRING)?
+;
+
+enum ConstraintIntervalType: min = 'MIN' | max = 'MAX' | strlen = 'STRLEN' | regex = 'REGEX' ;
+
+terminal FLOAT: ('-')?('0'..'9')*'.'('0'..'9')*;
+
+terminal DATE:
+ ('0'..'9')('0'..'9')('0'..'9')('0'..'9')('-')('0'..'9')('0'..'9')('-')('0'..'9')('0'..'9')
+;
+
+terminal TIME:
+ ('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9')(TIMEZONE)?
+;
+
+terminal fragment TIMEZONE:
+ 'Z'|(('+'|'-')('0'..'9')('0'..'9')(':')('0'..'9')('0'..'9'))
+;
+
+terminal DATETIME:
+ DATE('T')TIME
+;
+
+terminal SIGNEDINT :
+ '-'INT
+;
+
+IntervalType:
+ INT | SIGNEDINT | FLOAT | DATETIME | STRING
+;
+
+Constraint:
+ type = ConstraintIntervalType constraintValues = IntervalType
+;
+
+Operation :
+ methodName=ID '(' (params += Parameter (',' params+=Parameter)*)?')' ('returns' returnType = ReturnType)? (description=STRING)?
+;
+
+ReturnType :
+ ReturnObjectType | ReturnPrimitiveType
+;
+
+ReturnObjectType :
+ (multiplicity = 'multiple')? returnType = [ObjectType]
+;
+
+ReturnPrimitiveType :
+ (multiplicity = 'multiple')? returnType = PrimitiveType
+;
+
+Parameter:
+ PrimitiveParam | ObjectParam
+;
+
+ObjectParam :
+ (multiplicity = 'multiple')? paramName = ID 'as' paramType = [ObjectType]
+;
+
+PrimitiveParam :
+ (multiplicity = 'multiple')? paramName = ID 'as' paramType = PrimitiveType
+;
+
+Enum:
+ 'enum' name = ID '{'
+ ( enums += EnumLiteral (',' enums += EnumLiteral)* )?
+ '}'
+;
+
+EnumLiteral:
+ literal = ID
+;
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockRuntimeModule.java b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockRuntimeModule.java
new file mode 100644
index 0000000..7c5ecbd
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockRuntimeModule.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor;
+
+import org.eclipse.vorto.fbeditor.generator.FbOutputConfigurationProvider;
+import org.eclipse.vorto.fbeditor.scoping.FunctionblockScopeProvider;
+import org.eclipse.xtext.generator.IOutputConfigurationProvider;
+import org.eclipse.xtext.scoping.IScopeProvider;
+
+import com.google.inject.Binder;
+import com.google.inject.Singleton;
+
+/**
+ * Use this class to register components to be used at runtime / without the
+ * Equinox extension registry.
+ */
+public class FunctionblockRuntimeModule extends
+ org.eclipse.vorto.fbeditor.AbstractFunctionblockRuntimeModule {
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(IOutputConfigurationProvider.class)
+ .to(FbOutputConfigurationProvider.class).in(Singleton.class);
+ }
+
+ @Override
+ public Class<? extends IScopeProvider> bindIScopeProvider() {
+ return FunctionblockScopeProvider.class;
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockStandaloneSetup.java b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockStandaloneSetup.java
new file mode 100644
index 0000000..901f886
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/FunctionblockStandaloneSetup.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/*
+* generated by Xtext
+*/
+package org.eclipse.vorto.fbeditor;
+
+/**
+ * Initialization support for running Xtext languages
+ * without equinox extension registry
+ */
+public class FunctionblockStandaloneSetup extends FunctionblockStandaloneSetupGenerated{
+
+ public static void doSetup() {
+ new FunctionblockStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+}
+
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/GenerateFunctionblock.mwe2 b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/GenerateFunctionblock.mwe2
new file mode 100644
index 0000000..374bc96
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/GenerateFunctionblock.mwe2
@@ -0,0 +1,145 @@
+module org.eclipse.vorto.fbeditor.GenerateFunctionblock
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "platform:/resource/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/Functionblock.xtext"
+var fileExtensions = "fbmodel"
+var projectName = "org.eclipse.vorto.fbeditor"
+var runtimeProject = "../${projectName}"
+var generateXtendStub = true
+var encoding = "UTF-8"
+
+Workflow {
+ bean = StandaloneSetup {
+ resourceSet = org.eclipse.xtext.resource.XtextResourceSet:theResourceSet {}
+
+ // add mappings from platform:/resource to classpath:/
+ uriMap = {
+ from = "platform:/resource/org.eclipse.xtext.common.types/"
+ to = "classpath:/"
+ }
+
+// scanClassPath = true
+ platformUri = "${runtimeProject}/.."
+
+ // The following two lines can be removed, if Xbase is not used.
+ registerGeneratedEPackage = "org.eclipse.vorto.functionblock.FunctionblockPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.vorto.metamodel/model/generated/Functionblock.genmodel"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}/src-gen"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.ui/src-gen"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.tests/src-gen"
+ }
+
+ component = Generator {
+ pathRtProject = runtimeProject
+ pathUiProject = "${runtimeProject}.ui"
+ pathTestProject = "${runtimeProject}.tests"
+ projectNameRt = projectName
+ projectNameUi = "${projectName}.ui"
+ encoding = encoding
+ language = auto-inject {
+ forcedResourceSet = theResourceSet
+
+ uri = grammarURI
+
+ // Java API to access grammar elements (required by several other fragments)
+ fragment = grammarAccess.GrammarAccessFragment auto-inject {}
+
+ // generates Java API for the generated EPackages
+// fragment = ecore.EMFGeneratorFragment auto-inject {
+// basePackage = "com.boschsi.m2m.tool"
+// javaModelDirectory = "${metamodelProject}/src"
+// }
+
+ // the old serialization component
+ // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}
+
+ // serializer 2.0
+ fragment = serializer.SerializerFragment auto-inject {
+ generateStub = false
+ }
+
+ // a custom ResourceFactory for use with EMF
+ fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
+
+ // The antlr parser generator fragment.
+ fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
+ // options = {
+ // backtrack = true
+ // }
+ }
+
+ // Xtend-based API for validation
+ fragment = validation.ValidatorFragment auto-inject {
+ // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+ // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ }
+
+ // old scoping and exporting API
+ // fragment = scoping.ImportURIScopingFragment auto-inject {}
+ // fragment = exporting.SimpleNamesFragment auto-inject {}
+
+ // scoping and exporting API
+ fragment = scoping.ImportNamespacesScopingFragment auto-inject {
+ generateStub = false
+ }
+ fragment = exporting.QualifiedNamesFragment auto-inject {}
+ fragment = builder.BuilderIntegrationFragment auto-inject {}
+
+ // generator API
+ fragment = generator.GeneratorFragment auto-inject {}
+
+ // formatter API
+ fragment = formatting.FormatterFragment auto-inject {}
+
+ // labeling API
+ fragment = labeling.LabelProviderFragment auto-inject {}
+
+ // outline API
+ fragment = outline.OutlineTreeProviderFragment auto-inject {}
+ fragment = outline.QuickOutlineFragment auto-inject {}
+
+ // quickfix API
+ fragment = quickfix.QuickfixProviderFragment auto-inject {}
+
+ // content assist API
+ fragment = contentAssist.ContentAssistFragment auto-inject {}
+
+ // generates a more lightweight Antlr parser and lexer tailored for content assist
+ fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
+
+ // generates junit test support classes into Generator#pathTestProject
+// fragment = junit.Junit4Fragment auto-inject {}
+
+ // rename refactoring
+ fragment = refactoring.RefactorElementNameFragment auto-inject {}
+
+ // provides the necessary bindings for java types integration
+ fragment = types.TypesGeneratorFragment auto-inject {}
+
+ // generates the required bindings only if the grammar inherits from Xbase
+ fragment = xbase.XbaseGeneratorFragment auto-inject {}
+
+ // generates the required bindings only if the grammar inherits from Xtype
+// fragment = xbase.XtypeGeneratorFragment auto-inject {}
+
+ // provides a preference page for template proposals
+ fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
+
+ // provides a compare view
+ fragment = compare.CompareFragment auto-inject {}
+ }
+ }
+}
+
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/formatting/FunctionblockFormatter.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/formatting/FunctionblockFormatter.xtend
new file mode 100644
index 0000000..55c5545
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/formatting/FunctionblockFormatter.xtend
@@ -0,0 +1,77 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.formatting
+
+import javax.inject.Inject
+import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
+import org.eclipse.xtext.formatting.impl.FormattingConfig
+import org.eclipse.vorto.fbeditor.services.FunctionblockGrammarAccess
+
+
+class FunctionblockFormatter extends AbstractDeclarativeFormatter {
+
+ @Inject extension FunctionblockGrammarAccess f
+
+ override protected void configureFormatting(FormattingConfig c) {
+ // formatting for Comments
+ c.setLinewrap(1, 1, 2).before(SL_COMMENTRule)
+ c.setLinewrap(1, 1, 2).before(ML_COMMENTRule)
+ c.setLinewrap(1, 1, 1).after(ML_COMMENTRule)
+ c.setAutoLinewrap(120)
+
+ // Line wrap for all basic function block info, like displayname, description etc.
+ c.setLinewrap(1).after(f.functionBlockAccess.displaynameAssignment_1)
+ c.setLinewrap(1).after(f.functionBlockAccess.descriptionAssignment_2_1)
+ c.setLinewrap(1).after(f.functionBlockAccess.vendorAssignment_4)
+ c.setLinewrap(1).after(f.functionBlockAccess.categoryAssignment_6)
+ c.setLinewrap(2).after(f.functionBlockAccess.versionAssignment_8)
+
+ //Line wrap for every property entries in all function block constructs like configuration, status etc.
+ c.setLinewrap(1).after(f.FBFeatureAccess.propertiesAssignment)
+ c.setLinewrap(1).before(f.findKeywords("mandatory").get(0))
+ c.setLinewrap(1).before(f.findKeywords("optional").get(0))
+
+ // Line wrap and indentation between function block sub elements.
+ findKeywordPairs("{","}").forEach[
+ c.setLinewrap(1).after(first)
+ c.setLinewrap(1).before(second)
+ c.setLinewrap(2).after(second)
+ c.setIndentationIncrement().after(first)
+ c.setIndentationDecrement().before(second)
+ ]
+
+ //Formatting for operation paranthesis
+ findKeywordPairs("(",")").forEach[
+ c.setNoSpace().before(first)
+ c.setNoSpace().after(first)
+ c.setNoSpace().before(second)
+ ]
+
+ //Formatting for constraint block
+ findKeywordPairs("<",">").forEach[
+ c.setSpace(" ").before(first)
+ c.setNoSpace().after(first)
+ c.setNoSpace().before(second)
+ ]
+
+ //Line wrap for each operation.
+ c.setLinewrap(1).after(f.operationAccess.group)
+
+ //Remove space between enum values. Make enum into separate line.
+ c.setNoSpace().before(f.enumAccess.commaKeyword_3_1_0)
+ c.setLinewrap(1).after(f.enumAccess.commaKeyword_3_1_0)
+
+ //Remove extra spaces between constraint parameters.
+ c.setNoSpace().before(f.primitivePropertyAccess.commaKeyword_5_2_0)
+ c.setNoSpace().after(f.primitivePropertyAccess.commaKeyword_5_2_0)
+
+ //Remove extra spaces between method parameters.
+ c.setNoSpace().before(f.operationAccess.commaKeyword_2_1_0)
+ c.setNoSpace().after(f.operationAccess.commaKeyword_2_1_0)
+
+
+
+
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FbOutputConfigurationProvider.java b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FbOutputConfigurationProvider.java
new file mode 100644
index 0000000..10a71e5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FbOutputConfigurationProvider.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.generator;
+
+import static com.google.common.collect.Sets.newHashSet;
+
+import java.util.Set;
+
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IOutputConfigurationProvider;
+import org.eclipse.xtext.generator.OutputConfiguration;
+
+
+public class FbOutputConfigurationProvider implements
+ IOutputConfigurationProvider {
+
+ public static final String FB_OUTPUT = "src-gen";
+
+ @Override
+ public Set<OutputConfiguration> getOutputConfigurations() {
+ OutputConfiguration defaultOutput = new OutputConfiguration(
+ IFileSystemAccess.DEFAULT_OUTPUT);
+ defaultOutput
+ .setDescription("Output folder for generated XML, XSD and binding files");
+ defaultOutput.setOutputDirectory(FB_OUTPUT);
+ defaultOutput.setOverrideExistingResources(true);
+ defaultOutput.setCreateOutputDirectory(true);
+ defaultOutput.setCanClearOutputDirectory(true);
+ defaultOutput.setCleanUpDerivedResources(true);
+ defaultOutput.setSetDerivedProperty(false);
+
+ OutputConfiguration rootOutput = new OutputConfiguration("root_Output");
+ rootOutput.setDescription("Output folder for generated POM");
+ rootOutput.setOutputDirectory(".");
+ rootOutput.setOverrideExistingResources(true);
+ rootOutput.setCreateOutputDirectory(true);
+ rootOutput.setCanClearOutputDirectory(false);
+ rootOutput.setCleanUpDerivedResources(false);
+ rootOutput.setSetDerivedProperty(false);
+
+ return newHashSet(defaultOutput, rootOutput);
+ }
+
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FunctionblockGenerator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FunctionblockGenerator.xtend
new file mode 100644
index 0000000..cfba48b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/generator/FunctionblockGenerator.xtend
@@ -0,0 +1,19 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.generator
+
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.xtext.generator.IGenerator
+import org.eclipse.xtext.generator.IFileSystemAccess
+
+/**
+ * Generates code from your model files on save.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration
+ */
+class FunctionblockGenerator implements IGenerator {
+
+ override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/ConstraintValidatorFactory.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/ConstraintValidatorFactory.xtend
new file mode 100644
index 0000000..97f96d9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/ConstraintValidatorFactory.xtend
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+ package org.eclipse.vorto.fbeditor.internal.validation
+
+import org.eclipse.vorto.fbeditor.internal.validation.validator.ConstraintValueValidator
+import org.eclipse.vorto.fbeditor.internal.validation.validator.impl.AccordinglyValueValidator
+import org.eclipse.vorto.fbeditor.internal.validation.validator.impl.RegexValueValidator
+import org.eclipse.vorto.fbeditor.internal.validation.validator.impl.ScalarValueValidator
+import org.eclipse.vorto.functionblock.ConstraintIntervalType
+
+
+class ConstraintValidatorFactory {
+
+ def static ConstraintValueValidator getValueValidator(ConstraintIntervalType type){
+ var typeStr = type.literal.toString
+ switch typeStr{
+ case 'MAX' :
+ new AccordinglyValueValidator
+ case 'MIN' :
+ new AccordinglyValueValidator
+ case 'REGEX' :
+ new RegexValueValidator
+ case 'STRLEN' :
+ new ScalarValueValidator
+ default:
+ throw new IllegalArgumentException('Not supported constraint type')
+ }
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/SystemMessage.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/SystemMessage.xtend
new file mode 100644
index 0000000..e1d69f5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/SystemMessage.xtend
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+ package org.eclipse.vorto.fbeditor.internal.validation
+
+
+class SystemMessage {
+ public static final String ERROR_DUPLICATED_ENTITY_NAME = 'Entity name has been defined'
+ public static final String ERROR_DUPLICATED_PROPERTY_NAME = 'Property name has been defined'
+ public static final String ERROR_DUPLICATED_PARAMETER_NAME = 'Parameter name has been defined'
+ public static final String ERROR_DUPLICATED_METHOD_NAME = 'Method name has been defined'
+ public static final String ERROR_FBNAME_INVALID = 'Function block name must begin with a capital letter'
+ public static final String ERROR_ENTITYNAME_INVALID_CAMELCASE = 'Entity name must begin with a capital letter'
+ public static final String ERROR_PROPNAME_SUFFIX_TS = 'Invalid property name with suffix "TS"'
+ public static final String ERROR_ENTITYNAME_SUFFIX_REPLY = 'Invalid property name with suffix "Reply"'
+ public static final String ERROR_OPERATION_SAME_ENTITYNAME = 'Operation name cannot be same as entity name'
+ public static final String ERROR_DUPLICATED_CONSTRAINT = 'Constraint Type has been defined'
+ public static final String ERROR_CONSTRAINT_ENTITY = 'Constraint cannot be imposed on Entity or Enum'
+
+ public static final String ERROR_CONSTRAINT_VALUE_INT = 'This constraint value must be of an Integer'
+ public static final String ERROR_CONSTRAINT_VALUE_FLOAT = 'This constraint value must be of a Float'
+ public static final String ERROR_CONSTRAINT_VALUE_LONG = 'This constraint value must be of a Long'
+ public static final String ERROR_CONSTRAINT_VALUE_SHORT = 'This constraint value must be of a Short'
+ public static final String ERROR_CONSTRAINT_VALUE_DOUBLE= 'This constraint value must be of a Double'
+ public static final String ERROR_CONSTRAINT_VALUE_BYTE= 'This constraint value must be of a Byte'
+ public static final String ERROR_CONSTRAINT_VALUE= 'This constraint value must be same type of property'
+ public static final String ERROR_CONSTRAINT_VALUE_DATETIME = 'Value expected should be in ISO 8196 Date Format e.g: 2002-05-30T09:30:10+06:00'
+ public static final String ERROR_CONSTRAINTTYPE_INVALID = "Constraint cannot apply on this property's datatype"
+
+ public static final String ERROR_VERSION_PATTERN = "Version is not matching the following pattern: <MAJOR>.<MINOR>.<PATCH>-<QUALIFIER>"
+ public static final String ERROR_DUPLICATED_ENUM_LITERAL = 'Enumeration literal has been defined'
+ public static final String ERROR_DUPLICATED_ENUM_NAME = 'Enumeration has been defined'
+ public static final String ERROR_ENUMNAME_INVALID_CAMELCASE = 'Enum name must begin with a capital letter'
+ public static final String ERROR_OPERATION_SAME_ENUMNAME = 'Operation name cannot be same as enumeration name'
+ public static final String ERROR_ENTITY_SAME_ENUMNAME = 'Enumeration name cannot be same as entity name'
+ public static final String ERROR_ENUM_CANNOT_BE_EMPTY = 'Enumeration cannot have zero literals'
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/ConstraintValueValidator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/ConstraintValueValidator.xtend
new file mode 100644
index 0000000..8b69bd7
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/ConstraintValueValidator.xtend
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.fbeditor.internal.validation.validator
+
+import org.eclipse.vorto.functionblock.Constraint
+import org.eclipse.vorto.functionblock.PrimitiveType
+
+
+abstract class ConstraintValueValidator {
+
+ var errorMsg = "" ;
+
+ def boolean evaluateValueType(PrimitiveType type,Constraint constraint)
+
+ def String getErrorMessage(){
+ errorMsg
+ }
+
+ protected def String setErrorMessage(String err){
+ errorMsg = err
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/PropertyConstraintMappingValidation.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/PropertyConstraintMappingValidation.xtend
new file mode 100644
index 0000000..013b809
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/PropertyConstraintMappingValidation.xtend
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.fbeditor.internal.validation.validator
+
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.functionblock.Constraint
+import org.eclipse.vorto.functionblock.PrimitiveType
+
+
+class PropertyConstraintMappingValidation {
+
+ var errorMsg = SystemMessage.ERROR_CONSTRAINTTYPE_INVALID ;
+
+ val String[] intervalArr = #["MAX", "MIN"]
+ val String[] strArr = #["STRLEN", "REGEX"]
+ val String[] empty = #[]
+
+ private val valueTypeMap = <String, String[]>newHashMap(
+ 'int' -> intervalArr,
+ 'byte' -> intervalArr,
+ 'float' -> intervalArr,
+ 'long' -> intervalArr,
+ 'short' -> intervalArr,
+ 'double' -> intervalArr,
+ 'dateTime' -> intervalArr,
+ 'string' -> strArr,
+ 'boolean' -> empty,
+ 'base64Binary' -> empty
+ );
+
+ def final boolean checkPropertyConstraints(PrimitiveType type, Constraint cons) {
+ var arr = valueTypeMap.get(type.literal)
+ if (arr == null || !arr.contains(cons.type.literal)) {
+ setErrorMessage(SystemMessage.ERROR_CONSTRAINTTYPE_INVALID)
+ return false
+ }
+ true
+ }
+
+ def String getErrorMessage() {
+ errorMsg
+ }
+
+ private def String setErrorMessage(String err) {
+ errorMsg = err
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/AccordinglyValueValidator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/AccordinglyValueValidator.xtend
new file mode 100644
index 0000000..2434691
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/AccordinglyValueValidator.xtend
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.fbeditor.internal.validation.validator.impl
+
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.fbeditor.internal.validation.validator.ConstraintValueValidator
+import org.eclipse.vorto.functionblock.Constraint
+import org.eclipse.vorto.functionblock.PrimitiveType
+import java.text.ParseException
+import java.text.SimpleDateFormat
+
+
+class AccordinglyValueValidator extends ConstraintValueValidator {
+
+ override evaluateValueType(PrimitiveType type, Constraint constraint) {
+ var rawValue = constraint.constraintValues
+ var typeStr = type.literal
+
+ switch typeStr{
+ case 'int' :
+ try {
+ Integer.parseInt(rawValue)
+ }catch (NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_INT)
+ return false
+ }
+
+ case 'long' :
+ try{
+ Long.parseLong(rawValue)
+ }catch(NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_LONG)
+ return false
+ }
+
+ case 'short' :
+ try{
+ Short.parseShort(rawValue)
+ }catch(NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_SHORT)
+ return false
+ }
+
+ case 'double' :
+ try{
+ Double.parseDouble(rawValue)
+ }catch(NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_DOUBLE)
+ return false
+ }
+
+ case 'float' :
+ try {
+ Float.parseFloat(rawValue)
+ }catch (NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_FLOAT)
+ return false
+ }
+
+ case 'dateTime' :
+ try {
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX").parse(rawValue);
+ }catch (ParseException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_DATETIME)
+ return false
+ }
+ case 'byte' :
+ try {
+ Byte.parseByte(rawValue)
+ }catch (NumberFormatException ex){
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_BYTE)
+ return false
+ }
+ }
+ true
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/RegexValueValidator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/RegexValueValidator.xtend
new file mode 100644
index 0000000..959f78b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/RegexValueValidator.xtend
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+package org.eclipse.vorto.fbeditor.internal.validation.validator.impl
+
+import org.eclipse.vorto.fbeditor.internal.validation.validator.ConstraintValueValidator
+import org.eclipse.vorto.functionblock.Constraint
+import org.eclipse.vorto.functionblock.PrimitiveType
+
+
+class RegexValueValidator extends ConstraintValueValidator {
+
+ override evaluateValueType(PrimitiveType type, Constraint constraint) {
+ //currently no known restriction on this content
+ true
+ }
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/ScalarValueValidator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/ScalarValueValidator.xtend
new file mode 100644
index 0000000..d26f229
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/internal/validation/validator/impl/ScalarValueValidator.xtend
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.fbeditor.internal.validation.validator.impl
+
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.fbeditor.internal.validation.validator.ConstraintValueValidator
+import org.eclipse.vorto.functionblock.Constraint
+import org.eclipse.vorto.functionblock.PrimitiveType
+import org.apache.log4j.Logger
+
+
+class ScalarValueValidator extends ConstraintValueValidator {
+
+ private static final Logger logger = Logger.getLogger(ScalarValueValidator.canonicalName)
+
+ override evaluateValueType(PrimitiveType type, Constraint constraint) {
+ try {
+ Integer.parseInt(constraint.constraintValues)
+ }catch (NumberFormatException ex){
+ logger.info(ex.message)
+ this.setErrorMessage(SystemMessage.ERROR_CONSTRAINT_VALUE_INT)
+ return false
+ }
+
+ true
+ }
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/jvmmodel/FunctionblockJvmModelInferrer.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/jvmmodel/FunctionblockJvmModelInferrer.xtend
new file mode 100644
index 0000000..ae5b7fd
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/jvmmodel/FunctionblockJvmModelInferrer.xtend
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+
+package org.eclipse.vorto.fbeditor.jvmmodel
+
+import com.google.inject.Inject
+import org.eclipse.vorto.functionblock.FunctionblockModel
+import org.eclipse.xtext.common.types.JvmDeclaredType
+import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
+import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
+import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
+
+/**
+ * <p>Infers a JVM model from the source model.</p>
+ *
+ * <p>The JVM model should contain all elements that would appear in the Java code
+ * which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
+ */
+class FunctionblockJvmModelInferrer extends AbstractModelInferrer {
+
+ /**
+ * convenience API to build and initialize JVM types and their members.
+ */
+ @Inject extension JvmTypesBuilder
+
+ /**
+ * The dispatch method {@code infer} is called for each instance of the
+ * given element's type that is contained in a resource.
+ *
+ * @param element
+ * the model to create one or more
+ * {@link JvmDeclaredType declared
+ * types} from.
+ * @param acceptor
+ * each created
+ * {@link JvmDeclaredType type}
+ * without a container should be passed to the acceptor in order
+ * get attached to the current resource. The acceptor's
+ * {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType)
+ * accept(..)} method takes the constructed empty type for the
+ * pre-indexing phase. This one is further initialized in the
+ * indexing phase using the closure you pass to the returned
+ * {@link IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
+ * initializeLater(..)}.
+ * @param isPreIndexingPhase
+ * whether the method is called in a pre-indexing phase, i.e.
+ * when the global index is not yet fully updated. You must not
+ * rely on linking using the index if isPreIndexingPhase is
+ * <code>true</code>.
+ */
+ def dispatch void infer(FunctionblockModel element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
+ // Here you explain how your model is mapped to Java elements, by writing the actual translation code.
+
+ // An implementation for the initial hello world example could look like this:
+// acceptor.accept(element.toClass("my.company.greeting.MyGreetings"))
+// .initializeLater([
+// for (greeting : element.greetings) {
+// members += greeting.toMethod("hello" + greeting.name, greeting.newTypeRef(typeof(String))) [
+// body = [
+// append('''return "Hello «greeting.name»";''')
+// ]
+// ]
+// }
+// ])
+ }
+}
+
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/scoping/FunctionblockScopeProvider.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/scoping/FunctionblockScopeProvider.xtend
new file mode 100644
index 0000000..86ac377
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/scoping/FunctionblockScopeProvider.xtend
@@ -0,0 +1,47 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.scoping
+
+import org.eclipse.vorto.functionblock.Entity
+import org.eclipse.vorto.functionblock.Enum
+import org.eclipse.vorto.functionblock.FunctionblockModel
+import org.eclipse.vorto.functionblock.ObjectProperty
+import java.util.ArrayList
+import javax.inject.Inject
+import org.eclipse.emf.ecore.EReference
+import org.eclipse.xtext.EcoreUtil2
+import org.eclipse.xtext.naming.IQualifiedNameProvider
+import org.eclipse.xtext.resource.EObjectDescription
+import org.eclipse.xtext.resource.IEObjectDescription
+import org.eclipse.xtext.scoping.IScope
+import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
+import org.eclipse.xtext.scoping.impl.SimpleScope
+
+/**
+ * This class contains custom scoping description.
+ *
+ * see : http://www.eclipse.org/Xtext/documentation.html#scoping
+ * on how and when to use it
+ *
+ */
+class FunctionblockScopeProvider extends AbstractDeclarativeScopeProvider {
+
+ @Inject
+ IQualifiedNameProvider nameProvider;
+
+ def IScope scope_Property_type(ObjectProperty o, EReference r) {
+ var objects = new ArrayList<IEObjectDescription>();
+ var model = EcoreUtil2.getContainerOfType(o, typeof(FunctionblockModel));
+ for (Entity entity : model.elements) {
+ objects.add(EObjectDescription.create(nameProvider.getFullyQualifiedName(entity),entity));
+ }
+
+ for (Enum enumeration : model.enums) {
+ objects.add(EObjectDescription.create(nameProvider.getFullyQualifiedName(enumeration),enumeration));
+ }
+
+
+ return new SimpleScope(IScope.NULLSCOPE, objects);
+ }
+}
diff --git a/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/validation/FunctionblockValidator.xtend b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/validation/FunctionblockValidator.xtend
new file mode 100644
index 0000000..a1e0bf3
--- /dev/null
+++ b/bundles/org.eclipse.vorto.fbeditor/src/org/eclipse/vorto/fbeditor/validation/FunctionblockValidator.xtend
@@ -0,0 +1,248 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.vorto.fbeditor.validation
+
+import org.eclipse.vorto.fbeditor.internal.validation.validator.PropertyConstraintMappingValidation
+import org.eclipse.vorto.functionblock.Entity
+import org.eclipse.vorto.functionblock.Enum
+import org.eclipse.vorto.functionblock.FBFeature
+import org.eclipse.vorto.functionblock.FunctionBlock
+import org.eclipse.vorto.functionblock.FunctionblockModel
+import org.eclipse.vorto.functionblock.FunctionblockPackage
+import org.eclipse.vorto.functionblock.Operation
+import org.eclipse.vorto.functionblock.PrimitiveProperty
+import org.eclipse.vorto.functionblock.Property
+import java.util.HashSet
+import java.util.LinkedList
+import org.eclipse.xtext.validation.Check
+import org.eclipse.vorto.fbeditor.internal.validation.SystemMessage
+import org.eclipse.vorto.fbeditor.internal.validation.ConstraintValidatorFactory
+
+/**
+ * Custom validation rules.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#validation
+ */
+class FunctionblockValidator extends AbstractFunctionblockValidator {
+
+ public val propertyValidator = new PropertyConstraintMappingValidation
+
+ @Check
+ def checkConstraint(PrimitiveProperty prop) {
+ var list = prop.constraints
+
+ if(list.length == 0) return;
+
+ var primi = prop.type
+ for (i : list.size >.. 0) {
+ var constraint = list.get(i)
+ if (!propertyValidator.checkPropertyConstraints(primi, constraint)) {
+ error(propertyValidator.errorMessage, constraint, FunctionblockPackage.Literals.CONSTRAINT__TYPE)
+ }else{
+ var validator = ConstraintValidatorFactory.getValueValidator(constraint.type)
+ if (!validator.evaluateValueType(primi, constraint)) {
+ error(validator.errorMessage, constraint, FunctionblockPackage.Literals.CONSTRAINT__CONSTRAINT_VALUES)
+ }
+ }
+ }
+ }
+
+ @Check
+ def checkDuplicatedConstraint(PrimitiveProperty feature) {
+ var set = new HashSet<String>();
+ var list = feature.constraints;
+ for (var i = 0; i < list.length; i ++) {
+ var con = list.get(i);
+ if (!set.add(con.type.literal)) {
+ error(SystemMessage.ERROR_DUPLICATED_CONSTRAINT, con, FunctionblockPackage.Literals.CONSTRAINT__TYPE)
+ }
+ }
+ }
+
+ @Check
+ def checkDuplicateEntityName(Entity ent) {
+ var superEntity = ent.eContainer() as FunctionblockModel;
+ var set = new HashSet<String>();
+ var elems = superEntity.elements
+
+ for (var i = 0; i < elems.length; i ++) {
+ var elem = elems.get(i);
+ if (!set.add(elem.name)) {
+ error(SystemMessage.ERROR_DUPLICATED_ENTITY_NAME, elem, FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ }
+
+ }
+
+ @Check
+ def checkFunctionBlockName(FunctionblockModel model) {
+ val name = model.name
+ if (isCamelCasedName(name)) {
+ error(SystemMessage.ERROR_FBNAME_INVALID, model, FunctionblockPackage.Literals.FUNCTIONBLOCK_MODEL__NAME)
+ }
+ }
+
+ @Check
+ def checkEntityName(Entity entity) {
+ val name = entity.name
+ if (isCamelCasedName(name)) {
+ error(SystemMessage.ERROR_ENTITYNAME_INVALID_CAMELCASE, entity, FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ if (name.toLowerCase.endsWith('reply')) {
+ error(SystemMessage.ERROR_ENTITYNAME_SUFFIX_REPLY, entity, FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ }
+
+ def boolean isCamelCasedName(String name) {
+ !Character.isUpperCase((name).charAt(0))
+ }
+
+ @Check
+ def checkProperty(Property feature) {
+ var set = new HashSet<String>();
+ var features = feature.eContainer() as FBFeature;
+ var props = features.properties
+ for (var i = 0; i < props.length; i++) {
+ var feat = props.get(i)
+ if (!set.add(feat.propName)) {
+ error(SystemMessage.ERROR_DUPLICATED_PROPERTY_NAME, feat, FunctionblockPackage.Literals.PROPERTY__PROP_NAME)
+ }
+ }
+
+ }
+
+ @Check
+ def checkDuplicateParameter(Operation operation) {
+ var set = new HashSet<String>();
+ for (var i = 0; i < operation.params.length; i++) {
+ var param = operation.params.get(i)
+ if (!set.add(param.paramName)) {
+ error(SystemMessage.ERROR_DUPLICATED_PARAMETER_NAME, param, FunctionblockPackage.Literals.PARAMETER__PARAM_NAME)
+ }
+ }
+ }
+
+ @Check
+ def checkDuplicateOperation(Operation op) {
+ var set = new HashSet<String>();
+ var fb = op.eContainer() as FunctionBlock;
+ var ops = fb.features
+
+ for (var i = 0; i < ops.length; i++) {
+ var method = ops.get(i)
+ if (!set.add(method.methodName)) {
+ error(SystemMessage.ERROR_DUPLICATED_METHOD_NAME, method, FunctionblockPackage.Literals.OPERATION__METHOD_NAME)
+ }
+ }
+ }
+
+ @Check
+ def checkPropertyName(Property feature) {
+ var name = feature.propName
+ if (name.endsWith('TS')) {
+ error(SystemMessage.ERROR_PROPNAME_SUFFIX_TS, feature, FunctionblockPackage.Literals.PROPERTY__PROP_NAME)
+ }
+ }
+
+ @Check
+ def checkOpNameAgainstEntityName(Operation op) {
+ var fb = op.eContainer() as FunctionBlock
+ var fbm = fb.eContainer() as FunctionblockModel
+ var elems = fbm.elements
+ var enums = fbm.enums
+
+ var entLs = new LinkedList<String>;
+ for (i : elems.size >.. 0) {
+ entLs.add(elems.get(i).name.toLowerCase)
+ }
+
+ var enmLs = new LinkedList<String>;
+ for (i : enums.size >.. 0) {
+ enmLs.add(enums.get(i).name.toLowerCase)
+ }
+
+ var arr = entLs.toArray
+ var arr2 = enmLs.toArray
+
+ var ops = fb.features
+ for (i : ops.size >.. 0) {
+ if (arr.contains(ops.get(i).methodName.toLowerCase)) {
+ error(SystemMessage.ERROR_OPERATION_SAME_ENTITYNAME, ops.get(i),
+ FunctionblockPackage.Literals.OPERATION__METHOD_NAME)
+ }
+ if (arr2.contains(ops.get(i).methodName.toLowerCase)) {
+ error(SystemMessage.ERROR_OPERATION_SAME_ENUMNAME, ops.get(i),
+ FunctionblockPackage.Literals.OPERATION__METHOD_NAME)
+ }
+ }
+
+ }
+
+ @Check
+ def checkEnumNameAgainstEntityName(Enum enm) {
+ var fbm = enm.eContainer() as FunctionblockModel
+ var elems = fbm.elements
+
+ var entLs = new LinkedList<String>;
+ for (i : elems.size >.. 0) {
+ entLs.add(elems.get(i).name.toLowerCase)
+ }
+
+ var arr = entLs.toArray
+
+ if(arr.contains(enm.name.toLowerCase)){
+ error(SystemMessage.ERROR_ENTITY_SAME_ENUMNAME, enm,
+ FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ }
+
+ @Check
+ def checkVersionPattern(FunctionBlock functionblock){
+ if(!functionblock.version.matches("\\d+\\.\\d+\\.\\d+(\\-.+)?")){
+ error(SystemMessage.ERROR_VERSION_PATTERN, functionblock, FunctionblockPackage.Literals.FUNCTION_BLOCK__VERSION)
+ }
+ }
+
+ @Check
+ def checkDuplicatedLiteral(Enum enu){
+ var list = enu.enums
+ var set = new HashSet<String>();
+ for (var i = 0; i < list.length; i++) {
+ if(!set.add(list.get(i).literal)){
+ error(SystemMessage.ERROR_DUPLICATED_ENUM_LITERAL, list.get(i), FunctionblockPackage.Literals.ENUM_LITERAL__LITERAL)
+ }
+ }
+ }
+
+ @Check
+ def checkDuplicateEnumName(Enum ent) {
+ var superEntity = ent.eContainer() as FunctionblockModel;
+ var set = new HashSet<String>();
+ var enums = superEntity.enums
+
+ for (var i = 0; i < enums.length; i ++) {
+ var elem = enums.get(i);
+ if (!set.add(elem.name)) {
+ error(SystemMessage.ERROR_DUPLICATED_ENUM_NAME, elem, FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ }
+
+ }
+
+ @Check
+ def checkEnumName(Enum ent) {
+ val name = ent.name
+ if (isCamelCasedName(name)) {
+ error(SystemMessage.ERROR_ENUMNAME_INVALID_CAMELCASE, ent, FunctionblockPackage.Literals.OBJECT_TYPE__NAME)
+ }
+ }
+
+ @Check
+ def checkEnum(Enum ent) {
+ if(ent.getEnums().empty){
+ error(SystemMessage.ERROR_ENUM_CANNOT_BE_EMPTY, ent, FunctionblockPackage.Literals.ENUM__ENUMS)
+ }
+ }
+}
+
diff --git a/bundles/org.eclipse.vorto.metamodel/.classpath b/bundles/org.eclipse.vorto.metamodel/.classpath
new file mode 100644
index 0000000..c1ecbb3
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="model/generated"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.vorto.metamodel/.gitignore b/bundles/org.eclipse.vorto.metamodel/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/bundles/org.eclipse.vorto.metamodel/.project b/bundles/org.eclipse.vorto.metamodel/.project
new file mode 100644
index 0000000..4ec668b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.vorto.metamodel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.vorto.metamodel/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.metamodel/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..b0a07ea
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Vorto Information Meta-Model
+Bundle-Vendor: Bosch-SI
+Bundle-Version: 0.1.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-SymbolicName: org.eclipse.vorto.metamodel;singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.10.0"
+Export-Package:
+ org.eclipse.vorto.functionblock;uses:="org.eclipse.emf.ecore,org.eclipse.emf.common.util",
+ org.eclipse.vorto.functionblock.impl;
+ uses:="org.eclipse.vorto.functionblock,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.common.util,
+ org.eclipse.emf.ecore.impl,
+ org.eclipse.emf.common.notify",
+ org.eclipse.vorto.functionblock.util;
+ uses:="org.eclipse.vorto.functionblock,
+ org.eclipse.emf.ecore.util,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.common.notify.impl,
+ org.eclipse.emf.common.notify",
+ org.eclipse.vorto.functionblock.validation
+Bundle-ClassPath: .
+
diff --git a/bundles/org.eclipse.vorto.metamodel/about.html b/bundles/org.eclipse.vorto.metamodel/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/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>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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/bundles/org.eclipse.vorto.metamodel/build.properties b/bundles/org.eclipse.vorto.metamodel/build.properties
new file mode 100644
index 0000000..508931a
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/build.properties
@@ -0,0 +1,8 @@
+source.. = src/,\
+ model/generated
+bin.includes = META-INF/,\
+ .,\
+ model/,\
+ plugin.xml,\
+ about.html
+
diff --git a/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.ecore b/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.ecore
new file mode 100644
index 0000000..a4f9531
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.ecore
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="functionblock" nsURI="http://www.eclipse.org/vorto/metamodel/Functionblock"
+ nsPrefix="functionblock">
+ <eClassifiers xsi:type="ecore:EClass" name="FunctionblockModel">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="functionblock" eType="#//FunctionBlock"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="elements" upperBound="-1"
+ eType="#//Entity" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="enums" upperBound="-1"
+ eType="#//Enum" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="FunctionBlock">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="displayname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="vendor" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="category" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="version" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="configuration" eType="#//FBFeature"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="status" eType="#//FBFeature"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="fault" eType="#//FBFeature"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="features" upperBound="-1"
+ eType="#//Operation" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="events" upperBound="-1"
+ eType="#//Event" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="FBFeature">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="properties" upperBound="-1"
+ eType="#//Property" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="PrimitiveType">
+ <eLiterals name="string" literal="string"/>
+ <eLiterals name="int" value="1" literal="int"/>
+ <eLiterals name="float" value="2" literal="float"/>
+ <eLiterals name="boolean" value="3" literal="boolean"/>
+ <eLiterals name="datetime" value="4" literal="dateTime"/>
+ <eLiterals name="double" value="5" literal="double"/>
+ <eLiterals name="long" value="6" literal="long"/>
+ <eLiterals name="short" value="7" literal="short"/>
+ <eLiterals name="base64Binary" value="8" literal="base64Binary"/>
+ <eLiterals name="byte" value="9" literal="byte"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ObjectType">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Property">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="presence" eType="#//Presence"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="multiplicity" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="propName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Entity" eSuperTypes="#//ObjectType">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="superType" eType="#//Entity"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="properties" eType="#//FBFeature"
+ containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Presence">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="mandatory" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="optional" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="PrimitiveProperty" eSuperTypes="#//Property">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//PrimitiveType"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="Constraints" upperBound="-1"
+ eType="#//Constraint" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ObjectProperty" eSuperTypes="#//Property">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//ObjectType"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="ConstraintIntervalType">
+ <eLiterals name="min" literal="MIN"/>
+ <eLiterals name="max" value="1" literal="MAX"/>
+ <eLiterals name="strlen" value="2" literal="STRLEN"/>
+ <eLiterals name="regex" value="3" literal="REGEX"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Constraint">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ConstraintIntervalType"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="constraintValues" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Operation">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="methodName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="params" upperBound="-1"
+ eType="#//Parameter" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="returnType" eType="#//ReturnType"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ReturnType">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="multiplicity" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ReturnObjectType" eSuperTypes="#//ReturnType">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="returnType" eType="#//ObjectType"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ReturnPrimitiveType" eSuperTypes="#//ReturnType">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="returnType" eType="#//PrimitiveType"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Parameter">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="multiplicity" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="paramName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ObjectParam" eSuperTypes="#//Parameter">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="paramType" eType="#//ObjectType"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="PrimitiveParam" eSuperTypes="#//Parameter">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="paramType" eType="#//PrimitiveType"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Enum" eSuperTypes="#//ObjectType">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="enums" upperBound="-1"
+ eType="#//EnumLiteral" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="EnumLiteral">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="literal" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Event">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="feature" eType="#//FBFeature"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.genmodel b/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.genmodel
new file mode 100644
index 0000000..117586e
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/model/generated/Functionblock.genmodel
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.vorto.metamodel/src" editDirectory="/org.eclipse.vorto.fbeditor.edit/src"
+ editorDirectory="/org.eclipse.vorto.fbeditor.editor/src" modelPluginID="org.eclipse.vorto.fbeditor"
+ forceOverwrite="true" modelName="Functionblock" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
+ complianceLevel="5.0" copyrightFields="false" editPluginID="org.eclipse.vorto.fbeditor.edit"
+ editorPluginID="org.eclipse.vorto.fbeditor.editor" runtimeVersion="2.10">
+ <genPackages prefix="Functionblock" basePackage="org.eclipse.vorto"
+ disposableProviderFactory="true" fileExtensions="fbmodel" ecorePackage="Functionblock.ecore#/">
+ <genEnums typeSafeEnumCompatible="false" ecoreEnum="Functionblock.ecore#//PrimitiveType">
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/string"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/int"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/float"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/boolean"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/datetime"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/double"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/long"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/short"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/base64Binary"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//PrimitiveType/byte"/>
+ </genEnums>
+ <genEnums typeSafeEnumCompatible="false" ecoreEnum="Functionblock.ecore#//ConstraintIntervalType">
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//ConstraintIntervalType/min"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//ConstraintIntervalType/max"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//ConstraintIntervalType/strlen"/>
+ <genEnumLiterals ecoreEnumLiteral="Functionblock.ecore#//ConstraintIntervalType/regex"/>
+ </genEnums>
+ <genClasses ecoreClass="Functionblock.ecore#//FunctionblockModel">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionblockModel/name"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionblockModel/functionblock"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionblockModel/elements"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionblockModel/enums"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//FunctionBlock">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionBlock/displayname"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionBlock/description"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionBlock/vendor"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionBlock/category"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//FunctionBlock/version"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionBlock/configuration"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionBlock/status"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionBlock/fault"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FunctionBlock/features"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//FBFeature">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//FBFeature/properties"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ObjectType">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//ObjectType/name"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Property">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Property/presence"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Property/multiplicity"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Property/propName"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Property/description"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Entity">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Entity/superType"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Entity/properties"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Presence">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Presence/mandatory"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Presence/optional"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//PrimitiveProperty">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//PrimitiveProperty/type"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//PrimitiveProperty/Constraints"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ObjectProperty">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Functionblock.ecore#//ObjectProperty/type"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Constraint">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Constraint/type"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Constraint/constraintValues"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Operation">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Operation/methodName"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Operation/params"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Operation/returnType"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Operation/description"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ReturnType">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//ReturnType/multiplicity"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ReturnObjectType">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Functionblock.ecore#//ReturnObjectType/returnType"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ReturnPrimitiveType">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//ReturnPrimitiveType/returnType"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Parameter">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Parameter/multiplicity"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//Parameter/paramName"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//ObjectParam">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Functionblock.ecore#//ObjectParam/paramType"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//PrimitiveParam">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//PrimitiveParam/paramType"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//Enum">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Functionblock.ecore#//Enum/enums"/>
+ </genClasses>
+ <genClasses ecoreClass="Functionblock.ecore#//EnumLiteral">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Functionblock.ecore#//EnumLiteral/literal"/>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/bundles/org.eclipse.vorto.metamodel/plugin.xml b/bundles/org.eclipse.vorto.metamodel/plugin.xml
new file mode 100644
index 0000000..2450be9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/vorto/metamodel/Functionblock"
+ class = "org.eclipse.vorto.functionblock.FunctionblockPackage"
+ genModel = "model/generated/Functionblock.genmodel" />
+ </extension>
+</plugin>
diff --git a/bundles/org.eclipse.vorto.metamodel/pom.xml b/bundles/org.eclipse.vorto.metamodel/pom.xml
new file mode 100644
index 0000000..3c9444b
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/pom.xml
@@ -0,0 +1,94 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>bundles</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <artifactId>org.eclipse.vorto.metamodel</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Functionblock Meta-Model</name>
+
+ <profiles>
+ <profile>
+ <id>copy-plugins</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-kepler</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.metamodel</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${kepler.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-luna</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.metamodel</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${luna.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-visualrules</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.vorto</groupId>
+ <artifactId>org.eclipse.vorto.metamodel</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <outputDirectory>${visualrules.path}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Constraint.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Constraint.java
new file mode 100644
index 0000000..f9e3984
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Constraint.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Constraint</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.Constraint#getType <em>Type</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.Constraint#getConstraintValues <em>Constraint Values</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getConstraint()
+ * @model
+ * @generated
+ */
+public interface Constraint extends EObject {
+ /**
+ * Returns the value of the '<em><b>Type</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.vorto.functionblock.ConstraintIntervalType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Type</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Type</em>' attribute.
+ * @see org.eclipse.vorto.functionblock.ConstraintIntervalType
+ * @see #setType(ConstraintIntervalType)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getConstraint_Type()
+ * @model
+ * @generated
+ */
+ ConstraintIntervalType getType();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Constraint#getType <em>Type</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Type</em>' attribute.
+ * @see org.eclipse.vorto.functionblock.ConstraintIntervalType
+ * @see #getType()
+ * @generated
+ */
+ void setType(ConstraintIntervalType value);
+
+ /**
+ * Returns the value of the '<em><b>Constraint Values</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Constraint Values</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Constraint Values</em>' attribute.
+ * @see #setConstraintValues(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getConstraint_ConstraintValues()
+ * @model
+ * @generated
+ */
+ String getConstraintValues();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Constraint#getConstraintValues <em>Constraint Values</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Constraint Values</em>' attribute.
+ * @see #getConstraintValues()
+ * @generated
+ */
+ void setConstraintValues(String value);
+
+} // Constraint
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/ConstraintIntervalType.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/ConstraintIntervalType.java
new file mode 100644
index 0000000..dd1d013
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/ConstraintIntervalType.java
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Enumerator;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the literals of the enumeration '<em><b>Constraint Interval Type</b></em>',
+ * and utility methods for working with them.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getConstraintIntervalType()
+ * @model
+ * @generated
+ */
+public enum ConstraintIntervalType implements Enumerator {
+ /**
+ * The '<em><b>Min</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #MIN_VALUE
+ * @generated
+ * @ordered
+ */
+ MIN(0, "min", "MIN"),
+
+ /**
+ * The '<em><b>Max</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #MAX_VALUE
+ * @generated
+ * @ordered
+ */
+ MAX(1, "max", "MAX"),
+
+ /**
+ * The '<em><b>Strlen</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #STRLEN_VALUE
+ * @generated
+ * @ordered
+ */
+ STRLEN(2, "strlen", "STRLEN"),
+
+ /**
+ * The '<em><b>Regex</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #REGEX_VALUE
+ * @generated
+ * @ordered
+ */
+ REGEX(3, "regex", "REGEX");
+
+ /**
+ * The '<em><b>Min</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>Min</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #MIN
+ * @model name="min" literal="MIN"
+ * @generated
+ * @ordered
+ */
+ public static final int MIN_VALUE = 0;
+
+ /**
+ * The '<em><b>Max</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>Max</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #MAX
+ * @model name="max" literal="MAX"
+ * @generated
+ * @ordered
+ */
+ public static final int MAX_VALUE = 1;
+
+ /**
+ * The '<em><b>Strlen</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>Strlen</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #STRLEN
+ * @model name="strlen" literal="STRLEN"
+ * @generated
+ * @ordered
+ */
+ public static final int STRLEN_VALUE = 2;
+
+ /**
+ * The '<em><b>Regex</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>Regex</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #REGEX
+ * @model name="regex" literal="REGEX"
+ * @generated
+ * @ordered
+ */
+ public static final int REGEX_VALUE = 3;
+
+ /**
+ * An array of all the '<em><b>Constraint Interval Type</b></em>' enumerators.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final ConstraintIntervalType[] VALUES_ARRAY =
+ new ConstraintIntervalType[] {
+ MIN,
+ MAX,
+ STRLEN,
+ REGEX,
+ };
+
+ /**
+ * A public read-only list of all the '<em><b>Constraint Interval Type</b></em>' enumerators.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<ConstraintIntervalType> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
+
+ /**
+ * Returns the '<em><b>Constraint Interval Type</b></em>' literal with the specified literal value.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static ConstraintIntervalType get(String literal) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ ConstraintIntervalType result = VALUES_ARRAY[i];
+ if (result.toString().equals(literal)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>Constraint Interval Type</b></em>' literal with the specified name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static ConstraintIntervalType getByName(String name) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ ConstraintIntervalType result = VALUES_ARRAY[i];
+ if (result.getName().equals(name)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>Constraint Interval Type</b></em>' literal with the specified integer value.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static ConstraintIntervalType get(int value) {
+ switch (value) {
+ case MIN_VALUE: return MIN;
+ case MAX_VALUE: return MAX;
+ case STRLEN_VALUE: return STRLEN;
+ case REGEX_VALUE: return REGEX;
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final int value;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final String name;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final String literal;
+
+ /**
+ * Only this class can construct instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private ConstraintIntervalType(int value, String name, String literal) {
+ this.value = value;
+ this.name = name;
+ this.literal = literal;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /**
+ * Returns the literal value of the enumerator, which is its string representation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ return literal;
+ }
+
+} //ConstraintIntervalType
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Entity.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Entity.java
new file mode 100644
index 0000000..6285618
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Entity.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Entity</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.Entity#getSuperType <em>Super Type</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.Entity#getProperties <em>Properties</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEntity()
+ * @model
+ * @generated
+ */
+public interface Entity extends ObjectType {
+ /**
+ * Returns the value of the '<em><b>Super Type</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Super Type</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Super Type</em>' reference.
+ * @see #setSuperType(Entity)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEntity_SuperType()
+ * @model
+ * @generated
+ */
+ Entity getSuperType();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Entity#getSuperType <em>Super Type</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Super Type</em>' reference.
+ * @see #getSuperType()
+ * @generated
+ */
+ void setSuperType(Entity value);
+
+ /**
+ * Returns the value of the '<em><b>Properties</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Properties</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Properties</em>' containment reference.
+ * @see #setProperties(FBFeature)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEntity_Properties()
+ * @model containment="true"
+ * @generated
+ */
+ FBFeature getProperties();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Entity#getProperties <em>Properties</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Properties</em>' containment reference.
+ * @see #getProperties()
+ * @generated
+ */
+ void setProperties(FBFeature value);
+
+} // Entity
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Enum.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Enum.java
new file mode 100644
index 0000000..df6a073
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Enum.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Enum</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.Enum#getEnums <em>Enums</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEnum()
+ * @model
+ * @generated
+ */
+public interface Enum extends ObjectType {
+ /**
+ * Returns the value of the '<em><b>Enums</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.vorto.functionblock.EnumLiteral}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Enums</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Enums</em>' containment reference list.
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEnum_Enums()
+ * @model containment="true"
+ * @generated
+ */
+ EList<EnumLiteral> getEnums();
+
+} // Enum
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/EnumLiteral.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/EnumLiteral.java
new file mode 100644
index 0000000..8a139a9
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/EnumLiteral.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Enum Literal</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.EnumLiteral#getLiteral <em>Literal</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEnumLiteral()
+ * @model
+ * @generated
+ */
+public interface EnumLiteral extends EObject {
+ /**
+ * Returns the value of the '<em><b>Literal</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Literal</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Literal</em>' attribute.
+ * @see #setLiteral(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEnumLiteral_Literal()
+ * @model
+ * @generated
+ */
+ String getLiteral();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.EnumLiteral#getLiteral <em>Literal</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Literal</em>' attribute.
+ * @see #getLiteral()
+ * @generated
+ */
+ void setLiteral(String value);
+
+} // EnumLiteral
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Event.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Event.java
new file mode 100644
index 0000000..7948733
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/Event.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Event</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.Event#getFeature <em>Feature</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.Event#getName <em>Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEvent()
+ * @model
+ * @generated
+ */
+public interface Event extends EObject {
+ /**
+ * Returns the value of the '<em><b>Feature</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Feature</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Feature</em>' containment reference.
+ * @see #setFeature(FBFeature)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEvent_Feature()
+ * @model containment="true"
+ * @generated
+ */
+ FBFeature getFeature();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Event#getFeature <em>Feature</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Feature</em>' containment reference.
+ * @see #getFeature()
+ * @generated
+ */
+ void setFeature(FBFeature value);
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getEvent_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.Event#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+} // Event
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FBFeature.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FBFeature.java
new file mode 100644
index 0000000..8debc90
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FBFeature.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>FB Feature</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.FBFeature#getProperties <em>Properties</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFBFeature()
+ * @model
+ * @generated
+ */
+public interface FBFeature extends EObject {
+ /**
+ * Returns the value of the '<em><b>Properties</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.vorto.functionblock.Property}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Properties</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Properties</em>' containment reference list.
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFBFeature_Properties()
+ * @model containment="true"
+ * @generated
+ */
+ EList<Property> getProperties();
+
+} // FBFeature
diff --git a/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FunctionBlock.java b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FunctionBlock.java
new file mode 100644
index 0000000..bee6e09
--- /dev/null
+++ b/bundles/org.eclipse.vorto.metamodel/src/org/eclipse/vorto/functionblock/FunctionBlock.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Bosch Software Innovations GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * The Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Bosch Software Innovations GmbH - Please refer to git log
+ *
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.vorto.functionblock;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Function Block</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getDisplayname <em>Displayname</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getDescription <em>Description</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getVendor <em>Vendor</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getCategory <em>Category</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getVersion <em>Version</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getConfiguration <em>Configuration</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getStatus <em>Status</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getFault <em>Fault</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getFeatures <em>Features</em>}</li>
+ * <li>{@link org.eclipse.vorto.functionblock.FunctionBlock#getEvents <em>Events</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock()
+ * @model
+ * @generated
+ */
+public interface FunctionBlock extends EObject {
+ /**
+ * Returns the value of the '<em><b>Displayname</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Displayname</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Displayname</em>' attribute.
+ * @see #setDisplayname(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Displayname()
+ * @model
+ * @generated
+ */
+ String getDisplayname();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getDisplayname <em>Displayname</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Displayname</em>' attribute.
+ * @see #getDisplayname()
+ * @generated
+ */
+ void setDisplayname(String value);
+
+ /**
+ * Returns the value of the '<em><b>Description</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Description</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Description</em>' attribute.
+ * @see #setDescription(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Description()
+ * @model
+ * @generated
+ */
+ String getDescription();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getDescription <em>Description</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Description</em>' attribute.
+ * @see #getDescription()
+ * @generated
+ */
+ void setDescription(String value);
+
+ /**
+ * Returns the value of the '<em><b>Vendor</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Vendor</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Vendor</em>' attribute.
+ * @see #setVendor(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Vendor()
+ * @model
+ * @generated
+ */
+ String getVendor();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getVendor <em>Vendor</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Vendor</em>' attribute.
+ * @see #getVendor()
+ * @generated
+ */
+ void setVendor(String value);
+
+ /**
+ * Returns the value of the '<em><b>Category</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Category</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Category</em>' attribute.
+ * @see #setCategory(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Category()
+ * @model
+ * @generated
+ */
+ String getCategory();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getCategory <em>Category</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Category</em>' attribute.
+ * @see #getCategory()
+ * @generated
+ */
+ void setCategory(String value);
+
+ /**
+ * Returns the value of the '<em><b>Version</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Version</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Version</em>' attribute.
+ * @see #setVersion(String)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Version()
+ * @model
+ * @generated
+ */
+ String getVersion();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getVersion <em>Version</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Version</em>' attribute.
+ * @see #getVersion()
+ * @generated
+ */
+ void setVersion(String value);
+
+ /**
+ * Returns the value of the '<em><b>Configuration</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Configuration</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Configuration</em>' containment reference.
+ * @see #setConfiguration(FBFeature)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Configuration()
+ * @model containment="true"
+ * @generated
+ */
+ FBFeature getConfiguration();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getConfiguration <em>Configuration</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Configuration</em>' containment reference.
+ * @see #getConfiguration()
+ * @generated
+ */
+ void setConfiguration(FBFeature value);
+
+ /**
+ * Returns the value of the '<em><b>Status</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Status</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Status</em>' containment reference.
+ * @see #setStatus(FBFeature)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Status()
+ * @model containment="true"
+ * @generated
+ */
+ FBFeature getStatus();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getStatus <em>Status</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Status</em>' containment reference.
+ * @see #getStatus()
+ * @generated
+ */
+ void setStatus(FBFeature value);
+
+ /**
+ * Returns the value of the '<em><b>Fault</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Fault</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Fault</em>' containment reference.
+ * @see #setFault(FBFeature)
+ * @see org.eclipse.vorto.functionblock.FunctionblockPackage#getFunctionBlock_Fault()
+ * @model containment="true"
+ * @generated
+ */
+ FBFeature getFault();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.vorto.functionblock.FunctionBlock#getFault <em>Fault</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new va