Search in sources :

Example 1 with DependencyInfo

use of com.vaadin.flow.component.internal.ComponentMetaData.DependencyInfo in project flow by vaadin.

the class UIInternals method addExternalDependencies.

private void addExternalDependencies(DependencyInfo dependency) {
    Page page = ui.getPage();
    dependency.getJavaScripts().stream().filter(js -> UrlUtil.isExternal(js.value())).forEach(js -> page.addJavaScript(js.value(), js.loadMode()));
    dependency.getJsModules().stream().filter(js -> UrlUtil.isExternal(js.value())).forEach(js -> page.addJsModule(js.value()));
}
Also used : CssImportData(com.vaadin.flow.server.frontend.FallbackChunk.CssImportData) HeartbeatEvent(com.vaadin.flow.component.HeartbeatEvent) Component(com.vaadin.flow.component.Component) JavaScript(com.vaadin.flow.component.dependency.JavaScript) LoadingIndicatorConfigurationMap(com.vaadin.flow.internal.nodefeature.LoadingIndicatorConfigurationMap) CssImport(com.vaadin.flow.component.dependency.CssImport) ComponentUtil(com.vaadin.flow.component.ComponentUtil) Registration(com.vaadin.flow.shared.Registration) LoggerFactory(org.slf4j.LoggerFactory) BeforeEnterHandler(com.vaadin.flow.router.internal.BeforeEnterHandler) Router(com.vaadin.flow.router.Router) ExtendedClientDetails(com.vaadin.flow.component.page.ExtendedClientDetails) PushConfigurationMap(com.vaadin.flow.internal.nodefeature.PushConfigurationMap) AfterNavigationListener(com.vaadin.flow.router.AfterNavigationListener) PushMode(com.vaadin.flow.shared.communication.PushMode) AfterNavigationHandler(com.vaadin.flow.router.internal.AfterNavigationHandler) Map(java.util.Map) PushConnection(com.vaadin.flow.server.communication.PushConnection) ContinueNavigationAction(com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction) UI(com.vaadin.flow.component.UI) ConstantPool(com.vaadin.flow.internal.ConstantPool) VaadinSession(com.vaadin.flow.server.VaadinSession) IdentityHashMap(java.util.IdentityHashMap) BeforeLeaveListener(com.vaadin.flow.router.BeforeLeaveListener) BasicElementStateProvider(com.vaadin.flow.dom.impl.BasicElementStateProvider) AnnotationReader(com.vaadin.flow.internal.AnnotationReader) PushConfiguration(com.vaadin.flow.component.PushConfiguration) Set(java.util.Set) Collectors(java.util.stream.Collectors) ReconnectDialogConfigurationMap(com.vaadin.flow.internal.nodefeature.ReconnectDialogConfigurationMap) Serializable(java.io.Serializable) BeforeLeaveHandler(com.vaadin.flow.router.internal.BeforeLeaveHandler) List(java.util.List) VaadinContext(com.vaadin.flow.server.VaadinContext) Stream(java.util.stream.Stream) FallbackChunk(com.vaadin.flow.server.frontend.FallbackChunk) VaadinService(com.vaadin.flow.server.VaadinService) Optional(java.util.Optional) JsModule(com.vaadin.flow.component.dependency.JsModule) UrlUtil(com.vaadin.flow.internal.UrlUtil) HashMap(java.util.HashMap) StateTree(com.vaadin.flow.internal.StateTree) BeforeEnterListener(com.vaadin.flow.router.BeforeEnterListener) ListenerPriority(com.vaadin.flow.router.ListenerPriority) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) NodeFeature(com.vaadin.flow.internal.nodefeature.NodeFeature) ElementUtil(com.vaadin.flow.dom.ElementUtil) JsonCodec(com.vaadin.flow.internal.JsonCodec) Location(com.vaadin.flow.router.Location) HeartbeatListener(com.vaadin.flow.component.HeartbeatListener) Page(com.vaadin.flow.component.page.Page) RouterLayout(com.vaadin.flow.router.RouterLayout) Logger(org.slf4j.Logger) HasElement(com.vaadin.flow.component.HasElement) StyleSheet(com.vaadin.flow.component.dependency.StyleSheet) DependencyInfo(com.vaadin.flow.component.internal.ComponentMetaData.DependencyInfo) ArrayDeque(java.util.ArrayDeque) PollConfigurationMap(com.vaadin.flow.internal.nodefeature.PollConfigurationMap) Collections(java.util.Collections) Push(com.vaadin.flow.component.page.Push) Page(com.vaadin.flow.component.page.Page)

Example 2 with DependencyInfo

use of com.vaadin.flow.component.internal.ComponentMetaData.DependencyInfo in project flow by vaadin.

the class UIInternals method addComponentDependencies.

/**
 * Adds the dependencies defined using {@link StyleSheet} or
 * {@link JavaScript} on the given Component class.
 *
 * @param componentClass
 *            the component class to read annotations from
 */
public void addComponentDependencies(Class<? extends Component> componentClass) {
    Page page = ui.getPage();
    DependencyInfo dependencies = ComponentUtil.getDependencies(session.getService(), componentClass);
    // In npm mode, add external JavaScripts directly to the page.
    addExternalDependencies(dependencies);
    addFallbackDependencies(dependencies);
    dependencies.getStyleSheets().forEach(styleSheet -> page.addStyleSheet(styleSheet.value(), styleSheet.loadMode()));
}
Also used : Page(com.vaadin.flow.component.page.Page) DependencyInfo(com.vaadin.flow.component.internal.ComponentMetaData.DependencyInfo)

Aggregations

DependencyInfo (com.vaadin.flow.component.internal.ComponentMetaData.DependencyInfo)2 Page (com.vaadin.flow.component.page.Page)2 Component (com.vaadin.flow.component.Component)1 ComponentUtil (com.vaadin.flow.component.ComponentUtil)1 HasElement (com.vaadin.flow.component.HasElement)1 HeartbeatEvent (com.vaadin.flow.component.HeartbeatEvent)1 HeartbeatListener (com.vaadin.flow.component.HeartbeatListener)1 PushConfiguration (com.vaadin.flow.component.PushConfiguration)1 UI (com.vaadin.flow.component.UI)1 CssImport (com.vaadin.flow.component.dependency.CssImport)1 JavaScript (com.vaadin.flow.component.dependency.JavaScript)1 JsModule (com.vaadin.flow.component.dependency.JsModule)1 StyleSheet (com.vaadin.flow.component.dependency.StyleSheet)1 ExtendedClientDetails (com.vaadin.flow.component.page.ExtendedClientDetails)1 Push (com.vaadin.flow.component.page.Push)1 ElementUtil (com.vaadin.flow.dom.ElementUtil)1 BasicElementStateProvider (com.vaadin.flow.dom.impl.BasicElementStateProvider)1 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)1 AnnotationReader (com.vaadin.flow.internal.AnnotationReader)1 ConstantPool (com.vaadin.flow.internal.ConstantPool)1