Popupmenu for Terminals should be invoked for target tab, not for visible tab

The NB Terminals can open multiple tabs. Before this change the popup
menu opened in the "Tab"-Area shows actions, that are invoked on the
visible tab, even when the mouse cursor hovers over another tab.

With this change, if the cursor hovers of a terminal tab, that tab
is the target for the action.
diff --git a/ide/terminal.nb/src/org/netbeans/modules/terminal/iocontainer/TerminalContainerTabbed.java b/ide/terminal.nb/src/org/netbeans/modules/terminal/iocontainer/TerminalContainerTabbed.java
index 6101d07..4fb3a05 100644
--- a/ide/terminal.nb/src/org/netbeans/modules/terminal/iocontainer/TerminalContainerTabbed.java
+++ b/ide/terminal.nb/src/org/netbeans/modules/terminal/iocontainer/TerminalContainerTabbed.java
@@ -268,8 +268,18 @@
 
 	@Override
 	protected void showPopup(MouseEvent e) {
-	    Terminal selected = (Terminal) getSelected();
-	    
+            Terminal selected = null;
+            if (e.getSource() == tabbedPane) {
+                int tabIndex = tabbedPane.indexAtLocation(e.getX(), e.getY());
+                if(tabIndex >= 0) {
+                    selected = (Terminal) tabbedPane.getComponentAt(tabIndex);
+                }
+            }
+
+            if (selected == null) {
+                selected = (Terminal) getSelected();
+            }
+
 	    Action close = ActionFactory.forID(ActionFactory.CLOSE_ACTION_ID);
 	    Action setTitle = ActionFactory.forID(ActionFactory.SET_TITLE_ACTION_ID);
 	    Action pin = ActionFactory.forID(ActionFactory.PIN_TAB_ACTION_ID);
@@ -285,7 +295,7 @@
 			null,
 			setTitle,
 			pin
-		    }, Lookups.fixed(getSelected())
+		    }, Lookups.fixed(selected)
 	    );
 	    menu.show(TerminalContainerTabbed.this, e.getX(), e.getY());
 	}