Browse Source

Add LoadStyle.NONE for completely omitting a connector

tags/8.1.0.alpha6
Leif Åstrand 7 years ago
parent
commit
7d4595c25c

+ 6
- 0
client-compiler/src/main/java/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java View File

@@ -1158,6 +1158,12 @@ public class ConnectorBundleLoaderFactory extends Generator {
bundles.add(bundle);
}

Collection<JClassType> none = connectorsByLoadStyle.get(LoadStyle.NONE);
for (JClassType type : none) {
logger.log(Type.TRACE,
"Ignoring " + type.getName() + " with LoadStyle.NONE");
}

return bundles;
}


+ 7
- 1
shared/src/main/java/com/vaadin/shared/ui/Connect.java View File

@@ -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
}
}

+ 38
- 0
uitest/src/main/java/com/vaadin/tests/widgetset/client/NoneLoadStyleConnector.java View File

@@ -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();
}
}

+ 38
- 0
uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyle.java View File

@@ -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);
}
}

+ 22
- 0
uitest/src/main/java/com/vaadin/tests/widgetset/server/NoneLoadStyleComponent.java View File

@@ -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 {

}

+ 33
- 0
uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java View File

@@ -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"));
}
}

Loading…
Cancel
Save