Skip to content

Commit e922bc7

Browse files
committed
feat: plan manager tab switch controller
1 parent ea4ad04 commit e922bc7

File tree

2 files changed

+62
-24
lines changed

2 files changed

+62
-24
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.phoebus.applications.queueserver.controller;
2+
3+
import org.phoebus.applications.queueserver.view.TabSwitchEvent;
4+
import javafx.fxml.FXML;
5+
import javafx.fxml.Initializable;
6+
import javafx.scene.control.Tab;
7+
import javafx.scene.control.TabPane;
8+
9+
import java.net.URL;
10+
import java.util.ResourceBundle;
11+
12+
public class RePlanManagerController implements Initializable {
13+
14+
@FXML private TabPane tabPane;
15+
@FXML private Tab planViewerTab;
16+
@FXML private Tab planEditorTab;
17+
18+
@Override
19+
public void initialize(URL location, ResourceBundle resources) {
20+
TabSwitchEvent.getInstance().addListener(this::switchToTab);
21+
}
22+
23+
private void switchToTab(String tabName) {
24+
if (tabPane == null) return;
25+
26+
switch (tabName) {
27+
case "Plan Editor" -> tabPane.getSelectionModel().select(planEditorTab);
28+
case "Plan Viewer" -> tabPane.getSelectionModel().select(planViewerTab);
29+
}
30+
}
31+
32+
public String getCurrentTabName() {
33+
if (tabPane == null || tabPane.getSelectionModel().getSelectedItem() == null) {
34+
return null;
35+
}
36+
return tabPane.getSelectionModel().getSelectedItem().getText();
37+
}
38+
}

app/queue-server/src/main/resources/org/phoebus/applications/queueserver/view/RePlanManager.fxml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
<?import javafx.scene.control.TabPane?>
55
<?import javafx.scene.layout.AnchorPane?>
66

7-
<AnchorPane xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
8-
<children>
9-
<TabPane stylesheets="@../css/style.css" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
10-
<tabs>
11-
<Tab text="Plan Viewer">
12-
<content>
13-
<AnchorPane minHeight="0.0" minWidth="0.0">
14-
<children>
15-
<fx:include source="RePlanViewer.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
16-
</children></AnchorPane>
17-
</content>
18-
</Tab>
19-
<Tab text="Plan Editor">
20-
<content>
21-
<AnchorPane minHeight="0.0" minWidth="0.0">
22-
<children>
23-
<fx:include source="RePlanEditor.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
24-
</children></AnchorPane>
25-
</content>
26-
</Tab>
27-
</tabs>
28-
</TabPane>
29-
</children>
30-
</AnchorPane>
7+
<AnchorPane xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.phoebus.applications.queueserver.controller.RePlanManagerController">
8+
<children>
9+
<TabPane fx:id="tabPane" stylesheets="@../css/style.css" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
10+
<tabs>
11+
<Tab fx:id="planViewerTab" text="Plan Viewer">
12+
<content>
13+
<AnchorPane minHeight="0.0" minWidth="0.0">
14+
<children>
15+
<fx:include source="RePlanViewer.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
16+
</children></AnchorPane>
17+
</content>
18+
</Tab>
19+
<Tab fx:id="planEditorTab" text="Plan Editor">
20+
<content>
21+
<AnchorPane minHeight="0.0" minWidth="0.0">
22+
<children>
23+
<fx:include source="RePlanEditor.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
24+
</children></AnchorPane>
25+
</content>
26+
</Tab>
27+
</tabs>
28+
</TabPane>
29+
</children>
30+
</AnchorPane>

0 commit comments

Comments
 (0)