Skip to content

Commit

Permalink
Merge pull request #2847 from ControlSystemStudio/CSSTUDIO-2049
Browse files Browse the repository at this point in the history
Bug fix in save&restore tab management
  • Loading branch information
shroffk authored Oct 20, 2023
2 parents 2a2d08a + 20a840f commit 2b363ae
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,32 @@
import org.phoebus.applications.saveandrestore.ui.snapshot.SnapshotTab;
import org.phoebus.ui.javafx.ImageCache;

import java.util.ArrayList;
import java.util.List;

/**
* Base class for save-n-restore {@link Tab}s containing common functionality.
*/
public abstract class SaveAndRestoreTab extends Tab implements NodeChangedListener{
public abstract class SaveAndRestoreTab extends Tab implements NodeChangedListener {

public SaveAndRestoreTab(){
public SaveAndRestoreTab() {
ContextMenu contextMenu = new ContextMenu();

MenuItem closeAll = new MenuItem(org.phoebus.ui.application.Messages.DockCloseAll,
new ImageView(ImageCache.getImage(SnapshotTab.class, "/icons/remove_multiple.png")));
closeAll.setOnAction(e -> {
getTabPane().getTabs().removeAll(getTabPane().getTabs());
});
closeAll.setOnAction(e -> getTabPane().getTabs().removeAll(getTabPane().getTabs()));

MenuItem closeOthers = new MenuItem(org.phoebus.ui.application.Messages.DockCloseOthers,
new ImageView(ImageCache.getImage(SnapshotTab.class, "/icons/remove_multiple.png")));
List<Tab> tabsToClose = new ArrayList<>();
closeOthers.setOnAction(e -> {
List<Tab> tabs = getTabPane().getTabs();
Platform.runLater(() -> tabs.forEach(t -> {
tabs.forEach(t -> {
if (!t.equals(this)) {
tabs.remove(t);
tabsToClose.add(t);
}
}));
});
Platform.runLater(() -> tabsToClose.forEach(tabs::remove));
});

contextMenu.getItems().addAll(closeAll, closeOthers);
Expand Down

0 comments on commit 2b363ae

Please sign in to comment.