diff options
5 files changed, 189 insertions, 5 deletions
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java index 2fc9645940..0235fb277d 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java @@ -32,6 +32,7 @@ import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JEnumConstant; import com.google.gwt.core.ext.typeinfo.JEnumType; import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JPackage; import com.google.gwt.core.ext.typeinfo.JPrimitiveType; import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.TypeOracleException; @@ -59,8 +60,6 @@ import com.vaadin.terminal.gwt.client.communication.SerializerMap; public class SerializerGenerator extends Generator { private static final String SUBTYPE_SEPARATOR = "___"; - private static String serializerPackageName = SerializerMap.class - .getPackage().getName(); @Override public String generate(TreeLogger logger, GeneratorContext context, @@ -75,8 +74,8 @@ public class SerializerGenerator extends Generator { String serializerClassName = getSerializerSimpleClassName(type); try { // Generate class source code - generateClass(logger, context, type, serializerPackageName, - serializerClassName); + generateClass(logger, context, type, + getSerializerPackageName(type), serializerClassName); } catch (Exception e) { logger.log(TreeLogger.ERROR, "SerializerGenerator failed for " + type.getQualifiedSourceName(), e); @@ -465,6 +464,18 @@ public class SerializerGenerator extends Generator { } public static String getFullyQualifiedSerializerClassName(JClassType type) { - return serializerPackageName + "." + getSerializerSimpleClassName(type); + return getSerializerPackageName(type) + "." + + getSerializerSimpleClassName(type); + } + + private static String getSerializerPackageName(JClassType type) { + JPackage typePackage = type.getPackage(); + if (typePackage == null) { + return SerializerMap.class.getPackage().getName(); + } else { + // What about e.g. java.* packages, can we create classes there or + // should we use e.g. com.vaadin.java.* + return typePackage.getName(); + } } } diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java new file mode 100644 index 0000000000..6a873a6be3 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 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.serialization; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.widgetset.server.DummyLabel; +import com.vaadin.ui.Label; + +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class SerializerNamespaceTest extends AbstractTestRoot { + + @Override + protected void setup(WrappedRequest request) { + addComponent(new Label("The real label")); + addComponent(new DummyLabel("The dummy label")); + } + + @Override + protected String getTestDescription() { + return "Using connectors with different state classes having the same simple name should not cause any clietn-side exceptions"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8683); + } + +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java new file mode 100644 index 0000000000..bf3a472b33 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java @@ -0,0 +1,50 @@ +/* + * Copyright 2011 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.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; +import com.vaadin.terminal.gwt.client.ui.label.VLabel; +import com.vaadin.tests.widgetset.server.DummyLabel; + +/** + * Dummy connector just to cause {@link LabelState} to be used to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +@Connect(DummyLabel.class) +public class DummyLabelConnector extends AbstractComponentConnector { + @Override + public LabelState getState() { + return (LabelState) super.getState(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + getWidget().setText(getState().getText()); + } + + @Override + public VLabel getWidget() { + return (VLabel) super.getWidget(); + } +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java b/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java new file mode 100644 index 0000000000..91a269e33f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java @@ -0,0 +1,41 @@ +/* + * Copyright 2011 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.vaadin.shared.ComponentState; + +/** + * State class with the same simple name as + * {@link com.vaadin.shared.ui.label.LabelState} to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class LabelState extends ComponentState { + + private String text; + + public void setText(String text) { + this.text = text; + } + + public String getText() { + return text; + } + +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java b/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java new file mode 100644 index 0000000000..bda36d64a8 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java @@ -0,0 +1,38 @@ +/* + * Copyright 2011 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.tests.widgetset.client.LabelState; +import com.vaadin.ui.AbstractComponent; + +/** + * Dummy component to cause {@link LabelState} to be used to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class DummyLabel extends AbstractComponent { + public DummyLabel(String text) { + getState().setText(text); + } + + @Override + public LabelState getState() { + return (LabelState) super.getState(); + } +} |