| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.utils.vaadin; |
| |
| import java.io.BufferedInputStream; |
| import java.io.IOException; |
| import java.util.Iterator; |
| |
| import com.vaadin.ui.Accordion; |
| import com.vaadin.ui.Component; |
| import com.vaadin.ui.ComponentContainer; |
| import com.vaadin.ui.CssLayout; |
| import com.vaadin.ui.Panel; |
| import com.vaadin.ui.Window; |
| import com.vaadin.ui.themes.Reindeer; |
| |
| public class ExtendedAccordion extends Accordion { |
| private Component toolbar; |
| private CssLayout wrapper = new CssLayout(); |
| private Window scroll = new Window(); |
| |
| public ExtendedAccordion() { |
| super(); |
| |
| // Force size updates to be immediate so that contained layouts can |
| // adjust after initial render |
| setImmediate(true); |
| |
| wrapper.setSizeUndefined(); |
| scroll.setSizeUndefined(); |
| |
| addStyleName("extendedaccordion"); |
| wrapper.addStyleName("extendedaccordion-wrap"); |
| scroll.addStyleName("extendedaccordion-scroll"); |
| scroll.addStyleName(Reindeer.PANEL_LIGHT); |
| |
| Component oldContent = getUI().getContent(); |
| |
| super.getUI().setContent(wrapper); |
| wrapper.addComponent(scroll); |
| |
| setContent(oldContent); |
| |
| } |
| |
| public ExtendedAccordion(String caption) { |
| this(); |
| setCaption(caption); |
| } |
| |
| public void setContent(Component content) { |
| if (scroll != null) { |
| scroll.setContent(content); |
| } |
| } |
| |
| // public void addComponent(Component c) { |
| // scroll.addComponent(c); |
| // } |
| // |
| // @Override |
| // public void removeComponent(Component c) { |
| // scroll.removeComponent(c); |
| // } |
| // |
| // @Override |
| // public Iterator<Component> getComponentIterator() { |
| // return scroll.getComponentIterator(); |
| // } |
| // |
| // @Override |
| // public void replaceComponent(Component oldComponent, Component newComponent) { |
| // scroll.replaceComponent(oldComponent, newComponent); |
| // } |
| // |
| // @Override |
| // public void removeAllComponents() { |
| // scroll.removeAllComponents(); |
| // } |
| // |
| // @Override |
| // public void setWidth(float width, int unit) { |
| // super.setWidth(width, unit); |
| // |
| // if (wrapper == null) { |
| // return; |
| // } |
| // |
| // if (width > 0) { |
| // wrapper.setWidth("100%"); |
| // scroll.setWidth("100%"); |
| // } else { |
| // wrapper.setWidth("-1px"); |
| // scroll.setWidth("-1px"); |
| // } |
| // } |
| // |
| // @Override |
| // public void setHeight(float height, int unit) { |
| // super.setHeight(height, unit); |
| // |
| // if (wrapper == null) { |
| // return; |
| // } |
| // |
| // if (height > 0) { |
| // wrapper.setHeight("100%"); |
| // scroll.setHeight("100%"); |
| // } else { |
| // wrapper.setHeight("-1px"); |
| // scroll.setHeight("-1px"); |
| // } |
| // } |
| |
| public void setToolbar(Component toolbar) { |
| if (this.toolbar != null) { |
| wrapper.removeComponent(this.toolbar); |
| } |
| this.toolbar = toolbar; |
| this.toolbar.addStyleName("extendedaccordion-toolbar"); |
| wrapper.addComponent(toolbar, 1); |
| } |
| |
| public Component getToolbar() { |
| return toolbar; |
| } |
| } |