List of usage examples for com.vaadin.ui Image addStyleName
@Override public void addStyleName(String style)
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }// w w w. jav a 2 s. c o m imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }//from w w w . j a v a 2 s .c o m imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo = null; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public Component getSources(InterestProfile profile) { VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setWidth("100%"); VerticalLayout sourcesLayout = new VerticalLayout(); sourcesLayout.setWidth("100%"); Panel sourcesPanel = new Panel(sourcesLayout); List<CheckBox> checkBoxes = new ArrayList<>(); HashMap<String, GridLayout> sourceLayouts = new HashMap<>(); profile.getSources().entrySet().stream() .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> { Source source = e.getKey(); boolean enabled = e.getValue(); GridLayout sourceLayout = new GridLayout(5, 1); sourceLayout.setSizeFull(); CheckBox sourceSelected = new CheckBox(); sourceSelected.setValue(enabled); sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE); sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue())); checkBoxes.add(sourceSelected); Image sourceLogo = new Image(); sourceLogo.addStyleName("logosmall"); sourceLogo.setSource(new ExternalResource(source.getLogo())); sourceLogo.addClickListener(c -> { sourceSelected.setValue(!sourceSelected.getValue()); profile.getSources().replace(source, sourceSelected.getValue()); });/*from w ww .jav a 2s.co m*/ VerticalLayout layoutLogo = new VerticalLayout(sourceLogo); layoutLogo.setWidth("150px"); layoutLogo.setHeight("50px"); layoutLogo.setMargin(false); layoutLogo.setSpacing(false); layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT); Label labelHeadLine = new Label( source.getCategory().getIcon().getHtml() + " " + source.getName(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H3); Label labelDescription = new Label(source.getDescription(), ContentMode.HTML); labelDescription.setWidth("300px"); PopupView popup = new PopupView(null, labelDescription); Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O); buttonDescription.addClickListener(ce -> { popup.setPopupVisible(true); }); sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription); sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER); sourceLayout.setColumnExpandRatio(2, 5); sourceLayout.setSpacing(true); sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "") .replaceAll("_", ""), sourceLayout); sourcesLayout.addComponent(sourceLayout); }); sourcesPanel.setContent(sourcesLayout); sourcesPanel.setHeight("100%"); sourcesPanel.setCaption(Language.get(Word.SOURCES)); Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s)); windowLayout.addComponent(sourcesPanel); windowLayout.setExpandRatio(sourcesPanel, 1); windowLayout.setSpacing(false); windowLayout.setMargin(false); CheckBox checkBoxSelectAll = new CheckBox(); Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s)); checkBoxSelectAll.setWidth("100%"); checkBoxSelectAll.addValueChangeListener(e -> { profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue()); checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue())); }); TextField textFieldSearch = new TextField(); Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s)); textFieldSearch.setWidth("100%"); textFieldSearch.setMaxLength(255); textFieldSearch.setPlaceholder(Language.get(Word.SEARCH)); textFieldSearch.addValueChangeListener(searchValue -> { sourceLayouts.forEach((sourceName, sourceLayout) -> { if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "") .replaceAll("-", "").replaceAll("_", ""))) { sourcesLayout.removeComponent(sourceLayout); } else { sourcesLayout.addComponent(sourceLayout); } }); }); Label placeholder = new Label(); placeholder.setWidth("100%"); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(true, false, false, false)); footer.addStyleName("menubar"); footer.setWidth("100%"); footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder); footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT); footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER); windowLayout.addComponent(footer); windowLayout.setHeight("350px"); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java
public Component getSources(GroupInterestProfile profile, boolean isAdmin) { VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setWidth("100%"); VerticalLayout sourcesLayout = new VerticalLayout(); sourcesLayout.setWidth("100%"); Panel sourcesPanel = new Panel(sourcesLayout); List<CheckBox> checkBoxes = new ArrayList<>(); HashMap<String, GridLayout> sourceLayouts = new HashMap<>(); profile.getSources().entrySet().stream() .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> { Source source = e.getKey(); boolean enabled = e.getValue(); GridLayout sourceLayout = new GridLayout(5, 1); sourceLayout.setSizeFull(); CheckBox sourceSelected = new CheckBox(); sourceSelected.setValue(enabled); sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE); sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue())); sourceSelected.setEnabled(isAdmin); checkBoxes.add(sourceSelected); Image sourceLogo = new Image(); sourceLogo.addStyleName("logosmall"); sourceLogo.setSource(new ExternalResource(source.getLogo())); if (isAdmin) { sourceLogo.addClickListener(c -> { sourceSelected.setValue(!sourceSelected.getValue()); profile.getSources().replace(source, sourceSelected.getValue()); });/*from ww w.j av a2 s. com*/ } VerticalLayout layoutLogo = new VerticalLayout(sourceLogo); layoutLogo.setWidth("150px"); layoutLogo.setHeight("50px"); layoutLogo.setMargin(false); layoutLogo.setSpacing(false); layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT); Label labelHeadLine = new Label( source.getCategory().getIcon().getHtml() + " " + source.getName(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H3); Label labelDescription = new Label(source.getDescription(), ContentMode.HTML); labelDescription.setWidth("300px"); PopupView popup = new PopupView(null, labelDescription); Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O); buttonDescription.addClickListener(ce -> { popup.setPopupVisible(true); }); sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription); sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER); sourceLayout.setColumnExpandRatio(2, 5); sourceLayout.setSpacing(true); sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "") .replaceAll("_", ""), sourceLayout); sourcesLayout.addComponent(sourceLayout); }); sourcesPanel.setContent(sourcesLayout); sourcesPanel.setHeight("100%"); sourcesPanel.setCaption(Language.get(Word.SOURCES)); Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s)); windowLayout.addComponent(sourcesPanel); windowLayout.setExpandRatio(sourcesPanel, 1); windowLayout.setSpacing(false); windowLayout.setMargin(false); CheckBox checkBoxSelectAll = new CheckBox(); Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s)); checkBoxSelectAll.setWidth("100%"); checkBoxSelectAll.addValueChangeListener(e -> { profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue()); checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue())); }); checkBoxSelectAll.setEnabled(isAdmin); TextField textFieldSearch = new TextField(); Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s)); textFieldSearch.setWidth("100%"); textFieldSearch.setMaxLength(255); textFieldSearch.setPlaceholder(Language.get(Word.SEARCH)); textFieldSearch.addValueChangeListener(searchValue -> { sourceLayouts.forEach((sourceName, sourceLayout) -> { if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "") .replaceAll("-", "").replaceAll("_", ""))) { sourcesLayout.removeComponent(sourceLayout); } else { sourcesLayout.addComponent(sourceLayout); } }); }); Label placeholder = new Label(); placeholder.setWidth("100%"); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(true, false, false, false)); footer.addStyleName("menubar"); footer.setWidth("100%"); footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder); footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT); footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER); windowLayout.addComponent(footer); windowLayout.setHeight("350px"); return windowLayout; }
From source file:edu.kit.dama.ui.admin.LoginInformationBar.java
License:Apache License
/** * Build a menu item and return it./*from ww w. ja va 2 s .c o m*/ * * @param pId The item id. * @param pImage The item image. * * @return The item. */ private Image buildMenuItem(String pId, ThemeResource pImage) { Image item = new Image(null, pImage); item.setId(pId); item.addStyleName("shadow"); item.addStyleName("menu"); item.addStyleName("myclickablecomponent"); item.setWidth("70px"); new HelpExtension().extend(item); return item; }
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Create a new cell for the UI. Each cell contains an image located in the * provided resource and a help label for the cell adverse to it. * Furthermore, a style is provided which can be 'help-left' or 'help-right' * depending on which side the help text should be aligned (help in left col * -> align right).//from ww w .ja v a 2 s .c o m * * @param pResourceString The image resource string. * @param The alignment of the image (TOP_LEFT or TOP_RIGHT, depending on * the column) * @param cellNumber The cell number (0-3) counting from top left to bottom * right * @param pHelp The help string which may contain HTML tags. * @param pStyle The help label style ('help-left' or 'help-right'). * * @return The cell layout. */ private VerticalLayout createCell(String pResourceString, Alignment pAlignment, int cellNumber, String pHelp, String pStyle) { final String cellHeight = "132px"; //create the cell image Image cellImage = new Image(null, new ThemeResource(pResourceString)); cellImage.addStyleName("border"); //create the cell image wrapper, which provides the shadow and this show/hide functionality VerticalLayout imageWrapper = new VerticalLayout(cellImage); imageWrapper.addComponent(cellImage); imageWrapper.setComponentAlignment(cellImage, Alignment.MIDDLE_CENTER); imageWrapper.setWidth(cellHeight); imageWrapper.setHeight(cellHeight); imageWrapper.addStyleName("shadow"); imageWrapper.addStyleName("visible"); //help label for the cell adverse to the current cell Label oppositeCellHelp = new Label(pHelp, ContentMode.HTML); oppositeCellHelp.addStyleName(pStyle); oppositeCellHelp.setSizeFull(); oppositeCellHelp.addStyleName("invisible"); oppositeCellHelp.setHeight(cellHeight); //the cell layout containing image and help label VerticalLayout cell = new VerticalLayout(); cell.addComponent(imageWrapper); cell.setComponentAlignment(imageWrapper, pAlignment); cell.setMargin(true); cell.addComponent(oppositeCellHelp); cell.setComponentAlignment(oppositeCellHelp, Alignment.MIDDLE_CENTER); //define component ids depending on the provided cell number //--------- //| 0 | 1 | //| 2 | 3 | //--------- //Each cell gets the id 'image<cellNumber>' //The currently created wrapper and help label are getting the cellId of the adverse cell (0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2). //These ids are used then by edu.kit.dama.ui.admin.client.HelpConnector to show/hide elements on mouse over. switch (cellNumber) { case 0: cellImage.setId("image0"); //this cell contains the help for cell 1 imageWrapper.setId("image1_wrapper"); oppositeCellHelp.setId("image1_help"); break; case 1: cellImage.setId("image1"); //this cell contains the help for cell 0 imageWrapper.setId("image0_wrapper"); oppositeCellHelp.setId("image0_help"); break; case 2: cellImage.setId("image2"); //this cell contains the help for cell 3 imageWrapper.setId("image3_wrapper"); oppositeCellHelp.setId("image3_help"); break; case 3: cellImage.setId("image3"); //this cell contains the help for cell 2 imageWrapper.setId("image2_wrapper"); oppositeCellHelp.setId("image2_help"); break; } //link the HelpExtension to the image new HelpExtension().extend(cellImage); return cell; }
From source file:edu.nps.moves.mmowgli.components.AvatarChooser.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w ww .j a va 2s .c o m public void initGui() { VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setMargin(true); //test mainLayout.setSpacing(true); MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator(); Label sp; setContent(mainLayout); Panel p = new Panel(imgLay = new HorizontalLayout()); imgLay.setSpacing(true); p.setWidth("100%"); mainLayout.addComponent(p); Collection<?> lis = Avatar.getContainer().getItemIds(); avIdArr = new Object[lis.size()]; int idx = 0; for (Object id : lis) { avIdArr[idx++] = id; if (initSelectedID == null) initSelectedID = id; // sets first one Avatar a = Avatar.getTL(id); Image em = new Image(null, medLoc.locate(a.getMedia())); em.setWidth("95px"); em.setHeight("95px"); em.addClickListener(new ImageClicked()); if (id.equals(initSelectedID)) { em.addStyleName("m-orangeborder5"); lastSel = em; } else em.addStyleName("m-greyborder5"); imgLay.addComponent(em); } butts = new HorizontalLayout(); butts.setWidth("100%"); butts.setSpacing(true); mainLayout.addComponent(butts); butts.addComponent(sp = new Label()); sp.setWidth("1px"); butts.setExpandRatio(sp, 1.0f); NativeButton cancelButt = new NativeButton(); medLoc.decorateCancelButton(cancelButt); butts.addComponent(cancelButt); NativeButton selectButt = new NativeButton(); medLoc.decorateSelectButton(selectButt); butts.addComponent(selectButt); butts.addComponent(sp = new Label("")); sp.setWidth("20px"); mainLayout.addComponent(sp = new Label("")); sp.setHeight("1px"); mainLayout.setExpandRatio(sp, 1.0f); ; cancelButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry public void buttonClick(ClickEvent event) { cancelClick(); } }); selectButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry public void buttonClick(ClickEvent event) { selectClick(); } }); }
From source file:edu.nps.moves.mmowgli.components.AvatarPanel.java
License:Open Source License
@Override public void initGui() { setCaption(caption);//from w ww . j a v a2 s .c o m //setScrollable(true); imgLay = new HorizontalLayout(); setContent(imgLay); // imgLay.setHeight("105px"); imgLay.setSpacing(true); @SuppressWarnings("unchecked") HbnContainer<Avatar> contr = (HbnContainer<Avatar>) HSess.getContainer(Avatar.class); Collection<?> lis = contr.getItemIds(); avIdArr = new Object[lis.size()]; int idx = 0; MediaLocator loc = Mmowgli2UI.getGlobals().mediaLocator(); for (Object id : lis) { avIdArr[idx++] = id; Avatar a = Avatar.getTL(id); Image em = new Image(null, loc.locate(a.getMedia())); em.setWidth("95px"); em.setHeight("95px"); em.addClickListener(new ImageClicked()); em.addStyleName("m-greyborder5"); //m-orangeborder5 imgLay.addComponent(em); } }
From source file:edu.nps.moves.mmowgli.components.AvatarPanel.java
License:Open Source License
public void setSelectedAvatarId(Object selId) { for (int i = 0; i < avIdArr.length; i++) { Object aId = avIdArr[i];//w w w . ja va 2 s.com if (aId.equals(selId)) { if (selectedIdx != null) { Image oldSel = (Image) imgLay.getComponent(selectedIdx); oldSel.removeStyleName("m-orangeborder5"); oldSel.addStyleName("m-greyborder5"); } Image em = (Image) imgLay.getComponent(i); em.removeStyleName("m-greyborder5"); em.addStyleName("m-orangeborder5"); selectedIdx = i; } } }
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) {//ww w . j av a 2 s. co m // messageList can be null if coming in from ActionPlan Object key = HSess.checkInit(); UserListEntry wu = (UserListEntry) message; User u = wu.getUser(); 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); }