Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-07-31 06:37:12 -0400
committerTom Schindl2013-07-31 06:37:12 -0400
commit8787980b6affb22664109008f48f9a419a679860 (patch)
treec2beb0f7b274fa9aa6259826a3c26368405da301
parentf52bf9d9616b4bfc951fb0030a54bfca3ebe4f3b (diff)
downloadorg.eclipse.efxclipse-runtime/kepler.tar.gz
org.eclipse.efxclipse-runtime/kepler.tar.xz
org.eclipse.efxclipse-runtime/kepler.zip
Bug 414114 - Add FXML to Java Translatorruntime/kepler
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend28
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/PrimitiveType.xtend5
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/ReflectionHelper.xtend2
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/TestLoading.xtend20
4 files changed, 47 insertions, 8 deletions
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend b/bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend
index eb38202f2..9e71fb26a 100644
--- a/bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend
+++ b/bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend
@@ -11,22 +11,33 @@ import org.eclipse.xtext.common.types.TypesFactory
import javax.inject.Inject
import org.eclipse.xtext.common.types.access.IJvmTypeProvider
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
+import javax.xml.parsers.SAXParserFactory
class FXMLSaxHandler extends DefaultHandler {
- Model model;
+ public Model model;
Stack<Object> stack = new Stack;
// @Inject
// private IJvmTypeProvider.Factory jdtTypeProviderFactory;
- private IJvmTypeProvider jdtTypeProvider;
+// private IJvmTypeProvider jdtTypeProvider;
+
+ private String packageName;
+
+ new(String packageName)
+ {
+ this.packageName = packageName;
+ }
override startDocument() throws SAXException {
// jdtTypeProvider = jdtTypeProviderFactory.findOrCreateTypeProvider(new ResourceSetImpl)
model = FXGraphFactory.eINSTANCE.createModel
- val componentDef = FXGraphFactory.eINSTANCE.createComponentDefinition
+ val pack = FXGraphFactory.eINSTANCE.createPackageDeclaration
+ pack.setName(packageName)
+ model.setPackage(pack)
+ val componentDef = FXGraphFactory.eINSTANCE.createComponentDefinition
model.componentDef = componentDef
}
@@ -50,6 +61,8 @@ class FXMLSaxHandler extends DefaultHandler {
// A property
val e = stack.peek as Element
val prop = FXGraphFactory.eINSTANCE.createProperty
+ val vProp = FXGraphFactory.eINSTANCE.createSimpleValueProperty
+
e.properties.add(prop)
stack.push(prop)
@@ -62,6 +75,10 @@ class FXMLSaxHandler extends DefaultHandler {
jvmType.simpleName = localName
t.type = jvmType
e.type = t
+
+ if( model.componentDef.rootNode == null ) {
+ model.componentDef.rootNode = e
+ }
stack.push(e)
}
@@ -70,9 +87,4 @@ class FXMLSaxHandler extends DefaultHandler {
override endElement(String uri, String localName, String qName) throws SAXException {
stack.pop
}
-
- def static void main(String[] args) {
- val h = new FXMLSaxHandler()
-
- }
} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/PrimitiveType.xtend b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/PrimitiveType.xtend
new file mode 100644
index 000000000..90e3cd9a7
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/PrimitiveType.xtend
@@ -0,0 +1,5 @@
+package org.eclipse.fx.ide.fxml.compiler
+
+enum PrimitiveType {
+
+} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/ReflectionHelper.xtend b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/ReflectionHelper.xtend
index a8d403f66..a83ad4e41 100644
--- a/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/ReflectionHelper.xtend
+++ b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/ReflectionHelper.xtend
@@ -27,4 +27,6 @@ class ReflectionHelper {
return p.value;
}
+
+// def static
} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/TestLoading.xtend b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/TestLoading.xtend
new file mode 100644
index 000000000..4e17fbbe4
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/src/org/eclipse/fx/ide/fxml/compiler/TestLoading.xtend
@@ -0,0 +1,20 @@
+package org.eclipse.fx.ide.fxml.compiler
+
+import java.io.File
+import javax.xml.parsers.SAXParserFactory
+import org.eclipse.fx.ide.fxgraph.converter.FXMLSaxHandler
+import org.eclipse.fx.ide.fxgraph.converter.FXGraphConverter
+
+class TestLoading {
+ def static void main(String[] args) {
+ val f = SAXParserFactory.newInstance
+ f.setNamespaceAware(true);
+ val p = f.newSAXParser
+ val h = new FXMLSaxHandler("test")
+
+ p.parse(new File("/Users/tomschindl/git/efxclipse/bundles/tooling/org.eclipse.fx.ide.fxml.compiler/sample-src/sample/Sample.fxml"), h)
+ val c = new FXGraphConverter
+ c.generate(h.model);
+ }
+
+} \ No newline at end of file

Back to the top