summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-02-12 14:59:34 +0000
committerMarc Englund <marc.englund@itmill.com>2009-02-12 14:59:34 +0000
commitf2b93f880ffeb8fd790e947e36fac09348deb415 (patch)
tree6b3df5b2a759aa5340ab14227fcad9ba07b2967d /src/com/itmill/toolkit/demo
parentfc5388c5ea5ea3467ed2582bb55773db2e375ce6 (diff)
downloadvaadin-framework-f2b93f880ffeb8fd790e947e36fac09348deb415.tar.gz
vaadin-framework-f2b93f880ffeb8fd790e947e36fac09348deb415.zip
Remove sampler source window when appropriate.
svn changeset:6822/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo')
-rw-r--r--src/com/itmill/toolkit/demo/sampler/FeatureView.java11
-rw-r--r--src/com/itmill/toolkit/demo/sampler/SamplerApplication.java23
2 files changed, 25 insertions, 9 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/FeatureView.java b/src/com/itmill/toolkit/demo/sampler/FeatureView.java
index f652f01807..9f234a4703 100644
--- a/src/com/itmill/toolkit/demo/sampler/FeatureView.java
+++ b/src/com/itmill/toolkit/demo/sampler/FeatureView.java
@@ -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());
}
}
diff --git a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java
index 2607d83310..4fc3b2541a 100644
--- a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java
+++ b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java
@@ -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);