summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebContent/VAADIN/themes/base/base.scss10
-rw-r--r--WebContent/VAADIN/themes/base/common/common.scss9
-rw-r--r--WebContent/VAADIN/themes/chameleon/chameleon.scss8
-rw-r--r--WebContent/VAADIN/themes/chameleon/common/common.scss3
-rw-r--r--WebContent/VAADIN/themes/reindeer/common/common.scss1
-rw-r--r--WebContent/VAADIN/themes/reindeer/reindeer.scss8
-rw-r--r--WebContent/VAADIN/themes/runo/common/common.scss3
-rw-r--r--WebContent/VAADIN/themes/runo/runo.scss7
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java25
-rw-r--r--client/src/com/vaadin/client/ui/VOverlay.java55
-rw-r--r--client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierachy.java55
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierarchy.html31
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java68
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java25
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/UseStateFromHierachyComponent.java37
16 files changed, 316 insertions, 56 deletions
diff --git a/WebContent/VAADIN/themes/base/base.scss b/WebContent/VAADIN/themes/base/base.scss
index 42047e9af5..a16b063ba8 100644
--- a/WebContent/VAADIN/themes/base/base.scss
+++ b/WebContent/VAADIN/themes/base/base.scss
@@ -47,16 +47,6 @@
overflow: hidden;
}
-/* Temporarily moved here to make drag'n'drop work before #10384 is fixed */
-.v-drag-element {
- z-index: 60000;
- /* override any other position: properties */
- position: absolute !important;
- opacity: 0.5;
- filter: alpha(opacity=50);
- cursor: default;
-}
-
@mixin base {
// @include base-app;
diff --git a/WebContent/VAADIN/themes/base/common/common.scss b/WebContent/VAADIN/themes/base/common/common.scss
index 9162e64a89..ac9154d2dc 100644
--- a/WebContent/VAADIN/themes/base/common/common.scss
+++ b/WebContent/VAADIN/themes/base/common/common.scss
@@ -204,6 +204,15 @@ body &.v-app-loading {
padding: 2px;
}
+.v-drag-element {
+ z-index: 60000;
+ /* override any other position: properties */
+ position: absolute !important;
+ opacity: 0.5;
+ filter: alpha(opacity=50);
+ cursor: default;
+}
+
.v-clip {
overflow: hidden;
}
diff --git a/WebContent/VAADIN/themes/chameleon/chameleon.scss b/WebContent/VAADIN/themes/chameleon/chameleon.scss
index 855c9d19e1..8a24a73cbf 100644
--- a/WebContent/VAADIN/themes/chameleon/chameleon.scss
+++ b/WebContent/VAADIN/themes/chameleon/chameleon.scss
@@ -3,14 +3,6 @@
@import "components/components.scss";
@import "compound/compound.scss";
-/* Temporarily moved here to make drag'n'drop work before #10384 is fixed */
-.v-drag-element {
- font-family: $chameleon-font-family;
- font-size: $chameleon-font-size;
- line-height: $chameleon-line-height;
- color: #222;
-}
-
@mixin chameleon {
// TODO move this?
@include base;
diff --git a/WebContent/VAADIN/themes/chameleon/common/common.scss b/WebContent/VAADIN/themes/chameleon/common/common.scss
index ab4651033e..050d100673 100644
--- a/WebContent/VAADIN/themes/chameleon/common/common.scss
+++ b/WebContent/VAADIN/themes/chameleon/common/common.scss
@@ -70,7 +70,8 @@ $chameleon-line-height: 1.4;
.v-Notification,
.v-menubar-submenu,
.v-table-header-drag,
- .v-menubar-submenu {
+ .v-menubar-submenu,
+ .v-drag-element {
font-family: $chameleon-font-family;
font-size: $chameleon-font-size;
line-height: $chameleon-line-height;
diff --git a/WebContent/VAADIN/themes/reindeer/common/common.scss b/WebContent/VAADIN/themes/reindeer/common/common.scss
index 7de3365717..5e85cb09bc 100644
--- a/WebContent/VAADIN/themes/reindeer/common/common.scss
+++ b/WebContent/VAADIN/themes/reindeer/common/common.scss
@@ -25,6 +25,7 @@
.v-contextmenu,
.v-Notification,
.v-menubar-submenu,
+.v-drag-element,
.v-table-header-drag {
font-family: Arial, Helvetica, Tahoma, Verdana, sans-serif;
font-size: 12px;
diff --git a/WebContent/VAADIN/themes/reindeer/reindeer.scss b/WebContent/VAADIN/themes/reindeer/reindeer.scss
index 880378e34a..ce6b54610e 100644
--- a/WebContent/VAADIN/themes/reindeer/reindeer.scss
+++ b/WebContent/VAADIN/themes/reindeer/reindeer.scss
@@ -32,14 +32,6 @@
background: #f5f5f5;
}
-/* Temporarily moved here to make drag'n'drop work before #10384 is fixed */
-.v-drag-element {
- font-family: Arial, Helvetica, Tahoma, Verdana, sans-serif;
- font-size: 12px;
- line-height: normal;
- color: #222;
-}
-
@mixin reindeer {
// should this be here?
@include base;
diff --git a/WebContent/VAADIN/themes/runo/common/common.scss b/WebContent/VAADIN/themes/runo/common/common.scss
index 8a2cdb95bc..9d4b4a4858 100644
--- a/WebContent/VAADIN/themes/runo/common/common.scss
+++ b/WebContent/VAADIN/themes/runo/common/common.scss
@@ -28,7 +28,8 @@
.v-datefield-popup,
.v-contextmenu,
.v-Notification,
-.v-menubar-submenu {
+.v-menubar-submenu,
+.v-drag-element {
font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
color: #464f52;
font-size: 13px;
diff --git a/WebContent/VAADIN/themes/runo/runo.scss b/WebContent/VAADIN/themes/runo/runo.scss
index a5150b2d16..de4d2b3bbd 100644
--- a/WebContent/VAADIN/themes/runo/runo.scss
+++ b/WebContent/VAADIN/themes/runo/runo.scss
@@ -31,13 +31,6 @@
background: #e9eced;
}
-/* Temporarily moved here to make drag'n'drop work before #10384 is fixed */
-.v-drag-element {
- font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
- color: #464f52;
- font-size: 13px;
-}
-
@mixin runo {
// TODO move?
@include base;
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 354d809622..5f90fe4c19 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -2035,6 +2035,31 @@ public class ApplicationConnection {
private void recursivelyDetach(ServerConnector connector,
List<ConnectorHierarchyChangeEvent> events) {
+
+ /*
+ * Reset state in an attempt to keep it consistent with the
+ * hierarchy. No children and no parent is the initial situation
+ * for the hierarchy, so changing the state to its initial value
+ * is the closest we can get without data from the server.
+ * #10151
+ */
+ try {
+ Type stateType = AbstractConnector.getStateType(connector);
+
+ // Empty state instance to get default property values from
+ Object defaultState = stateType.createInstance();
+
+ SharedState state = connector.getState();
+
+ for (Property property : stateType.getProperties()) {
+ property.setValue(state,
+ property.getValue(defaultState));
+ }
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can't reset state for "
+ + Util.getConnectorString(connector), e);
+ }
+
/*
* Recursively detach children to make sure they get
* setParent(null) and hierarchy change events as needed.
diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java
index dc6c7e4dff..ec09fbab69 100644
--- a/client/src/com/vaadin/client/ui/VOverlay.java
+++ b/client/src/com/vaadin/client/ui/VOverlay.java
@@ -34,6 +34,7 @@ import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.Util;
+import com.vaadin.client.VConsole;
/**
* In Vaadin UI this Overlay should always be used for all elements that
@@ -637,32 +638,48 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
}
/**
- * Gets the 'overlay container' element pertaining to the given
- * {@link ApplicationConnection}. Each overlay should be created in a
- * overlay container element, so that the correct theme and styles can be
- * applied.
+ * Gets the 'overlay container' element. Tries to find the current
+ * {@link ApplicationConnection} using {@link #getApplicationConnection()}.
*
- * @param ac
- * @return
+ * @return the overlay container element for the current
+ * {@link ApplicationConnection} or another element if the current
+ * {@link ApplicationConnection} cannot be determined.
*/
public Element getOverlayContainer() {
ApplicationConnection ac = getApplicationConnection();
if (ac == null) {
- // could not figure out which one we belong to, styling might fail
+ // could not figure out which one we belong to, styling will
+ // probably fail
+ VConsole.error("Could not determin ApplicationConnection for Overlay. Overlay will be attached directly to the root panel");
return RootPanel.get().getElement();
} else {
- String id = ac.getConfiguration().getRootPanelId();
- id = id += "-overlays";
- Element container = DOM.getElementById(id);
- if (container == null) {
- container = DOM.createDiv();
- container.setId(id);
- String styles = ac.getUIConnector().getWidget().getParent()
- .getStyleName();
- container.setClassName(styles);
- RootPanel.get().getElement().appendChild(container);
- }
- return container;
+ return getOverlayContainer(ac);
}
}
+
+ /**
+ * Gets the 'overlay container' element pertaining to the given
+ * {@link ApplicationConnection}. Each overlay should be created in a
+ * overlay container element, so that the correct theme and styles can be
+ * applied.
+ *
+ * @param ac
+ * A reference to {@link ApplicationConnection}
+ * @return The overlay container
+ */
+ public static Element getOverlayContainer(ApplicationConnection ac) {
+ String id = ac.getConfiguration().getRootPanelId();
+ id = id += "-overlays";
+ Element container = DOM.getElementById(id);
+ if (container == null) {
+ container = DOM.createDiv();
+ container.setId(id);
+ String styles = ac.getUIConnector().getWidget().getParent()
+ .getStyleName();
+ container.setClassName(styles);
+ RootPanel.get().getElement().appendChild(container);
+ }
+ return container;
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
index 6667dc7438..ae14218fff 100644
--- a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
+++ b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
@@ -39,7 +39,9 @@ import com.vaadin.client.ComponentConnector;
import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
+import com.vaadin.client.VConsole;
import com.vaadin.client.ValueMap;
+import com.vaadin.client.ui.VOverlay;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.dd.DragEventType;
@@ -567,7 +569,7 @@ public class VDragAndDropManager {
private void clearDragElement() {
if (dragElement != null) {
if (dragElement.getParentElement() != null) {
- RootPanel.getBodyElement().removeChild(dragElement);
+ dragElement.removeFromParent();
}
dragElement = null;
}
@@ -708,7 +710,15 @@ public class VDragAndDropManager {
@Override
public void run() {
if (dragElement != null && dragElement.getParentElement() == null) {
- RootPanel.getBodyElement().appendChild(dragElement);
+ ApplicationConnection connection = getCurrentDragApplicationConnection();
+ Element dragImageParent;
+ if (connection == null) {
+ VConsole.error("Could not determine ApplicationConnection for current drag operation. The drag image will likely look broken");
+ dragImageParent = RootPanel.getBodyElement();
+ } else {
+ dragImageParent = VOverlay.getOverlayContainer(connection);
+ }
+ dragImageParent.appendChild(dragElement);
}
}
@@ -720,6 +730,19 @@ public class VDragAndDropManager {
return serverCallback != null;
}
+ protected ApplicationConnection getCurrentDragApplicationConnection() {
+ if (currentDrag == null) {
+ return null;
+ }
+
+ final ComponentConnector dragSource = currentDrag.getTransferable()
+ .getDragSource();
+ if (dragSource == null) {
+ return null;
+ }
+ return dragSource.getConnection();
+ }
+
/**
* Method to que tasks until all dd related server visits are done
*
diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierachy.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierachy.java
new file mode 100644
index 0000000000..0697286f38
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierachy.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 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.components.abstractcomponent;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.server.UseStateFromHierachyComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class UseStateFromHierachy extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final UseStateFromHierachyComponent component = new UseStateFromHierachyComponent();
+ component.setContent(new Label("Content child"));
+
+ addComponent(component);
+ addComponent(new Button("Remove component", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ removeComponent(component);
+ }
+ }));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests that shared state and connector hierarchy is consistent when removing components from the hierachy";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(10151);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierarchy.html b/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierarchy.html
new file mode 100644
index 0000000000..225b901413
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/UseStateFromHierarchy.html
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title></title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">UIScrollTest</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.abstractcomponent.UseStateFromHierachy?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsabstractcomponentUseStateFromHierachy::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentsabstractcomponentUseStateFromHierachy::Root/VNotification[0]/HTML[0]/domChild[0]</td>
+ <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java
new file mode 100644
index 0000000000..948c1ece3d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 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.SimplePanel;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.client.ui.AbstractSingleComponentContainerConnector;
+import com.vaadin.shared.Connector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.widgetset.server.UseStateFromHierachyComponent;
+
+@Connect(UseStateFromHierachyComponent.class)
+public class UseStateFromHierachyChangeConnector extends
+ AbstractSingleComponentContainerConnector {
+
+ @Override
+ public SimplePanel getWidget() {
+ return (SimplePanel) super.getWidget();
+ }
+
+ @Override
+ public UseStateFromHierachyChangeConnectorState getState() {
+ return (UseStateFromHierachyChangeConnectorState) super.getState();
+ }
+
+ @Override
+ public void updateCaption(ComponentConnector connector) {
+ // Caption not supported
+ }
+
+ @Override
+ public void onConnectorHierarchyChange(
+ ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
+ Connector stateChild = getState().child;
+ if (stateChild == null) {
+ if (getChildComponents().size() != 0) {
+ throw new IllegalStateException(
+ "Hierarchy has child but state has not");
+ } else {
+ getWidget().setWidget(null);
+ }
+ } else {
+ if (getChildComponents().size() != 1
+ || getChildComponents().get(0) != stateChild) {
+ throw new IllegalStateException(
+ "State has child but hierarchy has not");
+ } else {
+ getWidget().setWidget(getChildComponents().get(0).getWidget());
+ }
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java
new file mode 100644
index 0000000000..9dbededb50
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2012 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.AbstractComponentState;
+import com.vaadin.shared.Connector;
+
+public class UseStateFromHierachyChangeConnectorState extends
+ AbstractComponentState {
+ public Connector child;
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/UseStateFromHierachyComponent.java b/uitest/src/com/vaadin/tests/widgetset/server/UseStateFromHierachyComponent.java
new file mode 100644
index 0000000000..3349024340
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/UseStateFromHierachyComponent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 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.UseStateFromHierachyChangeConnectorState;
+import com.vaadin.ui.AbstractSingleComponentContainer;
+import com.vaadin.ui.Component;
+
+public class UseStateFromHierachyComponent extends
+ AbstractSingleComponentContainer {
+
+ @Override
+ protected UseStateFromHierachyChangeConnectorState getState() {
+ return (UseStateFromHierachyChangeConnectorState) super.getState();
+ }
+
+ @Override
+ public void setContent(Component content) {
+ getState().child = content;
+ super.setContent(content);
+ }
+
+}