Package com.poker.thread

Source Code of com.poker.thread.OpenWindowThread

package com.poker.thread;

import com.poker.analyst.AnalystResult;
import com.poker.control.PokerControl;
import com.poker.data.PokerData;
import com.poker.ui.robot.reaction.UIReaction;
import com.poker.ui.settings.rooms.events.EventType;

public class OpenWindowThread extends Thread {

    PokerData    pData;
    PokerControl pControl;
    Boolean      bAlive = true;

    public OpenWindowThread(final PokerData pData, final PokerControl pControl) {

        super();
        this.pData = pData;
        this.pControl = pControl;
        setDaemon(true);
    }

    public Boolean getbAlive() {

        return this.bAlive;
    }

    public void setbAlive(final Boolean bAlive) {

        this.bAlive = bAlive;
    }

    @Override
    public void run() {

        while (this.bAlive) {
            try {

                Thread.sleep(this.pData.getProgramSettings().getDelayOpenThreadMs() / 2);
                synchronized (this.pData.bSyncVariable) {
                    if (this.pData.getMainWnd() != null) {
                        if (this.pControl.isNewTableNeeds(this.pData)) {

                            Thread
                                    .sleep(this.pData.getProgramSettings().getDelayOpenThreadMs() / 4);
                            System.out.println("OpenWindowIsRunning.....");

                            final EventType ev = this.pControl.getMainWindowEvent(this.pData,
                                    this.pControl);
                            if (ev != null) {
                                System.out.println(ev);
                                this.pControl.activateWindow(this.pData.getMainWnd());
                                this.pControl.react(this.pData, this.pData.getMainWnd(),
                                        new AnalystResult(UIReaction.UIR_MN_CLOSE_SYSTEM_WINDOW,
                                                null));
                            }
                            this.pControl.activateWindow(this.pData.getMainWnd());
                            this.pControl.react(this.pData, this.pData.getMainWnd(),
                                    new AnalystResult(UIReaction.UIR_OPEN_WINDOW, null));
                            Thread
                                    .sleep(this.pData.getProgramSettings().getDelayOpenThreadMs() / 4);
                        }
                    }
                }

            } catch (final InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
TOP

Related Classes of com.poker.thread.OpenWindowThread

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.