From 84a6b1d91173994e28f9f2bd3add34afec925925 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 7 Oct 2024 14:52:01 +0300 Subject: [PATCH 1/3] chore!: Change line length to a more modern 120 --- eclipse/VaadinJavaConventions.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclipse/VaadinJavaConventions.xml b/eclipse/VaadinJavaConventions.xml index 7f9391169a0..6bb40294614 100644 --- a/eclipse/VaadinJavaConventions.xml +++ b/eclipse/VaadinJavaConventions.xml @@ -74,7 +74,7 @@ - + @@ -199,7 +199,7 @@ - + From eef6719c4222f8e63ca28ceedf7e182ed3f980c4 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 8 Oct 2024 09:40:35 +0300 Subject: [PATCH 2/3] mvn -Pbenchmark formatter:format --- .../client/ApplicationConfiguration.java | 53 +- .../vaadin/client/ApplicationConnection.java | 67 +- .../java/com/vaadin/client/BrowserInfo.java | 29 +- .../vaadin/client/ConnectionIndicator.java | 22 +- .../main/java/com/vaadin/client/Console.java | 42 +- .../com/vaadin/client/DefaultRegistry.java | 15 +- .../com/vaadin/client/DependencyLoader.java | 97 +- .../java/com/vaadin/client/ElementUtil.java | 10 +- .../client/ExecuteJavaScriptElementUtils.java | 70 +- .../com/vaadin/client/ExistingElementMap.java | 15 +- .../client/InitialPropertiesHandler.java | 66 +- .../main/java/com/vaadin/client/LitUtils.java | 9 +- .../java/com/vaadin/client/PolymerUtils.java | 177 +- .../main/java/com/vaadin/client/Profiler.java | 174 +- .../java/com/vaadin/client/ReactUtils.java | 9 +- .../main/java/com/vaadin/client/Registry.java | 20 +- .../com/vaadin/client/ResourceLoader.java | 211 +- .../com/vaadin/client/SystemErrorHandler.java | 81 +- .../com/vaadin/client/TrackingScheduler.java | 10 +- .../java/com/vaadin/client/UILifecycle.java | 22 +- .../java/com/vaadin/client/URIResolver.java | 29 +- .../java/com/vaadin/client/WidgetUtil.java | 93 +- .../vaadin/client/bootstrap/Bootstrapper.java | 89 +- .../client/bootstrap/JsoConfiguration.java | 44 +- .../client/bootstrap/LocationParser.java | 6 +- .../AtmospherePushConnection.java | 138 +- .../communication/ConnectionStateHandler.java | 82 +- .../DefaultConnectionStateHandler.java | 124 +- .../client/communication/Heartbeat.java | 21 +- .../LoadingIndicatorConfigurator.java | 39 +- .../client/communication/MessageHandler.java | 245 +- .../client/communication/MessageSender.java | 83 +- .../communication/PollConfigurator.java | 9 +- .../vaadin/client/communication/Poller.java | 7 +- .../communication/PushConfiguration.java | 47 +- .../client/communication/PushConnection.java | 62 +- .../communication/PushConnectionFactory.java | 3 +- .../communication/ReconnectConfiguration.java | 44 +- .../communication/RequestResponseTracker.java | 44 +- .../ResponseHandlingEndedEvent.java | 6 +- .../ResponseHandlingStartedEvent.java | 6 +- .../client/communication/ServerConnector.java | 60 +- .../client/communication/ServerRpcQueue.java | 13 +- .../client/communication/XhrConnection.java | 57 +- .../communication/XhrConnectionError.java | 12 +- .../com/vaadin/client/flow/ConstantPool.java | 9 +- .../flow/ExecuteJavaScriptProcessor.java | 52 +- .../com/vaadin/client/flow/StateNode.java | 65 +- .../com/vaadin/client/flow/StateTree.java | 168 +- .../client/flow/TreeChangeProcessor.java | 28 +- .../vaadin/client/flow/binding/Binder.java | 27 +- .../client/flow/binding/BinderContext.java | 25 +- .../client/flow/binding/BindingStrategy.java | 17 +- .../vaadin/client/flow/binding/Debouncer.java | 99 +- .../binding/ServerEventHandlerBinder.java | 33 +- .../flow/binding/ServerEventObject.java | 91 +- .../binding/SimpleElementBindingStrategy.java | 596 ++--- .../flow/binding/TextBindingStrategy.java | 13 +- .../client/flow/collection/JsArray.java | 30 +- .../client/flow/collection/JsCollections.java | 9 +- .../vaadin/client/flow/collection/JsMap.java | 20 +- .../vaadin/client/flow/collection/JsSet.java | 7 +- .../client/flow/collection/JsWeakMap.java | 20 +- .../flow/collection/jre/JreJsArray.java | 15 +- .../flow/collection/jre/JreJsWeakMap.java | 16 +- .../com/vaadin/client/flow/dom/DomApi.java | 14 +- .../vaadin/client/flow/dom/DomApiImpl.java | 3 +- .../vaadin/client/flow/dom/DomElement.java | 47 +- .../com/vaadin/client/flow/dom/DomNode.java | 48 +- .../client/flow/dom/PolymerDomApiImpl.java | 21 +- .../flow/model/UpdatableModelProperties.java | 11 +- .../flow/nodefeature/ListSpliceEvent.java | 11 +- .../client/flow/nodefeature/MapProperty.java | 85 +- .../nodefeature/MapPropertyChangeEvent.java | 3 +- .../client/flow/nodefeature/NodeFeature.java | 11 +- .../client/flow/nodefeature/NodeList.java | 45 +- .../client/flow/nodefeature/NodeMap.java | 35 +- .../client/flow/reactive/Computation.java | 39 +- .../vaadin/client/flow/reactive/Reactive.java | 72 +- .../flow/reactive/ReactiveEventRouter.java | 26 +- .../client/flow/reactive/ReactiveValue.java | 16 +- .../client/flow/util/ClientJsonCodec.java | 49 +- .../com/vaadin/client/flow/util/JsObject.java | 9 +- .../client/flow/util/NativeFunction.java | 14 +- .../bindery/event/shared/SimpleEventBus.java | 47 +- .../client/gwt/elemental/js/util/Xhr.java | 62 +- .../flow/linker/ClientEngineLinker.java | 116 +- .../java/com/vaadin/client/AssertionTest.java | 3 +- .../test/java/com/vaadin/client/CodeTest.java | 20 +- .../vaadin/client/DependencyLoaderTest.java | 129 +- .../client/DomApiAbstractionUsageTest.java | 61 +- .../client/InitialPropertiesHandlerTest.java | 21 +- .../client/bootstrap/LocationParserTest.java | 12 +- .../communication/PollConfiguratorTest.java | 3 +- .../ReconnectConfigurationTest.java | 16 +- .../ServerMessageHandlerTest.java | 3 +- .../client/flow/ClientEngineSizeIT.java | 12 +- .../flow/ExecuteJavaScriptProcessorTest.java | 57 +- .../com/vaadin/client/flow/StateTreeTest.java | 24 +- .../client/flow/TreeChangeProcessorTest.java | 67 +- .../client/flow/collection/JreArrayTest.java | 3 +- .../flow/nodefeature/MapPropertyTest.java | 51 +- .../client/flow/nodefeature/NodeListTest.java | 15 +- .../client/flow/nodefeature/NodeMapTest.java | 11 +- .../client/flow/reactive/ComputationTest.java | 51 +- .../client/flow/reactive/ReactiveTest.java | 32 +- .../reactive/TestReactiveEventRouter.java | 10 +- .../client/flow/util/ClientJsonCodecTest.java | 33 +- .../AbstractBeanPropertyDefinition.java | 22 +- .../flow/data/binder/BeanPropertySet.java | 201 +- .../data/binder/BeanValidationBinder.java | 82 +- .../com/vaadin/flow/data/binder/Binder.java | 2030 ++++++-------- .../binder/BinderValidationErrorHandler.java | 14 +- .../data/binder/BinderValidationStatus.java | 79 +- .../binder/BinderValidationStatusHandler.java | 13 +- .../flow/data/binder/BindingException.java | 26 +- .../data/binder/BindingExceptionHandler.java | 26 +- .../data/binder/BindingValidationStatus.java | 63 +- .../BindingValidationStatusHandler.java | 8 +- .../DefaultBinderValidationErrorHandler.java | 34 +- .../DefaultBindingExceptionHandler.java | 32 +- .../data/binder/ErrorMessageProvider.java | 6 +- .../flow/data/binder/HasDataProvider.java | 9 +- .../binder/HasFilterableDataProvider.java | 21 +- .../flow/data/binder/HasItemComponents.java | 17 +- .../com/vaadin/flow/data/binder/HasItems.java | 18 +- .../data/binder/HasItemsAndComponents.java | 14 +- .../vaadin/flow/data/binder/HasValidator.java | 50 +- .../flow/data/binder/PropertyDefinition.java | 22 +- .../data/binder/PropertyFilterDefinition.java | 12 +- .../vaadin/flow/data/binder/PropertyId.java | 15 +- .../vaadin/flow/data/binder/PropertySet.java | 10 +- .../flow/data/binder/ReadOnlyHasValue.java | 27 +- .../binder/RequiredFieldConfigurator.java | 55 +- .../binder/RequiredFieldConfiguratorUtil.java | 31 +- .../com/vaadin/flow/data/binder/Result.java | 53 +- .../com/vaadin/flow/data/binder/Setter.java | 3 +- .../vaadin/flow/data/binder/SimpleResult.java | 23 +- .../flow/data/binder/StatusChangeEvent.java | 11 +- .../flow/data/binder/ValidationException.java | 26 +- .../flow/data/binder/ValidationResult.java | 58 +- .../data/binder/ValidationResultWrap.java | 15 +- .../binder/ValidationStatusChangeEvent.java | 6 +- .../ValidationStatusChangeListener.java | 29 +- .../vaadin/flow/data/binder/Validator.java | 74 +- .../vaadin/flow/data/binder/ValueContext.java | 42 +- .../AbstractStringToNumberConverter.java | 40 +- .../BigDecimalToDoubleConverter.java | 9 +- .../converter/BigDecimalToFloatConverter.java | 6 +- .../BigDecimalToIntegerConverter.java | 12 +- .../vaadin/flow/data/converter/Converter.java | 40 +- .../flow/data/converter/ConverterFactory.java | 17 +- .../converter/DateToSqlDateConverter.java | 14 +- .../converter/DefaultConverterFactory.java | 104 +- .../DoubleToBigDecimalConverter.java | 9 +- .../converter/FloatToBigDecimalConverter.java | 6 +- .../IntegerToBigDecimalConverter.java | 12 +- .../LocalDateTimeToDateConverter.java | 18 +- .../LocalDateTimeToInstantConverter.java | 15 +- .../converter/LocalDateToDateConverter.java | 9 +- .../StringToBigDecimalConverter.java | 42 +- .../StringToBigIntegerConverter.java | 39 +- .../converter/StringToBooleanConverter.java | 31 +- .../data/converter/StringToDateConverter.java | 13 +- .../converter/StringToDoubleConverter.java | 30 +- .../converter/StringToFloatConverter.java | 30 +- .../converter/StringToIntegerConverter.java | 33 +- .../data/converter/StringToLongConverter.java | 33 +- .../data/converter/StringToUuidConverter.java | 9 +- .../com/vaadin/flow/data/event/SortEvent.java | 21 +- .../provider/AbstractBackEndDataProvider.java | 24 +- .../AbstractComponentDataGenerator.java | 36 +- .../data/provider/AbstractDataProvider.java | 36 +- .../flow/data/provider/AbstractDataView.java | 98 +- .../data/provider/AbstractLazyDataView.java | 66 +- .../data/provider/AbstractListDataView.java | 130 +- .../flow/data/provider/ArrayUpdater.java | 3 +- .../data/provider/BackEndDataProvider.java | 27 +- .../flow/data/provider/BeanDataGenerator.java | 18 +- .../data/provider/CallbackDataProvider.java | 64 +- .../data/provider/CompositeDataGenerator.java | 15 +- .../ConfigurableFilterDataProvider.java | 9 +- ...ConfigurableFilterDataProviderWrapper.java | 33 +- .../flow/data/provider/DataChangeEvent.java | 33 +- .../flow/data/provider/DataCommunicator.java | 537 ++-- .../flow/data/provider/DataGenerator.java | 22 +- .../flow/data/provider/DataKeyMapper.java | 23 +- .../flow/data/provider/DataProvider.java | 169 +- .../data/provider/DataProviderListener.java | 10 +- .../data/provider/DataProviderWrapper.java | 22 +- .../vaadin/flow/data/provider/DataView.java | 71 +- .../flow/data/provider/DataViewUtils.java | 73 +- .../flow/data/provider/FilterUtils.java | 26 +- .../flow/data/provider/HasDataGenerators.java | 6 +- .../flow/data/provider/HasDataView.java | 25 +- .../flow/data/provider/HasLazyDataView.java | 81 +- .../flow/data/provider/HasListDataView.java | 26 +- .../IdentifierProviderChangeEvent.java | 12 +- .../data/provider/InMemoryDataProvider.java | 288 +- .../provider/InMemoryDataProviderHelpers.java | 73 +- .../data/provider/ItemCountChangeEvent.java | 33 +- .../provider/ItemCountChangeListener.java | 12 +- .../flow/data/provider/ItemIndexProvider.java | 29 +- .../vaadin/flow/data/provider/KeyMapper.java | 19 +- .../flow/data/provider/LazyDataView.java | 66 +- .../flow/data/provider/ListDataProvider.java | 15 +- .../flow/data/provider/ListDataView.java | 176 +- .../com/vaadin/flow/data/provider/Query.java | 77 +- .../flow/data/provider/QuerySortOrder.java | 6 +- .../data/provider/QuerySortOrderBuilder.java | 11 +- .../vaadin/flow/data/provider/QueryTrace.java | 7 +- .../vaadin/flow/data/provider/SortOrder.java | 6 +- .../flow/data/provider/SortOrderBuilder.java | 11 +- ...stractBackEndHierarchicalDataProvider.java | 31 +- .../AbstractHierarchicalDataProvider.java | 16 +- .../BackEndHierarchicalDataProvider.java | 3 +- .../HasHierarchicalDataProvider.java | 88 +- .../hierarchy/HierarchicalArrayUpdater.java | 20 +- .../HierarchicalCommunicationController.java | 110 +- ...rchicalConfigurableFilterDataProvider.java | 6 +- .../HierarchicalDataCommunicator.java | 208 +- .../hierarchy/HierarchicalDataProvider.java | 37 +- .../hierarchy/HierarchicalFilterUtils.java | 50 +- .../provider/hierarchy/HierarchicalQuery.java | 22 +- .../provider/hierarchy/HierarchyMapper.java | 162 +- .../data/provider/hierarchy/TreeData.java | 150 +- .../provider/hierarchy/TreeDataProvider.java | 48 +- .../flow/data/selection/MultiSelect.java | 50 +- .../data/selection/MultiSelectionEvent.java | 28 +- .../selection/MultiSelectionListener.java | 6 +- .../flow/data/selection/SelectionEvent.java | 15 +- .../data/selection/SelectionListener.java | 6 +- .../flow/data/selection/SelectionModel.java | 95 +- .../flow/data/selection/SingleSelect.java | 3 +- .../data/selection/SingleSelectionEvent.java | 14 +- .../selection/SingleSelectionListener.java | 6 +- .../data/validator/AbstractValidator.java | 18 +- .../flow/data/validator/BeanValidator.java | 66 +- .../validator/BigDecimalRangeValidator.java | 11 +- .../validator/BigIntegerRangeValidator.java | 11 +- .../data/validator/ByteRangeValidator.java | 8 +- .../data/validator/DateRangeValidator.java | 11 +- .../validator/DateTimeRangeValidator.java | 14 +- .../data/validator/DoubleRangeValidator.java | 8 +- .../flow/data/validator/EmailValidator.java | 19 +- .../data/validator/FloatRangeValidator.java | 8 +- .../data/validator/IntegerRangeValidator.java | 8 +- .../data/validator/LongRangeValidator.java | 8 +- .../flow/data/validator/RangeValidator.java | 51 +- .../flow/data/validator/RegexpValidator.java | 16 +- .../data/validator/ShortRangeValidator.java | 8 +- .../data/validator/StringLengthValidator.java | 15 +- .../flow/data/value/HasValueChangeMode.java | 36 +- .../flow/data/value/ValueChangeMode.java | 60 +- .../flow/data/binder/BeanBinderTest.java | 87 +- .../flow/data/binder/BeanPropertySetTest.java | 186 +- .../binder/BinderConverterValidatorTest.java | 175 +- .../binder/BinderCustomPropertySetTest.java | 36 +- .../data/binder/BinderInstanceFieldTest.java | 131 +- .../data/binder/BinderStatusChangeTest.java | 114 +- .../vaadin/flow/data/binder/BinderTest.java | 982 +++---- .../flow/data/binder/BinderTestBase.java | 21 +- ...derValidationStatusChangeListenerTest.java | 45 +- .../binder/BinderValidationStatusTest.java | 70 +- .../data/binder/BinderValueChangeTest.java | 34 +- ...faultBinderValidationErrorHandlerTest.java | 17 +- .../DefaultBindingExceptionHandlerTest.java | 27 +- .../vaadin/flow/data/binder/Jsr303Test.java | 19 +- .../vaadin/flow/data/binder/NotEmptyTest.java | 17 +- .../data/binder/ReadOnlyHasValueTest.java | 9 +- .../vaadin/flow/data/binder/ResultTest.java | 6 +- .../vaadin/flow/data/binder/UnbindTest.java | 15 +- .../data/binder/ValidationResultTest.java | 27 +- .../flow/data/binder/ValidatorTest.java | 22 +- .../flow/data/binder/ValueContextTest.java | 39 +- .../AbstractTestHasValueAndValidation.java | 6 +- .../binder/testcomponents/TestCheckbox.java | 3 +- .../binder/testcomponents/TestDatePicker.java | 3 +- .../TestHasValidatorDatePicker.java | 30 +- .../data/binder/testcomponents/TestLabel.java | 29 +- .../testcomponents/TestSelectComponent.java | 21 +- .../binder/testcomponents/TestTextField.java | 6 +- .../BigDecimalToDoubleConverterTest.java | 6 +- .../BigDecimalToFloatConverterTest.java | 3 +- .../BigDecimalToIntegerConverterTest.java | 6 +- .../BigDecimalToLongConverterTest.java | 3 +- .../DefaultConverterFactoryTest.java | 83 +- .../DoubleToBigDecimalConverterTest.java | 6 +- .../FloatToBigDecimalConverterTest.java | 3 +- .../converter/FloatToDoubleConverterTest.java | 29 +- .../IntegerToBigDecimalConverterTest.java | 6 +- .../IntegerToDoubleConverterTest.java | 3 +- .../LocalDateTimeToInstantConverterTest.java | 15 +- .../LongToBigDecimalConverterTest.java | 8 +- .../AbstractComponentDataGeneratorTest.java | 3 +- .../AbstractComponentDataViewTest.java | 27 +- .../provider/AbstractDataProviderTest.java | 6 +- .../data/provider/AbstractDataViewTest.java | 65 +- .../provider/AbstractLazyDataViewTest.java | 92 +- .../AbstractListDataViewListenerTest.java | 46 +- .../provider/AbstractListDataViewTest.java | 585 ++-- .../provider/BackendDataProviderTest.java | 34 +- .../provider/CompositeDataGeneratorTest.java | 15 +- ...igurableFilterDataProviderWrapperTest.java | 33 +- .../provider/CustomInMemoryDataProvider.java | 3 +- .../provider/DataCommunicatorAsyncTest.java | 30 +- .../data/provider/DataCommunicatorTest.java | 653 ++--- .../data/provider/DataProviderTestBase.java | 110 +- .../data/provider/HasLazyDataViewTest.java | 13 +- .../data/provider/ListDataProviderTest.java | 58 +- .../provider/ReplaceListDataProvider.java | 6 +- .../provider/ReplaceListDataProviderTest.java | 24 +- .../vaadin/flow/data/provider/StrBean.java | 3 +- .../HasHierarchicalDataProviderTest.java | 47 +- .../HierarchicalCommunicatorDataTest.java | 52 +- .../HierarchicalCommunicatorTest.java | 58 +- .../HierarchyMapperWithDataTest.java | 157 +- .../HierarchyMapperWithNumerousDataTest.java | 29 +- .../hierarchy/TreeDataProviderTest.java | 160 +- .../flow/data/selection/MultiSelectTest.java | 39 +- .../data/validator/BeanValidatorTest.java | 6 +- .../data/validator/EmailValidatorTest.java | 7 +- .../data/validator/NotEmptyValidator.java | 19 +- .../data/validator/RangeValidatorTest.java | 27 +- .../data/validator/RegexpValidatorTest.java | 15 +- .../validator/StringLengthValidatorTest.java | 15 +- .../data/validator/ValidatorTestBase.java | 9 +- .../flow/data/value/ValueChangeModeTest.java | 40 +- .../flow/tests/data/DataSerializableTest.java | 16 +- .../vaadin/flow/tests/data/bean/Address.java | 7 +- .../flow/tests/data/bean/FatherAndSon.java | 7 +- .../vaadin/flow/tests/data/bean/Person.java | 14 +- .../server/ClassesSerializableUtils.java | 6 +- .../flow/component/dnd/DragEndEvent.java | 42 +- .../vaadin/flow/component/dnd/DragSource.java | 234 +- .../flow/component/dnd/DragStartEvent.java | 11 +- .../vaadin/flow/component/dnd/DropEvent.java | 32 +- .../vaadin/flow/component/dnd/DropTarget.java | 91 +- .../flow/component/dnd/EffectAllowed.java | 21 +- .../flow/component/dnd/internal/DndUtil.java | 61 +- .../component/dnd/AbstractDnDUnitTest.java | 22 +- .../flow/component/dnd/DragSourceTest.java | 45 +- .../flow/component/dnd/DropTargetTest.java | 54 +- .../com/vaadin/flow/component/dnd/MockUI.java | 13 +- .../html/testbench/InputTextElement.java | 9 +- .../html/testbench/NativeButtonElement.java | 3 +- .../html/testbench/NativeDetailsElement.java | 3 +- .../html/testbench/RangeInputElement.java | 6 +- .../testbench/NativeDetailsElementIT.java | 12 +- .../html/testbench/NativeDetailsView.java | 3 +- .../component/html/testbench/SelectView.java | 9 +- .../vaadin/flow/component/html/Anchor.java | 89 +- .../flow/component/html/AnchorTarget.java | 9 +- .../component/html/AnchorTargetValue.java | 8 +- .../vaadin/flow/component/html/Article.java | 3 +- .../com/vaadin/flow/component/html/Aside.java | 3 +- .../flow/component/html/DescriptionList.java | 15 +- .../com/vaadin/flow/component/html/Div.java | 3 +- .../vaadin/flow/component/html/FieldSet.java | 16 +- .../vaadin/flow/component/html/Footer.java | 3 +- .../vaadin/flow/component/html/Header.java | 3 +- .../flow/component/html/HtmlObject.java | 29 +- .../vaadin/flow/component/html/IFrame.java | 47 +- .../com/vaadin/flow/component/html/Image.java | 14 +- .../com/vaadin/flow/component/html/Input.java | 21 +- .../com/vaadin/flow/component/html/Label.java | 113 +- .../com/vaadin/flow/component/html/Main.java | 3 +- .../flow/component/html/NativeButton.java | 7 +- .../flow/component/html/NativeDetails.java | 49 +- .../flow/component/html/NativeLabel.java | 51 +- .../flow/component/html/NativeTable.java | 29 +- .../flow/component/html/NativeTableBody.java | 3 +- .../flow/component/html/NativeTableCell.java | 20 +- .../component/html/NativeTableHeaderCell.java | 3 +- .../flow/component/html/NativeTableRow.java | 49 +- .../html/NativeTableRowContainer.java | 19 +- .../com/vaadin/flow/component/html/Nav.java | 3 +- .../flow/component/html/OrderedList.java | 13 +- .../vaadin/flow/component/html/Paragraph.java | 3 +- .../com/vaadin/flow/component/html/Param.java | 6 +- .../flow/component/html/RangeInput.java | 75 +- .../vaadin/flow/component/html/Section.java | 3 +- .../flow/component/html/UnorderedList.java | 3 +- .../component/html/AnchorTargetValueTest.java | 3 +- .../flow/component/html/AnchorTest.java | 24 +- .../flow/component/html/AssertUtils.java | 21 +- .../component/html/ComponentProperty.java | 20 +- .../flow/component/html/ComponentTest.java | 195 +- .../flow/component/html/FieldSetTest.java | 7 +- .../html/HtmlComponentSmokeTest.java | 132 +- .../flow/component/html/HtmlObjectTest.java | 12 +- .../flow/component/html/IFrameTest.java | 10 +- .../vaadin/flow/component/html/InputTest.java | 4 +- .../component/html/NativeDetailsTest.java | 9 +- .../component/html/NativeTableCellTest.java | 12 +- .../html/NativeTableRowContainerTest.java | 42 +- .../flow/component/html/NativeTableTest.java | 25 +- .../flow/component/html/OrderedListTest.java | 3 +- .../flow/component/html/RangeInputTest.java | 24 +- .../littemplate/BundleLitParser.java | 40 +- .../IllegalAttributeException.java | 3 +- .../InjectableLitElementInitializer.java | 27 +- .../component/littemplate/LitTemplate.java | 46 +- .../littemplate/LitTemplateDataAnalyzer.java | 32 +- .../littemplate/LitTemplateInitializer.java | 31 +- .../littemplate/LitTemplateParser.java | 17 +- .../internal/LitTemplateParserImpl.java | 102 +- .../littemplate/BundleLitParserTest.java | 19 +- .../InjectableLitElementInitializerTest.java | 12 +- .../LitClassesSerializableTest.java | 14 +- .../littemplate/LitTemplateTest.java | 40 +- .../internal/LitTemplateParserImplTest.java | 129 +- .../flow/server/MockVaadinServletService.java | 30 +- .../flow/plugin/maven/BuildDevBundleMojo.java | 91 +- .../flow/plugin/maven/BuildFrontendMojo.java | 132 +- .../flow/plugin/maven/CleanFrontendMojo.java | 4 +- .../flow/plugin/maven/ConvertPolymerMojo.java | 15 +- .../plugin/maven/FlowModeAbstractMojo.java | 117 +- .../plugin/maven/GenerateMavenBOMMojo.java | 58 +- .../flow/plugin/maven/GenerateNpmBOMMojo.java | 93 +- .../maven/InvocationRequestBuilder.java | 3 +- .../plugin/maven/PrepareFrontendMojo.java | 10 +- .../com/vaadin/flow/plugin/TestUtils.java | 33 +- .../plugin/maven/BuildFrontendMojoTest.java | 450 ++-- .../plugin/maven/CleanFrontendMojoTest.java | 178 +- .../maven/GenerateMavenBOMMojoTest.java | 45 +- .../plugin/maven/GenerateNpmBOMMojoTest.java | 63 +- .../maven/InvocationRequestBuilderTest.java | 6 +- .../plugin/maven/PrepareFrontendMojoTest.java | 143 +- .../TestEndpointGeneratorTaskFactory.java | 34 +- .../flow/plugin/samplecode/BarExporter.java | 3 +- .../plugin/samplecode/ExporterFactory.java | 3 +- .../flow/plugin/samplecode/FooExporter.java | 3 +- .../com/vaadin/flow/theme/CustomLumo.java | 8 +- .../flow/plugin/base/BuildFrontendUtil.java | 356 +-- .../flow/plugin/base/CleanFrontendUtil.java | 85 +- .../vaadin/flow/plugin/base/CleanOptions.java | 15 +- .../plugin/base/ConvertPolymerCommand.java | 63 +- .../flow/plugin/base/PluginAdapterBase.java | 57 +- .../flow/plugin/base/PluginAdapterBuild.java | 41 +- .../scanner/ReflectionsClassFinder.java | 41 +- .../com/vaadin/flow/utils/FlowFileUtils.java | 14 +- .../com/vaadin/flow/utils/LookupImpl.java | 6 +- .../flow/utils/ResourceProviderImpl.java | 6 +- .../plugin/base/BuildFrontendUtilTest.java | 307 +-- .../base/ConvertPolymerCommandTest.java | 136 +- .../com/vaadin/flow/plugin/base/TestUtil.java | 27 +- .../scanner/ReflectionsClassFinderTest.java | 103 +- .../polymertemplate/AbstractTemplate.java | 96 +- .../polymertemplate/BundleParser.java | 60 +- .../polymertemplate/EventHandler.java | 20 +- .../flow/component/polymertemplate/Id.java | 30 +- .../polymertemplate/IdCollector.java | 22 +- .../component/polymertemplate/IdMapper.java | 12 +- .../InjectablePolymerElementInitializer.java | 35 +- .../component/polymertemplate/JsoupUtils.java | 14 +- .../component/polymertemplate/ModelItem.java | 23 +- .../polymertemplate/NpmTemplateParser.java | 110 +- .../polymertemplate/PolymerTemplate.java | 55 +- .../polymertemplate/RepeatIndex.java | 14 +- .../polymertemplate/TemplateDataAnalyzer.java | 79 +- .../polymertemplate/TemplateInitializer.java | 92 +- .../polymertemplate/TemplateParser.java | 25 +- .../rpc/PolymerPublishedEventRpcHandler.java | 31 +- .../templatemodel/AbstractBasicModelType.java | 44 +- .../templatemodel/AllowClientUpdates.java | 38 +- .../templatemodel/BasicComplexModelType.java | 46 +- .../flow/templatemodel/BasicModelType.java | 23 +- .../flow/templatemodel/BeanModelType.java | 345 +-- .../flow/templatemodel/ClientUpdateMode.java | 11 +- .../flow/templatemodel/ComplexModelType.java | 17 +- .../templatemodel/ConvertedModelType.java | 27 +- .../com/vaadin/flow/templatemodel/Encode.java | 23 +- .../vaadin/flow/templatemodel/Exclude.java | 22 +- .../vaadin/flow/templatemodel/Include.java | 27 +- .../InvalidTemplateModelException.java | 11 +- .../flow/templatemodel/ListModelType.java | 47 +- .../flow/templatemodel/ModelDescriptor.java | 17 +- .../flow/templatemodel/ModelEncoder.java | 22 +- .../vaadin/flow/templatemodel/ModelType.java | 59 +- .../vaadin/flow/templatemodel/PathLookup.java | 22 +- .../flow/templatemodel/PropertyFilter.java | 40 +- .../templatemodel/PropertyMapBuilder.java | 112 +- .../flow/templatemodel/TemplateModel.java | 83 +- .../templatemodel/TemplateModelListProxy.java | 37 +- .../TemplateModelProxyHandler.java | 129 +- .../flow/templatemodel/TemplateModelUtil.java | 56 +- .../flow/component/AbstractTemplateTest.java | 9 +- .../vaadin/flow/component/CompositeTest.java | 12 +- .../DeprecatedIdTemplateComponentTest.java | 81 +- .../PolymerClassesSerializableTest.java | 22 +- .../flow/component/TemplateComponentTest.java | 81 +- .../polymertemplate/BundleParserTest.java | 20 +- .../polymertemplate/HasCurrentService.java | 3 +- ...jectablePolymerElementInitializerTest.java | 16 +- .../NpmTemplateParserTest.java | 160 +- .../polymertemplate/PolymerTemplateTest.java | 328 +-- .../TemplateInitializerTest.java | 45 +- .../PolymerPublishedEventRpcHandlerTest.java | 37 +- .../flow/server/MockVaadinServletService.java | 30 +- ...ishedServerEventHandlerRpcHandlerTest.java | 134 +- .../flow/templatemodel/BeanModelTypeTest.java | 171 +- .../KnownUnsupportedTypesTest.java | 19 +- .../templatemodel/ModelDescriptorTest.java | 188 +- .../templatemodel/PropertyFilterTest.java | 9 +- .../TemplateModelListProxyTest.java | 13 +- .../TemplateModelProxyHandlerTest.java | 38 +- .../flow/templatemodel/TemplateModelTest.java | 343 +-- .../TemplateModelWithEncodersTest.java | 93 +- .../flow/polymer2lit/FrontendConverter.java | 8 +- .../flow/polymer2lit/ServerConverter.java | 56 +- .../polymer2lit/FrontendConverterTest.java | 119 +- .../flow/polymer2lit/ServerConverterTest.java | 24 +- .../react/ReactAdapterComponent.java | 68 +- .../component/react/ReactRouterOutlet.java | 3 +- .../java/com/vaadin/experimental/Feature.java | 7 +- .../com/vaadin/experimental/FeatureFlags.java | 151 +- .../component/AbstractCompositeField.java | 71 +- .../vaadin/flow/component/AbstractField.java | 121 +- .../AbstractSinglePropertyField.java | 206 +- .../vaadin/flow/component/AttachEvent.java | 9 +- .../vaadin/flow/component/AttachNotifier.java | 12 +- .../vaadin/flow/component/BlurNotifier.java | 22 +- .../com/vaadin/flow/component/ClickEvent.java | 70 +- .../vaadin/flow/component/ClickNotifier.java | 98 +- .../vaadin/flow/component/ClientCallable.java | 10 +- .../com/vaadin/flow/component/Component.java | 321 +-- .../vaadin/flow/component/ComponentEvent.java | 18 +- .../flow/component/ComponentEventBus.java | 260 +- .../flow/component/ComponentEventBusUtil.java | 69 +- .../component/ComponentEventListener.java | 3 +- .../vaadin/flow/component/ComponentUtil.java | 296 +- .../com/vaadin/flow/component/Composite.java | 70 +- .../flow/component/CompositionEndEvent.java | 14 +- .../flow/component/CompositionNotifier.java | 24 +- .../flow/component/CompositionStartEvent.java | 14 +- .../component/CompositionUpdateEvent.java | 14 +- .../flow/component/DebounceSettings.java | 4 +- .../vaadin/flow/component/DetachEvent.java | 3 +- .../vaadin/flow/component/DetachNotifier.java | 12 +- .../com/vaadin/flow/component/Direction.java | 3 +- .../com/vaadin/flow/component/DomEvent.java | 33 +- .../com/vaadin/flow/component/EventData.java | 23 +- .../vaadin/flow/component/FocusNotifier.java | 22 +- .../com/vaadin/flow/component/Focusable.java | 111 +- .../vaadin/flow/component/HasAriaLabel.java | 79 +- .../vaadin/flow/component/HasComponents.java | 75 +- .../com/vaadin/flow/component/HasEnabled.java | 60 +- .../com/vaadin/flow/component/HasHelper.java | 41 +- .../com/vaadin/flow/component/HasLabel.java | 14 +- .../flow/component/HasOrderedComponents.java | 45 +- .../vaadin/flow/component/HasPlaceholder.java | 20 +- .../com/vaadin/flow/component/HasSize.java | 132 +- .../com/vaadin/flow/component/HasStyle.java | 62 +- .../com/vaadin/flow/component/HasText.java | 73 +- .../com/vaadin/flow/component/HasTheme.java | 35 +- .../vaadin/flow/component/HasValidation.java | 39 +- .../com/vaadin/flow/component/HasValue.java | 91 +- .../flow/component/HasValueAndElement.java | 3 +- .../java/com/vaadin/flow/component/Html.java | 71 +- .../vaadin/flow/component/HtmlComponent.java | 17 +- .../vaadin/flow/component/HtmlContainer.java | 23 +- .../com/vaadin/flow/component/InputEvent.java | 11 +- .../vaadin/flow/component/InputNotifier.java | 15 +- .../flow/component/ItemLabelGenerator.java | 3 +- .../flow/component/JsonSerializable.java | 3 +- .../java/com/vaadin/flow/component/Key.java | 602 ++--- .../vaadin/flow/component/KeyDownEvent.java | 41 +- .../flow/component/KeyEventListener.java | 17 +- .../vaadin/flow/component/KeyLocation.java | 9 +- .../vaadin/flow/component/KeyModifier.java | 3 +- .../vaadin/flow/component/KeyNotifier.java | 87 +- .../vaadin/flow/component/KeyPressEvent.java | 41 +- .../com/vaadin/flow/component/KeyUpEvent.java | 41 +- .../vaadin/flow/component/NotSupported.java | 7 +- .../com/vaadin/flow/component/PollEvent.java | 10 +- .../vaadin/flow/component/PollNotifier.java | 20 +- .../flow/component/PropertyDescriptor.java | 22 +- .../flow/component/PropertyDescriptors.java | 132 +- .../flow/component/PushConfiguration.java | 72 +- .../ReconnectDialogConfiguration.java | 32 +- .../vaadin/flow/component/ShortcutEvent.java | 23 +- .../flow/component/ShortcutRegistration.java | 305 +-- .../com/vaadin/flow/component/Shortcuts.java | 116 +- .../java/com/vaadin/flow/component/Svg.java | 30 +- .../vaadin/flow/component/Synchronize.java | 27 +- .../java/com/vaadin/flow/component/Tag.java | 3 +- .../java/com/vaadin/flow/component/Text.java | 65 +- .../java/com/vaadin/flow/component/UI.java | 1077 +++----- .../java/com/vaadin/flow/component/Unit.java | 14 +- .../flow/component/WebComponentExporter.java | 250 +- .../WebComponentExporterFactory.java | 75 +- .../flow/component/dependency/CssImport.java | 65 +- .../flow/component/dependency/JavaScript.java | 78 +- .../flow/component/dependency/JsModule.java | 54 +- .../flow/component/dependency/NpmPackage.java | 34 +- .../flow/component/dependency/StyleSheet.java | 30 +- .../flow/component/dependency/Uses.java | 17 +- .../internal/AbstractAttachDetachEvent.java | 3 +- .../internal/AbstractFieldSupport.java | 42 +- .../component/internal/ComponentMetaData.java | 73 +- .../component/internal/ComponentTracker.java | 102 +- .../component/internal/CompositionEvent.java | 14 +- .../DeadlockDetectingCompletableFuture.java | 34 +- .../component/internal/DependencyList.java | 29 +- .../internal/DependencyTreeCache.java | 64 +- .../component/internal/EventDataCache.java | 31 +- .../JavaScriptNavigationStateRenderer.java | 27 +- .../component/internal/KeyboardEvent.java | 44 +- .../internal/PendingJavaScriptInvocation.java | 43 +- .../component/internal/UIInternalUpdater.java | 6 +- .../flow/component/internal/UIInternals.java | 453 ++-- .../component/page/AppShellConfigurator.java | 29 +- .../vaadin/flow/component/page/BodySize.java | 8 +- .../page/BrowserWindowResizeListener.java | 3 +- .../component/page/ExtendedClientDetails.java | 123 +- .../vaadin/flow/component/page/History.java | 214 +- .../vaadin/flow/component/page/Inline.java | 3 +- .../page/LoadingIndicatorConfiguration.java | 36 +- .../com/vaadin/flow/component/page/Meta.java | 3 +- .../com/vaadin/flow/component/page/Page.java | 315 +-- .../page/PendingJavaScriptResult.java | 153 +- .../com/vaadin/flow/component/page/Push.java | 15 +- .../vaadin/flow/component/page/Viewport.java | 18 +- .../flow/component/page/WebStorage.java | 115 +- .../vaadin/flow/component/template/Id.java | 33 +- .../AbstractInjectableElementInitializer.java | 19 +- ...eprecatedPolymerPublishedEventHandler.java | 15 +- .../internal/DeprecatedPolymerTemplate.java | 6 +- .../ElementInitializationStrategy.java | 6 +- .../template/internal/IdCollector.java | 56 +- .../component/template/internal/IdMapper.java | 69 +- .../internal/InjectableFieldConsumer.java | 4 +- .../template/internal/ParserData.java | 3 +- .../component/webcomponent/EventOptions.java | 31 +- .../webcomponent/PropertyConfiguration.java | 34 +- .../component/webcomponent/WebComponent.java | 133 +- .../WebComponentConfiguration.java | 40 +- .../webcomponent/WebComponentUI.java | 150 +- .../webcomponent/WebComponentWrapper.java | 73 +- .../flow/di/AbstractLookupInitializer.java | 71 +- .../vaadin/flow/di/DefaultInstantiator.java | 51 +- .../java/com/vaadin/flow/di/Instantiator.java | 79 +- .../vaadin/flow/di/InstantiatorFactory.java | 4 +- .../main/java/com/vaadin/flow/di/Lookup.java | 92 +- .../com/vaadin/flow/di/LookupInitializer.java | 110 +- .../flow/di/OneTimeInitializerPredicate.java | 32 +- .../com/vaadin/flow/di/ResourceProvider.java | 29 +- .../vaadin/flow/dom/ChildElementConsumer.java | 28 +- .../java/com/vaadin/flow/dom/ClassList.java | 3 +- .../com/vaadin/flow/dom/DebouncePhase.java | 48 +- .../vaadin/flow/dom/DisabledUpdateMode.java | 15 +- .../java/com/vaadin/flow/dom/DomEvent.java | 62 +- .../flow/dom/DomListenerRegistration.java | 268 +- .../java/com/vaadin/flow/dom/Element.java | 682 ++--- .../vaadin/flow/dom/ElementAttachEvent.java | 3 +- .../flow/dom/ElementAttachListener.java | 3 +- .../vaadin/flow/dom/ElementDetachEvent.java | 3 +- .../flow/dom/ElementDetachListener.java | 3 +- .../com/vaadin/flow/dom/ElementFactory.java | 11 +- .../vaadin/flow/dom/ElementStateProvider.java | 59 +- .../java/com/vaadin/flow/dom/ElementUtil.java | 112 +- .../main/java/com/vaadin/flow/dom/Node.java | 192 +- .../java/com/vaadin/flow/dom/NodeVisitor.java | 21 +- .../vaadin/flow/dom/PropertyChangeEvent.java | 16 +- .../flow/dom/PropertyChangeListener.java | 3 +- .../java/com/vaadin/flow/dom/ShadowRoot.java | 3 +- .../main/java/com/vaadin/flow/dom/Style.java | 227 +- .../java/com/vaadin/flow/dom/StyleUtil.java | 12 +- .../java/com/vaadin/flow/dom/ThemeList.java | 3 +- .../dom/impl/AbstractNodeStateProvider.java | 68 +- .../AbstractTextElementStateProvider.java | 26 +- .../dom/impl/BasicElementStateProvider.java | 107 +- .../flow/dom/impl/BasicElementStyle.java | 9 +- .../impl/BasicTextElementStateProvider.java | 11 +- .../flow/dom/impl/ClassAttributeHandler.java | 3 +- .../vaadin/flow/dom/impl/CustomAttribute.java | 26 +- .../flow/dom/impl/ImmutableClassList.java | 3 +- .../dom/impl/ShadowRootStateProvider.java | 24 +- .../flow/dom/impl/StyleAttributeHandler.java | 27 +- .../vaadin/flow/dom/impl/ThemeListImpl.java | 15 +- .../flow/function/ContentTypeResolver.java | 6 +- .../function/DeploymentConfiguration.java | 190 +- .../flow/function/SerializableBiConsumer.java | 3 +- .../flow/function/SerializableBiFunction.java | 3 +- .../function/SerializableBiPredicate.java | 3 +- .../flow/function/SerializableComparator.java | 13 +- .../flow/function/SerializableFunction.java | 3 +- ...dinApplicationInitializationBootstrap.java | 12 +- .../vaadin/flow/function/ValueProvider.java | 8 +- .../com/vaadin/flow/hotswap/Hotswapper.java | 228 +- .../vaadin/flow/hotswap/VaadinHotswapper.java | 54 +- .../vaadin/flow/i18n/DefaultI18NProvider.java | 29 +- .../com/vaadin/flow/i18n/I18NProvider.java | 25 +- .../java/com/vaadin/flow/i18n/I18NUtil.java | 57 +- .../flow/i18n/LocaleChangeObserver.java | 4 +- .../i18n/TranslationFileRequestHandler.java | 93 +- .../flow/internal/AnnotationReader.java | 101 +- .../ApplicationClassLoaderAccess.java | 6 +- .../com/vaadin/flow/internal/BeanUtil.java | 118 +- .../flow/internal/BootstrapHandlerHelper.java | 60 +- .../flow/internal/BrowserLiveReload.java | 16 +- .../internal/BrowserLiveReloadAccess.java | 12 +- .../internal/BrowserLiveReloadAccessor.java | 28 +- .../com/vaadin/flow/internal/CaseUtil.java | 20 +- .../vaadin/flow/internal/ConstantPool.java | 17 +- .../vaadin/flow/internal/ConstantPoolKey.java | 33 +- .../vaadin/flow/internal/CurrentInstance.java | 97 +- .../internal/CustomElementNameValidator.java | 23 +- .../vaadin/flow/internal/DevModeHandler.java | 6 +- .../flow/internal/DevModeHandlerManager.java | 21 +- .../com/vaadin/flow/internal/EncodeUtil.java | 4 +- .../flow/internal/ExecutionContext.java | 13 +- .../flow/internal/JavaScriptSemantics.java | 13 +- .../com/vaadin/flow/internal/JsonCodec.java | 80 +- .../flow/internal/JsonDecodingException.java | 3 +- .../vaadin/flow/internal/JsonSerializer.java | 132 +- .../com/vaadin/flow/internal/JsonUtils.java | 54 +- .../com/vaadin/flow/internal/LocaleUtil.java | 41 +- .../flow/internal/MessageDigestUtil.java | 17 +- .../com/vaadin/flow/internal/NodeOwner.java | 14 +- .../com/vaadin/flow/internal/NullOwner.java | 6 +- .../java/com/vaadin/flow/internal/Pair.java | 3 +- .../java/com/vaadin/flow/internal/Range.java | 129 +- .../vaadin/flow/internal/ReflectTools.java | 358 +-- .../vaadin/flow/internal/ReflectionCache.java | 45 +- .../internal/ReflectionCacheHotswapper.java | 6 +- .../vaadin/flow/internal/ResponseWriter.java | 189 +- .../com/vaadin/flow/internal/StateNode.java | 364 +-- .../com/vaadin/flow/internal/StateTree.java | 134 +- .../com/vaadin/flow/internal/StringUtil.java | 39 +- .../com/vaadin/flow/internal/Template.java | 5 +- .../com/vaadin/flow/internal/UrlUtil.java | 52 +- .../vaadin/flow/internal/UsageStatistics.java | 16 +- .../internal/UsageStatisticsExporter.java | 10 +- .../internal/VaadinContextInitializer.java | 9 +- .../internal/change/AbstractListChange.java | 9 +- .../flow/internal/change/EmptyChange.java | 4 +- .../flow/internal/change/ListAddChange.java | 27 +- .../flow/internal/change/ListClearChange.java | 3 +- .../internal/change/ListRemoveChange.java | 3 +- .../flow/internal/change/MapPutChange.java | 6 +- .../flow/internal/change/NodeChange.java | 9 +- .../internal/change/NodeFeatureChange.java | 3 +- .../internal/hilla/EndpointRequestUtil.java | 11 +- .../internal/hilla/FileRouterRequestUtil.java | 3 +- .../flow/internal/menu/MenuRegistry.java | 242 +- .../nodefeature/AbstractPropertyMap.java | 21 +- .../nodefeature/AbstractServerHandlers.java | 60 +- .../AttachExistingElementFeature.java | 15 +- .../internal/nodefeature/BasicTypeValue.java | 4 +- .../nodefeature/ClientCallableHandlers.java | 9 +- .../nodefeature/ComponentMapping.java | 27 +- .../nodefeature/ElementAttributeMap.java | 24 +- .../nodefeature/ElementClassList.java | 9 +- .../nodefeature/ElementListenerMap.java | 150 +- .../nodefeature/ElementPropertyMap.java | 167 +- .../nodefeature/ElementStylePropertyMap.java | 3 +- .../flow/internal/nodefeature/InertData.java | 76 +- .../LoadingIndicatorConfigurationMap.java | 6 +- .../internal/nodefeature/NodeFeature.java | 23 +- .../nodefeature/NodeFeatureRegistry.java | 90 +- .../internal/nodefeature/NodeFeatures.java | 3 +- .../flow/internal/nodefeature/NodeList.java | 41 +- .../flow/internal/nodefeature/NodeMap.java | 86 +- .../internal/nodefeature/NodeProperties.java | 21 +- .../flow/internal/nodefeature/NodeValue.java | 18 +- .../nodefeature/PolymerEventListenerMap.java | 21 +- .../PolymerServerEventHandlers.java | 47 +- .../PropertyChangeDeniedException.java | 3 +- .../nodefeature/PushConfigurationMap.java | 24 +- .../ReconnectDialogConfigurationMap.java | 6 +- .../nodefeature/ReturnChannelMap.java | 57 +- .../ReturnChannelRegistration.java | 24 +- .../nodefeature/SerializableNodeList.java | 6 +- .../nodefeature/ServerSideFeature.java | 4 +- .../internal/nodefeature/ShadowRootHost.java | 3 +- .../nodefeature/VirtualChildrenList.java | 12 +- .../internal/springcsrf/SpringCsrfToken.java | 3 +- .../springcsrf/SpringCsrfTokenUtil.java | 93 +- .../router/AbstractRouteNotFoundError.java | 53 +- .../flow/router/AfterNavigationEvent.java | 3 +- .../flow/router/AfterNavigationListener.java | 13 +- .../flow/router/AfterNavigationObserver.java | 3 +- .../vaadin/flow/router/BeforeEnterEvent.java | 29 +- .../flow/router/BeforeEnterListener.java | 15 +- .../flow/router/BeforeEnterObserver.java | 6 +- .../com/vaadin/flow/router/BeforeEvent.java | 508 ++-- .../vaadin/flow/router/BeforeLeaveEvent.java | 76 +- .../flow/router/BeforeLeaveListener.java | 23 +- .../flow/router/BeforeLeaveObserver.java | 15 +- .../flow/router/DefaultRoutePathProvider.java | 7 +- .../flow/router/ErrorNavigationEvent.java | 19 +- .../vaadin/flow/router/ErrorParameter.java | 21 +- .../com/vaadin/flow/router/EventUtil.java | 157 +- .../vaadin/flow/router/HasDynamicTitle.java | 3 +- .../vaadin/flow/router/HasErrorParameter.java | 6 +- .../vaadin/flow/router/HighlightAction.java | 4 +- .../vaadin/flow/router/HighlightActions.java | 27 +- .../flow/router/HighlightCondition.java | 3 +- .../flow/router/HighlightConditions.java | 18 +- .../flow/router/InternalServerError.java | 59 +- .../flow/router/InvalidLocationException.java | 16 +- .../java/com/vaadin/flow/router/Layout.java | 16 +- .../vaadin/flow/router/ListenerPriority.java | 13 +- .../java/com/vaadin/flow/router/Location.java | 76 +- .../flow/router/LocationChangeEvent.java | 63 +- .../com/vaadin/flow/router/LocationUtil.java | 35 +- .../java/com/vaadin/flow/router/Menu.java | 21 +- .../vaadin/flow/router/NavigationEvent.java | 70 +- .../vaadin/flow/router/NavigationHandler.java | 15 +- .../vaadin/flow/router/NavigationState.java | 22 +- .../flow/router/NavigationStateBuilder.java | 19 +- .../vaadin/flow/router/NavigationTrigger.java | 9 +- .../vaadin/flow/router/NotFoundException.java | 10 +- .../com/vaadin/flow/router/PageTitle.java | 8 +- .../flow/router/ParameterDeserializer.java | 98 +- .../com/vaadin/flow/router/ParentLayout.java | 3 +- .../vaadin/flow/router/PreserveOnRefresh.java | 21 +- .../vaadin/flow/router/QueryParameters.java | 112 +- .../java/com/vaadin/flow/router/Route.java | 55 +- .../flow/router/RouteAccessDeniedError.java | 9 +- .../com/vaadin/flow/router/RouteAlias.java | 49 +- .../vaadin/flow/router/RouteAliasData.java | 32 +- .../com/vaadin/flow/router/RouteBaseData.java | 32 +- .../flow/router/RouteConfiguration.java | 280 +- .../com/vaadin/flow/router/RouteData.java | 41 +- .../flow/router/RouteNotFoundError.java | 6 +- .../com/vaadin/flow/router/RouteParam.java | 3 +- .../router/RouteParameterFormatOption.java | 9 +- .../vaadin/flow/router/RouteParameters.java | 46 +- .../vaadin/flow/router/RoutePathProvider.java | 8 +- .../com/vaadin/flow/router/RoutePrefix.java | 10 +- .../com/vaadin/flow/router/RouteResolver.java | 3 +- .../java/com/vaadin/flow/router/Router.java | 151 +- .../com/vaadin/flow/router/RouterLayout.java | 29 +- .../com/vaadin/flow/router/RouterLink.java | 182 +- .../flow/router/RoutesChangedEvent.java | 34 +- .../flow/router/RoutesChangedListener.java | 6 +- .../vaadin/flow/router/WildcardParameter.java | 3 +- .../AbstractNavigationStateRenderer.java | 519 ++-- .../internal/AbstractRouteRegistry.java | 283 +- .../router/internal/ClientRoutesProvider.java | 3 +- .../flow/router/internal/ConfigureRoutes.java | 76 +- .../router/internal/ConfiguredRoutes.java | 118 +- .../router/internal/DefaultErrorHandler.java | 4 +- .../router/internal/DefaultRouteResolver.java | 28 +- .../router/internal/ErrorStateRenderer.java | 48 +- .../router/internal/ErrorTargetEntry.java | 9 +- .../internal/HasUrlParameterFormat.java | 125 +- .../internal/InternalRedirectHandler.java | 6 +- .../internal/NavigationRouteTarget.java | 17 +- .../internal/NavigationStateRenderer.java | 37 +- .../flow/router/internal/ParameterInfo.java | 6 +- .../vaadin/flow/router/internal/PathUtil.java | 28 +- .../vaadin/flow/router/internal/Postpone.java | 9 +- .../flow/router/internal/RouteFormat.java | 31 +- .../flow/router/internal/RouteModel.java | 85 +- .../internal/RouteRegistryHotswapper.java | 56 +- .../flow/router/internal/RouteSegment.java | 272 +- .../flow/router/internal/RouteTarget.java | 28 +- .../flow/router/internal/RouteUtil.java | 317 +-- .../flow/server/AbstractConfiguration.java | 109 +- .../AbstractDeploymentConfiguration.java | 11 +- .../server/AbstractPropertyConfiguration.java | 34 +- .../flow/server/AbstractStreamResource.java | 17 +- .../AmbiguousRouteConfigurationException.java | 31 +- .../vaadin/flow/server/AppShellRegistry.java | 106 +- .../vaadin/flow/server/AppShellSettings.java | 78 +- .../com/vaadin/flow/server/Attributes.java | 37 +- .../flow/server/BootstrapException.java | 29 +- .../vaadin/flow/server/BootstrapHandler.java | 700 ++--- .../server/BootstrapInitialPredicate.java | 7 +- .../flow/server/BootstrapUrlPredicate.java | 3 +- .../vaadin/flow/server/BootstrapUtils.java | 134 +- .../com/vaadin/flow/server/Constants.java | 93 +- .../flow/server/CustomizedSystemMessages.java | 83 +- .../DefaultDeploymentConfiguration.java | 98 +- .../flow/server/DefaultErrorHandler.java | 30 +- .../server/DefaultSystemMessagesProvider.java | 6 +- .../vaadin/flow/server/DependencyFilter.java | 16 +- .../DeploymentConfigurationFactory.java | 63 +- .../com/vaadin/flow/server/DevToolsToken.java | 32 +- .../com/vaadin/flow/server/ErrorEvent.java | 13 +- .../vaadin/flow/server/ErrorHandlerUtil.java | 77 +- .../flow/server/ErrorHandlingCommand.java | 3 +- .../flow/server/ErrorRouteRegistry.java | 8 +- .../flow/server/ExecutionFailedException.java | 3 +- .../com/vaadin/flow/server/FutureAccess.java | 20 +- .../com/vaadin/flow/server/HandlerHelper.java | 191 +- .../vaadin/flow/server/HttpStatusCode.java | 161 +- .../vaadin/flow/server/InitParameters.java | 95 +- .../com/vaadin/flow/server/InlineTargets.java | 12 +- .../flow/server/InputStreamFactory.java | 38 +- ...alidApplicationConfigurationException.java | 10 +- .../InvalidCustomElementNameException.java | 7 +- .../InvalidI18NConfigurationException.java | 23 +- .../InvalidMenuAccessControlException.java | 23 +- .../InvalidRouteConfigurationException.java | 10 +- ...alidRouteLayoutConfigurationException.java | 7 +- .../server/LoadDependenciesOnStartup.java | 28 +- .../main/java/com/vaadin/flow/server/PWA.java | 63 +- .../java/com/vaadin/flow/server/Platform.java | 29 +- .../PropertyDeploymentConfiguration.java | 67 +- .../vaadin/flow/server/PwaConfiguration.java | 37 +- .../java/com/vaadin/flow/server/PwaIcon.java | 44 +- .../com/vaadin/flow/server/PwaRegistry.java | 271 +- .../vaadin/flow/server/RequestHandler.java | 24 +- .../com/vaadin/flow/server/RouteRegistry.java | 114 +- .../server/ServiceContextUriResolver.java | 9 +- .../flow/server/ServiceDestroyEvent.java | 3 +- .../flow/server/ServiceDestroyListener.java | 3 +- .../vaadin/flow/server/ServiceException.java | 3 +- .../vaadin/flow/server/ServiceInitEvent.java | 50 +- .../flow/server/SessionDestroyListener.java | 3 +- .../flow/server/SessionExpiredHandler.java | 16 +- .../vaadin/flow/server/SessionInitEvent.java | 12 +- .../flow/server/SessionInitListener.java | 19 +- .../flow/server/SessionLockCheckStrategy.java | 20 +- .../flow/server/SessionRouteRegistry.java | 133 +- .../vaadin/flow/server/StaticFileHandler.java | 13 +- .../flow/server/StaticFileHandlerFactory.java | 3 +- .../vaadin/flow/server/StaticFileServer.java | 235 +- .../vaadin/flow/server/StreamReceiver.java | 14 +- .../flow/server/StreamRegistration.java | 15 +- .../vaadin/flow/server/StreamResource.java | 75 +- .../flow/server/StreamResourceRegistry.java | 46 +- .../flow/server/StreamResourceWriter.java | 13 +- .../vaadin/flow/server/StreamVariable.java | 73 +- .../server/SynchronizedRequestHandler.java | 41 +- .../vaadin/flow/server/SystemMessages.java | 75 +- .../flow/server/SystemMessagesInfo.java | 12 +- .../flow/server/SystemMessagesProvider.java | 8 +- .../vaadin/flow/server/UIInitListener.java | 4 +- .../server/UnsupportedBrowserHandler.java | 28 +- .../com/vaadin/flow/server/VaadinConfig.java | 16 +- .../com/vaadin/flow/server/VaadinContext.java | 44 +- .../com/vaadin/flow/server/VaadinRequest.java | 263 +- .../flow/server/VaadinRequestInterceptor.java | 10 +- .../vaadin/flow/server/VaadinResponse.java | 65 +- .../com/vaadin/flow/server/VaadinService.java | 1084 +++----- .../server/VaadinServiceInitListener.java | 18 +- .../com/vaadin/flow/server/VaadinServlet.java | 295 +- .../flow/server/VaadinServletConfig.java | 9 +- .../flow/server/VaadinServletContext.java | 6 +- .../flow/server/VaadinServletRequest.java | 14 +- .../flow/server/VaadinServletResponse.java | 25 +- .../flow/server/VaadinServletService.java | 74 +- .../com/vaadin/flow/server/VaadinSession.java | 474 ++-- .../flow/server/VaadinSessionState.java | 8 +- .../java/com/vaadin/flow/server/Version.java | 26 +- .../com/vaadin/flow/server/WebBrowser.java | 80 +- .../flow/server/WrappedHttpSession.java | 17 +- .../vaadin/flow/server/WrappedSession.java | 52 +- .../server/auth/AccessAnnotationChecker.java | 117 +- .../flow/server/auth/AccessCheckDecision.java | 3 +- .../auth/AccessCheckDecisionResolver.java | 45 +- .../flow/server/auth/AccessCheckResult.java | 60 +- .../server/auth/AccessDeniedErrorRouter.java | 20 +- .../flow/server/auth/AccessPathChecker.java | 26 +- .../auth/AnnotatedViewAccessChecker.java | 68 +- .../flow/server/auth/AnonymousAllowed.java | 24 +- .../DefaultAccessCheckDecisionResolver.java | 72 +- .../server/auth/DefaultMenuAccessControl.java | 3 +- .../flow/server/auth/MenuAccessControl.java | 22 +- .../server/auth/NavigationAccessChecker.java | 59 +- .../server/auth/NavigationAccessControl.java | 182 +- .../flow/server/auth/NavigationContext.java | 107 +- .../server/auth/RoutePathAccessChecker.java | 28 +- .../flow/server/auth/ViewAccessChecker.java | 127 +- .../AtmospherePushConnection.java | 136 +- .../server/communication/FaviconHandler.java | 10 +- .../FragmentedMessageHolder.java | 7 +- .../communication/HeartbeatHandler.java | 44 +- .../IndexHtmlRequestHandler.java | 211 +- .../IndexHtmlRequestListener.java | 18 +- .../communication/IndexHtmlResponse.java | 17 +- .../JSR356WebsocketInitializer.java | 100 +- .../JavaScriptBootstrapHandler.java | 95 +- .../communication/LongPollingCacheFilter.java | 66 +- .../server/communication/MetadataWriter.java | 16 +- .../communication/PushAtmosphereHandler.java | 18 +- .../server/communication/PushConnection.java | 22 +- .../communication/PushConnectionFactory.java | 13 +- .../server/communication/PushHandler.java | 252 +- .../communication/PushRequestHandler.java | 153 +- .../flow/server/communication/PwaHandler.java | 76 +- .../communication/ReturnChannelHandler.java | 24 +- .../communication/ServerRpcHandler.java | 189 +- .../communication/SessionRequestHandler.java | 22 +- .../communication/StreamReceiverHandler.java | 220 +- .../communication/StreamRequestHandler.java | 39 +- .../communication/StreamResourceHandler.java | 20 +- .../communication/UidlRequestHandler.java | 67 +- .../flow/server/communication/UidlWriter.java | 182 +- .../WebComponentBootstrapHandler.java | 250 +- .../communication/WebComponentProvider.java | 82 +- .../rpc/AbstractRpcInvocationHandler.java | 91 +- .../rpc/AttachExistingElementRpcHandler.java | 31 +- .../rpc/AttachTemplateChildRpcHandler.java | 46 +- .../communication/rpc/DefaultRpcDecoder.java | 6 +- .../communication/rpc/EventRpcHandler.java | 9 +- .../communication/rpc/MapSyncRpcHandler.java | 94 +- .../rpc/NavigationRpcHandler.java | 20 +- ...PublishedServerEventHandlerRpcHandler.java | 171 +- .../communication/rpc/RpcDecodeException.java | 8 +- .../server/communication/rpc/RpcDecoder.java | 27 +- .../rpc/RpcInvocationHandler.java | 5 +- .../rpc/StringToEnumDecoder.java | 12 +- .../rpc/StringToNumberDecoder.java | 23 +- .../streaming/AbstractStreamingEvent.java | 3 +- .../streaming/StreamingEndEventImpl.java | 6 +- .../streaming/StreamingErrorEventImpl.java | 7 +- .../streaming/StreamingProgressEventImpl.java | 7 +- .../streaming/StreamingStartEventImpl.java | 6 +- .../vaadin/flow/server/dau/DAUCustomizer.java | 33 +- .../com/vaadin/flow/server/dau/DAUUtils.java | 151 +- .../dau/DAUVaadinRequestInterceptor.java | 33 +- .../server/dau/DauEnforcementException.java | 7 +- .../flow/server/dau/FlowDauIntegration.java | 55 +- .../flow/server/dau/UserIdentitySupplier.java | 17 +- .../AbstractFileGeneratorFallibleCommand.java | 25 +- .../frontend/AbstractTaskClientGenerator.java | 6 +- .../frontend/AbstractUpdateImports.java | 363 +-- .../flow/server/frontend/BundleUtils.java | 71 +- .../server/frontend/BundleValidationUtil.java | 451 ++-- .../flow/server/frontend/CompressUtil.java | 36 +- .../server/frontend/CompressionException.java | 12 +- .../flow/server/frontend/CssBundler.java | 124 +- .../flow/server/frontend/CvdlProducts.java | 15 +- .../flow/server/frontend/DevBundleUtils.java | 27 +- .../flow/server/frontend/ExclusionFilter.java | 25 +- .../flow/server/frontend/FallibleCommand.java | 11 +- .../flow/server/frontend/FileIOUtils.java | 72 +- .../server/frontend/FrontendPluginsUtil.java | 12 +- .../flow/server/frontend/FrontendTools.java | 511 ++-- .../server/frontend/FrontendToolsLocator.java | 84 +- .../frontend/FrontendToolsSettings.java | 63 +- .../flow/server/frontend/FrontendUtils.java | 588 ++-- .../flow/server/frontend/FrontendVersion.java | 101 +- .../FrontendWebComponentGenerator.java | 52 +- .../server/frontend/GenerateMainImports.java | 18 +- .../frontend/GeneratedFilesSupport.java | 43 +- .../flow/server/frontend/ImportExtractor.java | 15 +- .../server/frontend/JarContentsManager.java | 176 +- .../flow/server/frontend/NodeTasks.java | 144 +- .../flow/server/frontend/NodeUpdater.java | 201 +- .../vaadin/flow/server/frontend/Options.java | 185 +- .../flow/server/frontend/ProdBundleUtils.java | 28 +- .../flow/server/frontend/ProxyFactory.java | 57 +- .../frontend/TaskCleanFrontendFiles.java | 33 +- .../frontend/TaskCopyFrontendFiles.java | 69 +- .../frontend/TaskCopyLocalFrontendFiles.java | 64 +- .../frontend/TaskCopyTemplateFiles.java | 35 +- .../frontend/TaskGenerateBootstrap.java | 35 +- .../frontend/TaskGenerateFeatureFlags.java | 14 +- .../frontend/TaskGenerateIndexHtml.java | 3 +- .../server/frontend/TaskGenerateIndexTs.java | 40 +- .../frontend/TaskGeneratePackageJson.java | 12 +- .../frontend/TaskGenerateReactFiles.java | 124 +- .../frontend/TaskGenerateServiceWorker.java | 9 +- .../server/frontend/TaskGenerateTsConfig.java | 75 +- .../frontend/TaskGenerateTsDefinitions.java | 123 +- .../frontend/TaskGenerateViteDevMode.java | 10 +- .../TaskGenerateWebComponentBootstrap.java | 21 +- .../TaskGenerateWebComponentHtml.java | 12 +- .../TaskInstallFrontendBuildPlugins.java | 45 +- .../frontend/TaskPrepareProdBundle.java | 49 +- .../TaskRemoveOldFrontendGeneratedFiles.java | 91 +- .../frontend/TaskRunDevBundleBuild.java | 68 +- .../server/frontend/TaskRunNpmInstall.java | 197 +- .../server/frontend/TaskUpdateImports.java | 16 +- .../server/frontend/TaskUpdateOldIndexTs.java | 6 +- .../server/frontend/TaskUpdatePackages.java | 185 +- .../frontend/TaskUpdateSettingsFile.java | 71 +- .../frontend/TaskUpdateThemeImport.java | 88 +- .../flow/server/frontend/TaskUpdateVite.java | 54 +- .../flow/server/frontend/ThemeUtils.java | 103 +- .../server/frontend/ThemeValidationUtil.java | 212 +- .../frontend/TypeScriptBootstrapModifier.java | 9 +- .../server/frontend/UnknownTaskException.java | 3 +- .../frontend/VersionsJsonConverter.java | 24 +- .../server/frontend/VersionsJsonFilter.java | 45 +- .../frontend/installer/ArchiveExtractor.java | 3 +- .../installer/DefaultArchiveExtractor.java | 67 +- .../installer/DefaultFileDownloader.java | 76 +- .../frontend/installer/FileDownloader.java | 14 +- .../frontend/installer/NodeInstaller.java | 225 +- .../server/frontend/installer/Platform.java | 12 +- .../frontend/installer/ProxyConfig.java | 41 +- .../scanner/AbstractDependenciesScanner.java | 12 +- .../server/frontend/scanner/ChunkInfo.java | 19 +- .../server/frontend/scanner/ClassFinder.java | 50 +- .../flow/server/frontend/scanner/CssData.java | 11 +- .../frontend/scanner/EntryPointData.java | 8 +- .../frontend/scanner/EntryPointType.java | 4 +- .../FrontendAnnotatedClassVisitor.java | 83 +- .../scanner/FrontendClassVisitor.java | 64 +- .../scanner/FrontendDependencies.java | 336 +-- .../scanner/FrontendDependenciesScanner.java | 68 +- .../scanner/FullDependenciesScanner.java | 270 +- .../server/frontend/scanner/ThemeData.java | 11 +- .../server/frontend/scanner/ThemeWrapper.java | 11 +- .../flow/server/menu/MenuConfiguration.java | 29 +- .../startup/AbstractAnnotationValidator.java | 74 +- .../startup/AbstractConfigurationFactory.java | 111 +- .../AbstractRouteRegistryInitializer.java | 161 +- .../server/startup/AnnotationValidator.java | 10 +- .../server/startup/AppShellPredicate.java | 6 +- .../startup/ApplicationConfiguration.java | 43 +- .../ApplicationConfigurationFactory.java | 3 +- .../startup/ApplicationRouteRegistry.java | 66 +- ...oaderAwareServletContainerInitializer.java | 83 +- .../flow/server/startup/CustomElements.java | 43 +- ...efaultApplicationConfigurationFactory.java | 98 +- .../DeferredServletContextInitializers.java | 13 +- .../DuplicateNavigationTitleException.java | 8 +- .../ErrorNavigationTargetInitializer.java | 16 +- .../LookupServletContainerInitializer.java | 93 +- .../startup/NavigationTargetFilter.java | 14 +- .../startup/RouteRegistryInitializer.java | 109 +- .../startup/ServletContextListeners.java | 8 +- .../flow/server/startup/ServletDeployer.java | 133 +- .../startup/VaadinAppShellInitializer.java | 72 +- .../VaadinContextStartupInitializer.java | 6 +- .../startup/VaadinInitializerException.java | 16 +- ...aadinServletContextStartupInitializer.java | 11 +- ...onentConfigurationRegistryInitializer.java | 72 +- .../WebComponentExporterAwareValidator.java | 18 +- .../PropertyConfigurationImpl.java | 34 +- .../server/webcomponent/PropertyData.java | 12 +- .../UnsupportedPropertyTypeException.java | 14 +- .../webcomponent/WebComponentBinding.java | 118 +- .../WebComponentConfigurationRegistry.java | 134 +- .../WebComponentExporterTagExtractor.java | 13 +- .../WebComponentExporterUtils.java | 45 +- .../webcomponent/WebComponentGenerator.java | 135 +- .../WebComponentModulesWriter.java | 169 +- .../flow/shared/ApplicationConstants.java | 46 +- .../vaadin/flow/shared/BrowserDetails.java | 71 +- .../vaadin/flow/shared/GwtIncompatible.java | 8 +- .../com/vaadin/flow/shared/JsonConstants.java | 44 +- .../com/vaadin/flow/shared/Registration.java | 30 +- .../vaadin/flow/shared/VaadinUriResolver.java | 37 +- .../shared/communication/PushConstants.java | 15 +- .../flow/shared/communication/PushMode.java | 26 +- .../com/vaadin/flow/shared/ui/Dependency.java | 25 +- .../com/vaadin/flow/shared/ui/LoadMode.java | 37 +- .../com/vaadin/flow/shared/ui/Transport.java | 9 +- .../vaadin/flow/shared/util/SharedUtil.java | 88 +- .../flow/shared/util/UniqueSerializable.java | 4 +- .../com/vaadin/flow/theme/AbstractTheme.java | 33 +- .../java/com/vaadin/flow/theme/NoTheme.java | 17 +- .../java/com/vaadin/flow/theme/Theme.java | 36 +- .../vaadin/flow/theme/ThemeDefinition.java | 9 +- .../test/java/com/vaadin/AssertionTest.java | 3 +- .../vaadin/experimental/FeatureFlagsTest.java | 281 +- .../flow/ComponentTrackerLocationTest.java | 93 +- .../com/vaadin/flow/ComponentTrackerTest.java | 18 +- .../flow/DisableComponentTrackerTest.java | 37 +- .../java/com/vaadin/flow/NotifierTest.java | 3 +- .../flow/WarURLStreamHandlerFactory.java | 35 +- .../component/AbstractCompositeFieldTest.java | 19 +- .../flow/component/AbstractFieldTest.java | 74 +- .../AbstractSinglePropertyFieldTest.java | 106 +- .../flow/component/ComponentEventBusTest.java | 178 +- .../component/ComponentEventBusUtilTest.java | 16 +- .../flow/component/ComponentMetaDataTest.java | 21 +- .../vaadin/flow/component/ComponentTest.java | 538 ++-- .../flow/component/ComponentUtilTest.java | 69 +- .../flow/component/CompositeNestedTest.java | 24 +- .../vaadin/flow/component/CompositeTest.java | 96 +- .../flow/component/CompositeTextNodeTest.java | 3 +- ...efaultWebComponentExporterFactoryTest.java | 21 +- .../vaadin/flow/component/DomEventTest.java | 54 +- .../vaadin/flow/component/FocusableTest.java | 22 +- .../com/vaadin/flow/component/HTMLTest.java | 15 +- .../flow/component/HasAriaLabelTest.java | 6 +- .../flow/component/HasComponentsTest.java | 15 +- .../vaadin/flow/component/HasEnabledTest.java | 3 +- .../vaadin/flow/component/HasHelperTest.java | 3 +- .../component/HasOrderedComponentsTest.java | 24 +- .../flow/component/HasPlaceholderTest.java | 3 +- .../vaadin/flow/component/HasStyleTest.java | 16 +- .../vaadin/flow/component/HasTextTest.java | 3 +- .../vaadin/flow/component/HasThemeTest.java | 9 +- .../vaadin/flow/component/InvalidUrlTest.java | 19 +- .../component/JavaScriptInvocationTest.java | 10 +- .../com/vaadin/flow/component/KeyTest.java | 6 +- .../flow/component/LocationObserverTest.java | 67 +- .../MappedDomEventWithRouterLinkData.java | 8 +- .../flow/component/MappedToDomEvent.java | 6 +- .../MappedToDomEventMultipleConstructors.java | 11 +- .../MappedToDomEventWithElementData.java | 4 +- .../component/MappedToDomNoDataEvent.java | 3 +- .../vaadin/flow/component/NpmPackageTest.java | 3 +- .../component/PropertyDescriptorsTest.java | 108 +- .../ShortCutRegistrationFilterTest.java | 85 +- .../flow/component/ShortcutEventTest.java | 36 +- .../component/ShortcutRegistrationTest.java | 277 +- .../component/ShortcutSerializationTest.java | 9 +- .../vaadin/flow/component/ShortcutsTest.java | 31 +- .../TestComponentWithServerEvent.java | 3 +- .../com/vaadin/flow/component/TextTest.java | 57 +- .../com/vaadin/flow/component/UITest.java | 365 +-- .../flow/component/ValueChangeMonitor.java | 9 +- .../WebComponentConfigurationFactoryTest.java | 117 +- .../component/WebComponentExporterTest.java | 91 +- .../vaadin/flow/component/WhiteSpaceTest.java | 3 +- .../internal/DependencyTreeCacheTest.java | 61 +- .../internal/JavaScriptBootstrapUITest.java | 227 +- .../flow/component/internal/PageTest.java | 9 +- .../PendingJavaScriptInvocationTest.java | 79 +- .../component/internal/UIInternalsTest.java | 284 +- .../page/ExtendedClientDetailsTest.java | 33 +- .../flow/component/page/HistoryTest.java | 120 +- .../vaadin/flow/component/page/PageTest.java | 81 +- .../polymertemplate/EventHandler.java | 4 +- .../polymertemplate/RepeatIndex.java | 4 +- .../webcomponent/WebComponentTest.java | 46 +- .../webcomponent/WebComponentWrapperTest.java | 107 +- .../flow/di/AppShellPredicateImplTest.java | 3 +- .../flow/di/DefaultInstantiatorTest.java | 37 +- .../vaadin/flow/di/LookupInitializerTest.java | 141 +- .../java/com/vaadin/flow/di/LookupTest.java | 3 +- .../com/vaadin/flow/dom/AbstractNodeTest.java | 30 +- .../dom/BasicElementStateProviderTest.java | 41 +- .../BasicTextElementStateProviderTest.java | 3 +- .../flow/dom/DisabledUpdateModeTest.java | 13 +- .../vaadin/flow/dom/ElementFactoryTest.java | 35 +- .../java/com/vaadin/flow/dom/ElementTest.java | 338 +-- .../com/vaadin/flow/dom/ElementUtilTest.java | 31 +- .../flow/dom/ShadowRootStateProviderTest.java | 3 +- .../com/vaadin/flow/dom/ShadowRootTest.java | 23 +- .../com/vaadin/flow/dom/StyleUtilTest.java | 9 +- ...ementStateProviderDeserializationTest.java | 15 +- .../flow/dom/impl/ThemeListImplTest.java | 135 +- .../vaadin/flow/hotswap/HotswapperTest.java | 361 +-- .../i18n/DefaultInstantiatorI18NTest.java | 168 +- .../com/vaadin/flow/i18n/I18NUtilTest.java | 200 +- .../TranslationFileRequestHandlerTest.java | 147 +- .../vaadin/flow/internal/CaseUtilTest.java | 9 +- .../flow/internal/ConstantPoolTest.java | 9 +- .../flow/internal/CurrentInstanceTest.java | 33 +- .../CustomElementNameValidatorTest.java | 24 +- .../flow/internal/HasCurrentService.java | 3 +- .../vaadin/flow/internal/JsonCodecTest.java | 88 +- .../flow/internal/JsonSerializerTest.java | 262 +- .../vaadin/flow/internal/JsonUtilsTest.java | 129 +- .../vaadin/flow/internal/LocaleUtilTest.java | 38 +- .../com/vaadin/flow/internal/RangeTest.java | 93 +- .../ReflectToolsGetFieldValueByTypeTest.java | 6 +- ...eflectToolsGetPrimitiveFieldValueTest.java | 3 +- .../flow/internal/ReflectToolsTest.java | 177 +- .../flow/internal/ReflectionCacheTest.java | 35 +- .../flow/internal/ResponseWriterTest.java | 258 +- .../vaadin/flow/internal/StateNodeTest.java | 369 +-- .../vaadin/flow/internal/StateTreeTest.java | 181 +- .../vaadin/flow/internal/StringUtilTest.java | 50 +- .../com/vaadin/flow/internal/UrlUtilTest.java | 56 +- .../internal/UsageStatisticsExporterTest.java | 10 +- .../flow/internal/change/ListChangeTest.java | 24 +- .../internal/change/MapPutChangeTest.java | 15 +- .../internal/change/MapRemoveChangeTest.java | 12 +- .../nodefeature/AbstractMapFeatureTest.java | 12 +- .../nodefeature/AbstractNodeFeatureTest.java | 21 +- .../AttachExistingElementFeatureTest.java | 18 +- .../ClientCallableHandlersTest.java | 29 +- .../nodefeature/DependencyListTest.java | 103 +- .../internal/nodefeature/ElementDataTest.java | 12 +- .../nodefeature/ElementListenersTest.java | 116 +- .../nodefeature/ElementPropertyMapTest.java | 64 +- .../internal/nodefeature/InertDataTest.java | 42 +- .../nodefeature/ListFeatureSetViewTest.java | 3 +- .../LoadingIndicatorConfigurationMapTest.java | 33 +- .../internal/nodefeature/NodeFeatureTest.java | 90 +- .../nodefeature/NodeListAddRemoveTest.java | 84 +- .../internal/nodefeature/NodeMapTest.java | 30 +- .../nodefeature/PollConfigurationMapTest.java | 6 +- .../PolymerServerEventHandlersTest.java | 64 +- .../nodefeature/PushConfigurationMapTest.java | 33 +- .../ReconnectDialogConfigurationMapTest.java | 39 +- .../nodefeature/ReturnChannelMapTest.java | 53 +- .../nodefeature/SerializableNodeListTest.java | 21 +- .../nodefeature/StateNodeNodeListTest.java | 30 +- .../nodefeature/VirtualChildrenListTest.java | 21 +- .../flow/router/DefaultRouteResolverTest.java | 104 +- .../flow/router/ErrorParameterTest.java | 15 +- .../com/vaadin/flow/router/EventUtilTest.java | 163 +- .../flow/router/HighlightConditionsTest.java | 12 +- .../flow/router/InternalServerErrorTest.java | 29 +- .../com/vaadin/flow/router/LocationTest.java | 124 +- .../router/ParameterDeserializerTest.java | 65 +- .../flow/router/QueryParametersTest.java | 102 +- .../flow/router/RouteConfigurationTest.java | 221 +- .../flow/router/RouteNotFoundErrorTest.java | 58 +- .../flow/router/RouteParametersTest.java | 72 +- .../RouterConfigurationUrlResolvingTest.java | 369 +-- .../vaadin/flow/router/RouterLayoutTest.java | 3 +- .../vaadin/flow/router/RouterLinkTest.java | 193 +- .../com/vaadin/flow/router/RouterTest.java | 2370 ++++++----------- .../vaadin/flow/router/RoutingTestBase.java | 10 +- .../internal/AbstractRouteRegistryTest.java | 450 ++-- .../router/internal/ConfigureRoutesTest.java | 81 +- .../router/internal/ConfiguredRoutesTest.java | 131 +- .../internal/ErrorStateRendererTest.java | 68 +- .../internal/NavigationStateRendererTest.java | 398 +-- .../flow/router/internal/PathUtilTest.java | 36 +- .../flow/router/internal/RouteModelTest.java | 160 +- .../internal/RouteRegistryHotswapperTest.java | 181 +- .../flow/router/internal/RouteUtilTest.java | 468 ++-- .../server/AbstractConfigurationTest.java | 18 +- .../AbstractDeploymentConfigurationTest.java | 20 +- .../flow/server/BootstrapContextTest.java | 57 +- .../flow/server/CustomUIClassLoaderTest.java | 37 +- .../DefaultDeploymentConfigurationTest.java | 180 +- .../flow/server/DefaultErrorHandlerTest.java | 25 +- .../DeploymentConfigurationFactoryTest.java | 440 ++- .../vaadin/flow/server/DevToolsTokenTest.java | 13 +- .../flow/server/ErrorHandlerUtilTest.java | 51 +- .../vaadin/flow/server/HandlerHelperTest.java | 249 +- .../flow/server/HttpStatusCodeTest.java | 19 +- .../vaadin/flow/server/I18NProviderTest.java | 77 +- .../flow/server/InitParametersTest.java | 14 +- .../flow/server/MockServletContext.java | 64 +- .../MockServletServiceSessionSetup.java | 149 +- .../vaadin/flow/server/MockVaadinContext.java | 6 +- .../flow/server/MockVaadinServletService.java | 15 +- .../vaadin/flow/server/MockVaadinSession.java | 13 +- .../com/vaadin/flow/server/PlatformTest.java | 21 +- .../PropertyDeploymentConfigurationTest.java | 192 +- .../flow/server/PwaConfigurationTest.java | 6 +- .../vaadin/flow/server/PwaRegistryTest.java | 283 +- .../flow/server/SessionRouteRegistryTest.java | 598 ++--- .../flow/server/StaticFileServerTest.java | 550 ++-- .../server/StreamResourceRegistryTest.java | 54 +- .../flow/server/StreamResourceTest.java | 15 +- .../flow/server/VaadinServiceDauTest.java | 40 +- .../vaadin/flow/server/VaadinServiceTest.java | 170 +- .../flow/server/VaadinServletConfigTest.java | 27 +- .../flow/server/VaadinServletContextTest.java | 48 +- .../flow/server/VaadinServletRequestTest.java | 6 +- .../flow/server/VaadinServletServiceTest.java | 147 +- .../vaadin/flow/server/VaadinServletTest.java | 118 +- .../vaadin/flow/server/VaadinSessionTest.java | 121 +- .../auth/AccessAnnotationCheckerTest.java | 290 +- .../server/auth/AccessCheckResultTest.java | 15 +- .../server/auth/AccessControlTestClasses.java | 52 +- .../auth/AnnotatedViewAccessCheckerTest.java | 197 +- .../server/auth/CustomMenuAccessControl.java | 3 +- ...aultInstantiatorMenuAccessControlTest.java | 49 +- .../server/auth/InvalidMenuAccessControl.java | 3 +- .../auth/NavigationAccessControlTest.java | 236 +- .../auth/RoutePathAccessCheckerTest.java | 282 +- .../server/auth/TestNavigationResult.java | 14 +- .../server/auth/ViewAccessCheckerTest.java | 378 +-- .../AtmospherePushConnectionTest.java | 102 +- .../communication/CommunicationUtil.java | 32 +- .../communication/FragmentedMessageTest.java | 22 +- .../communication/HeartbeatHandlerTest.java | 6 +- .../IndexHtmlRequestHandlerTest.java | 678 ++--- .../JavaScriptBootstrapHandlerTest.java | 129 +- .../LongPollingCacheFilterTest.java | 109 +- .../communication/MetadataWriterTest.java | 15 +- .../PushAtmosphereHandlerTest.java | 18 +- .../server/communication/PushHandlerTest.java | 152 +- .../server/communication/PwaHandlerTest.java | 39 +- .../communication/ServerRpcHandlerTest.java | 43 +- .../StreamReceiverHandlerTest.java | 163 +- .../StreamRequestHandlerTest.java | 94 +- .../StreamResourceHandlerTest.java | 60 +- .../communication/UidlRequestHandlerTest.java | 47 +- .../server/communication/UidlWriterTest.java | 211 +- .../WebComponentBootstrapHandlerViteTest.java | 116 +- .../WebComponentProviderTest.java | 146 +- .../rpc/AbstractRpcInvocationHandlerTest.java | 70 +- .../AttachExistingElementRpcHandlerTest.java | 33 +- .../AttachTemplateChildRpcHandlerTest.java | 3 +- .../communication/rpc/EnumDecoderTest.java | 15 +- .../rpc/EventRpcHandlerTest.java | 18 +- .../rpc/MapSyncRpcHandlerTest.java | 138 +- .../rpc/NavigationRpcHandlerTest.java | 15 +- ...ishedServerEventHandlerRpcHandlerTest.java | 137 +- .../rpc/ReturnChannelHandlerTest.java | 35 +- .../rpc/StringToNumberDecoderTest.java | 108 +- .../vaadin/flow/server/dau/DAUUtilsTest.java | 156 +- .../dau/DAUVaadinRequestInterceptorTest.java | 139 +- .../server/dau/FlowDauIntegrationTest.java | 9 +- .../AbstractNodeUpdateImportsTest.java | 129 +- .../AbstractNodeUpdatePackagesTest.java | 294 +- .../frontend/AbstractUpdateImportsTest.java | 403 +-- .../flow/server/frontend/BundleUtilsTest.java | 177 +- .../server/frontend/BundleValidationTest.java | 1741 ++++-------- .../server/frontend/ComponentFlagsTest.java | 62 +- .../flow/server/frontend/CssBundlerTest.java | 174 +- .../server/frontend/DevBundleUtilsTest.java | 15 +- .../EmptyByteScannerDataTestComponents.java | 3 +- .../flow/server/frontend/FileIOUtilsTest.java | 18 +- ...ndResourcesAreCopiedAfterCleaningTest.java | 54 +- .../frontend/FrontendToolsLocatorTest.java | 19 +- .../server/frontend/FrontendToolsTest.java | 425 ++- .../server/frontend/FrontendUtilsTest.java | 316 +-- .../server/frontend/FrontendVersionTest.java | 148 +- .../frontend/GeneratedFilesSupportTest.java | 67 +- .../server/frontend/ImportExtractorTest.java | 39 +- .../frontend/JarContentsManagerTest.java | 277 +- .../flow/server/frontend/MockLogger.java | 63 +- .../frontend/NodeTasksExecutionTest.java | 83 +- .../server/frontend/NodeTasksHillaTest.java | 53 +- .../server/frontend/NodeTasksViteTest.java | 163 +- .../server/frontend/NodeTestComponents.java | 14 +- ...eUpdateImportsWithByteCodeScannerTest.java | 6 +- ...odeUpdateImportsWithFullCPScannerTest.java | 6 +- ...deUpdatePackagesNpmVersionLockingTest.java | 58 +- ...UpdatePackagesWithByteCodeScannerTest.java | 6 +- ...datePackagesWithFullCPCodeScannerTest.java | 6 +- .../server/frontend/NodeUpdateTestUtil.java | 69 +- .../flow/server/frontend/NodeUpdaterTest.java | 293 +- .../server/frontend/ProdBundleUtilsTest.java | 12 +- .../frontend/TaskCleanFrontendFilesTest.java | 64 +- .../frontend/TaskCopyFrontendFilesTest.java | 67 +- .../TaskCopyLocalFrontendFilesTest.java | 26 +- .../frontend/TaskCopyTemplateFilesTest.java | 34 +- .../frontend/TaskGenerateBootstrapTest.java | 53 +- .../TaskGenerateFeatureFlagsTest.java | 32 +- .../frontend/TaskGenerateIndexHtmlTest.java | 38 +- .../frontend/TaskGenerateIndexTsTest.java | 72 +- .../frontend/TaskGenerateReactFilesTest.java | 166 +- .../TaskGenerateServicWorkerTest.java | 49 +- .../frontend/TaskGenerateTsConfigTest.java | 141 +- .../TaskGenerateTsDefinitionsTest.java | 370 +-- ...TaskGenerateWebComponentBootstrapTest.java | 22 +- .../TaskGenerateWebComponentHtmlTest.java | 44 +- .../TaskInstallFrontendBuildPluginsTest.java | 62 +- ...skRemoveOldFrontendGeneratedFilesTest.java | 111 +- .../frontend/TaskRunNpmInstallTest.java | 179 +- .../frontend/TaskRunPnpmInstallTest.java | 166 +- .../frontend/TaskUpdatePackagesNpmTest.java | 555 ++-- .../frontend/TaskUpdateSettingsFileTest.java | 52 +- .../frontend/TaskUpdateThemeImportTest.java | 230 +- .../server/frontend/TaskUpdateViteTest.java | 110 +- .../frontend/ThemeValidationUtilTest.java | 28 +- .../UpdateImportsWithByteCodeScannerTest.java | 208 +- .../UpdateImportsWithFullCPScannerTest.java | 18 +- .../frontend/UpdateThemedImportsTest.java | 97 +- .../frontend/VersionsJsonConverterTest.java | 60 +- .../frontend/VersionsJsonFilterTest.java | 128 +- .../DefaultArchiveExtractorTest.java | 27 +- .../installer/DefaultFileDownloaderTest.java | 38 +- .../frontend/installer/NodeInstallerTest.java | 67 +- .../frontend/installer/PlatformTest.java | 42 +- .../scanner/AbstractScannerPwaTest.java | 72 +- .../frontend/scanner/ClassFinderTest.java | 41 +- .../server/frontend/scanner/DepsTests.java | 31 +- .../scanner/FrontendDependenciesTest.java | 237 +- .../scanner/FrontendScannerPwaTest.java | 6 +- .../scanner/FullDependenciesScannerTest.java | 284 +- .../frontend/scanner/FullScannerPwaTest.java | 11 +- .../frontend/scanner/ScannerCssTest.java | 27 +- .../scanner/ScannerDependenciesTest.java | 128 +- .../scanner/ScannerTestComponents.java | 31 +- .../frontend/scanner/ScannerThemeTest.java | 53 +- .../scanner/samples/ErrorComponent.java | 3 +- .../RouteComponentWithMethodReference.java | 6 +- .../samples/RouteInterfaceComponent.java | 3 +- .../server/menu/MenuConfigurationTest.java | 122 +- .../flow/server/menu/MenuRegistryTest.java | 235 +- .../AbstractRouteRegistryInitializerTest.java | 94 +- .../startup/AnnotationValidatorTest.java | 87 +- .../startup/ApplicationConfigurationTest.java | 5 +- .../startup/ApplicationRouteRegistryTest.java | 140 +- .../server/startup/CustomElementsTest.java | 31 +- ...ltApplicationConfigurationFactoryTest.java | 113 +- ...LookupServletContainerInitializerTest.java | 82 +- .../startup/RouteRegistryInitializerTest.java | 834 +++--- .../startup/RouteRegistryMenuAccessTest.java | 182 +- .../server/startup/RouteRegistryTestBase.java | 154 +- .../ServletContainerInitializerTest.java | 65 +- .../server/startup/ServletDeployerTest.java | 181 +- .../VaadinAppShellInitializerTest.java | 195 +- ...tConfigurationRegistryInitializerTest.java | 125 +- ...ebComponentExporterAwareValidatorTest.java | 37 +- .../AnotherTestInstantiatorFactory.java | 3 +- .../OneMoreTestInstantiatorFactory.java | 3 +- .../testdata/TestInstantiatorFactory.java | 3 +- .../testdata/TestResourceProvider.java | 3 +- .../PropertyConfigurationImplTest.java | 13 +- .../webcomponent/WebComponentBindingTest.java | 3 +- ...WebComponentConfigurationRegistryTest.java | 148 +- .../WebComponentExporterUtilsTest.java | 47 +- .../WebComponentGeneratorTest.java | 137 +- .../WebComponentModulesWriterTest.java | 61 +- .../flow/shared/BrowserDetailsTest.java | 36 +- .../vaadin/flow/shared/RegistrationTest.java | 6 +- .../flow/shared/VaadinUriResolverTest.java | 3 +- .../vaadin/flow/shared/ui/DependencyTest.java | 31 +- .../flow/shared/util/SharedUtilTests.java | 128 +- .../shared/util/UniqueSerializableTest.java | 3 +- .../flow/testcategory/ContainerTests.java | 5 +- .../vaadin/flow/theme/AbstractThemeTest.java | 18 +- .../vaadin/packaging/SplitPackagesTest.java | 26 +- .../com/vaadin/tests/PublicApiAnalyzer.java | 10 +- .../java/com/vaadin/tests/VaadinClasses.java | 46 +- .../tests/server/AssertionsEnabledTest.java | 3 +- .../tests/server/AtmosphereVersionTest.java | 6 +- .../tests/server/SerializationTest.java | 79 +- .../FlowClassesSerializableTest.java | 20 +- .../util/MockDeploymentConfiguration.java | 12 +- .../com/vaadin/tests/util/MockOptions.java | 6 +- .../java/com/vaadin/tests/util/TestUtil.java | 95 +- .../vaadin/flow/testcategory/ChromeTests.java | 5 +- .../vaadin/flow/testcategory/IgnoreOSGi.java | 5 +- .../vaadin/flow/testcategory/PushTests.java | 3 +- .../flow/testcategory/ScreenshotTests.java | 5 +- .../vaadin/flow/testcategory/SlowTests.java | 5 +- .../com/vaadin/flow/testutil/ClassFinder.java | 47 +- .../testutil/ClassesSerializableTest.java | 143 +- .../flow/testutil/CurrentInstanceCleaner.java | 3 +- .../vaadin/flow/testutil/FrontendStubs.java | 132 +- .../com/vaadin/flow/testutil/TestUtils.java | 36 +- .../flow/testutil/AbstractComponentIT.java | 6 +- .../AbstractParallelTestBenchTest.java | 54 +- .../flow/testutil/AbstractTestBenchTest.java | 122 +- .../flow/testutil/AbstractValidationTest.java | 9 +- .../flow/testutil/AbstractViewTest.java | 5 +- .../flow/testutil/ChromeBrowserTest.java | 50 +- .../flow/testutil/ChromeDeviceTest.java | 72 +- .../vaadin/flow/testutil/DevToolsWrapper.java | 41 +- .../vaadin/flow/testutil/FileTestUtil.java | 3 +- .../vaadin/flow/testutil/LocalExecution.java | 11 +- .../flow/testutil/TestBenchHelpers.java | 141 +- .../com/vaadin/flow/testutil/TestPath.java | 3 +- .../flow/testutil/ValidationTestView.java | 3 +- .../vaadin/flow/testutil/ViewOrUITest.java | 31 +- .../net/EphemeralPortRangeDetector.java | 5 +- .../net/LinuxEphemeralPortRangeDetector.java | 15 +- .../vaadin/flow/testutil/net/PortProber.java | 23 +- .../flow/uitest/ui/theme/ParentThemeView.java | 18 +- .../flow/uitest/ui/theme/ParentThemeIT.java | 71 +- .../ui/ComponentThemeLiveReloadView.java | 3 +- .../uitest/ui/ComponentThemeLiveReloadIT.java | 114 +- .../flow/uitest/ui/ThemeLiveReloadIT.java | 37 +- .../uitest/ui/theme/ReusableThemeView.java | 16 +- .../flow/uitest/ui/theme/ReusableThemeIT.java | 98 +- .../com/vaadin/flow/uitest/ui/theme/TSIT.java | 3 +- .../navigate/ConnectionIndicatorView.java | 16 +- .../vaadin/flow/navigate/HelloWorldView.java | 18 +- .../navigate/ReconnectIntervalConfigurer.java | 4 +- .../flow/navigate/SpecialCharactersView.java | 3 +- .../flow/navigate/ConnectionIndicatorIT.java | 37 +- .../flow/navigate/NavigateBetweenViewsIT.java | 48 +- .../vaadin/flow/navigate/ServiceWorkerIT.java | 83 +- .../ServiceWorkerOnNestedMappingIT.java | 3 +- .../ccdmtest/ForwardToWithBeforeEnter.java | 3 +- .../flow/ccdmtest/PreventLeavingView.java | 9 +- .../ccdmtest/RerouteToWithBeforeEnter.java | 3 +- .../flow/ccdmtest/ServerSideForwardView.java | 9 +- .../flow/ccdmtest/ServerSidePostponeView.java | 18 +- .../TestApplicationServiceInitListener.java | 12 +- .../UnauthenticatedExceptionHandler.java | 9 +- .../flow/ccdmtest/ViewThrowsException.java | 3 +- .../flow/ccdmtest/ViewWithAllEvents.java | 7 +- .../flow/ccdmtest/ViewWithHomeButton.java | 3 +- .../flow/ccdmtest/ViewWithParameter.java | 3 +- .../ccdmtest/ViewWithServerViewButton.java | 9 +- .../vaadin/flow/ccdmtest/AppThemeTestIT.java | 6 +- .../com/vaadin/flow/ccdmtest/CCDMTest.java | 7 +- .../ccdmtest/IndexHtmlRequestHandlerIT.java | 236 +- ...avigateToServerSideViewWithoutTitleIT.java | 11 +- ...rverSideNavigationExceptionHandlingIT.java | 4 +- .../flow/ccdmtest/ServerSidePostponeIT.java | 58 +- .../RouterLayoutCustomScopeServlet.java | 71 +- .../uitest/servlet/RouterTestServlet.java | 27 +- .../flow/uitest/servlet/ViewClassLocator.java | 39 +- .../flow/uitest/servlet/ViewTestLayout.java | 18 +- .../flow/uitest/ui/AbstractDivView.java | 3 +- .../DependenciesLoadingBaseView.java | 6 +- .../flow/uitest/ui/theme/CssLoadingView.java | 22 +- .../flow/uitest/ui/theme/ThemeView.java | 10 +- .../flow/uitest/ui/theme/CssLoadingIT.java | 23 +- .../vaadin/flow/uitest/ui/theme/ThemeIT.java | 153 +- .../flow/custom/CustomErrorHandler.java | 9 +- .../flow/custom/CustomInitListener.java | 9 +- .../flow/custom/CustomNotFoundView.java | 9 +- .../com/vaadin/flow/custom/CustomRoute.java | 12 +- .../flow/custom/CustomRouteRegistry.java | 27 +- .../com/vaadin/flow/custom/CustomServlet.java | 6 +- .../flow/custom/CustomServletService.java | 3 +- .../com/vaadin/flow/custom/CustomRouteIT.java | 12 +- .../ui/DebugWindowErrorHandlingView.java | 47 +- .../vaadin/flow/uitest/ui/DependencyView.java | 23 +- .../vaadin/flow/uitest/ui/DevToolsPlugin.java | 3 +- .../flow/uitest/ui/DevToolsPluginView.java | 3 +- .../uitest/ui/ExportedJSFunctionView.java | 11 +- .../vaadin/flow/uitest/ui/FeatureView.java | 31 +- .../com/vaadin/flow/uitest/ui/InfoView.java | 15 +- .../flow/uitest/ui/StreamResourceView.java | 15 +- .../uitest/ui/TestingServiceInitListener.java | 10 +- .../ui/frontend/BrowserLoggingView.java | 7 +- ...ractAttachExistingElementByIdTemplate.java | 3 +- .../AttachExistingElementByIdView.java | 3 +- .../vaadin/flow/uitest/ui/DependencyIT.java | 13 +- .../flow/uitest/ui/ExceptionStacktraceIT.java | 16 +- .../flow/uitest/ui/ExportedJSFunctionIT.java | 8 +- .../com/vaadin/flow/uitest/ui/InfoIT.java | 7 +- .../flow/uitest/ui/OrderedDependencyIT.java | 3 +- .../flow/uitest/ui/StreamResourceIT.java | 34 +- .../flow/uitest/ui/UrlValidationIT.java | 25 +- .../ui/dependencies/DependencyFilterIT.java | 17 +- .../uitest/ui/frontend/BrowserLoggingIT.java | 19 +- .../template/AttachExistingElementByIdIT.java | 9 +- .../flow/eagerbootstrap/ParameterView.java | 12 +- .../flow/eagerbootstrap/ParameterIT.java | 10 +- .../com/vaadin/flow/servlet/BasicViewsIT.java | 9 +- .../vaadin/flow/servlet/LowLevelFetchIT.java | 6 +- .../webcomponent/ClientSelectComponent.java | 6 +- .../webcomponent/ClientSelectExporter.java | 11 +- .../DefaultValueInitializationExporter.java | 9 +- .../flow/webcomponent/FactoryExporter.java | 9 +- .../flow/webcomponent/FireEventComponent.java | 3 +- .../flow/webcomponent/FireEventExporter.java | 15 +- .../NoPreserveOnRefreshExporter.java | 6 +- .../PreserveOnRefreshExporter.java | 6 +- .../webcomponent/PropertyUpdateComponent.java | 3 +- .../webcomponent/PropertyUpdateExporter.java | 6 +- .../flow/webcomponent/PushComponent.java | 3 +- .../flow/webcomponent/PushExporter.java | 3 +- .../com/vaadin/flow/webcomponent/Select.java | 9 +- .../webcomponent/StreamResourceExporter.java | 10 +- .../webcomponent/ThemedComponentExporter.java | 6 +- .../servlets/AbstractPlainServlet.java | 15 +- .../CustomStreamResourceRegistryServlet.java | 28 +- .../DefaultValueInitializationIT.java | 47 +- .../webcomponent/EmbeddedWebComponentIT.java | 12 +- .../flow/webcomponent/FactoryExporterIT.java | 4 +- .../vaadin/flow/webcomponent/FireEventIT.java | 48 +- .../com/vaadin/flow/webcomponent/HasById.java | 9 +- .../webcomponent/PreserveOnRefreshIT.java | 107 +- .../flow/webcomponent/PushAnnotationIT.java | 10 +- .../flow/webcomponent/StreamResourceIT.java | 30 +- .../flow/webcomponent/UpdatePropertyIT.java | 6 +- .../flow/webcomponent/WebComponentIT.java | 26 +- .../flow/webcomponent/ThemedComponent.java | 3 +- .../webcomponent/ThemedComponentExporter.java | 6 +- .../ApplicationThemeComponentIT.java | 148 +- .../flow/webcomponent/ThemedComponent.java | 3 +- .../webcomponent/ThemedComponentExporter.java | 6 +- .../ApplicationThemeComponentIT.java | 72 +- .../ThemedVariantComponentExporter.java | 7 +- .../flow/webcomponent/VariantTheme.java | 8 +- .../ThemedVariantComponentIT.java | 3 +- .../com/vaadin/flow/todo/TodoElement.java | 15 +- .../java/com/vaadin/flow/todo/TodoList.java | 3 +- .../com/vaadin/flow/select/SelectElement.java | 6 +- .../frontend/ChangeFrontendContentIT.java | 27 +- .../flow/frontend/DevBundleCssImportIT.java | 40 +- .../flow/frontend/DevBundleJsModuleIT.java | 9 +- .../flow/frontend/ViteImportedCSSIT.java | 3 +- .../nobuildmojo/TodoIT.java | 21 +- .../nobuildmojo/AddOnIT.java | 35 +- .../nobuildmojo/NoAppBundleIT.java | 30 +- .../webcomponent/OtherComponentExporter.java | 7 +- .../flow/webcomponent/ThemedComponent.java | 3 +- .../webcomponent/ThemedComponentExporter.java | 6 +- .../ApplicationThemeComponentIT.java | 113 +- .../vaadin/flow/webcomponent/MyViewIT.java | 3 +- .../vaadin/flow/devbuild/ParentThemeView.java | 7 +- .../vaadin/flow/devbuild/ParentThemeIT.java | 24 +- .../prodbuild/ParentThemeInFrontendIT.java | 18 +- .../devbuild/ParentThemeInFrontendIT.java | 3 +- .../flow/prodbuild/ParentThemeView.java | 3 +- .../nobuildmojo/NoAppBundleIT.java | 30 +- .../flow/devbuild/ReusingThemeView.java | 4 +- .../vaadin/flow/devbuild/ReusingThemeIT.java | 32 +- .../flow/devbuild/DevBundleThemeIT.java | 60 +- .../prodbuild/ThemeComponentsCssView.java | 6 +- .../flow/prodbuild/ThemeComponentsCssIT.java | 12 +- .../vaadin/flow/mixedtest/ui/IdTestView.java | 3 +- .../mixedtest/ui/MissingDependenciesView.java | 12 +- .../flow/mixedtest/ui/PolymerIdTestView.java | 3 +- .../vaadin/flow/mixedtest/ui/IdTestIT.java | 13 +- .../flow/mixedtest/ui/PolymerIdTestIT.java | 25 +- .../vaadin/flow/mixedtest/ui/IdTestView.java | 3 +- .../mixedtest/ui/MissingDependenciesView.java | 12 +- .../flow/mixedtest/ui/PolymerIdTestView.java | 3 +- .../vaadin/flow/mixedtest/ui/IdTestIT.java | 13 +- .../flow/mixedtest/ui/PolymerIdTestIT.java | 25 +- .../com/vaadin/viteapp/BootstrapModifier.java | 3 +- .../vaadin/viteapp/views/empty/MainView.java | 21 +- .../java/com/vaadin/viteapp/BasicsIT.java | 15 +- .../java/com/vaadin/viteapp/BundlesIT.java | 18 +- .../com/vaadin/viteapp/ExternalPackageIT.java | 3 +- .../java/com/vaadin/viteapp/FileAccessIT.java | 24 +- .../com/vaadin/viteapp/PostinstallIT.java | 5 +- .../com/vaadin/viteapp/ReactComponentsIT.java | 18 +- .../test/java/com/vaadin/viteapp/ThemeIT.java | 8 +- .../com/vaadin/viteapp/ThemeReloadIT.java | 21 +- .../com/vaadin/viteapp/ViteDevModeIT.java | 3 +- .../vaadin/viteapp/views/empty/MainView.java | 3 +- .../java/com/vaadin/viteapp/BundlesIT.java | 6 +- .../java/com/vaadin/viteapp/LoginForm.java | 3 +- .../com/vaadin/viteapp/LoginFormExporter.java | 3 +- .../com/vaadin/viteapp/BasicComponentIT.java | 12 +- .../com/vaadin/viteapp/BasicComponent.java | 4 +- .../com/vaadin/viteapp/PushComponent.java | 7 +- .../com/vaadin/viteapp/PushComponentIT.java | 12 +- .../vaadin/viteapp/views/empty/MainView.java | 12 +- .../java/com/vaadin/viteapp/BundlesIT.java | 3 +- .../com/vaadin/viteapp/CompressionIT.java | 12 +- .../com/vaadin/viteapp/ExternalPackageIT.java | 3 +- .../vaadin/viteapp/ProductionBasicsIT.java | 9 +- .../test/java/com/vaadin/viteapp/MainIT.java | 9 +- .../ApplicationServiceInitListener.java | 3 +- .../test/java/com/vaadin/viteapp/MainIT.java | 18 +- .../test/java/com/vaadin/viteapp/MainIT.java | 3 +- .../test/java/com/vaadin/viteapp/MainIT.java | 21 +- .../viteapp/views/template/TemplateView.java | 3 +- .../java/com/vaadin/viteapp/TemplateIT.java | 9 +- .../multimodule/ui/ProjectFolderInfo.java | 3 +- .../multimodule/ui/ProjectHotdeployInfo.java | 4 +- .../multimodule/ui/FrontendLiveReloadIT.java | 58 +- .../uitest/ui/FrontendLiveReloadView.java | 22 +- .../flow/uitest/ui/JavaLiveReloadView.java | 10 +- .../uitest/ui/TestingServiceInitListener.java | 36 +- .../flow/uitest/ui/ThemeLiveReloadView.java | 9 +- .../ui/ThemeLiveReloadWithShadowRootView.java | 9 +- .../flow/uitest/ui/AbstractLiveReloadIT.java | 3 +- .../flow/uitest/ui/FrontendLiveReloadIT.java | 27 +- .../flow/uitest/ui/JavaLiveReloadIT.java | 9 +- .../ui/PreserveOnRefreshLiveReloadIT.java | 9 +- .../flow/uitest/ui/ThemeLiveReloadIT.java | 9 +- .../ui/ThemeLiveReloadWithShadowRootIT.java | 6 +- .../java/com/vaadin/flow/theme/lumo/Lumo.java | 5 +- .../vaadin/flow/misc/ui/ActiveUIsView.java | 30 +- .../flow/misc/ui/ExceptionLoggingView.java | 18 +- .../vaadin/flow/misc/ui/MiscelaneousView.java | 5 +- .../flow/misc/ui/NpmThemedComponentView.java | 6 +- .../flow/misc/ui/PreserveOnRefreshView.java | 6 +- .../flow/misc/ui/ProdModeConfigView.java | 12 +- .../vaadin/flow/misc/ui/TranslationView.java | 11 +- .../flow/misc/ui/UITrackerListener.java | 10 +- .../flow/misc/ui/CompressedResourceIT.java | 9 +- .../flow/misc/ui/ExceptionLoggingIT.java | 15 +- .../misc/ui/JavascriptServedAsUtf8IT.java | 4 +- .../vaadin/flow/misc/ui/MiscelaneousIT.java | 13 +- .../flow/misc/ui/NpmThemedComponentIT.java | 15 +- .../misc/ui/PreserveOnRefreshCloseUIsIT.java | 57 +- .../vaadin/flow/misc/ui/ProdModeConfigIT.java | 21 +- .../vaadin/flow/misc/ui/TranslationIT.java | 48 +- .../flow/multiwar/deployment/TwoAppsIT.java | 18 +- .../multiwar/war1/HelloComponentExporter.java | 6 +- .../multiwar/war2/HelloComponentExporter.java | 6 +- .../uitest/ui/notheme/NoThemeComponentIT.java | 4 +- .../ByteCodeScanningView.java | 3 +- .../bytecodescanning/ByteCodeScanningIT.java | 6 +- .../bytecodescanning/FullCPScanningIT.java | 6 +- .../bytecodescanning/LazyIT.java | 3 +- .../general/ExternalJSModuleIT.java | 32 +- .../MultipleNpmPackageAnnotationsIT.java | 3 +- .../StartupPerformanceIT.java | 21 +- .../ApplicationServiceInitListener.java | 3 +- .../java/com/vaadin/flow/pwatest/MainIT.java | 18 +- .../com/vaadin/flow/pwatest/ui/PwaTestIT.java | 135 +- .../vaadin/flow/FlowInReactComponentView.java | 18 +- .../com/vaadin/flow/ReactAdapterView.java | 9 +- .../java/com/vaadin/flow/ReactLayout.java | 9 +- .../vaadin/flow/FlowInReactComponentIT.java | 36 +- .../java/com/vaadin/flow/ReactAdapterIT.java | 15 +- .../main/java/com/vaadin/flow/AnchorView.java | 3 +- .../com/vaadin/flow/BackNavFirstView.java | 3 +- .../com/vaadin/flow/BackNavSecondView.java | 3 +- .../flow/ForwardTargetWithParametersView.java | 6 +- .../flow/ForwardingToParametersView.java | 3 +- .../java/com/vaadin/flow/NavigationView.java | 33 +- .../java/com/vaadin/flow/PostponeView.java | 6 +- .../main/java/com/vaadin/flow/ServerView.java | 14 +- .../main/java/com/vaadin/flow/StateView.java | 34 +- .../test/java/com/vaadin/flow/BackNavIT.java | 60 +- .../java/com/vaadin/flow/ForwardTargetIT.java | 29 +- .../java/com/vaadin/flow/NavigationIT.java | 289 +- .../test/java/com/vaadin/flow/StateIT.java | 12 +- .../uitest/ui/DevModeNoClassCacheView.java | 53 +- .../flow/uitest/ui/DevModeNoClassCacheIT.java | 3 +- .../flow/uitest/ui/AbstractReloadView.java | 3 +- .../vaadin/flow/uitest/ui/Application.java | 3 +- .../flow/uitest/ui/DevModeClassCacheView.java | 45 +- .../flow/uitest/ui/SessionValueView.java | 3 +- .../flow/uitest/ui/DevModeClassCacheIT.java | 35 +- .../vaadin/flow/uitest/ui/SessionValueIT.java | 9 +- .../uitest/ui/ThemeSwitchLiveReloadIT.java | 44 +- .../ItApplicationConfigurationFactory.java | 9 +- .../java/com/vaadin/flow/osgi/Activator.java | 79 +- .../com/vaadin/flow/osgi/OSGiMarkerImpl.java | 5 +- .../uitest/ui/AbstractErrorHandlerView.java | 3 +- .../uitest/ui/AbstractPushUpdateDivView.java | 3 +- .../flow/uitest/ui/ActivatePushView.java | 3 +- .../uitest/ui/AttachExistingElementView.java | 40 +- .../flow/uitest/ui/AttachListenerView.java | 39 +- .../ui/BackButtonServerRoundTripView.java | 15 +- .../vaadin/flow/uitest/ui/BaseHrefView.java | 6 +- .../flow/uitest/ui/BasicComponentView.java | 5 +- .../flow/uitest/ui/BasicElementView.java | 48 +- .../flow/uitest/ui/BrokenRouterLinkView.java | 3 +- .../uitest/ui/BrowserWindowResizeView.java | 4 +- .../uitest/ui/ComplexDialogShortcutView.java | 9 +- .../flow/uitest/ui/ComponentErrorView.java | 3 +- .../uitest/ui/ComponentEventDataView.java | 54 +- .../vaadin/flow/uitest/ui/CompositeView.java | 18 +- .../ui/ConstantPoolPerformanceView.java | 9 +- .../vaadin/flow/uitest/ui/CountUIsView.java | 3 +- .../uitest/ui/CustomCustomElementView.java | 3 +- .../ui/DebounceSynchronizePropertyView.java | 26 +- .../flow/uitest/ui/DevModeConfigView.java | 9 +- .../flow/uitest/ui/DialogShortcutView.java | 89 +- .../flow/uitest/ui/DirectionChangeView.java | 25 +- .../flow/uitest/ui/DnDAttachDetachView.java | 3 +- .../uitest/ui/DnDCustomComponentView.java | 10 +- .../flow/uitest/ui/DnDDisabledView.java | 20 +- .../com/vaadin/flow/uitest/ui/DnDView.java | 182 +- .../flow/uitest/ui/DomEventFilterView.java | 90 +- ...tStopPropagationAndPreventDefaultView.java | 6 +- .../flow/uitest/ui/DynamicTitleView.java | 7 +- .../flow/uitest/ui/ElementInitOrderView.java | 11 +- .../flow/uitest/ui/ElementInnerHtmlView.java | 6 +- .../vaadin/flow/uitest/ui/EnabledView.java | 20 +- .../flow/uitest/ui/ErrorHandlingView.java | 23 +- .../flow/uitest/ui/EventTargetView.java | 3 +- .../uitest/ui/ExceptionDuringMapSyncView.java | 3 +- .../ui/ExceptionInStreamResourceView.java | 8 +- .../flow/uitest/ui/ExecJavaScriptView.java | 44 +- .../uitest/ui/ExtendedClientDetailsView.java | 44 +- .../flow/uitest/ui/FindComponentView.java | 3 +- .../flow/uitest/ui/FragmentLinkView.java | 54 +- .../flow/uitest/ui/FragmentLinkView2.java | 3 +- .../uitest/ui/HasUrlParameterErrorView.java | 6 +- .../vaadin/flow/uitest/ui/HistoryView.java | 12 +- .../com/vaadin/flow/uitest/ui/IFrameView.java | 10 +- .../flow/uitest/ui/InMemoryChildrenView.java | 6 +- .../flow/uitest/ui/InertComponentView.java | 18 +- .../flow/uitest/ui/InternalErrorView.java | 44 +- .../uitest/ui/InvalidateHttpSessionView.java | 3 +- .../uitest/ui/JavaScriptReturnValueView.java | 39 +- .../flow/uitest/ui/JsApiGetByIdView.java | 6 +- .../flow/uitest/ui/KeyboardEventView.java | 18 +- .../flow/uitest/ui/LoadingIndicatorView.java | 22 +- .../flow/uitest/ui/LocaleChangeView.java | 36 +- .../ui/LogoutWithNotificationServlet.java | 11 +- .../ui/LongPollingMultipleThreadsView.java | 6 +- .../flow/uitest/ui/LongPollingPushView.java | 3 +- .../flow/uitest/ui/ModalDialogView.java | 64 +- .../flow/uitest/ui/MyExceptionHandler.java | 6 +- .../flow/uitest/ui/NavigationEventsView.java | 10 +- .../flow/uitest/ui/NavigationTriggerView.java | 30 +- .../com/vaadin/flow/uitest/ui/PageView.java | 23 +- .../flow/uitest/ui/PopStateHandlerView.java | 23 +- .../flow/uitest/ui/PostponeProceedView.java | 20 +- .../flow/uitest/ui/PostponeUpdateView.java | 9 +- .../ui/PreserveOnRefreshForwardToView.java | 12 +- .../ui/PreserveOnRefreshForwardingView.java | 3 +- .../ui/PreserveOnRefreshNavigationView.java | 12 +- ...erveOnRefreshNestedBeforeEnterCounter.java | 3 +- ...reserveOnRefreshNestedBeforeEnterView.java | 9 +- .../uitest/ui/PreserveOnRefreshReAddView.java | 9 +- .../ui/PreserveOnRefreshShortcutView.java | 3 +- .../flow/uitest/ui/PreserveOnRefreshView.java | 3 +- ...hLongPollingWithPreserveOnRefreshView.java | 13 +- .../flow/uitest/ui/PushSettingsView.java | 3 +- .../ui/PushWithPreserveOnRefreshView.java | 4 +- .../uitest/ui/RefreshCloseConnectionView.java | 19 +- ...reshCurrentPreserveOnRefreshRouteView.java | 3 +- .../uitest/ui/RefreshCurrentRouteView.java | 13 +- .../uitest/ui/RemoveAddVisibilityView.java | 11 +- .../ui/RequestParametersHistoryView.java | 9 +- .../flow/uitest/ui/RequestParametersView.java | 6 +- .../vaadin/flow/uitest/ui/RerouteView.java | 17 +- .../flow/uitest/ui/ResynchronizationView.java | 3 +- .../flow/uitest/ui/ReturnChannelView.java | 10 +- .../ui/RouteAndQueryParametersView.java | 21 +- .../vaadin/flow/uitest/ui/RouterLinkView.java | 32 +- .../flow/uitest/ui/ScriptInjectView.java | 5 +- .../flow/uitest/ui/SerializeShortcutView.java | 33 +- .../flow/uitest/ui/SerializeUIView.java | 4 +- .../uitest/ui/ServiceInitListenersView.java | 15 +- .../uitest/ui/SetParameterForwardToView.java | 10 +- ...wRootShortcutsWithValueChangeModeView.java | 15 +- .../vaadin/flow/uitest/ui/ShadowRootView.java | 6 +- .../vaadin/flow/uitest/ui/ShortcutsView.java | 98 +- .../ui/ShortcutsWithValueChangeModeView.java | 15 +- .../flow/uitest/ui/StreamResourceView.java | 18 +- .../uitest/ui/SynchronizedPropertyView.java | 40 +- .../uitest/ui/TestingServiceInitListener.java | 29 +- .../uitest/ui/TimingInfoReportedView.java | 3 +- .../flow/uitest/ui/TrackMessageSizeView.java | 50 +- .../vaadin/flow/uitest/ui/UIElementView.java | 6 +- .../ui/UIsCollectedWithBeaconAPIView.java | 3 +- .../flow/uitest/ui/ValueChangeModeView.java | 6 +- .../vaadin/flow/uitest/ui/VisibilityView.java | 16 +- .../ui/dependencies/ContextInlineApiView.java | 6 +- .../DependenciesLoadingAnnotationsView.java | 3 +- .../DependenciesLoadingPageApiView.java | 6 +- .../dependencies/DynamicDependencyView.java | 15 +- .../ui/frontend/UsageStatisticsView.java | 24 +- .../littemplate/AnchorInsideTemplateView.java | 3 +- .../InnerTemplateVisibilityView.java | 6 +- .../littemplate/LitTemplateAttributeView.java | 6 +- .../ui/littemplate/SetInitialTextLitView.java | 6 +- .../ui/push/AbstractTestViewWithLog.java | 10 +- .../flow/uitest/ui/push/BasicPollView.java | 6 +- .../ui/push/BasicPushLongPollingView.java | 3 +- .../flow/uitest/ui/push/BasicPushView.java | 4 +- .../ui/push/BasicPushWebsocketView.java | 3 +- .../ui/push/BasicPushWebsocketXhrView.java | 3 +- .../uitest/ui/push/EnableDisablePushView.java | 21 +- .../MakeComponentVisibleWithPushView.java | 7 +- .../ui/push/ManualLongPollingPushView.java | 25 +- .../uitest/ui/push/PushConfiguration.java | 6 +- .../flow/uitest/ui/push/PushConfigurator.java | 15 +- .../uitest/ui/push/PushErrorHandlingView.java | 7 +- .../flow/uitest/ui/push/PushLargeData.java | 19 +- .../ui/push/PushLargeDataLongPollingView.java | 3 +- .../ui/push/PushLargeDataWebsocketView.java | 3 +- ...endMultibyteCharactersLongPollingView.java | 3 +- .../ui/push/SendMultibyteCharactersView.java | 3 +- .../SendMultibyteCharactersWebSocketView.java | 3 +- .../flow/uitest/ui/push/TogglePushView.java | 32 +- .../push/components/ClientServerCounter.java | 15 +- .../flow/uitest/ui/routing/NPEHandler.java | 9 +- .../routing/NavigationExceptionHandler.java | 6 +- .../ui/routing/NavigationExceptionLayout.java | 3 +- .../flow/uitest/ui/routing/PushLayout.java | 9 +- .../ui/routing/PushRouteNotFoundView.java | 7 +- .../PushRouteWildcardParameterView.java | 15 +- .../ui/scroll/CustomScrollCallbacksView.java | 17 +- .../flow/uitest/ui/scroll/LongToOpenView.java | 10 +- .../uitest/ui/scroll/MultipleAnchorsView.java | 13 +- .../uitest/ui/scroll/PushStateScrollView.java | 6 +- .../flow/uitest/ui/scroll/ScrollView.java | 18 +- .../ui/template/AfterServerChangesView.java | 13 +- .../AttachExistingDomElementByIdView.java | 3 +- .../ui/template/BasicTypeInListView.java | 6 +- .../uitest/ui/template/BeanInListingView.java | 9 +- .../ChangeInjectedComponentTextView.java | 3 +- .../uitest/ui/template/ChildOrderView.java | 28 +- .../ui/template/ClearNodeChildrenView.java | 60 +- .../ui/template/ClientUpdateModeView.java | 15 +- .../uitest/ui/template/ConvertToBeanView.java | 12 +- .../uitest/ui/template/DomRepeatView.java | 9 +- .../uitest/ui/template/EventHandlerView.java | 15 +- .../ExceptionsDuringPropertyUpdatesView.java | 19 +- ...njectedElementInsideMixinBehaviorView.java | 3 +- .../InvisibleDefaultPropertyValueView.java | 6 +- .../uitest/ui/template/JsSubTemplate.java | 3 +- .../MutationSeveralSyncedPropsView.java | 18 +- .../ui/template/OneWayPolymerBindingView.java | 3 +- .../PolymerDefaultPropertyValueView.java | 3 +- .../template/PolymerModelPropertiesView.java | 14 +- .../PolymerPropertyChangeEventView.java | 7 +- ...PolymerPropertyMutationInObserverView.java | 11 +- ...opertiesUpdatedBeforeChangeEventsView.java | 10 +- .../RestoreViewWithAttachedByIdView.java | 3 +- .../ui/template/SetInitialTextView.java | 6 +- .../ui/template/SubPropertyModelTemplate.java | 3 +- .../ui/template/TemplateAttributeView.java | 6 +- .../TemplateHasInjectedSubTemplateView.java | 3 +- .../template/TemplateMappingDetectorView.java | 18 +- .../ui/template/TemplateScalabilityView.java | 6 +- .../TemplateWithConnectedCallbacks.java | 5 +- .../ui/template/TemplatesVisibilityView.java | 26 +- .../ui/template/TwoWayPolymerBindingView.java | 6 +- .../UpdatableModelPropertiesView.java | 18 +- .../ui/template/UpgradeElementView.java | 5 +- .../template/collections/ClearListView.java | 6 +- .../template/collections/ListBindingView.java | 18 +- .../ListInsideListBindingView.java | 23 +- .../template/collections/ModelListView.java | 9 +- .../collections/ToggleNullListView.java | 18 +- .../collections/TwoWayListBindingView.java | 9 +- .../flow/uitest/ui/webcomponent/HasMax.java | 4 +- .../ui/webcomponent/PaperInputView.java | 3 +- .../uitest/ui/webcomponent/PaperSlider.java | 8 +- .../ui/webcomponent/PaperSliderView.java | 8 +- .../java/com/vaadin/flow/AssertionTest.java | 4 +- .../com/vaadin/flow/ClientResourceIT.java | 39 +- .../com/vaadin/flow/FaultyLocationIT.java | 4 +- .../flow/InitialExtendedClientDetailsIT.java | 42 +- .../com/vaadin/flow/InvalidLocationIT.java | 3 +- .../com/vaadin/flow/ui/SerializationTest.java | 13 +- .../java/com/vaadin/flow/ui/ToStringTest.java | 4 +- .../ui/AbstractBasicElementComponentIT.java | 7 +- .../ui/AbstractDebounceSynchronizeIT.java | 25 +- .../flow/uitest/ui/AbstractErrorIT.java | 6 +- .../uitest/ui/AbstractStreamResourceIT.java | 22 +- .../flow/uitest/ui/AbstractUpdateDivIT.java | 12 +- .../uitest/ui/AttachExistingElementIT.java | 30 +- .../flow/uitest/ui/AttachListenerIT.java | 57 +- .../ui/BackButtonServerRoundTripIT.java | 15 +- .../flow/uitest/ui/BasicComponentIT.java | 3 +- .../vaadin/flow/uitest/ui/BasicElementIT.java | 10 +- .../vaadin/flow/uitest/ui/BodyScrollIT.java | 6 +- .../flow/uitest/ui/BrowserWindowResizeIT.java | 24 +- .../uitest/ui/ComplexDialogShortcutIT.java | 9 +- .../flow/uitest/ui/ComponentErrorIT.java | 6 +- .../flow/uitest/ui/ComponentEventDataIT.java | 12 +- .../vaadin/flow/uitest/ui/CompositeIT.java | 12 +- .../flow/uitest/ui/CompositeNestedIT.java | 3 +- .../uitest/ui/CustomBrowserTooOldPageIT.java | 6 +- .../flow/uitest/ui/CustomCustomElementIT.java | 6 +- .../ui/DebounceSynchronizePropertyIT.java | 3 +- .../flow/uitest/ui/DevModeConfigIT.java | 6 +- .../flow/uitest/ui/DialogShortcutIT.java | 68 +- .../flow/uitest/ui/DirectionChangeIT.java | 6 +- .../flow/uitest/ui/DnDAttachDetachIT.java | 6 +- .../java/com/vaadin/flow/uitest/ui/DnDIT.java | 65 +- .../flow/uitest/ui/DomEventFilterIT.java | 96 +- ...entStopPropagationAndPreventDefaultIT.java | 22 +- .../ui/DynamicallyRegisteredRouteIT.java | 13 +- .../flow/uitest/ui/ElementInitOrderIT.java | 6 +- .../flow/uitest/ui/ElementInnerHtmlIT.java | 18 +- .../vaadin/flow/uitest/ui/ElementStyleIT.java | 8 +- .../com/vaadin/flow/uitest/ui/EnabledIT.java | 3 +- .../flow/uitest/ui/ErrorHandlingIT.java | 3 +- .../vaadin/flow/uitest/ui/ErrorPageIT.java | 6 +- .../ui/ExceptionInStreamResourceIT.java | 12 +- .../flow/uitest/ui/ExecJavaScriptIT.java | 12 +- .../uitest/ui/ExtendedClientDetailsIT.java | 23 +- .../flow/uitest/ui/FindComponentIT.java | 5 +- .../vaadin/flow/uitest/ui/ForwardToIT.java | 9 +- .../vaadin/flow/uitest/ui/FragmentLinkIT.java | 31 +- .../uitest/ui/HasUrlParameterErrorIT.java | 3 +- .../com/vaadin/flow/uitest/ui/HistoryIT.java | 17 +- .../com/vaadin/flow/uitest/ui/IFrameIT.java | 3 +- .../flow/uitest/ui/InertComponentIT.java | 39 +- .../flow/uitest/ui/InternalErrorIT.java | 42 +- .../uitest/ui/InvalidateHttpSessionIT.java | 3 +- .../uitest/ui/JavaScriptReturnValueIT.java | 39 +- .../flow/uitest/ui/LoadingIndicatorIT.java | 30 +- .../vaadin/flow/uitest/ui/LocaleChangeIT.java | 3 +- .../com/vaadin/flow/uitest/ui/LogoutIT.java | 5 +- .../uitest/ui/LogoutWithNotificationIT.java | 3 +- .../ui/LongPollingMultipleThreadsIT.java | 3 +- .../flow/uitest/ui/LongPollingPushIT.java | 6 +- .../vaadin/flow/uitest/ui/ModalDialogIT.java | 64 +- .../flow/uitest/ui/NavigationEventsIT.java | 14 +- .../flow/uitest/ui/NavigationTriggerIT.java | 25 +- .../com/vaadin/flow/uitest/ui/PageIT.java | 37 +- .../flow/uitest/ui/PopStateHandlerIT.java | 7 +- .../flow/uitest/ui/PostponeProceedIT.java | 35 +- .../flow/uitest/ui/PostponeUpdateIT.java | 13 +- .../ui/PreserveOnRefreshForwardingIT.java | 3 +- .../flow/uitest/ui/PreserveOnRefreshIT.java | 38 +- .../PreserveOnRefreshNestedBeforeEnterIT.java | 22 +- .../uitest/ui/PreserveOnRefreshReAddIT.java | 3 +- .../ui/PreserveOnRefreshShortcutIT.java | 3 +- ...ushLongPollingWithPreserveOnRefreshIT.java | 6 +- .../ui/PushWithPreserveOnRefreshIT.java | 3 +- .../flow/uitest/ui/RedirectToPushIT.java | 3 +- .../uitest/ui/RefreshCloseConnectionIT.java | 3 +- ...efreshCurrentPreserveOnRefreshRouteIT.java | 3 +- .../flow/uitest/ui/RemoveAddVisibilityIT.java | 3 +- .../ui/RemoveRoutersLayoutContentIT.java | 12 +- .../uitest/ui/RequestParametersHistoryIT.java | 26 +- .../flow/uitest/ui/RequestParametersIT.java | 12 +- .../com/vaadin/flow/uitest/ui/RerouteIT.java | 9 +- .../flow/uitest/ui/ResynchronizationIT.java | 14 +- .../uitest/ui/RouteAndQueryParametersIT.java | 6 +- .../flow/uitest/ui/RouteNotFoundIT.java | 6 +- .../uitest/ui/RouteNotFoundProdModeIT.java | 3 +- .../com/vaadin/flow/uitest/ui/RouterIT.java | 57 +- .../vaadin/flow/uitest/ui/RouterLinkIT.java | 26 +- .../flow/uitest/ui/RouterParallelIT.java | 15 +- .../uitest/ui/RouterSessionExpirationIT.java | 3 +- .../vaadin/flow/uitest/ui/ScriptInjectIT.java | 7 +- .../uitest/ui/ServiceInitListenersIT.java | 9 +- .../flow/uitest/ui/SessionCloseLogoutIT.java | 7 +- .../uitest/ui/SetParameterForwardToIT.java | 9 +- .../vaadin/flow/uitest/ui/ShadowRootIT.java | 3 +- ...dowRootShortcutsWithValueChangeModeIT.java | 20 +- .../vaadin/flow/uitest/ui/ShortcutsIT.java | 18 +- .../ui/ShortcutsWithValueChangeModeIT.java | 17 +- .../vaadin/flow/uitest/ui/StaticHtmlIT.java | 3 +- .../flow/uitest/ui/StreamResourceIT.java | 12 +- .../flow/uitest/ui/StylePriorityIT.java | 3 +- .../uitest/ui/SynchronizedPropertyIT.java | 78 +- .../flow/uitest/ui/TimingInfoReportedIT.java | 3 +- .../flow/uitest/ui/TrackMessageSizeIT.java | 3 +- .../vaadin/flow/uitest/ui/UIElementIT.java | 3 +- .../flow/uitest/ui/VaadinPushScriptIT.java | 27 +- .../vaadin/flow/uitest/ui/ViewTitleIT.java | 3 +- .../vaadin/flow/uitest/ui/VisibilityIT.java | 9 +- .../vaadin/flow/uitest/ui/WebStorageIT.java | 12 +- .../DependenciesLoadingAnnotationsIT.java | 83 +- .../DependenciesLoadingPageApiIT.java | 10 +- .../ui/dependencies/DynamicDependencyIT.java | 12 +- .../ui/dependencies/ExternalJavaScriptIT.java | 26 +- .../littemplate/AnchorInsideTemplateIT.java | 9 +- .../ui/littemplate/InjectingTemplateIT.java | 3 +- .../InnerTemplateVisibilityIT.java | 45 +- .../uitest/ui/littemplate/ReattachIT.java | 3 +- .../SimpleLitTemplateNoShadowRootIT.java | 3 +- .../SimpleLitTemplateShadowRootIT.java | 12 +- .../ui/push/AbstractBrowserConsoleTest.java | 13 +- .../push/AbstractClientServerCounterIT.java | 16 +- .../flow/uitest/ui/push/AbstractLogTest.java | 6 +- .../ui/push/AbstractPushLargeDataIT.java | 3 +- .../ui/push/ChromeBrowserTestWithProxy.java | 9 +- .../uitest/ui/push/EnableDisablePushIT.java | 3 +- .../push/MakeComponentVisibleWithPushIT.java | 15 +- .../ui/push/ManualLongPollingPushIT.java | 3 +- .../push/PushConfigurationLongPollingIT.java | 16 +- .../uitest/ui/push/PushConfigurationTest.java | 13 +- .../ui/push/PushConfigurationWebSocketIT.java | 17 +- .../push/PushToggleComponentVisibilityIT.java | 6 +- .../uitest/ui/push/PushWithRequireJSIT.java | 3 +- .../flow/uitest/ui/push/ReconnectTest.java | 14 +- .../SendMultibyteCharactersLongPollingIT.java | 3 +- .../ui/push/SendMultibyteCharactersTest.java | 23 +- .../SendMultibyteCharactersWebSocketIT.java | 3 +- .../flow/uitest/ui/push/SimpleProxy.java | 15 +- .../flow/uitest/ui/push/TogglePushIT.java | 21 +- .../ui/routing/InfiniteRerouteLoopIT.java | 3 +- .../ui/routing/PushRouteNotFoundIT.java | 9 +- .../routing/PushRouteWildcardParameterIT.java | 3 +- .../uitest/ui/scroll/AbstractScrollIT.java | 6 +- .../ui/scroll/CustomScrollCallbacksIT.java | 6 +- .../uitest/ui/scroll/MultipleAnchorsIT.java | 24 +- .../uitest/ui/scroll/PushStateScrollIT.java | 6 +- .../flow/uitest/ui/scroll/ScrollIT.java | 33 +- .../ui/scroll/ServerRequestScrollIT.java | 7 +- .../AttachExistingDomElementByIdIT.java | 12 +- .../uitest/ui/template/BasicTypeInListIT.java | 9 +- .../uitest/ui/template/BeanInListingIT.java | 18 +- .../ChangeInjectedComponentTextIT.java | 13 +- .../flow/uitest/ui/template/ChildOrderIT.java | 144 +- .../ui/template/ClearNodeChildrenIT.java | 201 +- .../flow/uitest/ui/template/DomRepeatIT.java | 9 +- .../flow/uitest/ui/template/EmptyListsIT.java | 3 +- .../uitest/ui/template/EventHandlerIT.java | 27 +- .../ExceptionsDuringPropertyUpdatesIT.java | 6 +- .../uitest/ui/template/HiddenTemplateIT.java | 9 +- .../uitest/ui/template/InjectScriptTagIT.java | 9 +- .../ui/template/InjectsJsTemplateIT.java | 12 +- .../InvisibleDefaultPropertyValueIT.java | 3 +- .../uitest/ui/template/JsGrandParentIT.java | 3 +- .../ui/template/OneWayPolymerBindingIT.java | 21 +- .../ui/template/PolymerModelPropertiesIT.java | 15 +- .../PolymerPropertyChangeEventIT.java | 11 +- .../PolymerPropertyMutationInObserverIT.java | 21 +- .../PolymerTemplateWithoutShadowRootIT.java | 3 +- ...PropertiesUpdatedBeforeChangeEventsIT.java | 6 +- .../RestoreViewWithAttachedByIdIT.java | 6 +- .../uitest/ui/template/SetInitialTextIT.java | 9 +- .../ui/template/SubPropertyModelIT.java | 18 +- .../TemplateHasInjectedSubTemplateIT.java | 3 +- .../template/TemplateMappingDetectorIT.java | 31 +- .../ui/template/TemplateScalabilityIT.java | 8 +- .../TemplateWithConnectedCallbacksIT.java | 12 +- .../ui/template/TemplatesVisibilityIT.java | 54 +- .../ui/template/TwoWayPolymerBindingIT.java | 3 +- .../template/UpdatableModelPropertiesIT.java | 9 +- .../uitest/ui/template/UpgradeElementIT.java | 3 +- .../ui/template/collections/ClearListIT.java | 20 +- .../template/collections/ListBindingIT.java | 42 +- .../collections/ListInsideListBindingIT.java | 31 +- .../ui/template/collections/ModelListIT.java | 6 +- .../collections/ToggleNullListIT.java | 9 +- .../collections/TwoWayListBindingIT.java | 4 +- .../ui/template/imports/LazyWidgetIT.java | 6 +- .../uitest/ui/webcomponent/PaperInputIT.java | 9 +- .../uitest/ui/webcomponent/PaperSliderIT.java | 25 +- .../flow/contexttest/ui/DependencyLayout.java | 34 +- .../flow/contexttest/ui/PathLayout.java | 15 +- .../vaadin/flow/contexttest/ui/PushUtil.java | 13 +- .../contexttest/ui/RootContextLayout.java | 12 +- .../contexttest/ui/AbstractContextIT.java | 10 +- .../ui/OfflineWithCustomContextIT.java | 15 +- .../vaadin/flow/contexttest/ui/PushIT.java | 10 +- .../flow/uitest/ui/theme/CssLoadingView.java | 43 +- .../flow/uitest/ui/theme/ThemeView.java | 25 +- .../flow/uitest/ui/theme/CssLoadingIT.java | 7 +- .../vaadin/flow/uitest/ui/theme/ThemeIT.java | 128 +- .../java/org/vaadin/example/Application.java | 3 +- .../org/vaadin/example/WebConfiguration.java | 3 +- .../java/org/vaadin/example/AppViewIT.java | 3 +- .../vaadin/flow/spring/test/Application.java | 3 +- .../spring/test/HelloWorldController.java | 13 +- .../spring/test/ReadyStatusController.java | 3 +- .../test/SpringDevToolsReloadUtils.java | 19 +- .../example/SpringDevToolsReloadViewIT.java | 23 +- .../spring/test/TestServletInitializer.java | 11 +- .../flow/spring/test/CodeGeneratorMojo.java | 112 +- .../flow/spring/test/JavaRouteContext.java | 6 +- .../vaadin/flow/spring/test/Application.java | 6 +- .../test/ApplicationServiceInitListener.java | 9 +- .../vaadin/flow/spring/test/MainLayout.java | 17 +- .../SpringDevToolsApplicationReloadView.java | 22 +- .../test/SpringDevToolsReloadUtils.java | 29 +- .../flow/spring/test/store/CatalogLayout.java | 3 +- .../flow/spring/test/store/ProductView.java | 28 +- .../example/SpringDevToolsReloadViewIT.java | 56 +- .../vaadin/flow/spring/test/Application.java | 6 +- ...ingDevToolsHorizontalLayoutReloadView.java | 15 +- .../SpringDevToolsNativeButtonReloadView.java | 22 +- .../test/SpringDevToolsReloadUtils.java | 29 +- .../example/SpringDevToolsReloadViewIT.java | 42 +- .../flow/spring/test/ComponentTestView.java | 3 +- .../test/ConfigureUIServiceInitListener.java | 9 +- .../flow/spring/test/CustomWebSocket.java | 9 +- .../test/DoubleNpmAnnotationHolder.java | 5 +- .../vaadin/flow/spring/test/NPEHandler.java | 9 +- .../spring/test/ProxiedNavigationTarget.java | 12 +- .../spring/test/RootNavigationTarget.java | 6 +- .../flow/spring/test/StreamResourceView.java | 3 +- .../flow/spring/test/TemplatePushView.java | 3 +- .../flow/spring/test/TranslationView.java | 7 +- .../flow/spring/test/UIScopeTarget.java | 6 +- .../vaadin/flow/spring/test/UploadView.java | 6 +- .../test/VaadinAutowiredDependencies.java | 6 +- .../routescope/AnotherBeanNopOwnerView.java | 3 +- .../test/routescope/BeansWithNoOwnerView.java | 3 +- .../test/routescope/ButtonInLayout.java | 9 +- .../test/routescope/CustomExceptionRoute.java | 3 +- .../routescope/CustomExceptionTarget.java | 6 +- .../routescope/InvalidRouteScopeUsage.java | 3 +- .../flow/spring/test/routescope/Layout.java | 6 +- .../test/routescope/MainPreDestroyView.java | 3 +- .../test/routescope/PreDestroyView.java | 3 +- .../test/CoExistingSpringEndpointsIT.java | 7 +- .../flow/spring/test/ComponentTestIT.java | 3 +- .../flow/spring/test/CustomWebSocketIT.java | 9 +- .../spring/test/DoubleNpmAnnotationIT.java | 12 +- .../vaadin/flow/spring/test/NPEHandlerIT.java | 13 +- .../flow/spring/test/ProfiledRouteIT.java | 3 +- .../vaadin/flow/spring/test/ResourcesIT.java | 15 +- .../vaadin/flow/spring/test/RouteBasicIT.java | 16 +- .../vaadin/flow/spring/test/SmokeTestIT.java | 13 +- .../flow/spring/test/StreamResourceIT.java | 25 +- .../vaadin/flow/spring/test/SwaggerIT.java | 5 +- .../flow/spring/test/TranslationIT.java | 33 +- .../com/vaadin/flow/spring/test/UploadIT.java | 24 +- .../test/VaadinAutowiredDependenciesIT.java | 3 +- .../test/routescope/BeansWithNoOwnerIT.java | 6 +- .../test/routescope/ErrorParameterIT.java | 3 +- .../flow/spring/test/routescope/LayoutIT.java | 40 +- .../PreserveOnRefreshDestroyBeanIT.java | 3 +- .../test/filtering/ClassScannerView.java | 3 +- .../filtering/TestServletInitializer.java | 12 +- .../spring/test/filtering/ClassScannerIT.java | 25 +- .../CustomVaadinServiceInitListener.java | 3 +- ...lockedCustomVaadinServiceInitListener.java | 3 +- .../spring/test/exclude/ExcludedRoute.java | 3 +- .../test/filtering/ClassScannerView.java | 3 +- .../filtering/TestServletInitializer.java | 12 +- .../spring/test/filtering/ClassScannerIT.java | 25 +- .../flow/spring/test/DummyOAuth2Server.java | 20 +- .../test/PathRewritingProxyServlet.java | 20 +- .../com/vaadin/flow/spring/test/Proxy.java | 6 +- .../flow/spring/test/AbstractSpringTest.java | 6 +- .../flowsecuritycontextpath/Application.java | 3 +- .../spring/flowsecurity/SecurityConfig.java | 33 +- .../spring/flowsecurity/SecurityUtils.java | 3 +- .../spring/flowsecurity/data/Account.java | 6 +- .../spring/flowsecurity/data/UserInfo.java | 3 +- .../flowsecurity/service/AccountService.java | 3 +- .../flowsecurity/service/BankService.java | 12 +- .../flowsecurity/service/UserInfoService.java | 11 +- .../spring/flowsecurity/views/AdminView.java | 6 +- .../flowsecurity/views/Broadcaster.java | 3 +- .../spring/flowsecurity/views/LoginView.java | 3 +- .../spring/flowsecurity/views/MainView.java | 16 +- .../flowsecurity/views/PrivateView.java | 23 +- .../spring/flowsecurity/views/PublicView.java | 30 +- .../flow/spring/flowsecurity/AbstractIT.java | 29 +- .../flow/spring/flowsecurity/AppViewIT.java | 14 +- .../flowsecurityreverseproxy/Application.java | 3 +- .../flow/spring/flowsecurity/Application.java | 3 +- .../spring/flowsecurity/SecurityConfig.java | 29 +- .../spring/flowsecurity/SecurityUtils.java | 3 +- .../spring/flowsecurity/data/Account.java | 6 +- .../spring/flowsecurity/data/UserInfo.java | 3 +- .../flowsecurity/service/AccountService.java | 3 +- .../flowsecurity/service/BankService.java | 12 +- .../flowsecurity/service/UserInfoService.java | 11 +- .../spring/flowsecurity/views/AdminView.java | 6 +- .../flowsecurity/views/AnotherPublicView.java | 3 +- .../flowsecurity/views/Broadcaster.java | 3 +- .../spring/flowsecurity/views/LoginView.java | 3 +- .../spring/flowsecurity/views/MainView.java | 13 +- .../flowsecurity/views/MenuListView.java | 10 +- .../flowsecurity/views/PassThroughView.java | 3 +- .../flowsecurity/views/PrivateView.java | 23 +- .../spring/flowsecurity/views/PublicView.java | 39 +- .../flow/spring/flowsecurity/AbstractIT.java | 32 +- .../flow/spring/flowsecurity/AppViewIT.java | 34 +- .../flow/spring/flowsecurity/MenuItem.java | 3 +- .../flowsecurity/UIAccessContextIT.java | 12 +- .../spring/flowsecurity/SecurityConfig.java | 32 +- .../spring/flowsecurity/SecurityUtils.java | 3 +- .../spring/flowsecurity/data/Account.java | 6 +- .../spring/flowsecurity/data/UserInfo.java | 3 +- .../flowsecurity/service/AccountService.java | 3 +- .../flowsecurity/service/BankService.java | 12 +- .../flowsecurity/service/UserInfoService.java | 11 +- .../spring/flowsecurity/views/AdminView.java | 6 +- .../flowsecurity/views/AnotherPublicView.java | 3 +- .../flowsecurity/views/Broadcaster.java | 3 +- .../spring/flowsecurity/views/LoginView.java | 3 +- .../spring/flowsecurity/views/MainView.java | 13 +- .../flowsecurity/views/PassThroughView.java | 3 +- .../flowsecurity/views/PrivateView.java | 23 +- .../spring/flowsecurity/views/PublicView.java | 39 +- .../flow/spring/flowsecurity/AbstractIT.java | 32 +- .../flow/spring/flowsecurity/AppViewIT.java | 30 +- .../flow/spring/flowsecurity/MenuItem.java | 3 +- .../flowsecurity/UIAccessContextIT.java | 12 +- .../flowsecurityurlmapping/Application.java | 15 +- .../flow/spring/flowsecurity/Application.java | 10 +- .../CustomServiceInitListener.java | 11 +- .../spring/flowsecurity/SecurityConfig.java | 29 +- .../spring/flowsecurity/SecurityUtils.java | 3 +- .../spring/flowsecurity/data/Account.java | 6 +- .../spring/flowsecurity/data/UserInfo.java | 3 +- .../flowsecurity/service/AccountService.java | 3 +- .../flowsecurity/service/BankService.java | 12 +- .../flowsecurity/service/UserInfoService.java | 11 +- .../spring/flowsecurity/views/AdminView.java | 6 +- .../flowsecurity/views/Broadcaster.java | 3 +- .../spring/flowsecurity/views/LoginView.java | 3 +- .../spring/flowsecurity/views/LogoutView.java | 3 +- .../spring/flowsecurity/views/MainView.java | 16 +- .../flowsecurity/views/MenuListView.java | 10 +- .../flowsecurity/views/PrivateView.java | 23 +- .../spring/flowsecurity/views/PublicView.java | 30 +- .../views/RolePrefixedAdminView.java | 7 +- .../flow/spring/flowsecurity/AbstractIT.java | 35 +- .../flow/spring/flowsecurity/AppViewIT.java | 33 +- .../flow/spring/flowsecurity/MenuItem.java | 3 +- .../spring/flowsecurity/TranslationIT.java | 18 +- .../flowsecurity/UIAccessContextIT.java | 12 +- .../spring/flowsecurity/Configurator.java | 3 +- .../spring/flowsecurity/CustomWebIconsIT.java | 20 +- .../spring/flowsecurity/Configurator.java | 3 +- .../spring/flowsecurity/CustomWebIconsIT.java | 14 +- .../flow/spring/test/TestConfiguration.java | 3 +- .../test/mvc/TestWebAppInitializer.java | 3 +- .../vaadin/flow/server/webpush/WebPush.java | 95 +- .../flow/server/webpush/WebPushException.java | 6 +- .../devserver/AbstractDevServerRunner.java | 239 +- .../base/devserver/BrowserLauncher.java | 21 +- .../BrowserLiveReloadAccessorImpl.java | 12 +- .../base/devserver/DebugWindowConnection.java | 102 +- .../devserver/DevBundleBuildingHandler.java | 29 +- .../devserver/DevModeHandlerManagerImpl.java | 59 +- .../devserver/DevServerOutputTracker.java | 85 +- .../base/devserver/DevServerWatchDog.java | 15 +- .../devserver/DevToolsMessageHandler.java | 18 +- .../devserver/ExternalDependencyWatcher.java | 73 +- .../vaadin/base/devserver/FileWatcher.java | 19 +- .../com/vaadin/base/devserver/MavenUtils.java | 59 +- .../base/devserver/OpenInCurrentIde.java | 51 +- .../vaadin/base/devserver/RestartMonitor.java | 22 +- .../com/vaadin/base/devserver/ServerInfo.java | 11 +- .../base/devserver/ThemeLiveUpdater.java | 28 +- .../vaadin/base/devserver/ViteHandler.java | 50 +- .../devserver/startup/DevModeInitializer.java | 253 +- .../startup/DevModeStartupListener.java | 60 +- .../stats/DevModeUsageStatistics.java | 58 +- .../base/devserver/stats/JsonHelpers.java | 14 +- .../vaadin/base/devserver/stats/ProKey.java | 3 +- .../base/devserver/stats/ProjectHelpers.java | 68 +- .../devserver/stats/StatisticsContainer.java | 3 +- .../devserver/stats/StatisticsSender.java | 83 +- .../devserver/stats/StatisticsStorage.java | 24 +- .../viteproxy/ViteWebsocketConnection.java | 37 +- .../viteproxy/ViteWebsocketEndpoint.java | 33 +- .../viteproxy/ViteWebsocketProxy.java | 25 +- .../AbstractDevServerRunnerTest.java | 75 +- .../BrowserLiveReloadAccessorImplTest.java | 27 +- .../devserver/DebugWindowConnectionTest.java | 138 +- .../base/devserver/DevModeEndpointTest.java | 59 +- .../vaadin/base/devserver/MavenUtilsTest.java | 29 +- .../MockDeploymentConfiguration.java | 12 +- .../base/devserver/OpenInCurrentIdeTest.java | 216 +- .../base/devserver/RestartMonitorTest.java | 27 +- .../vaadin/base/devserver/ServerInfoTest.java | 16 +- .../TestEndpointGeneratorTaskFactory.java | 34 +- .../startup/AbstractDevModeTest.java | 64 +- .../startup/DevModeClassFinderTest.java | 44 +- .../DevModeInitializerClassLoaderTest.java | 29 +- .../startup/DevModeInitializerTest.java | 202 +- .../startup/DevModeInitializerTestBase.java | 55 +- .../stats/AbstractStatisticsTest.java | 16 +- .../stats/DevModeUsageStatisticsTest.java | 148 +- .../devserver/stats/ProjectHelpersTest.java | 15 +- .../devserver/stats/StatisticsSenderTest.java | 57 +- .../ViteWebsocketConnectionTest.java | 48 +- .../flow/spring/AuthenticationUtil.java | 20 +- .../flow/spring/DevModeBrowserLauncher.java | 38 +- .../flow/spring/ForwardingRequestWrapper.java | 5 +- .../com/vaadin/flow/spring/ReloadCache.java | 4 +- .../com/vaadin/flow/spring/ReloadEvent.java | 8 +- .../vaadin/flow/spring/ReloadListener.java | 6 +- .../flow/spring/RootMappedCondition.java | 43 +- ...SpringApplicationConfigurationFactory.java | 15 +- .../spring/SpringBootAutoConfiguration.java | 19 +- .../spring/SpringDevToolsPortHandler.java | 9 +- .../flow/spring/SpringInstantiator.java | 59 +- .../flow/spring/SpringLookupInitializer.java | 67 +- .../SpringSecurityAutoConfiguration.java | 62 +- .../com/vaadin/flow/spring/SpringServlet.java | 49 +- .../com/vaadin/flow/spring/SpringUtil.java | 6 +- .../spring/SpringVaadinServletService.java | 50 +- .../flow/spring/SpringVaadinSession.java | 12 +- .../flow/spring/SpringViewAccessChecker.java | 25 +- .../VaadinApplicationConfiguration.java | 23 +- .../spring/VaadinConfigurationProperties.java | 136 +- .../spring/VaadinMVCWebAppInitializer.java | 38 +- .../spring/VaadinScanPackagesRegistrar.java | 35 +- .../spring/VaadinServletConfiguration.java | 58 +- .../VaadinServletContextInitializer.java | 621 ++--- .../VaadinWebsocketEndpointExporter.java | 7 +- .../flow/spring/annotation/EnableVaadin.java | 38 +- .../flow/spring/annotation/RouteScope.java | 23 +- .../spring/annotation/RouteScopeOwner.java | 9 +- .../spring/annotation/SpringComponent.java | 8 +- .../spring/data/VaadinSpringDataHelpers.java | 30 +- .../i18n/DefaultI18NProviderFactory.java | 37 +- .../spring/io/FilterableResourceResolver.java | 252 +- .../flow/spring/scopes/AbstractScope.java | 14 +- .../vaadin/flow/spring/scopes/BeanStore.java | 16 +- .../flow/spring/scopes/VaadinRouteScope.java | 115 +- .../spring/scopes/VaadinSessionScope.java | 17 +- .../flow/spring/scopes/VaadinUIScope.java | 24 +- .../security/AuthenticationContext.java | 223 +- .../NavigationAccessControlConfigurer.java | 134 +- .../NavigationAccessControlInitializer.java | 9 +- .../flow/spring/security/RequestUtil.java | 103 +- .../security/SpringAccessPathChecker.java | 36 +- .../SpringNavigationAccessControl.java | 32 +- .../spring/security/UidlRedirectStrategy.java | 19 +- ...dinAwareSecurityContextHolderStrategy.java | 24 +- ...ityContextHolderStrategyConfiguration.java | 7 +- .../security/VaadinDefaultRequestCache.java | 41 +- .../security/VaadinRolePrefixHolder.java | 59 +- ...uestAwareAuthenticationSuccessHandler.java | 149 +- .../VaadinSimpleUrlLogoutSuccessHandler.java | 12 +- .../spring/security/VaadinWebSecurity.java | 304 +-- .../ViewAccessCheckerInitializer.java | 6 +- .../security/WebIconsRequestMatcher.java | 54 +- .../JwtSecurityContextRepository.java | 61 +- .../SerializedJwtSplitCookieRepository.java | 40 +- .../VaadinStatelessSecurityConfigurer.java | 131 +- .../AtmosphereHintsRegistrar.java | 35 +- ...BeanFactoryInitializationAotProcessor.java | 195 +- .../springnative/VaadinHintsRegistrar.java | 45 +- .../AbstractDevModeBrowserLauncherTest.java | 3 +- .../DevModeBrowserLauncherHttpsProtoTest.java | 6 +- ...evModeBrowserLauncherNoPropertiesTest.java | 3 +- ...ModeBrowserLauncherServletMappingTest.java | 3 +- ...erLauncherVaadinAndServletMappingTest.java | 6 +- ...vModeBrowserLauncherVaadinMappingTest.java | 6 +- .../flow/spring/DevModeHandlerStopTest.java | 26 +- .../vaadin/flow/spring/MockVaadinContext.java | 6 +- .../vaadin/flow/spring/PrefixTreeTest.java | 6 +- .../flow/spring/RootMappedConditionTest.java | 3 +- ...ngApplicationConfigurationFactoryTest.java | 31 +- ...gBootAutoConfigurationConditionalTest.java | 18 +- ...ngBootAutoConfigurationRootMappedTest.java | 9 +- ...ingBootAutoConfigurationUrlMappedTest.java | 9 +- .../spring/SpringClassesSerializableTest.java | 24 +- .../spring/SpringLookupInitializerTest.java | 64 +- .../SpringSecurityAutoConfigurationTest.java | 104 +- .../spring/SpringViewAccessCheckerTest.java | 28 +- .../VaadinServletContextInitializerTest.java | 137 +- .../data/VaadinSpringDataHelpersTest.java | 27 +- .../i18n/DefaultI18NProviderFactoryTest.java | 50 +- .../i18n/I18NProviderInstantiationTest.java | 18 +- .../JavaSPIVaadinServiceInitListener.java | 3 +- .../instantiator/SpringInstantiatorTest.java | 155 +- .../io/FilterableResourceResolverTest.java | 72 +- .../flow/spring/scopes/AbstractScopeTest.java | 25 +- .../spring/scopes/AbstractUIScopedTest.java | 19 +- .../spring/scopes/VaadinRouteScopeTest.java | 33 +- .../spring/scopes/VaadinSessionScopeTest.java | 3 +- .../flow/spring/scopes/VaadinUIScopeTest.java | 6 +- .../security/AuthenticationContextTest.java | 191 +- ...NavigationAccessControlConfigurerTest.java | 146 +- .../security/RequestUtilPathAccessTest.java | 82 +- .../flow/spring/security/RequestUtilTest.java | 147 +- .../security/SpringAccessPathCheckerTest.java | 96 +- .../security/UidlRedirectStrategyTest.java | 9 +- ...UrlMappingSpringAccessPathCheckerTest.java | 96 +- ...wareSecurityContextHolderStrategyTest.java | 18 +- .../VaadinDefaultRequestCacheTest.java | 45 +- ...AwareAuthenticationSuccessHandlerTest.java | 151 +- .../security/VaadinWebSecurityTest.java | 37 +- .../security/WebIconsRequestMatcherTest.java | 64 +- .../JwtSecurityContextRepositoryTest.java | 495 ++-- .../JwtStatelessAuthenticationTest.java | 77 +- ...erializedJwtSplitCookieRepositoryTest.java | 124 +- .../TestSecurityContextHolderStrategy.java | 3 +- .../service/MyVaadinServiceInitListener.java | 3 +- .../spring/service/SpringServletTest.java | 3 +- ...adinServletServiceStaticLocationsTest.java | 63 +- .../SpringVaadinServletServiceTest.java | 40 +- .../service/TestServletConfiguration.java | 9 +- 2505 files changed, 45984 insertions(+), 82507 deletions(-) diff --git a/flow-client/src/main/java/com/vaadin/client/ApplicationConfiguration.java b/flow-client/src/main/java/com/vaadin/client/ApplicationConfiguration.java index 09c54b2f819..bd69c3749c0 100644 --- a/flow-client/src/main/java/com/vaadin/client/ApplicationConfiguration.java +++ b/flow-client/src/main/java/com/vaadin/client/ApplicationConfiguration.java @@ -20,8 +20,7 @@ /** * Application configuration data. *

- * This class is effectively immutable although setters exist to assign the - * values during construction. + * This class is effectively immutable although setters exist to assign the values during construction. * * @author Vaadin Ltd * @since 1.0 @@ -127,10 +126,9 @@ public void setWebComponentMode(boolean mode) { } /** - * Gets the UI id of the server-side UI associated with this client-side - * instance. The UI id should be included in every request originating from - * this instance in order to associate the request with the right UI - * instance on the server. + * Gets the UI id of the server-side UI associated with this client-side instance. The UI id should be included in + * every request originating from this instance in order to associate the request with the right UI instance on the + * server. * * @return the UI id */ @@ -139,8 +137,7 @@ public int getUIId() { } /** - * Sets the UI id of the server-side UI associated with this client-side - * instance. + * Sets the UI id of the server-side UI associated with this client-side instance. * * @param uiId * the UI id @@ -152,8 +149,7 @@ public void setUIId(int uiId) { /** * Gets the interval for heartbeat requests. * - * @return The interval in seconds between heartbeat requests, or -1 if - * heartbeat is disabled. + * @return The interval in seconds between heartbeat requests, or -1 if heartbeat is disabled. */ public int getHeartbeatInterval() { return heartbeatInterval; @@ -163,8 +159,7 @@ public int getHeartbeatInterval() { * Sets the interval for heartbeat requests. * * @param heartbeatInterval - * The interval in seconds between heartbeat requests, or -1 if - * heartbeat is disabled. + * The interval in seconds between heartbeat requests, or -1 if heartbeat is disabled. */ public void setHeartbeatInterval(int heartbeatInterval) { this.heartbeatInterval = heartbeatInterval; @@ -173,8 +168,8 @@ public void setHeartbeatInterval(int heartbeatInterval) { /** * Gets the maximum message suspension delay. * - * @return The maximum time, in milliseconds, to suspend out-of-order - * messages waiting for their predecessor before resynchronizing. + * @return The maximum time, in milliseconds, to suspend out-of-order messages waiting for their predecessor before + * resynchronizing. */ public int getMaxMessageSuspendTimeout() { return maxMessageSuspendTimeout; @@ -184,8 +179,8 @@ public int getMaxMessageSuspendTimeout() { * Sets the maximum message suspension delay. * * @param maxMessageSuspendTimeout - * The maximum time, in milliseconds, to suspend out-of-order - * messages waiting for their predecessor before resynchronizing. + * The maximum time, in milliseconds, to suspend out-of-order messages waiting for their predecessor + * before resynchronizing. */ public void setMaxMessageSuspendTimeout(int maxMessageSuspendTimeout) { this.maxMessageSuspendTimeout = maxMessageSuspendTimeout; @@ -270,13 +265,11 @@ public void setAtmosphereJSVersion(String atmosphereJSVersion) { /** * Checks if we are running in production mode. *

- * With production mode disabled, a lot more information is logged to the - * browser console. In production you should always enable production mode, - * because logging and other debug features can have a significant - * performance impact. + * With production mode disabled, a lot more information is logged to the browser console. In production you should + * always enable production mode, because logging and other debug features can have a significant performance + * impact. * - * @return {@code true} if production mode is enabled, {@code false} - * otherwise + * @return {@code true} if production mode is enabled, {@code false} otherwise */ public boolean isProductionMode() { return productionMode; @@ -285,8 +278,7 @@ public boolean isProductionMode() { /** * Checks if request timing info should be made available. * - * @return {@code true} if request timing info should be made availble, - * {@code false} otherwise + * @return {@code true} if request timing info should be made availble, {@code false} otherwise */ public boolean isRequestTiming() { return requestTiming; @@ -295,14 +287,12 @@ public boolean isRequestTiming() { /** * Sets whether we are running in production mode. *

- * With production mode disabled, a lot more information is logged to the - * browser console. In production you should always enable production mode, - * because logging and other debug features can have a significant - * performance impact. + * With production mode disabled, a lot more information is logged to the browser console. In production you should + * always enable production mode, because logging and other debug features can have a significant performance + * impact. * * @param productionMode - * {@code true} if production mode is enabled, {@code false} - * otherwise + * {@code true} if production mode is enabled, {@code false} otherwise */ public void setProductionMode(boolean productionMode) { this.productionMode = productionMode; @@ -313,8 +303,7 @@ public void setProductionMode(boolean productionMode) { * Sets whether request timing info should be made available. * * @param requestTiming - * {@code true} if request timing info should be made available, - * {@code false} otherwise + * {@code true} if request timing info should be made available, {@code false} otherwise */ public void setRequestTiming(boolean requestTiming) { this.requestTiming = requestTiming; diff --git a/flow-client/src/main/java/com/vaadin/client/ApplicationConnection.java b/flow-client/src/main/java/com/vaadin/client/ApplicationConnection.java index 1f3db48ce8c..0d138979a0b 100644 --- a/flow-client/src/main/java/com/vaadin/client/ApplicationConnection.java +++ b/flow-client/src/main/java/com/vaadin/client/ApplicationConnection.java @@ -52,12 +52,10 @@ public class ApplicationConnection { * @param applicationConfiguration * the configuration object for the application */ - public ApplicationConnection( - ApplicationConfiguration applicationConfiguration) { + public ApplicationConnection(ApplicationConfiguration applicationConfiguration) { registry = new DefaultRegistry(this, applicationConfiguration); - GWT.setUncaughtExceptionHandler( - registry.getSystemErrorHandler()::handleError); + GWT.setUncaughtExceptionHandler(registry.getSystemErrorHandler()::handleError); StateNode rootNode = registry.getStateTree().getRootNode(); @@ -71,8 +69,7 @@ public ApplicationConnection( rootNode.setDomNode(body); Binder.bind(rootNode, body); - Console.log("Starting application " - + applicationConfiguration.getApplicationId()); + Console.log("Starting application " + applicationConfiguration.getApplicationId()); String appRootPanelName = applicationConfiguration.getApplicationId(); // remove the end (window name) of autogenerated rootpanel id @@ -80,16 +77,12 @@ public ApplicationConnection( boolean productionMode = applicationConfiguration.isProductionMode(); boolean requestTiming = applicationConfiguration.isRequestTiming(); - publishJavascriptMethods(appRootPanelName, productionMode, - requestTiming, + publishJavascriptMethods(appRootPanelName, productionMode, requestTiming, applicationConfiguration.getExportedWebComponents()); if (!productionMode) { - String servletVersion = applicationConfiguration - .getServletVersion(); - publishDevelopmentModeJavascriptMethods(appRootPanelName, - servletVersion); - Console.log( - "Vaadin application servlet version: " + servletVersion); + String servletVersion = applicationConfiguration.getServletVersion(); + publishDevelopmentModeJavascriptMethods(appRootPanelName, servletVersion); + Console.log("Vaadin application servlet version: " + servletVersion); } ConnectionIndicator.setState(ConnectionIndicator.LOADING); @@ -98,8 +91,7 @@ public ApplicationConnection( /** * Starts this application. *

- * Called by the bootstrapper, which ensures applications are started in - * order. + * Called by the bootstrapper, which ensures applications are started in order. * * @param initialUidl * the initial UIDL or null if the server did not provide any @@ -139,8 +131,7 @@ public void start(ValueMap initialUidl) { */ private boolean isActive() { return !registry.getMessageHandler().isInitialUidlHandled() - || registry.getRequestResponseTracker().hasActiveRequest() - || isExecutingDeferredCommands(); + || registry.getRequestResponseTracker().hasActiveRequest() || isExecutingDeferredCommands(); } /** @@ -149,16 +140,13 @@ private boolean isActive() { * @param applicationId * the application id provided by the server * @param productionMode - * true if running in production mode, - * false otherwise + * true if running in production mode, false otherwise * @param requestTiming - * true if request timing info should be made - * available, false otherwise + * true if request timing info should be made available, false otherwise * @param exportedWebComponents * a list of web component tags exported by this UI */ - private native void publishJavascriptMethods(String applicationId, - boolean productionMode, boolean requestTiming, + private native void publishJavascriptMethods(String applicationId, boolean productionMode, boolean requestTiming, String[] exportedWebComponents) /*-{ var ap = this; @@ -231,9 +219,7 @@ private Node getDomElementByNodeId(int id) { private String getJavaClass(int id) { StateNode node = registry.getStateTree().getNode(id); return node == null ? null - : node.getMap(NodeFeatures.ELEMENT_DATA) - .getProperty(NodeProperties.JAVA_CLASS) - .getValueOrDefault(null); + : node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.JAVA_CLASS).getValueOrDefault(null); } public static final class Styles extends JavaScriptObject { @@ -250,14 +236,10 @@ private JavaScriptObject getElementStyleProperties(int id) { StateNode node = registry.getStateTree().getNode(id); Styles styles = JavaScriptObject.createObject().cast(); if (node != null) { - JsArray names = node - .getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES) - .getPropertyNames(); + JsArray names = node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES).getPropertyNames(); for (int i = 0; i < names.length(); i++) { String name = names.get(i); - styles.set(name, - node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES) - .getProperty(name).getValue()); + styles.set(name, node.getMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES).getProperty(name).getValue()); } } @@ -265,16 +247,14 @@ private JavaScriptObject getElementStyleProperties(int id) { } private int getNodeId(Element element) { - StateNode node = registry.getStateTree() - .getStateNodeForDomNode(DomApi.wrap(element)); + StateNode node = registry.getStateTree().getStateNodeForDomNode(DomApi.wrap(element)); return node == null ? -1 : node.getId(); } private void addDomSetListener(int nodeId, JavaScriptObject callback) { registry.getStateTree().getNode(nodeId).addDomNodeSetListener(node -> { if (nodeId == node.getId()) { - NativeFunction function = NativeFunction.create("callback", - "callback();"); + NativeFunction function = NativeFunction.create("callback", "callback();"); function.call(null, callback); return true; } @@ -288,8 +268,7 @@ private void addDomSetListener(int nodeId, JavaScriptObject callback) { * @param applicationId * the application id provided by the server */ - private native void publishDevelopmentModeJavascriptMethods( - String applicationId, String servletVersion) + private native void publishDevelopmentModeJavascriptMethods(String applicationId, String servletVersion) /*-{ var ap = this; var client = $wnd.Vaadin.Flow.clients[applicationId]; @@ -314,16 +293,14 @@ private native void publishDevelopmentModeJavascriptMethods( }-*/; /** - * Checks if deferred commands are (potentially) still being executed as a - * result of an update from the server. Returns true if a deferred command - * might still be executing, false otherwise. This will not work correctly - * if a deferred command is added in another deferred command. + * Checks if deferred commands are (potentially) still being executed as a result of an update from the server. + * Returns true if a deferred command might still be executing, false otherwise. This will not work correctly if a + * deferred command is added in another deferred command. *

* Used by the native "client.isActive" function. *

* - * @return true if deferred commands are (potentially) being executed, false - * otherwise + * @return true if deferred commands are (potentially) being executed, false otherwise */ private boolean isExecutingDeferredCommands() { Scheduler s = Scheduler.get(); diff --git a/flow-client/src/main/java/com/vaadin/client/BrowserInfo.java b/flow-client/src/main/java/com/vaadin/client/BrowserInfo.java index 746c68f3abf..5e57ed8597f 100644 --- a/flow-client/src/main/java/com/vaadin/client/BrowserInfo.java +++ b/flow-client/src/main/java/com/vaadin/client/BrowserInfo.java @@ -21,8 +21,7 @@ /** * Provides a way to query information about web browser. * - * Browser details are detected only once and those are stored in this singleton - * class. + * Browser details are detected only once and those are stored in this singleton class. * * @since 1.0 */ @@ -131,8 +130,7 @@ public boolean isSafari() { } /** - * Checks if the browser is Safari or runs on IOS (covering also Chrome on - * iOS). + * Checks if the browser is Safari or runs on IOS (covering also Chrome on iOS). * * @return true if the browser is Safari or running on IOS, false otherwise */ @@ -168,8 +166,8 @@ public boolean isWebkit() { } /** - * Returns the Gecko version if the browser is Gecko based. The Gecko - * version for Firefox 2 is 1.8 and 1.9 for Firefox 3. + * Returns the Gecko version if the browser is Gecko based. The Gecko version for Firefox 2 is 1.8 and 1.9 for + * Firefox 3. * * @return The Gecko version or -1 if the browser is not Gecko based */ @@ -182,8 +180,8 @@ public float getGeckoVersion() { } /** - * Returns the WebKit version if the browser is WebKit based. The WebKit - * version returned is the major version e.g., 523. + * Returns the WebKit version if the browser is WebKit based. The WebKit version returned is the major version e.g., + * 523. * * @return The WebKit version or -1 if the browser is not WebKit based */ @@ -234,15 +232,12 @@ public boolean isAndroid() { } /** - * Tests if this is an Android devices with a broken scrollTop - * implementation. + * Tests if this is an Android devices with a broken scrollTop implementation. * - * @return true if scrollTop cannot be trusted on this device, false - * otherwise + * @return true if scrollTop cannot be trusted on this device, false otherwise */ public boolean isAndroidWithBrokenScrollTop() { - return isAndroid() && (getOperatingSystemMajorVersion() == 3 - || getOperatingSystemMajorVersion() == 4); + return isAndroid() && (getOperatingSystemMajorVersion() == 3 || getOperatingSystemMajorVersion() == 4); } private int getOperatingSystemMajorVersion() { @@ -250,11 +245,9 @@ private int getOperatingSystemMajorVersion() { } /** - * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome - * 4, 8 for Internet Explorer 8. + * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8. *

- * Note that Internet Explorer 8 and newer will return the document mode so - * IE8 rendering as IE7 will return 7. + * Note that Internet Explorer 8 and newer will return the document mode so IE8 rendering as IE7 will return 7. *

* * @return The major version of the browser. diff --git a/flow-client/src/main/java/com/vaadin/client/ConnectionIndicator.java b/flow-client/src/main/java/com/vaadin/client/ConnectionIndicator.java index 1e1ccf39bb6..ee3cd93bb28 100644 --- a/flow-client/src/main/java/com/vaadin/client/ConnectionIndicator.java +++ b/flow-client/src/main/java/com/vaadin/client/ConnectionIndicator.java @@ -29,30 +29,28 @@ public class ConnectionIndicator { */ /** - * Application is connected to server: last transaction over the wire (XHR / - * heartbeat / endpoint call) was successful. + * Application is connected to server: last transaction over the wire (XHR / heartbeat / endpoint call) was + * successful. */ public static final String CONNECTED = "connected"; /** - * Application is connected and Flow is loading application state from the - * server, or Fusion is waiting for an endpoint call to return. + * Application is connected and Flow is loading application state from the server, or Fusion is waiting for an + * endpoint call to return. */ public static final String LOADING = "loading"; /** - * Application has been temporarily disconnected from the server because the - * last transaction over the wire (XHR / heartbeat / endpoint call) resulted - * in a network error, or the browser has received the 'online' event and - * needs to verify reconnection with the server. Flow is attempting to - * reconnect a configurable number of times before giving up. + * Application has been temporarily disconnected from the server because the last transaction over the wire (XHR / + * heartbeat / endpoint call) resulted in a network error, or the browser has received the 'online' event and needs + * to verify reconnection with the server. Flow is attempting to reconnect a configurable number of times before + * giving up. */ public static final String RECONNECTING = "reconnecting"; /** - * Application has been permanently disconnected due to browser receiving - * the 'offline' event, or the server not being reached after a number of - * reconnect attempts. + * Application has been permanently disconnected due to browser receiving the 'offline' event, or the server not + * being reached after a number of reconnect attempts. */ public static final String CONNECTION_LOST = "connection-lost"; diff --git a/flow-client/src/main/java/com/vaadin/client/Console.java b/flow-client/src/main/java/com/vaadin/client/Console.java index 878d74c822c..5a7581014da 100644 --- a/flow-client/src/main/java/com/vaadin/client/Console.java +++ b/flow-client/src/main/java/com/vaadin/client/Console.java @@ -22,8 +22,8 @@ import elemental.client.Browser; /** - * Helper class for using window.console. Does not log anything except - * JavaScript exception traces to console if production mode is enabled. + * Helper class for using window.console. Does not log anything except JavaScript exception traces to console if + * production mode is enabled. * * @author Vaadin Ltd * @since 1.0 @@ -41,8 +41,7 @@ private Console() { } /** - * Changes logger behavior, making it skip all browser logging for - * production mode. + * Changes logger behavior, making it skip all browser logging for production mode. * * @param isProductionMode * if an application is in the production mode or not @@ -52,11 +51,9 @@ public static void setProductionMode(boolean isProductionMode) { } /** - * If not in production mode, logs the given message to the browser console - * using the debug log level. + * If not in production mode, logs the given message to the browser console using the debug log level. *

- * If used directly in a JVM, writes the message to standard output - * disregarding of the production mode settings. + * If used directly in a JVM, writes the message to standard output disregarding of the production mode settings. * * @param message * the message to log @@ -72,11 +69,9 @@ public static void debug(Object message) { } /** - * If not in production mode, logs the given message to the browser console - * using the info log level. + * If not in production mode, logs the given message to the browser console using the info log level. *

- * If used directly in a JVM, writes the message to standard output - * disregarding of the production mode settings. + * If used directly in a JVM, writes the message to standard output disregarding of the production mode settings. * * @param message * the message to log @@ -92,11 +87,9 @@ public static void log(Object message) { } /** - * If not in production mode, logs the given message to the browser console - * using the warning log level. + * If not in production mode, logs the given message to the browser console using the warning log level. *

- * If used directly in a JVM, writes the message to standard error - * disregarding of the production mode settings. + * If used directly in a JVM, writes the message to standard error disregarding of the production mode settings. * * @param message * the message to log @@ -112,11 +105,9 @@ public static void warn(Object message) { } /** - * If not in production mode, logs the given message to the browser console - * using the error log level. + * If not in production mode, logs the given message to the browser console using the error log level. *

- * If used directly in a JVM, writes the message to standard error - * disregarding of the production mode settings. + * If used directly in a JVM, writes the message to standard error disregarding of the production mode settings. * * @param message * the message to log @@ -132,9 +123,8 @@ public static void error(Object message) { } /** - * Logs the stacktrace of an exception to the browser console. Logging is - * done asynchronously since that approach allows reporting it with highest - * possible fidelity. + * Logs the stacktrace of an exception to the browser console. Logging is done asynchronously since that approach + * allows reporting it with highest possible fidelity. * * @param exception * the exception for which @@ -151,10 +141,8 @@ private static void doReportStacktrace(Exception exception) { // Defer without $entry to bypass some of GWT's exception handling deferWithoutEntry(() -> { // Bypass regular exception reporting - UncaughtExceptionHandler originalHandler = GWT - .getUncaughtExceptionHandler(); - GWT.setUncaughtExceptionHandler( - ignore -> GWT.setUncaughtExceptionHandler(originalHandler)); + UncaughtExceptionHandler originalHandler = GWT.getUncaughtExceptionHandler(); + GWT.setUncaughtExceptionHandler(ignore -> GWT.setUncaughtExceptionHandler(originalHandler)); // Throw in the appropriate way if (exception instanceof JavaScriptException) { diff --git a/flow-client/src/main/java/com/vaadin/client/DefaultRegistry.java b/flow-client/src/main/java/com/vaadin/client/DefaultRegistry.java index 174577059a3..b9a26e239b2 100644 --- a/flow-client/src/main/java/com/vaadin/client/DefaultRegistry.java +++ b/flow-client/src/main/java/com/vaadin/client/DefaultRegistry.java @@ -42,16 +42,14 @@ public class DefaultRegistry extends Registry { /** - * Constructs a registry based on the given application connection and - * configuration references. + * Constructs a registry based on the given application connection and configuration references. * * @param connection * the application connection * @param applicationConfiguration * the application configuration */ - public DefaultRegistry(ApplicationConnection connection, - ApplicationConfiguration applicationConfiguration) { + public DefaultRegistry(ApplicationConnection connection, ApplicationConfiguration applicationConfiguration) { // Note that initialization order matters. Many constructors depend on // ApplicationConnection, ApplicationConfiguration and StateTree even // though this is not explicitly specified anywhere. @@ -71,17 +69,14 @@ public DefaultRegistry(ApplicationConnection connection, set(MessageSender.class, new MessageSender(this)); set(ServerRpcQueue.class, new ServerRpcQueue(this)); set(ServerConnector.class, new ServerConnector(this)); - set(ExecuteJavaScriptProcessor.class, - new ExecuteJavaScriptProcessor(this)); + set(ExecuteJavaScriptProcessor.class, new ExecuteJavaScriptProcessor(this)); set(ConstantPool.class, (Supplier) ConstantPool::new); - set(ExistingElementMap.class, - (Supplier) ExistingElementMap::new); + set(ExistingElementMap.class, (Supplier) ExistingElementMap::new); set(InitialPropertiesHandler.class, new InitialPropertiesHandler(this)); // Classes with dependencies, in correct order set(Heartbeat.class, new Heartbeat(this)); - set(ConnectionStateHandler.class, - new DefaultConnectionStateHandler(this)); + set(ConnectionStateHandler.class, new DefaultConnectionStateHandler(this)); set(XhrConnection.class, new XhrConnection(this)); set(PushConfiguration.class, new PushConfiguration(this)); set(ReconnectConfiguration.class, new ReconnectConfiguration(this)); diff --git a/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java b/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java index 1706ffe5b38..fff8215d464 100644 --- a/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java +++ b/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java @@ -49,8 +49,7 @@ public void onLoad(ResourceLoadEvent event) { @Override public void onError(ResourceLoadEvent event) { - Console.error( - "'" + event.getResourceData() + "' could not be loaded."); + Console.error("'" + event.getResourceData() + "' could not be loaded."); // The show must go on onLoad(event); } @@ -84,23 +83,19 @@ public DependencyLoader(Registry registry) { this.registry = registry; } - private void loadLazyDependency(String dependencyUrl, - final BiConsumer loader) { + private void loadLazyDependency(String dependencyUrl, final BiConsumer loader) { loader.accept(dependencyUrl, LAZY_RESOURCE_LOAD_LISTENER); } - private void loadDependencyEagerly(String data, - final BiConsumer loader) { + private void loadDependencyEagerly(String data, final BiConsumer loader) { startEagerDependencyLoading(); loader.accept(data, EAGER_RESOURCE_LOAD_LISTENER); } /** - * Adds a command to be run when all eager dependencies have finished - * loading. + * Adds a command to be run when all eager dependencies have finished loading. *

- * If no eager dependencies are currently being loaded, runs the command - * immediately. + * If no eager dependencies are currently being loaded, runs the command immediately. * * @see #startEagerDependencyLoading() * @see #endEagerDependencyLoading() @@ -128,8 +123,8 @@ private static void startEagerDependencyLoading() { /** * Marks that loading of a dependency has ended. *

- * If all pending dependencies have been loaded, calls any callback - * registered using {@link #runWhenEagerDependenciesLoaded(Command)}. + * If all pending dependencies have been loaded, calls any callback registered using + * {@link #runWhenEagerDependenciesLoaded(Command)}. */ private static void endEagerDependencyLoading() { eagerDependenciesLoading--; @@ -149,19 +144,16 @@ private static void endEagerDependencyLoading() { * Triggers loading of the given dependencies. * * @param clientDependencies - * the map of the dependencies to load, divided into groups by - * load mode, not {@code null}. + * the map of the dependencies to load, divided into groups by load mode, not {@code null}. */ - public void loadDependencies( - JsMap clientDependencies) { + public void loadDependencies(JsMap clientDependencies) { assert clientDependencies != null; - JsMap> lazyDependencies = JsCollections - .map(); + JsMap> lazyDependencies = JsCollections.map(); clientDependencies.forEach((dependencies, mode) -> { - extractLazyDependenciesAndLoadOthers(mode, dependencies).forEach( - (loader, url) -> lazyDependencies.set(url, loader)); + extractLazyDependenciesAndLoadOthers(mode, dependencies) + .forEach((loader, url) -> lazyDependencies.set(url, loader)); }); // postpone load dependencies execution after the browser event @@ -169,49 +161,36 @@ public void loadDependencies( // run after the eager dependencies so that lazy dependencies // don't block those commands if (!lazyDependencies.isEmpty()) { - runWhenEagerDependenciesLoaded( - () -> Scheduler.get().scheduleDeferred(() -> { - Console.log( - "Finished loading eager dependencies, loading lazy."); - lazyDependencies.forEach((loader, - url) -> loadLazyDependency(url, loader)); - })); + runWhenEagerDependenciesLoaded(() -> Scheduler.get().scheduleDeferred(() -> { + Console.log("Finished loading eager dependencies, loading lazy."); + lazyDependencies.forEach((loader, url) -> loadLazyDependency(url, loader)); + })); } } private JsMap> extractLazyDependenciesAndLoadOthers( LoadMode loadMode, JsonArray dependencies) { - JsMap> lazyDependencies = JsCollections - .map(); + JsMap> lazyDependencies = JsCollections.map(); for (int i = 0; i < dependencies.length(); i++) { JsonObject dependencyJson = dependencies.getObject(i); - Dependency.Type type = Dependency.Type - .valueOf(dependencyJson.getString(Dependency.KEY_TYPE)); - BiConsumer resourceLoader = getResourceLoader( - type, loadMode); + Dependency.Type type = Dependency.Type.valueOf(dependencyJson.getString(Dependency.KEY_TYPE)); + BiConsumer resourceLoader = getResourceLoader(type, loadMode); if (type == Dependency.Type.DYNAMIC_IMPORT) { - loadDependencyEagerly( - dependencyJson.getString(Dependency.KEY_URL), - resourceLoader); + loadDependencyEagerly(dependencyJson.getString(Dependency.KEY_URL), resourceLoader); } else { switch (loadMode) { case EAGER: - loadDependencyEagerly(getDependencyUrl(dependencyJson), - resourceLoader); + loadDependencyEagerly(getDependencyUrl(dependencyJson), resourceLoader); break; case LAZY: - lazyDependencies.set(getDependencyUrl(dependencyJson), - resourceLoader); + lazyDependencies.set(getDependencyUrl(dependencyJson), resourceLoader); break; case INLINE: - loadDependencyEagerly( - dependencyJson.getString(Dependency.KEY_CONTENTS), - resourceLoader); + loadDependencyEagerly(dependencyJson.getString(Dependency.KEY_CONTENTS), resourceLoader); break; default: - throw new IllegalArgumentException( - "Unknown load mode = " + loadMode); + throw new IllegalArgumentException("Unknown load mode = " + loadMode); } } } @@ -219,12 +198,11 @@ private JsMap> extractLazyDepen } private String getDependencyUrl(JsonObject dependencyJson) { - return registry.getURIResolver() - .resolveVaadinUri(dependencyJson.getString(Dependency.KEY_URL)); + return registry.getURIResolver().resolveVaadinUri(dependencyJson.getString(Dependency.KEY_URL)); } - private BiConsumer getResourceLoader( - Dependency.Type resourceType, LoadMode loadMode) { + private BiConsumer getResourceLoader(Dependency.Type resourceType, + LoadMode loadMode) { ResourceLoader resourceLoader = registry.getResourceLoader(); boolean inline = loadMode == LoadMode.INLINE; @@ -238,30 +216,27 @@ private BiConsumer getResourceLoader( if (inline) { return resourceLoader::inlineScript; } - return (scriptUrl, resourceLoadListener) -> resourceLoader - .loadScript(scriptUrl, resourceLoadListener, false, true); + return (scriptUrl, resourceLoadListener) -> resourceLoader.loadScript(scriptUrl, resourceLoadListener, + false, true); case JS_MODULE: if (inline) { - throw new IllegalArgumentException( - "Inline load mode is not supported for JsModule."); + throw new IllegalArgumentException("Inline load mode is not supported for JsModule."); } - return (scriptUrl, resourceLoadListener) -> resourceLoader - .loadJsModule(scriptUrl, resourceLoadListener, false, true); + return (scriptUrl, resourceLoadListener) -> resourceLoader.loadJsModule(scriptUrl, resourceLoadListener, + false, true); case DYNAMIC_IMPORT: return resourceLoader::loadDynamicImport; default: - throw new IllegalArgumentException( - "Unknown dependency type " + resourceType); + throw new IllegalArgumentException("Unknown dependency type " + resourceType); } } /** - * Prevents eager dependencies from being considered as loaded until - * HTMLImports.whenReady has been run. + * Prevents eager dependencies from being considered as loaded until HTMLImports.whenReady has been + * run. */ public void requireHtmlImportsReady() { startEagerDependencyLoading(); - registry.getResourceLoader().runWhenHtmlImportsReady( - DependencyLoader::endEagerDependencyLoading); + registry.getResourceLoader().runWhenHtmlImportsReady(DependencyLoader::endEagerDependencyLoading); } } diff --git a/flow-client/src/main/java/com/vaadin/client/ElementUtil.java b/flow-client/src/main/java/com/vaadin/client/ElementUtil.java index d9f6e3c78f0..37c7d98e8e2 100644 --- a/flow-client/src/main/java/com/vaadin/client/ElementUtil.java +++ b/flow-client/src/main/java/com/vaadin/client/ElementUtil.java @@ -39,20 +39,18 @@ private ElementUtil() { * @return {@code true} if the node has required tag name */ public static boolean hasTag(Node node, String tag) { - return node instanceof Element - && tag.equalsIgnoreCase(((Element) node).getTagName()); + return node instanceof Element && tag.equalsIgnoreCase(((Element) node).getTagName()); } /** - * Searches the shadow root of the given context element for the given id or - * searches the light DOM if the element has no shadow root. + * Searches the shadow root of the given context element for the given id or searches the light DOM if the element + * has no shadow root. * * @param context * the container element to search through * @param id * the identifier of the element to search for - * @return the element with the given {@code id} if found, otherwise - * null + * @return the element with the given {@code id} if found, otherwise null */ public static native Element getElementById(Node context, String id) /*-{ diff --git a/flow-client/src/main/java/com/vaadin/client/ExecuteJavaScriptElementUtils.java b/flow-client/src/main/java/com/vaadin/client/ExecuteJavaScriptElementUtils.java index b1fc969bb3a..1c2bf12b1af 100644 --- a/flow-client/src/main/java/com/vaadin/client/ExecuteJavaScriptElementUtils.java +++ b/flow-client/src/main/java/com/vaadin/client/ExecuteJavaScriptElementUtils.java @@ -45,8 +45,7 @@ private ExecuteJavaScriptElementUtils() { } /** - * Calculate the data required for server side callback to attach existing - * element and send it to the server. + * Calculate the data required for server side callback to attach existing element and send it to the server. * * @param parent * the parent node whose child is requested to attach @@ -55,14 +54,12 @@ private ExecuteJavaScriptElementUtils() { * @param tagName * the tag name of the element requested to attach * @param id - * the identifier of the server side node which is requested to - * be a counterpart of the client side element + * the identifier of the server side node which is requested to be a counterpart of the client side + * element */ - public static void attachExistingElement(StateNode parent, - Element previousSibling, String tagName, int id) { + public static void attachExistingElement(StateNode parent, Element previousSibling, String tagName, int id) { Element existingElement = null; - JsArray childNodes = DomApi.wrap(parent.getDomNode()) - .getChildNodes(); + JsArray childNodes = DomApi.wrap(parent.getDomNode()).getChildNodes(); JsMap indices = new JsMap<>(); boolean afterSibling = previousSibling == null; int elementIndex = -1; @@ -81,8 +78,7 @@ public static void attachExistingElement(StateNode parent, if (existingElement == null) { // report an error - parent.getTree().sendExistingElementAttachToServer(parent, id, -1, - tagName, -1); + parent.getTree().sendExistingElementAttachToServer(parent, id, -1, tagName, -1); } else { NodeList list = parent.getList(NodeFeatures.ELEMENT_CHILDREN); Integer existingId = null; @@ -101,37 +97,31 @@ public static void attachExistingElement(StateNode parent, } } - existingId = getExistingIdOrUpdate(parent, id, existingElement, - existingId); + existingId = getExistingIdOrUpdate(parent, id, existingElement, existingId); - parent.getTree().sendExistingElementAttachToServer(parent, id, - existingId, existingElement.getTagName(), childIndex); + parent.getTree().sendExistingElementAttachToServer(parent, id, existingId, existingElement.getTagName(), + childIndex); } } private static boolean hasTag(Node node, String tag) { - return node instanceof Element - && tag.equalsIgnoreCase(((Element) node).getTagName()); + return node instanceof Element && tag.equalsIgnoreCase(((Element) node).getTagName()); } /** - * Populate model {@code properties}: add them into - * {@literal NodeFeatures.ELEMENT_PROPERTIES} {@link NodeMap} if they are - * not defined by the client-side element or send their client-side value to - * the server otherwise. + * Populate model {@code properties}: add them into {@literal NodeFeatures.ELEMENT_PROPERTIES} {@link NodeMap} if + * they are not defined by the client-side element or send their client-side value to the server otherwise. * * @param node * the node whose properties should be populated * @param properties * array of property names to populate */ - public static void populateModelProperties(StateNode node, - JsArray properties) { + public static void populateModelProperties(StateNode node, JsArray properties) { NodeMap map = node.getMap(NodeFeatures.ELEMENT_PROPERTIES); if (node.getDomNode() == null) { PolymerUtils.invokeWhenDefined(PolymerUtils.getTag(node), - () -> Reactive.addPostFlushListener( - () -> populateModelProperties(node, properties))); + () -> Reactive.addPostFlushListener(() -> populateModelProperties(node, properties))); return; } for (int i = 0; i < properties.length(); i++) { @@ -139,51 +129,43 @@ public static void populateModelProperties(StateNode node, } } - private static void populateModelProperty(StateNode node, NodeMap map, - String property) { + private static void populateModelProperty(StateNode node, NodeMap map, String property) { if (!isPropertyDefined(node.getDomNode(), property)) { if (!map.hasPropertyValue(property)) { map.getProperty(property).setValue(null); } } else { - UpdatableModelProperties updatableProperties = node - .getNodeData(UpdatableModelProperties.class); - if (updatableProperties == null - || !updatableProperties.isUpdatableProperty(property)) { + UpdatableModelProperties updatableProperties = node.getNodeData(UpdatableModelProperties.class); + if (updatableProperties == null || !updatableProperties.isUpdatableProperty(property)) { return; } - map.getProperty(property).syncToServer( - WidgetUtil.getJsProperty(node.getDomNode(), property)); + map.getProperty(property).syncToServer(WidgetUtil.getJsProperty(node.getDomNode(), property)); } } /** * Register the updatable model properties of the {@code node}. *

- * Only updates for the properties from the {@code properties} array will be - * sent to the server without explicit synchronization. The - * {@code properties} array includes all properties that are allowed to be - * updated (including sub properties). + * Only updates for the properties from the {@code properties} array will be sent to the server without explicit + * synchronization. The {@code properties} array includes all properties that are allowed to be updated (including + * sub properties). * * @param node * the node whose updatable properties should be registered * @param properties * all updatable model properties */ - public static void registerUpdatableModelProperties(StateNode node, - JsArray properties) { + public static void registerUpdatableModelProperties(StateNode node, JsArray properties) { if (!properties.isEmpty()) { - UpdatableModelProperties data = new UpdatableModelProperties( - properties); + UpdatableModelProperties data = new UpdatableModelProperties(properties); node.setNodeData(data); } } - private static Integer getExistingIdOrUpdate(StateNode parent, - int serverSideId, Element existingElement, Integer existingId) { + private static Integer getExistingIdOrUpdate(StateNode parent, int serverSideId, Element existingElement, + Integer existingId) { if (existingId == null) { - ExistingElementMap map = parent.getTree().getRegistry() - .getExistingElementMap(); + ExistingElementMap map = parent.getTree().getRegistry().getExistingElementMap(); Integer fromMap = map.getId(existingElement); if (fromMap == null) { map.add(serverSideId, existingElement); diff --git a/flow-client/src/main/java/com/vaadin/client/ExistingElementMap.java b/flow-client/src/main/java/com/vaadin/client/ExistingElementMap.java index 3c4df54aa3c..ae9a345673b 100644 --- a/flow-client/src/main/java/com/vaadin/client/ExistingElementMap.java +++ b/flow-client/src/main/java/com/vaadin/client/ExistingElementMap.java @@ -22,8 +22,7 @@ import elemental.dom.Element; /** - * Mapping between a server side node identifier which has been requested to - * attach existing client side element. + * Mapping between a server side node identifier which has been requested to attach existing client side element. * * @author Vaadin Ltd * @since 1.0 @@ -37,26 +36,22 @@ public class ExistingElementMap { private final JsArray idToElement = JsCollections.array(); /** - * Gets the element stored via the {@link #add(int, Element)} method by the - * given {@code id}. + * Gets the element stored via the {@link #add(int, Element)} method by the given {@code id}. * * @param id * identifier associated with an element - * @return the element associated with the {@code id} or null if it doesn't - * exist + * @return the element associated with the {@code id} or null if it doesn't exist */ public Element getElement(int id) { return idToElement.get(id); } /** - * Gets the id stored via the {@link #add(int, Element)} method by the given - * {@code element}. + * Gets the id stored via the {@link #add(int, Element)} method by the given {@code element}. * * @param element * element associated with an identifier - * @return the identifier associated with the {@code element} or null if it - * doesn't exist + * @return the identifier associated with the {@code element} or null if it doesn't exist */ public Integer getId(Element element) { return elementToId.get(element); diff --git a/flow-client/src/main/java/com/vaadin/client/InitialPropertiesHandler.java b/flow-client/src/main/java/com/vaadin/client/InitialPropertiesHandler.java index 151dbbbb899..5640440b480 100644 --- a/flow-client/src/main/java/com/vaadin/client/InitialPropertiesHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/InitialPropertiesHandler.java @@ -27,15 +27,12 @@ import com.vaadin.flow.internal.nodefeature.NodeFeatures; /** - * Handles server initial property values with the purpose to prevent change - * their values from the client side. + * Handles server initial property values with the purpose to prevent change their values from the client side. *

- * Initial property values have to be set from the server side. Client side may - * have default values which override server side values and those values are - * sent to the server (overriding server side values). This class prevents this. - * Only properties that have not been set form the server are sent from the - * client to the server. Properties that have been set from the server overrides - * any client side default value. + * Initial property values have to be set from the server side. Client side may have default values which override + * server side values and those values are sent to the server (overriding server side values). This class prevents this. + * Only properties that have not been set form the server are sent from the client to the server. Properties that have + * been set from the server overrides any client side default value. * * @author Vaadin Ltd * @since 1.0 @@ -48,8 +45,7 @@ public class InitialPropertiesHandler { private final JsSet newNodeDuringUpdate = JsCollections.set(); - private final JsArray propertyUpdateQueue = JsCollections - .array(); + private final JsArray propertyUpdateQueue = JsCollections.array(); /** * Creates a new instance connected to the given registry. @@ -62,17 +58,14 @@ public InitialPropertiesHandler(Registry registry) { } /** - * Flushes collected property update queue (requested to be sent from the - * client to the server). + * Flushes collected property update queue (requested to be sent from the client to the server). *

- * Supposed to be called in the end of {@link TreeChangeProcessor} changes - * processing. + * Supposed to be called in the end of {@link TreeChangeProcessor} changes processing. */ public void flushPropertyUpdates() { if (!getRegistry().getStateTree().isUpdateInProgress()) { JsMap> map = JsCollections.map(); - newNodeDuringUpdate - .forEach(node -> collectInitialProperties(node, map)); + newNodeDuringUpdate.forEach(node -> collectInitialProperties(node, map)); Reactive.addPostFlushListener(() -> doFlushPropertyUpdates(map)); } } @@ -80,8 +73,7 @@ public void flushPropertyUpdates() { /** * Notifies the handler about registered node. *

- * The method is called for the newly created {@code node} which is - * registered in the {@code StateTree}. + * The method is called for the newly created {@code node} which is registered in the {@code StateTree}. * * @param node * the registered node @@ -91,17 +83,14 @@ public void nodeRegistered(StateNode node) { } /** - * Handles {@code property} update request before it's sent to the server - * via RPC. + * Handles {@code property} update request before it's sent to the server via RPC. *

- * The method returns {@code true} for the {@code property} which shouldn't - * be sent to the server because it's going to be handled by the handler - * (queued and sent later on if allowed). + * The method returns {@code true} for the {@code property} which shouldn't be sent to the server because it's going + * to be handled by the handler (queued and sent later on if allowed). * * @param property * property to handle - * @return {@code true} if property is handled by the handler, {@code false} - * otherwise + * @return {@code true} if property is handled by the handler, {@code false} otherwise */ public boolean handlePropertyUpdate(MapProperty property) { if (isNodeNewlyCreated(property.getMap().getNode())) { @@ -111,12 +100,9 @@ public boolean handlePropertyUpdate(MapProperty property) { return false; } - private boolean resetProperty(MapProperty property, - JsMap> properties) { - JsMap ignoreProperties = properties - .get(getNodeId(property.getMap().getNode())); - if (ignoreProperties != null - && ignoreProperties.has(property.getName())) { + private boolean resetProperty(MapProperty property, JsMap> properties) { + JsMap ignoreProperties = properties.get(getNodeId(property.getMap().getNode())); + if (ignoreProperties != null && ignoreProperties.has(property.getName())) { Object value = ignoreProperties.get(property.getName()); property.setValue(value); return true; @@ -128,19 +114,16 @@ private boolean isNodeNewlyCreated(StateNode node) { return newNodeDuringUpdate.has(getNodeId(node)); } - private void doFlushPropertyUpdates( - JsMap> properties) { + private void doFlushPropertyUpdates(JsMap> properties) { newNodeDuringUpdate.clear(); while (propertyUpdateQueue.length() > 0) { MapProperty property = propertyUpdateQueue.remove(0); if (!resetProperty(property, properties)) { - getRegistry().getStateTree() - .sendNodePropertySyncToServer(property); + getRegistry().getStateTree().sendNodePropertySyncToServer(property); } /* - * Do flush after each property update. There may be several - * properties and it looks like a property update may trigger - * default values of other properties back. + * Do flush after each property update. There may be several properties and it looks like a property update + * may trigger default values of other properties back. * * See https://github.com/vaadin/flow/issues/2304 */ @@ -156,13 +139,12 @@ private Registry getRegistry() { return registry; } - private void collectInitialProperties(Double id, - JsMap> properties) { + private void collectInitialProperties(Double id, JsMap> properties) { StateNode node = getRegistry().getStateTree().getNode(id.intValue()); if (node.hasFeature(NodeFeatures.ELEMENT_PROPERTIES)) { JsMap map = JsCollections.map(); - node.getMap(NodeFeatures.ELEMENT_PROPERTIES).forEachProperty( - (property, name) -> map.set(name, property.getValue())); + node.getMap(NodeFeatures.ELEMENT_PROPERTIES) + .forEachProperty((property, name) -> map.set(name, property.getValue())); properties.set(id, map); } } diff --git a/flow-client/src/main/java/com/vaadin/client/LitUtils.java b/flow-client/src/main/java/com/vaadin/client/LitUtils.java index 09268aaa69a..fc9b1b7d43a 100644 --- a/flow-client/src/main/java/com/vaadin/client/LitUtils.java +++ b/flow-client/src/main/java/com/vaadin/client/LitUtils.java @@ -19,8 +19,7 @@ import elemental.dom.Node; /** - * Utils class, intended to ease working with LitElement related code on client - * side. + * Utils class, intended to ease working with LitElement related code on client side. * * @author Vaadin Ltd */ @@ -34,8 +33,7 @@ private LitUtils() { * * @param element * the custom element - * @return {@code true} if the element is a Lit element, false - * otherwise + * @return {@code true} if the element is a Lit element, false otherwise */ public static native boolean isLitElement(Node element) /*-{ @@ -43,8 +41,7 @@ public static native boolean isLitElement(Node element) }-*/; /** - * Invokes the {@code runnable} when the given Lit element has been rendered - * at least once. + * Invokes the {@code runnable} when the given Lit element has been rendered at least once. * * @param element * the Lit element diff --git a/flow-client/src/main/java/com/vaadin/client/PolymerUtils.java b/flow-client/src/main/java/com/vaadin/client/PolymerUtils.java index 88454bb366d..bc142638b09 100644 --- a/flow-client/src/main/java/com/vaadin/client/PolymerUtils.java +++ b/flow-client/src/main/java/com/vaadin/client/PolymerUtils.java @@ -42,8 +42,7 @@ import elemental.json.JsonValue; /** - * Utils class, intended to ease working with Polymer related code on a client - * side. + * Utils class, intended to ease working with Polymer related code on a client side. * * @author Vaadin Ltd * @since 1.0. @@ -67,12 +66,9 @@ private PolymerUtils() { * @param newValue * new value to be set at desired index * - * @see Polymer - * docs + * @see Polymer docs */ - public static native void setListValueByIndex(Element htmlNode, String path, - int listIndex, JsonValue newValue) + public static native void setListValueByIndex(Element htmlNode, String path, int listIndex, JsonValue newValue) /*-{ htmlNode.set(path + "." + listIndex, newValue); }-*/; @@ -80,8 +76,8 @@ public static native void setListValueByIndex(Element htmlNode, String path, /** * Calls Polymer {@code splice} method on specified {@code htmlNode}. * - * Splice call is made via {@code apply} method in order to force the method - * to treat {@code itemsToAdd} as numerous parameters, not a single one. + * Splice call is made via {@code apply} method in order to force the method to treat {@code itemsToAdd} as numerous + * parameters, not a single one. * * @param htmlNode * node to call splice method on @@ -94,12 +90,10 @@ public static native void setListValueByIndex(Element htmlNode, String path, * @param itemsToAdd * elements to add after startIndex * - * @see Polymer - * docs + * @see Polymer docs */ - public static native void splice(Element htmlNode, String path, - int startIndex, int deleteCount, JsonArray itemsToAdd) + public static native void splice(Element htmlNode, String path, int startIndex, int deleteCount, + JsonArray itemsToAdd) /*-{ htmlNode.splice.apply(htmlNode, [path, startIndex, deleteCount].concat(itemsToAdd)); }-*/; @@ -141,16 +135,12 @@ public static JsonValue createModelTree(Object object) { } else if (node.hasFeature(NodeFeatures.TEMPLATE_MODELLIST)) { feature = node.getList(NodeFeatures.TEMPLATE_MODELLIST); } else if (node.hasFeature(NodeFeatures.BASIC_TYPE_VALUE)) { - return createModelTree( - node.getMap(NodeFeatures.BASIC_TYPE_VALUE) - .getProperty(NodeProperties.VALUE)); + return createModelTree(node.getMap(NodeFeatures.BASIC_TYPE_VALUE).getProperty(NodeProperties.VALUE)); } - assert feature != null - : "Don't know how to convert node without map or list features"; + assert feature != null : "Don't know how to convert node without map or list features"; JsonValue convert = feature.convert(PolymerUtils::createModelTree); - if (convert instanceof JsonObject - && !((JsonObject) convert).hasKey("nodeId")) { + if (convert instanceof JsonObject && !((JsonObject) convert).hasKey("nodeId")) { ((JsonObject) convert).put("nodeId", node.getId()); registerChangeHandlers(node, feature, convert); @@ -162,8 +152,7 @@ public static JsonValue createModelTree(Object object) { return createModelTree(property.getValue()); } else { JsonObject convertedObject = Json.createObject(); - convertedObject.put(property.getName(), - createModelTree(property.getValue())); + convertedObject.put(property.getName(), createModelTree(property.getValue())); return convertedObject; } } else { @@ -171,8 +160,7 @@ public static JsonValue createModelTree(Object object) { } } - private static void registerChangeHandlers(StateNode node, - NodeFeature feature, JsonValue value) { + private static void registerChangeHandlers(StateNode node, NodeFeature feature, JsonValue value) { JsArray registrations = JsCollections.array(); if (node.hasFeature(NodeFeatures.ELEMENT_PROPERTIES)) { @@ -187,48 +175,39 @@ private static void registerChangeHandlers(StateNode node, : "Received an inconsistent NodeFeature for a node that has a TEMPLATE_MODELLIST feature. It should be NodeList, but it is: " + feature; NodeList list = (NodeList) feature; - registrations.push(list.addSpliceListener( - event -> handleListChange(event, value))); + registrations.push(list.addSpliceListener(event -> handleListChange(event, value))); } - assert !registrations.isEmpty() - : "Node should have ELEMENT_PROPERTIES or TEMPLATE_MODELLIST feature"; + assert !registrations.isEmpty() : "Node should have ELEMENT_PROPERTIES or TEMPLATE_MODELLIST feature"; - registrations.push(node.addUnregisterListener( - event -> registrations.forEach(EventRemover::remove))); + registrations.push(node.addUnregisterListener(event -> registrations.forEach(EventRemover::remove))); } - private static void registerPropertyAddHandler(JsonValue value, - JsArray registrations, NodeMap map) { + private static void registerPropertyAddHandler(JsonValue value, JsArray registrations, NodeMap map) { registrations.push(map.addPropertyAddListener(event -> { MapProperty property = event.getProperty(); - registrations.push(property.addChangeListener( - change -> handlePropertyChange(property, value))); + registrations.push(property.addChangeListener(change -> handlePropertyChange(property, value))); handlePropertyChange(property, value); })); } - private static void registerPropertyChangeHandlers(JsonValue value, - JsArray registrations, NodeMap map) { + private static void registerPropertyChangeHandlers(JsonValue value, JsArray registrations, + NodeMap map) { map.forEachProperty((property, propertyName) -> registrations - .push(property.addChangeListener( - event -> handlePropertyChange(property, value)))); + .push(property.addChangeListener(event -> handlePropertyChange(property, value)))); } - private static void handleListChange(ListSpliceEvent event, - JsonValue value) { + private static void handleListChange(ListSpliceEvent event, JsonValue value) { Reactive.addFlushListener(() -> doHandleListChange(event, value)); } - private static void doHandleListChange(ListSpliceEvent event, - JsonValue value) { + private static void doHandleListChange(ListSpliceEvent event, JsonValue value) { JsArray add = event.getAdd(); int index = event.getIndex(); int remove = event.getRemove().length(); StateNode node = event.getSource().getNode(); StateNode root = getFirstParentWithDomNode(node); if (root == null) { - Console.warn("Root node for node " + node.getId() - + " could not be found"); + Console.warn("Root node for node " + node.getId() + " could not be found"); return; } @@ -239,8 +218,7 @@ private static void doHandleListChange(ListSpliceEvent event, String path = getNotificationPath(root, node, null); if (path != null) { - splice((Element) root.getDomNode(), path, index, remove, - WidgetUtil.crazyJsoCast(array)); + splice((Element) root.getDomNode(), path, index, remove, WidgetUtil.crazyJsoCast(array)); return; } } @@ -249,19 +227,16 @@ private static void doHandleListChange(ListSpliceEvent event, payload.spliceArray(index, remove, array); } - private static void handlePropertyChange(MapProperty property, - JsonValue bean) { + private static void handlePropertyChange(MapProperty property, JsonValue bean) { Reactive.addFlushListener(() -> doHandlePropertyChange(property, bean)); } - private static void doHandlePropertyChange(MapProperty property, - JsonValue value) { + private static void doHandlePropertyChange(MapProperty property, JsonValue value) { String propertyName = property.getName(); StateNode node = property.getMap().getNode(); StateNode root = getFirstParentWithDomNode(node); if (root == null) { - Console.warn("Root node for node " + node.getId() - + " could not be found"); + Console.warn("Root node for node " + node.getId() + " could not be found"); return; } JsonValue modelTree = createModelTree(property.getValue()); @@ -276,8 +251,7 @@ private static void doHandlePropertyChange(MapProperty property, WidgetUtil.setJsProperty(value, propertyName, modelTree); } - private static String getNotificationPath(StateNode rootNode, - StateNode currentNode, String propertyName) { + private static String getNotificationPath(StateNode rootNode, StateNode currentNode, String propertyName) { JsArray path = JsCollections.array(); if (propertyName != null) { @@ -286,8 +260,7 @@ private static String getNotificationPath(StateNode rootNode, return doGetNotificationPath(rootNode, currentNode, path); } - private static String doGetNotificationPath(StateNode rootNode, - StateNode currentNode, JsArray path) { + private static String doGetNotificationPath(StateNode rootNode, StateNode currentNode, JsArray path) { StateNode parent = currentNode.getParent(); if (parent.hasFeature(NodeFeatures.ELEMENT_PROPERTIES)) { @@ -318,8 +291,7 @@ private static String doGetNotificationPath(StateNode rootNode, private static String getListNotificationPath(StateNode currentNode) { int indexInTheList = -1; - NodeList children = currentNode.getParent() - .getList(NodeFeatures.TEMPLATE_MODELLIST); + NodeList children = currentNode.getParent().getList(NodeFeatures.TEMPLATE_MODELLIST); for (int i = 0; i < children.length(); i++) { Object object = children.get(i); @@ -337,8 +309,7 @@ private static String getListNotificationPath(StateNode currentNode) { private static String getPropertiesNotificationPath(StateNode currentNode) { String propertyNameInTheMap = null; - NodeMap map = currentNode.getParent() - .getMap(NodeFeatures.ELEMENT_PROPERTIES); + NodeMap map = currentNode.getParent().getMap(NodeFeatures.ELEMENT_PROPERTIES); JsArray propertyNames = map.getPropertyNames(); for (int i = 0; i < propertyNames.length(); i++) { @@ -359,8 +330,7 @@ private static String getPropertiesNotificationPath(StateNode currentNode) { * * @param node * the node - * @return the first parent node with a DOM Node, or null if - * none can be found + * @return the first parent node with a DOM Node, or null if none can be found */ private static StateNode getFirstParentWithDomNode(StateNode node) { StateNode parent = node.getParent(); @@ -386,16 +356,14 @@ public static native boolean isPolymerElement(Element htmlNode) }-*/; /** - * Checks whether the {@code htmlNode} can turn into polymer 2 element - * later. + * Checks whether the {@code htmlNode} can turn into polymer 2 element later. *

- * Lazy loaded dependencies can load Polymer later than the element itself - * gets processed by the Flow. This method helps to determine such elements. + * Lazy loaded dependencies can load Polymer later than the element itself gets processed by the Flow. This method + * helps to determine such elements. * * @param htmlNode * HTML element to check - * @return {@code true} if the {@code htmlNode} can become a polymer 2 - * element + * @return {@code true} if the {@code htmlNode} can become a polymer 2 element * * @deprecated This is not in use anywhere and can be removed */ @@ -420,8 +388,7 @@ public static native boolean mayBePolymerElement(Element htmlNode) * @deprecated This is not in use anywhere and can be removed */ @Deprecated - public static native Node searchForElementInShadowRoot( - ShadowRoot shadowRoot, String cssQuery) + public static native Node searchForElementInShadowRoot(ShadowRoot shadowRoot, String cssQuery) /*-{ return shadowRoot.querySelector(cssQuery); }-*/; @@ -441,8 +408,7 @@ public static native Node searchForElementInShadowRoot( * @deprecated This is not in use anywhere and can be removed */ @Deprecated - public static native Node getElementInShadowRootById(ShadowRoot shadowRoot, - String id) + public static native Node getElementInShadowRootById(ShadowRoot shadowRoot, String id) /*-{ return shadowRoot.getElementById(id); }-*/; @@ -451,27 +417,22 @@ public static native Node getElementInShadowRootById(ShadowRoot shadowRoot, * Find the DOM element inside shadow root of the {@code shadowRootParent}. * * @param shadowRootParent - * the parent whose shadow root contains the element with the - * {@code id} + * the parent whose shadow root contains the element with the {@code id} * @param id * the identifier of the element to search for - * @return the element with the given {@code id} inside the shadow root of - * the parent - * @deprecated This is Polymer specific. Use - * {@link ElementUtil#getElementById(Node, String)} for the - * generic version + * @return the element with the given {@code id} inside the shadow root of the parent + * @deprecated This is Polymer specific. Use {@link ElementUtil#getElementById(Node, String)} for the generic + * version */ @Deprecated - public static native Element getDomElementById(Node shadowRootParent, - String id) + public static native Element getDomElementById(Node shadowRootParent, String id) /*-{ return shadowRootParent.$[id]; }-*/; /** - * Returns {@code true} if the DOM structure of the polymer custom element - * {@code shadowRootParent} is ready (meaning that it has shadow root and - * its shadow root may be queried for children referenced by id). + * Returns {@code true} if the DOM structure of the polymer custom element {@code shadowRootParent} is ready + * (meaning that it has shadow root and its shadow root may be queried for children referenced by id). * * @param shadowRootParent * the polymer custom element @@ -491,18 +452,15 @@ public static native boolean isReady(Node shadowRootParent) * the required tag name * @return {@code true} if the node has required tag name * - * @deprecated Use the generic {@link ElementUtil#hasTag(Node, String)} - * instead + * @deprecated Use the generic {@link ElementUtil#hasTag(Node, String)} instead */ @Deprecated public static boolean hasTag(Node node, String tag) { - return node instanceof Element - && tag.equalsIgnoreCase(((Element) node).getTagName()); + return node instanceof Element && tag.equalsIgnoreCase(((Element) node).getTagName()); } /** - * Gets the custom element using {@code path} of indices starting from the - * {@code root}. + * Gets the custom element using {@code path} of indices starting from the {@code root}. * * @param root * the root element to start from @@ -519,11 +477,9 @@ public static Element getCustomElement(Node root, JsonArray path) { if (current instanceof Element) { return (Element) current; } else if (current == null) { - Console.warn( - "There is no element addressed by the path '" + path + "'"); + Console.warn("There is no element addressed by the path '" + path + "'"); } else { - Console.warn("The node addressed by path " + path - + " is not an Element"); + Console.warn("The node addressed by path " + path + " is not an Element"); } return null; } @@ -541,16 +497,15 @@ public static native Element getDomRoot(Node templateElement) }-*/; /** - * Invokes the {@code runnable} when the custom element with the given - * {@code tagName} is initialized (its DOM structure becomes available). + * Invokes the {@code runnable} when the custom element with the given {@code tagName} is initialized (its DOM + * structure becomes available). * * @param tagName * the name of the custom element * @param runnable * the command to run when the element if initialized */ - public static native void invokeWhenDefined(String tagName, - Runnable runnable) + public static native void invokeWhenDefined(String tagName, Runnable runnable) /*-{ $wnd.customElements.whenDefined(tagName).then( function () { @@ -566,25 +521,22 @@ public static native void invokeWhenDefined(String tagName, * @return the tag name of the node */ public static String getTag(StateNode node) { - return (String) node.getMap(NodeFeatures.ELEMENT_DATA) - .getProperty(NodeProperties.TAG).getValue(); + return (String) node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.TAG).getValue(); } /** - * Adds the {@code listener} which will be invoked when the - * {@code polymerElement} becomes "ready" meaning that it's method - * {@code ready} is called. + * Adds the {@code listener} which will be invoked when the {@code polymerElement} becomes "ready" meaning that it's + * method {@code ready} is called. *

- * The listener won't be called if the element is already "ready" and the - * listener will be removed immediately once it's executed. + * The listener won't be called if the element is already "ready" and the listener will be removed immediately once + * it's executed. * * @param polymerElement * the custom (polymer) element to listen its readiness state * @param listener * the callback to execute once the element becomes ready */ - public static void addReadyListener(Element polymerElement, - Runnable listener) { + public static void addReadyListener(Element polymerElement, Runnable listener) { if (readyListeners == null) { readyListeners = JsCollections.weakMap(); } @@ -618,10 +570,8 @@ private static Node getChildIgnoringStyles(Node parent, int index) { int filteredIndex = -1; for (int i = 0; i < children.getLength(); i++) { Node next = children.item(i); - assert next instanceof Element - : "Unexpected element type in the collection of children. " - + "DomElement::getChildren is supposed to return Element chidren only, but got " - + next.getClass(); + assert next instanceof Element : "Unexpected element type in the collection of children. " + + "DomElement::getChildren is supposed to return Element chidren only, but got " + next.getClass(); Element element = (Element) next; if (!"style".equalsIgnoreCase(element.getTagName())) { filteredIndex++; @@ -643,8 +593,7 @@ private static Node getChildIgnoringStyles(Node parent, int index) { * @param value * the value */ - public static native void setProperty(Element element, String path, - Object value) + public static native void setProperty(Element element, String path, Object value) /*-{ element.set(path, value); }-*/; diff --git a/flow-client/src/main/java/com/vaadin/client/Profiler.java b/flow-client/src/main/java/com/vaadin/client/Profiler.java index e1d4a94832a..5da3759572f 100644 --- a/flow-client/src/main/java/com/vaadin/client/Profiler.java +++ b/flow-client/src/main/java/com/vaadin/client/Profiler.java @@ -33,10 +33,8 @@ import com.google.gwt.core.client.JsArray; /** - * Lightweight profiling tool that can be used to collect profiling data with - * zero overhead unless enabled. To enable profiling, add - * <set-property name="vaadin.profiler" value="true" /> to - * your .gwt.xml file. + * Lightweight profiling tool that can be used to collect profiling data with zero overhead unless enabled. To enable + * profiling, add <set-property name="vaadin.profiler" value="true" /> to your .gwt.xml file. * * @author Vaadin Ltd * @since 1.0 @@ -78,12 +76,10 @@ public interface ProfilerResultConsumer { } /** - * A hierarchical representation of the time spent running a named block of - * code. + * A hierarchical representation of the time spent running a named block of code. *

- * Warning! This class is most likely to change in the future and is - * therefore defined in this class in an internal package instead of - * Profiler where it might seem more logical. + * Warning! This class is most likely to change in the future and is therefore defined in this class in an + * internal package instead of Profiler where it might seem more logical. */ public static class Node { private final String name; @@ -114,8 +110,7 @@ public String getName() { } /** - * Creates a new child node or retrieves and existing child and updates - * its total time and hit count. + * Creates a new child node or retrieves and existing child and updates its total time and hit count. * * @param name * the name of the child @@ -135,8 +130,7 @@ public Node enterChild(String name, double timestamp) { } /** - * Gets the total time spent in this node, including time spent in sub - * nodes. + * Gets the total time spent in this node, including time spent in sub nodes. * * @return the total time spent, in milliseconds */ @@ -145,8 +139,7 @@ public double getTimeSpent() { } /** - * Gets the minimum time spent for one invocation of this node, - * including time spent in sub nodes. + * Gets the minimum time spent for one invocation of this node, including time spent in sub nodes. * * @return the time spent for the fastest invocation, in milliseconds */ @@ -155,8 +148,7 @@ public double getMinTimeSpent() { } /** - * Gets the maximum time spent for one invocation of this node, - * including time spent in sub nodes. + * Gets the maximum time spent for one invocation of this node, including time spent in sub nodes. * * @return the time spent for the slowest invocation, in milliseconds */ @@ -174,8 +166,7 @@ public int getCount() { } /** - * Gets the total time spent in this node, excluding time spent in sub - * nodes. + * Gets the total time spent in this node, excluding time spent in sub nodes. * * @return the total time spent, in milliseconds */ @@ -205,25 +196,17 @@ public String getStringRepresentation(String prefix) { if (getName() == null) { return ""; } - String msg = prefix + " " + getName() + " in " - + roundToSignificantFigures(getTimeSpent()) + " ms."; + String msg = prefix + " " + getName() + " in " + roundToSignificantFigures(getTimeSpent()) + " ms."; if (getCount() > 1) { - msg += " Invoked " + getCount() + " times (" - + roundToSignificantFigures(getTimeSpent() / getCount()) - + " ms per time, min " - + roundToSignificantFigures(getMinTimeSpent()) - + " ms, max " - + roundToSignificantFigures(getMaxTimeSpent()) - + " ms)."; + msg += " Invoked " + getCount() + " times (" + roundToSignificantFigures(getTimeSpent() / getCount()) + + " ms per time, min " + roundToSignificantFigures(getMinTimeSpent()) + " ms, max " + + roundToSignificantFigures(getMaxTimeSpent()) + " ms)."; } if (!children.isEmpty()) { double ownTime = getOwnTime(); - msg += " " + roundToSignificantFigures(ownTime) - + " ms spent in own code"; + msg += " " + roundToSignificantFigures(ownTime) + " ms spent in own code"; if (getCount() > 1) { - msg += " (" - + roundToSignificantFigures(ownTime / getCount()) - + " ms per time)"; + msg += " (" + roundToSignificantFigures(ownTime / getCount()) + " ms per time)"; } msg += '.'; } @@ -256,10 +239,8 @@ public void sumUpTotals(Map totals) { totalNode.time += getOwnTime(); totalNode.count += getCount(); - totalNode.minTime = roundToSignificantFigures( - Math.min(totalNode.minTime, getMinTimeSpent())); - totalNode.maxTime = roundToSignificantFigures( - Math.max(totalNode.maxTime, getMaxTimeSpent())); + totalNode.minTime = roundToSignificantFigures(Math.min(totalNode.minTime, getMinTimeSpent())); + totalNode.maxTime = roundToSignificantFigures(Math.max(totalNode.maxTime, getMaxTimeSpent())); } for (Node node : children.values()) { node.sumUpTotals(totals); @@ -338,8 +319,7 @@ public String getEventName() { /** * Checks whether the profiling gathering is enabled. * - * @return true if the profiling is enabled, else - * false + * @return true if the profiling is enabled, else false */ public static boolean isEnabled() { // This will be fully inlined by the compiler @@ -348,9 +328,8 @@ public static boolean isEnabled() { } /** - * Enters a named block. There should always be a matching invocation of - * {@link #leave(String)} when leaving the block. Calls to this method will - * be removed by the compiler unless profiling is enabled. + * Enters a named block. There should always be a matching invocation of {@link #leave(String)} when leaving the + * block. Calls to this method will be removed by the compiler unless profiling is enabled. * * @param name * the name of the entered block @@ -362,9 +341,8 @@ public static void enter(String name) { } /** - * Leaves a named block. There should always be a matching invocation of - * {@link #enter(String)} when entering the block. Calls to this method will - * be removed by the compiler unless profiling is enabled. + * Leaves a named block. There should always be a matching invocation of {@link #enter(String)} when entering the + * block. Calls to this method will be removed by the compiler unless profiling is enabled. * * @param name * the name of the left block @@ -376,9 +354,8 @@ public static void leave(String name) { } /** - * Returns time relative to the particular page load time. The value should - * not be used directly but rather difference between two values returned by - * this method should be used to compare measurements. + * Returns time relative to the particular page load time. The value should not be used directly but rather + * difference between two values returned by this method should be used to compare measurements. * * @return the relative time in milliseconds * @@ -401,15 +378,14 @@ private static final native void logGwtEvent(String name, String type) }-*/; /** - * Resets the collected profiler data. Calls to this method will be removed - * by the compiler unless profiling is enabled. + * Resets the collected profiler data. Calls to this method will be removed by the compiler unless profiling is + * enabled. */ public static void reset() { if (isEnabled()) { /* - * Old implementations might call reset for initialization, so - * ensure it is initialized here as well. Initialization has no side - * effects if already done. + * Old implementations might call reset for initialization, so ensure it is initialized here as well. + * Initialization has no side effects if already done. */ initialize(); @@ -418,14 +394,11 @@ public static void reset() { } /** - * Initializes the profiler. This should be done before calling any other - * function in this class. Failing to do so might cause undesired behavior. - * This method has no side effects if the initialization has already been - * done. + * Initializes the profiler. This should be done before calling any other function in this class. Failing to do so + * might cause undesired behavior. This method has no side effects if the initialization has already been done. *

- * Please note that this method should be called even if the profiler is not - * enabled because it will then remove a logger function that might have - * been included in the HTML page and that would leak memory unless removed. + * Please note that this method should be called even if the profiler is not enabled because it will then remove a + * logger function that might have been included in the HTML page and that would leak memory unless removed. *

* */ @@ -447,8 +420,7 @@ public static void initialize() { */ public static void logTimings() { if (!isEnabled()) { - Console.warn( - "Profiler is not enabled, no data has been collected."); + Console.warn("Profiler is not enabled, no data has been collected."); return; } @@ -476,11 +448,9 @@ public static void logTimings() { boolean isBeginEvent = "begin".equals(type); Node stackTop = stack.getLast(); - boolean inEvent = eventName.equals(stackTop.getName()) - && !isBeginEvent; + boolean inEvent = eventName.equals(stackTop.getName()) && !isBeginEvent; - if (!inEvent && stack.size() >= 2 - && eventName.equals(stack.get(stack.size() - 2).getName()) + if (!inEvent && stack.size() >= 2 && eventName.equals(stack.get(stack.size() - 2).getName()) && !isBeginEvent) { // back out of sub event if (extendedTimeNodes.contains(stackTop) && isExtendedEvent) { @@ -496,8 +466,7 @@ public static void logTimings() { if (type.equals("end")) { if (!inEvent) { - Console.error("Got end event for " + eventName - + " but is currently in " + stackTop.getName()); + Console.error("Got end event for " + eventName + " but is currently in " + stackTop.getName()); return; } Node previousStackTop = stack.removeLast(); @@ -507,9 +476,7 @@ public static void logTimings() { previousStackTop.leave(gwtStatsEvent.getMillis()); } } else { - double millis = isExtendedEvent - ? gwtStatsEvent.getRelativeMillis() - : gwtStatsEvent.getMillis(); + double millis = isExtendedEvent ? gwtStatsEvent.getRelativeMillis() : gwtStatsEvent.getMillis(); if (!inEvent) { stackTop = stackTop.enterChild(eventName, millis); stack.add(stackTop); @@ -519,8 +486,7 @@ public static void logTimings() { } if (!isBeginEvent) { // Create sub event - Node subNode = stackTop.enterChild(eventName + "." + type, - millis); + Node subNode = stackTop.enterChild(eventName + "." + type, millis); if (isExtendedEvent) { extendedTimeNodes.add(subNode); } @@ -530,8 +496,7 @@ public static void logTimings() { } if (stack.size() != 1) { - Console.warn("Not all nodes are left, the last node is " - + stack.getLast().getName()); + Console.warn("Not all nodes are left, the last node is " + stack.getLast().getName()); return; } @@ -552,32 +517,26 @@ public int compare(Node o1, Node o2) { } /** - * Overridden in {@link EnabledProfiler} to make {@link #isEnabled()} return - * true if GWT.create returns that class. + * Overridden in {@link EnabledProfiler} to make {@link #isEnabled()} return true if GWT.create returns that class. * - * @return true if the profiling is enabled, else - * false + * @return true if the profiling is enabled, else false */ protected boolean isImplEnabled() { return false; } /** - * Outputs the time passed since various events recorded in - * performance.timing if supported by the browser. + * Outputs the time passed since various events recorded in performance.timing if supported by the browser. */ public static void logBootstrapTimings() { if (isEnabled()) { double now = Duration.currentTimeMillis(); - String[] keys = new String[] { "navigationStart", - "unloadEventStart", "unloadEventEnd", "redirectStart", - "redirectEnd", "fetchStart", "domainLookupStart", - "domainLookupEnd", "connectStart", "connectEnd", - "requestStart", "responseStart", "responseEnd", - "domLoading", "domInteractive", - "domContentLoadedEventStart", "domContentLoadedEventEnd", - "domComplete", "loadEventStart", "loadEventEnd" }; + String[] keys = new String[] { "navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart", + "redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd", "connectStart", "connectEnd", + "requestStart", "responseStart", "responseEnd", "domLoading", "domInteractive", + "domContentLoadedEventStart", "domContentLoadedEventEnd", "domComplete", "loadEventStart", + "loadEventEnd" }; LinkedHashMap timings = new LinkedHashMap<>(); @@ -591,8 +550,7 @@ public static void logBootstrapTimings() { } if (timings.isEmpty()) { - Console.log( - "Bootstrap timings not supported, please ensure your browser supports performance.timing"); + Console.log("Bootstrap timings not supported, please ensure your browser supports performance.timing"); return; } @@ -617,8 +575,7 @@ private static native JsArray getGwtStatsEvents() }-*/; /** - * Add logger if it's not already there, also initializing the event array - * if needed. + * Add logger if it's not already there, also initializing the event array if needed. */ private static native void ensureLogger() /*-{ @@ -634,8 +591,7 @@ private static native void ensureLogger() }-*/; /** - * Remove logger function and event array if it seems like the function has - * been added by us. + * Remove logger function and event array if it seems like the function has been added by us. */ private static native void ensureNoLogger() /*-{ @@ -653,20 +609,16 @@ private static native JsArray clearEventsList() }-*/; /** - * Sets the profiler result consumer that is used to output the profiler - * data to the user. + * Sets the profiler result consumer that is used to output the profiler data to the user. *

- * Warning! This is internal API and should not be used by - * applications or add-ons. + * Warning! This is internal API and should not be used by applications or add-ons. * * @param profilerResultConsumer * the consumer that gets profiler data */ - public static void setProfilerResultConsumer( - ProfilerResultConsumer profilerResultConsumer) { + public static void setProfilerResultConsumer(ProfilerResultConsumer profilerResultConsumer) { if (consumer != null) { - throw new IllegalStateException( - "The consumer has already been set"); + throw new IllegalStateException("The consumer has already been set"); } consumer = profilerResultConsumer; } @@ -684,8 +636,7 @@ private interface RelativeTimeSupplier { double getRelativeTime(); } - private static class DefaultRelativeTimeSupplier - implements RelativeTimeSupplier { + private static class DefaultRelativeTimeSupplier implements RelativeTimeSupplier { @Override public native double getRelativeTime() @@ -694,8 +645,7 @@ public native double getRelativeTime() }-*/; } - private static class HighResolutionTimeSupplier - implements RelativeTimeSupplier { + private static class HighResolutionTimeSupplier implements RelativeTimeSupplier { @Override public native double getRelativeTime() @@ -705,14 +655,12 @@ public native double getRelativeTime() } /** - * Returns a string, suitable for output to the user, containing the number - * of milliseconds which have elapsed since the given reference time. + * Returns a string, suitable for output to the user, containing the number of milliseconds which have elapsed since + * the given reference time. * * @param reference - * the reference time, as returned by - * {@link #getRelativeTimeMillis()} - * @return a string containing the number of ms elapsed since the reference - * time + * the reference time, as returned by {@link #getRelativeTimeMillis()} + * @return a string containing the number of ms elapsed since the reference time */ public static String getRelativeTimeString(double reference) { return "" + round(Profiler.getRelativeTimeMillis() - reference, 3); diff --git a/flow-client/src/main/java/com/vaadin/client/ReactUtils.java b/flow-client/src/main/java/com/vaadin/client/ReactUtils.java index cfc4d13006c..f12d3362a71 100644 --- a/flow-client/src/main/java/com/vaadin/client/ReactUtils.java +++ b/flow-client/src/main/java/com/vaadin/client/ReactUtils.java @@ -21,8 +21,7 @@ import elemental.dom.Element; /** - * Utils class, intended to ease working with React component related code on - * the client side. + * Utils class, intended to ease working with React component related code on the client side. * * @author Vaadin Ltd * @since 24.5. @@ -30,8 +29,7 @@ public final class ReactUtils { /** - * Add a callback to the react component that is called when the component - * initialization is ready for binding flow. + * Add a callback to the react component that is called when the component initialization is ready for binding flow. * * @param element * react component element @@ -40,8 +38,7 @@ public final class ReactUtils { * @param runnable * callback function runnable */ - public static native void addReadyCallback(Element element, String name, - Runnable runnable) + public static native void addReadyCallback(Element element, String name, Runnable runnable) /*-{ if(element.addReadyCallback){ element.addReadyCallback(name, diff --git a/flow-client/src/main/java/com/vaadin/client/Registry.java b/flow-client/src/main/java/com/vaadin/client/Registry.java index 4b8f0d80436..424a029f8c3 100644 --- a/flow-client/src/main/java/com/vaadin/client/Registry.java +++ b/flow-client/src/main/java/com/vaadin/client/Registry.java @@ -35,8 +35,7 @@ import com.vaadin.client.flow.collection.JsMap; /** - * A registry of singleton instances, such as {@link ServerRpcQueue}, which can - * be looked up based on their class. + * A registry of singleton instances, such as {@link ServerRpcQueue}, which can be looked up based on their class. * * @author Vaadin Ltd * @since 1.0 @@ -59,9 +58,8 @@ public Registry() { /** * Stores an instance of the given type. *

- * Note that instances by default are considered final, and you are not - * allowed to update an instance of any given type manually. In case - * instance is allowed to be recreated use {@link #set(Class, Supplier)}. + * Note that instances by default are considered final, and you are not allowed to update an instance of any given + * type manually. In case instance is allowed to be recreated use {@link #set(Class, Supplier)}. * * @param type * the type to store @@ -71,17 +69,15 @@ public Registry() { * the type */ protected final void set(Class type, T instance) { - assert !lookupTable.has(type) : "Registry already has a class of type " - + type.getName() + " registered"; + assert !lookupTable.has(type) : "Registry already has a class of type " + type.getName() + " registered"; lookupTable.set(type, instance); } /** * Stores an instance of the given type. *

- * Note that instances by default are considered final, and you are not - * allowed to update an instance of any given type manually. Uses resettable - * supplier to allow Registry to recreate given instances. + * Note that instances by default are considered final, and you are not allowed to update an instance of any given + * type manually. Uses resettable supplier to allow Registry to recreate given instances. * * @param type * the type to store @@ -106,8 +102,8 @@ protected final void set(Class type, Supplier instanceSupplier) { */ @SuppressWarnings("unchecked") protected final T get(Class type) { - assert lookupTable.has(type) : "Tried to lookup type " + type.getName() - + " but no instance has been registered"; + assert lookupTable.has(type) + : "Tried to lookup type " + type.getName() + " but no instance has been registered"; return (T) lookupTable.get(type); } diff --git a/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java b/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java index a001c7d547d..165cccb4156 100644 --- a/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java +++ b/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java @@ -40,12 +40,11 @@ import elemental.html.StyleElement; /** - * ResourceLoader lets you dynamically include external scripts and styles on - * the page and lets you know when the resource has been loaded. + * ResourceLoader lets you dynamically include external scripts and styles on the page and lets you know when the + * resource has been loaded. * - * You can also preload resources, allowing them to get cached by the browser - * without being evaluated. This enables downloading multiple resources at once - * while still controlling in which order e.g. scripts are executed. + * You can also preload resources, allowing them to get cached by the browser without being evaluated. This enables + * downloading multiple resources at once while still controlling in which order e.g. scripts are executed. * * @author Vaadin Ltd * @since 1.0 @@ -62,8 +61,7 @@ private StyleSheetLoadListener(String url) { public void onLoad(ResourceLoadEvent event) { // Chrome, IE, Edge all fire load for errors, must check // stylesheet data - if (BrowserInfo.get().isChrome() || BrowserInfo.get().isIE() - || BrowserInfo.get().isEdge()) { + if (BrowserInfo.get().isChrome() || BrowserInfo.get().isIE() || BrowserInfo.get().isEdge()) { int styleSheetLength = getStyleSheetLength(url); // Error if there's an empty stylesheet if (styleSheetLength == 0) { @@ -139,8 +137,7 @@ public static class ResourceLoadEvent { * @param loader * the resource loader that has loaded the resource * @param resourceData - * the url or content of the loaded resource or the JS - * expression that imports the resource + * the url or content of the loaded resource or the JS expression that imports the resource */ public ResourceLoadEvent(ResourceLoader loader, String resourceData) { this.loader = loader; @@ -157,11 +154,9 @@ public ResourceLoader getResourceLoader() { } /** - * Gets the absolute url or content of the loaded resource or the JS - * expression that imports the resource. + * Gets the absolute url or content of the loaded resource or the JS expression that imports the resource. * - * @return the absolute url or content of the loaded resource or the JS - * expression that imports the resource + * @return the absolute url or content of the loaded resource or the JS expression that imports the resource */ public String getResourceData() { return resourceData; @@ -174,55 +169,46 @@ public String getResourceData() { */ public interface ResourceLoadListener { /** - * Notifies this ResourceLoadListener that a resource has been loaded. - * Some browsers do not support any way of detecting load errors. In - * these cases, onLoad will be called regardless of the status. + * Notifies this ResourceLoadListener that a resource has been loaded. Some browsers do not support any way of + * detecting load errors. In these cases, onLoad will be called regardless of the status. * * @see ResourceLoadEvent * * @param event - * a resource load event with information about the loaded - * resource + * a resource load event with information about the loaded resource */ void onLoad(ResourceLoadEvent event); /** - * Notifies this ResourceLoadListener that a resource could not be - * loaded, e.g. because the file could not be found or because the - * server did not respond. Some browsers do not support any way of - * detecting load errors. In these cases, onLoad will be called - * regardless of the status. + * Notifies this ResourceLoadListener that a resource could not be loaded, e.g. because the file could not be + * found or because the server did not respond. Some browsers do not support any way of detecting load errors. + * In these cases, onLoad will be called regardless of the status. * * @see ResourceLoadEvent * * @param event - * a resource load event with information about the resource - * that could not be loaded. + * a resource load event with information about the resource that could not be loaded. */ void onError(ResourceLoadEvent event); } private final JsSet loadedResources = JsCollections.set(); - private final JsMap> loadListeners = JsCollections - .map(); + private final JsMap> loadListeners = JsCollections.map(); private Registry registry; - private final boolean supportsHtmlWhenReady = GWT.isClient() - && supportsHtmlWhenReady(); + private final boolean supportsHtmlWhenReady = GWT.isClient() && supportsHtmlWhenReady(); /** - * Creates a new resource loader. You should not create you own resource - * loader, but instead use {@link Registry#getResourceLoader()} to get an - * instance. + * Creates a new resource loader. You should not create you own resource loader, but instead use + * {@link Registry#getResourceLoader()} to get an instance. * * @param registry * the global registry * @param initFromDom - * true if currently loaded resources should be - * marked as loaded, false to ignore currently - * loaded resources + * true if currently loaded resources should be marked as loaded, false to + * ignore currently loaded resources */ public ResourceLoader(Registry registry, boolean initFromDom) { this.registry = registry; @@ -232,8 +218,7 @@ public ResourceLoader(Registry registry, boolean initFromDom) { } /** - * Populates the resource loader with the scripts currently added to the - * page. + * Populates the resource loader with the scripts currently added to the page. */ private void initLoadedResourcesFromDom() { Document document = Browser.getDocument(); @@ -253,8 +238,7 @@ private void initLoadedResourcesFromDom() { LinkElement linkElement = (LinkElement) links.item(i); String rel = linkElement.getRel(); String href = linkElement.getHref(); - if (("stylesheet".equalsIgnoreCase(rel) - || "import".equalsIgnoreCase(rel)) && href != null + if (("stylesheet".equalsIgnoreCase(rel) || "import".equalsIgnoreCase(rel)) && href != null && href.length() != 0) { loadedResources.add(href); } @@ -262,13 +246,11 @@ private void initLoadedResourcesFromDom() { } /** - * Load a script and notify a listener when the script is loaded. Calling - * this method when the script is currently loading or already loaded - * doesn't cause the script to be loaded again, but the listener will still - * be notified when appropriate. + * Load a script and notify a listener when the script is loaded. Calling this method when the script is currently + * loading or already loaded doesn't cause the script to be loaded again, but the listener will still be notified + * when appropriate. *

- * Loads all dependencies with {@code async = false} and - * {@code defer = false} attribute values, see + * Loads all dependencies with {@code async = false} and {@code defer = false} attribute values, see * {@link #loadScript(String, ResourceLoadListener, boolean, boolean)}. * * @param scriptUrl @@ -276,16 +258,14 @@ private void initLoadedResourcesFromDom() { * @param resourceLoadListener * the listener that will get notified when the script is loaded */ - public void loadScript(final String scriptUrl, - final ResourceLoadListener resourceLoadListener) { + public void loadScript(final String scriptUrl, final ResourceLoadListener resourceLoadListener) { loadScript(scriptUrl, resourceLoadListener, false, false); } /** - * Load a script and notify a listener when the script is loaded. Calling - * this method when the script is currently loading or already loaded - * doesn't cause the script to be loaded again, but the listener will still - * be notified when appropriate. + * Load a script and notify a listener when the script is loaded. Calling this method when the script is currently + * loading or already loaded doesn't cause the script to be loaded again, but the listener will still be notified + * when appropriate. * * * @param scriptUrl @@ -297,18 +277,15 @@ public void loadScript(final String scriptUrl, * @param defer * What mode the script.defer attribute should be set to */ - public void loadScript(final String scriptUrl, - final ResourceLoadListener resourceLoadListener, boolean async, + public void loadScript(final String scriptUrl, final ResourceLoadListener resourceLoadListener, boolean async, boolean defer) { - loadScript(scriptUrl, resourceLoadListener, async, defer, - "text/javascript"); + loadScript(scriptUrl, resourceLoadListener, async, defer, "text/javascript"); } /** - * Load a script with type module and notify a listener when the script is - * loaded. Calling this method when the script is currently loading or - * already loaded doesn't cause the script to be loaded again, but the - * listener will still be notified when appropriate. + * Load a script with type module and notify a listener when the script is loaded. Calling this method when the + * script is currently loading or already loaded doesn't cause the script to be loaded again, but the listener will + * still be notified when appropriate. * * * @param scriptUrl @@ -320,15 +297,13 @@ public void loadScript(final String scriptUrl, * @param defer * What mode the script.defer attribute should be set to */ - public void loadJsModule(final String scriptUrl, - final ResourceLoadListener resourceLoadListener, boolean async, + public void loadJsModule(final String scriptUrl, final ResourceLoadListener resourceLoadListener, boolean async, boolean defer) { loadScript(scriptUrl, resourceLoadListener, async, defer, "module"); } - private void loadScript(String scriptUrl, - ResourceLoadListener resourceLoadListener, boolean async, - boolean defer, String type) { + private void loadScript(String scriptUrl, ResourceLoadListener resourceLoadListener, boolean async, boolean defer, + String type) { final String url = WidgetUtil.getAbsoluteUrl(scriptUrl); ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { @@ -339,8 +314,7 @@ private void loadScript(String scriptUrl, } if (addListener(url, resourceLoadListener, loadListeners)) { - ScriptElement scriptTag = Browser.getDocument() - .createScriptElement(); + ScriptElement scriptTag = Browser.getDocument().createScriptElement(); scriptTag.setSrc(url); scriptTag.setType(type); scriptTag.setAsync(async); @@ -352,18 +326,16 @@ private void loadScript(String scriptUrl, } /** - * Inlines a script and notify a listener when the script is loaded. Calling - * this method when the script is currently loading or already loaded - * doesn't cause the script to be loaded again, but the listener will still - * be notified when appropriate. + * Inlines a script and notify a listener when the script is loaded. Calling this method when the script is + * currently loading or already loaded doesn't cause the script to be loaded again, but the listener will still be + * notified when appropriate. * * @param scriptContents * the script contents to inline * @param resourceLoadListener * listener to notify when script is loaded */ - public void inlineScript(String scriptContents, - final ResourceLoadListener resourceLoadListener) { + public void inlineScript(String scriptContents, final ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, scriptContents); if (loadedResources.has(scriptContents)) { if (resourceLoadListener != null) { @@ -391,21 +363,18 @@ private static HeadElement getHead() { } /** - * Loads an HTML import and notify a listener when the HTML import is - * loaded. Calling this method when the HTML import is currently loading or - * already loaded doesn't cause the HTML import to be loaded again, but the - * listener will still be notified when appropriate. + * Loads an HTML import and notify a listener when the HTML import is loaded. Calling this method when the HTML + * import is currently loading or already loaded doesn't cause the HTML import to be loaded again, but the listener + * will still be notified when appropriate. * * @param htmlUrl * url of HTML import to load * @param resourceLoadListener * listener to notify when the HTML import is loaded * @param async - * loads the import asynchronously, if {@code true}, - * synchronously otherwise + * loads the import asynchronously, if {@code true}, synchronously otherwise */ - public void loadHtml(final String htmlUrl, - final ResourceLoadListener resourceLoadListener, boolean async) { + public void loadHtml(final String htmlUrl, final ResourceLoadListener resourceLoadListener, boolean async) { final String url = WidgetUtil.getAbsoluteUrl(htmlUrl); ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { @@ -435,18 +404,16 @@ public void loadHtml(final String htmlUrl, } /** - * Inlines an HTML import and notify a listener when the HTML import is - * loaded. Calling this method when the HTML import is currently loading or - * already loaded doesn't cause the HTML import to be loaded again, but the - * listener will still be notified when appropriate. + * Inlines an HTML import and notify a listener when the HTML import is loaded. Calling this method when the HTML + * import is currently loading or already loaded doesn't cause the HTML import to be loaded again, but the listener + * will still be notified when appropriate. * * @param htmlContents * the html contents to inline * @param resourceLoadListener * listener to notify when the HTML import is loaded */ - public void inlineHtml(String htmlContents, - final ResourceLoadListener resourceLoadListener) { + public void inlineHtml(String htmlContents, final ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, htmlContents); if (loadedResources.has(htmlContents)) { if (resourceLoadListener != null) { @@ -471,9 +438,8 @@ public void inlineHtml(String htmlContents, } /** - * Sets the provided task to be run by HTMLImports.whenReady. - * The task is run immediately if HTMLImports.whenReady is not - * supported. + * Sets the provided task to be run by HTMLImports.whenReady. The task is run immediately if + * HTMLImports.whenReady is not supported. * * @param task * the task to run, not null @@ -500,9 +466,8 @@ private static native void addHtmlImportsReadyHandler(Runnable handler) }-*/; /** - * Adds an onload listener to the given element, which should be a link or a - * script tag. The listener is called whenever loading is complete or an - * error occurred. + * Adds an onload listener to the given element, which should be a link or a script tag. The listener is called + * whenever loading is complete or an error occurred. * * @param element * the element to attach a listener to @@ -511,8 +476,7 @@ private static native void addHtmlImportsReadyHandler(Runnable handler) * @param event * the event passed to the listener */ - public static native void addOnloadHandler(Element element, - ResourceLoadListener listener, ResourceLoadEvent event) + public static native void addOnloadHandler(Element element, ResourceLoadListener listener, ResourceLoadEvent event) /*-{ element.onload = $entry(function() { element.onload = null; @@ -534,19 +498,16 @@ public static native void addOnloadHandler(Element element, }-*/; /** - * Load a stylesheet and notify a listener when the stylesheet is loaded. - * Calling this method when the stylesheet is currently loading or already - * loaded doesn't cause the stylesheet to be loaded again, but the listener - * will still be notified when appropriate. + * Load a stylesheet and notify a listener when the stylesheet is loaded. Calling this method when the stylesheet is + * currently loading or already loaded doesn't cause the stylesheet to be loaded again, but the listener will still + * be notified when appropriate. * * @param stylesheetUrl * the url of the stylesheet to load * @param resourceLoadListener - * the listener that will get notified when the stylesheet is - * loaded + * the listener that will get notified when the stylesheet is loaded */ - public void loadStylesheet(final String stylesheetUrl, - final ResourceLoadListener resourceLoadListener) { + public void loadStylesheet(final String stylesheetUrl, final ResourceLoadListener resourceLoadListener) { final String url = WidgetUtil.getAbsoluteUrl(stylesheetUrl); final ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { @@ -587,8 +548,7 @@ public boolean execute() { } }, 10); } else { - addOnloadHandler(linkElement, new StyleSheetLoadListener(url), - event); + addOnloadHandler(linkElement, new StyleSheetLoadListener(url), event); if (BrowserInfo.get().isOpera()) { // Opera onerror never fired, assume error if no onload in x // seconds @@ -608,21 +568,17 @@ public void run() { } /** - * Inlines a stylesheet and notify a listener when the stylesheet is loaded. - * Calling this method when the stylesheet is currently loading or already - * loaded doesn't cause the stylesheet to be loaded again, but the listener - * will still be notified when appropriate. + * Inlines a stylesheet and notify a listener when the stylesheet is loaded. Calling this method when the stylesheet + * is currently loading or already loaded doesn't cause the stylesheet to be loaded again, but the listener will + * still be notified when appropriate. * * @param styleSheetContents * the contents to inline * @param resourceLoadListener - * the listener that will get notified when the stylesheet is - * loaded + * the listener that will get notified when the stylesheet is loaded */ - public void inlineStyleSheet(String styleSheetContents, - final ResourceLoadListener resourceLoadListener) { - final ResourceLoadEvent event = new ResourceLoadEvent(this, - styleSheetContents); + public void inlineStyleSheet(String styleSheetContents, final ResourceLoadListener resourceLoadListener) { + final ResourceLoadEvent event = new ResourceLoadEvent(this, styleSheetContents); if (loadedResources.has(styleSheetContents)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); @@ -630,8 +586,7 @@ public void inlineStyleSheet(String styleSheetContents, return; } - if (addListener(styleSheetContents, resourceLoadListener, - loadListeners)) { + if (addListener(styleSheetContents, resourceLoadListener, loadListeners)) { StyleElement styleSheetElement = getDocument().createStyleElement(); styleSheetElement.setTextContent(styleSheetContents); styleSheetElement.setType("text/css"); @@ -666,26 +621,23 @@ private elemental.dom.Node findCommentInHead(String comment) { } /** - * Loads a dynamic import via the provided JS {@code expression} and reports - * the result via the {@code resourceLoadListener}. + * Loads a dynamic import via the provided JS {@code expression} and reports the result via the + * {@code resourceLoadListener}. * * @param expression * the JS expression which returns a Promise * @param resourceLoadListener * a listener to report the Promise result exection */ - public void loadDynamicImport(String expression, - ResourceLoadListener resourceLoadListener) { + public void loadDynamicImport(String expression, ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, expression); NativeFunction function = new NativeFunction(expression); - runPromiseExpression(expression, () -> function.call(null), - () -> resourceLoadListener.onLoad(event), + runPromiseExpression(expression, () -> function.call(null), () -> resourceLoadListener.onLoad(event), () -> resourceLoadListener.onError(event)); } - private void addCssLoadHandler(String styleSheetContents, - ResourceLoadEvent event, StyleElement styleSheetElement) { + private void addCssLoadHandler(String styleSheetContents, ResourceLoadEvent event, StyleElement styleSheetElement) { if (BrowserInfo.get().isSafariOrIOS() || BrowserInfo.get().isOpera()) { // Safari and Opera don't fire any events for link elements // See http://www.phpied.com/when-is-a-stylesheet-really-loaded/ @@ -739,8 +691,7 @@ private static native int getStyleSheetLength(String url) return -1; }-*/; - private static boolean addListener(String resourceId, - ResourceLoadListener listener, + private static boolean addListener(String resourceId, ResourceLoadListener listener, JsMap> listenerMap) { JsArray listeners = listenerMap.get(resourceId); if (listeners == null) { @@ -755,8 +706,7 @@ private static boolean addListener(String resourceId, } private void fireError(ResourceLoadEvent event) { - registry.getSystemErrorHandler() - .handleError("Error loading " + event.getResourceData()); + registry.getSystemErrorHandler().handleError("Error loading " + event.getResourceData()); String resource = event.getResourceData(); JsArray listeners = loadListeners.get(resource); @@ -787,9 +737,8 @@ private void fireLoad(ResourceLoadEvent event) { } } - private static native void runPromiseExpression(String expression, - Supplier promiseSupplier, Runnable onSuccess, - Runnable onError) + private static native void runPromiseExpression(String expression, Supplier promiseSupplier, + Runnable onSuccess, Runnable onError) /*-{ try { var promise = promiseSupplier.@java.util.function.Supplier::get(*)(); diff --git a/flow-client/src/main/java/com/vaadin/client/SystemErrorHandler.java b/flow-client/src/main/java/com/vaadin/client/SystemErrorHandler.java index 2a70a11ebe1..e511b860533 100644 --- a/flow-client/src/main/java/com/vaadin/client/SystemErrorHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/SystemErrorHandler.java @@ -63,8 +63,7 @@ public SystemErrorHandler(Registry registry) { * message details or null if there are no details */ public void handleSessionExpiredError(String details) { - handleUnrecoverableError(details, registry.getApplicationConfiguration() - .getSessionExpiredError()); + handleUnrecoverableError(details, registry.getApplicationConfiguration().getSessionExpiredError()); } /** @@ -75,15 +74,12 @@ public void handleSessionExpiredError(String details) { * @param message * an ErrorMessage describing the error */ - protected void handleUnrecoverableError(String details, - ErrorMessage message) { - handleUnrecoverableError(message.getCaption(), message.getMessage(), - details, message.getUrl(), null); + protected void handleUnrecoverableError(String details, ErrorMessage message) { + handleUnrecoverableError(message.getCaption(), message.getMessage(), details, message.getUrl(), null); } /** - * Shows an error notification for an error which is unrecoverable, using - * the given parameters. + * Shows an error notification for an error which is unrecoverable, using the given parameters. * * @param caption * the caption of the message @@ -92,17 +88,14 @@ protected void handleUnrecoverableError(String details, * @param details * message details or {@code null} if there are no details * @param url - * a URL to redirect to when the user clicks the message or - * {@code null} to refresh on click + * a URL to redirect to when the user clicks the message or {@code null} to refresh on click */ - public void handleUnrecoverableError(String caption, String message, - String details, String url) { + public void handleUnrecoverableError(String caption, String message, String details, String url) { handleUnrecoverableError(caption, message, details, url, null); } /** - * Shows an error notification for an error which is unrecoverable, using - * the given parameters. + * Shows an error notification for an error which is unrecoverable, using the given parameters. * * @param caption * the caption of the message @@ -111,15 +104,13 @@ public void handleUnrecoverableError(String caption, String message, * @param details * message details or {@code null} if there are no details * @param url - * a URL to redirect to when the user clicks the message or - * {@code null} to refresh on click + * a URL to redirect to when the user clicks the message or {@code null} to refresh on click * @param querySelector - * query selector to find the element under which the error will - * be added . If element is not found or the selector is - * {@code null}, body will be used + * query selector to find the element under which the error will be added . If element is not found or + * the selector is {@code null}, body will be used */ - public void handleUnrecoverableError(String caption, String message, - String details, String url, String querySelector) { + public void handleUnrecoverableError(String caption, String message, String details, String url, + String querySelector) { if (caption == null && message == null && details == null) { if (!isWebComponentMode()) { WidgetUtil.redirect(url); @@ -129,11 +120,9 @@ public void handleUnrecoverableError(String caption, String message, return; } - Element systemErrorContainer = handleError(caption, message, details, - querySelector); + Element systemErrorContainer = handleError(caption, message, details, querySelector); if (!isWebComponentMode()) { - systemErrorContainer.addEventListener("click", - e -> WidgetUtil.redirect(url), false); + systemErrorContainer.addEventListener("click", e -> WidgetUtil.redirect(url), false); Browser.getDocument().addEventListener(Event.KEYDOWN, e -> { int keyCode = ((KeyboardEvent) e).getKeyCode(); if (keyCode == KeyCode.ESC) { @@ -145,14 +134,13 @@ public void handleUnrecoverableError(String caption, String message, } /** - * Send GET async request to acquire new JSESSIONID, browser will set cookie - * automatically based on Set-Cookie response header. + * Send GET async request to acquire new JSESSIONID, browser will set cookie automatically based on Set-Cookie + * response header. */ private void resynchronizeSession() { - String serviceUrl = registry.getApplicationConfiguration() - .getServiceUrl() + "web-component/web-component-bootstrap.js"; - String sessionResyncUri = SharedUtil.addGetParameter(serviceUrl, - ApplicationConstants.REQUEST_TYPE_PARAMETER, + String serviceUrl = registry.getApplicationConfiguration().getServiceUrl() + + "web-component/web-component-bootstrap.js"; + String sessionResyncUri = SharedUtil.addGetParameter(serviceUrl, ApplicationConstants.REQUEST_TYPE_PARAMETER, ApplicationConstants.REQUEST_TYPE_WEBCOMPONENT_RESYNC); Xhr.get(sessionResyncUri, new Xhr.Callback() { @@ -164,23 +152,18 @@ public void onFail(XMLHttpRequest xhr, Exception exception) { @Override public void onSuccess(XMLHttpRequest xhr) { - Console.log( - "Received xhr HTTP session resynchronization message: " - + xhr.getResponseText()); + Console.log("Received xhr HTTP session resynchronization message: " + xhr.getResponseText()); registry.reset(); registry.getUILifecycle().setState(UILifecycle.UIState.RUNNING); - ValueMap json = MessageHandler - .parseWrappedJson(xhr.getResponseText()); + ValueMap json = MessageHandler.parseWrappedJson(xhr.getResponseText()); registry.getMessageHandler().handleMessage(json); - registry.getApplicationConfiguration() - .setUIId(json.getInt(ApplicationConstants.UI_ID)); + registry.getApplicationConfiguration().setUIId(json.getInt(ApplicationConstants.UI_ID)); - Scheduler.get().scheduleDeferred(() -> Arrays - .stream(registry.getApplicationConfiguration() - .getExportedWebComponents()) - .forEach(SystemErrorHandler.this::recreateNodes)); + Scheduler.get().scheduleDeferred( + () -> Arrays.stream(registry.getApplicationConfiguration().getExportedWebComponents()) + .forEach(SystemErrorHandler.this::recreateNodes)); } }); } @@ -196,8 +179,8 @@ private native void recreateNodes(String elementName) }-*/; /** - * Shows the given error message if not running in production mode and logs - * it to the console if running in production mode. + * Shows the given error message if not running in production mode and logs it to the console if running in + * production mode. * * @param errorMessage * the error message to show @@ -207,8 +190,8 @@ public void handleError(String errorMessage) { } /** - * Shows an error message if not running in production mode and logs it to - * the console if running in production mode. + * Shows an error message if not running in production mode and logs it to the console if running in production + * mode. * * @param throwable * the throwable which occurred @@ -222,8 +205,7 @@ public void handleError(Throwable throwable) { } } - private Element handleError(String caption, String message, String details, - String querySelector) { + private Element handleError(String caption, String message, String details, String querySelector) { Document document = Browser.getDocument(); Element systemErrorContainer = document.createDivElement(); systemErrorContainer.setClassName("v-system-error"); @@ -256,8 +238,7 @@ private Element handleError(String caption, String message, String details, if (baseElement != null) { // if the baseElement has a shadow root, add the warning to // the shadow - otherwise add it to the baseElement - findShadowRoot(baseElement).orElse(baseElement) - .appendChild(systemErrorContainer); + findShadowRoot(baseElement).orElse(baseElement).appendChild(systemErrorContainer); } } else { document.getBody().appendChild(systemErrorContainer); diff --git a/flow-client/src/main/java/com/vaadin/client/TrackingScheduler.java b/flow-client/src/main/java/com/vaadin/client/TrackingScheduler.java index 4cca5f5b2f4..382c94bb395 100644 --- a/flow-client/src/main/java/com/vaadin/client/TrackingScheduler.java +++ b/flow-client/src/main/java/com/vaadin/client/TrackingScheduler.java @@ -18,8 +18,7 @@ import com.google.gwt.core.client.impl.SchedulerImpl; /** - * Scheduler implementation which tracks and reports whether there is any work - * queued or currently being executed. + * Scheduler implementation which tracks and reports whether there is any work queued or currently being executed. * * @author Vaadin Ltd * @since 1.0 @@ -27,8 +26,8 @@ public class TrackingScheduler extends SchedulerImpl { /** - * Keeps track of if there are deferred commands that are being executed. 0 - * == no deferred commands currently in progress, > 0 otherwise. + * Keeps track of if there are deferred commands that are being executed. 0 == no deferred commands currently in + * progress, > 0 otherwise. */ private int deferredCommandTrackers = 0; @@ -42,8 +41,7 @@ public void scheduleDeferred(ScheduledCommand cmd) { /** * Checks if there is work queued or currently being executed. * - * @return true if there is work queued or if work is currently being - * executed, false otherwise + * @return true if there is work queued or if work is currently being executed, false otherwise */ public boolean hasWorkQueued() { return deferredCommandTrackers != 0; diff --git a/flow-client/src/main/java/com/vaadin/client/UILifecycle.java b/flow-client/src/main/java/com/vaadin/client/UILifecycle.java index d76ee8be2c6..be60d965777 100644 --- a/flow-client/src/main/java/com/vaadin/client/UILifecycle.java +++ b/flow-client/src/main/java/com/vaadin/client/UILifecycle.java @@ -54,8 +54,8 @@ public UIState getState() { /** * Sets the state of the UI to the given value. *

- * Only allows state changes in one direction: {@link UIState#INITIALIZING} - * -> {@link UIState#RUNNING} -> {@link UIState#TERMINATED}. + * Only allows state changes in one direction: {@link UIState#INITIALIZING} -> {@link UIState#RUNNING} -> + * {@link UIState#TERMINATED}. *

* Changing the state fires a {@link StateChangeEvent}. * @@ -65,8 +65,7 @@ public UIState getState() { public void setState(UIState state) { if (state.ordinal() != this.state.ordinal() + 1) { throw new IllegalArgumentException( - "Tried to move from state " + this.state.name() + " to " - + state.name() + " which is not allowed"); + "Tried to move from state " + this.state.name() + " to " + state.name() + " which is not allowed"); } this.state = state; @@ -76,8 +75,7 @@ public void setState(UIState state) { /** * Check if the state is {@link UIState#RUNNING}. * - * @return {@code true} if the status is {@link UIState#RUNNING}, - * {@code false} otherwise + * @return {@code true} if the status is {@link UIState#RUNNING}, {@code false} otherwise */ public boolean isRunning() { return getState() == UIState.RUNNING; @@ -86,8 +84,7 @@ public boolean isRunning() { /** * Check if the state is {@link UIState#TERMINATED}. * - * @return {@code true} if the status is {@link UIState#TERMINATED}, - * {@code false} otherwise + * @return {@code true} if the status is {@link UIState#TERMINATED}, {@code false} otherwise */ public boolean isTerminated() { return getState() == UIState.TERMINATED; @@ -100,11 +97,9 @@ public boolean isTerminated() { * the handler to add * @param * the handler type - * @return a handler registration object which can be used to remove the - * handler + * @return a handler registration object which can be used to remove the handler */ - public HandlerRegistration addHandler( - H handler) { + public HandlerRegistration addHandler(H handler) { return eventBus.addHandler(StateChangeEvent.getType(), handler); } @@ -169,8 +164,7 @@ protected void dispatch(StateChangeHandler listener) { public interface StateChangeHandler extends EventHandler { /** - * Triggered when state of a UI if changed. To get the current state, - * call {@link UILifecycle#getState()}. + * Triggered when state of a UI if changed. To get the current state, call {@link UILifecycle#getState()}. * * @param event * the event object diff --git a/flow-client/src/main/java/com/vaadin/client/URIResolver.java b/flow-client/src/main/java/com/vaadin/client/URIResolver.java index 6e1b442f7d9..6265a153a1b 100644 --- a/flow-client/src/main/java/com/vaadin/client/URIResolver.java +++ b/flow-client/src/main/java/com/vaadin/client/URIResolver.java @@ -40,16 +40,14 @@ public URIResolver(Registry registry) { } /** - * Translates a Vaadin URI to a URL that can be loaded by the browser. The - * following URI schemes are supported: + * Translates a Vaadin URI to a URL that can be loaded by the browser. The following URI schemes are supported: *

    - *
  • {@value ApplicationConstants#CONTEXT_PROTOCOL_PREFIX} - - * resolves to the application context root
  • - *
  • {@value ApplicationConstants#BASE_PROTOCOL_PREFIX} - - * resolves to the base URI of the page
  • + *
  • {@value ApplicationConstants#CONTEXT_PROTOCOL_PREFIX} - resolves to the application context + * root
  • + *
  • {@value ApplicationConstants#BASE_PROTOCOL_PREFIX} - resolves to the base URI of the page
  • *
- * Any other URI protocols, such as http:// or - * https:// are passed through this method unmodified. + * Any other URI protocols, such as http:// or https:// are passed through this method + * unmodified. * * @param uri * the URI to resolve @@ -60,22 +58,18 @@ public String resolveVaadinUri(String uri) { } protected String getContextRootUrl() { - String root = registry.getApplicationConfiguration() - .getContextRootUrl(); + String root = registry.getApplicationConfiguration().getContextRootUrl(); assert root.endsWith("/"); return root; } /** - * Returns the current document location as relative to the base uri of the - * document. + * Returns the current document location as relative to the base uri of the document. * - * @return the document current location as relative to the document base - * uri + * @return the document current location as relative to the document base uri */ public static String getCurrentLocationRelativeToBaseUri() { - return getBaseRelativeUri(Browser.getDocument().getBaseURI(), - Browser.getDocument().getLocation().getHref()); + return getBaseRelativeUri(Browser.getDocument().getBaseURI(), Browser.getDocument().getLocation().getHref()); } /** @@ -85,8 +79,7 @@ public static String getCurrentLocationRelativeToBaseUri() { * the base uri of the document * @param uri * an absolute uri to transform - * @return the uri as relative to the document base uri, or the given uri - * unmodified if it is for different context. + * @return the uri as relative to the document base uri, or the given uri unmodified if it is for different context. */ public static String getBaseRelativeUri(String baseURI, String uri) { if (uri.startsWith(baseURI)) { diff --git a/flow-client/src/main/java/com/vaadin/client/WidgetUtil.java b/flow-client/src/main/java/com/vaadin/client/WidgetUtil.java index 00195040e83..f1e65332ccf 100644 --- a/flow-client/src/main/java/com/vaadin/client/WidgetUtil.java +++ b/flow-client/src/main/java/com/vaadin/client/WidgetUtil.java @@ -44,8 +44,7 @@ public static void refresh() { } /** - * Redirects the browser to the given url or refreshes the page if url is - * null + * Redirects the browser to the given url or refreshes the page if url is null * * @param url * The url to redirect to or null to refresh @@ -60,16 +59,14 @@ public static native void redirect(String url) }-*/; /** - * Resolve a relative URL to an absolute URL based on the current document's - * location. + * Resolve a relative URL to an absolute URL based on the current document's location. * * @param url * a string with the relative URL to resolve * @return the corresponding absolute URL as a string */ public static String getAbsoluteUrl(String url) { - AnchorElement a = (AnchorElement) Browser.getDocument() - .createElement("a"); + AnchorElement a = (AnchorElement) Browser.getDocument().createElement("a"); a.setHref(url); return a.getHref(); } @@ -77,13 +74,11 @@ public static String getAbsoluteUrl(String url) { /** * Detects if an URL is absolute. * - * URLs wihtout schema but starting with double slashes (e.g. //myhost/path} - * are considered absolute. + * URLs wihtout schema but starting with double slashes (e.g. //myhost/path} are considered absolute. * * @param url * a string with the URL to check - * @return {@literal true} if the url is absolute, otherwise - * {@literal false}. + * @return {@literal true} if the url is absolute, otherwise {@literal false}. */ public static native boolean isAbsoluteUrl(String url) /*-{ @@ -91,8 +86,7 @@ public static native boolean isAbsoluteUrl(String url) }-*/; /** - * Anything in, anything out. It's JavaScript after all. This method just - * makes the Java compiler accept the fact. + * Anything in, anything out. It's JavaScript after all. This method just makes the Java compiler accept the fact. * * @param value * anything @@ -106,9 +100,8 @@ public static native T crazyJsCast(Object value) }-*/; /** - * Anything in, JSO out. It's JavaScript after all. This method just makes - * the Java compiler accept the fact. The regular crazy cast doesn't work - * for JSOs since the generics still makes the compiler insert a JSO check. + * Anything in, JSO out. It's JavaScript after all. This method just makes the Java compiler accept the fact. The + * regular crazy cast doesn't work for JSOs since the generics still makes the compiler insert a JSO check. * * @param value * anything @@ -116,8 +109,7 @@ public static native T crazyJsCast(Object value) * the object type * @return the same stuff */ - public static native T crazyJsoCast( - Object value) + public static native T crazyJsoCast(Object value) /*-{ return value; }-*/; @@ -140,11 +132,9 @@ public static String toPrettyJson(JsonValue json) { } /** - * Updates the {@code attribute} value for the {@code element} to the given - * {@code value}. + * Updates the {@code attribute} value for the {@code element} to the given {@code value}. *

- * If {@code value} is {@code null} then {@code attribute} is removed, - * otherwise {@code value} is set as its value. + * If {@code value} is {@code null} then {@code attribute} is removed, otherwise {@code value} is set as its value. * * @param element * the DOM element owning attribute @@ -153,8 +143,7 @@ public static String toPrettyJson(JsonValue json) { * @param value * the value to update */ - public static void updateAttribute(Element element, String attribute, - String value) { + public static void updateAttribute(Element element, String attribute, String value) { if (value == null) { DomApi.wrap(element).removeAttribute(attribute); } else { @@ -185,8 +174,7 @@ private static native String toPrettyJsonJsni(JsonValue value) * @param value * the property value */ - public static native void setJsProperty(Object object, String name, - Object value) + public static native void setJsProperty(Object object, String name, Object value) /*-{ object[name] = value; }-*/; @@ -206,8 +194,8 @@ public static native Object getJsProperty(Object object, String name) }-*/; /** - * Checks whether the provided object itself has a JavaScript property with - * the given name. Inherited properties are not taken into account. + * Checks whether the provided object itself has a JavaScript property with the given name. Inherited properties are + * not taken into account. * * @see #hasJsProperty(Object, String) * @@ -215,9 +203,8 @@ public static native Object getJsProperty(Object object, String name) * the target object * @param name * the name of the property - * @return true if the object itself has the named property; - * false if it doesn't have the property of if the - * property is inherited + * @return true if the object itself has the named property; false if it doesn't have the + * property of if the property is inherited */ public static native boolean hasOwnJsProperty(Object object, String name) /*-{ @@ -225,8 +212,7 @@ public static native boolean hasOwnJsProperty(Object object, String name) }-*/; /** - * Checks whether the provided object has or inherits a JavaScript property - * with the given name. + * Checks whether the provided object has or inherits a JavaScript property with the given name. * * @see #hasOwnJsProperty(Object, String) * @@ -234,8 +220,7 @@ public static native boolean hasOwnJsProperty(Object object, String name) * the target object * @param name * the name of the property - * @return true if the object itself has or inherits the named - * property; false otherwise + * @return true if the object itself has or inherits the named property; false otherwise */ public static native boolean hasJsProperty(Object object, String name) /*-{ @@ -243,13 +228,11 @@ public static native boolean hasJsProperty(Object object, String name) }-*/; /** - * Checks if the given value is explicitly undefined. null - * values returns false. + * Checks if the given value is explicitly undefined. null values returns false. * * @param property * the value to be verified - * @return true is the value is explicitly undefined, - * false otherwise + * @return true is the value is explicitly undefined, false otherwise */ public static native boolean isUndefined(Object property) /*-{ @@ -270,9 +253,8 @@ public static native void deleteJsProperty(Object object, String name) }-*/; /** - * Creates a new {@link JsonObject} without any JavaScript prototype at all. - * Not having any prototype is only relevant for objects that are displayed - * through the browser console. + * Creates a new {@link JsonObject} without any JavaScript prototype at all. Not having any prototype is only + * relevant for objects that are displayed through the browser console. * * * @return a new json object @@ -293,13 +275,12 @@ public static native JsonObject createJsonObject() }-*/; /** - * Gets the boolean value of the provided value based on JavaScript - * semantics. + * Gets the boolean value of the provided value based on JavaScript semantics. * * @param value * the value to check for truthness - * @return true if the provided value is trueish according to - * JavaScript semantics, otherwise false + * @return true if the provided value is trueish according to JavaScript semantics, otherwise + * false */ public static native boolean isTrueish(Object value) /*-{ @@ -307,8 +288,7 @@ public static native boolean isTrueish(Object value) }-*/; /** - * Gets all JavaScript property names of the given object. This directly - * calls Object.keys. + * Gets all JavaScript property names of the given object. This directly calls Object.keys. * * @param value * the value to get keys for @@ -320,9 +300,8 @@ public static native String[] getKeys(Object value) }-*/; /** - * When serializing the JsonObject we check the values for dom nodes and - * throw and exception if one is found as they should not be synced and may - * create cyclic dependencies. + * When serializing the JsonObject we check the values for dom nodes and throw and exception if one is found as they + * should not be synced and may create cyclic dependencies. * * @param payload * JsonObject to stringify @@ -339,16 +318,15 @@ public static native String stringify(JsonObject payload) /*-{ }-*/; /** - * Checks whether the objects are equal either as Java objects (considering - * types and Java {@link Object#equals(Object)} method) or as JS values. + * Checks whether the objects are equal either as Java objects (considering types and Java + * {@link Object#equals(Object)} method) or as JS values. * * @param obj1 * an object * * @param obj2 * an object to be compared with {@code a} for deep equality - * @return {@code true} if the arguments are equal to each other and - * {@code false} otherwise + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise * * @see #equalsInJS(Object, Object) */ @@ -359,16 +337,15 @@ public static boolean equals(Object obj1, Object obj2) { /** * Checks whether the objects are equal as JS values. *

- * This check ignores object types and checks the values via JS {@code ==}. - * E.g. it means that an empty string equals to {@code 0}. + * This check ignores object types and checks the values via JS {@code ==}. E.g. it means that an empty string + * equals to {@code 0}. * * @param obj1 * an object * * @param obj2 * an object to be compared with {@code a} for deep equality - * @return {@code true} if the arguments are equal via JS {@code ==} to each - * other and {@code false} otherwise + * @return {@code true} if the arguments are equal via JS {@code ==} to each other and {@code false} otherwise */ public static native boolean equalsInJS(Object obj1, Object obj2) /*-{ diff --git a/flow-client/src/main/java/com/vaadin/client/bootstrap/Bootstrapper.java b/flow-client/src/main/java/com/vaadin/client/bootstrap/Bootstrapper.java index dc8e6ccd664..150f31a140c 100644 --- a/flow-client/src/main/java/com/vaadin/client/bootstrap/Bootstrapper.java +++ b/flow-client/src/main/java/com/vaadin/client/bootstrap/Bootstrapper.java @@ -31,8 +31,8 @@ /** * Handles bootstrapping of the application. *

- * Reads the configuration provided by the server in the DOM and starts the - * client engine ({@link ApplicationConnection}). + * Reads the configuration provided by the server in the DOM and starts the client engine + * ({@link ApplicationConnection}). *

* Acts as the GWT entry point. * @@ -43,8 +43,7 @@ public class Bootstrapper implements EntryPoint { private static boolean moduleLoaded = false; - private static JsArray runningApplications = JsCollections - .array(); + private static JsArray runningApplications = JsCollections.array(); @Override public void onModuleLoad() { @@ -55,8 +54,7 @@ private static void initModule() { // Don't run twice if the module has been inherited several times, // and don't continue if vaadinBootstrap was not executed. if (moduleLoaded || !vaadinBootstrapLoaded()) { - Console.warn( - "vaadinBootstrap.js was not loaded, skipping vaadin application configuration."); + Console.warn("vaadinBootstrap.js was not loaded, skipping vaadin application configuration."); return; } moduleLoaded = true; @@ -67,12 +65,11 @@ private static void initModule() { } /** - * Starts the application with a given id by reading the configuration - * options stored by the bootstrap javascript. + * Starts the application with a given id by reading the configuration options stored by the bootstrap javascript. * * @param applicationId - * id of the application to load, this is also the id of the html - * element into which the application should be rendered. + * id of the application to load, this is also the id of the html element into which the application + * should be rendered. */ public static void startApplication(final String applicationId) { Scheduler.get().scheduleDeferred(() -> { @@ -94,13 +91,11 @@ public static JsArray getRunningApplications() { } /** - * Constructs an ApplicationConfiguration object based on the information - * available in the DOM. + * Constructs an ApplicationConfiguration object based on the information available in the DOM. * * @param appId * the application id - * @return an application configuration object containing the read - * information + * @return an application configuration object containing the read information */ private static ApplicationConfiguration getConfigFromDOM(String appId) { ApplicationConfiguration conf = new ApplicationConfiguration(); @@ -114,70 +109,54 @@ private static ApplicationConfiguration getConfigFromDOM(String appId) { * * @param conf */ - private static void populateApplicationConfiguration( - ApplicationConfiguration conf, JsoConfiguration jsoConfiguration) { + private static void populateApplicationConfiguration(ApplicationConfiguration conf, + JsoConfiguration jsoConfiguration) { /* - * Resolve potentially relative URLs to ensure they point to the desired - * locations even if the base URL of the page changes later (e.g. with - * pushState) + * Resolve potentially relative URLs to ensure they point to the desired locations even if the base URL of the + * page changes later (e.g. with pushState) */ - String serviceUrl = jsoConfiguration - .getConfigString(ApplicationConstants.SERVICE_URL); + String serviceUrl = jsoConfiguration.getConfigString(ApplicationConstants.SERVICE_URL); - conf.setWebComponentMode(jsoConfiguration - .getConfigBoolean(ApplicationConstants.APP_WC_MODE)); + conf.setWebComponentMode(jsoConfiguration.getConfigBoolean(ApplicationConstants.APP_WC_MODE)); if (serviceUrl == null) { conf.setServiceUrl(WidgetUtil.getAbsoluteUrl(".")); - conf.setContextRootUrl(WidgetUtil.getAbsoluteUrl(jsoConfiguration - .getConfigString(ApplicationConstants.CONTEXT_ROOT_URL))); + conf.setContextRootUrl( + WidgetUtil.getAbsoluteUrl(jsoConfiguration.getConfigString(ApplicationConstants.CONTEXT_ROOT_URL))); } else { conf.setServiceUrl(serviceUrl); conf.setContextRootUrl(WidgetUtil.getAbsoluteUrl( - serviceUrl + jsoConfiguration.getConfigString( - ApplicationConstants.CONTEXT_ROOT_URL))); + serviceUrl + jsoConfiguration.getConfigString(ApplicationConstants.CONTEXT_ROOT_URL))); } - conf.setUIId(jsoConfiguration - .getConfigInteger(ApplicationConstants.UI_ID_PARAMETER) - .intValue()); + conf.setUIId(jsoConfiguration.getConfigInteger(ApplicationConstants.UI_ID_PARAMETER).intValue()); - conf.setHeartbeatInterval( - jsoConfiguration.getConfigInteger("heartbeatInterval")); + conf.setHeartbeatInterval(jsoConfiguration.getConfigInteger("heartbeatInterval")); - conf.setMaxMessageSuspendTimeout( - jsoConfiguration.getConfigInteger("maxMessageSuspendTimeout")); + conf.setMaxMessageSuspendTimeout(jsoConfiguration.getConfigInteger("maxMessageSuspendTimeout")); conf.setServletVersion(jsoConfiguration.getVaadinVersion()); conf.setAtmosphereVersion(jsoConfiguration.getAtmosphereVersion()); conf.setAtmosphereJSVersion(jsoConfiguration.getAtmosphereJSVersion()); - conf.setSessionExpiredError( - jsoConfiguration.getConfigError("sessExpMsg")); + conf.setSessionExpiredError(jsoConfiguration.getConfigError("sessExpMsg")); // Debug or production mode? conf.setProductionMode(!jsoConfiguration.getConfigBoolean("debug")); - conf.setRequestTiming( - jsoConfiguration.getConfigBoolean("requestTiming")); - conf.setExportedWebComponents( - jsoConfiguration.getConfigStringArray("webcomponents")); - - conf.setDevToolsEnabled(jsoConfiguration - .getConfigBoolean(ApplicationConstants.DEV_TOOLS_ENABLED)); - conf.setLiveReloadUrl( - jsoConfiguration.getConfigString("liveReloadUrl")); - conf.setLiveReloadBackend( - jsoConfiguration.getConfigString("liveReloadBackend")); - conf.setSpringBootLiveReloadPort( - jsoConfiguration.getConfigString("springBootLiveReloadPort")); + conf.setRequestTiming(jsoConfiguration.getConfigBoolean("requestTiming")); + conf.setExportedWebComponents(jsoConfiguration.getConfigStringArray("webcomponents")); + + conf.setDevToolsEnabled(jsoConfiguration.getConfigBoolean(ApplicationConstants.DEV_TOOLS_ENABLED)); + conf.setLiveReloadUrl(jsoConfiguration.getConfigString("liveReloadUrl")); + conf.setLiveReloadBackend(jsoConfiguration.getConfigString("liveReloadBackend")); + conf.setSpringBootLiveReloadPort(jsoConfiguration.getConfigString("springBootLiveReloadPort")); } private static void doStartApplication(final String applicationId) { Profiler.enter("Bootstrapper.startApplication"); ApplicationConfiguration appConf = getConfigFromDOM(applicationId); - ApplicationConnection applicationConnection = new ApplicationConnection( - appConf); + ApplicationConnection applicationConnection = new ApplicationConnection(appConf); runningApplications.push(applicationConnection); Profiler.leave("Bootstrapper.startApplication"); @@ -186,8 +165,7 @@ private static void doStartApplication(final String applicationId) { } /** - * Gets the configuration object for a specific application from the - * bootstrap javascript. + * Gets the configuration object for a specific application from the bootstrap javascript. * * @param appId * the id of the application to get configuration data for @@ -217,9 +195,8 @@ private static native boolean startApplicationImmediately() }-*/; /** - * Registers the callback that the bootstrap javascript uses to start - * applications once the widgetset is loaded and all required information is - * available. + * Registers the callback that the bootstrap javascript uses to start applications once the widgetset is loaded and + * all required information is available. * * @param widgetsetName * the name of this widgetset diff --git a/flow-client/src/main/java/com/vaadin/client/bootstrap/JsoConfiguration.java b/flow-client/src/main/java/com/vaadin/client/bootstrap/JsoConfiguration.java index 027ff639ce8..069eda49f1f 100644 --- a/flow-client/src/main/java/com/vaadin/client/bootstrap/JsoConfiguration.java +++ b/flow-client/src/main/java/com/vaadin/client/bootstrap/JsoConfiguration.java @@ -29,14 +29,12 @@ protected JsoConfiguration() { } /** - * Reads a configuration parameter as a string. Please note that the - * javascript value of the parameter should also be a string, or else an - * undefined exception may be thrown. + * Reads a configuration parameter as a string. Please note that the javascript value of the parameter should also + * be a string, or else an undefined exception may be thrown. * * @param name * name of the configuration parameter - * @return value of the configuration parameter, or null if not - * defined + * @return value of the configuration parameter, or null if not defined */ public native String getConfigString(String name) /*-{ @@ -49,14 +47,12 @@ public native String getConfigString(String name) }-*/; /** - * Reads a configuration parameter as a {@link ValueMap}. Please note that - * the javascript value of the parameter should also be a javascript object, - * or else an undefined exception may be thrown. + * Reads a configuration parameter as a {@link ValueMap}. Please note that the javascript value of the parameter + * should also be a javascript object, or else an undefined exception may be thrown. * * @param name * name of the configuration parameter - * @return value of the configuration parameter, or nullif not - * defined + * @return value of the configuration parameter, or nullif not defined */ public native ValueMap getConfigValueMap(String name) /*-{ @@ -68,8 +64,7 @@ public native ValueMap getConfigValueMap(String name) * * @param name * name of the configuration parameter - * @return value of the configuration parameter, or nullif not - * defined + * @return value of the configuration parameter, or nullif not defined */ public native String[] getConfigStringArray(String name) /*-{ @@ -79,13 +74,12 @@ public native String[] getConfigStringArray(String name) /** * Reads a configuration parameter as a boolean. *

- * Please note that the javascript value of the parameter should also be a - * boolean, or else an undefined exception may be thrown. + * Please note that the javascript value of the parameter should also be a boolean, or else an undefined exception + * may be thrown. * * @param name * name of the configuration parameter - * @return the boolean value of the configuration parameter, or - * false if no value is defined + * @return the boolean value of the configuration parameter, or false if no value is defined */ public native boolean getConfigBoolean(String name) /*-{ @@ -99,14 +93,12 @@ public native boolean getConfigBoolean(String name) }-*/; /** - * Reads a configuration parameter as an integer object. Please note that - * the javascript value of the parameter should also be an integer, or else - * an undefined exception may be thrown. + * Reads a configuration parameter as an integer object. Please note that the javascript value of the parameter + * should also be an integer, or else an undefined exception may be thrown. * * @param name * name of the configuration parameter - * @return integer value of the configuration parameter, or - * null if no value is defined + * @return integer value of the configuration parameter, or null if no value is defined */ public native Integer getConfigInteger(String name) /*-{ @@ -120,15 +112,13 @@ public native Integer getConfigInteger(String name) }-*/; /** - * Reads a configuration parameter as an {@link ErrorMessage} object. Please - * note that the javascript value of the parameter should also be an object - * with appropriate fields, or else an undefined exception may be thrown - * when calling this method or when calling methods on the returned object. + * Reads a configuration parameter as an {@link ErrorMessage} object. Please note that the javascript value of the + * parameter should also be an object with appropriate fields, or else an undefined exception may be thrown when + * calling this method or when calling methods on the returned object. * * @param name * name of the configuration parameter - * @return error message with the given name, or null if no - * value is defined + * @return error message with the given name, or null if no value is defined */ public native ErrorMessage getConfigError(String name) /*-{ diff --git a/flow-client/src/main/java/com/vaadin/client/bootstrap/LocationParser.java b/flow-client/src/main/java/com/vaadin/client/bootstrap/LocationParser.java index 0204b2a827a..d8f25617eb2 100644 --- a/flow-client/src/main/java/com/vaadin/client/bootstrap/LocationParser.java +++ b/flow-client/src/main/java/com/vaadin/client/bootstrap/LocationParser.java @@ -28,15 +28,13 @@ private LocationParser() { } /** - * Gets the value of the given parameter using the given search (query) - * string. + * Gets the value of the given parameter using the given search (query) string. * * @param search * the search string * @param parameter * the parameter to retrieve - * @return the value of the parameter or null if the parameter was not - * included in the search string + * @return the value of the parameter or null if the parameter was not included in the search string */ public static String getParameter(String search, String parameter) { String[] keyValues = search.substring(1).split("&"); diff --git a/flow-client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java b/flow-client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java index 8ed029ec347..729b0026cbe 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java @@ -34,8 +34,7 @@ import elemental.json.JsonObject; /** - * The default {@link PushConnection} implementation that uses Atmosphere for - * handling the communication channel. + * The default {@link PushConnection} implementation that uses Atmosphere for handling the communication channel. * * @author Vaadin Ltd * @since 1.0 @@ -57,9 +56,8 @@ protected enum State { CONNECTED, /** - * Connection was disconnected while the connection was pending. Wait - * for the connection to get established before closing it. No new - * messages are accepted, but pending messages will still be delivered. + * Connection was disconnected while the connection was pending. Wait for the connection to get established + * before closing it. No new messages are accepted, but pending messages will still be delivered. */ DISCONNECT_PENDING, @@ -70,8 +68,7 @@ protected enum State { } /** - * Represents a message splitted into multiple fragments of maximum length - * {@link #FRAGMENT_LENGTH}. + * Represents a message splitted into multiple fragments of maximum length {@link #FRAGMENT_LENGTH}. */ protected static class FragmentedMessage { @@ -91,23 +88,21 @@ public FragmentedMessage(String message) { } /** - * Checks if there is another fragment which can be retrieved using - * {@link #getNextFragment()} or if all fragments have been retrieved. + * Checks if there is another fragment which can be retrieved using {@link #getNextFragment()} or if all + * fragments have been retrieved. * - * @return true if there is another fragment to retrieve, false - * otherwise + * @return true if there is another fragment to retrieve, false otherwise */ public boolean hasNextFragment() { return index < message.length(); } /** - * Gets the following fragment and increments the internal fragment - * counter so the following call to this method will return the - * following fragment. + * Gets the following fragment and increments the internal fragment counter so the following call to this method + * will return the following fragment. *

- * This method should not be called if all fragments have been received - * ({@link #hasNextFragment()} returns false). + * This method should not be called if all fragments have been received ({@link #hasNextFragment()} returns + * false). * * @return the next fragment */ @@ -116,8 +111,7 @@ public String getNextFragment() { String result; if (index == 0) { - String header = "" + message.length() - + PushConstants.MESSAGE_DELIMITER; + String header = "" + message.length() + PushConstants.MESSAGE_DELIMITER; int fragmentLen = FRAGMENT_LENGTH - header.length(); result = header + getFragment(0, fragmentLen); index += fragmentLen; @@ -144,8 +138,8 @@ private String getFragment(int begin, int end) { private String transport; /** - * Keeps track of the disconnect confirmation command for cases where - * pending messages should be pushed before actually disconnecting. + * Keeps track of the disconnect confirmation command for cases where pending messages should be pushed before + * actually disconnecting. */ private Command pendingDisconnectCommand; @@ -166,8 +160,7 @@ public AtmospherePushConnection(Registry registry) { this.registry = registry; registry.getUILifecycle().addHandler(event -> { if (event.getUiLifecycle().isTerminated()) { - if (state == State.DISCONNECT_PENDING - || state == State.DISCONNECTED) { + if (state == State.DISCONNECT_PENDING || state == State.DISCONNECTED) { return; } @@ -180,8 +173,7 @@ public AtmospherePushConnection(Registry registry) { config.setStringValue("logLevel", "debug"); getPushConfiguration().getParameters().forEach((value, key) -> { - if (value.equalsIgnoreCase("true") - || value.equalsIgnoreCase("false")) { + if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { config.setBooleanValue(key, value.equalsIgnoreCase("true")); } else { config.setStringValue(key, value); @@ -189,16 +181,13 @@ public AtmospherePushConnection(Registry registry) { }); - String pushServletMapping = getPushConfiguration() - .getPushServletMapping(); - if (pushServletMapping == null || pushServletMapping.trim().isEmpty() - || "/".equals(pushServletMapping)) { + String pushServletMapping = getPushConfiguration().getPushServletMapping(); + if (pushServletMapping == null || pushServletMapping.trim().isEmpty() || "/".equals(pushServletMapping)) { // Handle null, empty and "/" mapping using just default push // mapping and serviceUrl url = Constants.PUSH_MAPPING; // If a specific serviceUrl is defined, prepend pushUrl with it - String serviceUrl = registry.getApplicationConfiguration() - .getServiceUrl(); + String serviceUrl = registry.getApplicationConfiguration().getServiceUrl(); if (!serviceUrl.equals(".")) { if (!serviceUrl.endsWith("/")) { serviceUrl += "/"; @@ -207,17 +196,14 @@ public AtmospherePushConnection(Registry registry) { } } else { // Append specific mapping directly to context root URL - String contextRootUrl = registry.getApplicationConfiguration() - .getContextRootUrl(); - if (contextRootUrl.endsWith("/") - && pushServletMapping.startsWith("/")) { + String contextRootUrl = registry.getApplicationConfiguration().getContextRootUrl(); + if (contextRootUrl.endsWith("/") && pushServletMapping.startsWith("/")) { pushServletMapping = pushServletMapping.substring(1); } url = contextRootUrl + pushServletMapping + Constants.PUSH_MAPPING; } - runWhenAtmosphereLoaded( - () -> Scheduler.get().scheduleDeferred(this::connect)); + runWhenAtmosphereLoaded(() -> Scheduler.get().scheduleDeferred(this::connect)); } private PushConfiguration getPushConfiguration() { @@ -230,17 +216,14 @@ private ConnectionStateHandler getConnectionStateHandler() { private void connect() { String pushUrl = registry.getURIResolver().resolveVaadinUri(url); - pushUrl = SharedUtil.addGetParameter(pushUrl, - ApplicationConstants.REQUEST_TYPE_PARAMETER, + pushUrl = SharedUtil.addGetParameter(pushUrl, ApplicationConstants.REQUEST_TYPE_PARAMETER, ApplicationConstants.REQUEST_TYPE_PUSH); - pushUrl = SharedUtil.addGetParameter(pushUrl, - ApplicationConstants.UI_ID_PARAMETER, + pushUrl = SharedUtil.addGetParameter(pushUrl, ApplicationConstants.UI_ID_PARAMETER, registry.getApplicationConfiguration().getUIId()); String pushId = registry.getMessageHandler().getPushId(); if (pushId != null) { - pushUrl = SharedUtil.addGetParameter(pushUrl, - ApplicationConstants.PUSH_ID_PARAMETER, pushId); + pushUrl = SharedUtil.addGetParameter(pushUrl, ApplicationConstants.PUSH_ID_PARAMETER, pushId); } Console.log("Establishing push connection"); @@ -291,12 +274,10 @@ public void push(JsonObject message) { } if (state == State.CONNECTED) { String messageJson = WidgetUtil.stringify(message); - Console.log("Sending push (" + transport + ") message to server: " - + messageJson); + Console.log("Sending push (" + transport + ") message to server: " + messageJson); if (transport.equals("websocket")) { - FragmentedMessage fragmented = new FragmentedMessage( - messageJson); + FragmentedMessage fragmented = new FragmentedMessage(messageJson); while (fragmented.hasNextFragment()) { doPush(socket, fragmented.getNextFragment()); } @@ -319,20 +300,17 @@ protected AtmosphereConfiguration getConfig() { } protected void onReopen(AtmosphereResponse response) { - Console.log("Push connection re-established using " - + response.getTransport()); + Console.log("Push connection re-established using " + response.getTransport()); onConnect(response); } protected void onOpen(AtmosphereResponse response) { - Console.log( - "Push connection established using " + response.getTransport()); + Console.log("Push connection established using " + response.getTransport()); onConnect(response); } /** - * Called whenever a server push connection is established (or - * re-established). + * Called whenever a server push connection is established (or re-established). * * @param response * the response @@ -355,8 +333,7 @@ protected void onConnect(AtmosphereResponse response) { break; default: throw new IllegalStateException( - "Got onOpen event when connection state is " + state - + ". This should never happen."); + "Got onOpen event when connection state is " + state + ". This should never happen."); } } @@ -379,8 +356,7 @@ public final void disconnect(Command command) { break; case DISCONNECT_PENDING: case DISCONNECTED: - throw new IllegalStateException( - "Can not disconnect more than once"); + throw new IllegalStateException("Can not disconnect more than once"); } } @@ -398,19 +374,16 @@ protected void onMessage(AtmosphereResponse response) { getConnectionStateHandler().pushInvalidContent(this, message); return; } else { - Console.log("Received push (" + getTransportType() + ") message: " - + message); + Console.log("Received push (" + getTransportType() + ") message: " + message); registry.getMessageHandler().handleMessage(json); } } /** - * Called if the transport mechanism cannot be used and the fallback will be - * tried. + * Called if the transport mechanism cannot be used and the fallback will be tried. */ protected void onTransportFailure() { - Console.warn("Push connection using primary method (" - + getConfig().getTransport() + ") failed. Trying with " + Console.warn("Push connection using primary method (" + getConfig().getTransport() + ") failed. Trying with " + getConfig().getFallbackTransport()); } @@ -430,8 +403,8 @@ protected void onError(AtmosphereResponse response) { /** * Called when the push connection has been closed. *

- * This does not necessarily indicate an error and Atmosphere might try to - * reconnect or downgrade to the fallback transport automatically. + * This does not necessarily indicate an error and Atmosphere might try to reconnect or downgrade to the fallback + * transport automatically. * * @param response * the Atmosphere response which was closed @@ -444,12 +417,10 @@ protected void onClose(AtmosphereResponse response) { /** * Called when the Atmosphere client side timeout occurs. *

- * The connection will be closed at this point and reconnect will not happen - * automatically. + * The connection will be closed at this point and reconnect will not happen automatically. * * @param response - * the Atmosphere response which was used when the timeout - * occurred + * the Atmosphere response which was used when the timeout occurred */ protected void onClientTimeout(AtmosphereResponse response) { state = State.DISCONNECTED; @@ -457,16 +428,15 @@ protected void onClientTimeout(AtmosphereResponse response) { } /** - * Called when the push connection has lost the connection to the server and - * will proceed to try to re-establish the connection. + * Called when the push connection has lost the connection to the server and will proceed to try to re-establish the + * connection. * * @param request * the Atmosphere request * @param response * the Atmosphere response */ - protected void onReconnect(JavaScriptObject request, - final AtmosphereResponse response) { + protected void onReconnect(JavaScriptObject request, final AtmosphereResponse response) { if (state == State.CONNECTED) { state = State.CONNECT_PENDING; } @@ -478,8 +448,7 @@ private int getLastSeenServerSyncId() { } /** - * JavaScriptObject class with some helper methods to set and get primitive - * values. + * JavaScriptObject class with some helper methods to set and get primitive values. */ public abstract static class AbstractJSO extends JavaScriptObject { /** @@ -650,11 +619,9 @@ public final String getResponseBody() { /** * Gets the Atmosphere reported state. *

- * The state can be at least {@literal messageReceived}, - * {@literal error}, {@literal opening}, {@literal messagePublished}, - * {@literal re-connecting}, {@literal closedByClient}, - * {@literal re-opening}, {@literal fail-to-reconnect}, - * {@literal unsubscribe}, {@literal closed} + * The state can be at least {@literal messageReceived}, {@literal error}, {@literal opening}, + * {@literal messagePublished}, {@literal re-connecting}, {@literal closedByClient}, {@literal re-opening}, + * {@literal fail-to-reconnect}, {@literal unsubscribe}, {@literal closed} * * @return the state reported by Atmosphere */ @@ -696,8 +663,7 @@ protected final native AtmosphereConfiguration createConfig() }; }-*/; - private final native JavaScriptObject doConnect(String uri, - JavaScriptObject config) + private final native JavaScriptObject doConnect(String uri, JavaScriptObject config) /*-{ var self = this; @@ -758,8 +724,7 @@ private void runWhenAtmosphereLoaded(final Command command) { Console.log("Loading " + pushJs); ResourceLoader loader = registry.getResourceLoader(); - String pushScriptUrl = registry.getApplicationConfiguration() - .getServiceUrl() + pushJs; + String pushScriptUrl = registry.getApplicationConfiguration().getServiceUrl() + pushJs; ResourceLoadListener loadListener = new ResourceLoadListener() { @Override public void onLoad(ResourceLoadEvent event) { @@ -776,8 +741,7 @@ public void onLoad(ResourceLoadEvent event) { @Override public void onError(ResourceLoadEvent event) { - getConnectionStateHandler() - .pushScriptLoadError(event.getResourceData()); + getConnectionStateHandler().pushScriptLoadError(event.getResourceData()); } }; @@ -801,8 +765,8 @@ public String getTransportType() { } /** - * The default {@link PushConnectionFactory} implementation that provides - * {@link AtmospherePushConnection} instances. + * The default {@link PushConnectionFactory} implementation that provides {@link AtmospherePushConnection} + * instances. */ static class Factory implements PushConnectionFactory { diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ConnectionStateHandler.java b/flow-client/src/main/java/com/vaadin/client/communication/ConnectionStateHandler.java index ec39f90d828..8bd5ff3df2b 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ConnectionStateHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ConnectionStateHandler.java @@ -21,12 +21,10 @@ import elemental.json.JsonObject; /** - * Handles problems and other events which occur during communication with the - * server. + * Handles problems and other events which occur during communication with the server. * - * The handler is responsible for handling any problem in XHR, heartbeat and - * push connections in a way it sees fit. The default implementation is - * {@link DefaultConnectionStateHandler}. + * The handler is responsible for handling any problem in XHR, heartbeat and push connections in a way it sees fit. The + * default implementation is {@link DefaultConnectionStateHandler}. * * @author Vaadin Ltd * @since 1.0 @@ -34,20 +32,18 @@ public interface ConnectionStateHandler { /** - * A string that, if found in a non-JSON response to a UIDL request, will - * cause the browser to refresh the page. If followed by a colon, optional - * whitespace, and a URI, causes the browser to synchronously load the URI. + * A string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page. If + * followed by a colon, optional whitespace, and a URI, causes the browser to synchronously load the URI. * *

- * This allows, for instance, a servlet filter to redirect the application - * to a custom login page when the session expires. For example: + * This allows, for instance, a servlet filter to redirect the application to a custom login page when the session + * expires. For example: *

* *
      * if (sessionExpired) {
      *     response.setHeader("Content-Type", "text/html");
-     *     response.getWriter().write(myLoginPageHtml + "<!-- Vaadin-Refresh: "
-     *             + request.getContextPath() + " -->");
+     *     response.getWriter().write(myLoginPageHtml + "<!-- Vaadin-Refresh: " + request.getContextPath() + " -->");
      * }
      * 
*/ @@ -64,8 +60,7 @@ public interface ConnectionStateHandler { void heartbeatException(XMLHttpRequest request, Exception exception); /** - * Called when a heartbeat request returns a status code other than OK - * (200). + * Called when a heartbeat request returns a status code other than OK (200). * * @param xhr * the heartbeat request @@ -78,42 +73,36 @@ public interface ConnectionStateHandler { void heartbeatOk(); /** - * Called when the push connection to the server is closed. This might - * result in the push connection trying a fallback connection method, trying - * to reconnect to the server or might just be an indication that the - * connection was intentionally closed ("unsubscribe"), + * Called when the push connection to the server is closed. This might result in the push connection trying a + * fallback connection method, trying to reconnect to the server or might just be an indication that the connection + * was intentionally closed ("unsubscribe"), * * @param pushConnection * The push connection which was closed * @param responseObject * An object containing response data */ - void pushClosed(PushConnection pushConnection, - JavaScriptObject responseObject); + void pushClosed(PushConnection pushConnection, JavaScriptObject responseObject); /** - * Called when a client side timeout occurs before a push connection to the - * server completes. + * Called when a client side timeout occurs before a push connection to the server completes. * - * The client side timeout causes a disconnection of the push connection and - * no reconnect will be attempted after this method is called, + * The client side timeout causes a disconnection of the push connection and no reconnect will be attempted after + * this method is called, * * @param pushConnection * The push connection which timed out * @param response * An object containing response data */ - void pushClientTimeout(PushConnection pushConnection, - JavaScriptObject response); + void pushClientTimeout(PushConnection pushConnection, JavaScriptObject response); /** * Called when a fatal error fatal error occurs in the push connection. * - * The push connection will not try to recover from this situation itself - * and typically the problem handler should not try to do automatic recovery - * either. The cause can be e.g. maximum number of reconnection attempts - * have been reached, neither the selected transport nor the fallback - * transport can be used or similar. + * The push connection will not try to recover from this situation itself and typically the problem handler should + * not try to do automatic recovery either. The cause can be e.g. maximum number of reconnection attempts have been + * reached, neither the selected transport nor the fallback transport can be used or similar. * * @param pushConnection * The push connection where the error occurred @@ -123,8 +112,8 @@ void pushClientTimeout(PushConnection pushConnection, void pushError(PushConnection pushConnection, JavaScriptObject response); /** - * Called when the push connection has lost the connection to the server and - * will proceed to try to re-establish the connection. + * Called when the push connection has lost the connection to the server and will proceed to try to re-establish the + * connection. * * @param pushConnection * The push connection which will be reconnected @@ -148,32 +137,26 @@ void pushClientTimeout(PushConnection pushConnection, void pushScriptLoadError(String resourceUrl); /** - * Called when an exception occurs during an XmlHttpRequest request to the - * server. + * Called when an exception occurs during an XmlHttpRequest request to the server. * * @param xhrConnectionError - * An event containing what was being sent to the server and what - * exception occurred + * An event containing what was being sent to the server and what exception occurred */ void xhrException(XhrConnectionError xhrConnectionError); /** - * Called when invalid content (not JSON) was returned from the server as - * the result of an XmlHttpRequest request. + * Called when invalid content (not JSON) was returned from the server as the result of an XmlHttpRequest request. * * @param xhrConnectionError - * An event containing what was being sent to the server and what - * was returned + * An event containing what was being sent to the server and what was returned */ void xhrInvalidContent(XhrConnectionError xhrConnectionError); /** - * Called when invalid status code (not 200) was returned by the server as - * the result of an XmlHttpRequest. + * Called when invalid status code (not 200) was returned by the server as the result of an XmlHttpRequest. * * @param xhrConnectionError - * An event containing what was being sent to the server and what - * was returned + * An event containing what was being sent to the server and what was returned */ void xhrInvalidStatusCode(XhrConnectionError xhrConnectionError); @@ -183,8 +166,7 @@ void pushClientTimeout(PushConnection pushConnection, void xhrOk(); /** - * Called when a message is to be sent to the server through the push - * channel but the push channel is not connected. + * Called when a message is to be sent to the server through the push channel but the push channel is not connected. * * @param payload * The payload to send to the server @@ -192,8 +174,7 @@ void pushClientTimeout(PushConnection pushConnection, void pushNotConnected(JsonObject payload); /** - * Called when invalid content (not JSON) was pushed from the server through - * the push connection. + * Called when invalid content (not JSON) was pushed from the server through the push connection. * * @param pushConnection * the push connection which was used @@ -203,8 +184,7 @@ void pushClientTimeout(PushConnection pushConnection, void pushInvalidContent(PushConnection pushConnection, String message); /** - * Called when some part of the reconnect dialog configuration has been - * changed. + * Called when some part of the reconnect dialog configuration has been changed. */ void configurationUpdated(); diff --git a/flow-client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java b/flow-client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java index ec98867090f..5b8ab25a20a 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java @@ -36,12 +36,10 @@ /** * Default implementation of the connection state handler. *

- * Handles temporary errors by showing a reconnect dialog to the user while - * trying to re-establish the connection to the server and re-send the pending - * message. + * Handles temporary errors by showing a reconnect dialog to the user while trying to re-establish the connection to the + * server and re-send the pending message. *

- * Handles permanent errors by showing a critical system notification to the - * user + * Handles permanent errors by showing a critical system notification to the user * * @author Vaadin Ltd * @since 1.0 @@ -73,8 +71,7 @@ public boolean isMessage() { * * @param type * the type to compare to - * @return true if this type has higher priority than the given type, - * false otherwise + * @return true if this type has higher priority than the given type, false otherwise */ public boolean isHigherPriorityThan(Type type) { return priority > type.priority; @@ -95,8 +92,7 @@ public DefaultConnectionStateHandler(Registry registry) { giveUp(); stopApplication(); } - if (scheduledReconnect != null - && scheduledReconnect.isRunning()) { + if (scheduledReconnect != null && scheduledReconnect.isRunning()) { scheduledReconnect.cancel(); } } @@ -109,8 +105,7 @@ public DefaultConnectionStateHandler(Registry registry) { /** * Checks if we are currently trying to reconnect. * - * @return true if we have noted a problem and are trying to re-establish - * server connection, false otherwise + * @return true if we have noted a problem and are trying to re-establish server connection, false otherwise */ private boolean isReconnecting() { return reconnectionCause != null; @@ -123,8 +118,7 @@ public void xhrException(XhrConnectionError xhrConnectionError) { } @Override - public void heartbeatException(XMLHttpRequest request, - Exception exception) { + public void heartbeatException(XMLHttpRequest request, Exception exception) { Console.error("Heartbeat exception: " + exception.getMessage()); handleRecoverableError(Type.HEARTBEAT, null); } @@ -162,15 +156,14 @@ private void debug(String msg) { } /** - * Called whenever an error occurs in communication which should be handled - * by showing the reconnect dialog and retrying communication until - * successful again. + * Called whenever an error occurs in communication which should be handled by showing the reconnect dialog and + * retrying communication until successful again. * * @param type * The type of failure detected * @param payload - * The message which did not reach the server, or null if no - * message was involved (heartbeat or push connection failed) + * The message which did not reach the server, or null if no message was involved (heartbeat or push + * connection failed) */ protected void handleRecoverableError(Type type, final JsonObject payload) { debug("handleTemporaryError(" + type + ")"); @@ -190,8 +183,7 @@ protected void handleRecoverableError(Type type, final JsonObject payload) { // If a higher priority issues is resolved, we can assume the lower // one will be also if (type.isHigherPriorityThan(reconnectionCause)) { - Console.warn( - "Now reconnecting because of " + type + " failure"); + Console.warn("Now reconnecting because of " + type + " failure"); reconnectionCause = type; } } @@ -214,12 +206,11 @@ protected void handleRecoverableError(Type type, final JsonObject payload) { /** * Called after a problem occurred. * - * This method is responsible for re-sending the payload to the server (if - * not null) or re-send a heartbeat request at some point + * This method is responsible for re-sending the payload to the server (if not null) or re-send a heartbeat request + * at some point * * @param payload - * the payload that did not reach the server, null if the problem - * was detected by a heartbeat + * the payload that did not reach the server, null if the problem was detected by a heartbeat */ protected void scheduleReconnect(final JsonObject payload) { // Here and not in timer to avoid TB for getting in between @@ -237,25 +228,21 @@ public void run() { doReconnect(payload); } }; - scheduledReconnect - .schedule(getConfiguration().getReconnectInterval()); + scheduledReconnect.schedule(getConfiguration().getReconnectInterval()); } } /** - * Re-sends the payload to the server (if not null) or re-sends a heartbeat - * request immediately. + * Re-sends the payload to the server (if not null) or re-sends a heartbeat request immediately. * * @param payload - * the payload that did not reach the server, null if the problem - * was detected by a heartbeat + * the payload that did not reach the server, null if the problem was detected by a heartbeat */ protected void doReconnect(JsonObject payload) { if (!registry.getUILifecycle().isRunning()) { // This should not happen as nobody should call this if the // application has been stopped - Console.warn( - "Trying to reconnect after application has been stopped. Giving up"); + Console.warn("Trying to reconnect after application has been stopped. Giving up"); return; } if (payload != null) { @@ -269,8 +256,8 @@ protected void doReconnect(JsonObject payload) { } /** - * Called when we should give up trying to reconnect and inform the user - * that the application is in CONNECTION_LOST state. + * Called when we should give up trying to reconnect and inform the user that the application is in CONNECTION_LOST + * state. */ protected final void giveUp() { reconnectionCause = null; @@ -284,16 +271,14 @@ protected final void giveUp() { } /** - * Gets the text to show in the reconnect dialog after giving up (reconnect - * limit reached). + * Gets the text to show in the reconnect dialog after giving up (reconnect limit reached). * * @param reconnectAttempt * The number of the current reconnection attempt * @return The text to show in the reconnect dialog after giving up */ protected String getDialogTextGaveUp(int reconnectAttempt) { - return getConfiguration().getDialogTextGaveUp().replace("{0}", - reconnectAttempt + ""); + return getConfiguration().getDialogTextGaveUp().replace("{0}", reconnectAttempt + ""); } /** @@ -304,20 +289,17 @@ protected String getDialogTextGaveUp(int reconnectAttempt) { * @return The text to show in the reconnect dialog */ protected String getDialogText(int reconnectAttempt) { - return getConfiguration().getDialogText().replace("{0}", - reconnectAttempt + ""); + return getConfiguration().getDialogText().replace("{0}", reconnectAttempt + ""); } @Override public void configurationUpdated() { // All other properties are fetched directly from the state when needed if (getConfiguration().getDialogText() != null) { - ConnectionIndicator.setProperty("reconnectingText", - getConfiguration().getDialogText()); + ConnectionIndicator.setProperty("reconnectingText", getConfiguration().getDialogText()); } if (getConfiguration().getDialogTextGaveUp() != null) { - ConnectionIndicator.setProperty("offlineText", - getConfiguration().getDialogTextGaveUp()); + ConnectionIndicator.setProperty("offlineText", getConfiguration().getDialogTextGaveUp()); } } @@ -332,16 +314,14 @@ public void xhrInvalidContent(XhrConnectionError xhrConnectionError) { String responseText = xhrConnectionError.getXhr().getResponseText(); if (!redirectIfRefreshToken(responseText)) { - handleUnrecoverableCommunicationError( - "Invalid JSON response from server: " + responseText, + handleUnrecoverableCommunicationError("Invalid JSON response from server: " + responseText, xhrConnectionError); } } @Override - public void pushInvalidContent(PushConnection pushConnection, - String message) { + public void pushInvalidContent(PushConnection pushConnection, String message) { debug("pushInvalidContent"); if (pushConnection.isBidirectional()) { // We can't be sure that what was pushed was actually a response but @@ -351,8 +331,7 @@ public void pushInvalidContent(PushConnection pushConnection, } if (!redirectIfRefreshToken(message)) { - handleUnrecoverableCommunicationError( - "Invalid JSON from server: " + message, null); + handleUnrecoverableCommunicationError("Invalid JSON from server: " + message, null); } } @@ -384,8 +363,7 @@ private void endRequest() { protected void handleUnauthorized(XhrConnectionError xhrConnectionError) { /* - * Authorization has failed (401). Assume that the session has timed - * out. + * Authorization has failed (401). Assume that the session has timed out. */ registry.getSystemErrorHandler().handleSessionExpiredError(""); stopApplication(); @@ -402,8 +380,7 @@ private void stopApplication() { } } - private void handleUnrecoverableCommunicationError(String details, - XhrConnectionError xhrConnectionError) { + private void handleUnrecoverableCommunicationError(String details, XhrConnectionError xhrConnectionError) { int statusCode = -1; if (xhrConnectionError != null) { XMLHttpRequest xhr = xhrConnectionError.getXhr(); @@ -426,8 +403,7 @@ private void handleUnrecoverableCommunicationError(String details, * the status code */ protected void handleCommunicationError(String details, int statusCode) { - registry.getSystemErrorHandler().handleUnrecoverableError("", details, - "", null); + registry.getSystemErrorHandler().handleUnrecoverableError("", details, "", null); } @Override @@ -463,8 +439,7 @@ public void pushOk(PushConnection pushConnection) { @Override public void pushScriptLoadError(String resourceUrl) { - handleCommunicationError( - resourceUrl + " could not be loaded. Push will not work.", 0); + handleCommunicationError(resourceUrl + " could not be loaded. Push will not work.", 0); } @Override @@ -475,8 +450,7 @@ public void pushNotConnected(JsonObject payload) { @Override public void pushReconnectPending(PushConnection pushConnection) { - debug("pushReconnectPending(" + pushConnection.getTransportType() - + ")"); + debug("pushReconnectPending(" + pushConnection.getTransportType() + ")"); Console.log("Reopening push connection"); if (pushConnection.isBidirectional()) { // Lost connection for a connection which will tell us when the @@ -491,28 +465,22 @@ public void pushReconnectPending(PushConnection pushConnection) { } @Override - public void pushError(PushConnection pushConnection, - JavaScriptObject response) { + public void pushError(PushConnection pushConnection, JavaScriptObject response) { debug("pushError()"); - handleCommunicationError("Push connection using " - + ((AtmosphereResponse) response).getTransport() + " failed!", + handleCommunicationError("Push connection using " + ((AtmosphereResponse) response).getTransport() + " failed!", -1); } @Override - public void pushClientTimeout(PushConnection pushConnection, - JavaScriptObject response) { + public void pushClientTimeout(PushConnection pushConnection, JavaScriptObject response) { debug("pushClientTimeout()"); // TODO Reconnect, allowing client timeout to be set // https://dev.vaadin.com/ticket/18429 - handleCommunicationError( - "Client unexpectedly disconnected. Ensure client timeout is disabled.", - -1); + handleCommunicationError("Client unexpectedly disconnected. Ensure client timeout is disabled.", -1); } @Override - public void pushClosed(PushConnection pushConnection, - JavaScriptObject response) { + public void pushClosed(PushConnection pushConnection, JavaScriptObject response) { debug("pushClosed()"); Console.log("Push connection closed"); } @@ -522,20 +490,16 @@ private void pauseHeartbeats() { } private void resumeHeartbeats() { - registry.getHeartbeat().setInterval( - registry.getApplicationConfiguration().getHeartbeatInterval()); + registry.getHeartbeat().setInterval(registry.getApplicationConfiguration().getHeartbeatInterval()); } private boolean redirectIfRefreshToken(String message) { /* - * A servlet filter or equivalent may have intercepted the request and - * served non-UIDL content (for instance, a login page if the session - * has expired.) If the response contains a magic substring, do a - * synchronous refresh. See #8241. + * A servlet filter or equivalent may have intercepted the request and served non-UIDL content (for instance, a + * login page if the session has expired.) If the response contains a magic substring, do a synchronous refresh. + * See #8241. */ - MatchResult refreshToken = RegExp - .compile(UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)") - .exec(message); + MatchResult refreshToken = RegExp.compile(UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)").exec(message); if (refreshToken != null) { WidgetUtil.redirect(refreshToken.getGroup(2)); return true; diff --git a/flow-client/src/main/java/com/vaadin/client/communication/Heartbeat.java b/flow-client/src/main/java/com/vaadin/client/communication/Heartbeat.java index d3ee979787a..10abb427ce7 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/Heartbeat.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/Heartbeat.java @@ -51,15 +51,12 @@ public void run() { */ public Heartbeat(Registry registry) { this.registry = registry; - setInterval( - registry.getApplicationConfiguration().getHeartbeatInterval()); + setInterval(registry.getApplicationConfiguration().getHeartbeatInterval()); uri = registry.getApplicationConfiguration().getServiceUrl(); - uri = SharedUtil.addGetParameter(uri, - ApplicationConstants.REQUEST_TYPE_PARAMETER, + uri = SharedUtil.addGetParameter(uri, ApplicationConstants.REQUEST_TYPE_PARAMETER, ApplicationConstants.REQUEST_TYPE_HEARTBEAT); - uri = SharedUtil.addGetParameter(uri, - ApplicationConstants.UI_ID_PARAMETER, + uri = SharedUtil.addGetParameter(uri, ApplicationConstants.UI_ID_PARAMETER, registry.getApplicationConfiguration().getUIId()); registry.getUILifecycle().addHandler(e -> { @@ -90,11 +87,9 @@ public void onFail(XMLHttpRequest xhr, Exception e) { // Handler should stop the application if heartbeat should no // longer be sent if (e == null) { - registry.getConnectionStateHandler() - .heartbeatInvalidStatusCode(xhr); + registry.getConnectionStateHandler().heartbeatInvalidStatusCode(xhr); } else { - registry.getConnectionStateHandler().heartbeatException(xhr, - e); + registry.getConnectionStateHandler().heartbeatException(xhr, e); } schedule(); @@ -111,8 +106,7 @@ public int getInterval() { } /** - * Updates the schedule of the heartbeat to match the set interval. A - * negative interval disables the heartbeat. + * Updates the schedule of the heartbeat to match the set interval. A negative interval disables the heartbeat. */ public void schedule() { if (interval > 0) { @@ -131,8 +125,7 @@ public void schedule() { * new interval in seconds. */ public final void setInterval(int heartbeatInterval) { - Console.log( - "Setting heartbeat interval to " + heartbeatInterval + "sec."); + Console.log("Setting heartbeat interval to " + heartbeatInterval + "sec."); interval = heartbeatInterval; schedule(); } diff --git a/flow-client/src/main/java/com/vaadin/client/communication/LoadingIndicatorConfigurator.java b/flow-client/src/main/java/com/vaadin/client/communication/LoadingIndicatorConfigurator.java index 033f85881cd..b29db555251 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/LoadingIndicatorConfigurator.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/LoadingIndicatorConfigurator.java @@ -25,8 +25,8 @@ import com.vaadin.flow.internal.nodefeature.NodeFeatures; /** - * Observes the loading indicator configuration stored in the given node and - * configures the loading indicator accordingly. + * Observes the loading indicator configuration stored in the given node and configures the loading indicator + * accordingly. * * @author Vaadin Ltd * @since 1.0 @@ -38,37 +38,30 @@ private LoadingIndicatorConfigurator() { } /** - * Observes the given node for loading indicator configuration changes and - * configures the loading indicator singleton accordingly. + * Observes the given node for loading indicator configuration changes and configures the loading indicator + * singleton accordingly. * * @param node * the node containing the loading indicator configuration */ public static void observe(StateNode node) { - NodeMap configMap = node - .getMap(NodeFeatures.LOADING_INDICATOR_CONFIGURATION); + NodeMap configMap = node.getMap(NodeFeatures.LOADING_INDICATOR_CONFIGURATION); bindInteger(configMap, LoadingIndicatorConfigurationMap.FIRST_DELAY_KEY, - LoadingIndicatorConfigurator::setFirstDelay, - LoadingIndicatorConfigurationMap.FIRST_DELAY_DEFAULT); - bindInteger(configMap, - LoadingIndicatorConfigurationMap.SECOND_DELAY_KEY, - LoadingIndicatorConfigurator::setSecondDelay, - LoadingIndicatorConfigurationMap.SECOND_DELAY_DEFAULT); + LoadingIndicatorConfigurator::setFirstDelay, LoadingIndicatorConfigurationMap.FIRST_DELAY_DEFAULT); + bindInteger(configMap, LoadingIndicatorConfigurationMap.SECOND_DELAY_KEY, + LoadingIndicatorConfigurator::setSecondDelay, LoadingIndicatorConfigurationMap.SECOND_DELAY_DEFAULT); bindInteger(configMap, LoadingIndicatorConfigurationMap.THIRD_DELAY_KEY, - LoadingIndicatorConfigurator::setThirdDelay, - LoadingIndicatorConfigurationMap.THIRD_DELAY_DEFAULT); + LoadingIndicatorConfigurator::setThirdDelay, LoadingIndicatorConfigurationMap.THIRD_DELAY_DEFAULT); - MapProperty defaultThemeProperty = configMap.getProperty( - LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_KEY); + MapProperty defaultThemeProperty = configMap + .getProperty(LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_KEY); defaultThemeProperty.addChangeListener(event -> setApplyDefaultTheme( - event.getSource().getValueOrDefault( - LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_DEFAULT))); + event.getSource().getValueOrDefault(LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_DEFAULT))); } /** - * Binds change events for the property identified by the given key in the - * given feature to the given setter. + * Binds change events for the property identified by the given key in the given feature to the given setter. * * @param map * the map containing the property @@ -79,11 +72,9 @@ public static void observe(StateNode node) { * @param defaultValue * the value to use if the property value is removed */ - private static void bindInteger(NodeMap map, String key, - Consumer setter, int defaultValue) { + private static void bindInteger(NodeMap map, String key, Consumer setter, int defaultValue) { MapProperty property = map.getProperty(key); - property.addChangeListener(e -> setter - .accept(e.getSource().getValueOrDefault(defaultValue))); + property.addChangeListener(e -> setter.accept(e.getSource().getValueOrDefault(defaultValue))); } private static void setFirstDelay(int delay) { diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java index 56b79126d58..8247cd044eb 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -48,9 +48,8 @@ import elemental.json.JsonObject; /** - * A MessageHandler is responsible for handling all incoming messages (JSON) - * from the server (state changes, RPCs and other updates) and ensuring that the - * connectors are updated accordingly. + * A MessageHandler is responsible for handling all incoming messages (JSON) from the server (state changes, RPCs and + * other updates) and ensuring that the connectors are updated accordingly. * * @author Vaadin Ltd * @since 1.0 @@ -63,22 +62,20 @@ public class MessageHandler { /** * The value of an undefined sync id. *

- * This must be -1, because of the contract in - * {@link #getLastSeenServerSyncId()} + * This must be -1, because of the contract in {@link #getLastSeenServerSyncId()} */ private static final int UNDEFINED_SYNC_ID = -1; /** - * If responseHandlingLocks contains any objects, response handling is - * suspended until the collection is empty or a timeout has occurred. + * If responseHandlingLocks contains any objects, response handling is suspended until the collection is empty or a + * timeout has occurred. */ private JsSet responseHandlingLocks = JsCollections.set(); /** * Contains all UIDL messages received while response handling is suspended. */ - private JsArray pendingUIDLMessages = JsCollections - .array(); + private JsArray pendingUIDLMessages = JsCollections.array(); // will hold the CSRF token once received private String csrfToken = ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE; @@ -92,42 +89,36 @@ public class MessageHandler { protected int lastProcessingTime; /** - * Holds the total time spent rendering requests during the lifetime of the - * session. + * Holds the total time spent rendering requests during the lifetime of the session. */ protected int totalProcessingTime; /** - * Holds the time it took to load the page and render the first view. -2 - * means that this value has not yet been calculated because the first view - * has not yet been rendered (or that your browser is very fast). -1 means - * that the browser does not support the performance.timing feature used to - * get this measurement. + * Holds the time it took to load the page and render the first view. -2 means that this value has not yet been + * calculated because the first view has not yet been rendered (or that your browser is very fast). -1 means that + * the browser does not support the performance.timing feature used to get this measurement. * * Note: also used for tracking whether the first UIDL has been handled */ private int bootstrapTime; /** - * Holds the timing information from the server-side. How much time was - * spent servicing the last request and how much time has been spent - * servicing the session so far. These values are always one request behind, - * since they cannot be measured before the request is finished. + * Holds the timing information from the server-side. How much time was spent servicing the last request and how + * much time has been spent servicing the session so far. These values are always one request behind, since they + * cannot be measured before the request is finished. */ private ValueMap serverTimingInfo; /** * Holds the last seen response id given by the server. *

- * The server generates a strictly increasing id for each response to each - * request from the client. This ID is then replayed back to the server on - * each request. This helps the server in knowing in what state the client - * is, and compare it to its own state. In short, it helps with concurrent - * changes between the client and server. + * The server generates a strictly increasing id for each response to each request from the client. This ID is then + * replayed back to the server on each request. This helps the server in knowing in what state the client is, and + * compare it to its own state. In short, it helps with concurrent changes between the client and server. *

- * Initial value, i.e. no responses received from the server, is - * {@link #UNDEFINED_SYNC_ID} ({@value #UNDEFINED_SYNC_ID}). This happens - * between the bootstrap HTML being loaded and the first UI being rendered; + * Initial value, i.e. no responses received from the server, is {@link #UNDEFINED_SYNC_ID} + * ({@value #UNDEFINED_SYNC_ID}). This happens between the bootstrap HTML being loaded and the first UI being + * rendered; */ private int lastSeenServerSyncId = UNDEFINED_SYNC_ID; private final Registry registry; @@ -135,8 +126,7 @@ public class MessageHandler { private boolean initialMessageHandled; /** - * Timer used to make sure that no misbehaving components can delay response - * handling forever. + * Timer used to make sure that no misbehaving components can delay response handling forever. */ private Timer forceHandleMessage = new Timer() { @Override @@ -178,24 +168,22 @@ public MessageHandler(Registry registry) { } /** - * Handles a received UIDL JSON text, parsing it, and passing it on to the - * appropriate handlers, while logging timing information. + * Handles a received UIDL JSON text, parsing it, and passing it on to the appropriate handlers, while logging + * timing information. * * @param json * The JSON to handle */ public void handleMessage(final ValueMap json) { if (json == null) { - throw new IllegalArgumentException( - "The json to handle cannot be null"); + throw new IllegalArgumentException("The json to handle cannot be null"); } if (getServerId(json) == -1) { ValueMap meta = json.getValueMap("meta"); // Log the error only if session didn't expire. - if (meta == null - || !meta.containsKey(JsonConstants.META_SESSION_EXPIRED)) { + if (meta == null || !meta.containsKey(JsonConstants.META_SESSION_EXPIRED)) { Console.error("Response didn't contain a server id. " + "Please verify that the server is up-to-date and that the response data has not been modified in transmission."); } @@ -211,8 +199,7 @@ public void handleMessage(final ValueMap json) { if (state == UIState.RUNNING) { handleJSON(json); } else { - Console.warn( - "Ignored received message because application has already been stopped"); + Console.warn("Ignored received message because application has already been stopped"); } } @@ -226,22 +213,18 @@ protected void handleJSON(final ValueMap valueMap) { JsonObject json = valueMap.cast(); if (json.hasKey(JsonConstants.UIDL_KEY_EXECUTE)) { - JsonArray commands = json - .getArray(JsonConstants.UIDL_KEY_EXECUTE); + JsonArray commands = json.getArray(JsonConstants.UIDL_KEY_EXECUTE); for (int i = 0; i < commands.length(); i++) { JsonArray command = commands.getArray(i); - if (command.length() > 0 && "window.location.reload();" - .equals(command.getString(0))) { - Console.warn( - "Executing forced page reload while a resync request is ongoing."); + if (command.length() > 0 && "window.location.reload();".equals(command.getString(0))) { + Console.warn("Executing forced page reload while a resync request is ongoing."); Browser.getWindow().getLocation().reload(); return; } } } - Console.warn( - "Ignoring message from the server as a resync request is ongoing."); + Console.warn("Ignoring message from the server as a resync request is ongoing."); return; } @@ -252,8 +235,7 @@ protected void handleJSON(final ValueMap valueMap) { // messages and ensure this is handled next. Otherwise we // would keep waiting for an older message forever (if this // is triggered by forceHandleMessage) - Console.log("Received resync message with id " + serverId - + " while waiting for " + getExpectedServerId()); + Console.log("Received resync message with id " + serverId + " while waiting for " + getExpectedServerId()); lastSeenServerSyncId = serverId - 1; removeOldPendingMessages(); } @@ -273,37 +255,31 @@ protected void handleJSON(final ValueMap valueMap) { // Unexpected server id if (serverId <= lastSeenServerSyncId) { // Why is the server re-sending an old package? Ignore it - Console.warn("Received message with server id " + serverId - + " but have already seen " + lastSeenServerSyncId - + ". Ignoring it"); + Console.warn("Received message with server id " + serverId + " but have already seen " + + lastSeenServerSyncId + ". Ignoring it"); endRequestIfResponse(valueMap); return; } // We are waiting for an earlier message... - Console.log("Received message with server id " + serverId - + " but expected " + getExpectedServerId() + Console.log("Received message with server id " + serverId + " but expected " + getExpectedServerId() + ". Postponing handling until the missing message(s) have been received"); } pendingUIDLMessages.push(new PendingUIDLMessage(valueMap)); if (!forceHandleMessage.isRunning()) { - int timeout = registry.getApplicationConfiguration() - .getMaxMessageSuspendTimeout(); + int timeout = registry.getApplicationConfiguration().getMaxMessageSuspendTimeout(); forceHandleMessage.schedule(timeout); } return; } /** - * Should only prepare resync after the if (locked || - * !isNextExpectedMessage(serverId)) {...} since - * stateTree.repareForResync() will remove the nodes, and if locked is - * true, it will return without handling the message, thus won't adding - * nodes back. + * Should only prepare resync after the if (locked || !isNextExpectedMessage(serverId)) {...} since + * stateTree.repareForResync() will remove the nodes, and if locked is true, it will return without handling the + * message, thus won't adding nodes back. * - * This is related to https://github.com/vaadin/flow/issues/8699 It - * seems that the reason is that `connectClient` is removed from the - * rootNode( element) during a resync and not added back. + * This is related to https://github.com/vaadin/flow/issues/8699 It seems that the reason is that + * `connectClient` is removed from the rootNode( element) during a resync and not added back. */ if (isResynchronize(valueMap)) { // Unregister all nodes and rebuild the state tree @@ -312,29 +288,24 @@ protected void handleJSON(final ValueMap valueMap) { double start = Duration.currentTimeMillis(); /* - * Lock response handling to avoid a situation where something pushed - * from the server gets processed while waiting for e.g. lazily loaded - * connectors that are needed for processing the current message. + * Lock response handling to avoid a situation where something pushed from the server gets processed while + * waiting for e.g. lazily loaded connectors that are needed for processing the current message. */ final Object lock = new Object(); suspendReponseHandling(lock); Console.log("Handling message from server"); - registry.getRequestResponseTracker() - .fireEvent(new ResponseHandlingStartedEvent()); + registry.getRequestResponseTracker().fireEvent(new ResponseHandlingStartedEvent()); // Client id must be updated before server id, as server id update can // cause a resync (which must use the updated id) if (valueMap.containsKey(ApplicationConstants.CLIENT_TO_SERVER_ID)) { - int serverNextExpected = valueMap - .getInt(ApplicationConstants.CLIENT_TO_SERVER_ID); - registry.getMessageSender().setClientToServerMessageId( - serverNextExpected, isResynchronize(valueMap)); + int serverNextExpected = valueMap.getInt(ApplicationConstants.CLIENT_TO_SERVER_ID); + registry.getMessageSender().setClientToServerMessageId(serverNextExpected, isResynchronize(valueMap)); } if (serverId != -1) { /* - * Use sync id unless explicitly set as undefined, as is done by - * e.g. critical server-side notifications + * Use sync id unless explicitly set as undefined, as is done by e.g. critical server-side notifications */ lastSeenServerSyncId = serverId; } @@ -349,8 +320,7 @@ protected void handleJSON(final ValueMap valueMap) { // Get security key if (valueMap.containsKey(ApplicationConstants.UIDL_SECURITY_TOKEN_ID)) { - csrfToken = valueMap - .getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); + csrfToken = valueMap.getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); } // Get push id if present @@ -362,12 +332,10 @@ protected void handleJSON(final ValueMap valueMap) { if (!initialMessageHandled) { /* - * When handling the initial JSON message, dependencies are embedded - * in the HTML document instead of being injected by - * DependencyLoader. We must still explicitly wait for all HTML - * imports from the HTML document to be loaded. It's not necessary - * to explicitly wait for JavaScript dependencies since the browser - * already takes care of that for us. + * When handling the initial JSON message, dependencies are embedded in the HTML document instead of being + * injected by DependencyLoader. We must still explicitly wait for all HTML imports from the HTML document + * to be loaded. It's not necessary to explicitly wait for JavaScript dependencies since the browser already + * takes care of that for us. */ registry.getDependencyLoader().requireHtmlImportsReady(); } @@ -379,10 +347,8 @@ protected void handleJSON(final ValueMap valueMap) { serverTimingInfo = valueMap.getValueMap("timings"); } - DependencyLoader.runWhenEagerDependenciesLoaded( - DomApi::updateApiImplementation); - DependencyLoader.runWhenEagerDependenciesLoaded( - () -> processMessage(valueMap, lock, start)); + DependencyLoader.runWhenEagerDependenciesLoaded(DomApi::updateApiImplementation); + DependencyLoader.runWhenEagerDependenciesLoaded(() -> processMessage(valueMap, lock, start)); } private void handleDependencies(JsonObject inputJson) { @@ -400,8 +366,7 @@ private void handleDependencies(JsonObject inputJson) { } /** - * Performs the actual processing of a server message when all dependencies - * have been loaded. + * Performs the actual processing of a server message when all dependencies have been loaded. * * @param valueMap * the message payload @@ -411,8 +376,7 @@ private void handleDependencies(JsonObject inputJson) { * the time stamp when processing started */ private void processMessage(ValueMap valueMap, Object lock, double start) { - assert getServerId(valueMap) == -1 - || getServerId(valueMap) == lastSeenServerSyncId; + assert getServerId(valueMap) == -1 || getServerId(valueMap) == lastSeenServerSyncId; try { double processUidlStart = Duration.currentTimeMillis(); @@ -434,16 +398,11 @@ assert getServerId(valueMap) == -1 // propagated and after post flush listeners added during // message processing (so add one more post flush listener which // is called after all added post listeners). - Reactive.addPostFlushListener( - () -> Reactive.addPostFlushListener(() -> registry - .getExecuteJavaScriptProcessor() - .execute(json.getArray( - JsonConstants.UIDL_KEY_EXECUTE)))); + Reactive.addPostFlushListener(() -> Reactive.addPostFlushListener(() -> registry + .getExecuteJavaScriptProcessor().execute(json.getArray(JsonConstants.UIDL_KEY_EXECUTE)))); } - Console.log("handleUIDLMessage: " - + (Duration.currentTimeMillis() - processUidlStart) - + " ms"); + Console.log("handleUIDLMessage: " + (Duration.currentTimeMillis() - processUidlStart) + " ms"); Reactive.flush(); @@ -456,18 +415,14 @@ assert getServerId(valueMap) == -1 if (nextResponseSessionExpiredHandler != null) { nextResponseSessionExpiredHandler.execute(); } else if (uiState != UIState.TERMINATED) { - registry.getSystemErrorHandler() - .handleSessionExpiredError(null); + registry.getSystemErrorHandler().handleSessionExpiredError(null); registry.getUILifecycle().setState(UIState.TERMINATED); } - } else if (meta.containsKey("appError") - && uiState != UIState.TERMINATED) { + } else if (meta.containsKey("appError") && uiState != UIState.TERMINATED) { ValueMap error = meta.getValueMap("appError"); - registry.getSystemErrorHandler().handleUnrecoverableError( - error.getString("caption"), - error.getString("message"), - error.getString("details"), error.getString("url"), + registry.getSystemErrorHandler().handleUnrecoverableError(error.getString("caption"), + error.getString("message"), error.getString("details"), error.getString("url"), error.getString("querySelector")); registry.getUILifecycle().setState(UIState.TERMINATED); @@ -483,10 +438,8 @@ assert getServerId(valueMap) == -1 double fetchStart = getFetchStartTime(); if (fetchStart != 0) { - int time = (int) (Duration.currentTimeMillis() - - fetchStart); - Console.log("First response processed " + time - + " ms after fetchStart"); + int time = (int) (Duration.currentTimeMillis() - fetchStart); + Console.log("First response processed " + time + " ms after fetchStart"); } bootstrapTime = calculateBootstrapTime(); @@ -496,8 +449,7 @@ assert getServerId(valueMap) == -1 } } finally { - Console.log(" Processing time was " - + String.valueOf(lastProcessingTime) + "ms"); + Console.log(" Processing time was " + String.valueOf(lastProcessingTime) + "ms"); endRequestIfResponse(valueMap); resumeResponseHandling(lock); @@ -514,8 +466,7 @@ assert getServerId(valueMap) == -1 private void processChanges(JsonObject json) { StateTree tree = registry.getStateTree(); - JsSet updatedNodes = TreeChangeProcessor.processChanges(tree, - json.getArray("changes")); + JsSet updatedNodes = TreeChangeProcessor.processChanges(tree, json.getArray("changes")); if (!registry.getApplicationConfiguration().isProductionMode()) { try { @@ -528,8 +479,8 @@ private void processChanges(JsonObject json) { } } - Reactive.addPostFlushListener(() -> Scheduler.get().scheduleDeferred( - () -> updatedNodes.forEach(this::afterServerUpdates))); + Reactive.addPostFlushListener( + () -> Scheduler.get().scheduleDeferred(() -> updatedNodes.forEach(this::afterServerUpdates))); } private void afterServerUpdates(StateNode node) { @@ -566,8 +517,7 @@ private boolean isResponse(ValueMap json) { } /** - * Checks if the given serverId is the one we are currently waiting for from - * the server. + * Checks if the given serverId is the one we are currently waiting for from the server. */ private boolean isNextExpectedMessage(int serverId) { if (serverId == -1) { @@ -599,16 +549,14 @@ private void forceMessageHandling() { if (!responseHandlingLocks.isEmpty()) { // Lock which was never release -> bug in locker or things just // too slow - Console.warn( - "WARNING: reponse handling was never resumed, forcibly removing locks..."); + Console.warn("WARNING: reponse handling was never resumed, forcibly removing locks..."); responseHandlingLocks.clear(); } else { // Waited for out-of-order message which never arrived // Do one final check and resynchronize if the message is not // there. The final check is only a precaution as this timer // should have been cancelled if the message has arrived - Console.warn("Gave up waiting for message " + getExpectedServerId() - + " from the server"); + Console.warn("Gave up waiting for message " + getExpectedServerId() + " from the server"); } if (!handlePendingMessages() && !pendingUIDLMessages.isEmpty()) { @@ -634,8 +582,8 @@ private void forceMessageHandling() { } /** - * This method can be used to postpone rendering of a response for a short - * period of time (e.g. to avoid the rendering process during animation). + * This method can be used to postpone rendering of a response for a short period of time (e.g. to avoid the + * rendering process during animation). * * @param lock * the lock @@ -657,8 +605,7 @@ public void resumeResponseHandling(Object lock) { forceHandleMessage.cancel(); if (!pendingUIDLMessages.isEmpty()) { - Console.log( - "No more response handling locks, handling pending requests."); + Console.log("No more response handling locks, handling pending requests."); handlePendingMessages(); } } @@ -675,8 +622,7 @@ private static final native int calculateBootstrapTime() }-*/; /** - * Finds the next pending UIDL message and handles it (next pending is - * decided based on the server id). + * Finds the next pending UIDL message and handles it (next pending is decided based on the server id). * * @return true if a message was handled, false otherwise */ @@ -696,8 +642,7 @@ private boolean handlePendingMessages() { } if (toHandle != -1) { - PendingUIDLMessage messageToHandle = pendingUIDLMessages - .remove(toHandle); + PendingUIDLMessage messageToHandle = pendingUIDLMessages.remove(toHandle); handleJSON(messageToHandle.getJson()); // Any remaining messages will be handled when this is called // again at the end of handleJSON @@ -724,13 +669,11 @@ private void removeOldPendingMessages() { /** * Gets the server id included in the last received response. *

- * This id can be used by connectors to determine whether new data has been - * received from the server to avoid doing the same calculations multiple - * times. + * This id can be used by connectors to determine whether new data has been received from the server to avoid doing + * the same calculations multiple times. *

- * No guarantees are made for the structure of the id other than that there - * will be a new unique value every time a new response with data from the - * server is received. + * No guarantees are made for the structure of the id other than that there will be a new unique value every time a + * new response with data from the server is received. *

* The initial id when no request has yet been processed is -1. * @@ -741,8 +684,8 @@ public int getLastSeenServerSyncId() { } /** - * Gets the token (synchronizer token pattern) that the server uses to - * protect against CSRF (Cross Site Request Forgery) attacks. + * Gets the token (synchronizer token pattern) that the server uses to protect against CSRF (Cross Site Request + * Forgery) attacks. * * @return the CSRF token string */ @@ -751,8 +694,7 @@ public String getCsrfToken() { } /** - * Gets the push connection identifier for this session. Used when - * establishing a push connection with the client. + * Gets the push connection identifier for this session. Used when establishing a push connection with the client. * * @return the push connection identifier string */ @@ -763,8 +705,7 @@ public String getPushId() { /** * Checks if the first UIDL has been handled. * - * @return true if the initial UIDL has already been processed, false - * otherwise + * @return true if the initial UIDL has already been processed, false otherwise */ public boolean isInitialUidlHandled() { return bootstrapTime != 0; @@ -777,8 +718,7 @@ public boolean isInitialUidlHandled() { * * @param jsonWithWrapping * the JSON received from the server - * @return an unwrapped JSON string or null if the given string was not - * wrapped + * @return an unwrapped JSON string or null if the given string was not wrapped */ public static String stripJSONWrapping(String jsonWithWrapping) { if (jsonWithWrapping == null) { @@ -798,8 +738,7 @@ public static String stripJSONWrapping(String jsonWithWrapping) { * * @param jsonText * the json from the server - * @return A parsed ValueMap or null if the input could not be parsed (or - * was null) + * @return A parsed ValueMap or null if the input could not be parsed (or was null) */ public static ValueMap parseJson(String jsonText) { if (jsonText == null) { @@ -808,8 +747,7 @@ public static ValueMap parseJson(String jsonText) { final double start = Profiler.getRelativeTimeMillis(); try { ValueMap json = parseJSONResponse(jsonText); - Console.log("JSON parsing took " - + Profiler.getRelativeTimeString(start) + "ms"); + Console.log("JSON parsing took " + Profiler.getRelativeTimeString(start) + "ms"); return json; } catch (final Exception e) { Console.error("Unable to parse JSON: " + jsonText); @@ -827,8 +765,7 @@ private static native ValueMap parseJSONResponse(String jsonText) * * @param wrappedJsonText * the json, wrapped as done by the server - * @return a ValueMap, or null if the wrapping was incorrect or json could - * not be parsed + * @return a ValueMap, or null if the wrapping was incorrect or json could not be parsed */ public static ValueMap parseWrappedJson(String wrappedJsonText) { return parseJson(stripJSONWrapping(wrappedJsonText)); @@ -844,15 +781,13 @@ private static final native double getFetchStartTime() }-*/; /** - * Sets a temporary handler for session expiration. This handler will be - * triggered if and only if the next server message tells that the session - * has expired. + * Sets a temporary handler for session expiration. This handler will be triggered if and only if the next server + * message tells that the session has expired. * * @param nextResponseSessionExpiredHandler * the handler to use or null to remove a previously set handler */ - public void setNextResponseSessionExpiredHandler( - Command nextResponseSessionExpiredHandler) { + public void setNextResponseSessionExpiredHandler(Command nextResponseSessionExpiredHandler) { this.nextResponseSessionExpiredHandler = nextResponseSessionExpiredHandler; } } diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java index 2cf6ec6c2b7..03cf06ca2fc 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java @@ -29,8 +29,8 @@ /** * MessageSender is responsible for sending messages to the server. *

- * Internally uses {@link XhrConnection} and/or {@link PushConnection} for - * delivering messages, depending on the application configuration. + * Internally uses {@link XhrConnection} and/or {@link PushConnection} for delivering messages, depending on the + * application configuration. * * @author Vaadin Ltd * @since 1.0 @@ -76,21 +76,18 @@ public MessageSender(Registry registry) { } /** - * Sends any pending invocations to the server if there is no request in - * progress and the application is running. + * Sends any pending invocations to the server if there is no request in progress and the application is running. *

- * If a request is in progress, this method does nothing and assumes that it - * is called again when the request completes. + * If a request is in progress, this method does nothing and assumes that it is called again when the request + * completes. */ public void sendInvocationsToServer() { if (!registry.getUILifecycle().isRunning()) { - Console.warn( - "Trying to send RPC from not yet started or stopped application"); + Console.warn("Trying to send RPC from not yet started or stopped application"); return; } - if (registry.getRequestResponseTracker().hasActiveRequest() - || (push != null && !push.isActive())) { + if (registry.getRequestResponseTracker().hasActiveRequest() || (push != null && !push.isActive())) { // There is an active request or push is enabled but not active // -> send when current request completes or push becomes active } else { @@ -99,15 +96,13 @@ public void sendInvocationsToServer() { } /** - * Sends all pending method invocations (server RPC and legacy variable - * changes) to the server. + * Sends all pending method invocations (server RPC and legacy variable changes) to the server. * */ private void doSendInvocationsToServer() { ServerRpcQueue serverRpcQueue = registry.getServerRpcQueue(); - if (serverRpcQueue.isEmpty() - && resynchronizationState != ResynchronizationState.SEND_TO_SERVER) { + if (serverRpcQueue.isEmpty() && resynchronizationState != ResynchronizationState.SEND_TO_SERVER) { return; } @@ -115,12 +110,10 @@ private void doSendInvocationsToServer() { JsonArray reqJson = serverRpcQueue.toJson(); serverRpcQueue.clear(); - if (reqJson.length() == 0 - && resynchronizationState != ResynchronizationState.SEND_TO_SERVER) { + if (reqJson.length() == 0 && resynchronizationState != ResynchronizationState.SEND_TO_SERVER) { // Nothing to send, all invocations were filtered out (for // non-existing connectors) - Console.warn( - "All RPCs filtered out, not sending anything to the server"); + Console.warn("All RPCs filtered out, not sending anything to the server"); return; } @@ -144,25 +137,21 @@ private void doSendInvocationsToServer() { * @param extraJson * Parameters that are added to the payload */ - protected void send(final JsonArray reqInvocations, - final JsonObject extraJson) { + protected void send(final JsonArray reqInvocations, final JsonObject extraJson) { registry.getRequestResponseTracker().startRequest(); send(preparePayload(reqInvocations, extraJson)); } - private JsonObject preparePayload(final JsonArray reqInvocations, - final JsonObject extraJson) { + private JsonObject preparePayload(final JsonArray reqInvocations, final JsonObject extraJson) { JsonObject payload = Json.createObject(); String csrfToken = registry.getMessageHandler().getCsrfToken(); if (!csrfToken.equals(ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) { payload.put(ApplicationConstants.CSRF_TOKEN, csrfToken); } payload.put(ApplicationConstants.RPC_INVOCATIONS, reqInvocations); - payload.put(ApplicationConstants.SERVER_SYNC_ID, - registry.getMessageHandler().getLastSeenServerSyncId()); - payload.put(ApplicationConstants.CLIENT_TO_SERVER_ID, - clientToServerMessageId++); + payload.put(ApplicationConstants.SERVER_SYNC_ID, registry.getMessageHandler().getLastSeenServerSyncId()); + payload.put(ApplicationConstants.CLIENT_TO_SERVER_ID, clientToServerMessageId++); if (extraJson != null) { for (String key : extraJson.keys()) { JsonValue value = extraJson.get(key); @@ -173,8 +162,7 @@ private JsonObject preparePayload(final JsonArray reqInvocations, } /** - * Sends an asynchronous or synchronous UIDL request to the server using the - * given URI. + * Sends an asynchronous or synchronous UIDL request to the server using the given URI. * * @param payload * The contents of the request to send @@ -191,8 +179,7 @@ public void send(final JsonObject payload) { * Sets the status for the push connection. * * @param enabled - * true to enable the push connection; - * false to disable the push connection. + * true to enable the push connection; false to disable the push connection. */ public void setPushEnabled(boolean enabled) { if (enabled && push == null) { @@ -201,17 +188,15 @@ public void setPushEnabled(boolean enabled) { push.disconnect(() -> { push = null; /* - * If push has been enabled again while we were waiting for the - * old connection to disconnect, now is the right time to open a - * new connection + * If push has been enabled again while we were waiting for the old connection to disconnect, now is the + * right time to open a new connection */ if (registry.getPushConfiguration().isPushEnabled()) { setPushEnabled(true); } /* - * Send anything that was enqueued while we waited for the - * connection to close + * Send anything that was enqueued while we waited for the connection to close */ if (registry.getServerRpcQueue().isFlushPending()) { registry.getServerRpcQueue().flush(); @@ -221,8 +206,7 @@ public void setPushEnabled(boolean enabled) { } /** - * Returns a human readable string representation of the method used to - * communicate with the server. + * Returns a human readable string representation of the method used to communicate with the server. * * @return A string representation of the current transport type */ @@ -236,13 +220,11 @@ public String getCommunicationMethodName() { } } - return "Client to server: " + clientToServer + ", " - + "server to client: " + serverToClient; + return "Client to server: " + clientToServer + ", " + "server to client: " + serverToClient; } /** - * Resynchronize the client side, i.e. reload all component hierarchy and - * state from the server + * Resynchronize the client side, i.e. reload all component hierarchy and state from the server */ public void resynchronize() { if (requestResynchronize()) { @@ -264,8 +246,7 @@ public void setClientToServerMessageId(int nextExpectedId, boolean force) { return; } if (force) { - Console.log( - "Forced update of clientId to " + clientToServerMessageId); + Console.log("Forced update of clientId to " + clientToServerMessageId); clientToServerMessageId = nextExpectedId; return; } @@ -275,13 +256,11 @@ public void setClientToServerMessageId(int nextExpectedId, boolean force) { // We have never sent a message to the server, so likely the // server knows better (typical case is that we refreshed a // @PreserveOnRefresh UI) - Console.log("Updating client-to-server id to " + nextExpectedId - + " based on server"); + Console.log("Updating client-to-server id to " + nextExpectedId + " based on server"); } else { - Console.warn("Server expects next client-to-server id to be " - + nextExpectedId + " but we were going to use " - + clientToServerMessageId + ". Will use " - + nextExpectedId + "."); + Console.warn( + "Server expects next client-to-server id to be " + nextExpectedId + " but we were going to use " + + clientToServerMessageId + ". Will use " + nextExpectedId + "."); } clientToServerMessageId = nextExpectedId; } else { @@ -291,11 +270,9 @@ public void setClientToServerMessageId(int nextExpectedId, boolean force) { } /** - * Modifies the resynchronize state to indicate that resynchronization is - * desired + * Modifies the resynchronize state to indicate that resynchronization is desired * - * @return true if the resynchronize request still needs to be sent; false - * otherwise + * @return true if the resynchronize request still needs to be sent; false otherwise */ boolean requestResynchronize() { switch (resynchronizationState) { diff --git a/flow-client/src/main/java/com/vaadin/client/communication/PollConfigurator.java b/flow-client/src/main/java/com/vaadin/client/communication/PollConfigurator.java index 52b22cb80b7..32c78b2d020 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/PollConfigurator.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/PollConfigurator.java @@ -22,8 +22,7 @@ import com.vaadin.flow.internal.nodefeature.PollConfigurationMap; /** - * Observes the poll configuration stored in the given node and configures - * polling accordingly. + * Observes the poll configuration stored in the given node and configures polling accordingly. * * @author Vaadin Ltd * @since 1.0 @@ -35,8 +34,7 @@ private PollConfigurator() { } /** - * Observes the given node for poll configuration changes and configures the - * given poller accordingly. + * Observes the given node for poll configuration changes and configures the given poller accordingly. * * @param node * the node containing the poll configuration @@ -45,8 +43,7 @@ private PollConfigurator() { */ public static void observe(StateNode node, Poller poller) { NodeMap configurationMap = node.getMap(NodeFeatures.POLL_CONFIGURATION); - MapProperty pollIntervalProperty = configurationMap - .getProperty(PollConfigurationMap.POLL_INTERVAL_KEY); + MapProperty pollIntervalProperty = configurationMap.getProperty(PollConfigurationMap.POLL_INTERVAL_KEY); pollIntervalProperty.addChangeListener(e -> { int interval = (int) (double) e.getNewValue(); poller.setInterval(interval); diff --git a/flow-client/src/main/java/com/vaadin/client/communication/Poller.java b/flow-client/src/main/java/com/vaadin/client/communication/Poller.java index d5f103d8b0a..29c0d7b980e 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/Poller.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/Poller.java @@ -60,8 +60,8 @@ private void stop() { /** * Sets the polling interval. *

- * Changing the polling interval will stop any current polling and schedule - * a new poll to happen after the given interval. + * Changing the polling interval will stop any current polling and schedule a new poll to happen after the given + * interval. * * @param interval * The interval to use @@ -85,8 +85,7 @@ public void run() { */ public void poll() { StateTree stateTree = registry.getStateTree(); - stateTree.sendEventToServer(stateTree.getRootNode(), - PollEvent.DOM_EVENT_NAME, null); + stateTree.sendEventToServer(stateTree.getRootNode(), PollEvent.DOM_EVENT_NAME, null); } } diff --git a/flow-client/src/main/java/com/vaadin/client/communication/PushConfiguration.java b/flow-client/src/main/java/com/vaadin/client/communication/PushConfiguration.java index cb77bf64bcf..c9b17f4376b 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/PushConfiguration.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/PushConfiguration.java @@ -27,11 +27,9 @@ import com.vaadin.flow.internal.nodefeature.PushConfigurationMap; /** - * Provides the push configuration stored in the root node with an easier to use - * API. + * Provides the push configuration stored in the root node with an easier to use API. * - * Additionally tracks when push is enabled/disabled and informs - * {@link MessageSender}. + * Additionally tracks when push is enabled/disabled and informs {@link MessageSender}. * * @author Vaadin Ltd * @since 1.0 @@ -52,8 +50,7 @@ public PushConfiguration(Registry registry) { } private void setupListener() { - getConfigurationMap().getProperty(PushConfigurationMap.PUSHMODE_KEY) - .addChangeListener(this::onPushModeChange); + getConfigurationMap().getProperty(PushConfigurationMap.PUSHMODE_KEY).addChangeListener(this::onPushModeChange); } /** @@ -71,49 +68,41 @@ private void onPushModeChange(MapPropertyChangeEvent event) { // We must wait until all parts of push configuration has been // updated - Reactive.addFlushListener( - () -> registry.getMessageSender().setPushEnabled(true)); + Reactive.addFlushListener(() -> registry.getMessageSender().setPushEnabled(true)); } else if (oldModeEnabled && !newModeEnabled) { // Switch push off // We must wait until all parts of push configuration has been // updated - Reactive.addFlushListener( - () -> registry.getMessageSender().setPushEnabled(false)); + Reactive.addFlushListener(() -> registry.getMessageSender().setPushEnabled(false)); } } private NodeMap getConfigurationMap() { - return registry.getStateTree().getRootNode() - .getMap(NodeFeatures.UI_PUSHCONFIGURATION); + return registry.getStateTree().getRootNode().getMap(NodeFeatures.UI_PUSHCONFIGURATION); } /** * Gets the push servlet mapping configured or determined on the server. * - * @return the push servlet mapping configured or determined on the server - * or null if none has been configured + * @return the push servlet mapping configured or determined on the server or null if none has been configured */ public String getPushServletMapping() { - if (getConfigurationMap().hasPropertyValue( - PushConfigurationMap.PUSH_SERVLET_MAPPING_KEY)) { - return (String) getConfigurationMap() - .getProperty(PushConfigurationMap.PUSH_SERVLET_MAPPING_KEY) - .getValue(); + if (getConfigurationMap().hasPropertyValue(PushConfigurationMap.PUSH_SERVLET_MAPPING_KEY)) { + return (String) getConfigurationMap().getProperty(PushConfigurationMap.PUSH_SERVLET_MAPPING_KEY).getValue(); } return null; } /** - * Checks if XHR should be used for client -> server messages even though - * we are using a bidirectional push transport such as websockets. + * Checks if XHR should be used for client -> server messages even though we are using a bidirectional push + * transport such as websockets. * * @return true if XHR should always be used, false otherwise */ public boolean isAlwaysXhrToServer() { // The only possible value is "true" - return (getConfigurationMap().hasPropertyValue( - PushConfigurationMap.ALWAYS_USE_XHR_TO_SERVER)); + return (getConfigurationMap().hasPropertyValue(PushConfigurationMap.ALWAYS_USE_XHR_TO_SERVER)); } /** @@ -124,11 +113,9 @@ public boolean isAlwaysXhrToServer() { * @return a map of all parameters configured on the server */ public JsMap getParameters() { - MapProperty p = getConfigurationMap() - .getProperty(PushConfigurationMap.PARAMETERS_KEY); + MapProperty p = getConfigurationMap().getProperty(PushConfigurationMap.PARAMETERS_KEY); StateNode parametersNode = (StateNode) p.getValue(); - NodeMap parametersMap = parametersNode - .getMap(NodeFeatures.UI_PUSHCONFIGURATION_PARAMETERS); + NodeMap parametersMap = parametersNode.getMap(NodeFeatures.UI_PUSHCONFIGURATION_PARAMETERS); JsMap parameters = JsCollections.map(); parametersMap.forEachProperty((property, key) -> { @@ -144,13 +131,11 @@ public JsMap getParameters() { * @return true if push is enabled, false otherwise */ public boolean isPushEnabled() { - return isPushEnabled(getConfigurationMap() - .getProperty(PushConfigurationMap.PUSHMODE_KEY).getValue()); + return isPushEnabled(getConfigurationMap().getProperty(PushConfigurationMap.PUSHMODE_KEY).getValue()); } /** - * Checks the given propertyValue from the PUSHMODE key to determine if push - * is enabled or not. + * Checks the given propertyValue from the PUSHMODE key to determine if push is enabled or not. * * @param propertyValue * the PushMode value diff --git a/flow-client/src/main/java/com/vaadin/client/communication/PushConnection.java b/flow-client/src/main/java/com/vaadin/client/communication/PushConnection.java index 49da4d4cad4..d0c6cacf5dc 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/PushConnection.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/PushConnection.java @@ -21,9 +21,8 @@ import elemental.json.JsonObject; /** - * Represents the client-side endpoint of a bidirectional ("push") communication - * channel. Can be used to send UIDL request messages to the server and to - * receive UIDL messages from the server (either asynchronously or as a response + * Represents the client-side endpoint of a bidirectional ("push") communication channel. Can be used to send UIDL + * request messages to the server and to receive UIDL messages from the server (either asynchronously or as a response * to a UIDL request). * * @author Vaadin Ltd @@ -32,16 +31,15 @@ public interface PushConnection { /** - * Pushes a message to the server. Will throw an exception if the connection - * is not active (see {@link #isActive()}). + * Pushes a message to the server. Will throw an exception if the connection is not active (see + * {@link #isActive()}). *

- * Implementation detail: If the push connection is not connected and the - * message can thus not be sent, the implementation must call - * {@link ConnectionStateHandler#pushNotConnected(JsonObject)}, which will - * retry the send later. + * Implementation detail: If the push connection is not connected and the message can thus not be sent, the + * implementation must call {@link ConnectionStateHandler#pushNotConnected(JsonObject)}, which will retry the send + * later. *

- * This method must not be called if the push connection is not - * bidirectional (if {@link #isBidirectional()} returns false) + * This method must not be called if the push connection is not bidirectional (if {@link #isBidirectional()} returns + * false) * * @param payload * the payload to push @@ -53,54 +51,44 @@ public interface PushConnection { void push(JsonObject payload); /** - * Checks whether this push connection is in a state where it can push - * messages to the server. A connection is active until - * {@link #disconnect(Command)} has been called. + * Checks whether this push connection is in a state where it can push messages to the server. A connection is + * active until {@link #disconnect(Command)} has been called. * - * @return true if this connection can accept new messages; - * false if this connection is disconnected or - * disconnecting. + * @return true if this connection can accept new messages; false if this connection is + * disconnected or disconnecting. */ boolean isActive(); /** - * Closes the push connection. To ensure correct message delivery order, new - * messages should not be sent using any other channel until it has been - * confirmed that all messages pending for this connection have been - * delivered. The provided command callback is invoked when messages can be - * passed using some other communication channel. + * Closes the push connection. To ensure correct message delivery order, new messages should not be sent using any + * other channel until it has been confirmed that all messages pending for this connection have been delivered. The + * provided command callback is invoked when messages can be passed using some other communication channel. *

- * After this method has been called, {@link #isActive()} returns - * false. Calling this method for a connection that is no - * longer active will throw an exception. + * After this method has been called, {@link #isActive()} returns false. Calling this method for a + * connection that is no longer active will throw an exception. * * @param command - * command to invoke when the connection has been properly - * disconnected + * command to invoke when the connection has been properly disconnected * @throws IllegalStateException * if this connection is not active */ void disconnect(Command command); /** - * Returns a human readable string representation of the transport type used - * to communicate with the server. + * Returns a human readable string representation of the transport type used to communicate with the server. * * @return A human readable string representation of the transport type */ String getTransportType(); /** - * Checks whether this push connection should be used for communication in - * both directions or if an XHR should be used for client to server - * communication. + * Checks whether this push connection should be used for communication in both directions or if an XHR should be + * used for client to server communication. * - * A bidirectional push connection must be able to reliably inform about its - * connection state. + * A bidirectional push connection must be able to reliably inform about its connection state. * - * @return true if the push connection should be used for messages in both - * directions, false if it should only be used for server to client - * messages + * @return true if the push connection should be used for messages in both directions, false if it should only be + * used for server to client messages */ boolean isBidirectional(); diff --git a/flow-client/src/main/java/com/vaadin/client/communication/PushConnectionFactory.java b/flow-client/src/main/java/com/vaadin/client/communication/PushConnectionFactory.java index 9745f9006e7..e68143d3d71 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/PushConnectionFactory.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/PushConnectionFactory.java @@ -28,8 +28,7 @@ public interface PushConnectionFactory { /** - * Creates a new {@link PushConnection} instance for the given - * {@code registry}. + * Creates a new {@link PushConnection} instance for the given {@code registry}. * * @param registry * the global registry diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ReconnectConfiguration.java b/flow-client/src/main/java/com/vaadin/client/communication/ReconnectConfiguration.java index 6820fce1514..b566911abfa 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ReconnectConfiguration.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ReconnectConfiguration.java @@ -23,11 +23,9 @@ import com.vaadin.flow.internal.nodefeature.ReconnectDialogConfigurationMap; /** - * Tracks the reconnect configuration stored in the root node and provides it - * with an easier to use API. + * Tracks the reconnect configuration stored in the root node and provides it with an easier to use API. *

- * Also triggers {@link ConnectionStateHandler#configurationUpdated()} whenever - * part of the configuration changes. + * Also triggers {@link ConnectionStateHandler#configurationUpdated()} whenever part of the configuration changes. * * @author Vaadin Ltd * @since 1.0 @@ -47,17 +45,15 @@ public ReconnectConfiguration(Registry registry) { } /** - * Binds this ReconnectDialogConfiguration to the given - * {@link ConnectionStateHandler} so that - * {@link ConnectionStateHandler#configurationUpdated()} is run whenever a - * relevant part of {@link ReconnectConfiguration} changes. + * Binds this ReconnectDialogConfiguration to the given {@link ConnectionStateHandler} so that + * {@link ConnectionStateHandler#configurationUpdated()} is run whenever a relevant part of + * {@link ReconnectConfiguration} changes. * * @param connectionStateHandler * the connection state handler to bind to */ public static void bind(ConnectionStateHandler connectionStateHandler) { - Reactive.runWhenDependenciesChange( - () -> connectionStateHandler.configurationUpdated()); + Reactive.runWhenDependenciesChange(() -> connectionStateHandler.configurationUpdated()); } private MapProperty getProperty(String key) { @@ -75,37 +71,29 @@ private MapProperty getProperty(String key) { */ @Deprecated public String getDialogText() { - return getProperty(ReconnectDialogConfigurationMap.DIALOG_TEXT_KEY) - .getValueOrDefault(null); + return getProperty(ReconnectDialogConfigurationMap.DIALOG_TEXT_KEY).getValueOrDefault(null); } /** - * Gets the text to show in the reconnect dialog when no longer trying to - * reconnect. + * Gets the text to show in the reconnect dialog when no longer trying to reconnect. * - * @return the text to show in the reconnect dialog when no longer trying to - * reconnect + * @return the text to show in the reconnect dialog when no longer trying to reconnect * * @deprecated The API for configuring the connection indicator has changed. */ @Deprecated public String getDialogTextGaveUp() { - return getProperty( - ReconnectDialogConfigurationMap.DIALOG_TEXT_GAVE_UP_KEY) - .getValueOrDefault(null); + return getProperty(ReconnectDialogConfigurationMap.DIALOG_TEXT_GAVE_UP_KEY).getValueOrDefault(null); } /** - * Gets the number of reconnect attempts that should be performed before - * giving up. + * Gets the number of reconnect attempts that should be performed before giving up. * * @return the number of reconnect attempts to perform */ public int getReconnectAttempts() { - return getProperty( - ReconnectDialogConfigurationMap.RECONNECT_ATTEMPTS_KEY) - .getValueOrDefault( - ReconnectDialogConfigurationMap.RECONNECT_ATTEMPTS_DEFAULT); + return getProperty(ReconnectDialogConfigurationMap.RECONNECT_ATTEMPTS_KEY) + .getValueOrDefault(ReconnectDialogConfigurationMap.RECONNECT_ATTEMPTS_DEFAULT); } /** @@ -114,9 +102,7 @@ public int getReconnectAttempts() { * @return the interval in milliseconds to wait between reconnect attempts */ public int getReconnectInterval() { - return getProperty( - ReconnectDialogConfigurationMap.RECONNECT_INTERVAL_KEY) - .getValueOrDefault( - ReconnectDialogConfigurationMap.RECONNECT_INTERVAL_DEFAULT); + return getProperty(ReconnectDialogConfigurationMap.RECONNECT_INTERVAL_KEY) + .getValueOrDefault(ReconnectDialogConfigurationMap.RECONNECT_INTERVAL_DEFAULT); } } diff --git a/flow-client/src/main/java/com/vaadin/client/communication/RequestResponseTracker.java b/flow-client/src/main/java/com/vaadin/client/communication/RequestResponseTracker.java index 0d08be7644a..b256e60d2f5 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/RequestResponseTracker.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/RequestResponseTracker.java @@ -28,11 +28,9 @@ /** * Tracks active server UIDL requests. *

- * Ensures that there is only one outgoing server request active at a given - * time. + * Ensures that there is only one outgoing server request active at a given time. *

- * Fires events when a requests starts, response handling starts and when - * response handling ends. + * Fires events when a requests starts, response handling starts and when response handling ends. * * @author Vaadin Ltd * @since 1.0 @@ -56,15 +54,14 @@ public RequestResponseTracker(Registry registry) { /** * Marks that a new request has started. *

- * Should not be called when a request is in progress, i.e. - * {@link #startRequest()} has been called but not {@link #endRequest()}. + * Should not be called when a request is in progress, i.e. {@link #startRequest()} has been called but not + * {@link #endRequest()}. *

* Fires a {@link RequestStartingEvent}. */ public void startRequest() { if (hasActiveRequest) { - throw new IllegalStateException( - "Trying to start a new request while another is active"); + throw new IllegalStateException("Trying to start a new request while another is active"); } hasActiveRequest = true; fireEvent(new RequestStartingEvent()); @@ -92,8 +89,8 @@ public boolean hasActiveRequest() { /** * Marks that the current request has ended. *

- * Should not be called unless a request is in progress, i.e. - * {@link #startRequest()} has been called but not {@link #endRequest()}. + * Should not be called unless a request is in progress, i.e. {@link #startRequest()} has been called but not + * {@link #endRequest()}. *

* Will trigger sending of any pending invocations to the server. *

@@ -101,18 +98,15 @@ public boolean hasActiveRequest() { */ public void endRequest() { if (!hasActiveRequest) { - throw new IllegalStateException( - "endRequest called when no request is active"); + throw new IllegalStateException("endRequest called when no request is active"); } // After sendInvocationsToServer() there may be a new active // request, so we must set hasActiveRequest to false before, not after, // the call. hasActiveRequest = false; - if ((registry.getUILifecycle().isRunning() - && registry.getServerRpcQueue().isFlushPending()) - || registry.getMessageSender() - .getResynchronizationState() == ResynchronizationState.SEND_TO_SERVER) { + if ((registry.getUILifecycle().isRunning() && registry.getServerRpcQueue().isFlushPending()) + || registry.getMessageSender().getResynchronizationState() == ResynchronizationState.SEND_TO_SERVER) { // Send the pending RPCs immediately. // This might be an unnecessary optimization as ServerRpcQueue has a // finally scheduled command which trigger the send if we do not do @@ -124,8 +118,7 @@ public void endRequest() { // shortly thereafter Scheduler.get().scheduleDeferred(() -> { boolean terminated = registry.getUILifecycle().isTerminated(); - boolean requestNowOrSoon = hasActiveRequest() - || registry.getServerRpcQueue().isFlushPending(); + boolean requestNowOrSoon = hasActiveRequest() || registry.getServerRpcQueue().isFlushPending(); if (terminated || !requestNowOrSoon) { ConnectionIndicator.setState(ConnectionIndicator.CONNECTED); @@ -142,8 +135,7 @@ public void endRequest() { * the handler to add * @return a registration object which can be used to remove the handler */ - public HandlerRegistration addRequestStartingHandler( - RequestStartingEvent.Handler handler) { + public HandlerRegistration addRequestStartingHandler(RequestStartingEvent.Handler handler) { return eventBus.addHandler(RequestStartingEvent.getType(), handler); } @@ -154,10 +146,8 @@ public HandlerRegistration addRequestStartingHandler( * the handler to add * @return a registration object which can be used to remove the handler */ - public HandlerRegistration addResponseHandlingStartedHandler( - ResponseHandlingStartedEvent.Handler handler) { - return eventBus.addHandler(ResponseHandlingStartedEvent.getType(), - handler); + public HandlerRegistration addResponseHandlingStartedHandler(ResponseHandlingStartedEvent.Handler handler) { + return eventBus.addHandler(ResponseHandlingStartedEvent.getType(), handler); } /** @@ -167,10 +157,8 @@ public HandlerRegistration addResponseHandlingStartedHandler( * the handler to add * @return a registration object which can be used to remove the handler */ - public HandlerRegistration addResponseHandlingEndedHandler( - ResponseHandlingEndedEvent.Handler handler) { - return eventBus.addHandler(ResponseHandlingEndedEvent.getType(), - handler); + public HandlerRegistration addResponseHandlingEndedHandler(ResponseHandlingEndedEvent.Handler handler) { + return eventBus.addHandler(ResponseHandlingEndedEvent.getType(), handler); } } diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingEndedEvent.java b/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingEndedEvent.java index 66381b3e220..9425ec606da 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingEndedEvent.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingEndedEvent.java @@ -24,8 +24,7 @@ * @author Vaadin Ltd * @since 1.0 */ -public class ResponseHandlingEndedEvent - extends Event { +public class ResponseHandlingEndedEvent extends Event { /** * Handler for {@link ResponseHandlingEndedEvent}s. @@ -38,8 +37,7 @@ public interface Handler extends EventHandler { * @param responseHandlingEndedEvent * the event object */ - void onResponseHandlingEnded( - ResponseHandlingEndedEvent responseHandlingEndedEvent); + void onResponseHandlingEnded(ResponseHandlingEndedEvent responseHandlingEndedEvent); } private static Type type; diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingStartedEvent.java b/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingStartedEvent.java index c33b69c4e8c..413c814164c 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingStartedEvent.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ResponseHandlingStartedEvent.java @@ -24,8 +24,7 @@ * @author Vaadin Ltd * @since 1.0 */ -public class ResponseHandlingStartedEvent - extends Event { +public class ResponseHandlingStartedEvent extends Event { /** * Handler for {@link ResponseHandlingStartedEvent}s. @@ -38,8 +37,7 @@ public interface Handler extends EventHandler { * @param responseHandlingStartedEvent * the event object */ - void onResponseHandlingStarted( - ResponseHandlingStartedEvent responseHandlingStartedEvent); + void onResponseHandlingStarted(ResponseHandlingStartedEvent responseHandlingStartedEvent); } private static Type type = null; diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ServerConnector.java b/flow-client/src/main/java/com/vaadin/client/communication/ServerConnector.java index 08dc12654b7..28b9dfc6c6a 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ServerConnector.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ServerConnector.java @@ -26,8 +26,7 @@ import elemental.json.JsonValue; /** - * Handles creating and sending messages to the server using - * {@link ServerRpcQueue}. + * Handles creating and sending messages to the server using {@link ServerRpcQueue}. * * @since 1.0 */ @@ -53,18 +52,15 @@ public ServerConnector(Registry registry) { * @param stateObject * the state object or null if none applicable * @param routerLinkEvent - * true if this event was triggered by interaction - * with a router link; false if triggered by history - * navigation + * true if this event was triggered by interaction with a router link; false if + * triggered by history navigation */ - public void sendNavigationMessage(String location, Object stateObject, - boolean routerLinkEvent) { + public void sendNavigationMessage(String location, Object stateObject, boolean routerLinkEvent) { JsonObject message = Json.createObject(); message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_TYPE_NAVIGATION); message.put(JsonConstants.RPC_NAVIGATION_LOCATION, location); if (stateObject != null) { - JsonValue stateJson = ClientJsonCodec - .encodeWithoutTypeInfo(stateObject); + JsonValue stateJson = ClientJsonCodec.encodeWithoutTypeInfo(stateObject); message.put(JsonConstants.RPC_NAVIGATION_STATE, stateJson); } if (routerLinkEvent) { @@ -84,8 +80,7 @@ public void sendNavigationMessage(String location, Object stateObject, * @param eventData * extra data associated with the event */ - public void sendEventMessage(StateNode node, String eventType, - JsonObject eventData) { + public void sendEventMessage(StateNode node, String eventType, JsonObject eventData) { sendEventMessage(node.getId(), eventType, eventData); } @@ -99,8 +94,7 @@ public void sendEventMessage(StateNode node, String eventType, * @param eventData * extra data associated with the event */ - public void sendEventMessage(int nodeId, String eventType, - JsonObject eventData) { + public void sendEventMessage(int nodeId, String eventType, JsonObject eventData) { JsonObject message = Json.createObject(); message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_TYPE_EVENT); message.put(JsonConstants.RPC_NODE, nodeId); @@ -123,14 +117,11 @@ public void sendEventMessage(int nodeId, String eventType, * @param argsArray * the arguments array for the method * @param promiseId - * the promise id to use for getting the result back, or -1 if no - * result is expected + * the promise id to use for getting the result back, or -1 if no result is expected */ - public void sendTemplateEventMessage(StateNode node, String methodName, - JsonArray argsArray, int promiseId) { + public void sendTemplateEventMessage(StateNode node, String methodName, JsonArray argsArray, int promiseId) { JsonObject message = Json.createObject(); - message.put(JsonConstants.RPC_TYPE, - JsonConstants.RPC_PUBLISHED_SERVER_EVENT_HANDLER); + message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_PUBLISHED_SERVER_EVENT_HANDLER); message.put(JsonConstants.RPC_NODE, node.getId()); message.put(JsonConstants.RPC_TEMPLATE_EVENT_METHOD_NAME, methodName); message.put(JsonConstants.RPC_TEMPLATE_EVENT_ARGS, argsArray); @@ -152,15 +143,13 @@ public void sendTemplateEventMessage(StateNode node, String methodName, * @param value * the new value */ - public void sendNodeSyncMessage(StateNode node, int feature, String key, - Object value) { + public void sendNodeSyncMessage(StateNode node, int feature, String key, Object value) { JsonObject message = Json.createObject(); message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_TYPE_MAP_SYNC); message.put(JsonConstants.RPC_NODE, node.getId()); message.put(JsonConstants.RPC_FEATURE, feature); message.put(JsonConstants.RPC_PROPERTY, key); - message.put(JsonConstants.RPC_PROPERTY_VALUE, - ClientJsonCodec.encodeWithoutTypeInfo(value)); + message.put(JsonConstants.RPC_PROPERTY_VALUE, ClientJsonCodec.encodeWithoutTypeInfo(value)); sendMessage(message); } @@ -173,18 +162,16 @@ public void sendNodeSyncMessage(StateNode node, int feature, String key, * @param requestedId * originally requested id of a server side node * @param assignedId - * identifier which should be used on the server side for the - * element (instead of requestedId) + * identifier which should be used on the server side for the element (instead of requestedId) * @param tagName * the requested tagName * @param index * the index of the element on the server side */ - public void sendExistingElementAttachToServer(StateNode parent, - int requestedId, int assignedId, String tagName, int index) { + public void sendExistingElementAttachToServer(StateNode parent, int requestedId, int assignedId, String tagName, + int index) { JsonObject message = Json.createObject(); - message.put(JsonConstants.RPC_TYPE, - JsonConstants.RPC_ATTACH_EXISTING_ELEMENT); + message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_ATTACH_EXISTING_ELEMENT); message.put(JsonConstants.RPC_NODE, parent.getId()); message.put(JsonConstants.RPC_ATTACH_REQUESTED_ID, requestedId); message.put(JsonConstants.RPC_ATTACH_ASSIGNED_ID, assignedId); @@ -202,16 +189,13 @@ public void sendExistingElementAttachToServer(StateNode parent, * @param requestedId * originally requested id of a server side node * @param assignedId - * identifier which should be used on the server side for the - * element (instead of requestedId) + * identifier which should be used on the server side for the element (instead of requestedId) * @param id * id of requested element */ - public void sendExistingElementWithIdAttachToServer(StateNode parent, - int requestedId, int assignedId, String id) { + public void sendExistingElementWithIdAttachToServer(StateNode parent, int requestedId, int assignedId, String id) { JsonObject message = Json.createObject(); - message.put(JsonConstants.RPC_TYPE, - JsonConstants.RPC_ATTACH_EXISTING_ELEMENT_BY_ID); + message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_ATTACH_EXISTING_ELEMENT_BY_ID); message.put(JsonConstants.RPC_NODE, parent.getId()); message.put(JsonConstants.RPC_ATTACH_REQUESTED_ID, requestedId); message.put(JsonConstants.RPC_ATTACH_ASSIGNED_ID, assignedId); @@ -228,11 +212,9 @@ public void sendExistingElementWithIdAttachToServer(StateNode parent, * @param channelId * the id of the channel. * @param arguments - * array of arguments passed to the channel, not - * null. + * array of arguments passed to the channel, not null. */ - public void sendReturnChannelMessage(int stateNodeId, int channelId, - JsonArray arguments) { + public void sendReturnChannelMessage(int stateNodeId, int channelId, JsonArray arguments) { JsonObject message = Json.createObject(); message.put(JsonConstants.RPC_TYPE, JsonConstants.RPC_TYPE_CHANNEL); diff --git a/flow-client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java b/flow-client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java index be8f0ea706f..d476d8f7d0f 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java @@ -24,8 +24,7 @@ import elemental.json.JsonValue; /** - * Manages the queue of server invocations (RPC) which are waiting to be sent to - * the server. + * Manages the queue of server invocations (RPC) which are waiting to be sent to the server. * * @author Vaadin Ltd * @since 1.0 @@ -62,8 +61,7 @@ public ServerRpcQueue(Registry registry) { */ public void add(JsonValue invocation) { if (!registry.getUILifecycle().isRunning()) { - Console.warn( - "Trying to invoke method on not yet started or stopped application"); + Console.warn("Trying to invoke method on not yet started or stopped application"); return; } pendingInvocations.set(pendingInvocations.length(), invocation); @@ -121,8 +119,8 @@ public boolean isFlushPending() { } /** - * Checks if a loading indicator should be shown when the RPCs have been - * sent to the server and we are waiting for a response. + * Checks if a loading indicator should be shown when the RPCs have been sent to the server and we are waiting for a + * response. * * @return true if a loading indicator should be shown, false otherwise */ @@ -133,8 +131,7 @@ public boolean showLoadingIndicator() { /** * Returns the current invocations as JSON. * - * @return the current invocations in a JSON format ready to be sent to the - * server + * @return the current invocations in a JSON format ready to be sent to the server */ public JsonArray toJson() { return pendingInvocations; diff --git a/flow-client/src/main/java/com/vaadin/client/communication/XhrConnection.java b/flow-client/src/main/java/com/vaadin/client/communication/XhrConnection.java index d2c688d4db2..192be4792b3 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/XhrConnection.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/XhrConnection.java @@ -32,8 +32,7 @@ import elemental.json.JsonObject; /** - * Provides a connection to the UIDL request handler on the server and knows how - * to send messages to that end point. + * Provides a connection to the UIDL request handler on the server and knows how to send messages to that end point. * * @author Vaadin Ltd * @since 1.0 @@ -41,11 +40,9 @@ public class XhrConnection { /** - * Webkit will ignore outgoing requests while waiting for a response to a - * navigation event (indicated by a beforeunload event). When this happens, - * we should keep trying to send the request every now and then until there - * is a response or until it throws an exception saying that it is already - * being sent. + * Webkit will ignore outgoing requests while waiting for a response to a navigation event (indicated by a + * beforeunload event). When this happens, we should keep trying to send the request every now and then until there + * is a response or until it throws an exception saying that it is already being sent. */ private boolean webkitMaybeIgnoringRequests = false; @@ -59,13 +56,11 @@ public class XhrConnection { */ public XhrConnection(Registry registry) { this.registry = registry; - Browser.getWindow().addEventListener("beforeunload", - event -> webkitMaybeIgnoringRequests = true, false); + Browser.getWindow().addEventListener("beforeunload", event -> webkitMaybeIgnoringRequests = true, false); - registry.getRequestResponseTracker() - .addResponseHandlingEndedHandler(event -> { - webkitMaybeIgnoringRequests = false; - }); + registry.getRequestResponseTracker().addResponseHandlingEndedHandler(event -> { + webkitMaybeIgnoringRequests = false; + }); } protected XhrResponseHandler createResponseHandler() { @@ -73,9 +68,8 @@ protected XhrResponseHandler createResponseHandler() { } /** - * Handles the response from the server by forwarding the received message - * to {@link MessageHandler} or failures to the appropriate method in - * {@link ConnectionStateHandler}. + * Handles the response from the server by forwarding the received message to {@link MessageHandler} or failures to + * the appropriate method in {@link ConnectionStateHandler}. * */ public class XhrResponseHandler implements Xhr.Callback { @@ -98,13 +92,11 @@ public void setPayload(JsonObject payload) { @Override public void onFail(XMLHttpRequest xhr, Exception e) { - XhrConnectionError errorEvent = new XhrConnectionError(xhr, payload, - e); + XhrConnectionError errorEvent = new XhrConnectionError(xhr, payload, e); if (e == null) { // Response other than 200 - registry.getConnectionStateHandler() - .xhrInvalidStatusCode(errorEvent); + registry.getConnectionStateHandler().xhrInvalidStatusCode(errorEvent); return; } else { registry.getConnectionStateHandler().xhrException(errorEvent); @@ -114,8 +106,7 @@ public void onFail(XMLHttpRequest xhr, Exception e) { @Override public void onSuccess(XMLHttpRequest xhr) { - Console.log("Server visit took " - + Profiler.getRelativeTimeString(requestStartTime) + "ms"); + Console.log("Server visit took " + Profiler.getRelativeTimeString(requestStartTime) + "ms"); // for(;;);["+ realJson +"]" String responseText = xhr.getResponseText(); @@ -123,8 +114,7 @@ public void onSuccess(XMLHttpRequest xhr) { ValueMap json = MessageHandler.parseWrappedJson(responseText); if (json == null) { // Invalid string (not wrapped as expected or can't parse) - registry.getConnectionStateHandler().xhrInvalidContent( - new XhrConnectionError(xhr, payload, null)); + registry.getConnectionStateHandler().xhrInvalidContent(new XhrConnectionError(xhr, payload, null)); return; } @@ -134,8 +124,7 @@ public void onSuccess(XMLHttpRequest xhr) { } /** - * Sets the relative time (see {@link Profiler#getRelativeTimeMillis()}) - * when the request was sent. + * Sets the relative time (see {@link Profiler#getRelativeTimeMillis()}) when the request was sent. * * @param requestStartTime * the relative time when the request was sent @@ -158,8 +147,7 @@ public void send(JsonObject payload) { responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis()); String payloadJson = WidgetUtil.stringify(payload); - XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson, - JsonConstants.JSON_CONTENT_TYPE, responseHandler); + XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson, JsonConstants.JSON_CONTENT_TYPE, responseHandler); Console.log("Sending xhr message to server: " + payloadJson); @@ -189,15 +177,10 @@ protected String getUri() { // the variable in JS scope, breaking strict mode which is // needed for ES6 imports. // See https://github.com/vaadin/flow/pull/6227 - return SharedUtil - .addGetParameter( - SharedUtil.addGetParameter( - registry.getApplicationConfiguration() - .getServiceUrl(), - ApplicationConstants.REQUEST_TYPE_PARAMETER, - ApplicationConstants.REQUEST_TYPE_UIDL), - ApplicationConstants.UI_ID_PARAMETER, - registry.getApplicationConfiguration().getUIId()); + return SharedUtil.addGetParameter( + SharedUtil.addGetParameter(registry.getApplicationConfiguration().getServiceUrl(), + ApplicationConstants.REQUEST_TYPE_PARAMETER, ApplicationConstants.REQUEST_TYPE_UIDL), + ApplicationConstants.UI_ID_PARAMETER, registry.getApplicationConfiguration().getUIId()); } private static native boolean resendRequest(XMLHttpRequest xhr) diff --git a/flow-client/src/main/java/com/vaadin/client/communication/XhrConnectionError.java b/flow-client/src/main/java/com/vaadin/client/communication/XhrConnectionError.java index c53de8a8dfe..02101ef3367 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/XhrConnectionError.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/XhrConnectionError.java @@ -20,8 +20,7 @@ import elemental.json.JsonObject; /** - * XhrConnectionError provides detail about an error which occurred during an - * XHR request to the server. + * XhrConnectionError provides detail about an error which occurred during an XHR request to the server. * * @author Vaadin Ltd * @since 1.0 @@ -33,19 +32,16 @@ public class XhrConnectionError { private final JsonObject payload; /** - * Creates a XhrConnectionError for the given request using the given - * payload. + * Creates a XhrConnectionError for the given request using the given payload. * * @param xhr * the request which caused the error * @param payload * the payload which was on its way to the server * @param exception - * the exception which caused the error or null if the error was - * not caused by an exception + * the exception which caused the error or null if the error was not caused by an exception */ - public XhrConnectionError(XMLHttpRequest xhr, JsonObject payload, - Exception exception) { + public XhrConnectionError(XMLHttpRequest xhr, JsonObject payload, Exception exception) { this.xhr = xhr; this.payload = payload; this.exception = exception; diff --git a/flow-client/src/main/java/com/vaadin/client/flow/ConstantPool.java b/flow-client/src/main/java/com/vaadin/client/flow/ConstantPool.java index d4cbc6bde5d..a022b121661 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/ConstantPool.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/ConstantPool.java @@ -35,8 +35,7 @@ public class ConstantPool { * Imports new constants into this pool. * * @param json - * a JSON object mapping constant keys to constant values, not - * null + * a JSON object mapping constant keys to constant values, not null */ public void importFromJson(JsonObject json) { assert json != null; @@ -55,8 +54,7 @@ public void importFromJson(JsonObject json) { * * @param key * the key to check, not null - * @return true if there is a constant for the given key; - * otherwise false + * @return true if there is a constant for the given key; otherwise false */ public boolean has(String key) { assert key != null; @@ -70,8 +68,7 @@ public boolean has(String key) { * the key to get a constant for, not null * @param * the constant type - * @return the constant value, or null if there is no constant - * with the given key + * @return the constant value, or null if there is no constant with the given key */ @SuppressWarnings("unchecked") // Returns any type to make it easier to use constants as JsInterop types diff --git a/flow-client/src/main/java/com/vaadin/client/flow/ExecuteJavaScriptProcessor.java b/flow-client/src/main/java/com/vaadin/client/flow/ExecuteJavaScriptProcessor.java index bf1954d95ea..17ea9a17b64 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/ExecuteJavaScriptProcessor.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/ExecuteJavaScriptProcessor.java @@ -34,8 +34,7 @@ import elemental.json.JsonValue; /** - * Processes the result of - * {@link Page#executeJs(String, java.io.Serializable...)} on the client. + * Processes the result of {@link Page#executeJs(String, java.io.Serializable...)} on the client. * * @author Vaadin Ltd * @since 1.0 @@ -79,18 +78,14 @@ private void handleInvocation(JsonArray invocation) { JsMap map = JsCollections.map(); for (int i = 0; i < parameterCount; i++) { JsonValue parameterJson = invocation.get(i); - Object parameter = ClientJsonCodec.decodeWithTypeInfo(tree, - parameterJson); + Object parameter = ClientJsonCodec.decodeWithTypeInfo(tree, parameterJson); parameters.push(parameter); parameterNamesAndCode[i] = "$" + i; - StateNode stateNode = ClientJsonCodec.decodeStateNode(tree, - parameterJson); + StateNode stateNode = ClientJsonCodec.decodeStateNode(tree, parameterJson); if (stateNode != null) { - if (isVirtualChildAwaitingInitialization(stateNode) - || !isBound(stateNode)) { + if (isVirtualChildAwaitingInitialization(stateNode) || !isBound(stateNode)) { stateNode.addDomNodeSetListener(node -> { - Reactive.addPostFlushListener( - () -> handleInvocation(invocation)); + Reactive.addPostFlushListener(() -> handleInvocation(invocation)); return true; }); return; @@ -107,27 +102,22 @@ private void handleInvocation(JsonArray invocation) { } private boolean isVirtualChildAwaitingInitialization(StateNode node) { - if (node.getDomNode() != null - || node.getTree().getNode(node.getId()) == null) { + if (node.getDomNode() != null || node.getTree().getNode(node.getId()) == null) { return false; } - if (node.getMap(NodeFeatures.ELEMENT_DATA) - .hasPropertyValue(NodeProperties.PAYLOAD)) { - Object value = node.getMap(NodeFeatures.ELEMENT_DATA) - .getProperty(NodeProperties.PAYLOAD).getValue(); + if (node.getMap(NodeFeatures.ELEMENT_DATA).hasPropertyValue(NodeProperties.PAYLOAD)) { + Object value = node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.PAYLOAD).getValue(); if (value instanceof JsonObject) { JsonObject object = (JsonObject) value; String type = object.getString(NodeProperties.TYPE); - return NodeProperties.INJECT_BY_ID.equals(type) - || NodeProperties.TEMPLATE_IN_TEMPLATE.equals(type); + return NodeProperties.INJECT_BY_ID.equals(type) || NodeProperties.TEMPLATE_IN_TEMPLATE.equals(type); } } return false; } protected boolean isBound(StateNode node) { - boolean isNodeBound = node.getDomNode() != null - && !SimpleElementBindingStrategy.needsRebind(node); + boolean isNodeBound = node.getDomNode() != null && !SimpleElementBindingStrategy.needsRebind(node); if (!isNodeBound || node.getParent() == null) { return isNodeBound; } @@ -135,19 +125,16 @@ protected boolean isBound(StateNode node) { } /** - * Executes the actual invocation. This method is protected instead of - * private for testing purposes. + * Executes the actual invocation. This method is protected instead of private for testing purposes. * * @param parameterNamesAndCode - * an array consisting of parameter names followed by the - * JavaScript expression to execute + * an array consisting of parameter names followed by the JavaScript expression to execute * @param parameters * an array of parameter values * @param nodeParameters * the node parameters */ - protected void invoke(String[] parameterNamesAndCode, - JsArray parameters, + protected void invoke(String[] parameterNamesAndCode, JsArray parameters, JsMap nodeParameters) { assert parameterNamesAndCode.length == parameters.length() + 1; @@ -161,8 +148,7 @@ protected void invoke(String[] parameterNamesAndCode, }), parameters); } catch (Exception exception) { Console.reportStacktrace(exception); - Console.error( - "Exception is thrown during JavaScript execution. Stacktrace will be dumped separately."); + Console.error("Exception is thrown during JavaScript execution. Stacktrace will be dumped separately."); if (!registry.getApplicationConfiguration().isProductionMode()) { StringBuilder codeBuilder = new StringBuilder("["); String delimiter = ""; @@ -179,14 +165,12 @@ protected void invoke(String[] parameterNamesAndCode, if (code.charAt(code.length() - 1) == ']') { code = code.substring(0, code.length() - 1); } - Console.error("The error has occurred in the JS code: '" + code - + "'"); + Console.error("The error has occurred in the JS code: '" + code + "'"); } } } - private boolean handleRemoveExistingNode(Integer removedId, int nodeId, - JsonArray invocation) { + private boolean handleRemoveExistingNode(Integer removedId, int nodeId, JsonArray invocation) { if (removedId.intValue() == nodeId) { Reactive.addPostFlushListener(() -> handleInvocation(invocation)); return true; @@ -198,8 +182,8 @@ private String getAppId() { return registry.getApplicationConfiguration().getApplicationId(); } - private native JsonObject getContextExecutionObject( - JsMap nodeParameters, Runnable stopApplication) + private native JsonObject getContextExecutionObject(JsMap nodeParameters, + Runnable stopApplication) /*-{ var object = {}; object.getNode = $entry(function (element) { diff --git a/flow-client/src/main/java/com/vaadin/client/flow/StateNode.java b/flow-client/src/main/java/com/vaadin/client/flow/StateNode.java index 938c2f0be2d..ea05c3de236 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/StateNode.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/StateNode.java @@ -47,11 +47,9 @@ public class StateNode { private final JsMap features = JsCollections.map(); - private final JsSet unregisterListeners = JsCollections - .set(); + private final JsSet unregisterListeners = JsCollections.set(); - private final JsSet> domNodeSetListeners = JsCollections - .set(); + private final JsSet> domNodeSetListeners = JsCollections.set(); private final JsMap, Object> nodeData = JsCollections.map(); @@ -89,8 +87,7 @@ public int getId() { } /** - * Gets the node list with the given id. Creates a new node list if one - * doesn't already exist. + * Gets the node list with the given id. Creates a new node list if one doesn't already exist. * * @param id * the id of the list @@ -110,8 +107,7 @@ public NodeList getList(int id) { } /** - * Gets the node map with the given id. Creates a new map if one doesn't - * already exist. + * Gets the node map with the given id. Creates a new map if one doesn't already exist. * * @param id * the id of the map @@ -135,8 +131,7 @@ public NodeMap getMap(int id) { * * @param id * the id of the feature - * @return true if this node has the given feature; otherwise - * false + * @return true if this node has the given feature; otherwise false */ public boolean hasFeature(int id) { return features.has(Double.valueOf(id)); @@ -153,8 +148,7 @@ public void forEachFeature(ForEachCallback callback) { } /** - * Gets a JSON object representing the contents of this node. Only intended - * for debugging purposes. + * Gets a JSON object representing the contents of this node. Only intended for debugging purposes. * * @return a JSON representation */ @@ -164,8 +158,7 @@ public JsonObject getDebugJson() { forEachFeature((feature, featureId) -> { JsonValue json = feature.getDebugJson(); if (json != null) { - object.put(tree.getFeatureDebugName(featureId.intValue()), - json); + object.put(tree.getFeatureDebugName(featureId.intValue()), json); } }); @@ -178,22 +171,19 @@ public JsonObject getDebugJson() { * * @see StateTree#unregisterNode(StateNode) * - * @return true if this node has been unregistered; - * false if the node is still registered + * @return true if this node has been unregistered; false if the node is still registered */ public boolean isUnregistered() { return unregistered; } /** - * Unregisters this node, causing all registered node unregister listeners - * to be notified. + * Unregisters this node, causing all registered node unregister listeners to be notified. * * @see #addUnregisterListener(NodeUnregisterListener) */ public void unregister() { - assert tree.getNode(id) == null - : "Node should no longer be findable from the tree"; + assert tree.getNode(id) == null : "Node should no longer be findable from the tree"; assert !unregistered : "Node is already unregistered"; @@ -201,8 +191,7 @@ public void unregister() { NodeUnregisterEvent event = new NodeUnregisterEvent(this); - JsSet copy = JsCollections - .set(unregisterListeners); + JsSet copy = JsCollections.set(unregisterListeners); copy.forEach(l -> l.onUnregister(event)); // Don't refer to the listeners which won't be ever used again unregisterListeners.clear(); @@ -224,8 +213,7 @@ public EventRemover addUnregisterListener(NodeUnregisterListener listener) { /** * Gets the DOM node associated with this state node. * - * @return the DOM node, or null if no DOM node has been - * associated with this state node + * @return the DOM node, or null if no DOM node has been associated with this state node */ public Node getDomNode() { return domNode; @@ -238,12 +226,10 @@ public Node getDomNode() { * the associated DOM node */ public void setDomNode(Node node) { - assert domNode == null || node == null - : "StateNode already has a DOM node"; + assert domNode == null || node == null : "StateNode already has a DOM node"; domNode = node; - JsSet> copy = JsCollections - .set(domNodeSetListeners); + JsSet> copy = JsCollections.set(domNodeSetListeners); copy.forEach(listener -> { if (listener.apply(this) == Boolean.TRUE) { domNodeSetListeners.delete(listener); @@ -252,18 +238,16 @@ public void setDomNode(Node node) { } /** - * Adds a listener to get a notification when the DOM Node is set for this - * {@link StateNode}. + * Adds a listener to get a notification when the DOM Node is set for this {@link StateNode}. *

- * The listener return value is used to decide whether the listener should - * be removed immediately if it returns {@code true}. + * The listener return value is used to decide whether the listener should be removed immediately if it returns + * {@code true}. * * @param listener * listener to add * @return an event remover that can be used for removing the added listener */ - public EventRemover addDomNodeSetListener( - Function listener) { + public EventRemover addDomNodeSetListener(Function listener) { domNodeSetListeners.add(listener); return () -> domNodeSetListeners.delete(listener); } @@ -290,10 +274,9 @@ public void setParent(StateNode parent) { /** * Stores the {@code object} in the {@link StateNode} instance. *

- * The {@code object} may represent any kind of data. This data can be - * retrieved later on via the {@link #getNodeData(Class)} providing the - * class of the object. So make sure you are using some custom type for your - * data to avoid clash with other types. + * The {@code object} may represent any kind of data. This data can be retrieved later on via the + * {@link #getNodeData(Class)} providing the class of the object. So make sure you are using some custom type for + * your data to avoid clash with other types. * * @see #getNodeData(Class) * @@ -307,11 +290,9 @@ public void setNodeData(T object) { } /** - * Gets the object previously stored by the {@link #setNodeData(Object)} by - * its type. + * Gets the object previously stored by the {@link #setNodeData(Object)} by its type. *

- * If there is no stored object with the given type then the method returns - * {@code null}. + * If there is no stored object with the given type then the method returns {@code null}. * * @param clazz * the type of the object to get diff --git a/flow-client/src/main/java/com/vaadin/client/flow/StateTree.java b/flow-client/src/main/java/com/vaadin/client/flow/StateTree.java index 99625ae0fa4..ceff56e788b 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/StateTree.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/StateTree.java @@ -67,15 +67,12 @@ public StateTree(Registry registry) { * Mark this tree as being updated. * * @param updateInProgress - * true if the tree is being updated, - * false if not + * true if the tree is being updated, false if not * @see #isUpdateInProgress() */ public void setUpdateInProgress(boolean updateInProgress) { - assert this.updateInProgress != updateInProgress - : "Inconsistent state tree updating status, expected " - + (updateInProgress ? "no " : "") - + " updates in progress."; + assert this.updateInProgress != updateInProgress : "Inconsistent state tree updating status, expected " + + (updateInProgress ? "no " : "") + " updates in progress."; this.updateInProgress = updateInProgress; getRegistry().getInitialPropertiesHandler().flushPropertyUpdates(); @@ -117,8 +114,7 @@ private static Double getKey(StateNode node) { } /** - * Unregisters a node from this tree. Once the node has been unregistered, - * it can't be registered again. + * Unregisters a node from this tree. Once the node has been unregistered, it can't be registered again. * * @param node * the node to unregister @@ -132,20 +128,17 @@ public void unregisterNode(StateNode node) { } /** - * Unregisters all nodes except root from this tree, and clears the root's - * features. Use to reset the tree in preparation for rebuilding it in in a - * resynchronization response. + * Unregisters all nodes except root from this tree, and clears the root's features. Use to reset the tree in + * preparation for rebuilding it in in a resynchronization response. */ public void prepareForResync() { - rootNode.getList(NodeFeatures.VIRTUAL_CHILDREN) - .forEach(sn -> clearLists((StateNode) sn)); + rootNode.getList(NodeFeatures.VIRTUAL_CHILDREN).forEach(sn -> clearLists((StateNode) sn)); clearLists(rootNode); idToNode.forEach((node, b) -> { if (node != rootNode) { final Node dom = node.getDomNode(); - if (dom != null - && ServerEventObject.getIfPresent(dom) != null) { + if (dom != null && ServerEventObject.getIfPresent(dom) != null) { // reject any promise waiting on this node ServerEventObject.getIfPresent(dom).rejectPromises(); } @@ -176,11 +169,9 @@ public void setResync(boolean resync) { } /** - * Returns the state node in the tree for the given dom node or {@code null} - * if none found. + * Returns the state node in the tree for the given dom node or {@code null} if none found. *

- * Comparison is done with Node.isSameNode() method which is same as - * {@code ===} comparison. + * Comparison is done with Node.isSameNode() method which is same as {@code ===} comparison. * * @param domNode * the dom node to find state node for @@ -213,26 +204,22 @@ private void clearLists(StateNode stateNode) { } /** - * Verifies that the provided node is not null and properly registered with - * this state tree. + * Verifies that the provided node is not null and properly registered with this state tree. * * @param node * the node to test - * @return always true, for use with the assert - * keyword + * @return always true, for use with the assert keyword */ private boolean assertValidNode(StateNode node) { assert node != null : "Node is null"; assert node.getTree() == this : "Node is not created for this tree"; - assert node == getNode(node.getId()) - : "Node id is not registered with this tree"; + assert node == getNode(node.getId()) : "Node id is not registered with this tree"; return true; } /** - * Validates that the provided node is not null and is properly registered - * for this state tree. + * Validates that the provided node is not null and is properly registered for this state tree. *

* Logs a warning if there was a problem with the node. * @@ -261,8 +248,7 @@ private boolean isValidNode(StateNode node) { * * @param id * the id - * @return the node with the given id, or null if no such node - * is registered. + * @return the node with the given id, or null if no such node is registered. */ public StateNode getNode(int id) { Double key = Double.valueOf(id); @@ -289,11 +275,9 @@ public StateNode getRootNode() { * @param eventData * extra data associated with the event */ - public void sendEventToServer(StateNode node, String eventType, - JsonObject eventData) { + public void sendEventToServer(StateNode node, String eventType, JsonObject eventData) { if (isValidNode(node)) { - registry.getServerConnector().sendEventMessage(node, eventType, - eventData); + registry.getServerConnector().sendEventMessage(node, eventType, eventData); } } @@ -301,8 +285,7 @@ public void sendEventToServer(StateNode node, String eventType, * Sends a map property sync to the server. * * @param property - * the property that should have its value synced to the server, - * not null + * the property that should have its value synced to the server, not null */ public void sendNodePropertySyncToServer(MapProperty property) { assert property != null; @@ -310,39 +293,33 @@ public void sendNodePropertySyncToServer(MapProperty property) { NodeMap nodeMap = property.getMap(); StateNode node = nodeMap.getNode(); - if (getRegistry().getInitialPropertiesHandler() - .handlePropertyUpdate(property) || !isValidNode(node)) { + if (getRegistry().getInitialPropertiesHandler().handlePropertyUpdate(property) || !isValidNode(node)) { return; } - registry.getServerConnector().sendNodeSyncMessage(node, nodeMap.getId(), - property.getName(), property.getValue()); + registry.getServerConnector().sendNodeSyncMessage(node, nodeMap.getId(), property.getName(), + property.getValue()); } /** - * Sends a request to call server side method with {@code methodName} using - * {@code argsArray} as argument values. + * Sends a request to call server side method with {@code methodName} using {@code argsArray} as argument values. *

- * In cases when the state tree has been changed and we receive a delayed or - * deferred template event the event is just ignored. + * In cases when the state tree has been changed and we receive a delayed or deferred template event the event is + * just ignored. * * @param node - * the node referring to the server side instance containing the - * method + * the node referring to the server side instance containing the method * @param methodName * the method name * @param argsArray * the arguments array for the method * @param promiseId - * the promise id to use for getting the result back, or -1 if no - * result is expected + * the promise id to use for getting the result back, or -1 if no result is expected */ - public void sendTemplateEventToServer(StateNode node, String methodName, - JsArray argsArray, int promiseId) { + public void sendTemplateEventToServer(StateNode node, String methodName, JsArray argsArray, int promiseId) { if (isValidNode(node)) { JsonArray array = WidgetUtil.crazyJsCast(argsArray); - registry.getServerConnector().sendTemplateEventMessage(node, - methodName, array, promiseId); + registry.getServerConnector().sendTemplateEventMessage(node, methodName, array, promiseId); } } @@ -354,19 +331,18 @@ public void sendTemplateEventToServer(StateNode node, String methodName, * @param requestedId * originally requested id of a server side node * @param assignedId - * identifier which should be used on the server side for the - * element (instead of requestedId) + * identifier which should be used on the server side for the element (instead of requestedId) * @param tagName * the requested tagName * @param index * the index of the element on the server side */ - public void sendExistingElementAttachToServer(StateNode parent, - int requestedId, int assignedId, String tagName, int index) { + public void sendExistingElementAttachToServer(StateNode parent, int requestedId, int assignedId, String tagName, + int index) { assert assertValidNode(parent); - registry.getServerConnector().sendExistingElementAttachToServer(parent, - requestedId, assignedId, tagName, index); + registry.getServerConnector().sendExistingElementAttachToServer(parent, requestedId, assignedId, tagName, + index); } /** @@ -377,17 +353,14 @@ public void sendExistingElementAttachToServer(StateNode parent, * @param requestedId * originally requested id of a server side node * @param assignedId - * identifier which should be used on the server side for the - * element (instead of requestedId) + * identifier which should be used on the server side for the element (instead of requestedId) * @param id * id of requested element */ - public void sendExistingElementWithIdAttachToServer(StateNode parent, - int requestedId, int assignedId, String id) { + public void sendExistingElementWithIdAttachToServer(StateNode parent, int requestedId, int assignedId, String id) { assert assertValidNode(parent); - registry.getServerConnector().sendExistingElementWithIdAttachToServer( - parent, requestedId, assignedId, id); + registry.getServerConnector().sendExistingElementWithIdAttachToServer(parent, requestedId, assignedId, id); } /** @@ -411,12 +384,10 @@ public boolean isVisible(StateNode node) { return true; } NodeMap visibilityMap = node.getMap(NodeFeatures.ELEMENT_DATA); - Boolean visibility = (Boolean) visibilityMap - .getProperty(NodeProperties.VISIBLE).getValue(); + Boolean visibility = (Boolean) visibilityMap.getProperty(NodeProperties.VISIBLE).getValue(); /* - * Absence of value or "true" means that the node should be visible. So - * only "false" means "hide". + * Absence of value or "true" means that the node should be visible. So only "false" means "hide". */ return !Boolean.FALSE.equals(visibility); } @@ -451,51 +422,28 @@ String getFeatureDebugName(int id) { // GWT does not allow to call Class::getFields method, so we cannot // use reflection to fill the map automatically nodeFeatureDebugName.set(NodeFeatures.ELEMENT_DATA, "elementData"); - nodeFeatureDebugName.set(NodeFeatures.ELEMENT_PROPERTIES, - "elementProperties"); - nodeFeatureDebugName.set(NodeFeatures.ELEMENT_CHILDREN, - "elementChildren"); - nodeFeatureDebugName.set(NodeFeatures.ELEMENT_ATTRIBUTES, - "elementAttributes"); - nodeFeatureDebugName.set(NodeFeatures.ELEMENT_LISTENERS, - "elementListeners"); - nodeFeatureDebugName.set(NodeFeatures.UI_PUSHCONFIGURATION, - "pushConfiguration"); - nodeFeatureDebugName.set( - NodeFeatures.UI_PUSHCONFIGURATION_PARAMETERS, - "pushConfigurationParameters"); + nodeFeatureDebugName.set(NodeFeatures.ELEMENT_PROPERTIES, "elementProperties"); + nodeFeatureDebugName.set(NodeFeatures.ELEMENT_CHILDREN, "elementChildren"); + nodeFeatureDebugName.set(NodeFeatures.ELEMENT_ATTRIBUTES, "elementAttributes"); + nodeFeatureDebugName.set(NodeFeatures.ELEMENT_LISTENERS, "elementListeners"); + nodeFeatureDebugName.set(NodeFeatures.UI_PUSHCONFIGURATION, "pushConfiguration"); + nodeFeatureDebugName.set(NodeFeatures.UI_PUSHCONFIGURATION_PARAMETERS, "pushConfigurationParameters"); nodeFeatureDebugName.set(NodeFeatures.TEXT_NODE, "textNode"); - nodeFeatureDebugName.set(NodeFeatures.POLL_CONFIGURATION, - "pollConfiguration"); - nodeFeatureDebugName.set( - NodeFeatures.RECONNECT_DIALOG_CONFIGURATION, - "reconnectDialogConfiguration"); - nodeFeatureDebugName.set( - NodeFeatures.LOADING_INDICATOR_CONFIGURATION, - "loadingIndicatorConfiguration"); + nodeFeatureDebugName.set(NodeFeatures.POLL_CONFIGURATION, "pollConfiguration"); + nodeFeatureDebugName.set(NodeFeatures.RECONNECT_DIALOG_CONFIGURATION, "reconnectDialogConfiguration"); + nodeFeatureDebugName.set(NodeFeatures.LOADING_INDICATOR_CONFIGURATION, "loadingIndicatorConfiguration"); nodeFeatureDebugName.set(NodeFeatures.CLASS_LIST, "classList"); - nodeFeatureDebugName.set(NodeFeatures.ELEMENT_STYLE_PROPERTIES, - "elementStyleProperties"); - nodeFeatureDebugName.set(NodeFeatures.COMPONENT_MAPPING, - "componentMapping"); - nodeFeatureDebugName.set(NodeFeatures.TEMPLATE_MODELLIST, - "modelList"); - nodeFeatureDebugName.set(NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS, - "polymerServerEventHandlers"); - nodeFeatureDebugName.set(NodeFeatures.POLYMER_EVENT_LISTENERS, - "polymerEventListenerMap"); - nodeFeatureDebugName.set(NodeFeatures.CLIENT_DELEGATE_HANDLERS, - "clientDelegateHandlers"); - nodeFeatureDebugName.set(NodeFeatures.SHADOW_ROOT_DATA, - "shadowRootData"); - nodeFeatureDebugName.set(NodeFeatures.SHADOW_ROOT_HOST, - "shadowRootHost"); - nodeFeatureDebugName.set(NodeFeatures.ATTACH_EXISTING_ELEMENT, - "attachExistingElementFeature"); - nodeFeatureDebugName.set(NodeFeatures.VIRTUAL_CHILDREN, - "virtualChildrenList"); - nodeFeatureDebugName.set(NodeFeatures.BASIC_TYPE_VALUE, - "basicTypeValue"); + nodeFeatureDebugName.set(NodeFeatures.ELEMENT_STYLE_PROPERTIES, "elementStyleProperties"); + nodeFeatureDebugName.set(NodeFeatures.COMPONENT_MAPPING, "componentMapping"); + nodeFeatureDebugName.set(NodeFeatures.TEMPLATE_MODELLIST, "modelList"); + nodeFeatureDebugName.set(NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS, "polymerServerEventHandlers"); + nodeFeatureDebugName.set(NodeFeatures.POLYMER_EVENT_LISTENERS, "polymerEventListenerMap"); + nodeFeatureDebugName.set(NodeFeatures.CLIENT_DELEGATE_HANDLERS, "clientDelegateHandlers"); + nodeFeatureDebugName.set(NodeFeatures.SHADOW_ROOT_DATA, "shadowRootData"); + nodeFeatureDebugName.set(NodeFeatures.SHADOW_ROOT_HOST, "shadowRootHost"); + nodeFeatureDebugName.set(NodeFeatures.ATTACH_EXISTING_ELEMENT, "attachExistingElementFeature"); + nodeFeatureDebugName.set(NodeFeatures.VIRTUAL_CHILDREN, "virtualChildrenList"); + nodeFeatureDebugName.set(NodeFeatures.BASIC_TYPE_VALUE, "basicTypeValue"); } if (nodeFeatureDebugName.has(id)) { return nodeFeatureDebugName.get(id); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/TreeChangeProcessor.java b/flow-client/src/main/java/com/vaadin/client/flow/TreeChangeProcessor.java index eaa1973fce4..07883e250f2 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/TreeChangeProcessor.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/TreeChangeProcessor.java @@ -49,10 +49,8 @@ private TreeChangeProcessor() { * the JSON array of changes * @return a set of updated nodes addressed by the {@code changes} */ - public static JsSet processChanges(StateTree tree, - JsonArray changes) { - assert !tree.isUpdateInProgress() - : "Previous tree change processing has not completed"; + public static JsSet processChanges(StateTree tree, JsonArray changes) { + assert !tree.isUpdateInProgress() : "Previous tree change processing has not completed"; try { tree.setUpdateInProgress(true); @@ -77,8 +75,7 @@ public static JsSet processChanges(StateTree tree, } } - private static JsSet processAttachChanges(StateTree tree, - JsonArray changes) { + private static JsSet processAttachChanges(StateTree tree, JsonArray changes) { JsSet nodes = JsCollections.set(); int length = changes.length(); for (int i = 0; i < length; i++) { @@ -97,13 +94,11 @@ private static JsSet processAttachChanges(StateTree tree, } private static boolean isAttach(JsonObject change) { - return JsonConstants.CHANGE_TYPE_ATTACH - .equals(change.getString(JsonConstants.CHANGE_TYPE)); + return JsonConstants.CHANGE_TYPE_ATTACH.equals(change.getString(JsonConstants.CHANGE_TYPE)); } /** - * Update a state tree based on a JSON change. This method is public for - * testing purposes. + * Update a state tree based on a JSON change. This method is public for testing purposes. * * @param tree * the tree to update @@ -172,17 +167,14 @@ private static void processPutChange(JsonObject change, StateNode node) { Object value = ClientJsonCodec.decodeWithoutTypeInfo(jsonValue); property.setValue(value); } else if (change.hasKey(JsonConstants.CHANGE_PUT_NODE_VALUE)) { - int childId = (int) change - .getNumber(JsonConstants.CHANGE_PUT_NODE_VALUE); + int childId = (int) change.getNumber(JsonConstants.CHANGE_PUT_NODE_VALUE); StateNode child = node.getTree().getNode(childId); assert child != null; child.setParent(node); property.setValue(child); } else { - assert false - : "Change should have either value or nodeValue property: " - + WidgetUtil.stringify(change); + assert false : "Change should have either value or nodeValue property: " + WidgetUtil.stringify(change); } } @@ -214,15 +206,13 @@ private static void processSpliceChange(JsonObject change, StateNode node) { } if (change.hasKey(JsonConstants.CHANGE_SPLICE_ADD)) { - JsonArray addJson = change - .getArray(JsonConstants.CHANGE_SPLICE_ADD); + JsonArray addJson = change.getArray(JsonConstants.CHANGE_SPLICE_ADD); JsArray add = ClientJsonCodec.jsonArrayAsJsArray(addJson); list.splice(index, remove, add); } else if (change.hasKey(JsonConstants.CHANGE_SPLICE_ADD_NODES)) { - JsonArray addNodes = change - .getArray(JsonConstants.CHANGE_SPLICE_ADD_NODES); + JsonArray addNodes = change.getArray(JsonConstants.CHANGE_SPLICE_ADD_NODES); int length = addNodes.length(); JsArray add = JsCollections.array(); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/Binder.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/Binder.java index 271c36cc007..d288cc76dd9 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/Binder.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/Binder.java @@ -39,15 +39,13 @@ public final class Binder { private static final BinderContext CONTEXT = new BinderContextImpl(); /** - * This is the implementation of {@link BinderContext} which is passed to - * the {@link BindingStrategy} instances to be able to delegate creation of - * subnodes with the type that they are not aware of. + * This is the implementation of {@link BinderContext} which is passed to the {@link BindingStrategy} instances to + * be able to delegate creation of subnodes with the type that they are not aware of. *

- * This is the only factory/binder that may be used inside - * {@link BindingStrategy} implementation. So that implementation should not - * know anything about external classes/API. Everything that is required by - * the {@link BindingStrategy} must be here to avoid uncertainty which - * methods are allowed/correct to use in the implementation. + * This is the only factory/binder that may be used inside {@link BindingStrategy} implementation. So that + * implementation should not know anything about external classes/API. Everything that is required by the + * {@link BindingStrategy} must be here to avoid uncertainty which methods are allowed/correct to use in the + * implementation. * * @see BinderContext */ @@ -74,8 +72,7 @@ public void bind(StateNode stateNode, Node node) { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public > JsArray getStrategies( - Predicate> predicate) { + public > JsArray getStrategies(Predicate> predicate) { JsArray array = JsCollections.array(); Predicate testFunction = predicate; for (int i = 0; i < STRATEGIES.length(); i++) { @@ -102,8 +99,7 @@ private Binder() { */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static void bind(StateNode stateNode, Node domNode) { - assert !stateNode.getTree().isUpdateInProgress() - : "Binding state node while processing state tree changes"; + assert !stateNode.getTree().isUpdateInProgress() : "Binding state node while processing state tree changes"; BindingStrategy applicable = getApplicableStrategy(stateNode); applicable.bind(stateNode, domNode, CONTEXT); @@ -115,15 +111,12 @@ private static BindingStrategy getApplicableStrategy(StateNode node) { BindingStrategy strategy = STRATEGIES.get(i); if (strategy.isApplicable(node)) { assert applicable == null - : "Found two strategies for the node : " - + applicable.getClass() + ", " - + strategy.getClass(); + : "Found two strategies for the node : " + applicable.getClass() + ", " + strategy.getClass(); applicable = strategy; } } if (applicable == null) { - throw new IllegalArgumentException( - "State node has no suitable binder strategy"); + throw new IllegalArgumentException("State node has no suitable binder strategy"); } return applicable; } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/BinderContext.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/BinderContext.java index ba2e5f4dbb5..e934d29928a 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/BinderContext.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/BinderContext.java @@ -23,8 +23,8 @@ import elemental.dom.Node; /** - * Binder context which is passed to the {@link BindingStrategy} instances - * enabling them to delegate the creation of any child nodes. + * Binder context which is passed to the {@link BindingStrategy} instances enabling them to delegate the creation of any + * child nodes. * * @author Vaadin Ltd * @since 1.0 @@ -33,12 +33,11 @@ public interface BinderContext { /** - * Creates and binds a DOM node for the given state node. For state nodes - * based on templates, the root element of the template is returned. + * Creates and binds a DOM node for the given state node. For state nodes based on templates, the root element of + * the template is returned. * * @param node - * the state node for which to create a DOM node, not - * null + * the state node for which to create a DOM node, not null * @return the DOM node, not null */ Node createAndBind(StateNode node); @@ -54,14 +53,11 @@ public interface BinderContext { void bind(StateNode stateNode, Node node); /** - * Gets the strategies with a specific type {@code T} using filtering - * {@code predicate}. + * Gets the strategies with a specific type {@code T} using filtering {@code predicate}. *

- * Predicate normally should be based on {@code Class#isInstance()} but - * this method is not available in GWT so predicate {@code instanceof T} - * should be used. It's the developer responsibility to make sure that the - * resulting strategies types are correct to avoid - * {@link ClassCastException}. + * Predicate normally should be based on {@code Class#isInstance()} but this method is not available in GWT so + * predicate {@code instanceof T} should be used. It's the developer responsibility to make sure that the resulting + * strategies types are correct to avoid {@link ClassCastException}. * * @param predicate * predicate to filter strategies using type {@code T}. @@ -70,6 +66,5 @@ public interface BinderContext { * * @return collection of filtered strategies */ - > JsArray getStrategies( - Predicate> predicate); + > JsArray getStrategies(Predicate> predicate); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/BindingStrategy.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/BindingStrategy.java index 05cc6f468a1..291e65031c9 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/BindingStrategy.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/BindingStrategy.java @@ -24,9 +24,8 @@ /** * Binding strategy/factory for {@link StateNode}s. *

- * Only one strategy may be applicable for the given {@link StateNode} instance. - * Once the applicable strategy is identified it's used to produce a - * {@link Node} based on the {@link StateNode} instance and bind it. + * Only one strategy may be applicable for the given {@link StateNode} instance. Once the applicable strategy is + * identified it's used to produce a {@link Node} based on the {@link StateNode} instance and bind it. * * @param * a DOM node type which strategy is applicable for @@ -41,8 +40,7 @@ public interface BindingStrategy { * Creates a DOM node for the {@code node}. * * @param node - * the state node for which to create a DOM node, not - * {@code null} + * the state node for which to create a DOM node, not {@code null} * @return the DOM node, not null */ T create(StateNode node); @@ -58,22 +56,19 @@ public interface BindingStrategy { boolean isApplicable(StateNode node); /** - * Binds a DOM node to the {@code stateNode} using {@code context} to create - * and bind nodes of other types. + * Binds a DOM node to the {@code stateNode} using {@code context} to create and bind nodes of other types. * * @param stateNode * the state node to bind, not {@code null} * @param domNode * the DOM node, not null * @param context - * binder context to create and construct HTML nodes of other - * types + * binder context to create and construct HTML nodes of other types */ void bind(StateNode stateNode, T domNode, BinderContext context); /** - * Gets the tag value from the {@link NodeFeatures#ELEMENT_DATA} feature for - * the {@code node}. + * Gets the tag value from the {@link NodeFeatures#ELEMENT_DATA} feature for the {@code node}. * * @param node * the state node diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/Debouncer.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/Debouncer.java index d1eecb34490..75d9434541d 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/Debouncer.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/Debouncer.java @@ -30,9 +30,8 @@ import elemental.util.Timer; /** - * Manages debouncing of events. Use {@link #getOrCreate(Node, String, double)} - * to either create a new instance or get an existing instance that currently - * tracks a sequence of similar events. + * Manages debouncing of events. Use {@link #getOrCreate(Node, String, double)} to either create a new instance or get + * an existing instance that currently tracks a sequence of similar events. * * @author Vaadin Ltd * @since 1.0 @@ -64,68 +63,55 @@ private Debouncer(Node element, String identifier, double timeout) { * Informs this debouncer that an event has occurred. * * @param phases - * a set of strings identifying the phases for which the - * triggered event should be considered. + * a set of strings identifying the phases for which the triggered event should be considered. * @param command - * a consumer that will may be asynchronously invoked with a - * phase code if an associated phase is triggered + * a consumer that will may be asynchronously invoked with a phase code if an associated phase is + * triggered * @param commands - * individual commands executed just before the given send - * command + * individual commands executed just before the given send command * - * @return true if the event should be processed as-is without - * delaying + * @return true if the event should be processed as-is without delaying */ - public boolean trigger(JsSet phases, Consumer command, - JsMap commands) { + public boolean trigger(JsSet phases, Consumer command, JsMap commands) { // If "leading" events are requested and no timers created yet, // this is considered the leading event that is triggered immediately // and there is no need to save it - final boolean triggerImmediately = phases - .has(JsonConstants.EVENT_PHASE_LEADING) && idleTimer == null + final boolean triggerImmediately = phases.has(JsonConstants.EVENT_PHASE_LEADING) && idleTimer == null && intermediateTimer == null; - if (!triggerImmediately - && (phases.has(JsonConstants.EVENT_PHASE_TRAILING) || phases - .has(JsonConstants.EVENT_PHASE_INTERMEDIATE))) { + if (!triggerImmediately && (phases.has(JsonConstants.EVENT_PHASE_TRAILING) + || phases.has(JsonConstants.EVENT_PHASE_INTERMEDIATE))) { // last command is saved for timers unless this is a "leading" event bufferedSendCommand = command; bufferedCommands = commands; if (!phases.has(JsonConstants.EVENT_PHASE_INTERMEDIATE) - && (idleTimer == null - || previousBufferedNonExecutedCommands == null)) { + && (idleTimer == null || previousBufferedNonExecutedCommands == null)) { previousBufferedNonExecutedCommands = commands; } potentialTrailingWithBothTrailingAndIntermediate = null; potentialTrailingWithBothTrailingAndIntermediateBufferedCommands = null; } // idleTimer is used for trailing/leading, should always be there? - if (phases.has(JsonConstants.EVENT_PHASE_LEADING) - || phases.has(JsonConstants.EVENT_PHASE_TRAILING)) { + if (phases.has(JsonConstants.EVENT_PHASE_LEADING) || phases.has(JsonConstants.EVENT_PHASE_TRAILING)) { if (idleTimer == null) { idleTimer = new Timer() { @Override public void run() { if (bufferedSendCommand != null) { - runCommands(JsonConstants.EVENT_PHASE_TRAILING, - bufferedSendCommand, bufferedCommands, + runCommands(JsonConstants.EVENT_PHASE_TRAILING, bufferedSendCommand, bufferedCommands, previousBufferedNonExecutedCommands); bufferedSendCommand = null; bufferedCommands = null; previousBufferedNonExecutedCommands = null; } else if (potentialTrailingWithBothTrailingAndIntermediate != null) { /* - * This happens if both trailing & intermediate are - * configured and e.g. typing has stopped. Then we - * wait for one additional timeout and if no new - * commands are there, we re-post the SAME event to - * the server. Documented in DebouncePhase. This is - * ugly but maybe handy for some people in some - * situations. + * This happens if both trailing & intermediate are configured and e.g. typing has stopped. + * Then we wait for one additional timeout and if no new commands are there, we re-post the + * SAME event to the server. Documented in DebouncePhase. This is ugly but maybe handy for + * some people in some situations. */ runCommands(JsonConstants.EVENT_PHASE_TRAILING, potentialTrailingWithBothTrailingAndIntermediate, - potentialTrailingWithBothTrailingAndIntermediateBufferedCommands, - null); + potentialTrailingWithBothTrailingAndIntermediateBufferedCommands, null); } unregister(); // unregister to release memory } @@ -135,14 +121,13 @@ public void run() { idleTimer.schedule((int) timeout); } - if (intermediateTimer == null - && phases.has(JsonConstants.EVENT_PHASE_INTERMEDIATE)) { + if (intermediateTimer == null && phases.has(JsonConstants.EVENT_PHASE_INTERMEDIATE)) { intermediateTimer = new Timer() { @Override public void run() { if (bufferedSendCommand != null) { - runCommands(JsonConstants.EVENT_PHASE_INTERMEDIATE, - bufferedSendCommand, bufferedCommands, null); + runCommands(JsonConstants.EVENT_PHASE_INTERMEDIATE, bufferedSendCommand, bufferedCommands, + null); if (phases.has(JsonConstants.EVENT_PHASE_TRAILING)) { potentialTrailingWithBothTrailingAndIntermediate = bufferedSendCommand; potentialTrailingWithBothTrailingAndIntermediateBufferedCommands = bufferedCommands; @@ -161,13 +146,11 @@ public void run() { return triggerImmediately; } - private static void runCommands(String phase, Consumer sendCommand, - JsMap commands, + private static void runCommands(String phase, Consumer sendCommand, JsMap commands, JsMap previousCommands) { if (JsonConstants.EVENT_PHASE_TRAILING.equals(phase)) { commands.forEach((command, property) -> { - if (command == MapProperty.NO_OP - && hasPreviousCommand(previousCommands, property)) { + if (command == MapProperty.NO_OP && hasPreviousCommand(previousCommands, property)) { previousCommands.get(property).run(); } else { command.run(); @@ -179,10 +162,8 @@ && hasPreviousCommand(previousCommands, property)) { sendCommand.accept(phase); } - private static boolean hasPreviousCommand( - JsMap previousCommands, String property) { - return previousCommands != null && property != null - && previousCommands.has(property); + private static boolean hasPreviousCommand(JsMap previousCommands, String property) { + return previousCommands != null && property != null && previousCommands.has(property); } private void unregister() { @@ -194,8 +175,7 @@ private void unregister() { idleTimer.cancel(); idleTimer = null; } - JsMap> elementMap = debouncers - .get(element); + JsMap> elementMap = debouncers.get(element); if (elementMap == null) { return; } @@ -217,22 +197,19 @@ private void unregister() { } /** - * Gets an existing debouncer or creates a new one associated with the given - * DOM node, identifier and debounce timeout. + * Gets an existing debouncer or creates a new one associated with the given DOM node, identifier and debounce + * timeout. * * @param element * the DOM node to which this debouncer is bound * @param identifier - * a unique identifier string in the scope of the provided - * element + * a unique identifier string in the scope of the provided element * @param debounce * the debounce timeout * @return a debouncer instance */ - public static Debouncer getOrCreate(Node element, String identifier, - double debounce) { - JsMap> elementMap = debouncers - .get(element); + public static Debouncer getOrCreate(Node element, String identifier, double debounce) { + JsMap> elementMap = debouncers.get(element); if (elementMap == null) { elementMap = JsCollections.map(); debouncers.set(element, elementMap); @@ -265,16 +242,14 @@ public static List> flushAll() { ForEachCallback>> flusher = new ForEachCallback>>() { @Override - public void accept(JsMap> jsmap, - Node key) { + public void accept(JsMap> jsmap, Node key) { jsmap.mapValues().forEach(value -> { value.mapValues().forEach(debouncer -> { if (debouncer.idleTimer != null) { if (debouncer.bufferedSendCommand != null) { // if there is trailing timer, consider as extra // trailing event - runCommands(JsonConstants.EVENT_PHASE_TRAILING, - debouncer.bufferedSendCommand, + runCommands(JsonConstants.EVENT_PHASE_TRAILING, debouncer.bufferedSendCommand, debouncer.bufferedCommands, null); } else { // "Debouncer was in queue, but no command. @@ -285,14 +260,12 @@ public void accept(JsMap> jsmap, // Because of an other triggered event, this now // comes bit early, but most likely this is better // than in wrong order - runCommands(JsonConstants.EVENT_PHASE_INTERMEDIATE, - debouncer.bufferedSendCommand, + runCommands(JsonConstants.EVENT_PHASE_INTERMEDIATE, debouncer.bufferedSendCommand, debouncer.bufferedCommands, null); // Restart intermediate timer so that there won't // be triggering more than one event "quicker than // orderd" in the orginal schedule. - debouncer.intermediateTimer - .scheduleRepeating((int) debouncer.timeout); + debouncer.intermediateTimer.scheduleRepeating((int) debouncer.timeout); } if (debouncer.bufferedSendCommand != null) { executedCommands.add(debouncer.bufferedSendCommand); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventHandlerBinder.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventHandlerBinder.java index 0bfdca8e8fb..d5f78d4a99b 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventHandlerBinder.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventHandlerBinder.java @@ -38,10 +38,9 @@ private ServerEventHandlerBinder() { } /** - * Registers all the server event handler names found in the - * {@link NodeFeatures#CLIENT_DELEGATE_HANDLERS} feature in the state node - * as serverObject.<methodName>. Additionally listens to - * changes in the feature and updates $server accordingly. + * Registers all the server event handler names found in the {@link NodeFeatures#CLIENT_DELEGATE_HANDLERS} feature + * in the state node as serverObject.<methodName>. Additionally listens to changes in the feature + * and updates $server accordingly. * * @param element * the element to update @@ -49,16 +48,14 @@ private ServerEventHandlerBinder() { * the state node containing the feature * @return a handle which can be used to remove the listener for the feature */ - public static EventRemover bindServerEventHandlerNames(Element element, - StateNode node) { - return bindServerEventHandlerNames(() -> ServerEventObject.get(element), - node, NodeFeatures.CLIENT_DELEGATE_HANDLERS, true); + public static EventRemover bindServerEventHandlerNames(Element element, StateNode node) { + return bindServerEventHandlerNames(() -> ServerEventObject.get(element), node, + NodeFeatures.CLIENT_DELEGATE_HANDLERS, true); } /** - * Registers all the server event handler names found in the feature with - * the {@code featureId} in the {@link ServerEventObject} {@code object}. - * Additionally listens to changes in the feature and updates server event + * Registers all the server event handler names found in the feature with the {@code featureId} in the + * {@link ServerEventObject} {@code object}. Additionally listens to changes in the feature and updates server event * object accordingly. * * @param objectProvider @@ -68,13 +65,11 @@ public static EventRemover bindServerEventHandlerNames(Element element, * @param featureId * the feature id which contains event handler methods * @param returnValue - * true if the handler should return a promise that - * will reflect the server-side result; false to not - * return any value + * true if the handler should return a promise that will reflect the server-side result; + * false to not return any value * @return a handle which can be used to remove the listener for the feature */ - public static EventRemover bindServerEventHandlerNames( - Supplier objectProvider, StateNode node, + public static EventRemover bindServerEventHandlerNames(Supplier objectProvider, StateNode node, int featureId, boolean returnValue) { NodeList serverEventHandlerNamesList = node.getList(featureId); @@ -82,8 +77,7 @@ public static EventRemover bindServerEventHandlerNames( ServerEventObject object = objectProvider.get(); for (int i = 0; i < serverEventHandlerNamesList.length(); i++) { - String serverEventHandlerName = (String) serverEventHandlerNamesList - .get(i); + String serverEventHandlerName = (String) serverEventHandlerNamesList.get(i); object.defineMethod(serverEventHandlerName, node, returnValue); } } @@ -98,8 +92,7 @@ public static EventRemover bindServerEventHandlerNames( JsArray add = e.getAdd(); for (int i = 0; i < add.length(); i++) { - serverObject.defineMethod((String) add.get(i), node, - returnValue); + serverObject.defineMethod((String) add.get(i), node, returnValue); } }); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventObject.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventObject.java index 621086b81d2..4934ebb6401 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventObject.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/ServerEventObject.java @@ -49,16 +49,14 @@ public final class ServerEventObject extends JavaScriptObject { private static final String PROMISE_CALLBACK_NAME = JsonConstants.RPC_PROMISE_CALLBACK_NAME; /** - * Callback interface for an event data expression parsed using new - * Function() in JavaScript. + * Callback interface for an event data expression parsed using new Function() in JavaScript. */ @FunctionalInterface @JsFunction @SuppressWarnings("unusable-by-js") private interface ServerEventDataExpression { /** - * Callback interface for an event data expression parsed using new - * Function() in JavaScript. + * Callback interface for an event data expression parsed using new Function() in JavaScript. * * @param event * Event to expand @@ -69,8 +67,7 @@ private interface ServerEventDataExpression { JsonObject evaluate(Event event, ServerEventObject serverEventObject); } - private static final JsMap expressionCache = JsCollections - .map(); + private static final JsMap expressionCache = JsCollections.map(); /** * JSO constructor. @@ -104,24 +101,20 @@ private native void initPromiseHandler() }-*/; /** - * Defines a method with the given name to be a callback to the server for - * the given state node. + * Defines a method with the given name to be a callback to the server for the given state node. *

- * Note! If the Polymer.Element contains an implementation for - * {@code methodName} it will be run before the server-side method. + * Note! If the Polymer.Element contains an implementation for {@code methodName} it will be run before the + * server-side method. * * @param methodName * the name of the method to add * @param node - * the node to use as an identifier when sending an event to the - * server + * the node to use as an identifier when sending an event to the server * @param returnPromise - * true if the handler should return a promise that - * will reflect the server-side result; false to not - * return any value + * true if the handler should return a promise that will reflect the server-side result; + * false to not return any value */ - public native void defineMethod(String methodName, StateNode node, - boolean returnPromise) + public native void defineMethod(String methodName, StateNode node, boolean returnPromise) /*-{ this[methodName] = $entry(function(eventParameter) { var prototype = Object.getPrototypeOf(this); @@ -156,9 +149,8 @@ public native void defineMethod(String methodName, StateNode node, }-*/; /** - * Collect extra data for element event if any has been sent from the - * server. Note! Data is sent in the array in the same order as defined on - * the server side. + * Collect extra data for element event if any has been sent from the server. Note! Data is sent in the array in the + * same order as defined on the server side. * * @param event * The fired Event @@ -168,20 +160,15 @@ public native void defineMethod(String methodName, StateNode node, * Target node * @return Array of extra event data */ - private JsonArray getEventData(Event event, String methodName, - StateNode node) { + private JsonArray getEventData(Event event, String methodName, StateNode node) { - if (node.getMap(NodeFeatures.POLYMER_EVENT_LISTENERS) - .hasPropertyValue(methodName)) { + if (node.getMap(NodeFeatures.POLYMER_EVENT_LISTENERS).hasPropertyValue(methodName)) { JsonArray dataArray = Json.createArray(); - ConstantPool constantPool = node.getTree().getRegistry() - .getConstantPool(); - String expressionConstantKey = (String) node - .getMap(NodeFeatures.POLYMER_EVENT_LISTENERS) + ConstantPool constantPool = node.getTree().getRegistry().getConstantPool(); + String expressionConstantKey = (String) node.getMap(NodeFeatures.POLYMER_EVENT_LISTENERS) .getProperty(methodName).getValue(); - JsArray dataExpressions = constantPool - .get(expressionConstantKey); + JsArray dataExpressions = constantPool.get(expressionConstantKey); for (int i = 0; i < dataExpressions.length(); i++) { String expression = dataExpressions.get(i); @@ -194,28 +181,24 @@ private JsonArray getEventData(Event event, String methodName, return null; } - private JsonObject getExpressionValue(Event event, StateNode node, - String expression) { + private JsonObject getExpressionValue(Event event, StateNode node, String expression) { JsonObject expressionValue; if (serverExpectsNodeId(expression)) { return getPolymerPropertyObject(event, node, expression); } - ServerEventDataExpression dataExpression = getOrCreateExpression( - expression); + ServerEventDataExpression dataExpression = getOrCreateExpression(expression); expressionValue = dataExpression.evaluate(event, this); return expressionValue; } private boolean serverExpectsNodeId(String expression) { - return !expression.startsWith(EVENT_PREFIX) - || "event.model.item".equals(expression); + return !expression.startsWith(EVENT_PREFIX) || "event.model.item".equals(expression); } - private JsonObject getPolymerPropertyObject(Event event, StateNode node, - String expression) { + private JsonObject getPolymerPropertyObject(Event event, StateNode node, String expression) { if (expression.startsWith(EVENT_PREFIX)) { return createPolymerPropertyObject(event, expression); } else { @@ -223,18 +206,15 @@ private JsonObject getPolymerPropertyObject(Event event, StateNode node, } } - private JsonObject createPolymerPropertyObject(Event event, - String expression) { - ServerEventDataExpression dataExpression = getOrCreateExpression( - expression); + private JsonObject createPolymerPropertyObject(Event event, String expression) { + ServerEventDataExpression dataExpression = getOrCreateExpression(expression); JsonObject expressionValue = dataExpression.evaluate(event, this); JsonObject object = Json.createObject(); object.put(NODE_ID, expressionValue.getNumber(NODE_ID)); return object; } - private native JsonObject getPolymerPropertyObject(Node node, - String propertyName) + private native JsonObject getPolymerPropertyObject(Node node, String propertyName) /*-{ if (typeof(node.get) === 'function') { var polymerProperty = node.get(propertyName); @@ -285,27 +265,21 @@ public static ServerEventObject get(Element element) { } /** - * Gets or creates element.$server for the given element, if - * present. + * Gets or creates element.$server for the given element, if present. * * @param node * the element to use - * @return a reference to the $server object in the element, or - * null if note present. + * @return a reference to the $server object in the element, or null if note present. */ public static ServerEventObject getIfPresent(Node node) { - return WidgetUtil - .crazyJsoCast(WidgetUtil.getJsProperty(node, "$server")); + return WidgetUtil.crazyJsoCast(WidgetUtil.getJsProperty(node, "$server")); } - protected static ServerEventDataExpression getOrCreateExpression( - String expressionString) { - ServerEventDataExpression expression = expressionCache - .get(expressionString); + protected static ServerEventDataExpression getOrCreateExpression(String expressionString) { + ServerEventDataExpression expression = expressionCache.get(expressionString); if (expression == null) { - expression = NativeFunction.create(EVENT_PREFIX, "element", - "return (" + expressionString + ")"); + expression = NativeFunction.create(EVENT_PREFIX, "element", "return (" + expressionString + ")"); expressionCache.set(expressionString, expression); } @@ -313,9 +287,8 @@ protected static ServerEventDataExpression getOrCreateExpression( } /** - * Reject all promises pending on this server object. Called during client - * resynchronization to free consumers of promises that are never delivered - * by the server. + * Reject all promises pending on this server object. Called during client resynchronization to free consumers of + * promises that are never delivered by the server. */ public native void rejectPromises() /*-{ diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java index 31c5a8e925c..d75591881c5 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java @@ -91,16 +91,14 @@ private interface PropertyUser { } /** - * Callback interface for an event expression parsed using new Function() in - * JavaScript. + * Callback interface for an event expression parsed using new Function() in JavaScript. */ @FunctionalInterface @JsFunction @SuppressWarnings("unusable-by-js") private interface EventExpression { /** - * Callback interface for an event expression parsed using new - * Function() in JavaScript. + * Callback interface for an event expression parsed using new Function() in JavaScript. * * @param event * Event to expand @@ -114,18 +112,16 @@ private interface EventExpression { private static JsMap expressionCache; /** - * This is used as a weak set. Only keys are important so that they are - * weakly referenced + * This is used as a weak set. Only keys are important so that they are weakly referenced */ private static JsWeakMap boundNodes; /** - * Just a context class whose instance is passed as a parameter between the - * operations of various kind to be able to access the data like listeners, - * node and element which they operate on. + * Just a context class whose instance is passed as a parameter between the operations of various kind to be able to + * access the data like listeners, node and element which they operate on. *

- * It's used to avoid having methods with a long numbers of parameters and - * because the strategy instance is stateless. + * It's used to avoid having methods with a long numbers of parameters and because the strategy instance is + * stateless. */ private static class BindingContext { @@ -133,13 +129,10 @@ private static class BindingContext { private final StateNode node; private final BinderContext binderContext; - private final JsMap listenerBindings = JsCollections - .map(); - private final JsMap listenerRemovers = JsCollections - .map(); + private final JsMap listenerBindings = JsCollections.map(); + private final JsMap listenerRemovers = JsCollections.map(); - private BindingContext(StateNode node, Node htmlNode, - BinderContext binderContext) { + private BindingContext(StateNode node, Node htmlNode, BinderContext binderContext) { this.node = node; this.htmlNode = htmlNode; this.binderContext = binderContext; @@ -180,18 +173,15 @@ public boolean isApplicable(StateNode node) { if (node.hasFeature(NodeFeatures.ELEMENT_DATA)) { return true; } - return node.getTree() != null - && node.equals(node.getTree().getRootNode()); + return node.getTree() != null && node.equals(node.getTree().getRootNode()); } @Override - public void bind(StateNode stateNode, Element htmlNode, - BinderContext nodeFactory) { + public void bind(StateNode stateNode, Element htmlNode, BinderContext nodeFactory) { boolean isVisible = isVisible(stateNode); - assert hasSameTag(stateNode, htmlNode) : "Element tag name is '" - + htmlNode.getTagName() + "', but the required tag name is " - + getTag(stateNode); + assert hasSameTag(stateNode, htmlNode) : "Element tag name is '" + htmlNode.getTagName() + + "', but the required tag name is " + getTag(stateNode); if (boundNodes == null) { boundNodes = JsCollections.weakMap(); @@ -202,11 +192,9 @@ assert hasSameTag(stateNode, htmlNode) : "Element tag name is '" } boundNodes.set(stateNode, true); - BindingContext context = new BindingContext(stateNode, htmlNode, - nodeFactory); + BindingContext context = new BindingContext(stateNode, htmlNode, nodeFactory); - JsArray> computationsCollection = JsCollections - .array(); + JsArray> computationsCollection = JsCollections.array(); JsArray listeners = JsCollections.array(); @@ -226,25 +214,21 @@ assert hasSameTag(stateNode, htmlNode) : "Element tag name is '" // Styling might be looked at by observers, but will typically not // trigger any observers synchronously listeners.push(bindClassList(htmlNode, stateNode)); - listeners.push(bindMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES, - property -> updateStyleProperty(property, htmlNode), - createComputations(computationsCollection), stateNode)); + listeners.push( + bindMap(NodeFeatures.ELEMENT_STYLE_PROPERTIES, property -> updateStyleProperty(property, htmlNode), + createComputations(computationsCollection), stateNode)); // The things that might actually be observed - listeners.push(bindMap(NodeFeatures.ELEMENT_ATTRIBUTES, - property -> updateAttribute(property, htmlNode), + listeners.push(bindMap(NodeFeatures.ELEMENT_ATTRIBUTES, property -> updateAttribute(property, htmlNode), createComputations(computationsCollection), stateNode)); - listeners.push(bindMap(NodeFeatures.ELEMENT_PROPERTIES, - property -> updateProperty(property, htmlNode), + listeners.push(bindMap(NodeFeatures.ELEMENT_PROPERTIES, property -> updateProperty(property, htmlNode), createComputations(computationsCollection), stateNode)); bindPolymerModelProperties(stateNode, htmlNode); // Prepare teardown - listeners.push(stateNode.addUnregisterListener( - e -> remove(listeners, context, computationsCollection))); + listeners.push(stateNode.addUnregisterListener(e -> remove(listeners, context, computationsCollection))); } - listeners.push(bindVisibility(listeners, context, - computationsCollection, nodeFactory)); + listeners.push(bindVisibility(listeners, context, computationsCollection, nodeFactory)); scheduleInitialExecution(stateNode); } @@ -253,23 +237,19 @@ private void scheduleInitialExecution(StateNode stateNode) { InitialPropertyUpdate update = new InitialPropertyUpdate(stateNode); stateNode.setNodeData(update); /* - * Update command will be executed after all initial Reactive stuff. - * E.g. initial JS (if any) will be executed BEFORE initial update - * command execution + * Update command will be executed after all initial Reactive stuff. E.g. initial JS (if any) will be executed + * BEFORE initial update command execution */ - Reactive.addPostFlushListener( - () -> Scheduler.get().scheduleDeferred(() -> { - InitialPropertyUpdate propertyUpdate = stateNode - .getNodeData(InitialPropertyUpdate.class); - // cleared if handlePropertiesChanged has already happened - if (propertyUpdate != null) { - propertyUpdate.execute(); - } - })); + Reactive.addPostFlushListener(() -> Scheduler.get().scheduleDeferred(() -> { + InitialPropertyUpdate propertyUpdate = stateNode.getNodeData(InitialPropertyUpdate.class); + // cleared if handlePropertiesChanged has already happened + if (propertyUpdate != null) { + propertyUpdate.execute(); + } + })); } - private native void bindPolymerModelProperties(StateNode node, - Element element) + private native void bindPolymerModelProperties(StateNode node, Element element) /*-{ if ( @com.vaadin.client.PolymerUtils::isPolymerElement(*)(element) ) { this.@SimpleElementBindingStrategy::hookUpPolymerElement(*)(node, element); @@ -408,8 +388,8 @@ private native void hookUpPolymerElement(StateNode node, Element element) }-*/; - private static void handleListItemPropertyChange(double nodeId, - Element host, String property, Object value, StateTree tree) { + private static void handleListItemPropertyChange(double nodeId, Element host, String property, Object value, + StateTree tree) { // Warning : it's important that tree is passed as an // argument instead of StateNode or Element ! We have replaced a method // in the prototype which means that it may not use the context from the @@ -421,13 +401,12 @@ private static void handleListItemPropertyChange(double nodeId, return; } - assert checkParent(node, host) - : "Host element is not a parent of the node whose property has changed. " - + "This is an implementation error. " - + "Most likely it means that there are several StateTrees on the same page " - + "(might be possible with portlets) and the target StateTree should not be passed " - + "into the method as an argument but somehow detected from the host element. " - + "Another option is that host element is calculated incorrectly."; + assert checkParent(node, host) : "Host element is not a parent of the node whose property has changed. " + + "This is an implementation error. " + + "Most likely it means that there are several StateTrees on the same page " + + "(might be possible with portlets) and the target StateTree should not be passed " + + "into the method as an argument but somehow detected from the host element. " + + "Another option is that host element is calculated incorrectly."; // TODO: this code doesn't care about "security feature" which prevents // sending @@ -466,21 +445,17 @@ private static boolean checkParent(StateNode node, Element supposedParent) { } } - private void handlePropertiesChanged( - JavaScriptObject changedPropertyPathsToValues, StateNode node) { + private void handlePropertiesChanged(JavaScriptObject changedPropertyPathsToValues, StateNode node) { String[] keys = WidgetUtil.getKeys(changedPropertyPathsToValues); Runnable runnable = () -> { for (String propertyName : keys) { handlePropertyChange(propertyName, - () -> WidgetUtil.getJsProperty( - changedPropertyPathsToValues, propertyName), - node); + () -> WidgetUtil.getJsProperty(changedPropertyPathsToValues, propertyName), node); } }; - InitialPropertyUpdate initialUpdate = node - .getNodeData(InitialPropertyUpdate.class); + InitialPropertyUpdate initialUpdate = node.getNodeData(InitialPropertyUpdate.class); if (initialUpdate == null) { runnable.run(); } else { @@ -488,12 +463,9 @@ private void handlePropertiesChanged( } } - private void handlePropertyChange(String fullPropertyName, - Supplier valueProvider, StateNode node) { - UpdatableModelProperties updatableProperties = node - .getNodeData(UpdatableModelProperties.class); - if (updatableProperties == null - || !updatableProperties.isUpdatableProperty(fullPropertyName)) { + private void handlePropertyChange(String fullPropertyName, Supplier valueProvider, StateNode node) { + UpdatableModelProperties updatableProperties = node.getNodeData(UpdatableModelProperties.class); + if (updatableProperties == null || !updatableProperties.isUpdatableProperty(fullPropertyName)) { // don't do anything if the property/sub-property is not in the // collection of updatable properties return; @@ -507,12 +479,9 @@ private void handlePropertyChange(String fullPropertyName, int i = 0; int size = subProperties.length; for (String subProperty : subProperties) { - NodeMap elementProperties = model - .getMap(NodeFeatures.ELEMENT_PROPERTIES); - if (!elementProperties.hasPropertyValue(subProperty) - && i < size - 1) { - Console.debug("Ignoring property change for property '" - + fullPropertyName + NodeMap elementProperties = model.getMap(NodeFeatures.ELEMENT_PROPERTIES); + if (!elementProperties.hasPropertyValue(subProperty) && i < size - 1) { + Console.debug("Ignoring property change for property '" + fullPropertyName + "' which isn't defined from server"); return; } @@ -527,8 +496,7 @@ private void handlePropertyChange(String fullPropertyName, // Don't send to the server updates for list nodes StateNode nodeValue = (StateNode) mapProperty.getValue(); JsonObject obj = WidgetUtil.crazyJsCast(valueProvider.get()); - if (!obj.hasKey("nodeId") - || nodeValue.hasFeature(NodeFeatures.TEMPLATE_MODELLIST)) { + if (!obj.hasKey("nodeId") || nodeValue.hasFeature(NodeFeatures.TEMPLATE_MODELLIST)) { return; } } @@ -536,20 +504,17 @@ private void handlePropertyChange(String fullPropertyName, } private EventRemover bindShadowRoot(BindingContext context) { - assert context.htmlNode instanceof Element - : "Cannot bind shadow root to a Node"; + assert context.htmlNode instanceof Element : "Cannot bind shadow root to a Node"; NodeMap map = context.node.getMap(NodeFeatures.SHADOW_ROOT_DATA); attachShadow(context); - return map.addPropertyAddListener(event -> Reactive - .addFlushListener(() -> attachShadow(context))); + return map.addPropertyAddListener(event -> Reactive.addFlushListener(() -> attachShadow(context))); } private void attachShadow(BindingContext context) { NodeMap map = context.node.getMap(NodeFeatures.SHADOW_ROOT_DATA); - StateNode shadowRootNode = (StateNode) map - .getProperty(NodeProperties.SHADOW_ROOT).getValue(); + StateNode shadowRootNode = (StateNode) map.getProperty(NodeProperties.SHADOW_ROOT).getValue(); if (shadowRootNode != null) { NativeFunction function = NativeFunction.create("element", "if ( element.shadowRoot ) { return element.shadowRoot; } " @@ -560,15 +525,13 @@ private void attachShadow(BindingContext context) { shadowRootNode.setDomNode(shadowRoot); } - BindingContext newContext = new BindingContext(shadowRootNode, - shadowRoot, context.binderContext); + BindingContext newContext = new BindingContext(shadowRootNode, shadowRoot, context.binderContext); bindChildren(newContext); } } @SuppressWarnings("unchecked") - private JsMap createComputations( - JsArray> computationsCollection) { + private JsMap createComputations(JsArray> computationsCollection) { JsMap computations = JsCollections.map(); computationsCollection.push(computations); return computations; @@ -579,46 +542,34 @@ private boolean hasSameTag(StateNode node, Element element) { return nsTag == null || element.getTagName().equalsIgnoreCase(nsTag); } - private EventRemover bindMap(int featureId, PropertyUser user, - JsMap bindings, StateNode node) { + private EventRemover bindMap(int featureId, PropertyUser user, JsMap bindings, + StateNode node) { NodeMap map = node.getMap(featureId); - map.forEachProperty((property, - name) -> bindProperty(user, property, bindings).recompute()); + map.forEachProperty((property, name) -> bindProperty(user, property, bindings).recompute()); - return map.addPropertyAddListener( - e -> bindProperty(user, e.getProperty(), bindings)); + return map.addPropertyAddListener(e -> bindProperty(user, e.getProperty(), bindings)); } - private EventRemover bindVisibility(JsArray listeners, - BindingContext context, - JsArray> computationsCollection, - BinderContext nodeFactory) { + private EventRemover bindVisibility(JsArray listeners, BindingContext context, + JsArray> computationsCollection, BinderContext nodeFactory) { assert context.htmlNode instanceof Element - : "The HTML node for the StateNode with id=" - + context.node.getId() + " is not an Element"; + : "The HTML node for the StateNode with id=" + context.node.getId() + " is not an Element"; NodeMap visibilityData = context.node.getMap(NodeFeatures.ELEMENT_DATA); - visibilityData.getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) - .setValue(isVisible(context.node)); - updateVisibility(listeners, context, computationsCollection, - nodeFactory); - return context.node.getMap(NodeFeatures.ELEMENT_DATA) - .getProperty(NodeProperties.VISIBLE) - .addChangeListener(event -> updateVisibility(listeners, context, - computationsCollection, nodeFactory)); + visibilityData.getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY).setValue(isVisible(context.node)); + updateVisibility(listeners, context, computationsCollection, nodeFactory); + return context.node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.VISIBLE) + .addChangeListener(event -> updateVisibility(listeners, context, computationsCollection, nodeFactory)); } private boolean isVisible(StateNode node) { return node.getTree().isVisible(node); } - private void updateVisibility(JsArray listeners, - BindingContext context, - JsArray> computationsCollection, - BinderContext nodeFactory) { + private void updateVisibility(JsArray listeners, BindingContext context, + JsArray> computationsCollection, BinderContext nodeFactory) { assert context.htmlNode instanceof Element - : "The HTML node for the StateNode with id=" - + context.node.getId() + " is not an Element"; + : "The HTML node for the StateNode with id=" + context.node.getId() + " is not an Element"; NodeMap visibilityData = context.node.getMap(NodeFeatures.ELEMENT_DATA); Element element = (Element) context.htmlNode; @@ -631,8 +582,7 @@ private void updateVisibility(JsArray listeners, doBind(context.node, nodeFactory); }); } else if (isVisible(context.node)) { - visibilityData.getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) - .setValue(true); + visibilityData.getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY).setValue(true); restoreInitialHiddenAttribute(element, visibilityData); } else { setElementInvisible(element, visibilityData); @@ -641,47 +591,36 @@ private void updateVisibility(JsArray listeners, private void setElementInvisible(Element element, NodeMap visibilityData) { storeInitialHiddenAttribute(element, visibilityData); - updateAttributeValue( - visibilityData.getNode().getTree().getRegistry() - .getApplicationConfiguration(), - element, HIDDEN_ATTRIBUTE, Boolean.TRUE); + updateAttributeValue(visibilityData.getNode().getTree().getRegistry().getApplicationConfiguration(), element, + HIDDEN_ATTRIBUTE, Boolean.TRUE); if (PolymerUtils.isInShadowRoot(element)) { element.getStyle().setDisplay("none"); } } - private void restoreInitialHiddenAttribute(Element element, - NodeMap visibilityData) { + private void restoreInitialHiddenAttribute(Element element, NodeMap visibilityData) { storeInitialHiddenAttribute(element, visibilityData); - MapProperty initialVisibility = visibilityData - .getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY); + MapProperty initialVisibility = visibilityData.getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY); if (initialVisibility.hasValue()) { - updateAttributeValue( - visibilityData.getNode().getTree().getRegistry() - .getApplicationConfiguration(), + updateAttributeValue(visibilityData.getNode().getTree().getRegistry().getApplicationConfiguration(), element, HIDDEN_ATTRIBUTE, initialVisibility.getValue()); } - MapProperty initialDisplay = visibilityData - .getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY); + MapProperty initialDisplay = visibilityData.getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY); if (initialDisplay.hasValue()) { final String initialValue = initialDisplay.getValue().toString(); element.getStyle().setDisplay(initialValue); } } - private void storeInitialHiddenAttribute(Element element, - NodeMap visibilityData) { - MapProperty initialVisibility = visibilityData - .getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY); + private void storeInitialHiddenAttribute(Element element, NodeMap visibilityData) { + MapProperty initialVisibility = visibilityData.getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY); if (!initialVisibility.hasValue()) { initialVisibility.setValue(element.getAttribute(HIDDEN_ATTRIBUTE)); } - MapProperty initialDisplay = visibilityData - .getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY); - if (PolymerUtils.isInShadowRoot(element) && !initialDisplay.hasValue() - && element.getStyle() != null) { + MapProperty initialDisplay = visibilityData.getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY); + if (PolymerUtils.isInShadowRoot(element) && !initialDisplay.hasValue() && element.getStyle() != null) { initialDisplay.setValue(element.getStyle().getDisplay()); } } @@ -698,34 +637,28 @@ private void doBind(StateNode node, BinderContext nodeFactory) { /** * Checks whether the {@code node} needs re-bind. *

- * The node needs re-bind if it was initially invisible. As a consequence - * such node has not be bound. It has been bound in respect to visibility - * feature only (partially bound). Such node needs re-bind once it becomes - * visible. + * The node needs re-bind if it was initially invisible. As a consequence such node has not be bound. It has been + * bound in respect to visibility feature only (partially bound). Such node needs re-bind once it becomes visible. * * @param node * the node to check - * @return {@code true} if the node is not entirely bound and needs re-bind - * later on + * @return {@code true} if the node is not entirely bound and needs re-bind later on */ public static boolean needsRebind(StateNode node) { /* - * Absence of value or "true" means that the node doesn't need re-bind. - * So only "false" means "needs re-bind". + * Absence of value or "true" means that the node doesn't need re-bind. So only "false" means "needs re-bind". */ return Boolean.FALSE.equals(node.getMap(NodeFeatures.ELEMENT_DATA) - .getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) - .getValue()); + .getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY).getValue()); } - private static Computation bindProperty(PropertyUser user, - MapProperty property, JsMap bindings) { + private static Computation bindProperty(PropertyUser user, MapProperty property, + JsMap bindings) { String name = property.getName(); assert !bindings.has(name) : "There's already a binding for " + name; - Computation computation = Reactive - .runWhenDependenciesChange(() -> user.use(property)); + Computation computation = Reactive.runWhenDependenciesChange(() -> user.use(property)); bindings.set(name, computation); @@ -740,11 +673,9 @@ private void updateProperty(MapProperty mapProperty, Element element) { // We compare with the current property to avoid setting properties // which are updated on the client side, e.g. when synchronizing // properties to the server (won't work for readonly properties). - if (WidgetUtil.isUndefined(domValue) - || !WidgetUtil.equals(domValue, treeValue)) { + if (WidgetUtil.isUndefined(domValue) || !WidgetUtil.equals(domValue, treeValue)) { Reactive.runWithComputation(null, - () -> WidgetUtil.setJsProperty(element, name, - PolymerUtils.createModelTree(treeValue))); + () -> WidgetUtil.setJsProperty(element, name, PolymerUtils.createModelTree(treeValue))); } } else if (WidgetUtil.hasOwnJsProperty(element, name)) { WidgetUtil.deleteJsProperty(element, name); @@ -762,15 +693,12 @@ private void updateStyleProperty(MapProperty mapProperty, Element element) { String value = (String) mapProperty.getValue(); boolean styleIsSet = false; if (value.contains("!important")) { - Element temp = Browser.getDocument() - .createElement(element.getTagName()); + Element temp = Browser.getDocument().createElement(element.getTagName()); CSSStyleDeclaration tmpStyle = temp.getStyle(); tmpStyle.setCssText(name + ": " + value + ";"); String priority = "important"; - if (priority - .equals(temp.getStyle().getPropertyPriority(name))) { - styleElement.setProperty(name, - temp.getStyle().getPropertyValue(name), priority); + if (priority.equals(temp.getStyle().getPropertyPriority(name))) { + styleElement.setProperty(name, temp.getStyle().getPropertyValue(name), priority); styleIsSet = true; } } @@ -784,9 +712,7 @@ private void updateStyleProperty(MapProperty mapProperty, Element element) { private void updateAttribute(MapProperty mapProperty, Element element) { String name = mapProperty.getName(); - updateAttributeValue( - mapProperty.getMap().getNode().getTree().getRegistry() - .getApplicationConfiguration(), + updateAttributeValue(mapProperty.getMap().getNode().getTree().getRegistry().getApplicationConfiguration(), element, name, mapProperty.getValue()); } @@ -799,8 +725,7 @@ private EventRemover bindChildren(BindingContext context) { for (int i = 0; i < children.length(); i++) { StateNode childNode = (StateNode) children.get(i); - ExistingElementMap existingElementMap = childNode.getTree() - .getRegistry().getExistingElementMap(); + ExistingElementMap existingElementMap = childNode.getTree().getRegistry().getExistingElementMap(); Node child = existingElementMap.getElement(childNode.getId()); if (child != null) { existingElementMap.remove(childNode.getId()); @@ -814,9 +739,8 @@ private EventRemover bindChildren(BindingContext context) { return children.addSpliceListener(e -> { /* - * Handle lazily so we can create the children we need to insert. - * The change that gives a child node an element tag name might not - * yet have been applied at this point. + * Handle lazily so we can create the children we need to insert. The change that gives a child node an + * element tag name might not yet have been applied at this point. */ Reactive.addFlushListener(() -> handleChildrenSplice(e, context)); }); @@ -831,24 +755,21 @@ private EventRemover bindVirtualChildren(BindingContext context) { return children.addSpliceListener(e -> { /* - * Handle lazily so we can create the children we need to insert. - * The change that gives a child node an element tag name might not - * yet have been applied at this point. + * Handle lazily so we can create the children we need to insert. The change that gives a child node an + * element tag name might not yet have been applied at this point. */ Reactive.addFlushListener(() -> { JsArray add = e.getAdd(); if (!add.isEmpty()) { for (int i = 0; i < add.length(); i++) { - appendVirtualChild(context, (StateNode) add.get(i), - true); + appendVirtualChild(context, (StateNode) add.get(i), true); } } }); }); } - private void appendVirtualChild(BindingContext context, StateNode node, - boolean reactivePhase) { + private void appendVirtualChild(BindingContext context, StateNode node, boolean reactivePhase) { JsonObject object = getPayload(node); String type = object.getString(NodeProperties.TYPE); @@ -861,8 +782,7 @@ private void appendVirtualChild(BindingContext context, StateNode node, : "Unexpected html node. The node is supposed to be a custom element"; if (NodeProperties.INJECT_BY_ID.equals(type)) { if (LitUtils.isLitElement(context.htmlNode)) { - LitUtils.whenRendered((Element) context.htmlNode, - () -> handleInjectId(context, node, object, false)); + LitUtils.whenRendered((Element) context.htmlNode, () -> handleInjectId(context, node, object, false)); return; } else if (!PolymerUtils.isReady(context.htmlNode)) { PolymerUtils.addReadyListener((Element) context.htmlNode, @@ -874,8 +794,7 @@ private void appendVirtualChild(BindingContext context, StateNode node, } else if (NodeProperties.TEMPLATE_IN_TEMPLATE.equals(type)) { if (PolymerUtils.getDomRoot(context.htmlNode) == null) { PolymerUtils.addReadyListener((Element) context.htmlNode, - () -> handleTemplateInTemplate(context, node, object, - false)); + () -> handleTemplateInTemplate(context, node, object, false)); return; } handleTemplateInTemplate(context, node, object, reactivePhase); @@ -883,35 +802,30 @@ private void appendVirtualChild(BindingContext context, StateNode node, String name = object.getString(NodeProperties.PAYLOAD); String address = "name='" + name + "'"; - Supplier elementLookup = () -> ElementUtil - .getElementByName(context.htmlNode, name); + Supplier elementLookup = () -> ElementUtil.getElementByName(context.htmlNode, name); if (!ReactUtils.isInitialized(elementLookup)) { - ReactUtils.addReadyCallback((Element) context.htmlNode, name, - () -> { - doAppendVirtualChild(context, node, false, - elementLookup, name, address); - }); + ReactUtils.addReadyCallback((Element) context.htmlNode, name, () -> { + doAppendVirtualChild(context, node, false, elementLookup, name, address); + }); return; } - doAppendVirtualChild(context, node, reactivePhase, elementLookup, - name, address); + doAppendVirtualChild(context, node, reactivePhase, elementLookup, name, address); } else { assert false : "Unexpected payload type " + type; } } - private void doAppendVirtualChild(BindingContext context, StateNode node, - boolean reactivePhase, Supplier elementLookup, String id, - String address) { + private void doAppendVirtualChild(BindingContext context, StateNode node, boolean reactivePhase, + Supplier elementLookup, String id, String address) { if (!verifyAttachRequest(context.node, node, id, address)) { return; } Element element = elementLookup.get(); if (verifyAttachedElement(element, node, id, address, context)) { if (!reactivePhase) { - InitialPropertiesHandler initialPropertiesHandler = node - .getTree().getRegistry().getInitialPropertiesHandler(); + InitialPropertiesHandler initialPropertiesHandler = node.getTree().getRegistry() + .getInitialPropertiesHandler(); initialPropertiesHandler.nodeRegistered(node); initialPropertiesHandler.flushPropertyUpdates(); @@ -929,50 +843,44 @@ private void doAppendVirtualChild(BindingContext context, StateNode node, } - private void handleTemplateInTemplate(BindingContext context, - StateNode node, JsonObject object, boolean reactivePhase) { + private void handleTemplateInTemplate(BindingContext context, StateNode node, JsonObject object, + boolean reactivePhase) { JsonArray path = object.getArray(NodeProperties.PAYLOAD); String address = "path='" + path.toString() + "'"; - Supplier elementLookup = () -> PolymerUtils.getCustomElement( - PolymerUtils.getDomRoot(context.htmlNode), path); + Supplier elementLookup = () -> PolymerUtils.getCustomElement(PolymerUtils.getDomRoot(context.htmlNode), + path); - doAppendVirtualChild(context, node, reactivePhase, elementLookup, null, - address); + doAppendVirtualChild(context, node, reactivePhase, elementLookup, null, address); } - private void handleInjectId(BindingContext context, StateNode node, - JsonObject object, boolean reactivePhase) { + private void handleInjectId(BindingContext context, StateNode node, JsonObject object, boolean reactivePhase) { String id = object.getString(NodeProperties.PAYLOAD); String address = "id='" + id + "'"; - Supplier elementLookup = () -> ElementUtil - .getElementById(context.htmlNode, id); + Supplier elementLookup = () -> ElementUtil.getElementById(context.htmlNode, id); - doAppendVirtualChild(context, node, reactivePhase, elementLookup, id, - address); + doAppendVirtualChild(context, node, reactivePhase, elementLookup, id, address); } - private boolean verifyAttachedElement(Element element, StateNode attachNode, - String id, String address, BindingContext context) { + private boolean verifyAttachedElement(Element element, StateNode attachNode, String id, String address, + BindingContext context) { StateNode node = context.node; String tag = getTag(attachNode); boolean failure = false; if (element == null) { failure = true; - Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address - + " is not found. The requested tag name is '" + tag + "'"); + Console.warn( + ELEMENT_ATTACH_ERROR_PREFIX + address + " is not found. The requested tag name is '" + tag + "'"); } else if (!ElementUtil.hasTag(element, tag)) { failure = true; - Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address - + " has the wrong tag name '" + element.getTagName() + Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address + " has the wrong tag name '" + element.getTagName() + "', the requested tag name is '" + tag + "'"); } if (failure) { - node.getTree().sendExistingElementWithIdAttachToServer(node, - attachNode.getId(), -1, id); + node.getTree().sendExistingElementWithIdAttachToServer(node, attachNode.getId(), -1, id); return false; } @@ -980,8 +888,7 @@ private boolean verifyAttachedElement(Element element, StateNode attachNode, return true; } NodeMap map = node.getMap(NodeFeatures.SHADOW_ROOT_DATA); - StateNode shadowRootNode = (StateNode) map - .getProperty(NodeProperties.SHADOW_ROOT).getValue(); + StateNode shadowRootNode = (StateNode) map.getProperty(NodeProperties.SHADOW_ROOT).getValue(); if (shadowRootNode == null) { return true; } @@ -1001,38 +908,31 @@ private boolean verifyAttachedElement(Element element, StateNode attachNode, if (existingId != null) { Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address - + " has been already attached previously via the node id='" - + existingId + "'"); - node.getTree().sendExistingElementWithIdAttachToServer(node, - attachNode.getId(), existingId, id); + + " has been already attached previously via the node id='" + existingId + "'"); + node.getTree().sendExistingElementWithIdAttachToServer(node, attachNode.getId(), existingId, id); return false; } return true; } - private boolean verifyAttachRequest(StateNode parent, StateNode node, - String id, String address) { + private boolean verifyAttachRequest(StateNode parent, StateNode node, String id, String address) { /* - * This should not happen at all because server side may not send - * several attach requests for the same client-side element. But that's - * the situation when the code is written. So this is a kind of - * assertion for the future code which verifies the correctness of - * assumptions made on the client side about server-side code impl. + * This should not happen at all because server side may not send several attach requests for the same + * client-side element. But that's the situation when the code is written. So this is a kind of assertion for + * the future code which verifies the correctness of assumptions made on the client side about server-side code + * impl. */ - NodeList virtualChildren = parent - .getList(NodeFeatures.VIRTUAL_CHILDREN); + NodeList virtualChildren = parent.getList(NodeFeatures.VIRTUAL_CHILDREN); for (int i = 0; i < virtualChildren.length(); i++) { StateNode child = (StateNode) virtualChildren.get(i); if (child == node) { continue; } if (getPayload(node).toJson().equals(getPayload(child).toJson())) { - Console.warn("There is already a request to attach " - + "element addressed by the " + address + Console.warn("There is already a request to attach " + "element addressed by the " + address + ". The existing request's node id='" + child.getId() + "'. Cannot attach the same element twice."); - node.getTree().sendExistingElementWithIdAttachToServer(parent, - node.getId(), child.getId(), id); + node.getTree().sendExistingElementWithIdAttachToServer(parent, node.getId(), child.getId(), id); return false; } } @@ -1044,20 +944,18 @@ private JsonObject getPayload(StateNode node) { return (JsonObject) map.getProperty(NodeProperties.PAYLOAD).getValue(); } - private Computation invokeWhenNodeIsConstructed(Command command, - StateNode node) { + private Computation invokeWhenNodeIsConstructed(Command command, StateNode node) { Computation computation = Reactive.runWhenDependenciesChange(command); node.addUnregisterListener(event -> computation.stop()); return computation; } - private void handleChildrenSplice(ListSpliceEvent event, - BindingContext context) { + private void handleChildrenSplice(ListSpliceEvent event, BindingContext context) { Node htmlNode = context.htmlNode; if (event.isClear()) { /* - * When a full clear event is fired, all nodes must be removed, - * including the nodes the server doesn't know about. + * When a full clear event is fired, all nodes must be removed, including the nodes the server doesn't know + * about. */ removeAllChildren(htmlNode); } else { @@ -1072,11 +970,9 @@ private void handleChildrenSplice(ListSpliceEvent event, DomApi.wrap(htmlNode).removeChild(child); } /* - * If the client-side element is not inside the parent the - * server thought it should be (because of client-side-only DOM - * changes), nothing is done at this point. If the server - * appends the element to a new parent, that will override the - * client DOM in the code below. + * If the client-side element is not inside the parent the server thought it should be (because of + * client-side-only DOM changes), nothing is done at this point. If the server appends the element to a + * new parent, that will override the client DOM in the code below. */ } } @@ -1094,22 +990,17 @@ private void removeAllChildren(Node htmlNode) { } } - private void addChildren(int index, BindingContext context, - JsArray add) { - NodeList nodeChildren = context.node - .getList(NodeFeatures.ELEMENT_CHILDREN); + private void addChildren(int index, BindingContext context, JsArray add) { + NodeList nodeChildren = context.node.getList(NodeFeatures.ELEMENT_CHILDREN); Node beforeRef; if (index == 0) { // Insert at the first position after the client-side-only nodes - beforeRef = getFirstNodeMappedAsStateNode(nodeChildren, - context.htmlNode); + beforeRef = getFirstNodeMappedAsStateNode(nodeChildren, context.htmlNode); } else if (index <= nodeChildren.length() && index > 0) { StateNode previousSibling = getPreviousSibling(index, context); // Insert before the next sibling of the current node - beforeRef = previousSibling == null ? null - : DomApi.wrap(previousSibling.getDomNode()) - .getNextSibling(); + beforeRef = previousSibling == null ? null : DomApi.wrap(previousSibling.getDomNode()).getNextSibling(); } else { // Insert at the end beforeRef = null; @@ -1119,8 +1010,7 @@ private void addChildren(int index, BindingContext context, Object newChildObject = add.get(i); StateNode newChild = (StateNode) newChildObject; - ExistingElementMap existingElementMap = newChild.getTree() - .getRegistry().getExistingElementMap(); + ExistingElementMap existingElementMap = newChild.getTree().getRegistry().getExistingElementMap(); Node childNode = existingElementMap.getElement(newChild.getId()); if (childNode != null) { existingElementMap.remove(newChild.getId()); @@ -1129,16 +1019,14 @@ private void addChildren(int index, BindingContext context, } else { childNode = context.binderContext.createAndBind(newChild); - DomApi.wrap(context.htmlNode).insertBefore(childNode, - beforeRef); + DomApi.wrap(context.htmlNode).insertBefore(childNode, beforeRef); } beforeRef = DomApi.wrap(childNode).getNextSibling(); } } - private static Node getFirstNodeMappedAsStateNode( - NodeList mappedNodeChildren, Node htmlNode) { + private static Node getFirstNodeMappedAsStateNode(NodeList mappedNodeChildren, Node htmlNode) { JsArray clientList = DomApi.wrap(htmlNode).getChildNodes(); for (int i = 0; i < clientList.length(); i++) { @@ -1154,8 +1042,7 @@ private static Node getFirstNodeMappedAsStateNode( } private StateNode getPreviousSibling(int index, BindingContext context) { - NodeList nodeChildren = context.node - .getList(NodeFeatures.ELEMENT_CHILDREN); + NodeList nodeChildren = context.node.getList(NodeFeatures.ELEMENT_CHILDREN); int count = 0; StateNode node = null; @@ -1177,11 +1064,9 @@ private StateNode getPreviousSibling(int index, BindingContext context) { */ private void remove(JsArray listeners, BindingContext context, JsArray> computationsCollection) { - ForEachCallback computationStopper = (computation, - name) -> computation.stop(); + ForEachCallback computationStopper = (computation, name) -> computation.stop(); - computationsCollection - .forEach(collection -> collection.forEach(computationStopper)); + computationsCollection.forEach(collection -> collection.forEach(computationStopper)); context.listenerBindings.forEach(computationStopper); context.listenerRemovers.forEach((remover, name) -> remover.remove()); @@ -1194,20 +1079,16 @@ private void remove(JsArray listeners, BindingContext context, private EventRemover bindDomEventListeners(BindingContext context) { NodeMap elementListeners = getDomEventListenerMap(context.node); elementListeners.forEachProperty((property, name) -> { - Computation computation = bindEventHandlerProperty(property, - context); + Computation computation = bindEventHandlerProperty(property, context); // Run eagerly to add initial listeners before element is attached computation.recompute(); }); - return elementListeners.addPropertyAddListener( - event -> bindEventHandlerProperty(event.getProperty(), - context)); + return elementListeners.addPropertyAddListener(event -> bindEventHandlerProperty(event.getProperty(), context)); } - private Computation bindEventHandlerProperty( - MapProperty eventHandlerProperty, BindingContext context) { + private Computation bindEventHandlerProperty(MapProperty eventHandlerProperty, BindingContext context) { String name = eventHandlerProperty.getName(); assert !context.listenerBindings.has(name); @@ -1240,8 +1121,8 @@ private void removeEventHandler(String eventType, BindingContext context) { private void addEventHandler(String eventType, BindingContext context) { assert !context.listenerRemovers.has(eventType); - EventRemover remover = context.htmlNode.addEventListener(eventType, - event -> handleDomEvent(event, context), false); + EventRemover remover = context.htmlNode.addEventListener(eventType, event -> handleDomEvent(event, context), + false); context.listenerRemovers.set(eventType, remover); } @@ -1255,17 +1136,14 @@ private void handleDomEvent(Event event, BindingContext context) { Node element = context.htmlNode; StateNode node = context.node; - assert element instanceof Element - : "Cannot handle DOM event for a Node"; + assert element instanceof Element : "Cannot handle DOM event for a Node"; String type = event.getType(); NodeMap listenerMap = getDomEventListenerMap(node); - ConstantPool constantPool = node.getTree().getRegistry() - .getConstantPool(); - String expressionConstantKey = (String) listenerMap.getProperty(type) - .getValue(); + ConstantPool constantPool = node.getTree().getRegistry().getConstantPool(); + String expressionConstantKey = (String) listenerMap.getProperty(type).getValue(); assert expressionConstantKey != null; assert constantPool.has(expressionConstantKey); @@ -1282,52 +1160,38 @@ private void handleDomEvent(Event event, BindingContext context) { eventData = Json.createObject(); } for (String expressionString : expressions) { - if (expressionString - .startsWith(JsonConstants.SYNCHRONIZE_PROPERTY_TOKEN)) { - String property = expressionString.substring( - JsonConstants.SYNCHRONIZE_PROPERTY_TOKEN.length()); + if (expressionString.startsWith(JsonConstants.SYNCHRONIZE_PROPERTY_TOKEN)) { + String property = expressionString.substring(JsonConstants.SYNCHRONIZE_PROPERTY_TOKEN.length()); synchronizeProperties.add(property); - } else if (expressionString - .equals(JsonConstants.MAP_STATE_NODE_EVENT_DATA)) { + } else if (expressionString.equals(JsonConstants.MAP_STATE_NODE_EVENT_DATA)) { // map event.target to the closest state node - int targetNodeId = getClosestStateNodeIdToEventTarget(node, - event.getTarget()); - eventData.put(JsonConstants.MAP_STATE_NODE_EVENT_DATA, - targetNodeId); - } else if (expressionString - .startsWith(JsonConstants.MAP_STATE_NODE_EVENT_DATA)) { + int targetNodeId = getClosestStateNodeIdToEventTarget(node, event.getTarget()); + eventData.put(JsonConstants.MAP_STATE_NODE_EVENT_DATA, targetNodeId); + } else if (expressionString.startsWith(JsonConstants.MAP_STATE_NODE_EVENT_DATA)) { // map element returned by JS to the closest state node - String jsEvaluation = expressionString.substring( - JsonConstants.MAP_STATE_NODE_EVENT_DATA.length()); - EventExpression expression = getOrCreateExpression( - jsEvaluation); - JsonValue expressionValue = expression.evaluate(event, - (Element) element); + String jsEvaluation = expressionString.substring(JsonConstants.MAP_STATE_NODE_EVENT_DATA.length()); + EventExpression expression = getOrCreateExpression(jsEvaluation); + JsonValue expressionValue = expression.evaluate(event, (Element) element); // find the closest state node matching the expression value - int targetNodeId = getClosestStateNodeIdToDomNode( - node.getTree(), expressionValue, jsEvaluation); + int targetNodeId = getClosestStateNodeIdToDomNode(node.getTree(), expressionValue, jsEvaluation); eventData.put(expressionString, targetNodeId); } else { - EventExpression expression = getOrCreateExpression( - expressionString); + EventExpression expression = getOrCreateExpression(expressionString); - JsonValue expressionValue = expression.evaluate(event, - (Element) element); + JsonValue expressionValue = expression.evaluate(event, (Element) element); eventData.put(expressionString, expressionValue); } } JsMap commands = JsCollections.map(); - synchronizeProperties.forEach(name -> commands.set(name, - getSyncPropertyCommand(name, context))); + synchronizeProperties.forEach(name -> commands.set(name, getSyncPropertyCommand(name, context))); Consumer sendCommand = debouncePhase -> { sendEventToServer(node, type, eventData, debouncePhase); }; - boolean sendNow = resolveFilters(element, type, expressionSettings, - eventData, sendCommand, commands); + boolean sendNow = resolveFilters(element, type, expressionSettings, eventData, sendCommand, commands); if (sendNow) { // Send if there were not filters or at least one matched @@ -1338,8 +1202,7 @@ private void handleDomEvent(Event event, BindingContext context) { if (flushPendingChanges) { // Flush all debounced events so that they don't happen // in wrong order in the server-side - commandAlreadyExecuted = Debouncer.flushAll() - .contains(sendCommand); + commandAlreadyExecuted = Debouncer.flushAll().contains(sendCommand); } if (!commandAlreadyExecuted) { @@ -1349,15 +1212,12 @@ private void handleDomEvent(Event event, BindingContext context) { } } - private Runnable getSyncPropertyCommand(String propertyName, - BindingContext context) { - return context.node.getMap(NodeFeatures.ELEMENT_PROPERTIES) - .getProperty(propertyName).getSyncToServerCommand(WidgetUtil - .getJsProperty(context.htmlNode, propertyName)); + private Runnable getSyncPropertyCommand(String propertyName, BindingContext context) { + return context.node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty(propertyName) + .getSyncToServerCommand(WidgetUtil.getJsProperty(context.htmlNode, propertyName)); } - private static void sendEventToServer(StateNode node, String type, - JsonObject eventData, String debouncePhase) { + private static void sendEventToServer(StateNode node, String type, JsonObject eventData, String debouncePhase) { if (debouncePhase == null) { if (eventData != null) { eventData.remove(JsonConstants.EVENT_DATA_PHASE); @@ -1372,9 +1232,8 @@ private static void sendEventToServer(StateNode node, String type, node.getTree().sendEventToServer(node, type, eventData); } - private static boolean resolveFilters(Node element, String eventType, - JsonObject expressionSettings, JsonObject eventData, - Consumer sendCommand, JsMap commands) { + private static boolean resolveFilters(Node element, String eventType, JsonObject expressionSettings, + JsonObject eventData, Consumer sendCommand, JsMap commands) { boolean noFilters = true; boolean atLeastOneFilterMatched = false; @@ -1389,14 +1248,12 @@ private static boolean resolveFilters(Node element, String eventType, } noFilters = false; - boolean filterMatched = eventData != null - && eventData.getBoolean(expression); + boolean filterMatched = eventData != null && eventData.getBoolean(expression); if (hasDebounce && filterMatched) { String debouncerId = "on-" + eventType + ":" + expression; // Count as a match only if at least one debounce is eager - filterMatched = resolveDebounces(element, debouncerId, - (JsonArray) settings, sendCommand, commands); + filterMatched = resolveDebounces(element, debouncerId, (JsonArray) settings, sendCommand, commands); } atLeastOneFilterMatched |= filterMatched; @@ -1405,9 +1262,8 @@ private static boolean resolveFilters(Node element, String eventType, return noFilters || atLeastOneFilterMatched; } - private static boolean resolveDebounces(Node element, String debouncerId, - JsonArray debounceList, Consumer sendCommand, - JsMap commands) { + private static boolean resolveDebounces(Node element, String debouncerId, JsonArray debounceList, + Consumer sendCommand, JsMap commands) { boolean atLeastOneEager = false; for (int i = 0; i < debounceList.length(); i++) { @@ -1426,8 +1282,7 @@ private static boolean resolveDebounces(Node element, String debouncerId, phases.add(debounceSettings.getString(j)); } - boolean eager = Debouncer.getOrCreate(element, debouncerId, timeout) - .trigger(phases, sendCommand, commands); + boolean eager = Debouncer.getOrCreate(element, debouncerId, timeout).trigger(phases, sendCommand, commands); atLeastOneEager |= eager; } @@ -1439,8 +1294,7 @@ private EventRemover bindClassList(Element element, StateNode node) { NodeList classNodeList = node.getList(NodeFeatures.CLASS_LIST); for (int i = 0; i < classNodeList.length(); i++) { - DomApi.wrap(element).getClassList() - .add((String) classNodeList.get(i)); + DomApi.wrap(element).getClassList().add((String) classNodeList.get(i)); } return classNodeList.addSpliceListener(e -> { @@ -1459,21 +1313,17 @@ private EventRemover bindClassList(Element element, StateNode node) { } private EventRemover bindPolymerEventHandlerNames(BindingContext context) { - return ServerEventHandlerBinder.bindServerEventHandlerNames( - () -> WidgetUtil.crazyJsoCast(context.htmlNode), context.node, - NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS, false); + return ServerEventHandlerBinder.bindServerEventHandlerNames(() -> WidgetUtil.crazyJsoCast(context.htmlNode), + context.node, NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS, false); } private EventRemover bindClientCallableMethods(BindingContext context) { - assert context.htmlNode instanceof Element - : "Cannot bind client delegate methods to a Node"; - return ServerEventHandlerBinder.bindServerEventHandlerNames( - (Element) context.htmlNode, context.node); + assert context.htmlNode instanceof Element : "Cannot bind client delegate methods to a Node"; + return ServerEventHandlerBinder.bindServerEventHandlerNames((Element) context.htmlNode, context.node); } - private static void updateAttributeValue( - ApplicationConfiguration configuration, Element element, - String attribute, Object value) { + private static void updateAttributeValue(ApplicationConfiguration configuration, Element element, String attribute, + Object value) { if (value == null || value instanceof String) { WidgetUtil.updateAttribute(element, attribute, (String) value); } else { @@ -1481,36 +1331,30 @@ private static void updateAttributeValue( if (JsonType.OBJECT.equals(jsonValue.getType())) { JsonObject object = (JsonObject) jsonValue; assert object.hasKey(NodeProperties.URI_ATTRIBUTE) - : "Implementation error: JsonObject is recieved as an attribute value for '" - + attribute + "' but it has no " - + NodeProperties.URI_ATTRIBUTE + " key"; + : "Implementation error: JsonObject is recieved as an attribute value for '" + attribute + + "' but it has no " + NodeProperties.URI_ATTRIBUTE + " key"; String uri = object.getString(NodeProperties.URI_ATTRIBUTE); - if (configuration.isWebComponentMode() - && !WidgetUtil.isAbsoluteUrl(uri)) { + if (configuration.isWebComponentMode() && !WidgetUtil.isAbsoluteUrl(uri)) { String baseUri = configuration.getServiceUrl(); baseUri = baseUri.endsWith("/") ? baseUri : baseUri + "/"; - WidgetUtil.updateAttribute(element, attribute, - baseUri + uri); + WidgetUtil.updateAttribute(element, attribute, baseUri + uri); } else { WidgetUtil.updateAttribute(element, attribute, uri); } } else { - WidgetUtil.updateAttribute(element, attribute, - value.toString()); + WidgetUtil.updateAttribute(element, attribute, value.toString()); } } } - private static EventExpression getOrCreateExpression( - String expressionString) { + private static EventExpression getOrCreateExpression(String expressionString) { if (expressionCache == null) { expressionCache = JsCollections.map(); } EventExpression expression = expressionCache.get(expressionString); if (expression == null) { - expression = NativeFunction.create("event", "element", - "return (" + expressionString + ")"); + expression = NativeFunction.create("event", "element", "return (" + expressionString + ")"); expressionCache.set(expressionString, expression); } @@ -1518,8 +1362,7 @@ private static EventExpression getOrCreateExpression( } // This method could be moved somewhere to be reusable - private int getClosestStateNodeIdToEventTarget(StateNode topNode, - EventTarget target) { + private int getClosestStateNodeIdToEventTarget(StateNode topNode, EventTarget target) { if (target == null) { return -1; } @@ -1536,8 +1379,7 @@ private int getClosestStateNodeIdToEventTarget(StateNode topNode, } // NOTE: for now not looking at virtual children on purpose. // If needed (?), those can be included here to the search stack - stateNode.getList(NodeFeatures.ELEMENT_CHILDREN) - .forEach(child -> stack.push((StateNode) child)); + stateNode.getList(NodeFeatures.ELEMENT_CHILDREN).forEach(child -> stack.push((StateNode) child)); } // no direct match, all child element state nodes collected. // bottom-up search elements until matching state node found @@ -1545,16 +1387,13 @@ private int getClosestStateNodeIdToEventTarget(StateNode topNode, return getStateNodeForElement(stack, targetNode); } catch (Exception e) { // not going to let event handling fail; just report nothing found - Console.debug( - "An error occurred when Flow tried to find a state node matching the element " - + target + ", which was the event.target. Error: " - + e.getMessage()); + Console.debug("An error occurred when Flow tried to find a state node matching the element " + target + + ", which was the event.target. Error: " + e.getMessage()); } return -1; // no match / error; } - private static int getStateNodeForElement(JsArray searchStack, - DomNode targetNode) { + private static int getStateNodeForElement(JsArray searchStack, DomNode targetNode) { while (targetNode != null) { for (int i = searchStack.length() - 1; i > -1; i--) { final StateNode stateNode = searchStack.get(i); @@ -1567,17 +1406,15 @@ private static int getStateNodeForElement(JsArray searchStack, return -1; } - private int getClosestStateNodeIdToDomNode(StateTree stateTree, - Object domNodeReference, String eventDataExpression) { + private int getClosestStateNodeIdToDomNode(StateTree stateTree, Object domNodeReference, + String eventDataExpression) { if (domNodeReference == null) { return -1; } try { - DomNode targetNode = DomApi - .wrap(WidgetUtil.crazyJsCast(domNodeReference)); + DomNode targetNode = DomApi.wrap(WidgetUtil.crazyJsCast(domNodeReference)); while (targetNode != null) { - StateNode stateNodeForDomNode = stateTree - .getStateNodeForDomNode(targetNode); + StateNode stateNodeForDomNode = stateTree.getStateNodeForDomNode(targetNode); if (stateNodeForDomNode != null) { return stateNodeForDomNode.getId(); } @@ -1585,12 +1422,9 @@ private int getClosestStateNodeIdToDomNode(StateTree stateTree, } } catch (Exception e) { // not going to let event handling fail; just report nothing found - Console.debug( - "An error occurred when Flow tried to find a state node matching the element " - + domNodeReference - + ", returned by an event data expression " - + eventDataExpression + ". Error: " - + e.getMessage()); + Console.debug("An error occurred when Flow tried to find a state node matching the element " + + domNodeReference + ", returned by an event data expression " + eventDataExpression + ". Error: " + + e.getMessage()); } return -1; // no match / error; } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/binding/TextBindingStrategy.java b/flow-client/src/main/java/com/vaadin/client/flow/binding/TextBindingStrategy.java index 4c0b6ee24f3..5c33b8c2cc3 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/binding/TextBindingStrategy.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/binding/TextBindingStrategy.java @@ -39,11 +39,9 @@ public class TextBindingStrategy implements BindingStrategy { /** - * This is used as a weak set. Only keys are important so that they are - * weakly referenced + * This is used as a weak set. Only keys are important so that they are weakly referenced */ - private static final JsWeakMap BOUND = JsCollections - .weakMap(); + private static final JsWeakMap BOUND = JsCollections.weakMap(); @Override public Text create(StateNode node) { @@ -56,8 +54,7 @@ public boolean isApplicable(StateNode node) { } @Override - public void bind(StateNode stateNode, Text htmlNode, - BinderContext nodeFactory) { + public void bind(StateNode stateNode, Text htmlNode, BinderContext nodeFactory) { assert stateNode.hasFeature(NodeFeatures.TEXT_NODE); if (BOUND.has(stateNode)) { @@ -68,8 +65,8 @@ public void bind(StateNode stateNode, Text htmlNode, NodeMap textMap = stateNode.getMap(NodeFeatures.TEXT_NODE); MapProperty textProperty = textMap.getProperty(NodeProperties.TEXT); - Computation computation = Reactive.runWhenDependenciesChange( - () -> htmlNode.setData((String) textProperty.getValue())); + Computation computation = Reactive + .runWhenDependenciesChange(() -> htmlNode.setData((String) textProperty.getValue())); stateNode.addUnregisterListener(e -> unbind(stateNode, computation)); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsArray.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsArray.java index 72c27621c15..6db5153fb36 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsArray.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsArray.java @@ -26,8 +26,8 @@ import jsinterop.annotations.JsType; /** - * Native JS Array interface with an alternative implementation for JRE usage. - * Use {@link JsCollections#array()} to create an appropriate instance. + * Native JS Array interface with an alternative implementation for JRE usage. Use {@link JsCollections#array()} to + * create an appropriate instance. * * @author Vaadin Ltd * @since 1.0 @@ -38,9 +38,8 @@ @SuppressWarnings("deprecation") public class JsArray { /* - * Don't look at this class as an example of how to integrate a JS API with - * a JRE-fallback. The use of @JsOverlay means that it must be made in - * needlessly complex way. JsMap is a better example. + * Don't look at this class as an example of how to integrate a JS API with a JRE-fallback. The use of @JsOverlay + * means that it must be made in needlessly complex way. JsMap is a better example. */ /** @@ -51,8 +50,7 @@ protected JsArray() { } /** - * Gets the item at the given index. This is corresponding to - * return array[index] in JavaScript. + * Gets the item at the given index. This is corresponding to return array[index] in JavaScript. * * @param index * the index to get @@ -68,8 +66,7 @@ public final T get(int index) { } /** - * Sets the item at the given index. This is corresponding to - * array[index] = value in JavaScript. + * Sets the item at the given index. This is corresponding to array[index] = value in JavaScript. * * @param index * the index to set @@ -131,8 +128,7 @@ public final int pushArray(JsArray values) { * @return an array of removed items */ @JsOverlay - public final JsArray spliceArray(int index, int remove, - JsArray add) { + public final JsArray spliceArray(int index, int remove, JsArray add) { if (GWT.isScript()) { return JsniHelper.spliceArray(this, index, remove, add); } else { @@ -151,8 +147,7 @@ public final JsArray spliceArray(int index, int remove, * new items to add * @return an array of removed items */ - public native JsArray splice(int index, int remove, - @SuppressWarnings("unchecked") T... add); + public native JsArray splice(int index, int remove, @SuppressWarnings("unchecked") T... add); /** * Removes the item at the given index. @@ -197,8 +192,7 @@ public final boolean isEmpty() { * * @param toRemove * the item to remove - * @return true if the item was found and removed from the - * array, false otherwise + * @return true if the item was found and removed from the array, false otherwise */ @JsOverlay public final boolean remove(T toRemove) { @@ -234,14 +228,12 @@ private JsniHelper() { // Only static stuff here, should never be instantiated } - static native int pushArray(JsArray array, - JsArray values) + static native int pushArray(JsArray array, JsArray values) /*-{ return array.push.apply(array, values); }-*/; - static native JsArray spliceArray(JsArray array, int index, - int remove, JsArray add) + static native JsArray spliceArray(JsArray array, int index, int remove, JsArray add) /*-{ return array.splice.apply(array, [index, remove].concat(add)); }-*/; diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsCollections.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsCollections.java index d0f201df4ea..594060e1262 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsCollections.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsCollections.java @@ -26,8 +26,7 @@ import com.vaadin.client.flow.collection.jre.JreJsWeakMap; /** - * Factory for JavaScript collection implementations with support for - * alternative JRE implementations. + * Factory for JavaScript collection implementations with support for alternative JRE implementations. * * @author Vaadin Ltd * @since 1.0 @@ -36,8 +35,7 @@ public class JsCollections { /** - * Functional interface for iterating all the entries in a {@link JsSet} or - * {@link JsArray}. + * Functional interface for iterating all the entries in a {@link JsSet} or {@link JsArray}. * * @param * the value type @@ -183,8 +181,7 @@ private static void checkJunitPolyfillStatus() { "This is not a JUnit compilation even though compiler.stackMode check has the expected value"); } - assert !isNativeMapConstructor() - : "ES6 collection cannot be created before gwtSetUp has set up the polyfill"; + assert !isNativeMapConstructor() : "ES6 collection cannot be created before gwtSetUp has set up the polyfill"; } private static native boolean isNativeMapConstructor() diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsMap.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsMap.java index 42238ec6020..8e7ce10adae 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsMap.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsMap.java @@ -22,8 +22,8 @@ import jsinterop.annotations.JsType; /** - * Native JS Map interface with an alternative implementation for JRE usage. Use - * {@link JsCollections#map()} to create an appropriate instance. + * Native JS Map interface with an alternative implementation for JRE usage. Use {@link JsCollections#map()} to create + * an appropriate instance. * * @author Vaadin Ltd * @since 1.0 @@ -76,14 +76,12 @@ public JsMap() { public native JsMap set(K key, V value); /** - * Gets the value mapped for the given key. Returns null if - * there is no mapping or if the key is explicitly mapped to - * null. + * Gets the value mapped for the given key. Returns null if there is no mapping or if the key is + * explicitly mapped to null. * * @param key * the key to get a value for - * @return the value corresponding to the given key; or null - * there is no mapping. + * @return the value corresponding to the given key; or null there is no mapping. */ public native V get(K key); @@ -92,8 +90,7 @@ public JsMap() { * * @param key * the key to check - * @return {@code true} if there is a mapping for the key; {@code false} if - * there is no mapping + * @return {@code true} if there is a mapping for the key; {@code false} if there is no mapping */ public native boolean has(K key); @@ -102,9 +99,8 @@ public JsMap() { * * @param key * the key for which to remove the mapping - * @return {@code true} if the map contained a mapping for the given key - * prior to calling this method; {@code false} if no mapping was - * present + * @return {@code true} if the map contained a mapping for the given key prior to calling this method; {@code false} + * if no mapping was present */ public native boolean delete(K key); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsSet.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsSet.java index 2dc80fd9f7f..75a99b220f8 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsSet.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsSet.java @@ -23,8 +23,8 @@ import com.vaadin.client.flow.collection.JsCollections.ForEachCallback; /** - * Native JS Set interface with an alternative implementation for JRE usage. Use - * {@link JsCollections#set()} to create an appropriate instance. + * Native JS Set interface with an alternative implementation for JRE usage. Use {@link JsCollections#set()} to create + * an appropriate instance. * * @author Vaadin Ltd * @since 1.0 @@ -64,8 +64,7 @@ public JsSet() { * * @param value * the value to remove - * @return {@code true} if the map contained the value prior to calling this - * method; {@code false} otherwise + * @return {@code true} if the map contained the value prior to calling this method; {@code false} otherwise */ public native boolean delete(V value); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsWeakMap.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsWeakMap.java index 06d59734b6f..428933affd5 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/JsWeakMap.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/JsWeakMap.java @@ -18,8 +18,8 @@ import jsinterop.annotations.JsType; /** - * Native JS WeakMap interface with an alternative implementation for JRE usage. - * Use {@link JsCollections#weakMap()} to create an appropriate instance. + * Native JS WeakMap interface with an alternative implementation for JRE usage. Use {@link JsCollections#weakMap()} to + * create an appropriate instance. * * @author Vaadin Ltd * @since 1.0 @@ -42,14 +42,12 @@ public interface JsWeakMap { JsWeakMap set(K key, V value); /** - * Gets the value mapped for the given key. Returns null if - * there is no mapping, if the key is explicitly mapped to null - * or if the key has been garbage collected. + * Gets the value mapped for the given key. Returns null if there is no mapping, if the key is + * explicitly mapped to null or if the key has been garbage collected. * * @param key * the key to get a value for - * @return the value corresponding to the given key; or null - * there is no mapping. + * @return the value corresponding to the given key; or null there is no mapping. */ V get(K key); @@ -58,8 +56,7 @@ public interface JsWeakMap { * * @param key * the key to check - * @return true if there is a mapping for the key; - * false if there is no mapping + * @return true if there is a mapping for the key; false if there is no mapping */ boolean has(K key); @@ -68,9 +65,8 @@ public interface JsWeakMap { * * @param key * the key for which to remove the mapping - * @return true if the map contained a mapping for the given - * key prior to calling this method; false if no - * mapping was present + * @return true if the map contained a mapping for the given key prior to calling this method; + * false if no mapping was present */ boolean delete(K key); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsArray.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsArray.java index bcb531a7b03..e819294281e 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsArray.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsArray.java @@ -94,8 +94,7 @@ public int length() { } /** - * JRE implementation of the final {@link #spliceArray(int, int, JsArray)} - * method. + * JRE implementation of the final {@link #spliceArray(int, int, JsArray)} method. * * @param index * the index at which to do the operation @@ -105,19 +104,16 @@ public int length() { * new items to add * @return an array of removed items */ - public JsArray doSpliceArray(int index, int remove, - JsArray add) { + public JsArray doSpliceArray(int index, int remove, JsArray add) { return doSplice(index, remove, ((JreJsArray) add).values); } @Override - public JsArray splice(int index, int remove, - @SuppressWarnings("unchecked") T... add) { + public JsArray splice(int index, int remove, @SuppressWarnings("unchecked") T... add) { return doSplice(index, remove, Arrays.asList(add)); } - private JreJsArray doSplice(int index, int remove, - List add) { + private JreJsArray doSplice(int index, int remove, List add) { JreJsArray removed; if (remove > 0) { List removeRange = values.subList(index, index + remove); @@ -141,8 +137,7 @@ public void doClear() { } /** - * Gets the values of this array as a list. This method is only exposed to - * simplify testing. + * Gets the values of this array as a list. This method is only exposed to simplify testing. * * @param array * the js array to get the values from diff --git a/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsWeakMap.java b/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsWeakMap.java index 2b9096c99c3..83dd13e070e 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsWeakMap.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/collection/jre/JreJsWeakMap.java @@ -37,24 +37,20 @@ @Deprecated public class JreJsWeakMap implements JsWeakMap { /* - * Using an ordinary HashMap here since WeakHashMap would make the GWT - * compiler upset. The difference can't be observed since there are no way - * of iterating the contents of a WeakMap or checking its size. Leaking - * memory is no issue since the JRE version is only used for testing. + * Using an ordinary HashMap here since WeakHashMap would make the GWT compiler upset. The difference can't be + * observed since there are no way of iterating the contents of a WeakMap or checking its size. Leaking memory is no + * issue since the JRE version is only used for testing. */ private Map values = new HashMap<>(); @Override public JsWeakMap set(K key, V value) { /* - * The native JavaScript implementation requires the keys to be - * "typeof object". + * The native JavaScript implementation requires the keys to be "typeof object". * - * We test for the most common offending types here to help the - * developer notice problems as early as possible. + * We test for the most common offending types here to help the developer notice problems as early as possible. */ - if (key instanceof String || key instanceof Boolean - || key instanceof Double) { + if (key instanceof String || key instanceof Boolean || key instanceof Double) { throw new IllegalArgumentException("Key must be a JS object type"); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java index 7174fc7aa30..6e0e2b509fa 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java @@ -20,12 +20,10 @@ import elemental.dom.Node; /** - * Access point for DOM API. All operations and interactions with DOM nodes and - * elements should go through this class. + * Access point for DOM API. All operations and interactions with DOM nodes and elements should go through this class. *

- * This class delegates the operations to the actual DOM API implementations, - * which might be changed on the run, meaning after dependencies have been - * loaded. + * This class delegates the operations to the actual DOM API implementations, which might be changed on the run, meaning + * after dependencies have been loaded. * * @author Vaadin Ltd * @since 1.0 @@ -40,8 +38,7 @@ public class DomApi { static boolean polymerMicroLoaded = false; /** - * The currently used DOM API implementation. By default just returns the - * same object. + * The currently used DOM API implementation. By default just returns the same object. * * Package protected for testing reasons. */ @@ -52,8 +49,7 @@ private DomApi() { } /** - * Wraps the given DOM node to make it safe to invoke any of the methods - * from {@link DomNode} or {@link DomElement}. + * Wraps the given DOM node to make it safe to invoke any of the methods from {@link DomNode} or {@link DomElement}. * * @param node * the node to wrap diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java index 4078ceed511..7db50cba2db 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java @@ -27,8 +27,7 @@ public interface DomApiImpl { /** - * Wraps the given DOM node to make it safe to invoke any of the methods - * from {@link DomNode} or {@link DomElement}. + * Wraps the given DOM node to make it safe to invoke any of the methods from {@link DomNode} or {@link DomElement}. * * @param node * the node to wrap diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomElement.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomElement.java index 071e90fb61d..b990aa9ffb0 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomElement.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomElement.java @@ -24,14 +24,12 @@ import jsinterop.annotations.JsType; /** - * Element that has all methods from - * Element - * API that have been overridden in - * Polymer - * DOM module. + * Element that has all methods from Element API + * that have been overridden in Polymer DOM + * module. *

- * No instances of this class should be created directly, but instead - * {@link DomApi#wrap(elemental.dom.Node)} should be used + * No instances of this class should be created directly, but instead {@link DomApi#wrap(elemental.dom.Node)} should be + * used * * @author Vaadin Ltd * @since 1.0 @@ -40,9 +38,7 @@ public interface DomElement extends DomNode { /** - * A - * - * DOMTokenList java representation. + * A DOMTokenList java representation. */ @JsType(isNative = true) interface DomTokenList { @@ -68,8 +64,7 @@ interface DomTokenList { * * @param token * the token to check for - * @return true if token was found, false if - * not + * @return true if token was found, false if not */ boolean contains(String token); @@ -90,14 +85,13 @@ interface DomTokenList { void remove(String token); /** - * Removes token from string and returns false - * . If token doesn't exist it's added and the function - * returns true. + * Removes token from string and returns false . If token doesn't exist + * it's added and the function returns true. * * @param token * the token to toggle - * @return true if token did not exist and was added, - * false if token existed and was removed + * @return true if token did not exist and was added, false if token existed and was + * removed */ boolean toggle(String token); } @@ -144,8 +138,7 @@ interface DomTokenList { void setInnerHTML(String innerHTML); /** - * Returns the children property containing all child elements - * of the element, as a live collection. + * Returns the children property containing all child elements of the element, as a live collection. * * @return a collection of all child elements */ @@ -153,8 +146,7 @@ interface DomTokenList { HTMLCollection getChildren(); /** - * Returns the first Node which matches the specified selector - * string relative to the element. + * Returns the first Node which matches the specified selector string relative to the element. * * @param selectors * a group of selectors to match on @@ -163,15 +155,14 @@ interface DomTokenList { Element querySelector(String selectors); /** - * Returns a non-live NodeList of all elements descended from - * this element and match the given group of CSS selectors. + * Returns a non-live NodeList of all elements descended from this element and match the given group of + * CSS selectors. *

- * NOTE: returns an array since that is what the Polymer.dom API does, and - * luckily native NodeList items can be accessed array like with - * list[index]. + * NOTE: returns an array since that is what the Polymer.dom API does, and luckily native NodeList items can be + * accessed array like with list[index]. *

- * This means that only {@link JsArray#get(int)} and - * {@link JsArray#length()} methods can be used from the returned "array". + * This means that only {@link JsArray#get(int)} and {@link JsArray#length()} methods can be used from the returned + * "array". * * @param selectors * a group of selectors to match on diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomNode.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomNode.java index aec8f2156d7..e8fefb2413e 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomNode.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomNode.java @@ -23,14 +23,11 @@ import elemental.dom.Node; /** - * Node that has all methods from - * Node API - * that have been overridden in - * Polymer - * DOM module. + * Node that has all methods from Node API that have + * been overridden in Polymer DOM module. *

- * No instances of this class should be created directly, but instead - * {@link DomApi#wrap(elemental.dom.Node)} should be used + * No instances of this class should be created directly, but instead {@link DomApi#wrap(elemental.dom.Node)} should be + * used * * @author Vaadin Ltd * @since 1.0 @@ -41,12 +38,11 @@ public interface DomNode { /** * Returns the childNodes property. *

- * NOTE: returns an array since that is what the Polymer.dom API does, and - * luckily native NodeList items can be accessed array like with - * list[index]. + * NOTE: returns an array since that is what the Polymer.dom API does, and luckily native NodeList items can be + * accessed array like with list[index]. *

- * This means that only {@link JsArray#get(int)} and - * {@link JsArray#length()} methods can be used from the returned "array". + * This means that only {@link JsArray#get(int)} and {@link JsArray#length()} methods can be used from the returned + * "array". * * @return the child nodes */ @@ -111,8 +107,7 @@ public interface DomNode { void appendChild(Node node); /** - * Inserts the first Node given in a parameter immediately before the - * second, child of this element, Node. + * Inserts the first Node given in a parameter immediately before the second, child of this element, Node. * * @param newChild * the node to be inserted @@ -122,8 +117,7 @@ public interface DomNode { void insertBefore(Node newChild, Node refChild); /** - * Removes a child node from the current node, which much be a child of the - * current node. + * Removes a child node from the current node, which much be a child of the current node. * * @param childNode * the child node to remove @@ -131,25 +125,21 @@ public interface DomNode { void removeChild(Node childNode); /** - * Replaces one child Node of the current one with the second one given in - * parameter. + * Replaces one child Node of the current one with the second one given in parameter. * * @param newChild - * the new node to replace the oldChild. If it already exists in - * the DOM, it is first removed. + * the new node to replace the oldChild. If it already exists in the DOM, it is first removed. * @param oldChild * is the existing child to be replaced. */ void replaceChild(Node newChild, Node oldChild); /** - * Clone a Node, and optionally, all of its contents. By default, it clones - * the content of the node. + * Clone a Node, and optionally, all of its contents. By default, it clones the content of the node. * * @param deep - * true if the children of the node should also be - * cloned, or false to clone only the specified - * node. + * true if the children of the node should also be cloned, or false to clone + * only the specified node. * @return a clone of this node */ Node cloneNode(boolean deep); @@ -157,16 +147,14 @@ public interface DomNode { /** * Gets the parent node of this node. * - * @return the parent node, not null if this node has no - * parent. + * @return the parent node, not null if this node has no parent. */ @JsProperty Node getParentNode(); /** - * The isSameNode() method for Node objects is a legacy alias the for the - * === strict equality operator. That is, it tests whether two nodes are the - * same (in other words, whether they reference the same object). + * The isSameNode() method for Node objects is a legacy alias the for the === strict equality operator. That is, it + * tests whether two nodes are the same (in other words, whether they reference the same object). * * @param node * the node to test diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java index 6a368eb10da..5c0609cb99b 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java @@ -22,8 +22,7 @@ /** * Implementation of {@link DomApiImpl} that uses the - * Polymer - * 's DOM API. + * Polymer 's DOM API. *

* Contains methods for checking whether polymer-micro.html has been loaded. * @@ -40,13 +39,11 @@ public DomElement wrap(Node node) { /** * Checks whether the polymer-micro.html is loaded or not. * - * @return true if polymer micro has been loaded, - * false if not + * @return true if polymer micro has been loaded, false if not */ public static boolean isPolymerMicroLoaded() { // Don't use the impl with Polymer 2 - return getPolymer() != null - && getPolymer().getVersion().startsWith("1."); + return getPolymer() != null && getPolymer().getVersion().startsWith("1."); } /** @@ -56,10 +53,8 @@ public static boolean isPolymerMicroLoaded() { interface Polymer { /** - * A Polymer - * .dom method java representation. Wraps a Node so - * that it works with Polymer based web components. + * A Polymer .dom method java + * representation. Wraps a Node so that it works with Polymer based web components. * * @param node * the node to wrap to Polymer dom @@ -80,11 +75,9 @@ interface Polymer { /** * Returns a reference to the native Polymer object in JavaScript. *

- * The existence of this object can be used to check whether - * polymer-micro.html has been loaded. + * The existence of this object can be used to check whether polymer-micro.html has been loaded. * - * @return the polymer object, or null if polymer micro has not - * been loaded + * @return the polymer object, or null if polymer micro has not been loaded */ @JsProperty(namespace = JsPackage.GLOBAL, name = "Polymer") private static native Polymer getPolymer(); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/model/UpdatableModelProperties.java b/flow-client/src/main/java/com/vaadin/client/flow/model/UpdatableModelProperties.java index 7f857866b79..59b017e7b3f 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/model/UpdatableModelProperties.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/model/UpdatableModelProperties.java @@ -24,11 +24,9 @@ /** * The storage class for set of updatable model properties. *

- * This class is stored inside a {@link StateNode} via - * {@link StateNode#setNodeData(Object)} if there is any data to store at all. - * Once it's stored in the {@link StateNode} the code which sends updates to the - * server side when a polymer property is updated uses this data to detect - * whether server expects the update to be sent(see + * This class is stored inside a {@link StateNode} via {@link StateNode#setNodeData(Object)} if there is any data to + * store at all. Once it's stored in the {@link StateNode} the code which sends updates to the server side when a + * polymer property is updated uses this data to detect whether server expects the update to be sent(see * {@link SimpleElementBindingStrategy}). * * @author Vaadin Ltd @@ -40,8 +38,7 @@ public class UpdatableModelProperties { private final JsSet properties = JsCollections.set(); /** - * Creates a new instance of storage class based on given - * {@code properties}. + * Creates a new instance of storage class based on given {@code properties}. * * @param properties * updatable properties array diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/ListSpliceEvent.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/ListSpliceEvent.java index 6a1872cc8d6..3a753a6a03a 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/ListSpliceEvent.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/ListSpliceEvent.java @@ -43,12 +43,10 @@ public class ListSpliceEvent extends ReactiveValueChangeEvent { * @param add * the added items, not null * @param clear - * true when this is an event triggered upon - * removing all the nodes of the given list, false - * otherwise + * true when this is an event triggered upon removing all the nodes of the given list, + * false otherwise */ - public ListSpliceEvent(NodeList source, int index, JsArray remove, - JsArray add, boolean clear) { + public ListSpliceEvent(NodeList source, int index, JsArray remove, JsArray add, boolean clear) { super(source); assert remove != null; @@ -95,8 +93,7 @@ public JsArray getAdd() { /** * Gets whether this event is a {@code clear} event. * - * @return true if the event was triggered after a full clear, - * false otherwise. + * @return true if the event was triggered after a full clear, false otherwise. */ public boolean isClear() { return clear; diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapProperty.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapProperty.java index 67404d07d9d..d2a61c49765 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapProperty.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapProperty.java @@ -38,8 +38,8 @@ public class MapProperty implements ReactiveValue { private final NodeMap map; /** - * Indicates that the server update is in progress. While this is true we - * don't accept any changes via {@link #syncToServer(Object)} method. + * Indicates that the server update is in progress. While this is true we don't accept any changes via + * {@link #syncToServer(Object)} method. */ private boolean isServerUpdate; @@ -49,14 +49,12 @@ public class MapProperty implements ReactiveValue { private final ReactiveEventRouter eventRouter = new ReactiveEventRouter( this) { @Override - protected MapPropertyChangeListener wrap( - ReactiveValueChangeListener listener) { + protected MapPropertyChangeListener wrap(ReactiveValueChangeListener listener) { return listener::onValueChange; } @Override - protected void dispatchEvent(MapPropertyChangeListener listener, - MapPropertyChangeEvent event) { + protected void dispatchEvent(MapPropertyChangeListener listener, MapPropertyChangeEvent event) { listener.onPropertyChange(event); } }; @@ -86,8 +84,7 @@ public MapProperty(String name, NodeMap map) { * @param map * the map that the property belongs to * @param forceValueUpdate - * whether value update for {@code name} property should be - * applied regardless of previous value + * whether value update for {@code name} property should be applied regardless of previous value */ public MapProperty(String name, NodeMap map, boolean forceValueUpdate) { this.name = name; @@ -124,14 +121,12 @@ public Object getValue() { } /** - * Checks whether this property has a value. A property has a value if - * {@link #setValue(Object)} has been invoked after the property was created - * or {@link #removeValue()} was invoked. + * Checks whether this property has a value. A property has a value if {@link #setValue(Object)} has been invoked + * after the property was created or {@link #removeValue()} was invoked. * * @see #removeValue() * - * @return true if the property has a value, false - * if the property has no value. + * @return true if the property has a value, false if the property has no value. */ public boolean hasValue() { eventRouter.registerRead(); @@ -139,8 +134,7 @@ public boolean hasValue() { } /** - * Sets the property value. Changing the value fires a - * {@link MapPropertyChangeEvent}. + * Sets the property value. Changing the value fires a {@link MapPropertyChangeEvent}. * * @see #addChangeListener(MapPropertyChangeListener) * @@ -157,16 +151,13 @@ public void setValue(Object value) { } /** - * Removes the value of this property so that {@link #hasValue()} will - * return false and {@link #getValue()} will return - * null until the next time {@link #setValue(Object)} is run. A - * {@link MapPropertyChangeEvent} will be fired if this property has a - * value. + * Removes the value of this property so that {@link #hasValue()} will return false and + * {@link #getValue()} will return null until the next time {@link #setValue(Object)} is run. A + * {@link MapPropertyChangeEvent} will be fired if this property has a value. *

- * Once a property has been created, it can no longer be removed from its - * map. The same semantics as e.g. {@link Map#remove(Object)} is instead - * provided by marking the value of the property as removed to distinguish - * it from assigning null as the value. + * Once a property has been created, it can no longer be removed from its map. The same semantics as e.g. + * {@link Map#remove(Object)} is instead provided by marking the value of the property as removed to distinguish it + * from assigning null as the value. */ public void removeValue() { if (hasValue) { @@ -180,8 +171,7 @@ public void removeValue() { } private void doSetValue(Object value) { - if (!forceValueUpdate && hasValue - && Objects.equals(value, this.value)) { + if (!forceValueUpdate && hasValue && Objects.equals(value, this.value)) { // Nothing to do return; } @@ -194,13 +184,11 @@ private void updateValue(Object value, boolean hasValue) { this.hasValue = hasValue; this.value = value; - eventRouter - .fireEvent(new MapPropertyChangeEvent(this, oldValue, value)); + eventRouter.fireEvent(new MapPropertyChangeEvent(this, oldValue, value)); } /** - * Adds a listener that gets notified when the value of this property - * changes. + * Adds a listener that gets notified when the value of this property changes. * * @param listener * the property change listener to add @@ -211,19 +199,17 @@ public EventRemover addChangeListener(MapPropertyChangeListener listener) { } @Override - public EventRemover addReactiveValueChangeListener( - ReactiveValueChangeListener reactiveValueChangeListener) { + public EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) { return eventRouter.addReactiveListener(reactiveValueChangeListener); } /** - * Returns the value, or the given defaultValue if the property does not - * have a value or the property value is null. + * Returns the value, or the given defaultValue if the property does not have a value or the property value is null. * * @param defaultValue * the default value - * @return the value of the property or the default value if the property - * does not have a value or the property value is null + * @return the value of the property or the default value if the property does not have a value or the property + * value is null */ public int getValueOrDefault(int defaultValue) { if (hasValue()) { @@ -238,13 +224,12 @@ public int getValueOrDefault(int defaultValue) { } /** - * Returns the value, or the given defaultValue if the property does not - * have a value or the property value is null. + * Returns the value, or the given defaultValue if the property does not have a value or the property value is null. * * @param defaultValue * the default value - * @return the value of the property or the default value if the property - * does not have a value or the property value is null + * @return the value of the property or the default value if the property does not have a value or the property + * value is null */ public boolean getValueOrDefault(boolean defaultValue) { if (hasValue()) { @@ -259,13 +244,12 @@ public boolean getValueOrDefault(boolean defaultValue) { } /** - * Returns the value, or the given defaultValue if the property does not - * have a value or the property value is null. + * Returns the value, or the given defaultValue if the property does not have a value or the property value is null. * * @param defaultValue * the default value - * @return the value of the property or the default value if the property - * does not have a value or the property value is null + * @return the value of the property or the default value if the property does not have a value or the property + * value is null */ public String getValueOrDefault(String defaultValue) { if (hasValue()) { @@ -309,8 +293,7 @@ public Runnable getSyncToServerCommand(Object newValue) { // the same property from its observer). isServerUpdate = false; } - if (!(Objects.equals(newValue, currentValue) && hasValue()) - && !isServerUpdate) { + if (!(Objects.equals(newValue, currentValue) && hasValue()) && !isServerUpdate) { StateNode node = getMap().getNode(); StateTree tree = node.getTree(); if (tree.isActive(node)) { @@ -319,13 +302,11 @@ public Runnable getSyncToServerCommand(Object newValue) { return () -> tree.sendNodePropertySyncToServer(this); } else { /* - * Fire an fake event to reset the property value back in the - * DOM element: we don't know how exactly set this property but - * it has to be set to the property value because of listener - * added to the property during binding. + * Fire an fake event to reset the property value back in the DOM element: we don't know how exactly set + * this property but it has to be set to the property value because of listener added to the property + * during binding. */ - eventRouter.fireEvent(new MapPropertyChangeEvent(this, - currentValue, currentValue)); + eventRouter.fireEvent(new MapPropertyChangeEvent(this, currentValue, currentValue)); // Flush is needed because we are out of normal lifecycle which // call the flush() automatically. Reactive.flush(); diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapPropertyChangeEvent.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapPropertyChangeEvent.java index f60c74720fb..54c6cb75c62 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapPropertyChangeEvent.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/MapPropertyChangeEvent.java @@ -38,8 +38,7 @@ public class MapPropertyChangeEvent extends ReactiveValueChangeEvent { * @param newValue * the new value */ - public MapPropertyChangeEvent(MapProperty source, Object oldValue, - Object newValue) { + public MapPropertyChangeEvent(MapProperty source, Object oldValue, Object newValue) { super(source); this.oldValue = oldValue; this.newValue = newValue; diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeFeature.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeFeature.java index 223e13f94f6..4f6557ecc94 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeFeature.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeFeature.java @@ -23,8 +23,7 @@ import elemental.json.JsonValue; /** - * Holder of the actual data in a state node. The state node data is isolated - * into different features of related data. + * Holder of the actual data in a state node. The state node data is isolated into different features of related data. * * @author Vaadin Ltd * @since 1.0 @@ -66,17 +65,15 @@ public StateNode getNode() { } /** - * Gets a JSON object representing the contents of this feature. Only - * intended for debugging purposes. + * Gets a JSON object representing the contents of this feature. Only intended for debugging purposes. * * @return a JSON representation */ public abstract JsonValue getDebugJson(); /** - * Convert the feature values into a {@link JsonValue} using provided - * {@code converter} for the values stored in the feature (i.e. primitive - * types, StateNodes). + * Convert the feature values into a {@link JsonValue} using provided {@code converter} for the values stored in the + * feature (i.e. primitive types, StateNodes). * * @param converter * converter to convert values stored in the feature diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeList.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeList.java index e5629f95e73..ef67b042df7 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeList.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeList.java @@ -35,14 +35,11 @@ /** * A state node feature that structures data as a list. *

- * The list works as a reactive value with regards to its structure. A - * {@link Computation} will get a dependency on this list for any read operation - * that depends on the list structure, such as querying the length, iterating - * the list or finding the index of an item. Accessing an item by index does not - * create a dependency. The Computation is invalidated when items - * are added, removed, reordered or replaced. It is not invalidated when the - * contents of an item is updated since all items are expected to be either - * immutable or reactive values of their own. + * The list works as a reactive value with regards to its structure. A {@link Computation} will get a dependency on this + * list for any read operation that depends on the list structure, such as querying the length, iterating the list or + * finding the index of an item. Accessing an item by index does not create a dependency. The Computation + * is invalidated when items are added, removed, reordered or replaced. It is not invalidated when the contents of an + * item is updated since all items are expected to be either immutable or reactive values of their own. * * @author Vaadin Ltd * @since 1.0 @@ -56,14 +53,12 @@ public class NodeList extends NodeFeature implements ReactiveValue { private final ReactiveEventRouter eventRouter = new ReactiveEventRouter( this) { @Override - protected ListSpliceListener wrap( - ReactiveValueChangeListener reactiveValueChangeListener) { + protected ListSpliceListener wrap(ReactiveValueChangeListener reactiveValueChangeListener) { return reactiveValueChangeListener::onValueChange; } @Override - protected void dispatchEvent(ListSpliceListener listener, - ListSpliceEvent event) { + protected void dispatchEvent(ListSpliceListener listener, ListSpliceEvent event) { listener.onSplice(event); } }; @@ -114,9 +109,8 @@ public void set(int index, Object value) { } /** - * Shorthand for adding the given item at the given index. This method - * delegates to {@link #splice(int, int, JsArray)} which updates the list - * contents and fires the appropriate event. + * Shorthand for adding the given item at the given index. This method delegates to + * {@link #splice(int, int, JsArray)} which updates the list contents and fires the appropriate event. * * @param index * the index where the item should be added @@ -128,8 +122,7 @@ public void add(int index, Object item) { } /** - * Removes a number of items at the given index. This causes a - * {@link ListSpliceEvent} to be fired. + * Removes a number of items at the given index. This causes a {@link ListSpliceEvent} to be fired. * * @param index * the index at which do do the operation @@ -138,20 +131,17 @@ public void add(int index, Object item) { */ public void splice(int index, int remove) { JsArray removed = values.splice(index, remove); - eventRouter.fireEvent(new ListSpliceEvent(this, index, removed, - JsCollections.array(), false)); + eventRouter.fireEvent(new ListSpliceEvent(this, index, removed, JsCollections.array(), false)); } /** - * Removes all the nodes from the list. This causes a - * {@link ListSpliceEvent} to be fired, with + * Removes all the nodes from the list. This causes a {@link ListSpliceEvent} to be fired, with * {@link ListSpliceEvent#isClear()} as true. */ public void clear() { hasBeenCleared = true; JsArray removed = values.splice(0, values.length()); - eventRouter.fireEvent(new ListSpliceEvent(this, 0, removed, - JsCollections.array(), true)); + eventRouter.fireEvent(new ListSpliceEvent(this, 0, removed, JsCollections.array(), true)); } /** @@ -170,8 +160,7 @@ public final void splice(int index, int remove, JsArray add) { @SuppressWarnings("unchecked") JsArray addObject = (JsArray) add; JsArray removed = values.spliceArray(index, remove, addObject); - eventRouter.fireEvent( - new ListSpliceEvent(this, index, removed, add, false)); + eventRouter.fireEvent(new ListSpliceEvent(this, index, removed, add, false)); } @Override @@ -196,8 +185,7 @@ public JsonValue convert(Function converter) { Object value = values.get(i); // Crazy cast since otherwise SDM fails // for primitives values since primitives are not a JSO - json.set(json.length(), - WidgetUtil.crazyJsoCast(converter.apply(value))); + json.set(json.length(), WidgetUtil.crazyJsoCast(converter.apply(value))); } return json; @@ -216,8 +204,7 @@ public EventRemover addSpliceListener(ListSpliceListener listener) { } @Override - public EventRemover addReactiveValueChangeListener( - ReactiveValueChangeListener reactiveValueChangeListener) { + public EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) { return eventRouter.addReactiveListener(reactiveValueChangeListener); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeMap.java b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeMap.java index 80602f19c4a..bf1ba1408cb 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeMap.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/nodefeature/NodeMap.java @@ -36,12 +36,10 @@ /** * A state node feature that structures data as a map. *

- * The feature works as a reactive value with regards to the set of available - * properties. A {@link Computation} will get a dependency on this feature by - * iterating the properties. Accessing a property by name does not create a - * dependency. The Computation is invalidated when a property is - * added (properties are never removed). It is not invalidated when the value of - * a property changes since the property is a reactive values of its own. + * The feature works as a reactive value with regards to the set of available properties. A {@link Computation} will get + * a dependency on this feature by iterating the properties. Accessing a property by name does not create a dependency. + * The Computation is invalidated when a property is added (properties are never removed). It is not + * invalidated when the value of a property changes since the property is a reactive values of its own. * * @author Vaadin Ltd * @since 1.0 @@ -52,14 +50,12 @@ public class NodeMap extends NodeFeature implements ReactiveValue { private final ReactiveEventRouter eventRouter = new ReactiveEventRouter( this) { @Override - protected MapPropertyAddListener wrap( - ReactiveValueChangeListener reactiveValueChangeListener) { + protected MapPropertyAddListener wrap(ReactiveValueChangeListener reactiveValueChangeListener) { return reactiveValueChangeListener::onValueChange; } @Override - protected void dispatchEvent(MapPropertyAddListener listener, - MapPropertyAddEvent event) { + protected void dispatchEvent(MapPropertyAddListener listener, MapPropertyAddEvent event) { listener.onPropertyAdd(event); } }; @@ -79,8 +75,7 @@ public NodeMap(int id, StateNode node) { /** * Gets the property with a given name, creating it if necessary. *

- * A {@link MapPropertyAddEvent} is fired if a new property instance is - * created. + * A {@link MapPropertyAddEvent} is fired if a new property instance is created. * * @param name * the name of the property @@ -89,8 +84,8 @@ public NodeMap(int id, StateNode node) { public MapProperty getProperty(String name) { MapProperty property = properties.get(name); if (property == null) { - property = new MapProperty(name, this, "innerHTML".equals(name) - && getId() == NodeFeatures.ELEMENT_PROPERTIES); + property = new MapProperty(name, this, + "innerHTML".equals(name) && getId() == NodeFeatures.ELEMENT_PROPERTIES); properties.set(name, property); eventRouter.fireEvent(new MapPropertyAddEvent(this, property)); @@ -161,8 +156,7 @@ public JsonValue convert(Function converter) { if (property.hasValue()) { // Crazy cast since otherwise SDM fails for string values since // String is not a JSO - JsonValue jsonValue = WidgetUtil - .crazyJsoCast(converter.apply(property.getValue())); + JsonValue jsonValue = WidgetUtil.crazyJsoCast(converter.apply(property.getValue())); json.put(name, jsonValue); } }); @@ -171,21 +165,18 @@ public JsonValue convert(Function converter) { } @Override - public EventRemover addReactiveValueChangeListener( - ReactiveValueChangeListener reactiveValueChangeListener) { + public EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) { return eventRouter.addReactiveListener(reactiveValueChangeListener); } /** - * Adds a listener that is informed whenever a new property is added to this - * map. + * Adds a listener that is informed whenever a new property is added to this map. * * @param listener * the property add listener * @return an event remover that can be used for removing the added listener */ - public EventRemover addPropertyAddListener( - MapPropertyAddListener listener) { + public EventRemover addPropertyAddListener(MapPropertyAddListener listener) { return eventRouter.addListener(listener); } } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/reactive/Computation.java b/flow-client/src/main/java/com/vaadin/client/flow/reactive/Computation.java index 6f5dc9d23c1..90b2cc9145e 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/reactive/Computation.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/reactive/Computation.java @@ -22,11 +22,9 @@ import elemental.events.EventRemover; /** - * Automatically reruns {@link #doRecompute()} whenever any reactive value used - * by it changes. The recompute method is invoked by the next invocation of - * {@link Reactive#flush()}, unless it has been invoked manually before the - * global flush. A computation is also scheduled to for an initial - * "recomputation" when it is created. + * Automatically reruns {@link #doRecompute()} whenever any reactive value used by it changes. The recompute method is + * invoked by the next invocation of {@link Reactive#flush()}, unless it has been invoked manually before the global + * flush. A computation is also scheduled to for an initial "recomputation" when it is created. * * @author Vaadin Ltd * @since 1.0 @@ -50,21 +48,18 @@ public Computation() { } /** - * Adds a dependency to a reactive value. This computation is scheduled for - * recomputation when any dependency fires a change event. All previous - * dependencies are cleared before recomputing. + * Adds a dependency to a reactive value. This computation is scheduled for recomputation when any dependency fires + * a change event. All previous dependencies are cleared before recomputing. *

- * This method is automatically called when a reactive value is used for - * recomputing this computation. The developer is not expected to call this - * method himself. + * This method is automatically called when a reactive value is used for recomputing this computation. The developer + * is not expected to call this method himself. * * @param dependency * the reactive value to depend on */ public void addDependency(ReactiveValue dependency) { if (!stopped) { - EventRemover remover = dependency - .addReactiveValueChangeListener(this); + EventRemover remover = dependency.addReactiveValueChangeListener(this); dependencies.push(remover); } } @@ -94,8 +89,7 @@ private void invalidate() { InvalidateEvent invalidateEvent = new InvalidateEvent(this); - oldListeners.forEach( - listener -> listener.onInvalidate(invalidateEvent)); + oldListeners.forEach(listener -> listener.onInvalidate(invalidateEvent)); } } @@ -121,13 +115,11 @@ public void stop() { } /** - * Checks whether this computation is invalidated. An invalidated - * computation will eventually be recomputed (unless it has also been - * stopped). Recomputation will happen the next time {@link #recompute()} or + * Checks whether this computation is invalidated. An invalidated computation will eventually be recomputed (unless + * it has also been stopped). Recomputation will happen the next time {@link #recompute()} or * {@link Reactive#flush()} is invoked. * - * @return true if this computation is invalidated; otherwise - * false + * @return true if this computation is invalidated; otherwise false */ public boolean isInvalidated() { return invalidated; @@ -147,14 +139,13 @@ public void recompute() { } /** - * Does the actual recomputation. This method is run in a way that - * automatically registers dependencies to any reactive value accessed. + * Does the actual recomputation. This method is run in a way that automatically registers dependencies to any + * reactive value accessed. */ protected abstract void doRecompute(); /** - * Adds an invalidate listener that will be invoked the next time this - * computation is invalidated. + * Adds an invalidate listener that will be invoked the next time this computation is invalidated. * * @param listener * the listener to run on the next invalidation diff --git a/flow-client/src/main/java/com/vaadin/client/flow/reactive/Reactive.java b/flow-client/src/main/java/com/vaadin/client/flow/reactive/Reactive.java index 4528bce91c7..464b6f15828 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/reactive/Reactive.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/reactive/Reactive.java @@ -23,16 +23,13 @@ import elemental.events.EventRemover; /** - * Handles global features related to reactivity, such as keeping track of the - * current {@link Computation}, providing a lazy flush cycle and registering - * reactive event collectors. + * Handles global features related to reactivity, such as keeping track of the current {@link Computation}, providing a + * lazy flush cycle and registering reactive event collectors. *

- * With a reactive programming model, the dependencies needed for producing a - * result are automatically registered when the result is computed. When any - * dependency of a computation is changed, that computation is scheduled to be - * recomputed. To reduce the number of recomputations performed when many - * dependencies are updated, the recomputation is performed lazily the next time - * {@link #flush()} is invoked. + * With a reactive programming model, the dependencies needed for producing a result are automatically registered when + * the result is computed. When any dependency of a computation is changed, that computation is scheduled to be + * recomputed. To reduce the number of recomputations performed when many dependencies are updated, the recomputation is + * performed lazily the next time {@link #flush()} is invoked. * * @see Computation * @@ -57,9 +54,8 @@ private Reactive() { } /** - * Adds a listener that will be invoked the next time {@link #flush()} is - * invoked. A listener added during a flush will be invoked before that - * flush finishes. + * Adds a listener that will be invoked the next time {@link #flush()} is invoked. A listener added during a flush + * will be invoked before that flush finishes. * * @param flushListener * the flush listener to add @@ -72,10 +68,9 @@ public static void addFlushListener(FlushListener flushListener) { } /** - * Adds a listener that will be invoked during the next {@link #flush()}, - * after all regular flush listeners have been invoked. If a post flush - * listener adds new flush listeners, those flush listeners will be invoked - * before the next post flush listener is invoked. + * Adds a listener that will be invoked during the next {@link #flush()}, after all regular flush listeners have + * been invoked. If a post flush listener adds new flush listeners, those flush listeners will be invoked before the + * next post flush listener is invoked. * * @param postFlushListener * the listener to add @@ -88,10 +83,8 @@ public static void addPostFlushListener(FlushListener postFlushListener) { } /** - * Flushes all flush listeners and post flush listeners. A listener is - * discarded after it has been invoked once. This means that there will be - * no listeners registered for the next flush at the time this method - * returns. + * Flushes all flush listeners and post flush listeners. A listener is discarded after it has been invoked once. + * This means that there will be no listeners registered for the next flush at the time this method returns. * * @see #addFlushListener(FlushListener) * @see #addPostFlushListener(FlushListener) @@ -131,31 +124,26 @@ private static boolean hasFlushListeners() { } /** - * Gets the currently active computation. Any reactive value that is - * accessed when a computation is active should be added as a dependency to - * that computation so that the computation will be invalidated if the value - * changes. + * Gets the currently active computation. Any reactive value that is accessed when a computation is active should be + * added as a dependency to that computation so that the computation will be invalidated if the value changes. * - * @return the current computation, or null if there is no - * current computation. + * @return the current computation, or null if there is no current computation. */ public static Computation getCurrentComputation() { return currentComputation; } /** - * Runs a task with the given computation set as - * {@link #getCurrentComputation()}. If another computation is set as the - * current computation, it is temporarily replaced by the provided - * computation, but restored again after the provided task has been run. + * Runs a task with the given computation set as {@link #getCurrentComputation()}. If another computation is set as + * the current computation, it is temporarily replaced by the provided computation, but restored again after the + * provided task has been run. * * @param computation * the computation to set as current * @param command * the command to run while the computation is set as current */ - public static void runWithComputation(Computation computation, - Command command) { + public static void runWithComputation(Computation computation, Command command) { Computation oldComputation = currentComputation; currentComputation = computation; try { @@ -166,15 +154,14 @@ public static void runWithComputation(Computation computation, } /** - * Adds a reactive change listener that will be invoked whenever a reactive - * change event is fired from any reactive event router. + * Adds a reactive change listener that will be invoked whenever a reactive change event is fired from any reactive + * event router. * * @param reactiveValueChangeListener * the listener to add * @return an event remover that can be used to remove the listener */ - public static EventRemover addEventCollector( - ReactiveValueChangeListener reactiveValueChangeListener) { + public static EventRemover addEventCollector(ReactiveValueChangeListener reactiveValueChangeListener) { if (eventCollectors == null) { eventCollectors = JsCollections.set(); } @@ -193,21 +180,18 @@ public static EventRemover addEventCollector( */ public static void notifyEventCollectors(ReactiveValueChangeEvent event) { if (eventCollectors != null) { - JsSet copy = JsCollections - .set(eventCollectors); + JsSet copy = JsCollections.set(eventCollectors); copy.forEach(listener -> listener.onValueChange(event)); } } /** - * Evaluates the given command whenever there is a change in any - * {@link ReactiveValue} used in the command. + * Evaluates the given command whenever there is a change in any {@link ReactiveValue} used in the command. * * @param command * the command to run - * @return A {@link Computation} object which can be used to control the - * evaluation + * @return A {@link Computation} object which can be used to control the evaluation */ public static Computation runWhenDependenciesChange(Command command) { return new Computation() { @@ -221,8 +205,8 @@ protected void doRecompute() { /** * Resets Reactive to the initial state. *

- * Intended for test cases to call in setup to avoid having tests affect - * each other as Reactive state is static and shared. + * Intended for test cases to call in setup to avoid having tests affect each other as Reactive state is static and + * shared. *

* Should never be called from non-test code! * diff --git a/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveEventRouter.java b/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveEventRouter.java index 23fc64f1de6..5a1ab410c62 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveEventRouter.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveEventRouter.java @@ -21,9 +21,8 @@ import elemental.events.EventRemover; /** - * Event router providing integration with reactive features in {@link Reactive} - * and {@link Computation}. Listeners can be added both for a specific event - * type and for the generic value change. All events are fired to both types of + * Event router providing integration with reactive features in {@link Reactive} and {@link Computation}. Listeners can + * be added both for a specific event type and for the generic value change. All events are fired to both types of * listeners, as well as to event collectors registered using * {@link Reactive#addEventCollector(ReactiveValueChangeListener)}. * @@ -79,17 +78,14 @@ public EventRemover addListener(L listener) { * the change listener to add, not null * @return an event remover that can be used for removing the added listener */ - public EventRemover addReactiveListener( - ReactiveValueChangeListener reactiveValueChangeListener) { + public EventRemover addReactiveListener(ReactiveValueChangeListener reactiveValueChangeListener) { assert reactiveValueChangeListener != null; return addListener(wrap(reactiveValueChangeListener)); } /** - * Fires an event to all listeners added to this router using - * {@link #addListener(Object)} or - * {@link #addReactiveListener(ReactiveValueChangeListener)} as well as all - * global event collectors added using + * Fires an event to all listeners added to this router using {@link #addListener(Object)} or + * {@link #addReactiveListener(ReactiveValueChangeListener)} as well as all global event collectors added using * {@link Reactive#addEventCollector(ReactiveValueChangeListener)}. * * @param event @@ -106,9 +102,8 @@ public void fireEvent(E event) { } /** - * Registers access to the data for which this event router fires event. - * This registers the event source of this event router to be set as a - * dependency of the current computation if there is one. + * Registers access to the data for which this event router fires event. This registers the event source of this + * event router to be set as a dependency of the current computation if there is one. */ public void registerRead() { Computation computation = Reactive.getCurrentComputation(); @@ -127,15 +122,14 @@ public ReactiveValue getReactiveValue() { } /** - * Callback for wrapping a generic reactive change listener to an instance - * of the listener type natively supported by this event router. + * Callback for wrapping a generic reactive change listener to an instance of the listener type natively supported + * by this event router. * * @param reactiveValueChangeListener * the reactive change listener * @return an event listener wrapping the provided listener */ - protected abstract L wrap( - ReactiveValueChangeListener reactiveValueChangeListener); + protected abstract L wrap(ReactiveValueChangeListener reactiveValueChangeListener); /** * Callback for dispatching an event to a listener. diff --git a/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveValue.java b/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveValue.java index b7915a296c7..d8b2d451506 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveValue.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/reactive/ReactiveValue.java @@ -18,26 +18,22 @@ import elemental.events.EventRemover; /** - * A reactive value fires reactive value change events when its value changes - * and registers itself as dependent on the current computation when the value - * is accessed. + * A reactive value fires reactive value change events when its value changes and registers itself as dependent on the + * current computation when the value is accessed. *

- * A reactive value typically uses a {@link ReactiveEventRouter} for keeping - * track of listeners, firing events and registering the value as dependent to - * the current computation. + * A reactive value typically uses a {@link ReactiveEventRouter} for keeping track of listeners, firing events and + * registering the value as dependent to the current computation. * * @author Vaadin Ltd * @since 1.0 */ public interface ReactiveValue { /** - * Adds a listener that has a dependency to this value, and should be - * notified when this value changes. + * Adds a listener that has a dependency to this value, and should be notified when this value changes. * * @param reactiveValueChangeListener * the listener to add * @return an event remover that can be used for removing the added listener */ - EventRemover addReactiveValueChangeListener( - ReactiveValueChangeListener reactiveValueChangeListener); + EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/util/ClientJsonCodec.java b/flow-client/src/main/java/com/vaadin/client/flow/util/ClientJsonCodec.java index f21387738cd..68c1b19765a 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/util/ClientJsonCodec.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/util/ClientJsonCodec.java @@ -42,14 +42,11 @@ private ClientJsonCodec() { } /** - * Decodes a value as a {@link StateNode} encoded on the server using - * {@link JsonCodec#encodeWithTypeInfo(Object)} if it's possible. Otherwise - * returns {@code null}. + * Decodes a value as a {@link StateNode} encoded on the server using {@link JsonCodec#encodeWithTypeInfo(Object)} + * if it's possible. Otherwise returns {@code null}. *

- * It does the same as {@link #decodeWithTypeInfo(StateTree, JsonValue)} for - * the encoded json value if the encoded object is a {@link StateNode} - * except it returns the node itself instead of a DOM element associated - * with it. + * It does the same as {@link #decodeWithTypeInfo(StateTree, JsonValue)} for the encoded json value if the encoded + * object is a {@link StateNode} except it returns the node itself instead of a DOM element associated with it. * * @see #decodeWithTypeInfo(StateTree, JsonValue) * @param tree @@ -71,8 +68,7 @@ public static StateNode decodeStateNode(StateTree tree, JsonValue json) { case JsonCodec.RETURN_CHANNEL_TYPE: return null; default: - throw new IllegalArgumentException( - "Unsupported complex type in " + array.toJson()); + throw new IllegalArgumentException("Unsupported complex type in " + array.toJson()); } } else { return null; @@ -80,8 +76,7 @@ public static StateNode decodeStateNode(StateTree tree, JsonValue json) { } /** - * Decodes a value encoded on the server using - * {@link JsonCodec#encodeWithTypeInfo(Object)}. + * Decodes a value encoded on the server using {@link JsonCodec#encodeWithTypeInfo(Object)}. * * @param tree * the state tree to use for resolving nodes and elements @@ -102,20 +97,18 @@ public static Object decodeWithTypeInfo(StateTree tree, JsonValue json) { case JsonCodec.ARRAY_TYPE: return jsonArrayAsJsArray(array.getArray(1)); case JsonCodec.RETURN_CHANNEL_TYPE: - return createReturnChannelCallback((int) array.getNumber(1), - (int) array.getNumber(2), + return createReturnChannelCallback((int) array.getNumber(1), (int) array.getNumber(2), tree.getRegistry().getServerConnector()); default: - throw new IllegalArgumentException( - "Unsupported complex type in " + array.toJson()); + throw new IllegalArgumentException("Unsupported complex type in " + array.toJson()); } } else { return decodeWithoutTypeInfo(json); } } - private static native NativeFunction createReturnChannelCallback(int nodeId, - int channelId, ServerConnector serverConnector) + private static native NativeFunction createReturnChannelCallback(int nodeId, int channelId, + ServerConnector serverConnector) /*-{ return $entry(function() { var args = Array.prototype.slice.call(arguments); @@ -124,10 +117,9 @@ private static native NativeFunction createReturnChannelCallback(int nodeId, }-*/; /** - * Decodes a value encoded on the server using - * {@link JsonCodec#encodeWithoutTypeInfo(Object)}. This is a no-op in - * compiled JavaScript since the JSON representation can be used as-is, but - * some special handling is needed for tests running in the JVM. + * Decodes a value encoded on the server using {@link JsonCodec#encodeWithoutTypeInfo(Object)}. This is a no-op in + * compiled JavaScript since the JSON representation can be used as-is, but some special handling is needed for + * tests running in the JVM. * * @param json * the JSON value to convert @@ -149,16 +141,14 @@ public static Object decodeWithoutTypeInfo(JsonValue json) { case NULL: return null; default: - throw new IllegalArgumentException( - "Can't (yet) convert " + json.getType()); + throw new IllegalArgumentException("Can't (yet) convert " + json.getType()); } } } /** - * Helper for encoding any "primitive" value that is directly supported in - * JSON. Supported values types are {@link String}, {@link Number}, - * {@link Boolean}, {@link JsonValue}. null is also supported. + * Helper for encoding any "primitive" value that is directly supported in JSON. Supported values types are + * {@link String}, {@link Number}, {@link Boolean}, {@link JsonValue}. null is also supported. * * @param value * the value to encode @@ -180,14 +170,13 @@ public static JsonValue encodeWithoutTypeInfo(Object value) { } else if (value instanceof JsonValue) { return (JsonValue) value; } - throw new IllegalArgumentException( - "Can't encode" + value.getClass() + " to json"); + throw new IllegalArgumentException("Can't encode" + value.getClass() + " to json"); } } /** - * Converts a JSON array to a JS array. This is a no-op in compiled - * JavaScript, but needs special handling for tests running in the JVM. + * Converts a JSON array to a JS array. This is a no-op in compiled JavaScript, but needs special handling for tests + * running in the JVM. * * @param jsonArray * the JSON array to convert diff --git a/flow-client/src/main/java/com/vaadin/client/flow/util/JsObject.java b/flow-client/src/main/java/com/vaadin/client/flow/util/JsObject.java index 6804981609c..4931ef1924b 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/util/JsObject.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/util/JsObject.java @@ -27,8 +27,7 @@ @JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL) public class JsObject { /** - * A property descriptor that can be passed to - * {@link JsObject#defineProperty(Object, String, PropertyDescriptor)}. + * A property descriptor that can be passed to {@link JsObject#defineProperty(Object, String, PropertyDescriptor)}. */ @JsType(isNative = true) public interface PropertyDescriptor { @@ -40,13 +39,11 @@ public interface PropertyDescriptor { * Adds a property to a JavaScript object. * * @param object - * the object to which the property should be added, not - * null + * the object to which the property should be added, not null * @param name * the name of the property to add, not null * @param descriptor * a descriptor for the property, not null */ - public static native void defineProperty(Object object, String name, - PropertyDescriptor descriptor); + public static native void defineProperty(Object object, String name, PropertyDescriptor descriptor); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/util/NativeFunction.java b/flow-client/src/main/java/com/vaadin/client/flow/util/NativeFunction.java index fa239e25a1d..ab686bac3b0 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/util/NativeFunction.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/util/NativeFunction.java @@ -39,14 +39,12 @@ public class NativeFunction { */ public NativeFunction(String... paramsAndCode) { /* - * The GWT compiler will replace this JsInterop constructor with a JS - * invocation of new Function() + * The GWT compiler will replace this JsInterop constructor with a JS invocation of new Function() */ } /** - * Invokes this function with a given this and arguments - * provided as an array. + * Invokes this function with a given this and arguments provided as an array. * * @param thisArg * the value of this @@ -57,8 +55,7 @@ public NativeFunction(String... paramsAndCode) { public native Object apply(Object thisArg, JsArray arguments); /** - * Invokes this function with a given this and arguments - * provides as varargs. + * Invokes this function with a given this and arguments provides as varargs. * * @param thisArg * the value of this @@ -69,9 +66,8 @@ public NativeFunction(String... paramsAndCode) { public native Object call(Object thisArg, Object... arguments); /** - * Creates a new function with the given parameters and implementation. The - * return value of this method is intended to be used as a type annotated - * with {@link JsFunction @JsFunction}. + * Creates a new function with the given parameters and implementation. The return value of this method is intended + * to be used as a type annotated with {@link JsFunction @JsFunction}. * * @param paramsAndCode * parameter names followed by the code of the function diff --git a/flow-client/src/main/java/com/vaadin/client/gwt/com/google/web/bindery/event/shared/SimpleEventBus.java b/flow-client/src/main/java/com/vaadin/client/gwt/com/google/web/bindery/event/shared/SimpleEventBus.java index 2d9b50647cd..1ca290ec3fc 100644 --- a/flow-client/src/main/java/com/vaadin/client/gwt/com/google/web/bindery/event/shared/SimpleEventBus.java +++ b/flow-client/src/main/java/com/vaadin/client/gwt/com/google/web/bindery/event/shared/SimpleEventBus.java @@ -27,8 +27,7 @@ /** * Basic implementation of {@link EventBus}. * - * Copied from the GWT project to use JsArray and JsMap instead of ArrayList and - * HashMap + * Copied from the GWT project to use JsArray and JsMap instead of ArrayList and HashMap * * @since 1.0 */ @@ -48,8 +47,7 @@ private interface Command { /** * Map of event type to map of event source to list of their handlers. */ - private final JsMap, JsMap>> map = JsCollections - .map(); + private final JsMap, JsMap>> map = JsCollections.map(); /** * Create an instance of the event bus. @@ -64,11 +62,9 @@ public HandlerRegistration addHandler(Type type, H handler) { } @Override - public HandlerRegistration addHandlerToSource(final Event.Type type, - final Object source, final H handler) { + public HandlerRegistration addHandlerToSource(final Event.Type type, final Object source, final H handler) { if (source == null) { - throw new NullPointerException( - "Cannot add a handler with a null source"); + throw new NullPointerException("Cannot add a handler with a null source"); } return doAdd(type, source, handler); @@ -88,8 +84,7 @@ public void fireEventFromSource(Event event, Object source) { } /** - * Not documented in GWT, required by legacy features in GWT's old - * HandlerManager. + * Not documented in GWT, required by legacy features in GWT's old HandlerManager. * * @param type * the type @@ -111,8 +106,7 @@ protected void doRemove(Event.Type type, Object source, H handler) { } /** - * Not documented in GWT, required by legacy features in GWT's old - * HandlerManager. + * Not documented in GWT, required by legacy features in GWT's old HandlerManager. * * @param type * the type @@ -126,17 +120,15 @@ protected void doRemove(Event.Type type, Object source, H handler) { */ @Deprecated protected H getHandler(Event.Type type, int index) { - assert index < getHandlerCount(type) : "handlers for " + type.getClass() - + " have size: " + getHandlerCount(type) - + " so do not have a handler at index: " + index; + assert index < getHandlerCount(type) : "handlers for " + type.getClass() + " have size: " + + getHandlerCount(type) + " so do not have a handler at index: " + index; JsArray l = getHandlerList(type, null); return l.get(index); } /** - * Not documented in GWT, required by legacy features in GWT's old - * HandlerManager. + * Not documented in GWT, required by legacy features in GWT's old HandlerManager. * * @param eventKey * the event type @@ -150,8 +142,7 @@ protected int getHandlerCount(Event.Type eventKey) { } /** - * Not documented in GWT, required by legacy features in GWT's old - * HandlerManager. + * Not documented in GWT, required by legacy features in GWT's old HandlerManager. * * @param eventKey * the event type @@ -170,11 +161,9 @@ private void defer(Command command) { deferredDeltas.push(command); } - private HandlerRegistration doAdd(final Event.Type type, - final Object source, final H handler) { + private HandlerRegistration doAdd(final Event.Type type, final Object source, final H handler) { if (type == null) { - throw new NullPointerException( - "Cannot add a handler with a null type"); + throw new NullPointerException("Cannot add a handler with a null type"); } if (handler == null) { throw new NullPointerException("Cannot add a null handler"); @@ -206,8 +195,7 @@ private void doFire(Event event, Object source) { setSourceOfEvent(event, source); } - JsArray handlers = getDispatchList(event.getAssociatedType(), - source); + JsArray handlers = getDispatchList(event.getAssociatedType(), source); JsArray causes = null; for (int i = 0; i < handlers.length(); i++) { @@ -244,18 +232,15 @@ private void doRemoveNow(Event.Type type, Object source, H handler) { } } - private void enqueueAdd(final Event.Type type, final Object source, - final H handler) { + private void enqueueAdd(final Event.Type type, final Object source, final H handler) { defer(() -> doAddNow(type, source, handler)); } - private void enqueueRemove(final Event.Type type, - final Object source, final H handler) { + private void enqueueRemove(final Event.Type type, final Object source, final H handler) { defer(() -> doRemoveNow(type, source, handler)); } - private JsArray ensureHandlerList(Event.Type type, - Object source) { + private JsArray ensureHandlerList(Event.Type type, Object source) { JsMap> sourceMap = map.get(type); if (sourceMap == null) { sourceMap = JsCollections.map(); diff --git a/flow-client/src/main/java/com/vaadin/client/gwt/elemental/js/util/Xhr.java b/flow-client/src/main/java/com/vaadin/client/gwt/elemental/js/util/Xhr.java index 59e4c609141..5904d354561 100644 --- a/flow-client/src/main/java/com/vaadin/client/gwt/elemental/js/util/Xhr.java +++ b/flow-client/src/main/java/com/vaadin/client/gwt/elemental/js/util/Xhr.java @@ -41,8 +41,7 @@ public interface Callback { * @param xhr * the request object * @param exception - * the exception which cause the request to fail, or null if - * not available + * the exception which cause the request to fail, or null if not available */ void onFail(XMLHttpRequest xhr, Exception exception); @@ -77,8 +76,7 @@ public void onReadyStateChange(XMLHttpRequest xhr) { } /** - * Send a GET request to the url and dispatch updates to the - * callback. + * Send a GET request to the url and dispatch updates to the callback. * * @param url * the URL @@ -91,26 +89,22 @@ public static XMLHttpRequest get(String url, Callback callback) { } /** - * Send a GET request to the url and dispatch updates to the - * callback. + * Send a GET request to the url and dispatch updates to the callback. * * @param window - * the window object used to access the XMLHttpRequest - * constructor + * the window object used to access the XMLHttpRequest constructor * @param url * the URL * @param callback * the callback to be notified * @return a reference to the sent XmlHttpRequest */ - public static XMLHttpRequest get(Window window, String url, - Callback callback) { + public static XMLHttpRequest get(Window window, String url, Callback callback) { return request(create(window), "GET", url, callback); } /** - * Send a HEAD request to the url and dispatch updates to the - * callback. + * Send a HEAD request to the url and dispatch updates to the callback. * * @param url * the URL @@ -123,26 +117,22 @@ public static XMLHttpRequest head(String url, Callback callback) { } /** - * Send a HEAD request to the url and dispatch updates to the - * callback. + * Send a HEAD request to the url and dispatch updates to the callback. * * @param window - * the window object used to access the XMLHttpRequest - * constructor + * the window object used to access the XMLHttpRequest constructor * @param url * the URL * @param callback * the callback to be notified * @return a reference to the sent XmlHttpRequest */ - public static XMLHttpRequest head(Window window, String url, - Callback callback) { + public static XMLHttpRequest head(Window window, String url, Callback callback) { return request(create(window), "HEAD", url, callback); } /** - * Send a POST request to the url and dispatch updates to the - * callback. + * Send a POST request to the url and dispatch updates to the callback. * * @param url * the URL @@ -154,19 +144,15 @@ public static XMLHttpRequest head(Window window, String url, * the callback to notify * @return a reference to the sent XmlHttpRequest */ - public static XMLHttpRequest post(String url, String requestData, - String contentType, Callback callback) { - return request(create(), "POST", url, requestData, contentType, - callback); + public static XMLHttpRequest post(String url, String requestData, String contentType, Callback callback) { + return request(create(), "POST", url, requestData, contentType, callback); } /** - * Send a POST request to the url and dispatch updates to the - * callback. + * Send a POST request to the url and dispatch updates to the callback. * * @param window - * the window object used to access the XMLHttpRequest - * constructor + * the window object used to access the XMLHttpRequest constructor * @param url * the URL * @param requestData @@ -177,10 +163,9 @@ public static XMLHttpRequest post(String url, String requestData, * the callback to notify * @return a reference to the sent XmlHttpRequest */ - public static XMLHttpRequest post(Window window, String url, - String requestData, String contentType, Callback callback) { - return request(create(window), "POST", url, requestData, contentType, - callback); + public static XMLHttpRequest post(Window window, String url, String requestData, String contentType, + Callback callback) { + return request(create(window), "POST", url, requestData, contentType, callback); } private static XMLHttpRequest create() { @@ -188,18 +173,16 @@ private static XMLHttpRequest create() { } /** - * Replacement for {@link XMLHttpRequest#create()} that allows better - * control of which window object is used to access the XMLHttpRequest - * constructor. + * Replacement for {@link XMLHttpRequest#create()} that allows better control of which window object is used to + * access the XMLHttpRequest constructor. */ private static native XMLHttpRequest create(Window window) /*-{ return new window.XMLHttpRequest(); }-*/; - private static XMLHttpRequest request(XMLHttpRequest xhr, String method, - String url, String requestData, String contentType, - Callback callback) { + private static XMLHttpRequest request(XMLHttpRequest xhr, String method, String url, String requestData, + String contentType, Callback callback) { try { xhr.setOnReadyStateChange(new Handler(callback)); xhr.open(method, url); @@ -215,8 +198,7 @@ private static XMLHttpRequest request(XMLHttpRequest xhr, String method, return xhr; } - private static XMLHttpRequest request(XMLHttpRequest xhr, String method, - String url, final Callback callback) { + private static XMLHttpRequest request(XMLHttpRequest xhr, String method, String url, final Callback callback) { try { xhr.setOnReadyStateChange(new Handler(callback)); xhr.open(method, url); diff --git a/flow-client/src/main/java/com/vaadin/flow/linker/ClientEngineLinker.java b/flow-client/src/main/java/com/vaadin/flow/linker/ClientEngineLinker.java index 638251be47d..fb13384a462 100644 --- a/flow-client/src/main/java/com/vaadin/flow/linker/ClientEngineLinker.java +++ b/flow-client/src/main/java/com/vaadin/flow/linker/ClientEngineLinker.java @@ -39,11 +39,9 @@ import com.google.gwt.util.tools.Utility; /** - * Customized version of {@link SingleScriptLinker} which uses a modified - * version of the single script template ({@value #SINGLE_SCRIPT_TEMPLATE_JS}). - * This is because the template from {@link SingleScriptLinker} uses a - * computeScriptBase function which does a document.write and thus - * cannot be called deferredly. + * Customized version of {@link SingleScriptLinker} which uses a modified version of the single script template + * ({@value #SINGLE_SCRIPT_TEMPLATE_JS}). This is because the template from {@link SingleScriptLinker} uses a + * computeScriptBase function which does a document.write and thus cannot be called deferredly. * * @see SingleScriptLinker * @since 1.0 @@ -57,8 +55,8 @@ public class ClientEngineLinker extends SingleScriptLinker { */ private static final String SINGLE_SCRIPT_TEMPLATE_JS = "com/vaadin/flow/linker/ClientEngineSingleScriptTemplate.js"; /** - * The computeScriptBase implementation which doesn't use document.write. It - * is taken from {@link CrossSiteIframeLinker}. + * The computeScriptBase implementation which doesn't use document.write. It is taken from + * {@link CrossSiteIframeLinker}. */ private static final String COMPUTE_SCRIPT_BASE_DOT_JS = "com/google/gwt/core/ext/linker/impl/computeScriptBase.js"; @@ -117,47 +115,40 @@ public String toString() { /* * (non-Javadoc) * - * @see com.google.gwt.core.linker.SingleScriptLinker#doEmitCompilation(com. - * google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, - * com.google.gwt.core.ext.linker.CompilationResult, + * @see com.google.gwt.core.linker.SingleScriptLinker#doEmitCompilation(com. google.gwt.core.ext.TreeLogger, + * com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.CompilationResult, * com.google.gwt.core.ext.linker.ArtifactSet) * * Overridden to avoid exception during compilation from SingleScriptLinker. */ @Override - protected Collection> doEmitCompilation(TreeLogger logger, - LinkerContext context, CompilationResult result, - ArtifactSet artifacts) throws UnableToCompleteException { + protected Collection> doEmitCompilation(TreeLogger logger, LinkerContext context, + CompilationResult result, ArtifactSet artifacts) throws UnableToCompleteException { String[] js = result.getJavaScript(); if (js.length != 1) { logger.branch(TreeLogger.ERROR, - "The module must not have multiple fragments when using the " - + getDescription() + " Linker.", + "The module must not have multiple fragments when using the " + getDescription() + " Linker.", null); throw new UnableToCompleteException(); } ArrayList> toReturn = new ArrayList<>(); toReturn.add(new Script(result.getStrongName(), js[0])); - toReturn.addAll( - emitSelectionInformation(result.getStrongName(), result)); + toReturn.addAll(emitSelectionInformation(result.getStrongName(), result)); return toReturn; } /* * (non-Javadoc) * - * @see - * com.google.gwt.core.linker.SingleScriptLinker#emitSelectionScript(com. - * google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, - * com.google.gwt.core.ext.linker.ArtifactSet) + * @see com.google.gwt.core.linker.SingleScriptLinker#emitSelectionScript(com. google.gwt.core.ext.TreeLogger, + * com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet) * * Overridden because of customized client engine file name. */ @Override - protected EmittedArtifact emitSelectionScript(TreeLogger logger, - LinkerContext context, ArtifactSet artifacts) + protected EmittedArtifact emitSelectionScript(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException { // Find the single Script result @@ -182,8 +173,7 @@ protected EmittedArtifact emitSelectionScript(TreeLogger logger, out.newlineOpt(); out.print("var $moduleName, $moduleBase;"); out.newlineOpt(); - out.print( - "var $stats = $wnd.__gwtStatsEvent ? function(a) {$wnd.__gwtStatsEvent(a)} : null;"); + out.print("var $stats = $wnd.__gwtStatsEvent ? function(a) {$wnd.__gwtStatsEvent(a)} : null;"); out.newlineOpt(); out.print("var $strongName = '" + result.getStrongName() + "';"); @@ -193,56 +183,46 @@ protected EmittedArtifact emitSelectionScript(TreeLogger logger, // Generate the call to tell the bootstrap code that we're ready to go. out.newlineOpt(); - out.print("if (" + context.getModuleFunctionName() + ") " - + context.getModuleFunctionName() + out.print("if (" + context.getModuleFunctionName() + ") " + context.getModuleFunctionName() + ".onScriptLoad(gwtOnLoad);"); out.newlineOpt(); out.print("})();"); out.newlineOpt(); - return emitString(logger, out.toString(), - getJsFilename(context, result)); + return emitString(logger, out.toString(), getJsFilename(context, result)); } /* * (non-Javadoc) * * @see com.google.gwt.core.ext.linker.impl.SelectionScriptLinker# - * fillSelectionScriptTemplate(java.lang.StringBuffer, - * com.google.gwt.core.ext.TreeLogger, - * com.google.gwt.core.ext.LinkerContext, - * com.google.gwt.core.ext.linker.ArtifactSet, + * fillSelectionScriptTemplate(java.lang.StringBuffer, com.google.gwt.core.ext.TreeLogger, + * com.google.gwt.core.ext.LinkerContext, com.google.gwt.core.ext.linker.ArtifactSet, * com.google.gwt.core.ext.linker.CompilationResult) * - * Overridden because need to use same compute base script as in - * CrossSiteIframeLinker, ClientEngineLinker.COMPUTE_SCRIPT_BASE_DOT_JS. It - * doesn't use document.write. + * Overridden because need to use same compute base script as in CrossSiteIframeLinker, + * ClientEngineLinker.COMPUTE_SCRIPT_BASE_DOT_JS. It doesn't use document.write. */ @Override - protected String fillSelectionScriptTemplate(StringBuffer selectionScript, - TreeLogger logger, LinkerContext context, ArtifactSet artifacts, - CompilationResult result) throws UnableToCompleteException { + protected String fillSelectionScriptTemplate(StringBuffer selectionScript, TreeLogger logger, LinkerContext context, + ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException { String computeScriptBase; String processMetas; try { - computeScriptBase = Utility - .getFileFromClassPath(COMPUTE_SCRIPT_BASE_DOT_JS); + computeScriptBase = Utility.getFileFromClassPath(COMPUTE_SCRIPT_BASE_DOT_JS); processMetas = Utility.getFileFromClassPath(PROCESS_METAS_JS); } catch (IOException e) { - logger.log(TreeLogger.ERROR, - "Unable to read selection script template", e); + logger.log(TreeLogger.ERROR, "Unable to read selection script template", e); throw new UnableToCompleteException(); } - replaceAll(selectionScript, "__COMPUTE_SCRIPT_BASE__", - computeScriptBase); + replaceAll(selectionScript, "__COMPUTE_SCRIPT_BASE__", computeScriptBase); replaceAll(selectionScript, "__PROCESS_METAS__", processMetas); ResourceInjectionUtil.injectResources(selectionScript, artifacts); permutationsUtil.addPermutationsJs(selectionScript, logger, context); - replaceAll(selectionScript, "__MODULE_FUNC__", - context.getModuleFunctionName()); + replaceAll(selectionScript, "__MODULE_FUNC__", context.getModuleFunctionName()); replaceAll(selectionScript, "__MODULE_NAME__", context.getModuleName()); replaceAll(selectionScript, "__HOSTED_FILENAME__", getHostedFilename()); @@ -250,19 +230,14 @@ protected String fillSelectionScriptTemplate(StringBuffer selectionScript, } private String getJsFilename(LinkerContext context, Script result) { - return context.getModuleName() + "-" + result.getStrongName() - + ".cache.js"; + return context.getModuleName() + "-" + result.getStrongName() + ".cache.js"; } - private Script getScript(TreeLogger logger, ArtifactSet artifacts) - throws UnableToCompleteException { + private Script getScript(TreeLogger logger, ArtifactSet artifacts) throws UnableToCompleteException { Set as end of script no matter - * if it is inside a string + * 1 - The browser interprets as end of script no matter if it is inside a string * - * 2 - Scripts can be injected with