Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » EclipseCon Demo/Slides
EclipseCon Demo/Slides [message #661998] Mon, 28 March 2011 19:53 Go to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Hey Konstantin,

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.

Thanks!
--Fitz
Re: EclipseCon Demo/Slides [message #662083 is a reply to message #661998] Tue, 29 March 2011 08:26 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Hi Brian,

I did not use slides for my EclipseCon talk. I will post the demo project shortly and I will probably produce a screen cast based on the content that I presented at some point.

In the meantime, what has got you all circular?

- Konstantin
Re: EclipseCon Demo/Slides [message #662203 is a reply to message #662083] Tue, 29 March 2011 17:26 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Awesome on the demo project and the screencast.

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. Smile

I didn't want to get too zealous though and implement absolutely everything in the hierarchy - just start small and work my way up.

--Fitz
Re: EclipseCon Demo/Slides [message #662280 is a reply to message #662203] Wed, 30 March 2011 04:19 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
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.

- Konstantin
Re: EclipseCon Demo/Slides [message #662388 is a reply to message #662280] Wed, 30 March 2011 13:48 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
It was #2. I didn't know I needed to turn on annotation processing. Now that it's on, it works!

I'm adding your list of things to check to my notes. Smile

Thanks Konstantin!

--Fitz
Re: EclipseCon Demo/Slides [message #662473 is a reply to message #662388] Wed, 30 March 2011 18:10 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
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.

- Konstantin
Re: EclipseCon Demo/Slides [message #662519 is a reply to message #662473] Wed, 30 March 2011 22:03 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Ok, so I'm now able to create a basic editor that generates some basic XML. Life is good. Smile

Here's the XML I'm generating:
<?xml version="1.0" encoding="UTF-8"?>
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <composite>
        <service>
            <service>MyCustomService</service>
        </service>
    </composite>
</switchyard>


I'd like to generate this:
<?xml version="1.0" encoding="UTF-8"?>
<switchyard xmlns="urn:switchyard-config:switchyard:1.0">
    <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
        <service>
            <service name="MyCustomService"></service>
        </service>
    </composite>
</switchyard>


This would require a couple of things.

1) A way to specify a custom namespace on particular elements. I tried adding:

@XmlNamespace(prefix = "sca", uri = "http://docs.oasis-open.org/ns/opencsa/sca/200912")


But it didn't do anything that I can see.

and 2) A way to specify XML attribute values.

The first I can believe is probably a work in progress. But the second hopefully isn't. Is there a way to specify attribute content vs. node content?

Thanks in advance!

--Fitz
Re: EclipseCon Demo/Slides [message #662522 is a reply to message #661998] Wed, 30 March 2011 22:27 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
> 1) A way to specify a custom namespace [snip]

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.

- Konstantin
Re: EclipseCon Demo/Slides [message #662543 is a reply to message #662522] Thu, 31 March 2011 04:37 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Awesome on both counts. I'll give 'em a go.

Thanks again!
Re: EclipseCon Demo/Slides [message #662545 is a reply to message #662522] Thu, 31 March 2011 04:44 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Ok, so for the namespace thing I'm still not getting it...

@GenerateImpl
@XmlNamespace(prefix = "sca", uri = "http://docs.oasis-open.org/ns/opencsa/sca/200912")

public interface IComposite  extends IModelElement {

    ModelElementType TYPE = new ModelElementType( IComposite.class );

    // *** Name ***
    
    @XmlBinding( path = "sca:composite" )
    @Label( standard = "&Name" )

    ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );
    ...
}


Should that work?

And for the attribute thing, I'm also not getting where that should go...

If I declare an XMLBinding to an element and have a ValueProperty, do I do a separate XMLBinding annotation to identify the attribute?

I have this:
@GenerateImpl

public interface IService extends IModelElement {

    ModelElementType TYPE = new ModelElementType( IService.class );

    // *** Name ***
    
    @XmlBinding( path = "service" )
    @Label( standard = "&service" )
    @NonNullValue

    ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );

    Value<String> getName();
    void setName( String value );
   ...
}


Where does the annotation go for the name?

Thanks again and sorry for the dumb questions. Smile

--Fitz
Re: EclipseCon Demo/Slides [message #662547 is a reply to message #662545] Thu, 31 March 2011 05:13 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
> Ok, so for the namespace thing I'm still not getting it...

That looks correct to me. Have you compared what you are doing with the contacts sample?

> If I declare an XMLBinding to an element and have a ValueProperty,
> do I do a separate XMLBinding annotation to identify the attribute?

Depends on what you are trying to accomplish. Maybe you are looking for this...

@XmlBinding( path = "service/@name" )


This will automatically create or traverse into the service element and bind the property to that element's name attribute.

- Konstantin
Re: EclipseCon Demo/Slides [message #662552 is a reply to message #662547] Thu, 31 March 2011 05:47 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
Ok, got the attribute thing working. Thanks for the tip there.

As far as the namespace bits go...

For my root element, I'm defining:
@XmlRootBinding( namespace = "urn:switchyard-config:switchyard:1.0",
                 elementName = "switchyard" )


And then in the next level down in the hierarchy, I'm defining:
@XmlNamespace(prefix = "sca", uri = "http://docs.oasis-open.org/ns/opencsa/sca/200912")

public interface ... {
    ModelElementType TYPE = blah...


    @XmlBinding( path = "sca:composite/@name" )


It doesn't look any different than the IAddress/IContactsDatabase example, but I might be missing something.

[Updated on: Thu, 31 March 2011 05:54]

Report message to a moderator

Re: EclipseCon Demo/Slides [message #662686 is a reply to message #662552] Thu, 31 March 2011 14:53 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Could you post the complete source of your two model elements along with XML structure you hope to generate?

- Konstantin
Re: EclipseCon Demo/Slides [message #662738 is a reply to message #662686] Thu, 31 March 2011 17:34 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 495
Registered: July 2009
Senior Member
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.]

--Fitz-

[Updated on: Thu, 31 March 2011 17:36]

Report message to a moderator

Re: EclipseCon Demo/Slides [message #662796 is a reply to message #662738] Fri, 01 April 2011 00:40 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
For those watching this thread, you may want to know that the tip has hopped over to sapphire-dev@eclipse.org in order to swap a few attachments.

http://dev.eclipse.org/mhonarc/lists/sapphire-dev/msg00202.h tml
http://dev.eclipse.org/mhonarc/lists/sapphire-dev/msg00206.h tml

- Konstantin
Previous Topic:State of Sapphire for Spring 2011
Next Topic:JBoss Blog Post re:Sapphire
Goto Forum:
  


Current Time: Fri Dec 19 21:00:22 GMT 2014

Powered by FUDForum. Page generated in 0.08966 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software