addComponent(newComponent); } else if (newLocation == -1) { Alignment alignment = getComponentAlignment(oldComponent); addComponent(newComponent, oldLocation); applyLayoutSettings(newComponent, alignment, expandRatio); } else {
@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); } } } }
/** * Adds a component into indexed position in this container. * * @param c * the component to be added. * @param index * the index of the component position. The components currently * in and after the position are shifted forwards. * @return this (for method chaining) * @see AbstractOrderedLayout#addComponent(Component, int) */ public default S withComponent(Component c, int index) { ((AbstractOrderedLayout) this).addComponent(c, index); return (S) this; }
private static AbstractOrderedLayout createLayout(Class<?> clazz, List<Component> components) { try { AbstractOrderedLayout layout = (AbstractOrderedLayout) clazz.newInstance(); for (Component c : components) layout.addComponent(c); return layout; } catch (InstantiationException ex) { ; } catch (IllegalAccessException ex) { ; } return null; } }
/** * Add component to detail-container. */ public void addDetailComponent(Component c, int index) { if(mainPanel.getContent() instanceof AbstractOrderedLayout) { ((AbstractOrderedLayout) mainPanel.getContent()).addComponent(c, index); } else { throw new UnsupportedOperationException("Cannot add components indexed component, detail content is not AbstractOrderedLayout"); } }
public void addLink (final @Nonnull String navigationTitle, final @Nonnull String link) { ((AbstractOrderedLayout)view).addComponent(new Link(navigationTitle, new ExternalResource(link))); } }
protected <LayoutType extends AbstractOrderedLayout> LayoutType attachActionButtons(LayoutType layout) { Component buttons = wrapButtons(createActionButtons()); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_CENTER); return layout; }
private void addSubField(final Component component) { AbstractOrderedLayout rootLayout = (AbstractOrderedLayout) multiField.iterator().next(); rootLayout.addComponent(component); }
@Override public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAndExpand( Component component, float expandRatio) { getInstance().addComponent(component); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public com.holonplatform.vaadin7.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAndExpand( Component component, float expandRatio) { getInstance().addComponent(component); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public B addAndExpand(Component component, float expandRatio) { getInstance().addComponent(component); getInstance().setExpandRatio(component, expandRatio); return builder(); }
@Override public B addAndExpand(Component component, float expandRatio) { getInstance().addComponent(component); getInstance().setExpandRatio(component, expandRatio); return builder(); }
/** * Adds the alarms components to a {@link com.vaadin.ui.AbstractOrderedLayout} * * @param component the component to add alarms to * @param alarms the alarms list */ private void addComponents(AbstractOrderedLayout component, List<OnmsAlarm> alarms) { if (alarms.size() == 0) { Label label = new Label("No alarms found!"); label.addStyleName("alerts-noalarms-font"); component.addComponent(label); } else { for (OnmsAlarm onmsAlarm : alarms) { OnmsNode onmsNode = null; if (onmsAlarm.getNodeId() != null) { CriteriaBuilder nodeCb = new CriteriaBuilder(OnmsNode.class); nodeCb.eq("id", onmsAlarm.getNodeId()); List<OnmsNode> nodes = m_nodeDao.findMatching(nodeCb.toCriteria()); if (nodes.size() == 1) { onmsNode = nodes.get(0); } } component.addComponent(createAlarmComponent(onmsAlarm, onmsNode)); OnmsSeverity boostSeverity = OnmsSeverity.valueOf(getDashletSpec().getParameters().get("boostSeverity")); if (onmsAlarm.getSeverity().isGreaterThanOrEqual(boostSeverity)) { boosted = true; } } } }
@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 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 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); } }