private boolean findFieldAndFocus(Component compositionRoot) { if (compositionRoot instanceof AbstractComponentContainer) { AbstractComponentContainer cc = (AbstractComponentContainer) compositionRoot; for (Component component : cc) { if (component instanceof AbstractTextField) { AbstractTextField abstractTextField = (AbstractTextField) component; abstractTextField.selectAll(); return true; } if (component instanceof AbstractField) { AbstractField<?> abstractField = (AbstractField<?>) component; abstractField.focus(); return true; } if (component instanceof AbstractComponentContainer) { if (findFieldAndFocus(component)) { return true; } } } } return false; }
private boolean findFieldAndFocus(Component compositionRoot) { if (compositionRoot instanceof AbstractComponentContainer) { AbstractComponentContainer cc = (AbstractComponentContainer) compositionRoot; for (Component component : cc) { if (component instanceof AbstractTextField) { AbstractTextField abstractTextField = (AbstractTextField) component; abstractTextField.selectAll(); return true; } if (component instanceof AbstractField) { AbstractField abstractField = (AbstractField) component; abstractField.focus(); return true; } if (component instanceof AbstractComponentContainer) { if (findFieldAndFocus(component)) { return true; } } } } return false; }
private ComponentContainer buildComponent(Component component, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { AbstractComponentContainer container; if (component instanceof Drawer) { container = buildDrawer((Drawer) component, mapComponents, fieldIdList, extraObjects); } else if (component instanceof Section) { container = buildSection((Section) component, mapComponents, fieldIdList, extraObjects); } else if (component instanceof SubForm) { container = buildSubForm((SubForm) component, mapComponents, fieldIdList, extraObjects); } else if (component instanceof TabSheet) { container = buildTabSheet((TabSheet) component, mapComponents, fieldIdList, extraObjects); } else { throw new UnsupportedOperationException(); } addComponent(mapComponents, component, container); return container; }
private AbstractComponentContainer buildTabSheet(TabSheet part, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { com.vaadin.ui.TabSheet tabSheet = new com.vaadin.ui.TabSheet(); for (Component component : part.getChildList()) { if (component instanceof Tab) { Tab tab = (Tab) component; VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); for (Component child : tab.getChildList()) { layout.addComponent(buildComponent(child, mapComponents, fieldIdList, extraObjects)); } tabSheet.addTab(layout, tab.getName()); } else { throw new UnsupportedOperationException(); } } tabSheet.setSizeFull(); return tabSheet; }
private AbstractComponentContainer buildSubForm(SubForm subForm, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { //panel.setCaption(formEditor.getName()); GridLayout layout = new GridLayout(subForm.getColumns(), subForm.getRows()); layout.setWidth("100%"); layout.setSpacing(true); for (int row = 0; row < subForm.getRows(); row++) { for (int column = 0; column < subForm.getColumns(); column++) { Component component = subForm.getField(row, column); if (component == null) { layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); } else if (component instanceof Field) { Field editor = (Field) component; if (editor != null) { layout.addComponent(buildField(editor, mapComponents, fieldIdList, extraObjects)); } } else { buildComponent(component, mapComponents, fieldIdList, extraObjects); } } } return layout; }
private boolean findFieldAndFocus(Component compositionRoot) { if (compositionRoot instanceof AbstractComponentContainer) { AbstractComponentContainer cc = (AbstractComponentContainer) compositionRoot; for (Component component : cc) { if (component instanceof AbstractTextField) { AbstractTextField abstractTextField = (AbstractTextField) component; if (!abstractTextField.isReadOnly()) { abstractTextField.selectAll(); return true; } } if (component instanceof AbstractField) { AbstractField abstractField = (AbstractField) component; if (!abstractField.isReadOnly()) { abstractField.focus(); return true; } } if (component instanceof AbstractComponentContainer) { if (findFieldAndFocus(component)) { return true; } } } } return false; }
private AbstractComponentContainer buildDrawer(final Drawer drawer, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { VerticalLayout layout = new VerticalLayout(); final Button button = new Button(); // button.setStyleName(BaseTheme.BUTTON_LINK); button.setCaption("\u25B6" + drawer.getName()); final VerticalLayout innerLayout = new VerticalLayout(); for (Component component : drawer.getChildList()) { ComponentContainer container = buildComponent(component, mapComponents, fieldIdList, extraObjects); innerLayout.addComponent(container); } button.addListener(new Button.ClickListener() { private static final long serialVersionUID = 4970466538378502562L; @Override public void buttonClick(ClickEvent event) { innerLayout.setVisible(!innerLayout.isVisible()); if (innerLayout.isVisible()) { button.setCaption("\u25BC" + drawer.getName()); } else { button.setCaption("\u25B6" + drawer.getName()); } } }); layout.addComponent(button); layout.addComponent(innerLayout); innerLayout.setVisible(false); return layout; }
private AbstractComponentContainer buildSection(Section part, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { Panel panel = new Panel(); panel.setCaption(part.getName()); for (Component component : part.getChildList()) { ComponentContainer container = buildComponent(component, mapComponents, fieldIdList, extraObjects); panel.addComponent(container); } return panel; }
public void addComponentToParent(VisualTreeNode parent, VisualTreeNode child) throws ElementFactoryException { if (parent.getComponent() instanceof AbstractComponentContainer) { Component childComponent = child.getComponent(); AbstractComponentContainer parentContainer = parent.getComponent(); parentContainer.addComponent(childComponent); if (parentContainer instanceof AbstractOrderedLayout) { Alignment alignment = parseAlignment(child.getAdditionalParameter("alignment", "MIDDLE_LEFT")); ((AbstractOrderedLayout) parentContainer).setComponentAlignment(childComponent, alignment); } } }