]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove sampler source window when appropriate.
authorMarc Englund <marc.englund@itmill.com>
Thu, 12 Feb 2009 14:59:34 +0000 (14:59 +0000)
committerMarc Englund <marc.englund@itmill.com>
Thu, 12 Feb 2009 14:59:34 +0000 (14:59 +0000)
svn changeset:6822/svn branch:trunk

src/com/itmill/toolkit/demo/sampler/FeatureView.java
src/com/itmill/toolkit/demo/sampler/SamplerApplication.java

index f652f01807c6a8f58d107942a1ed3dfd17f7244b..9f234a4703ef068f47c204da0e4e7db6f7e40c76 100644 (file)
@@ -14,7 +14,6 @@ import com.itmill.toolkit.ui.Label;
 import com.itmill.toolkit.ui.Link;
 import com.itmill.toolkit.ui.Panel;
 import com.itmill.toolkit.ui.VerticalLayout;
-import com.itmill.toolkit.ui.Window;
 import com.itmill.toolkit.ui.Button.ClickEvent;
 
 public class FeatureView extends HorizontalLayout {
@@ -79,14 +78,8 @@ public class FeatureView extends HorizontalLayout {
 
             public void linkActivated(LinkActivatedEvent event) {
                 if (!event.isLinkOpened()) {
-                    Window w = new Window("Java™ source");
-                    ((VerticalLayout) w.getLayout()).setSizeUndefined();
-                    w.setWidth("70%");
-                    w.setHeight("60%");
-                    w.setPositionX(100);
-                    w.setPositionY(100);
-                    w.addComponent(new CodeLabel(currentFeature.getSource()));
-                    getWindow().addWindow(w);
+                    ((SamplerWindow) getWindow()).showSource(currentFeature
+                            .getSource());
                 }
 
             }
index 2607d8331027dbd48845bc4b1d7c2dfc4611afee..4fc3b2541ae57e8c2ae8f72ebbe86c73b86851e6 100644 (file)
@@ -161,6 +161,8 @@ public class SamplerApplication extends Application {
         Button previousSample;
         Button nextSample;
 
+        private Window srcWindow = null;
+
         SamplerWindow() {
             // Main top/expanded-bottom layout
             VerticalLayout mainExpand = new VerticalLayout();
@@ -251,6 +253,26 @@ public class SamplerApplication extends Application {
             });
         }
 
+        public void showSource(String source) {
+            hideSource();
+            Window w = new Window("Java™ source");
+            ((VerticalLayout) w.getLayout()).setSizeUndefined();
+            w.setWidth("70%");
+            w.setHeight("60%");
+            w.setPositionX(100);
+            w.setPositionY(100);
+            w.addComponent(new CodeLabel(source));
+            addWindow(w);
+            srcWindow = w;
+        }
+
+        public void hideSource() {
+            if (srcWindow != null) {
+                removeWindow(srcWindow);
+                srcWindow = null;
+            }
+        }
+
         /**
          * Displays a Feature(Set)
          * 
@@ -258,6 +280,7 @@ public class SamplerApplication extends Application {
          *            the Feature(Set) to show
          */
         public void setFeature(Feature f) {
+            hideSource();
             currentFeature.setValue(f);
             String path = getPathFor(f);
             webAnalytics.trackPageview(path);