

//
// Core Program for TETDM 
// LogData.java Version 1.00
// Copyright(C) 2015-2018 TETDM CORE MEMBER ALL RIGHTS RESERVED.
// This program is provided under the license.
//

package source;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;

import java.io.*;

public class WINDOWACTIONLOG
{
    JFrame windowFrame;
    String windowName;
    MyWindowListener    windowListener;
    MyComponentListener componentListener;
    int positionX, positionY;
    int sizeX, sizeY;
    
    WINDOWACTIONLOG(JFrame windowFrame, String windowName)
    {
        this.windowFrame = windowFrame;
        this.windowName = windowName;
        
        windowListener = new MyWindowListener();
        componentListener = new MyComponentListener();
    }
    
    public void getPosition()
    {
        positionX = windowFrame.getX();
        positionY = windowFrame.getY();
    }
    
    public void getSize()
    {
        sizeX = windowFrame.getWidth();
        sizeY = windowFrame.getHeight();
    }
    
    public void writePositionLog()
    {
        getPosition();
        ACTIONLOG.writeActionLog(windowName+"*WINDOW*XY*"+positionX+":"+positionY);
    }
    
    public void writeSizeLog()
    {
        getSize();
        ACTIONLOG.writeActionLog(windowName+"*WINDOW*SIZE*"+sizeX+":"+sizeY);
    }
    
    public class MyWindowListener extends WindowAdapter
    {
        public void windowOpened(WindowEvent e)
        {
            ACTIONLOG.writeActionLog(windowName+"*WINDOW*CREATED");
            writePositionLog();
            writeSizeLog();
        }
        
        public void windowClosed(WindowEvent e)
        {
            ACTIONLOG.writeActionLog(windowName+"*WINDOW*CLOSED*");
        }
    }
    
    public class MyComponentListener extends ComponentAdapter
    {
        public void componentMoved(ComponentEvent e)
        {
            ACTIONLOG.writeActionLog(windowName+"*WINDOW*MOVED");
            writePositionLog();
        }
        
        public void componentResized(ComponentEvent e)
        {
            ACTIONLOG.writeActionLog(windowName+"*WINDOW*RESIZED");
            writeSizeLog();
        }
    }
    


}
