/*
 * Copyright 2011 Jonathan Anderson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.footlights.demos.good;

import scala.Option;
import java.util.logging.Logger;

import me.footlights.api.KernelInterface;
import me.footlights.api.ModifiablePreferences;
import me.footlights.api.ajax.AjaxHandler;


/**
 * A well-behaved application that legitimately exercises Footlights services.
 * @author jon@footlights.me
 */
public class GoodApp extends me.footlights.api.Application
{
	public static GoodApp init(KernelInterface kernel, ModifiablePreferences prefs, Logger log)
	{
		log.info("Loading " + GoodApp.class.getCanonicalName() + "...");
		return new GoodApp(new DemoAjaxHandler(kernel, log));
	}

	@Override public Option<AjaxHandler> ajaxHandler() { return Option.apply(ajax); }

	private GoodApp(AjaxHandler ajax)
	{
		super("Basic demo");
		this.ajax = ajax;
	}

	private final AjaxHandler ajax;
}

@@ -684,16 +684,52 @@
 ogger;%0A%0A
+import me.footlights.api.Directory;%0A
 import m
@@ -853,16 +853,58 @@
 andler;%0A
+import me.footlights.api.ajax.JavaScript;%0A
 %0A%0A/**%0A *
@@ -1379,16 +1379,237 @@
 ajax); %7D
+%0A%09@Override public void open(Directory directory)%0A%09%7B%0A%09%09ajax.fireAsynchronousEvent(%0A%09%09%09new JavaScript(%22context.root.appendElement('div').appendText('open(%22)%0A%09%09%09%09.appendText(directory.toString())%0A%09%09%09%09.append(%22)');%22)%0A%09%09);%0A%09%7D
 %0A%0A%09priva

Handle open(Directory) in basic demo app.