Yeah, you could do that.  The problem is that won't keep all the
formatting and such it it's an existing file.  I think a better way is
to use the WTP support to load the DOM model, and then create a POM
model wrapping it.  That way the XML sync code will keep as much
exising formatting, etc. as possible.

Something along the lines of:

        IFile file = ????????
        IModelManager modelManager =
StructuredModelManager.getModelManager();
        IDOMModel model = (IDOMModel)
modelManager.getExistingModelForEdit( file );
        if ( null == model )
        {
            model = (IDOMModel) modelManager.getModelForEdit( file );
        }
        URI uri =
URI.createURI( file.getLocationURI().toASCIIString() );
        SSESyncResource resc = new SSESyncResource( uri );
        resc.load( null );
        org.devzuz.q.maven.pom.Model pom =
(org.devzuz.q.maven.pom.Model) resc.getContents().get( 0 );
        //modify the pom
        model.save();
        model.releaseFromEdit();

Should do the trick.  I could have sworn I wrote a utility class to do
this, but looking at my copy of the tree I don't see it.  I didn't
test the code above so hopefully it or something close to it will
work.

On Sep 13, 4:14 am, Abel Muiño Vizcaino <[EMAIL PROTECTED]> wrote:
> AFAIK, you can persist any EMF model to XML (and also database), but  
> I'm not aware of the specific classes you need to use.
>
> A quick search returned this code snippet: http://
> kathayat.wordpress.com/2007/07/26/saving-the-emf-model-to-xml-file/
> --
> Abel Muiño Vizcaino -http://ramblingabout.wordpress.com
>
> El 13/09/2008, a las 9:20, aramirez escribió:
>
>
>
> > Hi guys,
>
> > I tried playing around with the new pom emf plugin. However, I can
> > seem to find a way to save the changes programmatically if no editor
> > is open.
>
> > I understand that emf is built so that each all editors that shared
> > same resources will be notified with the changes.
>
> > The problem is, what if no editor is open.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Q 
for Eclipse developers list" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/q4e-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to