From 7d4595c25cc510d36eef2c327a57d45c44b192dd Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 13 Apr 2017 13:30:28 +0300 Subject: Add LoadStyle.NONE for completely omitting a connector --- .../ConnectorBundleLoaderFactory.java | 6 ++++ .../main/java/com/vaadin/shared/ui/Connect.java | 8 ++++- .../widgetset/client/NoneLoadStyleConnector.java | 38 ++++++++++++++++++++++ .../tests/widgetset/server/NoneLoadStyle.java | 38 ++++++++++++++++++++++ .../widgetset/server/NoneLoadStyleComponent.java | 22 +++++++++++++ .../tests/widgetset/server/NoneLoadStyleTest.java | 33 +++++++++++++++++++ 6 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/client/NoneLoadStyleConnector.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyle.java create mode 100644 uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyleComponent.java create mode 100644 uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java diff --git a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java index 0432c716ff..8ac6e8e4e7 100644 --- a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -1158,6 +1158,12 @@ public class ConnectorBundleLoaderFactory extends Generator { bundles.add(bundle); } + Collection none = connectorsByLoadStyle.get(LoadStyle.NONE); + for (JClassType type : none) { + logger.log(Type.TRACE, + "Ignoring " + type.getName() + " with LoadStyle.NONE"); + } + return bundles; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/Connect.java b/shared/src/main/java/com/vaadin/shared/ui/Connect.java index fcb5981030..2a1625ad72 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/Connect.java +++ b/shared/src/main/java/com/vaadin/shared/ui/Connect.java @@ -98,6 +98,12 @@ public @interface Connect { /** * Loaded to the client only if needed. */ - LAZY + LAZY, + /** + * Completely left out of the widgetset. + * + * @since 8.1 + */ + NONE } } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/NoneLoadStyleConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/NoneLoadStyleConnector.java new file mode 100644 index 0000000000..b15ad5b661 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/NoneLoadStyleConnector.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client; + +import com.google.gwt.user.client.ui.Label; +import com.vaadin.client.ui.AbstractComponentConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.Connect.LoadStyle; +import com.vaadin.tests.widgetset.server.NoneLoadStyleComponent; + +@Connect(value = NoneLoadStyleComponent.class, loadStyle = LoadStyle.NONE) +public class NoneLoadStyleConnector extends AbstractComponentConnector { + + @Override + protected void init() { + super.init(); + + getWidget().setText(NoneLoadStyleConnector.class.getSimpleName()); + } + + @Override + public Label getWidget() { + return (Label) super.getWidget(); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyle.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyle.java new file mode 100644 index 0000000000..886956344c --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyle.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; + +@Widgetset(TestingWidgetSet.NAME) +public class NoneLoadStyle extends AbstractTestUI { + + @Override + protected String getTestDescription() { + return NoneLoadStyleComponent.class.getName() + + " should resolve to UnknownComponentConnector"; + } + + @Override + protected void setup(VaadinRequest request) { + NoneLoadStyleComponent component = new NoneLoadStyleComponent(); + component.setId("component"); + addComponent(component); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyleComponent.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyleComponent.java new file mode 100644 index 0000000000..4599848f24 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyleComponent.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.ui.AbstractComponent; + +public class NoneLoadStyleComponent extends AbstractComponent { + +} diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java new file mode 100644 index 0000000000..ce1829796a --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class NoneLoadStyleTest extends SingleBrowserTest { + @Test + public void connectorNotLoaded() { + openTestURL(); + + String componentText = findElement(By.id("component")).getText(); + + Assert.assertTrue(componentText.contains("does not contain")); + } +} -- cgit v1.2.3