classdef (Hidden) InspectDialog < ctrluis.component.AbstractDialog
    % Inpsect Dialog of Model Reduction App to see the system matrices of
    % LTI system
    
    % Author(s): Suat Gumussoy
    % Copyright 2015 The MathWorks, Inc.
    
    properties(GetAccess = public, SetAccess = private, AbortSet = true)
        ToolData
        Anchor
        Widgets
    end
    methods
        function this = InspectDialog(ToolData)
            this = this@ctrluis.component.AbstractDialog;                        
            this.ToolData = ToolData;
            this.Name = 'InspectDialog';
            this.Title = getString(message('Control:mrtool:InspectDialogTitle'));           
        end
        function updateUI(this)
            hText = evalc('display(this.ToolData.getTargetSystem)');
            hText = strrep(hText,'ans =',[this.ToolData.getTargetName ' =']);
            TextPane = this.Widgets.TextPane;
            TextPane.setText(hText);
            TextPane.setCaretPosition(0);
        end
    end
    methods (Access=protected)
        function MainPanel = createPanel(this)            
            TextPane = javaObjectEDT('com.mathworks.mwswing.MJTextPane');
            TextPane.setName('InpsectTextPanel'); % Added for testing             
            TextPane.setFont(java.awt.Font('Monospaced',java.awt.Font.PLAIN,12));
            TextPane.setEditable(false);            
            javaMethodEDT('setWrapping', TextPane, false);                                                       
            
            ScrollPane = javaObjectEDT('com.mathworks.mwswing.MJScrollPane', TextPane);
            ScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            ScrollPane.setVerticalScrollBarPolicy(com.mathworks.mwswing.MJScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
            ScaledSize = com.mathworks.util.ResolutionUtils.scaleSize(60);
            Size = javaObjectEDT('java.awt.Dimension',300,200);
            ScrollPane.setPreferredSize(Size);            
            
            MainPanel = toolpack.component.TSPanel('p','p');
            MainPanel.Peer.setBackground(java.awt.Color.WHITE);
            MainPanel.Peer.setLayout(java.awt.BorderLayout());
            MainPanel.Peer.add(ScrollPane, java.awt.BorderLayout.CENTER);

            % add to widgets
            this.Widgets = struct('TextPane',TextPane,...
                   'ScrollPane',ScrollPane,...
                   'Panel',MainPanel);                
        end
        function connectUI(this)
            L1 = addlistener(this.Dialog, 'ObjectBeingDestroyed', @(x,y) delete(this));
            registerUIListeners(this,L1);
            L2 = addlistener(this.Dialog,'CloseEvent', @(x,y) delete(this)); 
            registerUIListeners(this,L2);         
        end
        function cleanupUI(this)
            this.Widgets = [];
        end
    end
end

