/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package usda.weru.util;

import javolution.context.Context;

/**
 * Context to track when files are loaded for reports.  We don't want to show warnings or change the data on the fly.
 * @author Joseph Levin <joelevin@weru.ksu.edu>
 */
public class ReportContext extends Context{

    @Override
    protected void enterAction() {

    }

    @Override
    protected void exitAction() {

    }

    public static void enter(){
        Context.enter(ReportContext.class);
    }

    public static void exit(){
        Context.exit(ReportContext.class);
    }

    public static ReportContext getCurrent(){
        for (Context ctx = Context.getCurrent(); ctx != null; ctx = ctx.getOuter()) {
            if (ctx instanceof ReportContext){
                return (ReportContext) ctx;
            }
        }
        //TODO: add a default context
        return null;
    }

    public static boolean isInReport(){
        return getCurrent() != null;
    }

}
