From 956db78fe713ce42192bd2dd7b6e247c70e08078 Mon Sep 17 00:00:00 2001 From: "jose.pereda" Date: Wed, 23 Oct 2024 14:26:36 +0200 Subject: [PATCH] Fix NPE in accordion --- .../inspector/InspectorPanelController.java | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java index 2594118b6..91f2c6c82 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Gluon and/or its affiliates. + * Copyright (c) 2016, 2024, Gluon and/or its affiliates. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. * All rights reserved. Use is subject to license terms. * @@ -377,25 +377,16 @@ private void expandedSectionChanged() { if (!isInspectorLoaded()) { return; } - final TitledPane tp; - - switch (getExpandedSection()) { - case NONE: - tp = null; - break; - case PROPERTIES: - tp = propertiesTitledPane; - break; - case LAYOUT: - tp = layoutTitledPane; - break; - case CODE: - tp = codeTitledPane; - break; - default: - throw new IllegalStateException("Unexpected section id " + getExpandedSection()); //NOI18N - } - + SectionId expandedSection = getExpandedSection(); + if (expandedSection == null) { + return; + } + final TitledPane tp = switch (expandedSection) { + case NONE -> null; + case PROPERTIES -> propertiesTitledPane; + case LAYOUT -> layoutTitledPane; + case CODE -> codeTitledPane; + }; accordion.setExpandedPane(tp); }