Thanks again for walking through the demo at EclipseCon. I'm starting to play with the Sapphire framework a bit now and am getting wrapped in circles. I'm sure I can find my way out of the maze I've created, but if you get a chance to post the slides and demo from your talk, that might help as well if you have a chance.
I'm guessing that my issues stem from not having a fully-defined set of interfaces that I'm trying to code against. As we discussed at EclipseCon, I have a schema that I'm trying to develop a UI for in Sapphire. So I've started with a couple of interface classes and indicated a containment hierarchy...
Using the bug tracker example as my example, I have a root element containing a collection of another element. Not too complex. And the inner element has a title. That's it.
I've set up my editor class to extend SapphireEditorForXml.
And when I run it I get: "Editor org.jboss.tools.sapphire.ui.SwitchyardEditor failed to instantiate its model."
So I'm guessing that I've screwed something up initially.
PEBCAK and all.
I didn't want to get too zealous though and implement absolutely everything in the hierarchy - just start small and work my way up.
This error indicates that the framework is not able to find implementation class for a model element. This has a few possible causes:
1. Missing @GenerateImpl annotation on model element interface.
2. Annotation processing is not turned on for the project. See Project Properties -> Java Compiler -> Annotation Processing -> Enable annotation processing.
3. Dev eclipse install does not have Sapphire SDK installed (so no Sapphire annotation processor). Verify that this is not an issue by checking under Project Properties -> Java Compiler -> Annotation Processing -> Factory Path. You should see org.eclipse.sapphire.modeling listed.
To see the generated classes, turn off the filter that removes files that start with '.' then look for .apt_generated folder.
Very cool. Project configuration is a weak spot in the Sapphire SDK. There are other aspects that you will want to configure at some point. For instance, PDE Build (commandline build support) doesn't know anything about JDT's annotation processing capabilities. You have to compensate via Ant. See customBuildCallbacks.xml file in the samples project.
At some point we are going to need to make a Sapphire facet or something like that. I've been also considering dropping annotation processing in favor of runtime bytecode generation of impl classes. After all, a framework with fewer build dependencies would be easier to use.
Look forward to reading more about your experience. Thanks for the plug on your blog.
You got half of the required declaration. In addition to the @XmlNamespace declaration, you also need to reference the namespace in the binding annotations, such as @XmlBinding( path = "sca:composite" ). The prefix needs to line up to what's specified in @XmlNamespace annotation.
At runtime, it will use the prefix specified in @XmlNamespace, but if an existing document is loaded with a different prefix, it will understand and use that one.
There is an example of mixing namespaces in the contacts sample. The IAddress element uses a different namespace.
> 2) A way to specify XML attribute values.
Use "@" prefix in the path, such as @XmlBinding( path = "@id" ). There is also "%" prefix to bind to a meta-comment, which is a good way to tuck away extra data when you don't have place for it in the schema.
Well now I have a couple of issues. The namespace issue is one, but for some reason I can't get it to generate the implementation class for one of my interfaces. So when it tries to instantiate one, it dies because it's not there to instantiate.
I've tried everything I can think of short of deleting the file and recreating it. Any suggestions? Once I get it to the point where it'll build again I can put the code up.
[Update: Tried deleting it and rebuilding, no luck there.]