]> source.dussan.org Git - vaadin-framework.git/commitdiff
Now opening and closing subwindows work.
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 26 Aug 2007 09:33:53 +0000 (09:33 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 26 Aug 2007 09:33:53 +0000 (09:33 +0000)
svn changeset:2126/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java

index 9201b4d85fecf3b5a55b78a04ddd2a665146b9f4..71b400bd9abe19f5361730a5af8174fb0945c430 100755 (executable)
@@ -48,6 +48,8 @@ public class ApplicationConnection implements EntryPoint, FocusListener {
        private WidgetFactory widgetFactory = new DefaultWidgetFactory();
 
        private IContextMenu contextMenu = null;
+       
+       private IView view = new IView();
 
        /**
         * This is the entry point method.
@@ -64,6 +66,9 @@ public class ApplicationConnection implements EntryPoint, FocusListener {
 
                makeUidlRequest("repaintAll=1");
                
+               // TODO remove hardcoded id name
+               RootPanel.get("itmtk-ajax-window").add(view);
+               
        }
 
        private native boolean isDebugMode() /*-{
@@ -165,10 +170,7 @@ public class ApplicationConnection implements EntryPoint, FocusListener {
                                                                + uidl.getId() + ") registered yet.");
                                        if(uidl.getId().equals("PID0")) {
                                                // view
-                                               IView view = new IView();
                                                view.updateFromUIDL(uidl, this);
-                                               // TODO remove hardcoded id name
-                                               RootPanel.get("itmtk-ajax-window").add(view);
                                        } else {
                                                Widget window = widgetFactory.createWidget(uidl);
                                                registerPaintable(uidl.getId(), (Paintable) window);
index d7c42050d17180de0856e90ec4dc96b9747e6a07..b0b2e2df927f8f4d1d767fdc6b8a2a2f0c15757d 100644 (file)
@@ -1,5 +1,9 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
+import java.util.HashSet;
+import java.util.Iterator;
+
+import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
@@ -12,11 +16,16 @@ public class IView extends SimplePanel implements Paintable {
        
        private Paintable layout;
        
+       private HashSet subWindows = new HashSet();
+
+
+       
        public String getTheme() {
                return theme;
        }
        
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+               clear();
                theme = uidl.getStringAttribute("theme");
                com.google.gwt.user.client.Window.setTitle(uidl.getStringAttribute("caption"));
                UIDL childUidl = uidl.getChildUIDL(0);
@@ -33,6 +42,28 @@ public class IView extends SimplePanel implements Paintable {
                        setWidget((Widget) lo);
                }
                lo.updateFromUIDL(childUidl, client);
+               
+               int i=1;
+               HashSet removedSubWindows = new HashSet(subWindows);
+               while ((childUidl = uidl.getChildUIDL(i++)) != null) {
+                       if ("window".equals(childUidl.getTag())) {
+                               Widget w = client.getWidget(childUidl);
+                               if (subWindows.contains(w)) {
+                                       removedSubWindows.remove(w);
+                                       client.registerPaintable(childUidl.getId(), (Paintable)w);
+                               } else {
+                                       subWindows.add(w);
+                                       RootPanel.get().add(w);
+                               }
+                               ((Paintable)w).updateFromUIDL(childUidl, client);
+                       }
+               }
+               for (Iterator rem=removedSubWindows.iterator(); rem.hasNext();) {
+                       IWindow w = (IWindow) rem.next();
+                       client.unregisterPaintable(w);
+                       subWindows.remove(w);
+                       RootPanel.get().remove(w);
+               }
        }
 
 }
index eb197423f63ec37e9f4d508f4e2975e6d681a7a2..33b2d8de2e95d0f63e85f9bd896ba278d605bab3 100644 (file)
@@ -1,5 +1,7 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
+import java.util.HashSet;
+
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
@@ -49,7 +51,7 @@ public class IWindow extends PopupPanel implements Paintable {
        private int origW;
 
        private int origH;
-
+       
        public IWindow() {
                super();
                setStyleName(CLASSNAME);
@@ -94,6 +96,7 @@ public class IWindow extends PopupPanel implements Paintable {
                        setCaption(uidl.getStringAttribute("caption"));
                }
                lo.updateFromUIDL(childUidl, client);
+       
        }
        
        public void setCaption(String c) {