Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-07-01 17:03:24 -0400
committerTom Schindl2013-07-01 17:03:24 -0400
commit942c41fa6949998920fdc9911aff7a8bffe196b5 (patch)
tree9c949bfe98d9673b54125aa3ea7fc37fdaee83b0
parente2a4ef5bffc8da3b1e44fc4777b82bfb77311b0f (diff)
downloadorg.eclipse.efxclipse-942c41fa6949998920fdc9911aff7a8bffe196b5.tar.gz
org.eclipse.efxclipse-942c41fa6949998920fdc9911aff7a8bffe196b5.tar.xz
org.eclipse.efxclipse-942c41fa6949998920fdc9911aff7a8bffe196b5.zip
started on rewrite for FXML => FXGraph conversion
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend78
1 files changed, 78 insertions, 0 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
new file mode 100644
index 000000000..eb38202f2
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.fxgraph/src/org/eclipse/fx/ide/fxgraph/converter/FXMLSaxHandler.xtend
@@ -0,0 +1,78 @@
+package org.eclipse.fx.ide.fxgraph.converter
+
+import java.util.Stack
+import org.eclipse.fx.ide.fxgraph.fXGraph.Element
+import org.eclipse.fx.ide.fxgraph.fXGraph.FXGraphFactory
+import org.eclipse.fx.ide.fxgraph.fXGraph.Model
+import org.xml.sax.Attributes
+import org.xml.sax.SAXException
+import org.xml.sax.helpers.DefaultHandler
+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
+
+class FXMLSaxHandler extends DefaultHandler {
+ Model model;
+
+ Stack<Object> stack = new Stack;
+
+// @Inject
+// private IJvmTypeProvider.Factory jdtTypeProviderFactory;
+
+ private IJvmTypeProvider jdtTypeProvider;
+
+ override startDocument() throws SAXException {
+// jdtTypeProvider = jdtTypeProviderFactory.findOrCreateTypeProvider(new ResourceSetImpl)
+ model = FXGraphFactory.eINSTANCE.createModel
+ val componentDef = FXGraphFactory.eINSTANCE.createComponentDefinition
+
+ model.componentDef = componentDef
+ }
+
+ override processingInstruction(String target, String data) throws SAXException {
+ if ("import" == target) {
+ val i = FXGraphFactory.eINSTANCE.createImport
+ i.importedNamespace = data
+ model.imports += i
+ }
+ }
+
+ override startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ if( localName.contains('.') ) {
+ // A static property
+ val e = stack.peek as Element
+ val prop = FXGraphFactory.eINSTANCE.createStaticValueProperty
+
+ e.staticProperties.add(prop);
+ stack.push(prop)
+ } else if( Character.isLowerCase(localName.charAt(0)) ) {
+ // A property
+ val e = stack.peek as Element
+ val prop = FXGraphFactory.eINSTANCE.createProperty
+ e.properties.add(prop)
+
+ stack.push(prop)
+ } else {
+ // An element
+ val e = FXGraphFactory.eINSTANCE.createElement
+
+ val t = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference()
+ val jvmType = TypesFactory.eINSTANCE.createJvmPrimitiveType()
+ jvmType.simpleName = localName
+ t.type = jvmType
+ e.type = t
+
+ stack.push(e)
+ }
+ }
+
+ 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

Back to the top