< prev index next >
modules/javafx.controls/src/main/java/javafx/scene/control/skin/TabPaneSkin.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 475,502 ****
tabRegion.isClosing = true;
tabRegion.removeListeners(tab);
removeTabContent(tab);
- // remove the menu item from the popup menu
- ContextMenu popupMenu = tabHeaderArea.controlButtons.popup;
- TabMenuItem tabItem = null;
- if (popupMenu != null) {
- for (MenuItem item : popupMenu.getItems()) {
- tabItem = (TabMenuItem) item;
- if (tab == tabItem.getTab()) {
- break;
- }
- tabItem = null;
- }
- }
- if (tabItem != null) {
- tabItem.dispose();
- popupMenu.getItems().remove(tabItem);
- }
- // end of removing menu item
-
EventHandler<ActionEvent> cleanup = ae -> {
tabRegion.animationState = TabAnimationState.NONE;
tabHeaderArea.removeTab(tab);
tabHeaderArea.requestLayout();
--- 475,484 ----
*** 1846,1856 ****
// to hide it animate it back it.
if (isShowTabsMenu()) {
showControlButtons = true;
} else {
setVisible(false);
! popup.getItems().clear();
popup = null;
}
// This needs to be called when we are in the left tabPosition
// to allow for the clip offset to move properly (otherwise
--- 1828,1838 ----
// to hide it animate it back it.
if (isShowTabsMenu()) {
showControlButtons = true;
} else {
setVisible(false);
! clearPopupMenu();
popup = null;
}
// This needs to be called when we are in the left tabPosition
// to allow for the clip offset to move properly (otherwise
*** 1860,1870 ****
private void setupPopupMenu() {
if (popup == null) {
popup = new ContextMenu();
}
! popup.getItems().clear();
ToggleGroup group = new ToggleGroup();
ObservableList<RadioMenuItem> menuitems = FXCollections.<RadioMenuItem>observableArrayList();
for (final Tab tab : getSkinnable().getTabs()) {
TabMenuItem item = new TabMenuItem(tab);
item.setToggleGroup(group);
--- 1842,1852 ----
private void setupPopupMenu() {
if (popup == null) {
popup = new ContextMenu();
}
! clearPopupMenu();
ToggleGroup group = new ToggleGroup();
ObservableList<RadioMenuItem> menuitems = FXCollections.<RadioMenuItem>observableArrayList();
for (final Tab tab : getSkinnable().getTabs()) {
TabMenuItem item = new TabMenuItem(tab);
item.setToggleGroup(group);
*** 1872,1881 ****
--- 1854,1870 ----
menuitems.add(item);
}
popup.getItems().addAll(menuitems);
}
+ private void clearPopupMenu() {
+ for (MenuItem item : popup.getItems()) {
+ ((TabMenuItem) item).dispose();
+ }
+ popup.getItems().clear();
+ }
+
private void showPopupMenu() {
for (MenuItem mi: popup.getItems()) {
TabMenuItem tmi = (TabMenuItem)mi;
if (selectedTab.equals(tmi.getTab())) {
tmi.setSelected(true);
*** 1909,1919 ****
--- 1898,1910 ----
public Tab getTab() {
return tab;
}
public void dispose() {
+ textProperty().unbind();
tab.disableProperty().removeListener(weakDisableListener);
+ tab = null;
}
}
@Override
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
< prev index next >