Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-01-17 15:27:42 +0000
committerHenrik Rentz-Reichert2013-01-17 15:27:42 +0000
commitc6f4dda244f74e45aa6f8fb507098a6c97e2566b (patch)
treed657081a54be32b82d99f4578d0dafc537c355c9 /examples/my.etrice.generator/src/my
parent7d59957221934d0c85b19fc2fdc6980197e90a8f (diff)
downloadorg.eclipse.etrice-c6f4dda244f74e45aa6f8fb507098a6c97e2566b.tar.gz
org.eclipse.etrice-c6f4dda244f74e45aa6f8fb507098a6c97e2566b.tar.xz
org.eclipse.etrice-c6f4dda244f74e45aa6f8fb507098a6c97e2566b.zip
[examples] added minimal derived Java generator
Diffstat (limited to 'examples/my.etrice.generator/src/my')
-rw-r--r--examples/my.etrice.generator/src/my/etrice/generator/DerivedGenerator.java32
-rw-r--r--examples/my.etrice.generator/src/my/etrice/generator/gen/DerivedTranslationProvider.java35
-rw-r--r--examples/my.etrice.generator/src/my/etrice/generator/setup/DerivedGeneratorModule.java52
3 files changed, 119 insertions, 0 deletions
diff --git a/examples/my.etrice.generator/src/my/etrice/generator/DerivedGenerator.java b/examples/my.etrice.generator/src/my/etrice/generator/DerivedGenerator.java
new file mode 100644
index 000000000..034f91d18
--- /dev/null
+++ b/examples/my.etrice.generator/src/my/etrice/generator/DerivedGenerator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package my.etrice.generator;
+
+import my.etrice.generator.setup.DerivedGeneratorModule;
+
+import org.eclipse.etrice.generator.java.Main;
+
+/**
+ * EXAMPLE: just delegate to base class
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DerivedGenerator extends Main {
+
+ public static void main(String[] args) {
+ int ret = createAndRunGenerator(new DerivedGeneratorModule(), args);
+ if (isTerminateOnError() && ret!=GENERATOR_OK)
+ System.exit(ret);
+ }
+}
diff --git a/examples/my.etrice.generator/src/my/etrice/generator/gen/DerivedTranslationProvider.java b/examples/my.etrice.generator/src/my/etrice/generator/gen/DerivedTranslationProvider.java
new file mode 100644
index 000000000..3f1bd9379
--- /dev/null
+++ b/examples/my.etrice.generator/src/my/etrice/generator/gen/DerivedTranslationProvider.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package my.etrice.generator.gen;
+
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.generator.java.gen.JavaTranslationProvider;
+
+
+/**
+ * EXAMPLE: derive translation provider and just override the tags.
+ * Delegates to super.
+ * NOTE: not necessary in the minimal version.
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DerivedTranslationProvider extends JavaTranslationProvider {
+
+ public String translateTag(String tag, DetailCode code) {
+ if (tag.equals("Derived"))
+ return "DerivedReplacement";
+
+ return super.translateTag(tag, code);
+ }
+}
diff --git a/examples/my.etrice.generator/src/my/etrice/generator/setup/DerivedGeneratorModule.java b/examples/my.etrice.generator/src/my/etrice/generator/setup/DerivedGeneratorModule.java
new file mode 100644
index 000000000..af71bf759
--- /dev/null
+++ b/examples/my.etrice.generator/src/my/etrice/generator/setup/DerivedGeneratorModule.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package my.etrice.generator.setup;
+
+import my.etrice.generator.DerivedGenerator;
+import my.etrice.generator.gen.DerivedTranslationProvider;
+
+import org.eclipse.etrice.generator.base.ITranslationProvider;
+import org.eclipse.etrice.generator.java.Main;
+import org.eclipse.etrice.generator.java.setup.GeneratorModule;
+
+import com.google.inject.Binder;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DerivedGeneratorModule extends GeneratorModule {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.java.setup.GeneratorModule#configure(com.google.inject.Binder)
+ */
+ @Override
+ public void configure(Binder binder) {
+ // EXAMPLE: invoke base class configuration
+ super.configure(binder);
+
+ // EXAMPLE: override already bound AbstractGenerator -> Main
+ binder.bind(Main.class).to(DerivedGenerator.class);
+ }
+
+ /**
+ * EXAMPLE: override the translation provider
+ * NOTE: in the minimal setting not necessary
+ *
+ * @see org.eclipse.etrice.generator.java.setup.GeneratorModule#bindITranslationProvider()
+ */
+ @Override
+ public Class<? extends ITranslationProvider> bindITranslationProvider() {
+ return DerivedTranslationProvider.class;
+ }
+}

Back to the top