/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 Chuck Ritola
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.core;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Callable;

import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;

import org.jtrfp.trcl.dbg.FramebufferStateWindow;
import org.jtrfp.trcl.mem.GPUMemDump;

public class RootWindow extends JFrame {
    /**
     * 
     */
    private static final long serialVersionUID = -2412572500302248185L;
    static {GLProfile.initSingleton();}
    private final TR 			tr;
    private final GLProfile 		glProfile 	= GLProfile.get(GLProfile.GL2GL3);
    private final GLCapabilities 	capabilities 	= new GLCapabilities(glProfile);
    private final GLCanvas 		canvas 		= new GLCanvas(capabilities);
    private final FramebufferStateWindow fbsw;

    public RootWindow(TR tr) {
	this.tr = tr;
	try {
	    SwingUtilities.invokeAndWait(new Runnable() {
		@Override
		public void run() {
		    configureMenuBar();
		    // frame.setBackground(Color.black);
		    getContentPane().add(canvas);
		    setVisible(true);
		    setSize(800, 600);
		    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		}
	    });
	} catch (Exception e) {
	    e.printStackTrace();
	}//end try/catch Exception
	setTitle("Terminal Recall");
	fbsw = new FramebufferStateWindow(tr);
    }//end constructor

    private void configureMenuBar() {
	setJMenuBar(new JMenuBar());
	JMenu file = new JMenu("File"), window = new JMenu("Window");
	// And menus to menubar
	JMenuItem file_exit = new JMenuItem("Exit");
	JMenuItem debugStatesMenuItem = new JMenuItem("Debug States");
	JMenuItem frameBufferStatesMenuItem = new JMenuItem("Framebuffer States");
	JMenuItem gpuMemDump = new JMenuItem("Dump GPU Memory");
	// Menu item behaviors
	file_exit.addActionListener(new ActionListener() {
	    @Override
	    public void actionPerformed(ActionEvent arg0) {
		System.exit(1);
	    }
	});
	debugStatesMenuItem.addActionListener(new ActionListener() {
	    @Override
	    public void actionPerformed(ActionEvent ev) {
		tr.getReporter().setVisible(true);
	    };
	});
	frameBufferStatesMenuItem.addActionListener(new ActionListener(){
	    @Override
	    public void actionPerformed(ActionEvent e) {
		fbsw.setVisible(true);
	    }});
	gpuMemDump.addActionListener(new ActionListener() {
	    @Override
	    public void actionPerformed(ActionEvent ev) {
		tr.getThreadManager().submitToThreadPool(new Callable<Void>(){
		    @Override
		    public Void call() throws Exception {
			new GPUMemDump(tr);
			return null;
		    }});
	    };
	});
	final String showDebugStatesOnStartup = System
		.getProperty("org.jtrfp.trcl.showDebugStates");
	if (showDebugStatesOnStartup != null) {
	    if (showDebugStatesOnStartup.toUpperCase().contains("TRUE")) {
		tr.getReporter().setVisible(true);
	    }
	}
	file.add(file_exit);
	file.add(gpuMemDump);
	window.add(debugStatesMenuItem);
	window.add(frameBufferStatesMenuItem);
	getJMenuBar().add(file);
	getJMenuBar().add(window);
    }//end configureMenuBar()

    public GLCanvas getCanvas() {
	return canvas;
    }
}// end RootWindow

@@ -1031,16 +1031,56 @@
 Window;%0A
+import org.jtrfp.trcl.gui.ConfigWindow;%0A
 import o
@@ -1586,16 +1586,62 @@
 ow fbsw;
+%0A    private final ConfigWindow%09%09configWindow;
 %0A%0A    pu
@@ -2142,16 +2142,68 @@
 ow(tr);%0A
+%09configWindow = new ConfigWindow(tr.getTrConfig());%0A
     %7D//e
@@ -2347,16 +2347,46 @@
 Window%22)
+, gameMenu = new JMenu(%22Game%22)
 ;%0A%09// An
@@ -2446,24 +2446,126 @@
 em(%22Exit%22);%0A
+%09JMenuItem file_config = new JMenuItem(%22Configure%22);%0A%09JMenuItem game_new = new JMenuItem(%22New Game%22);%0A
 %09JMenuItem d
@@ -2774,16 +2774,180 @@
 haviors%0A
+%09file_config.addActionListener(new ActionListener()%7B%0A%09    @Override%0A%09    public void actionPerformed(ActionEvent arg0) %7B%0A%09%09configWindow.setVisible(true);%0A%09    %7D%7D);%0A
 %09file_ex
@@ -4016,16 +4016,40 @@
 _exit);%0A
+%09file.add(file_config);%0A
 %09file.ad
@@ -4137,16 +4137,41 @@
 uItem);%0A
+%09gameMenu.add(game_new);%0A
 %09getJMen

Add configuration to File->Configure in RootWindow.