@Deprecated
public void addComponent(Component c) {
// Use the thread local as the instance field might not yet be inited
- if (Application.getCurrentApplication() instanceof Application.LegacyApplication) {
+ if (isLegacyApplication()) {
getContent().addComponent(c);
} else {
throw new UnsupportedOperationException(
}
}
+ private boolean isLegacyApplication() {
+ return Application.getCurrentApplication() instanceof Application.LegacyApplication
+ || getApplication() instanceof Application.LegacyApplication;
+ }
+
/**
* <b>Removing a component from a root is generally not supported.</b> To
* maintain backwards compatibility, removing components is still supported
@Deprecated
public void removeComponent(Component c) {
// Use the thread local as the instance field might not yet be inited
- if (Application.getCurrentApplication() instanceof Application.LegacyApplication) {
+ if (isLegacyApplication()) {
getContent().removeComponent(c);
} else {
throw new UnsupportedOperationException(
@Deprecated
public void removeAllComponents() {
// Use the thread local as the instance field might not yet be inited
- if (Application.getCurrentApplication() instanceof Application.LegacyApplication) {
+ if (isLegacyApplication()) {
getContent().removeAllComponents();
} else {
throw new UnsupportedOperationException(
import com.vaadin.tests.data.bean.Country;\r
import com.vaadin.tests.data.bean.Person;\r
import com.vaadin.tests.data.bean.Sex;\r
+import com.vaadin.ui.Root;\r
import com.vaadin.ui.TextField;\r
-import com.vaadin.ui.Window;\r
\r
public class DefaultConverterFactory extends TestCase {\r
\r
}\r
\r
public void testDefaultNumberConversion() {\r
- Application app = new Application() {\r
+ Application.LegacyApplication app = new Application.LegacyApplication() {\r
\r
@Override\r
public void init() {\r
}\r
\r
};\r
- app.setMainWindow(new Window());\r
+ app.setMainWindow(new Root());\r
\r
TextField tf = new TextField();\r
app.getMainWindow().addComponent(tf);\r
public void buttonClick(ClickEvent event) {\r
field.commit();\r
Address address = field.getValue();\r
- field.getWindow().showNotification(\r
+ field.getRoot().showNotification(\r
"Address saved: " + address.getStreetAddress() + ", "\r
+ address.getPostalCode() + ", "\r
+ address.getCity());\r