import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.vaadin.terminal.gwt.client.ui.VTabsheetPanel;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.terminal.gwt.client.ui.VWindow;
+import com.vaadin.terminal.gwt.client.ui.WindowConnector;
/**
* ComponentLocator provides methods for generating a String locator for a given
return null;
}
- String pid = ConnectorMap.get(client).getConnectorId(w.getElement());
- if (isStaticPid(pid)) {
- return pid;
- }
-
if (w instanceof VView) {
return "";
} else if (w instanceof VWindow) {
- VWindow win = (VWindow) w;
- ArrayList<VWindow> subWindowList = client.getView().getWidget()
- .getSubWindowList();
- int indexOfSubWindow = subWindowList.indexOf(win);
+ Connector windowConnector = ConnectorMap.get(client)
+ .getConnector(w);
+ List<WindowConnector> subWindowList = client.getView()
+ .getSubWindows();
+ int indexOfSubWindow = subWindowList.indexOf(windowConnector);
return PARENTCHILD_SEPARATOR + "VWindow[" + indexOfSubWindow + "]";
} else if (w instanceof RootPanel) {
return ROOT_ID;
* compatibility
*/
if (widgetClassName.equals("VWindow")) {
- iterator = client.getView().getWidget().getSubWindowList()
- .iterator();
+ List<WindowConnector> windows = client.getView()
+ .getSubWindows();
+ List<VWindow> windowWidgets = new ArrayList<VWindow>(
+ windows.size());
+ for (WindowConnector wc : windows) {
+ windowWidgets.add(wc.getWidget());
+ }
+ iterator = windowWidgets.iterator();
} else if (widgetClassName.equals("VContextMenu")) {
return client.getContextMenu();
} else {
return null;
}
- /**
- * Checks if the given pid is a static pid.
- *
- * @param pid
- * The pid to check
- * @return true if the pid is a static pid, false otherwise
- */
- private boolean isStaticPid(String pid) {
- if (pid == null) {
- return false;
- }
-
- return pid.startsWith("PID_S");
- }
-
}
import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
-import com.vaadin.terminal.gwt.client.ui.VWindow;
+import com.vaadin.terminal.gwt.client.ui.WindowConnector;
/**
* A helper console for client side development. The debug console can also be
.getConnectors();
log("Sub windows:");
Set<ComponentConnector> subWindowHierarchyConnectors = new HashSet<ComponentConnector>();
- for (VWindow w : root.getWidget().getSubWindowList()) {
- SimpleTree windowHierachy = dumpConnectorHierarchy(
- connectorMap.getConnector(w), "",
+ for (WindowConnector wc : root.getSubWindows()) {
+ SimpleTree windowHierachy = dumpConnectorHierarchy(wc, "",
subWindowHierarchyConnectors);
if (panel.isAttached()) {
windowHierachy.open(true);
*/
package com.vaadin.terminal.gwt.client.ui;
-import java.util.HashSet;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.terminal.gwt.client.Connector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.Focusable;
public class RootConnector extends AbstractComponentContainerConnector
implements Paintable {
+ public static class RootState extends ComponentState {
+ private Connector content;
+
+ public Connector getContent() {
+ return content;
+ }
+
+ public void setContent(Connector content) {
+ this.content = content;
+ }
+
+ }
+
public interface RootServerRPC extends ClickRPC, ServerRpc {
}
return;
}
- // Draw this application level window
- UIDL childUidl = uidl.getChildUIDL(childIndex);
- final ComponentConnector lo = client.getPaintable(childUidl);
-
- boolean layoutChanged = getWidget().layout != lo;
- if (getWidget().layout != null) {
- if (layoutChanged) {
- // remove old
- if (childStateChangeHandlerRegistration != null) {
- childStateChangeHandlerRegistration.removeHandler();
- childStateChangeHandlerRegistration = null;
- }
- // add new
- getWidget().setWidget(lo.getWidget());
- getWidget().layout = lo;
- }
- } else {
- getWidget().setWidget(lo.getWidget());
- getWidget().layout = lo;
- if (layoutChanged) {
- childStateChangeHandlerRegistration = lo
- .addStateChangeHandler(childStateChangeHandler);
- // Must handle new child here as state change events are already
- // fired
- onChildSizeChange();
- }
- }
-
- // Save currently open subwindows to track which will need to be closed
- final HashSet<VWindow> removedSubWindows = new HashSet<VWindow>(
- getWidget().subWindows);
-
// Handle other UIDL children
+ UIDL childUidl;
while ((childUidl = uidl.getChildUIDL(++childIndex)) != null) {
String tag = childUidl.getTag().intern();
if (tag == "actions") {
final UIDL notification = (UIDL) it.next();
VNotification.showNotification(client, notification);
}
- } else {
- // subwindows
- final WindowConnector w = (WindowConnector) client
- .getPaintable(childUidl);
- VWindow windowWidget = w.getWidget();
- if (getWidget().subWindows.contains(windowWidget)) {
- removedSubWindows.remove(windowWidget);
- } else {
- getWidget().subWindows.add(windowWidget);
- }
- w.updateFromUIDL(childUidl, client);
}
}
- // Close old windows which where not in UIDL anymore
- for (final Iterator<VWindow> rem = removedSubWindows.iterator(); rem
- .hasNext();) {
- final VWindow w = rem.next();
- getWidget().subWindows.remove(w);
- w.hide();
- }
-
if (uidl.hasAttribute("focused")) {
// set focused component when render phase is finished
Scheduler.get().scheduleDeferred(new Command() {
}
protected void onChildSizeChange() {
- ComponentConnector child = getWidget().layout;
+ ComponentConnector child = (ComponentConnector) getState().getContent();
Style childStyle = child.getWidget().getElement().getStyle();
/*
* Must set absolute position if the child has relative height and
*/
@Deprecated
public boolean hasSubWindow(WindowConnector wc) {
- return getWidget().subWindows.contains(wc.getWidget());
+ return getChildren().contains(wc);
+ }
+
+ /**
+ * Return an iterator for current subwindows. This method is meant for
+ * testing purposes only.
+ *
+ * @return
+ */
+ public List<WindowConnector> getSubWindows() {
+ ArrayList<WindowConnector> windows = new ArrayList<WindowConnector>();
+ for (ComponentConnector child : getChildren()) {
+ if (child instanceof WindowConnector) {
+ windows.add((WindowConnector) child);
+ }
+ }
+ return windows;
+ }
+
+ @Override
+ public RootState getState() {
+ return (RootState) super.getState();
}
@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
super.onConnectorHierarchyChange(event);
+
+ ComponentConnector oldChild = null;
+ ComponentConnector newChild = (ComponentConnector) getState()
+ .getContent();
+
+ for (ComponentConnector c : event.getOldChildren()) {
+ if (!(c instanceof WindowConnector)) {
+ oldChild = c;
+ break;
+ }
+ }
+
+ if (oldChild != newChild) {
+ if (childStateChangeHandlerRegistration != null) {
+ childStateChangeHandlerRegistration.removeHandler();
+ childStateChangeHandlerRegistration = null;
+ }
+ getWidget().setWidget(newChild.getWidget());
+ childStateChangeHandlerRegistration = newChild
+ .addStateChangeHandler(childStateChangeHandler);
+ // Must handle new child here as state change events are already
+ // fired
+ onChildSizeChange();
+ }
+
for (ComponentConnector c : getChildren()) {
if (c instanceof WindowConnector) {
WindowConnector wc = (WindowConnector) c;
wc.setWindowOrderAndPosition();
}
}
+
+ // Close removed sub windows
+ for (ComponentConnector c : event.getOldChildren()) {
+ if (c.getParent() != this && c instanceof WindowConnector) {
+ ((WindowConnector) c).getWidget().hide();
+ }
+ }
}
}
package com.vaadin.terminal.gwt.client.ui;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
String theme;
- ComponentConnector layout;
-
- final LinkedHashSet<VWindow> subWindows = new LinkedHashSet<VWindow>();
-
String id;
ShortcutActionHandler actionHandler;
}
}-*/;
- /**
- * Return an iterator for current subwindows. This method is meant for
- * testing purposes only.
- *
- * @return
- */
- public ArrayList<VWindow> getSubWindowList() {
- ArrayList<VWindow> windows = new ArrayList<VWindow>(subWindows.size());
- for (VWindow widget : subWindows) {
- windows.add(widget);
- }
- return windows;
- }
-
public ShortcutActionHandler getShortcutActionHandler() {
return actionHandler;
}
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.Vaadin6Component;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.WrappedRequest.BrowserDetails;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.RootConnector.RootServerRPC;
+import com.vaadin.terminal.gwt.client.ui.RootConnector.RootState;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.tools.ReflectTools;
* @since 7.0
*/
public abstract class Root extends AbstractComponentContainer implements
- Action.Container, Action.Notifier {
+ Action.Container, Action.Notifier, Vaadin6Component {
/**
* Listener that gets notified when the size of the browser window
*/
public static final int BORDER_DEFAULT = 2;
- /**
- * The container in which the component hierarchy of the root starts.
- */
- private ComponentContainer content;
-
/**
* The application to which this root belongs
*/
* {@link VerticalLayout} with margins enabled as its content.
*/
public Root() {
- registerRpc(rpc);
- setSizeFull();
+ this((ComponentContainer) null);
}
/**
* @see #setContent(ComponentContainer)
*/
public Root(ComponentContainer content) {
- this();
+ registerRpc(rpc);
+ setSizeFull();
setContent(content);
}
* @see #setCaption(String)
*/
public Root(String caption) {
- this();
+ this((ComponentContainer) null);
setCaption(caption);
}
setCaption(caption);
}
+ @Override
+ public RootState getState() {
+ return (RootState) super.getState();
+ }
+
/**
* Overridden to return a value instead of referring to the parent.
*
}
}
- ComponentContainer content = getContent();
- if (content != null) {
- content.paint(target);
- }
-
- // Paint subwindows
- for (final Iterator<Window> i = windows.iterator(); i.hasNext();) {
- final Window w = i.next();
- w.paint(target);
- }
-
// Paint notifications
if (notifications != null) {
target.startTag("notifications");
* @see #createDefaultLayout()
*/
public ComponentContainer getContent() {
- if (content == null) {
- setContent(createDefaultLayout());
- }
- return content;
+ return (ComponentContainer) getState().getContent();
}
/**
* @see #createDefaultLayout()
*/
public void setContent(ComponentContainer content) {
- if (this.content != null) {
- super.removeComponent(this.content);
+ if (content == null) {
+ content = createDefaultLayout();
+ }
+
+ if (getState().getContent() != null) {
+ super.removeComponent((Component) getState().getContent());
}
- this.content = content;
+ getState().setContent(content);
if (content != null) {
super.addComponent(content);
}