private void applyLayoutSettings(Component target, Alignment alignment, float expandRatio) { setComponentAlignment(target, alignment); setExpandRatio(target, expandRatio); }
@Override public void readDesign(Element design, DesignContext designContext) { // process default attributes super.readDesign(design, designContext); setMargin(readMargin(design, getMargin(), designContext)); // handle children for (Element childComponent : design.children()) { Attributes attr = childComponent.attributes(); Component newChild = designContext.readDesign(childComponent); addComponent(newChild); // handle alignment setComponentAlignment(newChild, DesignAttributeHandler.readAlignment(attr)); // handle expand ratio if (attr.hasKey(":expand")) { String value = attr.get(":expand"); if (!value.isEmpty()) { try { float ratio = Float.valueOf(value); setExpandRatio(newChild, ratio); } catch (NumberFormatException nfe) { getLogger() .info("Failed to parse expand ratio " + value); } } else { setExpandRatio(newChild, 1.0f); } } } }
protected <LayoutType extends AbstractOrderedLayout> LayoutType attachActionButtons(LayoutType layout) { Component buttons = wrapButtons(createActionButtons()); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_CENTER); return layout; }
@Override public B addAlignAndExpand(Component component, Alignment alignment, float expandRatio) { getInstance().addComponent(component); getInstance().setComponentAlignment(component, alignment); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAlignAndExpand( Component component, Alignment alignment, float expandRatio) { getInstance().addComponent(component); getInstance().setComponentAlignment(component, alignment); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public com.holonplatform.vaadin7.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAlignAndExpand( Component component, Alignment alignment, float expandRatio) { getInstance().addComponent(component); getInstance().setComponentAlignment(component, alignment); getInstance().setExpandRatio(component, expandRatio); return builder(); }
private void createLoginUI(final AbstractOrderedLayout parentLayout) { final Rpi_gpio_controllerApplication application = this; LoginForm loginForm = new LoginForm(); loginForm.addListener(new LoginForm.LoginListener() { Rpi_gpio_controllerApplication mApplication = application; @Override public void onLogin(LoginEvent event) { String loginErrorMessage = new User( new UserData(event.getLoginParameter("username"), event.getLoginParameter("password")), mApplication).login(); if (loginErrorMessage != null) { Notification notification = new Notification(LoginErrorMessage, loginErrorMessage, Notification.TYPE_ERROR_MESSAGE); notification.setDelayMsec(1000); notification.show(Page.getCurrent()); } } }); Panel loginPanel = new Panel("Log in!!!!"); loginPanel.setWidth("200px"); loginPanel.setHeight("250px"); loginPanel.setContent(loginForm); parentLayout.addComponent(loginPanel); parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
@Override public B addAlignAndExpand(Component component, Alignment alignment, float expandRatio) { getInstance().addComponent(component); getInstance().setComponentAlignment(component, alignment); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(vComponent); if (index > existingIndex) { index--; } remove(childComponent); } component.addComponent(vComponent, index); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { attachToFrame(childComponent); } } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
((AbstractOrderedLayout) container).setComponentAlignment(vComponent, alignment);
@Override protected void handleHTML5Drop(DragAndDropEvent event) { VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous // component VerticalDropLocation loc = (details).getDropLocation(); if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous // component VerticalDropLocation loc = (details).getDropLocation(); if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous // component VerticalDropLocation loc = (details).getDropLocation(); if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { FormLayoutTargetDetails details = (FormLayoutTargetDetails) event .getTargetDetails(); int idx = details.getOverIndex(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); // Increase index if component is dropped after or above a // previous component VerticalDropLocation loc = details.getDropLocation(); if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) { idx++; } // Add component if (idx >= 0) { layout.addComponent(resolveComponentFromHTML5Drop(event), idx); } else { layout.addComponent(resolveComponentFromHTML5Drop(event)); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(resolveComponentFromHTML5Drop(event), dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { FormLayoutTargetDetails details = (FormLayoutTargetDetails) event .getTargetDetails(); int idx = details.getOverIndex(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); // Increase index if component is dropped after or above a // previous component VerticalDropLocation loc = details.getDropLocation(); if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) { idx++; } // Add component if (idx >= 0) { layout.addComponent(resolveComponentFromHTML5Drop(event), idx); } else { layout.addComponent(resolveComponentFromHTML5Drop(event)); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(resolveComponentFromHTML5Drop(event), dropAlignment); } }
getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
@Override protected void handleHTML5Drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); // Increase index if component is dropped after or above a // previous component HorizontalDropLocation loc = (details).getDropLocation(); if (loc == HorizontalDropLocation.CENTER || loc == HorizontalDropLocation.RIGHT) { idx++; } Component comp = resolveComponentFromHTML5Drop(event); // Add component if (idx >= 0) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
layout.setComponentAlignment(comp, dropAlignment);