Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,38 @@
package org.netbeans.core.windows.view.ui;


import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
import org.netbeans.core.windows.Constants;
import org.netbeans.core.windows.actions.ActionUtils;
import org.netbeans.core.windows.actions.MaximizeWindowAction;
import org.netbeans.core.windows.view.ModeView;
import org.netbeans.core.windows.WindowManagerImpl;
import org.netbeans.core.windows.view.ui.slides.SlideOperation;
import org.netbeans.swing.tabcontrol.TabbedContainer;
import org.netbeans.swing.tabcontrol.event.TabActionEvent;
import org.openide.windows.TopComponent;
import org.openide.util.Utilities;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import java.awt.*;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.AWTEventListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.netbeans.core.windows.Constants;
import org.netbeans.core.windows.ModeImpl;
import org.netbeans.core.windows.Switches;
import org.netbeans.core.windows.WindowManagerImpl;
import org.netbeans.core.windows.actions.ActionUtils;
import org.netbeans.core.windows.actions.MaximizeWindowAction;
import org.netbeans.core.windows.view.ModeView;
import org.netbeans.core.windows.view.ui.slides.SlideBar;
import org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent;
import org.netbeans.core.windows.view.ui.slides.SlideOperation;
import org.netbeans.core.windows.view.ui.slides.SlideOperationFactory;
import org.netbeans.swing.tabcontrol.TabbedContainer;
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
import org.netbeans.swing.tabcontrol.event.TabActionEvent;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;


/** Helper class which handles <code>Tabbed</code> component inside
Expand Down Expand Up @@ -87,7 +86,7 @@ public TabbedHandler(ModeView modeView, int kind, Tabbed tbd) {
Toolkit.getDefaultToolkit().addAWTEventListener(
activationManager, AWTEvent.MOUSE_EVENT_MASK);
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("focusOwner", activationManager);
.addPropertyChangeListener("permanentFocusOwner", activationManager);
}
}
tabbed = tbd;
Expand Down Expand Up @@ -488,15 +487,27 @@ public void eventDispatched(AWTEvent e) {
*/
@Override
public void propertyChange(PropertyChangeEvent e) {
KeyboardFocusManager focusMgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
Frame mainWindowNB = WindowManagerImpl.getInstance().getMainWindow();
Window activeWindowKB = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
Window activeWindowKB = focusMgr.getActiveWindow();
TopComponent currentTC = TopComponent.getRegistry().getActivated();
// Only do something if focus to the main window and
// active TC is not in the main window. Note that focus changes
// to detached windows handled in DefaultSeparateContainer.
if(mainWindowNB == activeWindowKB
&& mainWindowNB != SwingUtilities.getRoot(currentTC)) {
handleActivation(e.getNewValue());
// Defer possible activation with invokeLater(). This allows the focus
// manager to finish focus changes. Only activate if, after settling,
// the activationTarget is still focused.
Object activationTarget = e.getNewValue();
if (activationTarget != null) {
EventQueue.invokeLater(() -> {
if (activationTarget == focusMgr.getFocusOwner()) {
// ActivationTarget is still focused; activate it.
handleActivation(activationTarget);
}
});
}
}
}

Expand Down
Loading