Java Code Examples for com.vaadin.ui.AbstractOrderedLayout#addComponent()
The following examples show how to use
com.vaadin.ui.AbstractOrderedLayout#addComponent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormFactoryImpl.java From cia with Apache License 2.0 | 5 votes |
@Override public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final T item, final Class<T> beanType, final List<String> displayProperties) { final Panel formPanel = new Panel(); formPanel.setSizeFull(); panelContent.addComponent(formPanel); if (displayProperties.size() > SIZE_FOR_GRID) { panelContent.setExpandRatio(formPanel, ContentRatio.GRID); } else { panelContent.setExpandRatio(formPanel, ContentRatio.SMALL_GRID); } final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); formContent.setWidth(ContentSize.FULL_SIZE); final Binder<T> binder = new Binder<>(beanType); binder.setBean(item); binder.setReadOnly(true); PropertyDescriptor[] propertyDescriptors=null; try { final BeanInfo info = Introspector.getBeanInfo(item.getClass()); propertyDescriptors = info.getPropertyDescriptors(); } catch (final IntrospectionException exception) { LOGGER.error("No able to getfieldtypes for type:+ item.getClass()", exception); } createDisplayPropertyConverters(displayProperties, formContent, binder, propertyDescriptors); }
Example 2
Source File: Box.java From jdal with Apache License 2.0 | 5 votes |
/** * Try to imitate VerticalStruct of Swing BoxLayout * @param layout layout to add struct * @param height struct height */ public static void addVerticalStruct(AbstractOrderedLayout layout, int height) { Label label = new Label(); label.setHeight(height + "px"); layout.addComponent(label); layout.setExpandRatio(label, 0f); }
Example 3
Source File: Box.java From jdal with Apache License 2.0 | 5 votes |
/** * Try to imitate HorizontalStruct on Swing BoxLayout * @param layout Layout to add the struct * @param width struct withd */ public static void addHorizontalStruct(AbstractOrderedLayout layout, int width) { Label label = new Label(); label.setWidth(width + "px"); layout.addComponent(label); layout.setExpandRatio(label, 0f); }
Example 4
Source File: Box.java From jdal with Apache License 2.0 | 5 votes |
/** * Try to imitate a VerticalGlue of Swing BoxLayout */ public static void addVerticalGlue(AbstractOrderedLayout layout) { Label label = new Label(" "); label.setHeight("100%"); layout.addComponent(label); layout.setExpandRatio(label, 1.0f); }
Example 5
Source File: Box.java From jdal with Apache License 2.0 | 5 votes |
/** * Try to imitate a HorizalGlue of Swing BoxLayout. * A invisible component that get all extra space. * @param layout layout to add glue */ public static void addHorizontalGlue(AbstractOrderedLayout layout) { Label label = new Label(); label.setWidth("100%"); layout.addComponent(label); layout.setExpandRatio(label, 1.0f); }
Example 6
Source File: RowUtil.java From cia with Apache License 2.0 | 5 votes |
/** * Creates the grid layout. * * @param panelContent the panel content * @return the responsive row */ public static ResponsiveRow createGridLayout(final AbstractOrderedLayout panelContent) { final ResponsiveLayout layout = new ResponsiveLayout(); Responsive.makeResponsive(layout); layout.addStyleName("v-layout-content-overview-panel-level1"); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(100, Unit.PERCENTAGE); panelContent.addComponent(layout); panelContent.setExpandRatio(layout, ContentRatio.LARGE); return layout.addRow(); }
Example 7
Source File: AbstractChartDataManagerImpl.java From cia with Apache License 2.0 | 5 votes |
/** * Adds the chart. * * @param content * the content * @param caption * the caption * @param chart * the chart * @param fullPage * the full page */ protected final void addChart(final AbstractOrderedLayout content,final String caption, final DCharts chart, final boolean fullPage) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); final int browserWindowWidth = getChartWindowWidth(); final int browserWindowHeight = getChartWindowHeight(fullPage); horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS); horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS); horizontalLayout.setMargin(true); horizontalLayout.setSpacing(false); horizontalLayout.addStyleName("v-layout-content-overview-panel-level1"); final Panel formPanel = new Panel(); formPanel.setSizeFull(); formPanel.setContent(horizontalLayout); formPanel.setCaption(caption); content.addComponent(formPanel); content.setExpandRatio(formPanel, ContentRatio.LARGE); chart.setWidth(100, Unit.PERCENTAGE); chart.setHeight(100, Unit.PERCENTAGE); chart.setMarginRight(CHART_RIGHT_MARGIN); chart.setMarginLeft(CHART_LEFT_MARGIN); chart.setMarginBottom(CHART_BOTTOM_MARGIN_SIZE); chart.setMarginTop(CHART_TOP_MARGIN_SIZE); horizontalLayout.addComponent(chart); chart.setCaption(caption); }
Example 8
Source File: DefaultFormLayoutDropHandler.java From cuba with Apache License 2.0 | 5 votes |
@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); } }
Example 9
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 5 votes |
@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); } }
Example 10
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 5 votes |
@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); } }
Example 11
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component comp = transferable.getComponent(); int idx = details.getOverIndex(); int oldIndex = layout.getComponentIndex(comp); if (idx == oldIndex) { // Index did not change return; } // Detach layout.removeComponent(comp); // Account for detachment if new index is bigger then old index if (idx > oldIndex) { idx--; } // 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(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
Example 12
Source File: DefaultFormLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); FormLayoutTargetDetails details = (FormLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = details.getOverIndex(); Component comp = transferable.getComponent(); // Check that we are not dragging an outer layout into an inner // layout Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // 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(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
Example 13
Source File: AbstractGhantChartManagerImpl.java From cia with Apache License 2.0 | 4 votes |
/** * Creates the role ghant. * * @param roleSummaryLayoutTabsheet the role summary layout tabsheet * @param assignmentList the assignment list */ public final void createRoleGhant(final AbstractOrderedLayout roleSummaryLayoutTabsheet, final Collection<T> assignmentList) { final Comparator<T> compare = getComparator(); final List<T> list = assignmentList.stream().filter( (final T x) -> new DateTime(getStepMapping().getFromDate(x).getTime()).getYear() > FILTER_DATA_BEFORE_YEAR) .collect(Collectors.toList()); Collections.sort(list, compare); final Gantt createGantt = createGenericGantt(list, getRoleMapping(), getStepMapping()); roleSummaryLayoutTabsheet.addComponent(createGantt); roleSummaryLayoutTabsheet.setExpandRatio(createGantt, ContentRatio.GRID); }
Example 14
Source File: PagingUtilImpl.java From cia with Apache License 2.0 | 4 votes |
/** * Creates the paging controls. * * @param content the content * @param name the name * @param pageId the page id * @param size the size * @param pageNr the page nr * @param resultPerPage the result per page */ @Override public void createPagingControls(final AbstractOrderedLayout content, final String name, final String pageId, final Long size, final int pageNr, final int resultPerPage) { final HorizontalLayout pagingControls = new HorizontalLayout(); pagingControls.setSpacing(true); pagingControls.setMargin(true); final long maxPages = (size +resultPerPage-1) / resultPerPage; final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(PAGE_HEADER) .append(pageNr) .append(PAGE_SEPARATOR) .append(maxPages) .append(PAGES_TOTAL_RESULTS) .append(size) .append(RESULTS_PER_PAGE) .append(resultPerPage) .append(SHOW); final Label pageInfo = new Label(stringBuilder.toString()); pagingControls.addComponent(pageInfo); pagingControls.setExpandRatio(pageInfo, ContentRatio.SMALL); if (pageNr > PAGE_ONE) { addPagingLink(PREVIOUS_PAGE,name, pageId, pageNr -1L,pagingControls); } if (maxPages > PAGE_ONE && pageNr < maxPages) { addPagingLink(NEXT_PAGE,name, pageId, pageNr +1L,pagingControls); } if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr > PAGE_ONE) { addPagingLink(FIRST_PAGE,name, pageId, 1,pagingControls); } if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr < maxPages) { addPagingLink(LAST_PAGE,name, pageId, maxPages,pagingControls); } content.addComponent(pagingControls); content.setExpandRatio(pagingControls, ContentRatio.SMALL2); }
Example 15
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
/** * Handle a drop from another layout * * @param event * The drag and drop event */ @Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); // Check that we are not dragging an outer layout into an inner // layout Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // 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(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
Example 16
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component comp = transferable.getComponent(); int idx = details.getOverIndex(); int oldIndex = layout.getComponentIndex(comp); if (idx == oldIndex) { // Index did not change return; } // Detach layout.removeComponent(comp); // Account for detachment if new index is bigger then old index if (idx > oldIndex) { idx--; } // 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(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
Example 17
Source File: DefaultVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
/** * Handle a drop from another layout * * @param event * The drag and drop event */ @Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event .getTargetDetails(); AbstractOrderedLayout layout = (AbstractOrderedLayout) details .getTarget(); Component source = event.getTransferable().getSourceComponent(); int idx = (details).getOverIndex(); Component comp = transferable.getComponent(); // Check that we are not dragging an outer layout into an inner // layout Component parent = layout.getParent(); while (parent != null) { if (parent == comp) { return; } parent = parent.getParent(); } // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // 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(comp, idx); } else { layout.addComponent(comp); } // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(comp, dropAlignment); } }
Example 18
Source File: LabelFactory.java From cia with Apache License 2.0 | 3 votes |
/** * Creates a new Label object. * * @param panel * the panel * @param content * the content */ public static void createHeader2Label(final AbstractOrderedLayout panel,final String content) { final Label label = new Label(content); label.setStyleName("Level2Header"); panel.addComponent(label); panel.setExpandRatio(label,ContentRatio.SMALL); }
Example 19
Source File: GridFactoryImpl.java From cia with Apache License 2.0 | 3 votes |
@Override public <T extends Serializable> void createBasicBeanItemNestedPropertiesGrid( final AbstractOrderedLayout panelContent, final Class<T> dataType, final List<T> datasource, final String caption, final String[] nestedProperties, final String[] columnOrder, final String[] hideColumns, final PageItemRendererClickListener<?> listener, final String actionId, final ListPropertyConverter[] collectionPropertyConverters) { final Grid<T> grid = Grid.withPropertySet(BeanPropertySet.get(dataType)); grid.setCaption(caption); grid.setItems(datasource.stream().filter(Objects::nonNull).collect(Collectors.toList())); grid.setSelectionMode(SelectionMode.SINGLE); createNestedProperties(grid, nestedProperties); setColumnConverters(collectionPropertyConverters, grid); configureColumnOrdersAndHiddenFields(columnOrder, hideColumns, grid); configureListeners(listener, grid); grid.setSizeFull(); grid.setStyleName("Level2Header"); createGridCellFilter(columnOrder, grid, dataType); grid.setResponsive(true); panelContent.addComponent(grid); panelContent.setExpandRatio(grid, ContentRatio.GRID); }