Component c = containerToComponent.get(ts.getSelectedTab());
c.setVisible(!c.isVisible());
}
private Component createComponent(Class<? extends Component> c) {
RichTextArea textArea = new RichTextArea();
textArea.setVisible(false);
textArea.setCaption("This is the textArea");
textArea.setWidth("200px");
textArea.setHeight("100px");
textAreas.add(textArea);
Component cc = null;
try {
cc = c.newInstance();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
// if (c == OrderedLayout.class) {
// cc = new VerticalLayout();
// } else
if (c == Accordion.class) {
// Label l = new Label("Filler");
// l.setCaption("Filler label");
// cc.addComponent(l);
}
if (c == Form.class) {
Form f = (Form) cc;
f.setFormFieldFactory(new FormFieldFactory() {
@Override
public Field<?> createField(Item item, Object propertyId,
Component uiContext) {
formTextArea = new RichTextArea();
formTextArea.setVisible(false);
return formTextArea;
}
});
f.setItemDataSource(new BeanItem<Object>(new Object() {
private int a;
@SuppressWarnings("unused")
public int getA() {
return a;
}
@SuppressWarnings("unused")
public void setA(int a) {
this.a = a;
}
}));
containerToComponent.put(f, formTextArea);
return f;
}
containerToComponent.put(cc, textArea);
if (cc instanceof ComponentContainer) {
((ComponentContainer) cc).addComponent(textArea);
}
if (AbstractSplitPanel.class.isAssignableFrom(c)) {
AbstractSplitPanel sp = (AbstractSplitPanel) cc;
sp.setWidth("300px");
sp.setHeight("300px");
sp.addComponent(new Label("Label"));
textArea.setSizeFull();
}
if (c == Panel.class) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
((Panel) cc).setContent(layout);
containerToComponent.put(cc, layout);
layout.setVisible(false);
textArea.setVisible(true);
return cc;
}
return cc;
}