/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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.apache.isis.viewer.wicket.viewer.wicketapp.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;

import org.apache.isis.viewer.wicket.viewer.IsisModuleViewerWicketViewer;

import lombok.experimental.UtilityClass;

@UtilityClass
public class WicketViewerXray {

    private final String KEY = IsisModuleViewerWicketViewer.NAMESPACE + ".xray";

    /**
     * Activates visual debugging mode for the Wicket Viewer.
     * Use for troubleshooting and bug hunting.
     * <p>
     * Not imported by {@link IsisModuleViewerWicketViewer}.
     */
    @Configuration
    public static class Enable implements InitializingBean {

        @Override
        public void afterPropertiesSet() throws Exception {
            System.setProperty(KEY, "true");
        }

    }

    public boolean isEnabled() {
        return "true".equalsIgnoreCase(System.getProperty(KEY));
    }

    public void setEnabled(final boolean enabled) {
        System.setProperty(KEY, "" + enabled);
    }

}

@@ -898,53 +898,49 @@
 org.
-springframework.beans.factory.InitializingBea
+apache.wicket.protocol.http.WebApplicatio
 n;%0Ai
@@ -1000,16 +1000,94 @@
 ation;%0A%0A
+import org.apache.isis.viewer.wicket.model.isis.WicketApplicationInitializer;%0A
 import o
@@ -1153,16 +1153,38 @@
 iewer;%0A%0A
+import lombok.Getter;%0A
 import l
@@ -1268,90 +1268,8 @@
  %7B%0A%0A
-    private final String KEY = IsisModuleViewerWicketViewer.NAMESPACE + %22.xray%22;%0A%0A
     
@@ -1511,16 +1511,24 @@
 s Enable
+%0A       
  impleme
@@ -1531,16 +1531,33 @@
 lements 
+WicketApplication
 Initiali
@@ -1561,15 +1561,10 @@
 aliz
-ingBean
+er
  %7B%0A%0A
@@ -1605,90 +1605,198 @@
 oid 
-afterPropertiesSet() throws Exception %7B%0A            System.setProperty(KEY, %22
+init(final WebApplication webApplication) %7B%0A            WicketViewerXray.enabled = true;%0A            webApplication.getDebugSettings()%0A                .setOutputMarkupContainerClassName(
 true
-%22
 );%0A 
@@ -1800,25 +1800,24 @@
 ;%0A        %7D%0A
-%0A
     %7D%0A%0A    p
@@ -1819,213 +1819,52 @@
     
-public boolean isEnabled() %7B%0A        return %22true%22.equalsIgnoreCase(System.getProperty(KEY));%0A    %7D%0A%0A    public void setEnabled(final boolean enabled) %7B%0A        System.setProperty(KEY, %22%22 + enabled);%0A    %7D
+@Getter%0A    private boolean enabled = false;
 %0A%0A%7D%0A

simplify and harden prev. commit