/*
 *  Copyright 2014 Dan Haywood
 *
 *  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 org.isisaddons.app.kitchensink.fixture;

import java.util.List;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.DomainServiceLayout;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.Prototype;
import org.apache.isis.applib.fixturescripts.FixtureResult;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import org.apache.isis.applib.fixturescripts.FixtureScripts;

/**
 * Enables fixtures to be installed from the application.
 */
@Named("Prototyping")
@DomainService
@DomainServiceLayout(menuBar = DomainServiceLayout.MenuBar.SECONDARY, menuOrder = "99")
public class KitchensinkFixturesService extends FixtureScripts {

    private boolean isInstalled = false;

    public KitchensinkFixturesService() {
        super("org.isisaddons.app.kitchensink.fixture");
    }

    @Override
    public FixtureScript default0RunFixtureScript() {
        return findFixtureScriptFor(KitchensinkSetupFixture.class);
    }

    /**
     * Raising visibility to <tt>public</tt> so that choices are available for first param
     * of {@link #runFixtureScript(FixtureScript, String)}.
     */
    @Override
    public List<FixtureScript> choices0RunFixtureScript() {
        return super.choices0RunFixtureScript();
    }


    // //////////////////////////////////////

    @Prototype
    @MemberOrder(sequence="20")
    public Object installFixturesAndReturnFirst() {
        final List<FixtureResult> run = findFixtureScriptFor(KitchensinkSetupFixture.class).run(null);
        isInstalled = true;
        return run.get(0).getObject();
    }

    public String disableInstallFixturesAndReturnFirst() {
        return isInstalled ? "The installation can be ran just once" : null;
    }
}

@@ -1202,30 +1202,8 @@
  */%0A
-@Named(%22Prototyping%22)%0A
 @Dom
@@ -1234,16 +1234,39 @@
 eLayout(
+named = %22Prototyping%22, 
 menuBar 

Use @DomainServiceLayout#named instead of the deprecated @Named