package bdv.img.remote;

import java.io.File;
import java.io.IOException;

import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription;
import mpicbg.spim.data.generic.sequence.ImgLoaderIo;
import mpicbg.spim.data.generic.sequence.XmlIoBasicImgLoader;

import org.jdom2.Element;

@ImgLoaderIo( format = "bdv.remote", type = RemoteImageLoader.class )
public class XmlIoRemoteImageLoader implements XmlIoBasicImgLoader< RemoteImageLoader >
{

	@Override
	public Element toXml( final RemoteImageLoader imgLoader, final File basePath )
	{
		throw new UnsupportedOperationException( "not implemented" );
	}

	@Override
	public RemoteImageLoader fromXml( final Element elem, final File basePath, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription )
	{
		final String baseUrl = elem.getChildText( "baseUrl" );
		try
		{
			return new RemoteImageLoader( baseUrl );
		}
		catch ( final IOException e )
		{
			throw new RuntimeException( e );
		}
	}

}

@@ -18,16 +18,89 @@
 emote;%0A%0A
+import static mpicbg.spim.data.XmlKeys.IMGLOADER_FORMAT_ATTRIBUTE_NAME;%0A%0A
 import j
@@ -141,16 +141,52 @@
 ption;%0A%0A
+import mpicbg.spim.data.XmlHelpers;%0A
 import m
@@ -652,68 +652,219 @@
 %7B%0A%09%09
-throw new UnsupportedOperationException( %22not implemented%22 )
+final Element elem = new Element( %22ImageLoader%22 );%0A%09%09elem.setAttribute( IMGLOADER_FORMAT_ATTRIBUTE_NAME, %22bdv.remote%22 );%0A%09%09elem.addContent( XmlHelpers.textElement( %22baseUrl%22, imgLoader.baseUrl ) );%0A%09%09return elem
 ;%0A%09%7D

implement toXml() for RemoteImageLoader.