/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2015 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.gui;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.KeyStroke;

import org.jtrfp.trcl.core.TR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jogamp.newt.event.KeyEvent;

@Component
public class SatelliteViewToggle {
    private static final String satKey = "SATELLITE_KEY";

    @Autowired
    public SatelliteViewToggle(TR tr){
	final MenuSystem menuSystem = tr.getMenuSystem();
	final JCheckBoxMenuItem view_sat = menuSystem.getView_sat();
	Action satelliteKeyAction = new AbstractAction("SATELLITE_VIEW_KEY"){
	    private static final long serialVersionUID = -6843605846847411702L;
	    @Override
	    public void actionPerformed(ActionEvent l) {
		if(view_sat.isEnabled())
		    view_sat.doClick();
	    }};
	    view_sat.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0), satKey);
	    view_sat.getActionMap().put(satKey, satelliteKeyAction);
    }//end constructor
}//end SatelliteViewToggle

@@ -613,32 +613,35 @@
 ava.
-awt.event.Action
+beans.PropertyChange
 Event;%0A
-%0A
 impo
@@ -651,58 +651,39 @@
 java
-x.swing.AbstractAction;%0Aimport javax.swing.Action;
+.beans.PropertyChangeListener;%0A
 %0Aimp
@@ -740,50 +740,158 @@
 ing.
-JComponent;%0Aimport javax.swing.KeyStroke;%0A
+SwingUtilities;%0A%0Aimport org.jtrfp.trcl.core.ControllerInput;%0Aimport org.jtrfp.trcl.core.ControllerInputs;%0Aimport org.jtrfp.trcl.core.ControllerMapper;
 %0Aimp
@@ -1035,48 +1035,8 @@
 t;%0A%0A
-import com.jogamp.newt.event.KeyEvent;%0A%0A
 @Com
@@ -1078,30 +1078,29 @@
 ggle %7B%0A    p
-rivate
+ublic
  static fina
@@ -1112,88 +1112,394 @@
 ing 
-satKey = %22SATELLITE_KEY%22;%0A%0A    @Autowired%0A    public SatelliteViewToggle(TR tr)%7B
+SATELLITE_TOGGLE = %22Sat View%22;%0A    private final ControllerInput satelliteToggleInput;%0A    private final JCheckBoxMenuItem view_sat;%0A%0A    @Autowired%0A    public SatelliteViewToggle(TR tr, ControllerMapper mapper, ControllerInputs inputs)%7B%0A%09satelliteToggleInput = inputs.getControllerInput(SATELLITE_TOGGLE);%0A%09satelliteToggleInput.addPropertyChangeListener(new SatelliteToggleListener());
 %0A%09fi
@@ -1551,32 +1551,8 @@
 );%0A%09
-final JCheckBoxMenuItem 
 view
@@ -1588,157 +1588,114 @@
 ();%0A
-%09Action satelliteKeyAction = new AbstractAction(%22SATELLITE_VIEW_KEY%22)%7B%0A%09    private static final long serialVersionUID = -6843605846847411702L;%0A%09    
+    %7D//end constructor%0A    %0A    private class SatelliteToggleListener implements PropertyChangeListener%7B%0A%09
 @Ove
@@ -1701,20 +1701,16 @@
 erride%0A%09
-    
 public v
@@ -1717,108 +1717,147 @@
 oid 
-actionPerformed(Action
+propertyChange(final PropertyChange
 Event 
-l
+evt
 ) %7B%0A%09
-%09if(view_sat.isE
+    SwingUtilities.invokeLater(new Run
 nable
-d
 ()
-)%0A%09%09    view_sat.doClick();%0A%09    %7D%7D;%0A
+%7B%0A%09%09@Override%0A%09%09public void run() %7B%0A%09
 %09    
+if(
 view
@@ -1865,194 +1865,150 @@
 sat.
-getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0), satKey);%0A%09    view_sat.getActionMap().put(satKey, satelliteKeyAction);%0A    %7D//end constructo
+isEnabled() && ((Double)evt.getNewValue())%3E.9)%0A%09%09%09    view_sat.doClick();%0A%09%09%7D%7D);%0A%09%7D//end propertyChange(...)%0A    %7D//end SatelliteToggleListene
 r%0A%7D/

Add support for satellite view configurable for gamepad.