classdef(Hidden, Sealed) FigureList < internal.EconModeler.AbstractList
    %FIGURELIST Storage for figure documents currently open in the
    %econModeler App
    
    %Copyright 2017 The MathWorks, Inc.
    
    properties (Access = private)
        Listeners
    end
    
    methods(Access = {?internal.EconModeler.econModelerSession,...
            ?internal.EconModeler.AbstractList})
        function this = FigureList(session)
            this = this@internal.EconModeler.AbstractList(session);
        end
        
        function add(this,fig)
            %Add a figure to the list
            validateattributes(fig,{'internal.EconModeler.EconComponents.AbstractFigure'},{'column'});
            idx = this.List == fig;
            if ~any(idx)
                this.List = [this.List; fig];
            end
        end
    
        function clearAll(this)
            %Clear all figures in the list
            for n = 1:length(this.List)
                delete(this.List(n).Figure);
                delete(this.List(n));
            end
            this.List = [];
        end
        
        function removeFigure(this,figToDelete)
            %Remove a figure from the list
            idx = (this.List == figToDelete);
            this.List(idx) = [];
            %delete(figToDelete);
        end
    end
end

