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 {
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());
}
}
Button previousSample;
Button nextSample;
+ private Window srcWindow = null;
+
SamplerWindow() {
// Main top/expanded-bottom layout
VerticalLayout mainExpand = new VerticalLayout();
});
}
+ 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)
*
* the Feature(Set) to show
*/
public void setFeature(Feature f) {
+ hideSource();
currentFeature.setValue(f);
String path = getPathFor(f);
webAnalytics.trackPageview(path);