Make navigation settings callback explicit
This commit is contained in:
@@ -46,11 +46,6 @@ public final class NavigationRail extends VBox {
|
|||||||
private MainWindow.NavItem selectedItem;
|
private MainWindow.NavItem selectedItem;
|
||||||
private String selectedPluginId;
|
private String selectedPluginId;
|
||||||
|
|
||||||
public NavigationRail(List<MainWindow.NavItem> items,
|
|
||||||
Consumer<MainWindow.NavItem> navigator) {
|
|
||||||
this(items, navigator, () -> { });
|
|
||||||
}
|
|
||||||
|
|
||||||
public NavigationRail(List<MainWindow.NavItem> items,
|
public NavigationRail(List<MainWindow.NavItem> items,
|
||||||
Consumer<MainWindow.NavItem> navigator,
|
Consumer<MainWindow.NavItem> navigator,
|
||||||
Runnable openSettings) {
|
Runnable openSettings) {
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ class NativeUiVisualAcceptanceFixtureContractTest {
|
|||||||
void fixtureRendersTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
void fixtureRendersTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
||||||
List<String> renderedLabels = fx(() -> {
|
List<String> renderedLabels = fx(() -> {
|
||||||
NavigationRail rail = new NavigationRail(
|
NavigationRail rail = new NavigationRail(
|
||||||
NativeUiVisualAcceptanceFixture.navigationItems(() -> { }), item -> { });
|
NativeUiVisualAcceptanceFixture.navigationItems(() -> { }), item -> { }, () -> { });
|
||||||
VBox root = new VBox(rail);
|
VBox root = new VBox(rail);
|
||||||
new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 480);
|
new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 480);
|
||||||
root.applyCss();
|
root.applyCss();
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class NavigationRailTest {
|
|||||||
AppIcon.DIFF, "文本对比", "对比文本", () -> {
|
AppIcon.DIFF, "文本对比", "对比文本", () -> {
|
||||||
}, "diff");
|
}, "diff");
|
||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC, second), item -> {
|
NavigationRail rail = new NavigationRail(List.of(API_DOC, second), item -> {
|
||||||
});
|
}, () -> { });
|
||||||
VBox root = new VBox(rail);
|
VBox root = new VBox(rail);
|
||||||
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
||||||
Theme.applyCustomCss(scene);
|
Theme.applyCustomCss(scene);
|
||||||
@@ -187,7 +187,7 @@ class NavigationRailTest {
|
|||||||
void bottomSeparatorIsExactlyOnePixelWithoutPaddingOrBackgroundBand() throws Exception {
|
void bottomSeparatorIsExactlyOnePixelWithoutPaddingOrBackgroundBand() throws Exception {
|
||||||
fx(() -> {
|
fx(() -> {
|
||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||||
});
|
}, () -> { });
|
||||||
VBox root = new VBox(rail);
|
VBox root = new VBox(rail);
|
||||||
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
Scene scene = new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 320);
|
||||||
Theme.applyCustomCss(scene);
|
Theme.applyCustomCss(scene);
|
||||||
@@ -289,7 +289,7 @@ class NavigationRailTest {
|
|||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||||
selected.set(item);
|
selected.set(item);
|
||||||
routed.incrementAndGet();
|
routed.incrementAndGet();
|
||||||
});
|
}, () -> { });
|
||||||
|
|
||||||
rail.selectPlugin("api-doc");
|
rail.selectPlugin("api-doc");
|
||||||
rail.setExpanded(false);
|
rail.setExpanded(false);
|
||||||
@@ -307,7 +307,8 @@ class NavigationRailTest {
|
|||||||
void reselectingCurrentPluginKeepsItSelectedWithoutRoutingAgain() throws Exception {
|
void reselectingCurrentPluginKeepsItSelectedWithoutRoutingAgain() throws Exception {
|
||||||
fx(() -> {
|
fx(() -> {
|
||||||
AtomicInteger routed = new AtomicInteger();
|
AtomicInteger routed = new AtomicInteger();
|
||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> routed.incrementAndGet());
|
NavigationRail rail = new NavigationRail(
|
||||||
|
List.of(API_DOC), item -> routed.incrementAndGet(), () -> { });
|
||||||
ToggleButton apiDocButton = (ToggleButton) rail.lookup("#nav-api-doc");
|
ToggleButton apiDocButton = (ToggleButton) rail.lookup("#nav-api-doc");
|
||||||
|
|
||||||
apiDocButton.fire();
|
apiDocButton.fire();
|
||||||
@@ -329,7 +330,8 @@ class NavigationRailTest {
|
|||||||
AppIcon.SCANNER, "Second", "Second item", () -> {
|
AppIcon.SCANNER, "Second", "Second item", () -> {
|
||||||
});
|
});
|
||||||
List<MainWindow.NavItem> routed = new ArrayList<>();
|
List<MainWindow.NavItem> routed = new ArrayList<>();
|
||||||
NavigationRail rail = new NavigationRail(List.of(first, second), routed::add);
|
NavigationRail rail = new NavigationRail(
|
||||||
|
List.of(first, second), routed::add, () -> { });
|
||||||
|
|
||||||
rail.setExpanded(false);
|
rail.setExpanded(false);
|
||||||
ToggleButton firstButton = (ToggleButton) rail.lookup("#nav-item-0");
|
ToggleButton firstButton = (ToggleButton) rail.lookup("#nav-item-0");
|
||||||
@@ -357,7 +359,7 @@ class NavigationRailTest {
|
|||||||
AppIcon.APP, "No ID", "No ID item", () -> {
|
AppIcon.APP, "No ID", "No ID item", () -> {
|
||||||
});
|
});
|
||||||
NavigationRail rail = new NavigationRail(List.of(withoutId, API_DOC),
|
NavigationRail rail = new NavigationRail(List.of(withoutId, API_DOC),
|
||||||
item -> routed.incrementAndGet());
|
item -> routed.incrementAndGet(), () -> { });
|
||||||
|
|
||||||
rail.selectPlugin(null);
|
rail.selectPlugin(null);
|
||||||
rail.selectPlugin("unknown-plugin");
|
rail.selectPlugin("unknown-plugin");
|
||||||
@@ -377,7 +379,8 @@ class NavigationRailTest {
|
|||||||
MainWindow.NavItem second = new MainWindow.NavItem(
|
MainWindow.NavItem second = new MainWindow.NavItem(
|
||||||
AppIcon.SCANNER, "Second", "Second item", () -> {
|
AppIcon.SCANNER, "Second", "Second item", () -> {
|
||||||
}, "second");
|
}, "second");
|
||||||
NavigationRail rail = new NavigationRail(List.of(first), item -> routed.incrementAndGet());
|
NavigationRail rail = new NavigationRail(
|
||||||
|
List.of(first), item -> routed.incrementAndGet(), () -> { });
|
||||||
ToggleButton oldButton = (ToggleButton) rail.lookup("#nav-first");
|
ToggleButton oldButton = (ToggleButton) rail.lookup("#nav-first");
|
||||||
oldButton.fire();
|
oldButton.fire();
|
||||||
|
|
||||||
@@ -508,7 +511,7 @@ class NavigationRailTest {
|
|||||||
void collapsedRailUsesExactFixedWidthAndCollapsedPseudoClass() throws Exception {
|
void collapsedRailUsesExactFixedWidthAndCollapsedPseudoClass() throws Exception {
|
||||||
fx(() -> {
|
fx(() -> {
|
||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||||
});
|
}, () -> { });
|
||||||
|
|
||||||
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getMinWidth());
|
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getMinWidth());
|
||||||
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getPrefWidth());
|
assertEquals(DesignTokens.NAV_EXPANDED_WIDTH, rail.getPrefWidth());
|
||||||
@@ -526,7 +529,7 @@ class NavigationRailTest {
|
|||||||
void collapsedItemKeepsARealTooltipWithItsVisibleLabel() throws Exception {
|
void collapsedItemKeepsARealTooltipWithItsVisibleLabel() throws Exception {
|
||||||
fx(() -> {
|
fx(() -> {
|
||||||
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
NavigationRail rail = new NavigationRail(List.of(API_DOC), item -> {
|
||||||
});
|
}, () -> { });
|
||||||
|
|
||||||
rail.setExpanded(false);
|
rail.setExpanded(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user