22
33import com .vaadin .flow .component .Component ;
44import com .vaadin .flow .component .HasElement ;
5+ import com .vaadin .flow .component .page .AppShellConfigurator ;
56import com .vaadin .flow .component .page .Inline .Position ;
7+ import com .vaadin .flow .server .AppShellRegistry ;
68import com .vaadin .flow .server .AppShellSettings ;
9+ import com .vaadin .flow .server .VaadinContext ;
10+ import com .vaadin .flow .server .VaadinService ;
711import com .vaadin .flow .server .VaadinSession ;
812import com .vaadin .flow .server .Version ;
913import com .vaadin .flow .server .communication .IndexHtmlResponse ;
14+ import com .vaadin .flow .theme .Theme ;
1015import lombok .Getter ;
1116import lombok .RequiredArgsConstructor ;
1217import org .jsoup .nodes .Element ;
@@ -74,6 +79,15 @@ public static boolean isFeatureInitialized() {
7479 && VaadinSession .getCurrent ().getAttribute (DynamicTheme .class ) != null ;
7580 }
7681
82+ private static void assertNotLegacyTheme () {
83+ VaadinContext context = VaadinService .getCurrent ().getContext ();
84+ Class <? extends AppShellConfigurator > appShellClass =
85+ AppShellRegistry .getInstance (context ).getShell ();
86+ if (appShellClass != null && appShellClass .getAnnotation (Theme .class ) != null ) {
87+ throw new IllegalStateException ("App shell is configured with legacy @Theme annotation" );
88+ }
89+ }
90+
7791 /**
7892 * Return the current dynamic theme.
7993 *
@@ -96,9 +110,12 @@ public static DynamicTheme getCurrent() {
96110 *
97111 * @param settings the application shell settings to be modified
98112 * @throws UnsupportedOperationException if the runtime Vaadin version is older than 25
113+ * @throws IllegalStateException if the {@link AppShellConfigurator} is configured with the legacy
114+ * {@link Theme} annotation
99115 */
100116 public void initialize (AppShellSettings settings ) {
101117 assertFeatureSupported ();
118+ assertNotLegacyTheme ();
102119
103120 DynamicTheme theme = getCurrent ();
104121 if (theme == null ) {
@@ -132,6 +149,7 @@ public void initialize(AppShellSettings settings) {
132149 */
133150 public void initialize (IndexHtmlResponse response ) {
134151 assertFeatureSupported ();
152+ assertNotLegacyTheme ();
135153
136154 DynamicTheme theme = getCurrent ();
137155 if (theme == null ) {
0 commit comments