List of usage examples for com.vaadin.ui AbstractOrderedLayout addComponent
@Override public void addComponent(Component c)
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties) { final Panel formPanel = new Panel(); formPanel.setSizeFull();/*w w w. j a v a2s . co m*/ panelContent.addComponent(formPanel); panelContent.setExpandRatio(formPanel, ContentRatio.GRID); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item); fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind = fieldGroup.buildAndBind(property); buildAndBind.setWidth(ContentSize.FULL_SIZE); formContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } }
From source file:com.hack23.cia.web.impl.ui.application.views.common.gridfactory.impl.GridFactoryImpl.java
License:Apache License
@Override public void createBasicBeanItemNestedPropertiesGrid(final AbstractOrderedLayout panelContent, final Indexed datasource, final String caption, final String[] nestedProperties, final Object[] columnOrder, final Object[] hideColumns, final AbstractPageItemRendererClickListener<?> listener, final String actionId, final ListPropertyConverter[] collectionPropertyConverters) { final Grid grid = new Grid(datasource); grid.setCaption(caption);// w w w . j ava2 s .co m grid.setSelectionMode(SelectionMode.SINGLE); createNestedProperties(datasource, nestedProperties); configureColumnOrdersAndHiddenFields(columnOrder, hideColumns, grid); configureListeners(listener, grid); setColumnConverters(collectionPropertyConverters, grid); grid.setSizeFull(); grid.setStyleName("Level2Header"); grid.setImmediate(true); grid.setReadOnly(true); createGridCellFilter(columnOrder, grid); panelContent.addComponent(grid); panelContent.setExpandRatio(grid, ContentRatio.GRID); }
From source file:com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory.java
License:Apache License
/** * Creates a new Label object.//from w ww. java 2 s.c o m * * @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); }
From source file:com.haulmont.timesheets.web.calendar.CalendarScreen.java
License:Apache License
protected void initCalendar() { dataSource = new TimeSheetsCalendarEventProvider(userSession.getCurrentOrSubstitutedUser()); dataSource.addEventSetChangeListener(changeEvent -> updateSummaryColumn()); calendar = new TimeSheetsCalendar(dataSource); calendar.setWidth("100%"); calendar.setHeight("100%"); calendar.setTimeFormat(Calendar.TimeFormat.Format24H); calendar.setMoreMsgFormat(messages.getMessage(getClass(), "calendar.moreMsgFormat")); calendar.setDropHandler(null);//from ww w . j a v a 2 s. c o m calendar.setHandler((CalendarComponentEvents.MoveEvent event) -> { if (event.getCalendarEvent() instanceof TimeEntryCalendarEventAdapter) { TimeEntryCalendarEventAdapter adapter = (TimeEntryCalendarEventAdapter) event.getCalendarEvent(); adapter.getTimeEntry().setDate(event.getNewStart()); TimeEntry committed = getDsContext().getDataSupplier().commit(adapter.getTimeEntry(), viewRepository.getView(TimeEntry.class, "timeEntry-full")); dataSource.changeEventTimeEntity(committed); updateSummaryColumn(); } }); calendar.setHandler((CalendarComponentEvents.WeekClickHandler) null); calendar.setHandler((CalendarComponentEvents.DateClickEvent event) -> { TimeEntry timeEntry = metadata.create(TimeEntry.class); timeEntry.setDate(event.getDate()); editTimeEntry(timeEntry); }); calendar.setHandler((CalendarComponentEvents.EventResizeHandler) null); calendar.setHandler((CalendarComponentEvents.EventClick event) -> { if (event.getCalendarEvent() instanceof TimeEntryCalendarEventAdapter) { TimeEntryCalendarEventAdapter eventAdapter = (TimeEntryCalendarEventAdapter) event .getCalendarEvent(); editTimeEntry(eventAdapter.getTimeEntry()); } else if (event.getCalendarEvent() instanceof HolidayCalendarEventAdapter) { HolidayCalendarEventAdapter eventAdapter = (HolidayCalendarEventAdapter) event.getCalendarEvent(); editHoliday(eventAdapter.getHoliday()); } }); calendar.addActionHandler(new CalendarActionHandler()); AbstractOrderedLayout calendarLayout = (AbstractOrderedLayout) WebComponentsHelper.unwrap(calBox); calendarLayout.addComponent(calendar); calendarLayout.setExpandRatio(calendar, 1); updateCalendarRange(); updateSummaryColumn(); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
/** * Animate the component by visually wrapping it with a layout and button for toggling * the component's visibility. This allows the user to expand/collapse the given component in order * to free space for viewing other components. * * @param component component to show/hide * @param useVerticalLayout true if toggle button should be laid out vertically next to animated component * * @return the newly created layout that contains the toggle button and animated component *//* w ww .j av a2 s .co m*/ protected Component animate(Component component, boolean useVerticalLayout) { final Animator formAnimator = new Animator(component); formAnimator.setSizeUndefined(); AbstractOrderedLayout animatorLayout; if (useVerticalLayout) { animatorLayout = new VerticalLayout(); } else { animatorLayout = new HorizontalLayout(); } animatorLayout.setMargin(false, false, false, false); animatorLayout.setSpacing(false); toggleFormVisibilityButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { formAnimator.setRolledUp(!formAnimator.isRolledUp()); if (formAnimator.isRolledUp()) { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/expand-icon.png")); } else { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); } } }); toggleFormVisibilityButton .setDescription(uiMessageSource.getMessage("entryPoint.toggleSearchForm.description")); toggleFormVisibilityButton.setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); toggleFormVisibilityButton.addStyleName("borderless"); if (useVerticalLayout) { HorizontalLayout toggleFormButtonAndCaption = new HorizontalLayout(); toggleFormButtonAndCaption.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(toggleFormVisibilityButton); toggleFormButtonAndCaption.addComponent(new Label(getEntityCaption())); animatorLayout.addComponent(toggleFormButtonAndCaption); animatorLayout.addComponent(formAnimator); } else { animatorLayout.addComponent(toggleFormVisibilityButton); animatorLayout.addComponent(formAnimator); } return animatorLayout; }
From source file:com.purebred.core.view.menu.LayoutContextMenu.java
License:Open Source License
public LayoutContextMenu(AbstractOrderedLayout layout) { super();// w ww.j a v a 2 s .c o m layout.addListener(this); layout.addComponent(this); addListener(this); }
From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java
License:Open Source License
public static AbstractOrderedLayout buildRegionLegend(boolean vertical, CaseMeasure caseMeasure, boolean emptyPopulationDistrictPresent, BigDecimal districtShapesLowerQuartile, BigDecimal districtShapesMedian, BigDecimal districtShapesUpperQuartile) { AbstractOrderedLayout regionLegendLayout = vertical ? new VerticalLayout() : new HorizontalLayout(); regionLegendLayout.setSpacing(true); CssStyles.style(regionLegendLayout, CssStyles.LAYOUT_MINIMAL); regionLegendLayout.setSizeUndefined(); HorizontalLayout legendEntry;/*from ww w .ja v a 2 s.c om*/ switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("lowest-region-small", districtShapesLowerQuartile.compareTo(BigDecimal.ONE) > 0 ? "1 - " + districtShapesLowerQuartile + " " + I18nProperties.getString(Strings.entityCases) : "1 " + I18nProperties.getString(Strings.entityCase)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("lowest-region-small", "<= " + DataHelper.getTruncatedBigDecimal(districtShapesLowerQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); if (districtShapesLowerQuartile.compareTo(districtShapesMedian) < 0) { switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("low-region-small", districtShapesMedian.compareTo(districtShapesLowerQuartile.add(BigDecimal.ONE)) > 0 ? districtShapesLowerQuartile.add(BigDecimal.ONE) + " - " + districtShapesMedian + " " + I18nProperties.getString(Strings.entityCases) : districtShapesMedian + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("low-region-small", DataHelper .getTruncatedBigDecimal(districtShapesLowerQuartile.add(new BigDecimal(0.1)) .setScale(1, RoundingMode.HALF_UP)) + " - " + DataHelper.getTruncatedBigDecimal(districtShapesMedian) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); } if (districtShapesMedian.compareTo(districtShapesUpperQuartile) < 0) { switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("high-region-small", districtShapesUpperQuartile.compareTo(districtShapesMedian.add(BigDecimal.ONE)) > 0 ? districtShapesMedian.add(BigDecimal.ONE) + " - " + districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases) : districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("high-region-small", DataHelper.getTruncatedBigDecimal( districtShapesMedian.add(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP)) + " - " + DataHelper.getTruncatedBigDecimal(districtShapesUpperQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); } switch (caseMeasure) { case CASE_COUNT: legendEntry = buildMapIconLegendEntry("highest-region-small", "> " + districtShapesUpperQuartile + " " + I18nProperties.getString(Strings.entityCases)); break; case CASE_INCIDENCE: legendEntry = buildMapIconLegendEntry("highest-region-small", "> " + DataHelper.getTruncatedBigDecimal(districtShapesUpperQuartile) + " " + I18nProperties.getString(Strings.entityCases) + " / " + DistrictDto.CASE_INCIDENCE_DIVISOR); break; default: throw new IllegalArgumentException(caseMeasure.toString()); } regionLegendLayout.addComponent(legendEntry); if (caseMeasure == CaseMeasure.CASE_INCIDENCE && emptyPopulationDistrictPresent) { legendEntry = buildMapIconLegendEntry("no-population-region-small", I18nProperties.getCaption(Captions.dashboardNoPopulationData)); regionLegendLayout.addComponent(legendEntry); } return regionLegendLayout; }
From source file:edu.nps.moves.mmowgliMobile.ui.ActionPlanRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) { ActionPlanListEntry wap = (ActionPlanListEntry) message; ActionPlan ap = wap.getActionPlan(); layout.removeAllComponents();/* w ww . j a v a 2 s .c om*/ layout.addComponent(makeLabel("Title")); layout.addComponent(makeText(ap.getTitle())); layout.addComponent(makeHr()); layout.addComponent(makeLabel("Authors")); layout.addComponent(makeAuthors(ap.getQuickAuthorList(), mView)); layout.addComponent(makeHr()); layout.addComponent(makeLabel("Who is involved?")); layout.addComponent(makeText(ap.getSubTitle())); layout.addComponent(makeHr()); layout.addComponent(makeLabel("What is it?")); layout.addComponent(makeText(ap.getWhatIsItText())); layout.addComponent(makeHr()); layout.addComponent(makeLabel("What will it take?")); layout.addComponent(makeText(ap.getWhatWillItTakeText())); layout.addComponent(makeHr()); layout.addComponent(makeLabel("How will it work?")); layout.addComponent(makeText(ap.getHowWillItWorkText())); layout.addComponent(makeHr()); layout.addComponent(makeLabel("How will it change the situation?")); layout.addComponent(makeText(ap.getHowWillItChangeText())); }
From source file:edu.nps.moves.mmowgliMobile.ui.CardRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) { Object key = HSess.checkInit(); CardListEntry wc = (CardListEntry) message; Card c = wc.getCard();//from ww w . j a va 2s.c o m CardType typ = c.getCardType(); layout.removeAllComponents(); layout.setSpacing(true); VerticalLayout cardLay = new VerticalLayout(); cardLay.addStyleName("m-card-render"); cardLay.setWidth("98%"); //100%"); cardLay.setSpacing(true); layout.addComponent(cardLay); HorizontalLayout horl = new HorizontalLayout(); horl.addStyleName("m-card-header"); String stl = CardStyler.getCardBaseStyle(typ); horl.addStyleName(stl); horl.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ)); horl.setMargin(true); horl.setWidth("100%"); Label lbl = new Label(typ.getTitle());//c.getText()); horl.addComponent(lbl); lbl = new Label("" + getPojoId(message)); lbl.addStyleName("m-text-align-right"); horl.addComponent(lbl); cardLay.addComponent(horl); horl = new HorizontalLayout(); horl.setWidth("100%"); horl.setMargin(true); cardLay.addComponent(horl); lbl = new Label(c.getText()); horl.addComponent(lbl); horl = new HorizontalLayout(); horl.addStyleName("m-card-footer"); horl.setMargin(true); horl.setWidth("100%"); horl.addComponent(lbl = new Label("")); lbl.setWidth("5px"); Image img = new Image(); img.setSource(mediaLocator.locate(c.getAuthor().getAvatar().getMedia())); img.setWidth("30px"); img.setHeight("30px"); horl.addComponent(img); // horl.addComponent(lbl=new Label(c.getAuthorName())); // lbl.setWidth("100%"); // lbl.addStyleName("m-text-align-center"); // horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); // horl.setExpandRatio(lbl, 1.0f); Button authButt = new MyButton(c.getAuthorName(), c, mView); authButt.setStyleName(BaseTheme.BUTTON_LINK); authButt.setWidth("100%"); horl.addComponent(authButt); horl.setComponentAlignment(authButt, Alignment.MIDDLE_CENTER); horl.setExpandRatio(authButt, 1.0f); horl.addComponent(lbl = new HtmlLabel(formatter.format(message.getTimestamp()))); lbl.setWidth("115px"); ; lbl.addStyleName("m-text-align-right"); horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); cardLay.addComponent(horl); // lbl = new Hr(); // layout.addComponent(lbl); lbl = new Label("Child Cards"); layout.addComponent(lbl); lbl.addStyleName("m-text-center"); // lbl = new Hr(); // layout.addComponent(lbl); horl = new HorizontalLayout(); horl.setSpacing(true); horl.setMargin(true); horl.setWidth("100%"); layout.addComponent(horl); horl.addComponent( makeChildGroupButton("Expand", (CardListEntry) message, CardType.getExpandTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Counter", (CardListEntry) message, CardType.getCounterTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Adapt", (CardListEntry) message, CardType.getAdaptTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Explore", (CardListEntry) message, CardType.getExploreTypeTL(), messageList)); HSess.checkClose(key); }
From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) { // messageList can be null if coming in from ActionPlan Object key = HSess.checkInit(); UserListEntry wu = (UserListEntry) message; User u = wu.getUser();//from w ww . j a v a2s.c o m layout.removeAllComponents(); HorizontalLayout hlay = new HorizontalLayout(); layout.addComponent(hlay); hlay.addStyleName("m-userview-top"); hlay.setWidth("100%"); hlay.setMargin(true); hlay.setSpacing(true); Image img = new Image(); img.addStyleName("m-ridgeborder"); img.setSource(mediaLocator.locate(u.getAvatar().getMedia())); img.setWidth("90px"); img.setHeight("90px"); hlay.addComponent(img); hlay.setComponentAlignment(img, Alignment.MIDDLE_CENTER); Label lab; hlay.addComponent(lab = new Label()); lab.setWidth("5px"); VerticalLayout vlay = new VerticalLayout(); vlay.setSpacing(true); hlay.addComponent(vlay); hlay.setComponentAlignment(vlay, Alignment.MIDDLE_LEFT); vlay.setWidth("100%"); hlay.setExpandRatio(vlay, 1.0f); HorizontalLayout horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.BOTTOM_LEFT); horl.addComponent(lab = new Label("name")); lab.addStyleName("m-user-top-label"); //light-text"); horl.addComponent(lab = new HtmlLabel(" " + u.getUserName())); lab.addStyleName("m-user-top-value"); horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.TOP_LEFT); horl.addComponent(lab = new Label("level")); lab.addStyleName("m-user-top-label"); //light-text"); Level lev = u.getLevel(); if (u.isGameMaster()) { Level l = Level.getLevelByOrdinal(Level.GAME_MASTER_ORDINAL, HSess.get()); if (l != null) lev = l; } horl.addComponent(lab = new HtmlLabel(" " + lev.getDescription())); lab.addStyleName("m-user-top-value"); GridLayout gLay = new GridLayout(); // gLay.setHeight("155px"); // won't size properly gLay.setMargin(true); gLay.addStyleName("m-userview-mid"); gLay.setColumns(2); gLay.setRows(11); gLay.setSpacing(true); gLay.setWidth("100%"); gLay.setColumnExpandRatio(1, 1.0f); layout.addComponent(gLay); addRow(gLay, "user ID:", "" + getPojoId(message)); addRow(gLay, "location:", u.getLocation()); addRow(gLay, "expertise:", u.getExpertise()); addRow(gLay, "affiliation:", u.getAffiliation()); addRow(gLay, "date registered:", formatter.format(u.getRegisterDate())); gLay.addComponent(new Hr(), 0, 5, 1, 5); Container cntr = new CardsByUserContainer<Card>(u); // expects ThreadLocal session to be setup numCards = cntr.size(); addRow(gLay, "cards played:", "" + numCards); cntr = new ActionPlansByUserContainer<Card>(u); // expects ThreadLocal session to be setup numAps = cntr.size(); addRow(gLay, "action plans:", "" + numAps); gLay.addComponent(new Hr(), 0, 8, 1, 8); addRow(gLay, "exploration points:", "" + u.getBasicScore()); addRow(gLay, "innovation points:", "" + u.getInnovationScore()); cardListener = new CardLis(u, mView); apListener = new AppLis(u, mView); layout.addComponent(makeButtons()); HSess.checkClose(key); }